@cmmd-center/forge 0.13.127 → 0.13.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.cjs +17 -2
- package/dist/bin.mjs +41 -26
- package/dist/client/assets/{CanvasPanel-Db1Iz4JN.js → CanvasPanel-j0yQxyEH.js} +2 -2
- package/dist/client/assets/{DiffPanel-CqRZidQp.js → DiffPanel-DW-4nhXm.js} +3 -3
- package/dist/client/assets/{DiffPanel.logic-D4K70r-U.js → DiffPanel.logic-CaiJLSzy.js} +2 -2
- package/dist/client/assets/{DiffWorkerPoolProvider-BHmRAZ9V.js → DiffWorkerPoolProvider-DDV64q8E.js} +9 -9
- package/dist/client/assets/PullRequestCodePanel-CPhvQnl6.js +5 -0
- package/dist/client/assets/{ThemeEditorPanel-DTfrlPBc.js → ThemeEditorPanel-DCsxTx0Q.js} +2 -2
- package/dist/client/assets/{Virtualizer-BaK0M9lw.js → Virtualizer-C5HhtAFY.js} +2 -2
- package/dist/client/assets/{WorkerPoolContext-CD9L3Rin.js → WorkerPoolContext-DE6P0yOd.js} +37 -37
- package/dist/client/assets/{cmmdAuthRedirect-BYBGztDm.js → cmmdAuthRedirect-BUp02n05.js} +2 -2
- package/dist/client/assets/{cmmdForgeRuntimeListResource-lbV63vQg.js → cmmdForgeRuntimeListResource-DokzffFK.js} +4 -4
- package/dist/client/assets/{currentForgeWorkspaceStore-Cukj-AKS.js → currentForgeWorkspaceStore-DANo4KV4.js} +2 -2
- package/dist/client/assets/{index-CFdawhcA.js → index-Bo3YIsVh.js} +68 -68
- package/dist/client/assets/index-jrCMls69.css +1 -0
- package/dist/client/assets/notification-completion-vyCCbYsz.mp3 +0 -0
- package/dist/client/assets/notification-input-BJS4voY1.mp3 +0 -0
- package/dist/client/assets/{popover-Cvb1Axgx.js → popover-lOfV58pL.js} +2 -2
- package/dist/client/assets/{scroll-area-DzReJmNn.js → scroll-area-BxupGCij.js} +2 -2
- package/dist/client/assets/{src-BAHvoNAY.js → src-CFUzoLms.js} +2 -2
- package/dist/client/assets/{switch-RuRK1onH.js → switch-wFSVBlXv.js} +2 -2
- package/dist/client/assets/{themePalette-gr6ZYaOx.js → themePalette-NfQV9Yfl.js} +2 -2
- package/dist/client/assets/{toggle-D8xaJAgP.js → toggle-CYJl9GZL.js} +2 -2
- package/dist/client/assets/{toggle-group-CwSbXP07.js → toggle-group-DB8Zelac.js} +2 -2
- package/dist/client/assets/{utils-B4G-Q0s7.js → utils-BQ72yH0H.js} +2 -2
- package/dist/client/index.html +16 -16
- package/dist/forge-build.json +1 -1
- package/dist/{open-2-reBrpv.mjs → open-yHTUkd2Y.mjs} +3 -3
- package/package.json +1 -1
- package/dist/client/assets/PullRequestCodePanel-Bfws9NZf.js +0 -5
- package/dist/client/assets/index-DcAyKQAA.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workspaceReadinessAtom-D6bgTvKb.js","assets/rolldown-runtime-hePW80VL.js","assets/atomRegistry-C1yW8tyM.js","assets/Stream-mUTFnSY9.js","assets/angular-html-B8mrqUL5.js","assets/html-XwrE-1r6.js","assets/javascript-obGGvMPs.js","assets/css-CNuuLpMC.js","assets/angular-ts-Bzix210W.js","assets/scss-YesllqfO.js","assets/apl-Dhin1L29.js","assets/xml-BlnrEAEy.js","assets/java-DdHNQ9hk.js","assets/json-DAgxKhMr.js","assets/astro-B-4NNgOP.js","assets/typescript-BydbNFcO.js","assets/postcss-BXeXVLqQ.js","assets/tsx-CUOciP0b.js","assets/blade-Wr94ul2N.js","assets/html-derivative-i4STDFnl.js","assets/sql-ClgswhA6.js","assets/bsl-BkkzgIyY.js","assets/sdbl-bTVj8UrX.js","assets/c-iCihek07.js","assets/cairo-DLTphjLi.js","assets/python-gzcpVVnB.js","assets/cobol-Cw2-KvLW.js","assets/coffee-CiiSLhB6.js","assets/cpp-DjoE5qBx.js","assets/regexp-DR20uMnK.js","assets/glsl-D5MA2a_X.js","assets/crystal-wCJpIkgB.js","assets/shellscript-Da78Ox-3.js","assets/edge-DCY0a-ow.js","assets/elixir-DP304Xio.js","assets/elm-o4NJxfws.js","assets/erb-BcNYoZVd.js","assets/ruby-2bd251b9.js","assets/haml-CwEpbK1d.js","assets/graphql-Ctjuxyvl.js","assets/jsx-gTgmArGx.js","assets/lua-FONpmTUP.js","assets/yaml-Du_6cdrH.js","assets/erlang-Cphh6RMH.js","assets/markdown-BYOwaDjH.js","assets/fortran-fixed-form-DEKoE2YW.js","assets/fortran-free-form-CYNrtFtB.js","assets/fsharp-D13ZGOAj.js","assets/gdresource-C0sCabJj.js","assets/gdshader-CBce3t8t.js","assets/gdscript-Cp2uCuqX.js","assets/git-commit-BSykSTBG.js","assets/diff-woXpYk--.js","assets/git-rebase-BDPpS8w6.js","assets/glimmer-js-BONyzAsu.js","assets/glimmer-ts-f9c0GCOe.js","assets/hack-7ztQ7Up-.js","assets/handlebars-ryMP1rBR.js","assets/http-kmH8AyfE.js","assets/hurl-DCZHXKU4.js","assets/csv-Dx-8-gkx.js","assets/hxml-B0Qn7Nwc.js","assets/haxe-OTjmBuCE.js","assets/jinja-B-tLrNsM.js","assets/jison-CBjhYtSs.js","assets/julia-CjHxn3vf.js","assets/r-D6UWEOL2.js","assets/just-CZ9bduw9.js","assets/perl-BAov3eih.js","assets/latex-D9bvcAJr.js","assets/tex-0w6-Dtgt.js","assets/liquid-G0MH4h_m.js","assets/marko-DV5GrDmo.js","assets/less-DVTAwKKz.js","assets/mdc-cg1lnqpW.js","assets/nextflow-BJtWHP5T.js","assets/nextflow-groovy-DJMQeKeT.js","assets/nginx-BTMw9COX.js","assets/nim-B6yJ_yaC.js","assets/php-Cg76ANFt.js","assets/pug-DkgDHZci.js","assets/qml-_a-QhfPD.js","assets/razor-D3EoCAik.js","assets/csharp-Ct8U2NOr.js","assets/rst-YTmaoyaq.js","assets/cmake-Bj61d0ZC.js","assets/sas-B6p8-ynO.js","assets/shaderlab-TOUzSsQk.js","assets/hlsl-Cvrh5tZx.js","assets/shellsession-CVsQGYfZ.js","assets/soy-DEd-qcad.js","assets/sparql-D_iOobhT.js","assets/turtle-ByJddavk.js","assets/stata-RoaAgbqU.js","assets/surrealql-DIn4NJsS.js","assets/svelte-Bj3Hmc9F.js","assets/templ-TjxbArHn.js","assets/go-rLFTqkRN.js","assets/ts-tags-DFwAVxhO.js","assets/twig-BbcH-NR0.js","assets/vue-BNi0qJZP.js","assets/vue-html-DkKkQnZL.js","assets/vue-vine-DFaKYU4X.js","assets/stylus-B6D30XZt.js","assets/xsl-BOPS8gLt.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{$ as r,$t as i,Aa as a,An as o,Ar as s,At as c,B as l,Br as u,Bt as d,Ci as f,Dn as p,Ei as m,En as h,Er as g,Fa as _,Fi as v,Fn as y,Gn as b,Gt as x,Ha as ee,Hn as te,Hr as ne,Ht as re,Ia as ie,It as ae,J as oe,Jt as se,Kt as ce,L as le,La as ue,Ln as de,Lt as fe,M as pe,Ma as me,Mr as he,Ni as ge,Nn as _e,Nt as ve,Pi as ye,Pn as be,Pt as xe,Qi as Se,Rn as Ce,Rr as we,Rt as Te,Si as Ee,Ta as De,Tn as Oe,Tr as ke,Tt as Ae,Ua as je,Un as Me,Ur as Ne,Ut as Pe,V as Fe,Va as Ie,Vn as Le,Vr as Re,Vt as ze,W as Be,Wa as Ve,Wn as He,Wr as Ue,Wt as We,X as Ge,Yi as Ke,Yt as qe,Z as Je,Zi as Ye,_ as Xe,_t as Ze,an as Qe,at as $e,bn as et,br as tt,bt as nt,ca as rt,ci as it,ct as at,dn as ot,ea as st,en as ct,et as lt,fi as ut,gi as dt,gn as ft,hn as pt,hr as mt,ht,in as gt,it as _t,ja as vt,jn as yt,jr as bt,jt as xt,ki as St,kr as Ct,kt as wt,li as Tt,ln as Et,m as Dt,mn as Ot,mr as kt,na as At,ni as jt,nt as Mt,oa as Nt,or as Pt,pn as Ft,pt as It,q as Lt,qt as Rt,r as zt,rn as Bt,rr as Vt,rt as Ht,sn as Ut,un as Wt,ut as Gt,vn as Kt,vr as qt,wn as Jt,wr as Yt,wt as Xt,xi as Zt,xn as Qt,y as $t,yi as en,yn as tn,z as nn,zn as rn,zt as an}from"./Stream-mUTFnSY9.js";import{i as on,l as sn,n as cn,o as ln,s as un}from"./atomRegistry-C1yW8tyM.js";import{_n as dn,on as fn}from"./CompositeItem-BxPZ_9BJ.js";import{$ as pn,A as mn,B as hn,Bn as gn,C as _n,D as vn,Dt as yn,G as bn,H as S,Hn as C,Jn as xn,Kn as Sn,L as Cn,Ln as wn,M as Tn,N as En,O as Dn,Q as On,Qt as kn,Rt as An,S as jn,Sn as Mn,T as Nn,Tn as Pn,U as Fn,Un as In,Vn as Ln,Wn as Rn,Wt as zn,X as Bn,Y as Vn,Yt as Hn,Z as Un,_n as Wn,at as Gn,ct as Kn,dn as qn,dt as Jn,fn as Yn,gn as Xn,gt as Zn,hn as Qn,ht as $n,in as er,it as tr,ln as nr,lt as rr,mn as ir,mt as ar,ot as or,pn as sr,qn as cr,rn as lr,st as ur,t as dr,tn as fr,tt as pr,un as mr,ut as hr,vt as gr,w as _r,wn as vr,yn as yr,yt as br,zn as xr}from"./cmmdForgeRuntimeListResource-lbV63vQg.js";import{$t as Sr,A as Cr,At as wr,Bt as Tr,C as Er,Ct as Dr,Dt as Or,En as kr,Et as Ar,G as jr,Gn as Mr,Gt as Nr,Hn as Pr,Ht as Fr,In as w,Jt as Ir,Kn as Lr,Kt as Rr,Lt as zr,Mt as Br,Nn as Vr,Nt as Hr,Ot as Ur,Q as Wr,Qt as Gr,R as Kr,Rt as qr,Sn as Jr,U as Yr,Un as Xr,Ut as Zr,Vn as Qr,Vt as $r,W as ei,Wn as ti,Wt as ni,Xt as ri,Yn as ii,Yt as ai,Zt as oi,_n as si,_t as ci,an as li,b as ui,c as di,cn as fi,dt as pi,en as mi,er as hi,ft as gi,gn as _i,gt as vi,hn as yi,in as bi,j as xi,jt as Si,kn as Ci,l as wi,mt as Ti,nn as Ei,nt as Di,on as Oi,pn as ki,qt as Ai,rt as ji,s as T,sn as Mi,tn as Ni,tt as Pi,ut as Fi,vn as E,vt as Ii,w as Li,x as Ri,xn as zi,yn as Bi,zn as Vi,zt as Hi}from"./src-BAHvoNAY.js";import{$ as Ui,A as Wi,B as Gi,C as Ki,D as qi,E as Ji,F as Yi,G as Xi,H as Zi,I as Qi,J as $i,K as ea,L as ta,N as na,O as ra,P as ia,Q as aa,R as oa,T as sa,U as ca,W as la,X as ua,Y as da,Z as fa,_ as pa,et as ma,it as ha,nt as ga,q as _a,rt as va,tt as ya,w as ba}from"./cmmdAuthRedirect-BYBGztDm.js";import{d as xa,f as Sa,n as Ca,t as wa}from"./utils-B4G-Q0s7.js";import{t as D}from"./preload-helper-Czpn1I53.js";import{a as Ta,i as Ea,n as Da,o as Oa,r as ka,t as Aa}from"./debouncer-BmyJL8Gi.js";import{t as ja}from"./transport-CgH8pQK3.js";import{n as Ma,t as Na}from"./workspaceReadinessAtom-D6bgTvKb.js";import{a as Pa,c as Fa,n as Ia,r as La,s as Ra,u as za}from"./themePalette-gr6ZYaOx.js";function Ba(e){return e[e.length-1]}function Va(e,t){return typeof e==`function`?e(t):e}var Ha=Object.prototype.hasOwnProperty,Ua=Object.prototype.propertyIsEnumerable;function Wa(e){for(let t in e)if(Ha.call(e,t))return!0;return!1}var Ga=()=>Object.create(null),Ka=(e,t)=>qa(e,t,Ga);function qa(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=Za(e)&&Za(i);if(!a&&!(Ya(e)&&Ya(i)))return i;let o=a?e:Ja(e);if(!o)return i;let s=a?i:Ja(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:Ha.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=qa(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function Ja(e){let t=Object.keys(e);if(t.length!==Object.getOwnPropertyNames(e).length)return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;for(let r of n){if(!Ua.call(e,r))return!1;t.push(r)}return t}function Ya(e){if(!Xa(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Xa(n)||!n.hasOwnProperty(`isPrototypeOf`))}function Xa(e){return Object.prototype.toString.call(e)===`[object Object]`}function Za(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Qa(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!Qa(e[r],t[r],n))return!1;return!0}if(Ya(e)&&Ya(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!Qa(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!Qa(e[o],t[o],n)))return!1;return i===a}return!1}var $a=/[\x00-\x1f\x7f"<>`{}]/g;function eo(e){return e.replace($a,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function to(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return eo(t)}var no=[`http:`,`https:`,`mailto:`,`tel:`];function ro(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function io(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=to(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=to(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function ao(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function oo(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function so(){throw Error(`Invariant failed`)}var O=t(Ve(),1),co=O.createContext(null);function lo(e){return O.useContext(co)}var uo=O.createContext(void 0),fo=O.createContext(void 0),po=dn();function mo(e,t){return e===t}function ho(e,t,n=mo){let r=(0,O.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,O.useCallback)(()=>e?.get(),[e]);return(0,po.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var go={};function _o(e,t){let n=O.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=qa(n.current,i):i}}function vo(e){let t=lo(),n=O.useContext(e.from?fo:uo),r=e.from??n,i=t.stores.getMatchStore(r),a=_o(e,t),o=ho(i,e=>e?a(e):go);if(o!==go)return o;(e.shouldThrow??!0)&&so()}function yo(e){return vo({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}var bo=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},xo=new class extends bo{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},So={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Co=new class{#e=So;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function wo(e){setTimeout(e,0)}var To=typeof window>`u`||`Deno`in globalThis;function Eo(){}function Do(e,t){return typeof e==`function`?e(t):e}function Oo(e){return typeof e==`number`&&e>=0&&e!==1/0}function ko(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Ao(e,t){return typeof e==`function`?e(t):e}function jo(e,t){return typeof e==`function`?e(t):e}function Mo(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Po(o,t.options))return!1}else if(!Io(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function No(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Fo(t.options.mutationKey)!==Fo(a))return!1}else if(!Io(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Po(e,t){return(t?.queryKeyHashFn||Fo)(e)}function Fo(e){return JSON.stringify(e,(e,t)=>Vo(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Io(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!Io(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Io(e[r],t[r]))return!1;return!0}return!1}var Lo=Object.prototype.hasOwnProperty;function Ro(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Bo(e)&&Bo(t);if(!r&&!(Vo(e)&&Vo(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Lo.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Ro(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function zo(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Bo(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Vo(e){if(!Ho(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Ho(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Ho(e){return Object.prototype.toString.call(e)===`[object Object]`}function Uo(e){return new Promise(t=>{Co.setTimeout(t,e)})}function Wo(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Ro(e,t)}function Go(e){return e}function Ko(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function qo(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Jo=Symbol();function Yo(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Jo?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Xo(e,t){return typeof e==`function`?e(...t):!!e}function Zo(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var Qo=(()=>{let e=()=>To;return{isServer(){return e()},setIsServer(t){e=t}}})();function $o(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var es=wo;function ts(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=es,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var ns=ts(),rs=new class extends bo{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function is(e){return Math.min(1e3*2**e,3e4)}function as(e){return(e??`online`)!==`online`||rs.isOnline()}var os=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ss(e){let t=!1,n=0,r,i=$o(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new os(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>xo.isFocused()&&(e.networkMode===`always`||rs.isOnline())&&e.canRun(),u=()=>as(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(Qo.isServer()?0:3),o=e.retryDelay??is,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),Uo(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var cs=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Oo(this.gcTime)&&(this.#e=Co.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Qo.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(Co.clearTimeout(this.#e),this.#e=void 0)}};function ls(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Zo(e,()=>t.signal,()=>n=!0)},u=Yo(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?qo:Ko;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?ds:us,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:us(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function us(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ds(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function fs(e,t){return t?us(e,t)!=null:!1}function ps(e,t){return!t||!e.getPreviousPageParam?!1:ds(e,t)!=null}var ms=class extends cs{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=_s(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=_s(this.options);e.data!==void 0&&(this.setState(gs(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Wo(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(Eo).catch(Eo):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>jo(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Jo||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Ao(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!ko(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=Yo(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?ls(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=ss({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof os&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof os){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...hs(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...gs(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),ns.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function hs(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:as(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function gs(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function _s(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var vs=class extends bo{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=$o(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),bs(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return xs(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return xs(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof jo(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!zo(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ss(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||jo(this.options.enabled,this.#t)!==jo(t.enabled,this.#t)||Ao(this.options.staleTime,this.#t)!==Ao(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||jo(this.options.enabled,this.#t)!==jo(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return ws(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Eo)),t}#g(){this.#b();let e=Ao(this.options.staleTime,this.#t);if(Qo.isServer()||this.#r.isStale||!Oo(e))return;let t=ko(this.#r.dataUpdatedAt,e)+1;this.#d=Co.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(Qo.isServer()||jo(this.options.enabled,this.#t)===!1||!Oo(this.#p)||this.#p===0)&&(this.#f=Co.setInterval(()=>{(this.options.refetchIntervalInBackground||xo.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Co.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Co.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&bs(e,t),o=i&&Ss(e,n,t,r);(a||o)&&(l={...l,...hs(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=Wo(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=Wo(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Cs(e,t),refetch:this.refetch,promise:this.#o,isEnabled:jo(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{let e=this.#o=x.promise=$o();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a()}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!zo(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){ns.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function ys(e,t){return jo(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||jo(t.retryOnMount,e)!==!1)}function bs(e,t){return ys(e,t)||e.state.data!==void 0&&xs(e,t,t.refetchOnMount)}function xs(e,t,n){if(jo(t.enabled,e)!==!1&&Ao(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Cs(e,t)}return!1}function Ss(e,t,n,r){return(e!==t||jo(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Cs(e,n)}function Cs(e,t){return jo(t.enabled,e)!==!1&&e.isStaleByTime(Ao(t.staleTime,e))}function ws(e,t){return!zo(e.getCurrentResult(),t)}var k=je(),Ts=O.createContext(void 0),Es=e=>{let t=O.useContext(Ts);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Ds=({client:e,children:t})=>(O.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,k.jsx)(Ts.Provider,{value:e,children:t})),Os=O.createContext(!1),ks=()=>O.useContext(Os);Os.Provider;function As(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var js=O.createContext(As()),Ms=()=>O.useContext(js),Ns=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Xo(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ps=e=>{O.useEffect(()=>{e.clearReset()},[e])},Fs=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Xo(n,[e.error,r])),Is=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Ls=(e,t)=>e.isLoading&&e.isFetching&&!t,Rs=(e,t)=>e?.suspense&&t.isPending,zs=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Bs(e,t,n){let r=ks(),i=Ms(),a=Es(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Is(o),Ns(o,i,s),Ps(i);let l=!a.getQueryCache().get(o.queryHash),[u]=O.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(O.useSyncExternalStore(O.useCallback(e=>{let t=f?u.subscribe(ns.batchCalls(e)):Eo;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),O.useEffect(()=>{u.setOptions(o)},[o,u]),Rs(o,d))throw zs(o,u,i);if(Fs({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!Qo.isServer()&&Ls(d,r)&&(l?zs(o,u,i):s?.promise)?.catch(Eo).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function Vs(e,t){return Bs(e,vs,t)}function Hs(e){return e}var Us=g,Ws=globalThis.Number,Gs=e=>{if(e===`NaN`)return v(NaN);if(e===`Infinity`)return v(1/0);if(e===`-Infinity`)return v(-1/0);if(e.trim()===``)return ye();let t=Ws(e);return Ws.isNaN(t)?ye():v(t)},Ks=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],qs=`~effect/http/HttpClientRequest`,Js={[qs]:qs,...Se,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Nt(this.headers),body:this.body.toJSON()}},pipe(){return Ie(this,arguments)}};function Ys(e,t,n,r,i,a){let o=Object.create(Js);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var Xs=Ys(`GET`,``,Gr,ye(),Fr,ri),Zs=e=>(t,n)=>$s(Xs,{method:e,url:t,...n??void 0}),Qs=Zs(`POST`),$s=_(2,(e,t)=>{let n=e;return t.method&&(n=ec(n,t.method)),t.url&&(n=ac(n,t.url)),t.headers&&(n=nc(n,t.headers)),t.urlParams&&(n=oc(n,t.urlParams)),t.hash&&(n=sc(n,t.hash)),t.body&&(n=cc(n,t.body)),t.accept&&(n=rc(n,t.accept)),t.acceptJson&&(n=ic(n)),n}),ec=_(2,(e,t)=>Ys(t,e.url,e.urlParams,e.hash,e.headers,e.body)),tc=_(3,(e,t,n)=>Ys(e.method,e.url,e.urlParams,e.hash,Ir(e.headers,t,n),e.body)),nc=_(2,(e,t)=>Ys(e.method,e.url,e.urlParams,e.hash,ai(e.headers,t),e.body)),rc=_(2,(e,t)=>tc(e,`Accept`,t)),ic=rc(`application/json`),ac=_(2,(e,t)=>{if(typeof t==`string`)return Ys(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Sr(n.searchParams),i=Zt(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Ys(e.method,n.toString(),r,i,e.headers,e.body)}),oc=_(2,(e,t)=>Ys(e.method,e.url,Ni(e.urlParams,t),e.hash,e.headers,e.body)),sc=_(2,(e,t)=>Ys(e.method,e.url,e.urlParams,v(t),e.headers,e.body)),cc=_(2,(e,t)=>{let n=e.headers;return t._tag===`Empty`||t._tag===`FormData`?n=Ai(Ai(n,`Content-Type`),`Content-length`):(t.contentType&&(n=Ir(n,`content-type`,t.contentType)),t.contentLength!==void 0&&(n=Ir(n,`content-length`,t.contentLength.toString()))),Ys(e.method,e.url,e.urlParams,e.hash,n,t)}),lc=e=>ni({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${ge(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),uc=`~effect/http/HttpClient`,dc=Tt(`effect/HttpClient`),fc=_(2,(e,t)=>mc(n=>t(e.postprocess(n)),e.preprocess)),pc=fc(Mt(qr)),mc=(e,t)=>{let n=Object.create(hc);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},hc={[uc]:uc,pipe(){return Ie(this,arguments)},...Se,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(Ks.map(([e,t])=>[t,function(t,n){return this.execute(Zs(e)(t,n))}]))},gc=e=>mc(t=>Mt(t,t=>Kt(n=>{let i=Cc.get(t),a=i??new AbortController,o=mi(t.url,t.urlParams,m(t.hash));if(jt(o))return r(new Ei({reason:new bi({request:t,cause:o.failure})}));let s=o.success;if(n.getRef(Ct)||n.getRef(vc)(t)){let r=e(t,s,a.signal,n);return i?r:Ft(e=>Ae(e(r),{onSuccess(e){return Sc.register(e,a),ct(new wc(e,a))},onFailure(e){return kt(e)&&a.abort(),lt(e)}}))}return pt(n.getRef(bc)(t),{kind:`client`},r=>{r.attribute(`http.request.method`,t.method),r.attribute(`server.address`,s.origin),s.port!==``&&r.attribute(`server.port`,+s.port),r.attribute(`url.full`,s.toString()),r.attribute(`url.path`,s.pathname),r.attribute(`url.scheme`,s.protocol.slice(0,-1));let o=s.search.slice(1);o!==``&&r.attribute(`url.query`,o);let c=n.getRef($r),l=Rr(t.headers,c);for(let e in l)r.attribute(`http.request.header.${e}`,String(l[e]));return t=n.getRef(yc)?nc(t,lc(r)):t,Ft(o=>o(e(t,s,a.signal,n)).pipe(tn(r,{captureStackTrace:!1}),Ae({onSuccess:e=>{r.attribute(`http.response.status_code`,e.status);let t=Rr(e.headers,c);for(let e in t)r.attribute(`http.response.header.${e}`,String(t[e]));return i?ct(e):(Sc.register(e,a),ct(new wc(e,a)))},onFailure(e){return!i&&kt(e)&&a.abort(),lt(e)}})))})})),ct),_c=_(2,(e,t)=>{let n=Oe(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,i=n?t:t.schedule,o=i&&h(i),s=n?void 0:t.times;return fc(e,ie(r===`errors-only`?ue:ae({schedule:o,times:s,while:Dc}),r===`response-only`?ue:fe({while:n||t.while===void 0?Tc:a(Tc,t.while),schedule:i,times:s})))}),vc=it(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>vt}),yc=it(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:me}),bc=it(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),xc=e=>yt(dc)(oe(t=>nt(e,e=>fc(e,Ot(e=>dt(t,e)))))),Sc=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),Cc=new WeakMap,wc=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[zr]=zr;[Tr]=Tr;applyInterrupt(e){return Bt(()=>(Sc.unregister(this.original),wt(e,()=>gt(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return Xe(()=>(Sc.unregister(this.original),zt(this.original.stream,gt(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[st](){return this.original[st]()}pipe(){return Ie(this,arguments)}},Tc=e=>tt(e)||Ec(e),Ec=e=>Oi(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&Dc(e.reason.response)),Dc=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504,Oc=`~effect/ManagedRuntime`,kc=(e,t)=>{let n=t?.memoMap??_e(),r=He(`parallel`),i=te(r,`sequential`),a={onFiberStart:le(r)},s=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,c,l=Kt(t=>(c||=d(Qe(o(e,n,i),e=>gt(()=>{u.cachedContext=e})),{...a,scheduler:t.currentScheduler}),_t(pe(c)))),u={[Oc]:Oc,memoMap:n,scope:r,contextEffect:l,cachedContext:void 0,context(){return u.cachedContext===void 0?re(u.contextEffect):Promise.resolve(u.cachedContext)},dispose(){return re(u.disposeEffect)},disposeEffect:Bt(()=>(u.contextEffect=Ge(`ManagedRuntime disposed`),u.cachedContext=void 0,Le(u.scope,Pt))),runFork(e,t){return u.cachedContext===void 0?d(Ac(u,e),s(t)):ze(u.cachedContext)(e,s(t))},runCallback(e,t){return u.cachedContext===void 0?Te(Ac(u,e),s(t)):an(u.cachedContext)(e,s(t))},runSyncExit(e){return u.cachedContext===void 0?Rt(Ac(u,e)):se(u.cachedContext)(e)},runSync(e){return u.cachedContext===void 0?ce(Ac(u,e)):qe(u.cachedContext)(e)},runPromiseExit(e,t){return u.cachedContext===void 0?Pe(Ac(u,e),s(t)):We(u.cachedContext)(e,s(t))},runPromise(e,t){return u.cachedContext===void 0?re(Ac(u,e),s(t)):x(u.cachedContext)(e,s(t))}};return u};function Ac(e,t){return Mt(e.contextEffect,e=>ve(t,e))}var jc={accept:!1,observe:!1,missingFrameCount:0,startsNewStream:!1};function Mc(e){let t=e===!0;return{accept:t,observe:t,missingFrameCount:0,startsNewStream:t}}function Nc(e,t){let n=e.streamGeneration===void 0&&e.streamId===void 0,r=t.streamGeneration!==void 0||t.streamId!==void 0;return n&&r?Mc(t.keyframe):null}function Pc(e,t){return e.streamGeneration===void 0||t.streamGeneration===void 0?null:t.streamGeneration<e.streamGeneration?jc:t.streamGeneration>e.streamGeneration?Mc(t.keyframe):null}function Fc(e,t){if(!e.streamId||!t.streamId)return null;if(e.streamId!==t.streamId)return Mc(t.keyframe);if(t.sequence<=e.observedSequence)return jc;let n=Math.max(0,t.sequence-e.observedSequence-1);return{accept:n===0||t.keyframe===!0,observe:!0,missingFrameCount:n,startsNewStream:!1}}function Ic(e,t){if(t.sequence>e.acceptedSequence)return{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1};if(!e.acceptedCapturedAt)return jc;let n=Date.parse(e.acceptedCapturedAt),r=Date.parse(t.capturedAt);return Number.isNaN(n)||Number.isNaN(r)||r<=n?jc:{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1}}function Lc(e,t){return Nc(e,t)??Pc(e,t)??Fc(e,t)??Ic(e,t)}function Rc(e,t){let n=Lc(e,t);if(!n.observe)return{accept:n.accept,observe:n.observe,missingFrameCount:n.missingFrameCount,state:e};let r=n.startsNewStream?t.sequence:Math.max(e.observedSequence,t.sequence),i={...e,observedSequence:r,gapCount:e.gapCount+n.missingFrameCount},a=n.accept?{...i,acceptedSequence:t.sequence,acceptedCapturedAt:t.capturedAt,...t.streamId?{streamId:t.streamId}:{},...t.streamGeneration===void 0?{}:{streamGeneration:t.streamGeneration}}:i;return{accept:n.accept,observe:n.observe,missingFrameCount:n.missingFrameCount,state:a}}function zc(e){return{_tag:`Value`,value:e}}function Bc(e,t){return{_tag:`Record`,keys:e,value:t}}function Vc(e,t){return{_tag:`Array`,length:e,value:t}}hi(`SourceError`);var Hc=it(`effect/ConfigProvider`,{defaultValue:()=>Gc()}),Uc={...Ke,toJSON(){return{_id:`ConfigProvider`}}};function Wc(e,t,n){let r=Object.create(Uc);return r.get=e,r.mapInput=t,r.prefix=n,r.load=r=>(t&&(r=t(r)),n&&(r=[...n,...r]),e(r)),r}function Gc(e){let t=e?.env??{APP_VERSION:`0.13.4`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HOSTED_APP_CHANNEL:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:`c7fe2d96f51605b303a42c585157e3bc4d4af889`,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.13.4+c7fe2d96f51605b303a42c585157e3bc4d4af889`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=Kc(t);return Wc(e=>ct(Jc(n,t,e)))}function Kc(e){let t={};for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let e=n.split(`_`),i=t;for(let t of e)i.children??={},i=i.children[t]??={};i.value=r}return t}var qc=/^(0|[1-9][0-9]*)$/;function Jc(e,t,n){let r=t[n.map(String).join(`_`)],i=Yc(e,n),a=i?.children?Object.keys(i.children):[];return a.length===0?r===void 0?void 0:zc(r):a.every(e=>qc.test(e))?Vc(Math.max(...a.map(e=>parseInt(e,10)))+1,r):Bc(new Set(a),r)}function Yc(e,t){if(t.length===0)return e;let n=e;for(let e of t)if(n=n?.children?.[String(e)],!n)return;return n}var Xc=`~effect/Config`,Zc=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},Qc={...Ke,...Ye,[Xc]:Xc,asEffect(){return Mt(Hc.asEffect(),e=>this.parse(e))},toJSON(){return{_id:`Config`}}};function $c(e){let t=Object.create(Qc);return t.parse=e,t}var el=$e(function*(e,t){let n=yield*e.load(t);if(n!==void 0)switch(n._tag){case`Value`:return n.value;case`Record`:{if(n.value!==void 0)return n.value;let r={};for(let i of n.keys){let n=yield*el(e,[...t,i]);n!==void 0&&(r[i]=n)}return r}case`Array`:{if(n.value!==void 0)return n.value;let r=[];for(let i=0;i<n.length;i++)r.push(yield*el(e,[...t,i]));return r}}}),tl=$e(function*(e,t,n){switch(e._tag){case`Objects`:{let r={};for(let i of e.propertySignatures){let e=i.name;if(typeof e==`string`){let a=yield*tl(i.type,t,[...n,e]);a!==void 0&&(r[e]=a)}}if(e.indexSignatures.length>0){let i=yield*t.load(n);if(i&&i._tag===`Record`)for(let a of e.indexSignatures){let e=Pr(a.parameter);for(let o of i.keys)if(!Object.hasOwn(r,o)&&e(o)){let e=yield*tl(a.type,t,[...n,o]);e!==void 0&&(r[o]=e)}}}return r}case`Arrays`:{let r=yield*t.load(n);if(r&&r._tag===`Value`)return r.value;let i=[];for(let r=0;r<e.elements.length;r++)i.push(yield*tl(e.elements[r],t,[...n,r]));return i}case`Union`:return yield*el(t,n);case`Suspend`:return yield*tl(e.thunk(),t,n);default:{let e=yield*t.load(n);return e===void 0?void 0:e._tag===`Value`||e._tag===`Record`&&e.value!==void 0||e._tag===`Array`&&e.value!==void 0?e.value:void 0}}});function nl(e,t){let n=Vi(e),r=Xr(n),i=Mr(n.ast),a=typeof t==`string`?[t]:t??[];return $c(e=>{let t=e.prefix?[...e.prefix,...a]:a;return tl(i,e,a).pipe(Ht(e=>r(e).pipe(Xt(e=>new Qr(t.length>0?new ii(t,e):e)))),Xt(e=>new Zc(e)))})}var rl=(e,t,n)=>{let r=si(e,t),i=E.pipe(kr(si(E,E),Lr(n)),kr(r));return Jr([r,i])},A=ee();function il(e){return new Promise(t=>globalThis.setTimeout(t,e))}function al(){let e=Error(`The environment connection attempt was cancelled.`);return e.name=`AbortError`,e}function ol(e){if(e?.aborted)throw al()}function sl(e,t){return t?t.aborted?Promise.reject(al()):new Promise((n,r)=>{let i=()=>r(al());t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>{t.removeEventListener(`abort`,i)})}):e}function cl(e,t){return t?t.aborted?Promise.reject(al()):new Promise((n,r)=>{let i=globalThis.setTimeout(()=>{t.removeEventListener(`abort`,a),n()},e),a=()=>{globalThis.clearTimeout(i),r(al())};t.addEventListener(`abort`,a,{once:!0})}):il(e)}var ll=Object.freeze({connectionState:`disconnected`,authState:`unknown`,lastError:null,lastErrorAt:null,role:null,descriptor:null,serverConfig:null,connectedAt:null,disconnectedAt:null,providerAuthority:null}),ul=()=>({...ll}),j=Oa()(e=>({byId:{},ensure:t=>e(e=>e.byId[t]?e:{byId:{...e.byId,[t]:ul()}}),patch:(t,n)=>e(e=>({byId:{...e.byId,[t]:{...e.byId[t]??ul(),...n}}})),clear:t=>e(e=>{let{[t]:n,...r}=e.byId;return{byId:r}}),reset:()=>e({byId:{}})}));function dl(e){let t=tr(e.environmentId);if(t?.lastAuthenticatedPullRequestCapability!==void 0)return{...e,lastAuthenticatedPullRequestCapability:t.lastAuthenticatedPullRequestCapability};let n=j.getState().byId?.[e.environmentId];return n?.authState===`authenticated`&&n.descriptor?{...e,lastAuthenticatedPullRequestCapability:n.descriptor.capabilities.pullRequests===!0}:e}function fl(e){return!!e.runtimeId?.trim()||yr(e.environmentId).isCloud}function pl(e,t){return e.environmentId===t.environmentId&&e.httpBaseUrl===t.httpBaseUrl&&e.wsBaseUrl===t.wsBaseUrl&&e.runtimeId===t.runtimeId&&e.cmmdOrganizationId===t.cmmdOrganizationId}function ml(e){return e.replacedRecord===null&&e.existing!==null&&pl(e.existing,e.record)}function hl(e){let t=e.replacesEnvironmentId?Ur.make(e.replacesEnvironmentId):null,n=t&&t!==e.environmentId?tr(t):null;return{existing:tr(e.environmentId)??n,replacedRecord:n}}async function gl(e){return{records:ur(),bearerToken:e?await rr(e.environmentId):null}}async function _l(e){let t=e.replacedRecord?.environmentId??e.record.environmentId;await ir(e.rollback.records),await hr(e.record.environmentId).catch(()=>void 0),e.rollback.bearerToken&&await Zn(t,e.rollback.bearerToken)}async function vl(e){try{e.replacedRecord?await Jn(e.replacedRecord.environmentId,e.record):await Kn(e.record),ol(e.signal),await hr(e.record.environmentId),e.replacedRecord&&await hr(e.replacedRecord.environmentId),ol(e.signal)}catch(t){try{await _l(e)}catch(e){let n=AggregateError([t,e],`Cloud Environment rollback failed.`);throw n.cause=t,n}throw t}}function yl(e){return{lastError:e instanceof Error?e.message:String(e),lastErrorAt:new Date().toISOString()}}var bl=new Map;function xl(e,t){return e.acquire(t?{signal:t}:{})}function Sl(e,t){bl.set(e,t)}function Cl(e){return bl.has(e)}function wl(e,t){let n=bl.get(e);if(t&&n!==t){t.dispose();return}n?.dispose(),bl.delete(e)}async function Tl(e){let t=bl.get(e);if(t)return(await t.acquire()).bearerToken;let n=tr(e);return n&&fl(n)?null:rr(e)}function El(){return{executionCount:0,isPending:!1,lastArgs:void 0,lastExecutionTime:0,nextExecutionTime:0,status:`idle`,maybeExecuteCount:0}}var Dl={enabled:!0,leading:!0,trailing:!0,wait:0},Ol=class{#e;constructor(e,t){this.fn=e,this.store=new Ea(El()),this.setOptions=e=>{this.options={...this.options,...e},this.#n()||this.cancel()},this.#t=e=>{this.store.setState(t=>{let n={...t,...e},{isPending:r}=n;return{...n,status:this.#n()?r?`pending`:`idle`:`disabled`}}),Da(`Throttler`,this)},this.#n=()=>!!Ta(this.options.enabled,this),this.#r=()=>Ta(this.options.wait,this),this.maybeExecute=(...e)=>{this.#t({maybeExecuteCount:this.store.state.maybeExecuteCount+1});let t=Date.now(),n=t-this.store.state.lastExecutionTime,r=this.#r();if(this.options.leading&&n>=r)this.#i(...e);else if(this.#t({lastArgs:e}),!this.#e&&this.options.trailing){let e=r-(this.store.state.lastExecutionTime?t-this.store.state.lastExecutionTime:0);this.#t({isPending:!0}),this.#e=setTimeout(()=>{let{lastArgs:e}=this.store.state;e!==void 0&&this.#i(...e)},e)}},this.#i=(...e)=>{if(!this.#n())return;this.fn(...e);let t=Date.now(),n=t+this.#r();this.#a(),this.#t({executionCount:this.store.state.executionCount+1,lastExecutionTime:t,nextExecutionTime:n,isPending:!1,lastArgs:void 0}),this.options.onExecute?.(e,this),setTimeout(()=>{this.store.state.isPending||this.#t({nextExecutionTime:void 0})},this.#r())},this.flush=()=>{this.store.state.isPending&&this.store.state.lastArgs&&this.#i(...this.store.state.lastArgs)},this.#a=()=>{this.#e&&=(clearTimeout(this.#e),void 0)},this.cancel=()=>{this.#a(),this.#t({lastArgs:void 0,isPending:!1})},this.reset=()=>{this.#t(El())},this.key=t.key,this.options={...Dl,...t},this.#t(this.options.initialState??{}),this.key&&ka.on(`d-Throttler`,e=>{e.payload.key===this.key&&(this.#t(e.payload.store.state),this.setOptions(e.payload.options))})}#t;#n;#r;#i;#a},kl={all:[`projects`],searchContents:(e,t,n,r,i,a,o)=>[`projects`,`search-contents`,e??null,t,n,r,i,a,o],searchEntries:(e,t,n,r)=>[`projects`,`search-entries`,e??null,t,n,r]},Al={all:[`providers`],checkpointDiff:e=>[`providers`,`checkpointDiff`,e.environmentId??null,e.threadId,e.fromTurnCount,e.toTurnCount,e.cacheScope??null]};function jl(e){let t=null,n=!1;function r(){return t}function i(){n=!0,t?.queryInvalidationThrottler.maybeExecute()}function a(){t?.stop(),t=null}function o(r){if(t?.queryClient===r)return t.refCount+=1,()=>{!t||t.queryClient!==r||(--t.refCount,t.refCount===0&&a())};a(),n=!1;let i=new Ol(()=>{n&&(n=!1,r.invalidateQueries({queryKey:Al.all}),r.invalidateQueries({queryKey:kl.all}))},{wait:100,leading:!1,trailing:!0});e.createPrimaryEnvironmentConnection(),ta().catch(()=>void 0);let o=ar.subscribe(()=>{Gn()&&e.syncSavedEnvironmentConnections(ur())});return $n().then(()=>e.syncSavedEnvironmentConnections(ur())).catch(()=>void 0),t={queryClient:r,queryInvalidationThrottler:i,refCount:1,stop:()=>{o(),i.cancel()}},()=>{!t||t.queryClient!==r||(--t.refCount,t.refCount===0&&a())}}return{readActiveService:r,notifyProviderInvalidation:i,stopActiveService:a,start:o}}var Ml=class extends Error{status;constructor(e,t){super(e),this.name=`RemoteEnvironmentAuthHttpError`,this.status=t}};function Nl(e,t){let n=new URL(e);return n.pathname=`${n.pathname.endsWith(`/`)?n.pathname.slice(0,-1):n.pathname}${t.startsWith(`/`)?t:`/${t}`}`,n.search=``,n.hash=``,n.toString()}async function Pl(e,t){let n=await e.text();if(!n)return t;try{let e=JSON.parse(n);if(typeof e.error==`string`&&e.error.length>0)return e.error}catch{}return n}async function Fl(e){let t=Nl(e.httpBaseUrl,e.pathname),n;try{n=await fetch(t,{method:e.method??`GET`,headers:{...e.body===void 0?{}:{"content-type":`application/json`},...e.bearerToken?{authorization:`Bearer ${e.bearerToken}`}:{}},...e.body===void 0?{}:{body:JSON.stringify(e.body)},...e.signal?{signal:e.signal}:{}})}catch(e){throw Error(`Failed to fetch remote auth endpoint ${t} (${e.message}).`,{cause:e})}if(!n.ok)throw new Ml(await Pl(n,`Remote auth request failed (${n.status}).`),n.status);return await n.json()}async function Il(e){return Fl({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/session`,bearerToken:e.bearerToken,...e.signal?{signal:e.signal}:{}})}async function Ll(e){return Fl({httpBaseUrl:e.httpBaseUrl,pathname:`/.well-known/forge/environment`,...e.bearerToken?{bearerToken:e.bearerToken}:{}})}async function Rl(e){return Fl({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/ws-token`,method:`POST`,bearerToken:e.bearerToken})}async function zl(e){let t=new URL(e.wsBaseUrl,window.location.origin);if(e.runtimeTicket)return t.searchParams.set(`runtimeTicket`,e.runtimeTicket),t.searchParams.delete(`wsToken`),t.toString();let n=await Rl({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken});return t.searchParams.set(`wsToken`,n.token),t.toString()}function Bl(e,t){if(t){Ma(t,e);return}Na(e)}function Vl(e){let t=null,n=[];for(let r of e.split(/\r?\n/)){if(r.startsWith(`event:`)){t=r.slice(6).trim();continue}r.startsWith(`data:`)&&n.push(r.slice(5).trimStart())}return{eventName:t,data:n.join(`
|
|
2
|
+
import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{$ as r,$t as i,Aa as a,An as o,Ar as s,At as c,B as l,Br as u,Bt as d,Ci as f,Dn as p,Ei as m,En as h,Er as g,Fa as _,Fi as v,Fn as y,Gn as b,Gt as x,Ha as ee,Hn as te,Hr as ne,Ht as re,Ia as ie,It as ae,J as oe,Jt as se,Kt as ce,L as le,La as ue,Ln as de,Lt as fe,M as pe,Ma as me,Mr as he,Ni as ge,Nn as _e,Nt as ve,Pi as ye,Pn as be,Pt as xe,Qi as Se,Rn as Ce,Rr as we,Rt as Te,Si as Ee,Ta as De,Tn as Oe,Tr as ke,Tt as Ae,Ua as je,Un as Me,Ur as Ne,Ut as Pe,V as Fe,Va as Ie,Vn as Le,Vr as Re,Vt as ze,W as Be,Wa as Ve,Wn as He,Wr as Ue,Wt as We,X as Ge,Yi as Ke,Yt as qe,Z as Je,Zi as Ye,_ as Xe,_t as Ze,an as Qe,at as $e,bn as et,br as tt,bt as nt,ca as rt,ci as it,ct as at,dn as ot,ea as st,en as ct,et as lt,fi as ut,gi as dt,gn as ft,hn as pt,hr as mt,ht,in as gt,it as _t,ja as vt,jn as yt,jr as bt,jt as xt,ki as St,kr as Ct,kt as wt,li as Tt,ln as Et,m as Dt,mn as Ot,mr as kt,na as At,ni as jt,nt as Mt,oa as Nt,or as Pt,pn as Ft,pt as It,q as Lt,qt as Rt,r as zt,rn as Bt,rr as Vt,rt as Ht,sn as Ut,un as Wt,ut as Gt,vn as Kt,vr as qt,wn as Jt,wr as Yt,wt as Xt,xi as Zt,xn as Qt,y as $t,yi as en,yn as tn,z as nn,zn as rn,zt as an}from"./Stream-mUTFnSY9.js";import{i as on,l as sn,n as cn,o as ln,s as un}from"./atomRegistry-C1yW8tyM.js";import{_n as dn,on as fn}from"./CompositeItem-BxPZ_9BJ.js";import{$ as pn,A as mn,B as hn,Bn as gn,C as _n,D as vn,Dt as yn,G as bn,H as S,Hn as C,Jn as xn,Kn as Sn,L as Cn,Ln as wn,M as Tn,N as En,O as Dn,Q as On,Qt as kn,Rt as An,S as jn,Sn as Mn,T as Nn,Tn as Pn,U as Fn,Un as In,Vn as Ln,Wn as Rn,Wt as zn,X as Bn,Y as Vn,Yt as Hn,Z as Un,_n as Wn,at as Gn,ct as Kn,dn as qn,dt as Jn,fn as Yn,gn as Xn,gt as Zn,hn as Qn,ht as $n,in as er,it as tr,ln as nr,lt as rr,mn as ir,mt as ar,ot as or,pn as sr,qn as cr,rn as lr,st as ur,t as dr,tn as fr,tt as pr,un as mr,ut as hr,vt as gr,w as _r,wn as vr,yn as yr,yt as br,zn as xr}from"./cmmdForgeRuntimeListResource-DokzffFK.js";import{$t as Sr,A as Cr,At as wr,Bt as Tr,C as Er,Ct as Dr,Dt as Or,En as kr,Et as Ar,G as jr,Gn as Mr,Gt as Nr,Hn as Pr,Ht as Fr,In as w,Jt as Ir,Kn as Lr,Kt as Rr,Lt as zr,Mt as Br,Nn as Vr,Nt as Hr,Ot as Ur,Q as Wr,Qt as Gr,R as Kr,Rt as qr,Sn as Jr,U as Yr,Un as Xr,Ut as Zr,Vn as Qr,Vt as $r,W as ei,Wn as ti,Wt as ni,Xt as ri,Yn as ii,Yt as ai,Zt as oi,_n as si,_t as ci,an as li,b as ui,c as di,cn as fi,dt as pi,en as mi,er as hi,ft as gi,gn as _i,gt as vi,hn as yi,in as bi,j as xi,jt as Si,kn as Ci,l as wi,mt as Ti,nn as Ei,nt as Di,on as Oi,pn as ki,qt as Ai,rt as ji,s as T,sn as Mi,tn as Ni,tt as Pi,ut as Fi,vn as E,vt as Ii,w as Li,x as Ri,xn as zi,yn as Bi,zn as Vi,zt as Hi}from"./src-CFUzoLms.js";import{$ as Ui,A as Wi,B as Gi,C as Ki,D as qi,E as Ji,F as Yi,G as Xi,H as Zi,I as Qi,J as $i,K as ea,L as ta,N as na,O as ra,P as ia,Q as aa,R as oa,T as sa,U as ca,W as la,X as ua,Y as da,Z as fa,_ as pa,et as ma,it as ha,nt as ga,q as _a,rt as va,tt as ya,w as ba}from"./cmmdAuthRedirect-BUp02n05.js";import{d as xa,f as Sa,n as Ca,t as wa}from"./utils-BQ72yH0H.js";import{t as D}from"./preload-helper-Czpn1I53.js";import{a as Ta,i as Ea,n as Da,o as Oa,r as ka,t as Aa}from"./debouncer-BmyJL8Gi.js";import{t as ja}from"./transport-CgH8pQK3.js";import{n as Ma,t as Na}from"./workspaceReadinessAtom-D6bgTvKb.js";import{a as Pa,c as Fa,n as Ia,r as La,s as Ra,u as za}from"./themePalette-NfQV9Yfl.js";function Ba(e){return e[e.length-1]}function Va(e,t){return typeof e==`function`?e(t):e}var Ha=Object.prototype.hasOwnProperty,Ua=Object.prototype.propertyIsEnumerable;function Wa(e){for(let t in e)if(Ha.call(e,t))return!0;return!1}var Ga=()=>Object.create(null),Ka=(e,t)=>qa(e,t,Ga);function qa(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=Za(e)&&Za(i);if(!a&&!(Ya(e)&&Ya(i)))return i;let o=a?e:Ja(e);if(!o)return i;let s=a?i:Ja(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:Ha.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=qa(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function Ja(e){let t=Object.keys(e);if(t.length!==Object.getOwnPropertyNames(e).length)return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;for(let r of n){if(!Ua.call(e,r))return!1;t.push(r)}return t}function Ya(e){if(!Xa(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Xa(n)||!n.hasOwnProperty(`isPrototypeOf`))}function Xa(e){return Object.prototype.toString.call(e)===`[object Object]`}function Za(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Qa(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!Qa(e[r],t[r],n))return!1;return!0}if(Ya(e)&&Ya(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!Qa(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!Qa(e[o],t[o],n)))return!1;return i===a}return!1}var $a=/[\x00-\x1f\x7f"<>`{}]/g;function eo(e){return e.replace($a,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function to(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return eo(t)}var no=[`http:`,`https:`,`mailto:`,`tel:`];function ro(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function io(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=to(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=to(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function ao(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function oo(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function so(){throw Error(`Invariant failed`)}var O=t(Ve(),1),co=O.createContext(null);function lo(e){return O.useContext(co)}var uo=O.createContext(void 0),fo=O.createContext(void 0),po=dn();function mo(e,t){return e===t}function ho(e,t,n=mo){let r=(0,O.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,O.useCallback)(()=>e?.get(),[e]);return(0,po.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var go={};function _o(e,t){let n=O.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=qa(n.current,i):i}}function vo(e){let t=lo(),n=O.useContext(e.from?fo:uo),r=e.from??n,i=t.stores.getMatchStore(r),a=_o(e,t),o=ho(i,e=>e?a(e):go);if(o!==go)return o;(e.shouldThrow??!0)&&so()}function yo(e){return vo({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}var bo=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},xo=new class extends bo{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},So={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Co=new class{#e=So;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function wo(e){setTimeout(e,0)}var To=typeof window>`u`||`Deno`in globalThis;function Eo(){}function Do(e,t){return typeof e==`function`?e(t):e}function Oo(e){return typeof e==`number`&&e>=0&&e!==1/0}function ko(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Ao(e,t){return typeof e==`function`?e(t):e}function jo(e,t){return typeof e==`function`?e(t):e}function Mo(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Po(o,t.options))return!1}else if(!Io(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function No(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Fo(t.options.mutationKey)!==Fo(a))return!1}else if(!Io(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Po(e,t){return(t?.queryKeyHashFn||Fo)(e)}function Fo(e){return JSON.stringify(e,(e,t)=>Vo(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Io(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!Io(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Io(e[r],t[r]))return!1;return!0}return!1}var Lo=Object.prototype.hasOwnProperty;function Ro(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Bo(e)&&Bo(t);if(!r&&!(Vo(e)&&Vo(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Lo.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Ro(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function zo(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Bo(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Vo(e){if(!Ho(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Ho(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Ho(e){return Object.prototype.toString.call(e)===`[object Object]`}function Uo(e){return new Promise(t=>{Co.setTimeout(t,e)})}function Wo(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Ro(e,t)}function Go(e){return e}function Ko(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function qo(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Jo=Symbol();function Yo(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Jo?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Xo(e,t){return typeof e==`function`?e(...t):!!e}function Zo(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var Qo=(()=>{let e=()=>To;return{isServer(){return e()},setIsServer(t){e=t}}})();function $o(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var es=wo;function ts(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=es,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var ns=ts(),rs=new class extends bo{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function is(e){return Math.min(1e3*2**e,3e4)}function as(e){return(e??`online`)!==`online`||rs.isOnline()}var os=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ss(e){let t=!1,n=0,r,i=$o(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new os(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>xo.isFocused()&&(e.networkMode===`always`||rs.isOnline())&&e.canRun(),u=()=>as(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(Qo.isServer()?0:3),o=e.retryDelay??is,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),Uo(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var cs=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Oo(this.gcTime)&&(this.#e=Co.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Qo.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(Co.clearTimeout(this.#e),this.#e=void 0)}};function ls(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Zo(e,()=>t.signal,()=>n=!0)},u=Yo(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?qo:Ko;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?ds:us,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:us(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function us(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ds(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function fs(e,t){return t?us(e,t)!=null:!1}function ps(e,t){return!t||!e.getPreviousPageParam?!1:ds(e,t)!=null}var ms=class extends cs{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=_s(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=_s(this.options);e.data!==void 0&&(this.setState(gs(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Wo(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(Eo).catch(Eo):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>jo(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Jo||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Ao(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!ko(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=Yo(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?ls(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=ss({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof os&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof os){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...hs(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...gs(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),ns.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function hs(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:as(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function gs(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function _s(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var vs=class extends bo{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=$o(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),bs(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return xs(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return xs(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof jo(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!zo(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ss(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||jo(this.options.enabled,this.#t)!==jo(t.enabled,this.#t)||Ao(this.options.staleTime,this.#t)!==Ao(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||jo(this.options.enabled,this.#t)!==jo(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return ws(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Eo)),t}#g(){this.#b();let e=Ao(this.options.staleTime,this.#t);if(Qo.isServer()||this.#r.isStale||!Oo(e))return;let t=ko(this.#r.dataUpdatedAt,e)+1;this.#d=Co.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(Qo.isServer()||jo(this.options.enabled,this.#t)===!1||!Oo(this.#p)||this.#p===0)&&(this.#f=Co.setInterval(()=>{(this.options.refetchIntervalInBackground||xo.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Co.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Co.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&bs(e,t),o=i&&Ss(e,n,t,r);(a||o)&&(l={...l,...hs(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=Wo(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=Wo(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Cs(e,t),refetch:this.refetch,promise:this.#o,isEnabled:jo(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{let e=this.#o=x.promise=$o();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a()}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!zo(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){ns.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function ys(e,t){return jo(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||jo(t.retryOnMount,e)!==!1)}function bs(e,t){return ys(e,t)||e.state.data!==void 0&&xs(e,t,t.refetchOnMount)}function xs(e,t,n){if(jo(t.enabled,e)!==!1&&Ao(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Cs(e,t)}return!1}function Ss(e,t,n,r){return(e!==t||jo(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Cs(e,n)}function Cs(e,t){return jo(t.enabled,e)!==!1&&e.isStaleByTime(Ao(t.staleTime,e))}function ws(e,t){return!zo(e.getCurrentResult(),t)}var k=je(),Ts=O.createContext(void 0),Es=e=>{let t=O.useContext(Ts);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Ds=({client:e,children:t})=>(O.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,k.jsx)(Ts.Provider,{value:e,children:t})),Os=O.createContext(!1),ks=()=>O.useContext(Os);Os.Provider;function As(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var js=O.createContext(As()),Ms=()=>O.useContext(js),Ns=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Xo(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ps=e=>{O.useEffect(()=>{e.clearReset()},[e])},Fs=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Xo(n,[e.error,r])),Is=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Ls=(e,t)=>e.isLoading&&e.isFetching&&!t,Rs=(e,t)=>e?.suspense&&t.isPending,zs=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Bs(e,t,n){let r=ks(),i=Ms(),a=Es(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Is(o),Ns(o,i,s),Ps(i);let l=!a.getQueryCache().get(o.queryHash),[u]=O.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(O.useSyncExternalStore(O.useCallback(e=>{let t=f?u.subscribe(ns.batchCalls(e)):Eo;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),O.useEffect(()=>{u.setOptions(o)},[o,u]),Rs(o,d))throw zs(o,u,i);if(Fs({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!Qo.isServer()&&Ls(d,r)&&(l?zs(o,u,i):s?.promise)?.catch(Eo).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function Vs(e,t){return Bs(e,vs,t)}function Hs(e){return e}var Us=g,Ws=globalThis.Number,Gs=e=>{if(e===`NaN`)return v(NaN);if(e===`Infinity`)return v(1/0);if(e===`-Infinity`)return v(-1/0);if(e.trim()===``)return ye();let t=Ws(e);return Ws.isNaN(t)?ye():v(t)},Ks=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],qs=`~effect/http/HttpClientRequest`,Js={[qs]:qs,...Se,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Nt(this.headers),body:this.body.toJSON()}},pipe(){return Ie(this,arguments)}};function Ys(e,t,n,r,i,a){let o=Object.create(Js);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var Xs=Ys(`GET`,``,Gr,ye(),Fr,ri),Zs=e=>(t,n)=>$s(Xs,{method:e,url:t,...n??void 0}),Qs=Zs(`POST`),$s=_(2,(e,t)=>{let n=e;return t.method&&(n=ec(n,t.method)),t.url&&(n=ac(n,t.url)),t.headers&&(n=nc(n,t.headers)),t.urlParams&&(n=oc(n,t.urlParams)),t.hash&&(n=sc(n,t.hash)),t.body&&(n=cc(n,t.body)),t.accept&&(n=rc(n,t.accept)),t.acceptJson&&(n=ic(n)),n}),ec=_(2,(e,t)=>Ys(t,e.url,e.urlParams,e.hash,e.headers,e.body)),tc=_(3,(e,t,n)=>Ys(e.method,e.url,e.urlParams,e.hash,Ir(e.headers,t,n),e.body)),nc=_(2,(e,t)=>Ys(e.method,e.url,e.urlParams,e.hash,ai(e.headers,t),e.body)),rc=_(2,(e,t)=>tc(e,`Accept`,t)),ic=rc(`application/json`),ac=_(2,(e,t)=>{if(typeof t==`string`)return Ys(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Sr(n.searchParams),i=Zt(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Ys(e.method,n.toString(),r,i,e.headers,e.body)}),oc=_(2,(e,t)=>Ys(e.method,e.url,Ni(e.urlParams,t),e.hash,e.headers,e.body)),sc=_(2,(e,t)=>Ys(e.method,e.url,e.urlParams,v(t),e.headers,e.body)),cc=_(2,(e,t)=>{let n=e.headers;return t._tag===`Empty`||t._tag===`FormData`?n=Ai(Ai(n,`Content-Type`),`Content-length`):(t.contentType&&(n=Ir(n,`content-type`,t.contentType)),t.contentLength!==void 0&&(n=Ir(n,`content-length`,t.contentLength.toString()))),Ys(e.method,e.url,e.urlParams,e.hash,n,t)}),lc=e=>ni({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${ge(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),uc=`~effect/http/HttpClient`,dc=Tt(`effect/HttpClient`),fc=_(2,(e,t)=>mc(n=>t(e.postprocess(n)),e.preprocess)),pc=fc(Mt(qr)),mc=(e,t)=>{let n=Object.create(hc);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},hc={[uc]:uc,pipe(){return Ie(this,arguments)},...Se,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(Ks.map(([e,t])=>[t,function(t,n){return this.execute(Zs(e)(t,n))}]))},gc=e=>mc(t=>Mt(t,t=>Kt(n=>{let i=Cc.get(t),a=i??new AbortController,o=mi(t.url,t.urlParams,m(t.hash));if(jt(o))return r(new Ei({reason:new bi({request:t,cause:o.failure})}));let s=o.success;if(n.getRef(Ct)||n.getRef(vc)(t)){let r=e(t,s,a.signal,n);return i?r:Ft(e=>Ae(e(r),{onSuccess(e){return Sc.register(e,a),ct(new wc(e,a))},onFailure(e){return kt(e)&&a.abort(),lt(e)}}))}return pt(n.getRef(bc)(t),{kind:`client`},r=>{r.attribute(`http.request.method`,t.method),r.attribute(`server.address`,s.origin),s.port!==``&&r.attribute(`server.port`,+s.port),r.attribute(`url.full`,s.toString()),r.attribute(`url.path`,s.pathname),r.attribute(`url.scheme`,s.protocol.slice(0,-1));let o=s.search.slice(1);o!==``&&r.attribute(`url.query`,o);let c=n.getRef($r),l=Rr(t.headers,c);for(let e in l)r.attribute(`http.request.header.${e}`,String(l[e]));return t=n.getRef(yc)?nc(t,lc(r)):t,Ft(o=>o(e(t,s,a.signal,n)).pipe(tn(r,{captureStackTrace:!1}),Ae({onSuccess:e=>{r.attribute(`http.response.status_code`,e.status);let t=Rr(e.headers,c);for(let e in t)r.attribute(`http.response.header.${e}`,String(t[e]));return i?ct(e):(Sc.register(e,a),ct(new wc(e,a)))},onFailure(e){return!i&&kt(e)&&a.abort(),lt(e)}})))})})),ct),_c=_(2,(e,t)=>{let n=Oe(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,i=n?t:t.schedule,o=i&&h(i),s=n?void 0:t.times;return fc(e,ie(r===`errors-only`?ue:ae({schedule:o,times:s,while:Dc}),r===`response-only`?ue:fe({while:n||t.while===void 0?Tc:a(Tc,t.while),schedule:i,times:s})))}),vc=it(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>vt}),yc=it(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:me}),bc=it(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),xc=e=>yt(dc)(oe(t=>nt(e,e=>fc(e,Ot(e=>dt(t,e)))))),Sc=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),Cc=new WeakMap,wc=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[zr]=zr;[Tr]=Tr;applyInterrupt(e){return Bt(()=>(Sc.unregister(this.original),wt(e,()=>gt(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return Xe(()=>(Sc.unregister(this.original),zt(this.original.stream,gt(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[st](){return this.original[st]()}pipe(){return Ie(this,arguments)}},Tc=e=>tt(e)||Ec(e),Ec=e=>Oi(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&Dc(e.reason.response)),Dc=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504,Oc=`~effect/ManagedRuntime`,kc=(e,t)=>{let n=t?.memoMap??_e(),r=He(`parallel`),i=te(r,`sequential`),a={onFiberStart:le(r)},s=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,c,l=Kt(t=>(c||=d(Qe(o(e,n,i),e=>gt(()=>{u.cachedContext=e})),{...a,scheduler:t.currentScheduler}),_t(pe(c)))),u={[Oc]:Oc,memoMap:n,scope:r,contextEffect:l,cachedContext:void 0,context(){return u.cachedContext===void 0?re(u.contextEffect):Promise.resolve(u.cachedContext)},dispose(){return re(u.disposeEffect)},disposeEffect:Bt(()=>(u.contextEffect=Ge(`ManagedRuntime disposed`),u.cachedContext=void 0,Le(u.scope,Pt))),runFork(e,t){return u.cachedContext===void 0?d(Ac(u,e),s(t)):ze(u.cachedContext)(e,s(t))},runCallback(e,t){return u.cachedContext===void 0?Te(Ac(u,e),s(t)):an(u.cachedContext)(e,s(t))},runSyncExit(e){return u.cachedContext===void 0?Rt(Ac(u,e)):se(u.cachedContext)(e)},runSync(e){return u.cachedContext===void 0?ce(Ac(u,e)):qe(u.cachedContext)(e)},runPromiseExit(e,t){return u.cachedContext===void 0?Pe(Ac(u,e),s(t)):We(u.cachedContext)(e,s(t))},runPromise(e,t){return u.cachedContext===void 0?re(Ac(u,e),s(t)):x(u.cachedContext)(e,s(t))}};return u};function Ac(e,t){return Mt(e.contextEffect,e=>ve(t,e))}var jc={accept:!1,observe:!1,missingFrameCount:0,startsNewStream:!1};function Mc(e){let t=e===!0;return{accept:t,observe:t,missingFrameCount:0,startsNewStream:t}}function Nc(e,t){let n=e.streamGeneration===void 0&&e.streamId===void 0,r=t.streamGeneration!==void 0||t.streamId!==void 0;return n&&r?Mc(t.keyframe):null}function Pc(e,t){return e.streamGeneration===void 0||t.streamGeneration===void 0?null:t.streamGeneration<e.streamGeneration?jc:t.streamGeneration>e.streamGeneration?Mc(t.keyframe):null}function Fc(e,t){if(!e.streamId||!t.streamId)return null;if(e.streamId!==t.streamId)return Mc(t.keyframe);if(t.sequence<=e.observedSequence)return jc;let n=Math.max(0,t.sequence-e.observedSequence-1);return{accept:n===0||t.keyframe===!0,observe:!0,missingFrameCount:n,startsNewStream:!1}}function Ic(e,t){if(t.sequence>e.acceptedSequence)return{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1};if(!e.acceptedCapturedAt)return jc;let n=Date.parse(e.acceptedCapturedAt),r=Date.parse(t.capturedAt);return Number.isNaN(n)||Number.isNaN(r)||r<=n?jc:{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1}}function Lc(e,t){return Nc(e,t)??Pc(e,t)??Fc(e,t)??Ic(e,t)}function Rc(e,t){let n=Lc(e,t);if(!n.observe)return{accept:n.accept,observe:n.observe,missingFrameCount:n.missingFrameCount,state:e};let r=n.startsNewStream?t.sequence:Math.max(e.observedSequence,t.sequence),i={...e,observedSequence:r,gapCount:e.gapCount+n.missingFrameCount},a=n.accept?{...i,acceptedSequence:t.sequence,acceptedCapturedAt:t.capturedAt,...t.streamId?{streamId:t.streamId}:{},...t.streamGeneration===void 0?{}:{streamGeneration:t.streamGeneration}}:i;return{accept:n.accept,observe:n.observe,missingFrameCount:n.missingFrameCount,state:a}}function zc(e){return{_tag:`Value`,value:e}}function Bc(e,t){return{_tag:`Record`,keys:e,value:t}}function Vc(e,t){return{_tag:`Array`,length:e,value:t}}hi(`SourceError`);var Hc=it(`effect/ConfigProvider`,{defaultValue:()=>Gc()}),Uc={...Ke,toJSON(){return{_id:`ConfigProvider`}}};function Wc(e,t,n){let r=Object.create(Uc);return r.get=e,r.mapInput=t,r.prefix=n,r.load=r=>(t&&(r=t(r)),n&&(r=[...n,...r]),e(r)),r}function Gc(e){let t=e?.env??{APP_VERSION:`0.13.4`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HOSTED_APP_CHANNEL:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:`7bd86cd945a2df9489517d66dff5c15133d1a975`,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.13.4+7bd86cd945a2df9489517d66dff5c15133d1a975`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=Kc(t);return Wc(e=>ct(Jc(n,t,e)))}function Kc(e){let t={};for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let e=n.split(`_`),i=t;for(let t of e)i.children??={},i=i.children[t]??={};i.value=r}return t}var qc=/^(0|[1-9][0-9]*)$/;function Jc(e,t,n){let r=t[n.map(String).join(`_`)],i=Yc(e,n),a=i?.children?Object.keys(i.children):[];return a.length===0?r===void 0?void 0:zc(r):a.every(e=>qc.test(e))?Vc(Math.max(...a.map(e=>parseInt(e,10)))+1,r):Bc(new Set(a),r)}function Yc(e,t){if(t.length===0)return e;let n=e;for(let e of t)if(n=n?.children?.[String(e)],!n)return;return n}var Xc=`~effect/Config`,Zc=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},Qc={...Ke,...Ye,[Xc]:Xc,asEffect(){return Mt(Hc.asEffect(),e=>this.parse(e))},toJSON(){return{_id:`Config`}}};function $c(e){let t=Object.create(Qc);return t.parse=e,t}var el=$e(function*(e,t){let n=yield*e.load(t);if(n!==void 0)switch(n._tag){case`Value`:return n.value;case`Record`:{if(n.value!==void 0)return n.value;let r={};for(let i of n.keys){let n=yield*el(e,[...t,i]);n!==void 0&&(r[i]=n)}return r}case`Array`:{if(n.value!==void 0)return n.value;let r=[];for(let i=0;i<n.length;i++)r.push(yield*el(e,[...t,i]));return r}}}),tl=$e(function*(e,t,n){switch(e._tag){case`Objects`:{let r={};for(let i of e.propertySignatures){let e=i.name;if(typeof e==`string`){let a=yield*tl(i.type,t,[...n,e]);a!==void 0&&(r[e]=a)}}if(e.indexSignatures.length>0){let i=yield*t.load(n);if(i&&i._tag===`Record`)for(let a of e.indexSignatures){let e=Pr(a.parameter);for(let o of i.keys)if(!Object.hasOwn(r,o)&&e(o)){let e=yield*tl(a.type,t,[...n,o]);e!==void 0&&(r[o]=e)}}}return r}case`Arrays`:{let r=yield*t.load(n);if(r&&r._tag===`Value`)return r.value;let i=[];for(let r=0;r<e.elements.length;r++)i.push(yield*tl(e.elements[r],t,[...n,r]));return i}case`Union`:return yield*el(t,n);case`Suspend`:return yield*tl(e.thunk(),t,n);default:{let e=yield*t.load(n);return e===void 0?void 0:e._tag===`Value`||e._tag===`Record`&&e.value!==void 0||e._tag===`Array`&&e.value!==void 0?e.value:void 0}}});function nl(e,t){let n=Vi(e),r=Xr(n),i=Mr(n.ast),a=typeof t==`string`?[t]:t??[];return $c(e=>{let t=e.prefix?[...e.prefix,...a]:a;return tl(i,e,a).pipe(Ht(e=>r(e).pipe(Xt(e=>new Qr(t.length>0?new ii(t,e):e)))),Xt(e=>new Zc(e)))})}var rl=(e,t,n)=>{let r=si(e,t),i=E.pipe(kr(si(E,E),Lr(n)),kr(r));return Jr([r,i])},A=ee();function il(e){return new Promise(t=>globalThis.setTimeout(t,e))}function al(){let e=Error(`The environment connection attempt was cancelled.`);return e.name=`AbortError`,e}function ol(e){if(e?.aborted)throw al()}function sl(e,t){return t?t.aborted?Promise.reject(al()):new Promise((n,r)=>{let i=()=>r(al());t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>{t.removeEventListener(`abort`,i)})}):e}function cl(e,t){return t?t.aborted?Promise.reject(al()):new Promise((n,r)=>{let i=globalThis.setTimeout(()=>{t.removeEventListener(`abort`,a),n()},e),a=()=>{globalThis.clearTimeout(i),r(al())};t.addEventListener(`abort`,a,{once:!0})}):il(e)}var ll=Object.freeze({connectionState:`disconnected`,authState:`unknown`,lastError:null,lastErrorAt:null,role:null,descriptor:null,serverConfig:null,connectedAt:null,disconnectedAt:null,providerAuthority:null}),ul=()=>({...ll}),j=Oa()(e=>({byId:{},ensure:t=>e(e=>e.byId[t]?e:{byId:{...e.byId,[t]:ul()}}),patch:(t,n)=>e(e=>({byId:{...e.byId,[t]:{...e.byId[t]??ul(),...n}}})),clear:t=>e(e=>{let{[t]:n,...r}=e.byId;return{byId:r}}),reset:()=>e({byId:{}})}));function dl(e){let t=tr(e.environmentId);if(t?.lastAuthenticatedPullRequestCapability!==void 0)return{...e,lastAuthenticatedPullRequestCapability:t.lastAuthenticatedPullRequestCapability};let n=j.getState().byId?.[e.environmentId];return n?.authState===`authenticated`&&n.descriptor?{...e,lastAuthenticatedPullRequestCapability:n.descriptor.capabilities.pullRequests===!0}:e}function fl(e){return!!e.runtimeId?.trim()||yr(e.environmentId).isCloud}function pl(e,t){return e.environmentId===t.environmentId&&e.httpBaseUrl===t.httpBaseUrl&&e.wsBaseUrl===t.wsBaseUrl&&e.runtimeId===t.runtimeId&&e.cmmdOrganizationId===t.cmmdOrganizationId}function ml(e){return e.replacedRecord===null&&e.existing!==null&&pl(e.existing,e.record)}function hl(e){let t=e.replacesEnvironmentId?Ur.make(e.replacesEnvironmentId):null,n=t&&t!==e.environmentId?tr(t):null;return{existing:tr(e.environmentId)??n,replacedRecord:n}}async function gl(e){return{records:ur(),bearerToken:e?await rr(e.environmentId):null}}async function _l(e){let t=e.replacedRecord?.environmentId??e.record.environmentId;await ir(e.rollback.records),await hr(e.record.environmentId).catch(()=>void 0),e.rollback.bearerToken&&await Zn(t,e.rollback.bearerToken)}async function vl(e){try{e.replacedRecord?await Jn(e.replacedRecord.environmentId,e.record):await Kn(e.record),ol(e.signal),await hr(e.record.environmentId),e.replacedRecord&&await hr(e.replacedRecord.environmentId),ol(e.signal)}catch(t){try{await _l(e)}catch(e){let n=AggregateError([t,e],`Cloud Environment rollback failed.`);throw n.cause=t,n}throw t}}function yl(e){return{lastError:e instanceof Error?e.message:String(e),lastErrorAt:new Date().toISOString()}}var bl=new Map;function xl(e,t){return e.acquire(t?{signal:t}:{})}function Sl(e,t){bl.set(e,t)}function Cl(e){return bl.has(e)}function wl(e,t){let n=bl.get(e);if(t&&n!==t){t.dispose();return}n?.dispose(),bl.delete(e)}async function Tl(e){let t=bl.get(e);if(t)return(await t.acquire()).bearerToken;let n=tr(e);return n&&fl(n)?null:rr(e)}function El(){return{executionCount:0,isPending:!1,lastArgs:void 0,lastExecutionTime:0,nextExecutionTime:0,status:`idle`,maybeExecuteCount:0}}var Dl={enabled:!0,leading:!0,trailing:!0,wait:0},Ol=class{#e;constructor(e,t){this.fn=e,this.store=new Ea(El()),this.setOptions=e=>{this.options={...this.options,...e},this.#n()||this.cancel()},this.#t=e=>{this.store.setState(t=>{let n={...t,...e},{isPending:r}=n;return{...n,status:this.#n()?r?`pending`:`idle`:`disabled`}}),Da(`Throttler`,this)},this.#n=()=>!!Ta(this.options.enabled,this),this.#r=()=>Ta(this.options.wait,this),this.maybeExecute=(...e)=>{this.#t({maybeExecuteCount:this.store.state.maybeExecuteCount+1});let t=Date.now(),n=t-this.store.state.lastExecutionTime,r=this.#r();if(this.options.leading&&n>=r)this.#i(...e);else if(this.#t({lastArgs:e}),!this.#e&&this.options.trailing){let e=r-(this.store.state.lastExecutionTime?t-this.store.state.lastExecutionTime:0);this.#t({isPending:!0}),this.#e=setTimeout(()=>{let{lastArgs:e}=this.store.state;e!==void 0&&this.#i(...e)},e)}},this.#i=(...e)=>{if(!this.#n())return;this.fn(...e);let t=Date.now(),n=t+this.#r();this.#a(),this.#t({executionCount:this.store.state.executionCount+1,lastExecutionTime:t,nextExecutionTime:n,isPending:!1,lastArgs:void 0}),this.options.onExecute?.(e,this),setTimeout(()=>{this.store.state.isPending||this.#t({nextExecutionTime:void 0})},this.#r())},this.flush=()=>{this.store.state.isPending&&this.store.state.lastArgs&&this.#i(...this.store.state.lastArgs)},this.#a=()=>{this.#e&&=(clearTimeout(this.#e),void 0)},this.cancel=()=>{this.#a(),this.#t({lastArgs:void 0,isPending:!1})},this.reset=()=>{this.#t(El())},this.key=t.key,this.options={...Dl,...t},this.#t(this.options.initialState??{}),this.key&&ka.on(`d-Throttler`,e=>{e.payload.key===this.key&&(this.#t(e.payload.store.state),this.setOptions(e.payload.options))})}#t;#n;#r;#i;#a},kl={all:[`projects`],searchContents:(e,t,n,r,i,a,o)=>[`projects`,`search-contents`,e??null,t,n,r,i,a,o],searchEntries:(e,t,n,r)=>[`projects`,`search-entries`,e??null,t,n,r]},Al={all:[`providers`],checkpointDiff:e=>[`providers`,`checkpointDiff`,e.environmentId??null,e.threadId,e.fromTurnCount,e.toTurnCount,e.cacheScope??null]};function jl(e){let t=null,n=!1;function r(){return t}function i(){n=!0,t?.queryInvalidationThrottler.maybeExecute()}function a(){t?.stop(),t=null}function o(r){if(t?.queryClient===r)return t.refCount+=1,()=>{!t||t.queryClient!==r||(--t.refCount,t.refCount===0&&a())};a(),n=!1;let i=new Ol(()=>{n&&(n=!1,r.invalidateQueries({queryKey:Al.all}),r.invalidateQueries({queryKey:kl.all}))},{wait:100,leading:!1,trailing:!0});e.createPrimaryEnvironmentConnection(),ta().catch(()=>void 0);let o=ar.subscribe(()=>{Gn()&&e.syncSavedEnvironmentConnections(ur())});return $n().then(()=>e.syncSavedEnvironmentConnections(ur())).catch(()=>void 0),t={queryClient:r,queryInvalidationThrottler:i,refCount:1,stop:()=>{o(),i.cancel()}},()=>{!t||t.queryClient!==r||(--t.refCount,t.refCount===0&&a())}}return{readActiveService:r,notifyProviderInvalidation:i,stopActiveService:a,start:o}}var Ml=class extends Error{status;constructor(e,t){super(e),this.name=`RemoteEnvironmentAuthHttpError`,this.status=t}};function Nl(e,t){let n=new URL(e);return n.pathname=`${n.pathname.endsWith(`/`)?n.pathname.slice(0,-1):n.pathname}${t.startsWith(`/`)?t:`/${t}`}`,n.search=``,n.hash=``,n.toString()}async function Pl(e,t){let n=await e.text();if(!n)return t;try{let e=JSON.parse(n);if(typeof e.error==`string`&&e.error.length>0)return e.error}catch{}return n}async function Fl(e){let t=Nl(e.httpBaseUrl,e.pathname),n;try{n=await fetch(t,{method:e.method??`GET`,headers:{...e.body===void 0?{}:{"content-type":`application/json`},...e.bearerToken?{authorization:`Bearer ${e.bearerToken}`}:{}},...e.body===void 0?{}:{body:JSON.stringify(e.body)},...e.signal?{signal:e.signal}:{}})}catch(e){throw Error(`Failed to fetch remote auth endpoint ${t} (${e.message}).`,{cause:e})}if(!n.ok)throw new Ml(await Pl(n,`Remote auth request failed (${n.status}).`),n.status);return await n.json()}async function Il(e){return Fl({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/session`,bearerToken:e.bearerToken,...e.signal?{signal:e.signal}:{}})}async function Ll(e){return Fl({httpBaseUrl:e.httpBaseUrl,pathname:`/.well-known/forge/environment`,...e.bearerToken?{bearerToken:e.bearerToken}:{}})}async function Rl(e){return Fl({httpBaseUrl:e.httpBaseUrl,pathname:`/api/auth/ws-token`,method:`POST`,bearerToken:e.bearerToken})}async function zl(e){let t=new URL(e.wsBaseUrl,window.location.origin);if(e.runtimeTicket)return t.searchParams.set(`runtimeTicket`,e.runtimeTicket),t.searchParams.delete(`wsToken`),t.toString();let n=await Rl({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken});return t.searchParams.set(`wsToken`,n.token),t.toString()}function Bl(e,t){if(t){Ma(t,e);return}Na(e)}function Vl(e){let t=null,n=[];for(let r of e.split(/\r?\n/)){if(r.startsWith(`event:`)){t=r.slice(6).trim();continue}r.startsWith(`data:`)&&n.push(r.slice(5).trimStart())}return{eventName:t,data:n.join(`
|
|
3
3
|
`)}}function Hl(e,t){let n=Vl(e);if(n.eventName!==`phase`||!n.data)return!1;try{let e=JSON.parse(n.data);return Bl(e,t),e.phase===`app-ready`||e.phase===`error`}catch{return!1}}async function Ul(e,t,n){if(!e.body)return;let r=e.body.getReader(),i=new TextDecoder,a=``;for(;!n.aborted;){let{done:e,value:n}=await r.read();if(e)break;a+=i.decode(n,{stream:!0});let o=a.indexOf(`
|
|
4
4
|
|
|
5
5
|
`);for(;o!==-1;){let e=a.slice(0,o);if(a=a.slice(o+2),Hl(e,t))return;o=a.indexOf(`
|
|
@@ -13,24 +13,24 @@ import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{$ as r,$
|
|
|
13
13
|
`).trimEnd()}),null)};for(let t of e.split(`
|
|
14
14
|
`)){let e=/^- (.+):$/.exec(t);if(e){r(),n={header:e[1],bodyLines:[]};continue}if(n){if(t.startsWith(` `)){n.bodyLines.push(t.slice(2));continue}t.length===0&&n.bodyLines.push(``)}}return r(),t}function Um(e){let t=0;for(let n of e)n===``&&(t+=1);return t}function Wm(e,t){let n=t-Um(e);return n<=0?e:`${``.repeat(n)}${e}`}function Gm(e){return e===void 0||e===` `||e===`
|
|
15
15
|
`||e===` `||e===`\r`}function Km(e,t){let n=Math.max(0,Math.min(e.length,Math.floor(t))),r=`${Gm(e[n-1])?``:` `} `,i=e[n]===` `?n+1:n;return{prompt:`${e.slice(0,n)}${r}${e.slice(i)}`,cursor:n+r.length,contextIndex:Um(e.slice(0,n))}}function qm(e){return e.replaceAll(``,``)}function Jm(e,t){if(t<0)return{prompt:e,cursor:e.length};let n=0;for(let r=0;r<e.length;r+=1)if(e[r]===``){if(n===t)return{prompt:e.slice(0,r)+e.slice(r+1),cursor:r};n+=1}return{prompt:e,cursor:e.length}}var Ym=e=>Symbol.iterator in e,Xm=e=>`entries`in e,Zm=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},Qm=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function $m(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Ym(e)&&Ym(t)?Xm(e)&&Xm(t)?Zm(e,t):Qm(e,t):Zm({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function eh(e){let t=O.useRef(void 0);return n=>{let r=e(n);return $m(t.current,r)?t.current:t.current=r}}var th=[`draftsByThreadKey`,`draftThreadsByThreadKey`,`logicalProjectDraftThreadKeyByLogicalProjectKey`],nh=[`stickyModelSelectionByProvider`,`stickyActiveProvider`];function rh(e){let t=ah(e.nextLocal,e.version,!1);if(!t)return e.currentStored??e.nextLocal;if(e.currentStored!==null&&e.canMigrate!==void 0&&!e.canMigrate(e.currentStored,e.version))return e.currentStored;if(e.previousLocal===e.currentStored&&(e.canMigrate??ih)(e.currentStored,e.version))return e.nextLocal;let n=ah(e.previousLocal,e.version,!0),r=ah(e.currentStored,e.version,!0);if(!r||!n)return e.currentStored??e.nextLocal;let i={...r.state};for(let e of th)i[e]=lh(n.state[e],r.state[e],t.state[e]);for(let e of nh)uh(n.state[e],t.state[e])||(i[e]=t.state[e]);return JSON.stringify({...r,version:e.version,state:i})}function ih(e,t){if(e===null)return!0;try{let n=JSON.parse(e);return!dh(n)||!dh(n.state)||typeof n.version!=`number`||!Number.isInteger(n.version)?!1:n.version>=1&&n.version<t}catch{return!1}}function ah(e,t,n){if(e===null)return n?{version:t,state:ch()}:null;let r=oh(e);return r&&sh(r,t)?{version:t,state:r.state}:null}function oh(e){try{let t=JSON.parse(e);return dh(t)?t:null}catch{return null}}function sh(e,t){let n=e.state;return e.version!==t||!dh(n)?!1:th.every(e=>dh(n[e]))}function ch(){return Object.fromEntries(th.map(e=>[e,{}]))}function lh(e,t,n){let r={...t};for(let t of new Set([...Object.keys(e),...Object.keys(n)]))uh(e[t],n[t])||(t in n?r[t]=n[t]:delete r[t]);return r}function uh(e,t){return JSON.stringify(e)===JSON.stringify(t)}function dh(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function fh(e){let t;return{getItem:n=>{let r=e.storage.getItem(n);return t===void 0&&(t=r),r},setItem:(n,r)=>{let i=e.storage.getItem(n),a=rh({previousLocal:t??null,currentStored:i,nextLocal:r,version:e.version,...e.canMigrate===void 0?{}:{canMigrate:e.canMigrate}});(a!==i||i===r)&&(e.storage.setItem(n,a),t=r)},removeItem:n=>{e.storage.removeItem(n),t=null}}}function ph(e){let t=e.auth.status!==`unauthenticated`||e.auth.provenance?.credentialScope===`proxied`;return e.enabled&&e.installed&&e.status===`ready`&&t&&e.models.length>0}var mh={providers:{codex:!0,claude:!1,cmmd:!0},meteredEgressApproved:{codex:!1,claude:!1,cmmd:!1},allowedWallets:[`personal`],updatedAt:`1970-01-01T00:00:00.000Z`};function hh(e){if(e==null)return mh;let t=e.providers,n=e.meteredEgressApproved,r=e.allowedWallets;return{providers:{...mh.providers,...t},meteredEgressApproved:{...mh.meteredEgressApproved,...n},allowedWallets:Array.isArray(r)&&r.length>0?r:mh.allowedWallets,updatedAt:typeof e.updatedAt==`string`?e.updatedAt:mh.updatedAt}}function gh(e){switch(e){case`codex`:return`codex`;case`claudeAgent`:return`claude`;case`cmmd`:case`apex`:return`cmmd`;default:return null}}var _h=[`codex`,`claudeAgent`,`cmmd`];function vh(e,t){if(t==null)return null;let n=t.providers;if(typeof n!=`object`||!n)return null;let r=n[e];return typeof r==`boolean`?r:null}function yh(e,t){let n=gh(e);if(n===null)return{offered:!1,reason:`unknown-provider`};let r=vh(n,t);return r===!0?{offered:!0}:r===!1?{offered:!1,reason:`org-disabled`}:hh(t).providers[n]===!0?{offered:!0}:{offered:!1,reason:`policy-unavailable`}}function bh(e,t){return yh(e,t).offered}function xh(e,t){return Sh(e,t).offered}function Sh(e,t){return t===null?{offered:!0}:yh(e,t)}function Ch(e,t){return hh(t).allowedWallets.includes(e)}function wh(e){return Ch(`personal`,e)}function Th(e){return e===`claudeAgent`||e===`codex`}function Eh(e,t){return e!==`claudeAgent`||wh(t)||bh(`claudeAgent`,t)}function Dh(e){return e.isDebugDisclosureEnabled||Th(e.provider)&&wh(e.policy)?!1:!bh(e.provider===`apex`?`apex`:e.provider,e.policy)}function Oh(e){if(!Ph(e)||!Array.isArray(e.accounts))throw Error(`CMMD returned invalid provider accounts.`);return{accounts:e.accounts.filter(kh)}}function kh(e){return Ph(e)?jh(e.provider)&&Mh(e.providerAccountId)&&Ah(e)&&Nh(e.accountEmail)&&Nh(e.accountDisplayName)&&Nh(e.planType)&&typeof e.isDefault==`boolean`&&typeof e.needsReconnect==`boolean`:!1}function Ah(e){return(e.credentialTarget===`primary`||e.credentialTarget===`linked`)&&Array.isArray(e.legacyProviderAccountIds)&&e.legacyProviderAccountIds.every(Mh)}function jh(e){return e===`codex`||e===`claudeAgent`}function Mh(e){return typeof e==`string`&&e.trim().length>0}function Nh(e){return typeof e==`string`||e===null}function Ph(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Fh(e){let t=yr(e);return t.legacyRuntimeId===null?t.shape===`durable-environment`&&typeof e==`string`?e:null:t.legacyRuntimeId}var Ih=class extends Error{constructor(e){super(e===`auth`?`Your CMMD session expired. Sign in again to verify Claude runtime readiness.`:`CMMD denied access to verify Claude runtime readiness. Check your organization permissions.`),this.name=`ForgeProviderAccessAuthorityError`}};async function Lh(e){if(!e.enabled||e.readinessTargetId===null)return null;try{return Bh(await e.load(e.readinessTargetId),e.readinessTargetId)}catch(e){if(e instanceof ja&&(e.kind===`auth`||e.kind===`permission`))throw new Ih(e.kind);return null}}var Rh=new Set([`not_connected`,`pending`,`claimed`,`activating`,`applied`,`failed`,`stale`]),zh=[`generationId`,`nativeVerifiedAt`,`reason`,`lastErrorCode`,`lastErrorMessage`];function Bh(e,t){if(!Jh(e)||!Kh(e)||!Vh(e,t))throw Error(`CMMD returned invalid Claude runtime readiness.`);return e}function Vh(e,t){if(e.deliveryReceipt===null)return e.nativeExecutable!==!0;if(!Jh(e.deliveryReceipt))return!1;let n=e.deliveryReceipt,r=Jh(n.identity)?n.identity:null;return r!==null&&Hh(n,t)&&Gh(r,e.generationId)}function Hh(e,t){return Uh(e,t)&&Wh(e)}function Uh(e,t){return typeof e.receiptId==`string`&&e.receiptId.trim().length>0&&e.runtimeId===t&&typeof e.machineId==`string`&&e.machineId.trim().length>0&&typeof e.credentialEpoch==`number`&&Number.isSafeInteger(e.credentialEpoch)&&e.credentialEpoch>=0}function Wh(e){return typeof e.issuedAt==`string`&&Number.isFinite(Date.parse(e.issuedAt))&&e.expiresAt===null}function Gh(e,t){return e.kind===`credential_generation`&&e.provider===`claude`&&typeof e.credentialGenerationId==`string`&&e.credentialGenerationId===t}function Kh(e){return typeof e.connected==`boolean`&&Rh.has(String(e.deliveryStatus))&&typeof e.nativeExecutable==`boolean`&&zh.every(t=>qh(e[t]))}function qh(e){return e===null||typeof e==`string`}function Jh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Yh={credential_expired_refreshing:`CREDENTIAL_EXPIRED_REFRESHING`,credential_reconnect_required:`CREDENTIAL_RECONNECT_REQUIRED`,credential_not_connected:`CREDENTIAL_RECONNECT_REQUIRED`,credential_generation_not_applied:`CREDENTIAL_GENERATION_NOT_APPLIED`,runtime_unavailable:`RUNTIME_UNAVAILABLE`};function Xh(e){return typeof e!=`string`||!Object.hasOwn(Yh,e)?null:Yh[e]??null}var Zh=new Set([`pending`,`claimed`,`activating`]),Qh=2e3;function $h(e){return{readinessTargetId:e,dataUpdatedAt:0,consecutiveUnavailableResponses:0,consecutiveFailedResponses:0}}function eg(e){let t=e.current.readinessTargetId===e.readinessTargetId?e.current:$h(e.readinessTargetId);return e.dataUpdatedAt===0||e.dataUpdatedAt===t.dataUpdatedAt?t:{readinessTargetId:e.readinessTargetId,dataUpdatedAt:e.dataUpdatedAt,consecutiveUnavailableResponses:e.readinessUnavailable?t.consecutiveUnavailableResponses+1:0,consecutiveFailedResponses:e.deliveryStatus===`failed`?t.consecutiveFailedResponses+1:0}}function tg(e,t){if(!e.claudeOffered||!e.claudeConnected)return!1;let n=Xh(e.reason);return n===`CREDENTIAL_EXPIRED_REFRESHING`?!0:e.deliveryStatus===`failed`?n!==`CREDENTIAL_RECONNECT_REQUIRED`&&t.consecutiveFailedResponses<16:e.deliveryStatus===null?t.consecutiveUnavailableResponses>0&&t.consecutiveUnavailableResponses<3:Zh.has(e.deliveryStatus)}function ng(e){return e.credentialMode===`runtime`?e.provider&&ph(e.provider)?{eligible:!0}:{eligible:!1,reason:`runtime-unavailable`}:e.access.status===`loading`?{eligible:!1,reason:`access-loading`}:e.access.status===`error`?{eligible:!1,reason:`access-error`}:rg({provider:e.provider,providerKind:e.providerKind,policy:e.access.policy,personalConnections:e.access.personalConnections,personalReconnectRequired:e.access.personalReconnectRequired,claudeRuntimeReadiness:e.access.claudeRuntimeReadiness})}function rg(e){return!e.provider||!ph(e.provider)?{eligible:!1,reason:`runtime-unavailable`}:e.policy===null?{eligible:!1,reason:`access-error`}:bh(e.providerKind,e.policy)?ag({providerKind:e.providerKind,policy:e.policy,personalConnections:e.personalConnections,personalReconnectRequired:e.personalReconnectRequired,claudeRuntimeReadiness:e.claudeRuntimeReadiness,stage:`live-runtime`}):{eligible:!1,reason:`not-offered`}}function ig(e){return e.access.status===`loading`?{eligible:!1,reason:`access-loading`}:e.access.status===`error`||e.access.policy===null?{eligible:!1,reason:`access-error`}:bh(e.providerKind,e.access.policy)?ag({providerKind:e.providerKind,policy:e.access.policy,personalConnections:e.access.personalConnections,personalReconnectRequired:e.access.personalReconnectRequired,claudeRuntimeReadiness:e.access.claudeRuntimeReadiness,stage:`provisioning`}):{eligible:!1,reason:`not-offered`}}function ag(e){return e.providerKind===`cmmd`||e.providerKind===`apex`?{eligible:!0}:e.providerKind!==`codex`&&e.providerKind!==`claudeAgent`?{eligible:!1,reason:`not-offered`}:og({providerKind:e.providerKind,personalConnections:e.personalConnections,personalReconnectRequired:e.personalReconnectRequired,claudeRuntimeReadiness:e.claudeRuntimeReadiness,workspaceWalletAllowed:Ch(`workspace`,e.policy),stage:e.stage})}function og(e){return sg(e.workspaceWalletAllowed)?{eligible:!0}:cg(e.providerKind,e.personalReconnectRequired)?{eligible:!1,reason:`personal-credential-reconnect-required`}:lg(e.providerKind,e.personalConnections)?fg(e)?{eligible:!1,reason:`environment-not-running`}:ug(e)?{eligible:!0}:{eligible:!1,reason:`native-runtime-not-ready`}:{eligible:!1,reason:`personal-credential-required`}}function sg(e){return e&&!1}function cg(e,t){return e===`codex`&&t?.codex===!0}function lg(e,t){return t?.[e]===!0}function ug(e){return e.providerKind!==`claudeAgent`||e.stage===`provisioning`||pg(e.claudeRuntimeReadiness)}var dg=`runtime_unavailable`;function fg(e){return e.providerKind!==`claudeAgent`||e.stage===`provisioning`?!1:e.claudeRuntimeReadiness?.reason===dg}function pg(e){if(!mg(e))return!1;let t=e.deliveryReceipt?.identity;return t?.kind===`credential_generation`&&t.provider===`claude`&&t.credentialGenerationId===e.generationId}function mg(e){return e?.connected===!0&&e.nativeExecutable===!0&&typeof e.generationId==`string`&&e.generationId.trim().length>0}function hg(e){if(e.status!==`ready`)return!1;if(e.policy===null)return!0;let t=e.policy.providers,n=Ch(`workspace`,e.policy);return t.cmmd?!0:Ch(`personal`,e.policy)||n?t.codex&&e.personalConnections?.codex===!0||t.claude&&e.personalConnections?.claudeAgent===!0:!1}var gg={providers:{codex:!1,claude:!1,cmmd:!1},meteredEgressApproved:{codex:!1,claude:!1,cmmd:!1},allowedWallets:[`personal`],updatedAt:`1970-01-01T00:00:00.000Z`},_g=[`cmmd`,`forge-provider-access`],vg=Qh;function yg(e,t){return!(t instanceof Ih)&&e<3}function bg(e,t=null){return[..._g,e,t]}async function xg(e){e.queryClient.setQueriesData({queryKey:_g},t=>Sg(t,e.provider,e.connected)),await e.queryClient.invalidateQueries({queryKey:_g,refetchType:`all`})}function Sg(e,t,n){return e?.status!==`ready`||e.personalConnections===null?e:{...e,personalConnections:{...e.personalConnections,[t]:n},...t===`codex`?{personalReconnectRequired:{codex:!1}}:{},...t===`claudeAgent`?{claudeRuntimeReadiness:null}:{}}}async function Cg(e,t=null){if(e===`runtime`)return{status:`ready`,policy:null,personalConnections:null,providerAccounts:[],claudeRuntimeReadiness:null};let n=er(),r=Ag(await n.getOrgProviderPolicy());Ch(`workspace`,r);let[i,a,o,s]=await Promise.all([Eg(()=>n.getProviderAccounts()),Dg({enabled:r.providers.codex,load:()=>n.getUserCodexCredential(),provider:`codex`}),Dg({enabled:r.providers.claude,load:()=>n.getUserClaudeCredential(),provider:`claudeAgent`}),Lh({enabled:r.providers.claude,readinessTargetId:t,load:e=>n.getClaudeRuntimeReadiness(e)})]),c=i.accounts.filter(e=>e.provider===`codex`?r.providers.codex:r.providers.claude),l=wg(c),u=l.codex||a.connected,d=l.claudeAgent||o.connected,f=c.some(e=>e.provider===`codex`&&e.needsReconnect)||a.reconnectRequired;return{status:`ready`,policy:r,personalConnections:{codex:u,claudeAgent:d},providerAccounts:c,...f?{personalReconnectRequired:{codex:!0}}:{},claudeRuntimeReadiness:s}}function wg(e){return{codex:e.some(e=>e.provider===`codex`&&!e.needsReconnect),claudeAgent:e.some(e=>e.provider===`claudeAgent`&&!e.needsReconnect)}}function Tg(e,t){if(e.status!==`ready`)return;let n=e.providerAccounts??[];return(n.find(e=>e.provider===t&&e.isDefault&&!e.needsReconnect)??n.find(e=>e.provider===t&&!e.needsReconnect))?.providerAccountId}async function Eg(e){try{return Oh(await e())}catch{return{accounts:[]}}}async function Dg(e){if(!e.enabled)return{connected:!1,reconnectRequired:!1};try{return Pg(await e.load(),e.provider)}catch{return{connected:!1,reconnectRequired:!1}}}function Og(e){let t=e?.policy?.providers.claude===!0,n=e?.personalConnections?.claudeAgent===!0;return{claudeOffered:t,claudeConnected:n,deliveryStatus:e?.claudeRuntimeReadiness?.deliveryStatus??null,reason:e?.claudeRuntimeReadiness?.reason??null,readinessUnavailable:t&&n&&e?.claudeRuntimeReadiness===null}}function kg(e){let t=(0,A.c)(21),n;t[0]!==e.environmentId||t[1]!==e.runtimeId?(n=e.environmentId==null?e.runtimeId??null:Fh(e.environmentId),t[0]=e.environmentId,t[1]=e.runtimeId,t[2]=n):n=t[2];let r=n,i;t[3]===r?i=t[4]:(i=$h(r),t[3]=r,t[4]=i);let a=(0,O.useRef)(i),o;t[5]!==e.credentialMode||t[6]!==r?(o=bg(e.credentialMode,r),t[5]=e.credentialMode,t[6]=r,t[7]=o):o=t[7];let s;t[8]===r?s=t[9]:(s=()=>Cg(`cmmd-cloud`,r),t[8]=r,t[9]=s);let c=e.enabled&&e.credentialMode===`cmmd-cloud`,l;t[10]===r?l=t[11]:(l=e=>{if(e.state.error instanceof Ih)return!1;let t=Og(e.state.data);return a.current=eg({current:a.current,readinessTargetId:r,dataUpdatedAt:e.state.dataUpdatedAt,readinessUnavailable:r!==null&&t.readinessUnavailable,deliveryStatus:t.deliveryStatus}),r!==null&&tg(t,a.current)?vg:!1},t[10]=r,t[11]=l);let u;t[12]!==o||t[13]!==s||t[14]!==c||t[15]!==l?(u={queryKey:o,queryFn:s,enabled:c,retry:yg,staleTime:3e4,refetchInterval:l},t[12]=o,t[13]=s,t[14]=c,t[15]=l,t[16]=u):u=t[16];let d=Vs(u);if(!e.enabled){let e;return t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e={status:`loading`},t[17]=e):e=t[17],e}if(e.credentialMode===`runtime`){let e;return t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e={status:`ready`,policy:null,personalConnections:null,providerAccounts:[],claudeRuntimeReadiness:null},t[18]=e):e=t[18],e}if(d.isPending){let e;return t[19]===Symbol.for(`react.memo_cache_sentinel`)?(e={status:`loading`},t[19]=e):e=t[19],e}if(d.isError||!d.data){let e;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e={status:`error`},t[20]=e):e=t[20],e}return d.data}function Ag(e){if(!Ig(e)||!Ig(e.providers))throw Error(`CMMD returned an invalid organization provider policy.`);let{providers:t,meteredEgressApproved:n,allowedWallets:r,updatedAt:i}=e,a=Ng(r,i);if(!Mg(t)||a===null)throw Error(`CMMD returned an invalid organization provider policy.`);return{providers:{codex:t.codex,claude:t.claude,cmmd:t.cmmd},meteredEgressApproved:jg(n),allowedWallets:[...new Set(a.allowedWallets)],updatedAt:a.updatedAt}}function jg(e){return Ig(e)&&Mg(e)?{codex:e.codex,claude:e.claude,cmmd:e.cmmd}:{codex:!1,claude:!1,cmmd:!1}}function Mg(e){return typeof e.codex==`boolean`&&typeof e.claude==`boolean`&&typeof e.cmmd==`boolean`}function Ng(e,t){return Array.isArray(e)&&e.length>0&&e.every(Fg)&&typeof t==`string`&&t.trim().length>0?{allowedWallets:e,updatedAt:t}:null}function Pg(e,t){if(!Ig(e)||typeof e.connected!=`boolean`)throw Error(`CMMD returned an invalid ${t} connection state.`);if(!e.connected)return{connected:!1,reconnectRequired:!1};if(t===`codex`){if(typeof e.needsReconnect!=`boolean`)throw Error(`CMMD returned an invalid Codex connection state.`);return{connected:!e.needsReconnect,reconnectRequired:e.needsReconnect}}if(typeof e.generationId!=`string`||e.generationId.trim().length===0)throw Error(`CMMD returned an invalid Claude connection state.`);return{connected:!0,reconnectRequired:!1}}function Fg(e){return e===`personal`||e===`workspace`}function Ig(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Lg(e){return e.status===`ready`?e.policy:gg}var Rg=[`cursor`,`opencode`,`gemini`],zg={state:`usable`},Bg={state:`withheld`,reason:`unbuilt`},Vg={state:`withheld`,reason:`not-on-this-environment`};function Hg(e){return Rg.includes(e)}function Ug(e){return e===`gemini`?null:e}function Wg(e,t){if(e===void 0)return t?Vg:zg;if(e.availability===`unavailable`){let t=e.unavailableReason??`not-on-this-environment`,n=t===`not-on-this-environment`&&e.availabilityCheck===`could-not-check`?`could-not-check`:e.unavailableDetail;return n===void 0?{state:`withheld`,reason:t}:{state:`withheld`,reason:t,detail:n}}return e.availability===`available`||ph(e)||Gg(e)?zg:Vg}function Gg(e){return e.installed&&e.auth.status===`unauthenticated`&&e.auth.provenance?.credentialScope!==`proxied`}function Kg(e,t){let n=ig({providerKind:e,access:t});return n.eligible?null:qg(n.reason)}function qg(e){switch(e){case`access-loading`:return{state:`unresolved`,cause:`loading`};case`access-error`:return{state:`unresolved`,cause:`error`};case`not-offered`:return{state:`withheld`,reason:`not-offered`};case`personal-credential-required`:return{state:`withheld`,reason:`not-usable`,detail:`no-connection`};case`personal-credential-reconnect-required`:return{state:`withheld`,reason:`not-usable`,detail:`reconnect-required`};case`native-runtime-not-ready`:return{state:`withheld`,reason:`not-usable`,detail:`delivery-pending`};case`environment-not-running`:return{state:`withheld`,reason:`not-usable`,detail:`environment-not-running`};case`runtime-unavailable`:return null}}function Jg(e){if(Hg(e.provider))return{pick:Bg,run:Bg};let t=Ug(e.provider);return t===null?{pick:Bg,run:Bg}:Yg({...e,providerKind:t})}function Yg(e){return{pick:Qg(e,`pick`),run:Qg(e,`run`)}}function Xg(e){return Qg(e,`pick`)}function Zg(e){return e.providers.filter(t=>Qg({providerKind:t.provider,snapshot:t,access:e.access,credentialMode:e.credentialMode,hasLiveInventory:e.hasLiveInventory},`run`).state===`usable`)}function Qg(e,t){let{providerKind:n}=e;if(e.snapshot?.unavailableReason===`unbuilt`)return Bg;if(e.credentialMode===`runtime`)return $g({...e,providerKind:n},t);if(e.access.status!==`ready`)return{state:`unresolved`,cause:e.access.status};if(!Sh(n,e.access.policy).offered)return{state:`withheld`,reason:`not-offered`};let r=Kg(n,e.access);return r===null?$g({...e,providerKind:n},t):r}function $g(e,t){let n=ng({provider:e.snapshot,providerKind:e.providerKind,access:e.access,credentialMode:e.credentialMode});if(!n.eligible&&n.reason===`environment-not-running`)return{state:`withheld`,reason:`not-usable`,detail:`environment-not-running`};if(!n.eligible&&n.reason===`native-runtime-not-ready`)return{state:`withheld`,reason:`not-usable`,detail:`delivery-pending`};let r=Wg(e.snapshot,e.hasLiveInventory);return!n.eligible&&n.reason===`runtime-unavailable`&&t===`run`?e_(r,e.hasLiveInventory)?zg:Vg:r}function e_(e,t){return e.state===`withheld`&&e.reason===`not-on-this-environment`&&(e.detail===`could-not-check`||!t)}var t_={reasoningEffortLevels:[],supportsFastMode:!1,supportsThinkingToggle:!1,contextWindowOptions:[],promptInjectedEffortLevels:[]},n_=[`codex`,`claudeAgent`,`apex`];function r_(e){for(let t of n_){let n=e.find(e=>e.provider===t);if(n&&a_(n))return t}return e.find(a_)?.provider??null}function i_(e,t){return e.find(e=>e.provider===t)?.models??[]}function a_(e){return ph(e)}function o_(e,t){let n=t??r_(e)??`codex`,r=e.find(e=>e.provider===n);if(r&&a_(r)||n===`codex`)return n;for(let t of n_){let n=e.find(e=>e.provider===t);if(n&&a_(n))return t}return`codex`}function s_(e){return e.providers.filter(t=>Xg({providerKind:t.provider,snapshot:t,access:e.access,credentialMode:e.credentialMode,hasLiveInventory:!0}).state===`usable`)}function c_(e,t,n,r){let i=s_({providers:e,access:n,credentialMode:r});return t&&i.some(e=>e.provider===t)?t:r_(i)}function l_(e,t,n,r){return t==null?c_(e,null,n,r):Zg({providers:e,access:n,credentialMode:r,hasLiveInventory:!0}).some(e=>e.provider===t)?t:null}function u_(e,t,n){let r=On(t,n);return e.find(e=>e.slug===r)?.capabilities??t_}function d_(e,t,n){let r=i_(e,t).filter(e=>!e.isLegacy);return r.find(e=>e.slug===n)?.slug??r.find(e=>e.isDefault)?.slug??r.find(e=>e.slug===Ii[t])?.slug??r.find(e=>!e.isCustom)?.slug??r[0]?.slug??Ii[t]}function f_(e){let{provider:t,model:n,models:r,prompt:i,modelOptions:a}=e,o=u_(r,n,t),s=a?.[t],c=s?`effort`in s?s.effort:`reasoningEffort`in s?s.reasoningEffort:null:null,l=pn(o,c)??null,u=t===`codex`?Un(o,s):Bn(o,s),d=o.promptInjectedEffortLevels.length>0&&Vn(i);return{provider:t,promptEffort:l,modelOptionsForDispatch:u,...d?{composerFrameClassName:`ultrathink-frame`}:{},...d?{composerSurfaceClassName:`shadow-[0_0_0_1px_rgba(255,255,255,0.04)_inset]`}:{},...d?{modelPickerIconClassName:`ultrathink-chroma`}:{}}}function p_(e,t,n,r){return i_(t,n).map(({slug:e,name:t,isCustom:n,isDefault:r,isLegacy:i})=>({slug:e,name:t,isCustom:n,isDefault:r,isLegacy:i}))}function m_(e,t,n,r,i){let a=pr(e,r,p_(t,n,e,r));if(a&&!bn(a,e))return a;let o=h_(n,e,i),s=p_(t,n,o,r),c=pr(o,r,s)??d_(n,o);return e&&bn(c,e)?d_(n,e):c}function h_(e,t,n){return!t||!bh(t,n)?o_(e,`codex`):o_(e,t)}function g_(e,t,n,r){return{codex:p_(e,t,`codex`,n===`codex`?r:void 0),claudeAgent:p_(e,t,`claudeAgent`,n===`claudeAgent`?r:void 0),ollama:p_(e,t,`ollama`,n===`ollama`?r:void 0),cmmd:p_(e,t,`cmmd`,n===`cmmd`?r:void 0),apex:p_(e,t,`apex`,n===`apex`?r:void 0),cursor:p_(e,t,`cursor`,n===`cursor`?r:void 0),opencode:p_(e,t,`opencode`,n===`opencode`?r:void 0)}}function __(e,t,n){let r=e.textGenerationModelSelection??{provider:`codex`,model:ci.codex},i=h_(t,r.provider,n),a=m_(i,e,t,i===r.provider?r.model:null,n),{modelOptionsForDispatch:o}=f_({provider:i,model:a,models:i_(t,i),prompt:``,modelOptions:{[i]:i===r.provider?r.options:void 0}});return{provider:i,model:a,...o?{options:o}:{}}}function v_(e){return e?.options?{[e.provider]:e.options}:null}function y_(e){if(!e)return null;let t={};for(let[n,r]of Object.entries(e))r?.options&&(t[n]=r.options);return Object.keys(t).length>0?t:null}function b_(e){if(e.activeSelection&&`providerAccountId`in e.activeSelection)return e.activeSelection.providerAccountId;for(let t of e.candidates)if(t?.provider===e.selectedProvider&&`providerAccountId`in t)return t.providerAccountId}function x_(e){let t=t=>t!==void 0&&bn(t,e.selectedProvider)?void 0:t,n=t(e.threadModelSelection?.provider===e.selectedProvider?e.threadModelSelection.model:void 0),r=t(e.projectModelSelection?.provider===e.selectedProvider?e.projectModelSelection.model:void 0),i=On(n??r,e.selectedProvider)??d_(e.providers,e.selectedProvider),a=e.draft?.modelSelectionByProvider?.[e.selectedProvider],o=b_({activeSelection:a,selectedProvider:e.selectedProvider,candidates:[e.threadModelSelection,e.projectModelSelection]}),s=t(a?.model),c=s?m_(e.selectedProvider,e.settings,e.providers,s):i,l=y_(e.draft?.modelSelectionByProvider)??v_(e.threadModelSelection)??v_(e.projectModelSelection)??null;return{selectedModel:c,...o?{selectedProviderAccountId:o}:{},modelOptions:l}}var S_=Bi({id:E,name:E,mimeType:E,sizeBytes:_i,dataUrl:E}),C_=Bi({id:E,name:E,mimeType:E,sizeBytes:_i}),w_=Bi({id:E,threadId:Br,createdAt:E,terminalId:E,terminalLabel:E,lineStart:_i,lineEnd:_i}),T_=Bi({prompt:E,attachments:Mi(S_),files:w(Mi(C_)),terminalContexts:Mi(w_),startedAt:E,commandId:w(Or),messageId:w(wr),modelSelection:w(Di),runtimeMode:w(gi),interactionMode:w(Fi),executionIntent:w(Bi({runtimeId:E,intentId:w(E)}))});function E_(e,t){return Array.isArray(e)?e.flatMap(e=>t(e)??[]):[]}function D_(e){if(!(!e||typeof e.runtimeId!=`string`))return{runtimeId:e.runtimeId,...typeof e.intentId==`string`?{intentId:e.intentId}:{}}}function O_(e){return{...typeof e.commandId==`string`?{commandId:Or.make(e.commandId)}:{},...typeof e.messageId==`string`?{messageId:wr.make(e.messageId)}:{}}}function k_(e,t){let n=t.modelSelection(e.modelSelection);return{...n?{modelSelection:n}:{},...t.runtimeMode(e.runtimeMode)?{runtimeMode:e.runtimeMode}:{},...e.interactionMode==="default"||e.interactionMode===`plan`?{interactionMode:e.interactionMode}:{}}}function A_(e,t){if(!e||typeof e!=`object`)return null;let n=e;if(typeof n.prompt!=`string`||typeof n.startedAt!=`string`)return null;let r=D_(n.executionIntent);return{prompt:n.prompt,attachments:E_(n.attachments,t.attachment),files:E_(n.files,t.file),terminalContexts:E_(n.terminalContexts,t.terminalContext),startedAt:n.startedAt,...O_(n),...k_(n,t),...r?{executionIntent:r}:{}}}function j_(e){return{id:e.id,threadId:e.threadId,createdAt:e.createdAt,terminalId:e.terminalId,terminalLabel:e.terminalLabel,lineStart:e.lineStart,lineEnd:e.lineEnd}}function M_(e){return{prompt:e.prompt,attachments:[...e.attachments],files:[...e.files],terminalContexts:e.terminalContexts.map(j_),startedAt:e.startedAt,...e.commandId?{commandId:e.commandId}:{},...e.messageId?{messageId:e.messageId}:{},...e.modelSelection?{modelSelection:e.modelSelection}:{},...e.runtimeMode?{runtimeMode:e.runtimeMode}:{},...e.interactionMode?{interactionMode:e.interactionMode}:{},...e.executionIntent?{executionIntent:e.executionIntent}:{}}}function N_(e){return e?{...e,attachments:[...e.attachments],files:[...e.files??[]],terminalContexts:e.terminalContexts.map(e=>({...e,text:``}))}:null}function P_(e,t,n,r){let i=e[t];if(i?.stagedSubmission)return null;let a=B_(i??F_(),r,n);return a?{previousDraft:i,restoredDraft:a,drafts:{...e,[t]:a}}:null}function F_(){return{prompt:``,images:[],files:[],nonPersistedImageIds:[],persistedAttachments:[],terminalContexts:[],modelSelectionByProvider:{},activeProvider:null,runtimeMode:null,interactionMode:null,stagedSubmission:null}}function I_(e){return`${e.mimeType}\u0000${e.sizeBytes}\u0000${e.name}`}function L_(e){return`${e.terminalId}\u0000${e.lineStart}\u0000${e.lineEnd}`}function R_(e,t){let n=t.terminalId.trim(),r=t.terminalLabel.trim(),i=Dm(t.text);if(!n||!r)return null;let a=Math.max(1,Math.floor(t.lineStart));return{...t,threadId:e,terminalId:n,terminalLabel:r,lineStart:a,lineEnd:Math.max(a,Math.floor(t.lineEnd)),text:i}}function z_(e,t){let n=new Set,r=new Set,i=[];for(let a of t){let t=R_(e,a);if(!t)continue;let o=L_(t);n.has(t.id)||r.has(o)||(i.push(t),n.add(t.id),r.add(o))}return i}function B_(e,t,n){let r=H_(e,t);if(!r)return null;let i=V_(e.files??[],t.files);if(r.images.length+i.length>8)return null;let a=U_(e,t,n),o=[e.prompt,t.prompt].filter(e=>e.length>0).join(`
|
|
16
|
-
`);return{...e,prompt:Wm(o,a.contexts.length),images:r.images,files:i,persistedAttachments:r.attachments,terminalContexts:a.contexts,stashTerminalContexts:[...e.stashTerminalContexts??[],...a.restoredSnapshots]}}function V_(e,t){let n=new Set(e.map(e=>e.id));return[...e,...t.filter(e=>!n.has(e.id))]}function H_(e,t){let n=new Map(t.attachments.map(e=>[e.id,e])),r=[...e.images],i=e.persistedAttachments.filter(t=>e.images.some(e=>e.id===t.id)),a=new Set(r.map(e=>e.id)),o=new Set(r.map(I_));for(let e of t.images){let t=n.get(e.id);if(!t)return null;let s=I_(e);a.has(e.id)||o.has(s)||(r.push(e),i.push(t),a.add(e.id),o.add(s))}return r.length>8?null:{images:r,attachments:i}}function U_(e,t,n){let r=[...e.terminalContexts],i=new Set(r.map(e=>e.id)),a=new Set(r.map(L_)),o=[];for(let e of t.terminalContexts){let t=R_(n,e);!t||i.has(t.id)||a.has(L_(t))||(r.push(t),o.push(t),i.add(t.id),a.add(L_(t)))}return{contexts:r,restoredSnapshots:o}}function W_(e,t){return e.prompt===t.prompt&&JSON.stringify(e.attachments)===JSON.stringify(t.persistedAttachments)&&JSON.stringify(e.files??[])===JSON.stringify((t.files??[]).map(({file:e,type:t,...n})=>n))&&JSON.stringify(e.terminalContexts??[])===JSON.stringify(t.terminalContexts.map(({text:e,...t})=>t))&&JSON.stringify(e.stashTerminalContexts??[])===JSON.stringify(t.stashTerminalContexts??[])}function G_(e){typeof URL<`u`&&e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}function K_(e){if(!e||typeof e!=`object`)return null;let{id:t,name:n,mimeType:r,sizeBytes:i,dataUrl:a}=e;return typeof t!=`string`||typeof n!=`string`||typeof r!=`string`||typeof i!=`number`||!Number.isFinite(i)||typeof a!=`string`||t.length===0||a.length===0?null:{id:t,name:n,mimeType:r,sizeBytes:i,dataUrl:a}}function q_(e){if(!e||typeof e!=`object`)return null;let{id:t,name:n,mimeType:r,sizeBytes:i}=e;return typeof t!=`string`||t.length===0||typeof n!=`string`||typeof r!=`string`||typeof i!=`number`||!Number.isSafeInteger(i)||i<0?null:{id:t,name:n,mimeType:r,sizeBytes:i}}async function J_(e,t){let n=await Promise.all(e.map(async e=>{let n=await t.read(e);return{...e,type:`file`,file:n}}));return n.length===e.length?n:null}function Y_(e){let t=X_(e.dataUrl,e.mimeType);return t?new File([t.content],e.name,{type:t.mimeType}):null}function X_(e,t){let n=e.indexOf(`,`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n+1);if(i.length===0)return null;try{return r.includes(`;base64`)?{content:$_(i),mimeType:t}:{content:Q_(i),mimeType:Z_(r,t)}}catch{return null}}function Z_(e,t){return!e.startsWith(`data:`)||!e.includes(`;`)?t:e.slice(5,e.indexOf(`;`))||t}function Q_(e){return decodeURIComponent(e)}function $_(e){let t=atob(e),n=new Uint8Array(new ArrayBuffer(t.length));for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function ev(e){return e.flatMap(e=>{let t=Y_(e);return t?[{type:`image`,id:e.id,name:e.name,mimeType:e.mimeType,sizeBytes:e.sizeBytes,previewUrl:e.dataUrl,file:t}]:[]})}function tv(e){return{prompt:e.prompt,images:[...e.images],files:[...e.files??[]],persistedAttachments:[...e.persistedAttachments],terminalContexts:[...e.terminalContexts]}}function nv({file:e,previewUrl:t,...n}){return n}function rv(e,t){return e.prompt===t.prompt&&JSON.stringify(e.images.map(nv))===JSON.stringify(t.images.map(nv))&&JSON.stringify((e.files??[]).map(({file:e,...t})=>t))===JSON.stringify(t.files.map(({file:e,...t})=>t))&&JSON.stringify(e.persistedAttachments)===JSON.stringify(t.persistedAttachments)&&JSON.stringify(e.terminalContexts)===JSON.stringify(t.terminalContexts)}function iv(e){let{lastGeneratedPullRequestPrompt:t,...n}=e;return{...n,prompt:``,images:[],files:[],nonPersistedImageIds:[],persistedAttachments:[],terminalContexts:[],stashTerminalContexts:[]}}function N(e){return e.prompt.length===0&&e.lastGeneratedPullRequestPrompt===void 0&&e.images.length===0&&(e.files?.length??0)===0&&e.persistedAttachments.length===0&&e.terminalContexts.length===0&&Object.keys(e.modelSelectionByProvider).length===0&&e.activeProvider===null&&e.runtimeMode===null&&e.interactionMode===null&&e.stagedSubmission==null}function av(e){switch(e){case`codex`:case`claudeAgent`:case`ollama`:case`cmmd`:case`apex`:case`cursor`:case`opencode`:return e;default:return null}}function ov(e){return vi.some(t=>t===e)}function sv(e){return Ti.some(t=>t===e)}function cv(e,t,n){let r=e&&typeof e==`object`?e:null,i=r?.codex&&typeof r.codex==`object`?r.codex:null,a=r?.claudeAgent&&typeof r.claudeAgent==`object`?r.claudeAgent:null,o=ov(i?.reasoningEffort)?i.reasoningEffort:t===`codex`&&ov(n?.effort)?n.effort:void 0,s=i?.fastMode===!0?!0:i?.fastMode===!1?!1:t===`codex`&&n?.codexFastMode===!0||typeof n?.serviceTier==`string`&&n.serviceTier===`fast`||void 0,c=o!==void 0||s!==void 0?{...o===void 0?{}:{reasoningEffort:o},...s===void 0?{}:{fastMode:s}}:void 0,l=a?.thinking===!0||a?.thinking!==!1&&void 0,u=sv(a?.effort)?a.effort:void 0,d=a?.fastMode===!0||a?.fastMode!==!1&&void 0,f=typeof a?.contextWindow==`string`&&a.contextWindow.length>0?a.contextWindow:void 0,p=l!==void 0||u!==void 0||d!==void 0||f!==void 0?{...l===void 0?{}:{thinking:l},...u===void 0?{}:{effort:u},...d===void 0?{}:{fastMode:d},...f===void 0?{}:{contextWindow:f}}:void 0;return!c&&!p?null:{...c?{codex:c}:{},...p?{claudeAgent:p}:{}}}function lv(e,t){let n=e&&typeof e==`object`?e:null,r=av(n?.provider??t?.provider);if(r===null)return null;let i=n?.model??t?.model;if(typeof i!=`string`)return null;let a=On(i,r);if(!a)return null;let o=cv(n?.options?{[r]:n.options}:t?.modelOptions,r,r===`codex`?t?.legacyCodex:void 0),s=r===`codex`?o?.codex:o?.claudeAgent,c=n?.providerAccountId,l=typeof c==`string`&&c.trim().length>0?c.trim():void 0;return{provider:r,model:a,...l?{providerAccountId:l}:{},...s?{options:s}:{}}}function uv(e,t){if(e===null)return null;let n=t?.[e.provider];return{provider:e.provider,model:e.model,...`providerAccountId`in e&&e.providerAccountId?{providerAccountId:e.providerAccountId}:{},...n?{options:n}:{}}}function dv(e,t){return e?.options===void 0?cv(t):fv(cv(t),e.provider,e.options)}function fv(e,t,n){let{[t]:r,...i}=e??{},a=cv({[t]:n},t);return cv({...i,...a||{}})}function pv(e,t){let n={};if(t)for(let r of[`codex`,`claudeAgent`]){let i=t[r];i&&Object.keys(i).length>0&&(n[r]={provider:r,model:e?.provider===r?e.model:Ii[r],options:i})}return e&&(n[e.provider]=e),n}var mv=`forge:composer-drafts:v1`,hv=5,gv=ki([`local`,`worktree`]),_v=Vr(gi),vv=300,yv=fh({storage:typeof localStorage<`u`?localStorage:_r(),version:hv,canMigrate:Ev}),bv=_n(yv,vv);typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`beforeunload`,()=>{bv.flush()});var xv=Bi({prompt:E,lastGeneratedPullRequestPrompt:w(E),attachments:Mi(S_),files:w(Mi(C_)),terminalContexts:w(Mi(w_)),stashTerminalContexts:w(Mi(Bi({...w_.fields,text:E}))),modelSelectionByProvider:w(si(pi,w(Di))),activeProvider:w(yi(pi)),runtimeMode:w(gi),interactionMode:w(Fi),stagedSubmission:w(T_)});Bi({effort:w(ki(vi)),codexFastMode:w(fi),serviceTier:w(E)}),Bi({provider:w(pi),model:w(E),modelOptions:w(yi(Dr))}),Bi({stickyProvider:w(pi),stickyModel:w(E),stickyModelOptions:w(yi(Dr))});var Sv=Bi({threadId:Br,environmentId:E,projectId:Si,logicalProjectKey:w(E),createdAt:E,runtimeMode:gi,interactionMode:Fi,branch:yi(E),worktreePath:yi(E),envMode:gv,promotedTo:w(yi(Bi({environmentId:E,threadId:E}))),anchorKind:w(Wr),anchorCmmdId:w(yi(E)),linkedPullRequest:w(yi(Pi))}),Cv=Bi({draftsByThreadKey:si(E,xv),draftThreadsByThreadKey:si(E,Sv),logicalProjectDraftThreadKeyByLogicalProjectKey:si(E,E),stickyModelSelectionByProvider:w(si(pi,w(Di))),stickyActiveProvider:w(yi(pi))}),wv=Bi({version:_i,state:Cv}),Tv=Ci(wv);function Ev(e,t){if(e===null)return!0;try{let n=JSON.parse(e);if(!n||typeof n!=`object`)return!1;let r=n;return r.version===t?(Tv(n),!0):typeof r.version==`number`&&Number.isInteger(r.version)&&r.version>=1&&r.version<t&&r.state!==null&&typeof r.state==`object`}catch{return!1}}function Dv(e){if(e===null)return new Set;try{let t=Tv(JSON.parse(e));if(t.version!==hv)return null;let n=new Set;for(let e of Object.values(t.state.draftsByThreadKey)){for(let t of e.files??[])n.add(t.id);for(let t of e.stagedSubmission?.files??[])n.add(t.id)}return n}catch{return null}}function Ov(){bv.flush()}var kv=Object.freeze({draftsByThreadKey:{},draftThreadsByThreadKey:{},logicalProjectDraftThreadKeyByLogicalProjectKey:{},stickyModelSelectionByProvider:{},stickyActiveProvider:null}),Av=[],jv=[],Mv=[],Nv=[],Pv=[];Object.freeze(Av),Object.freeze(Mv),Object.freeze(Nv);var Fv=Object.freeze({}),Iv=Object.freeze({activeProvider:null,modelSelectionByProvider:Fv}),Lv=Object.freeze({prompt:``,images:Av,files:jv,nonPersistedImageIds:Mv,persistedAttachments:Nv,terminalContexts:Pv,modelSelectionByProvider:Fv,activeProvider:null,runtimeMode:null,interactionMode:null,stagedSubmission:null});function Rv(){return{prompt:``,images:[],files:[],nonPersistedImageIds:[],persistedAttachments:[],terminalContexts:[],modelSelectionByProvider:{},activeProvider:null,runtimeMode:null,interactionMode:null,stagedSubmission:null}}function zv(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.id,r=t.threadId,i=t.createdAt,a=t.lineStart,o=t.lineEnd;if(typeof n!=`string`||n.length===0||typeof r!=`string`||r.length===0||typeof i!=`string`||i.length===0||typeof a!=`number`||!Number.isFinite(a)||typeof o!=`number`||!Number.isFinite(o))return null;let s=typeof t.terminalId==`string`?t.terminalId.trim():``,c=typeof t.terminalLabel==`string`?t.terminalLabel.trim():``;if(s.length===0||c.length===0)return null;let l=Math.max(1,Math.floor(a));return{id:n,threadId:r,createdAt:i,terminalId:s,terminalLabel:c,lineStart:l,lineEnd:Math.max(l,Math.floor(o))}}function Bv(e,t){return e===`local`||e===`worktree`?e:t?`worktree`:`local`}function Vv(e){return In(e)}function Hv(e){return e.trim()}function Uv(e){return typeof e==`string`?e.trim():Rn(e)}function Wv(e,t){let n=gn(e);return n?Uv(n):t?.environmentId?Uv(C(t.environmentId,e)):e}function Gv(e){return gn(e)}function Kv(e,t){if(typeof t==`string`){let e=t.trim();return e.length>0?xa.make(e):null}return t}function P(e,t){let n=Kv(e,t);if(!n)return null;if(typeof n!=`string`){let t=Uv(n);if(e.draftsByThreadKey[t])return t;for(let[t,r]of Object.entries(e.draftThreadsByThreadKey))if(r.environmentId===n.environmentId&&r.threadId===n.threadId)return t;return t}let r=Uv(n);return r.length>0?r:null}function qv(e,t){let n=Kv(e,t);return n?typeof n==`string`?e.draftThreadsByThreadKey[n]?.threadId??Br.make(n):n.threadId:null}function Jv(e,t){let n=P(e,t);return n?e.draftsByThreadKey[n]??null:null}function Yv(e,t){return Object.values(e).includes(t)}function Xv(e,t){return{draftId:e,...t}}function Zv(e,t,n,r,i){let a=r!==void 0&&(r.environmentId!==e.environmentId||r.projectId!==e.projectId),o=i?.worktreePath===void 0?a?null:r?.worktreePath??null:i.worktreePath??null,s=i?.branch===void 0?a?null:r?.branch??null:i.branch??null,c=i?.anchorKind===void 0?r?.anchorKind:i.anchorKind??void 0;return{threadId:t,environmentId:e.environmentId,projectId:e.projectId,logicalProjectKey:n,createdAt:i?.createdAt??r?.createdAt??new Date().toISOString(),runtimeMode:i?.runtimeMode??r?.runtimeMode??`full-access`,interactionMode:i?.interactionMode??r?.interactionMode??`default`,branch:s,worktreePath:o,envMode:i?.envMode??(o?`worktree`:a?`local`:r?.envMode??`local`),promotedTo:null,cmmdTaskId:i?.cmmdTaskId===void 0?r?.cmmdTaskId??null:i.cmmdTaskId,anchorCmmdId:i?.anchorCmmdId===void 0?r?.anchorCmmdId??null:i.anchorCmmdId,linkedPullRequest:i?.linkedPullRequest===void 0?r?.linkedPullRequest??null:i.linkedPullRequest,...c===void 0?{}:{anchorKind:c}}}function Qv(e,t){return!e||!t?e===t:e.environmentId===t.environmentId&&e.threadId===t.threadId}function $v(e){return e?.promotedTo!==null&&e?.promotedTo!==void 0}function ey(e,t){return!!e&&e.threadId===t.threadId&&e.environmentId===t.environmentId&&e.projectId===t.projectId&&e.logicalProjectKey===t.logicalProjectKey&&e.createdAt===t.createdAt&&e.runtimeMode===t.runtimeMode&&e.interactionMode===t.interactionMode&&e.branch===t.branch&&e.worktreePath===t.worktreePath&&e.envMode===t.envMode&&(e.anchorKind??void 0)===(t.anchorKind??void 0)&&(e.anchorCmmdId??null)===(t.anchorCmmdId??null)&&ty(e.linkedPullRequest,t.linkedPullRequest)&&Qv(e.promotedTo,t.promotedTo)}function ty(e,t){return(e?.projectId??null)===(t?.projectId??null)&&(e?.projectRepositoryId??null)===(t?.projectRepositoryId??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.host??null)===(t?.host??null)&&(e?.repository??null)===(t?.repository??null)&&(e?.number??null)===(t?.number??null)&&(e?.url??null)===(t?.url??null)}function ny(e,t){let n=Object.fromEntries(Object.entries(e.logicalProjectDraftThreadKeyByLogicalProjectKey).filter(([,e])=>e!==t)),{[t]:r,...i}=e.draftThreadsByThreadKey,{[t]:a,...o}=e.draftsByThreadKey;return{draftsByThreadKey:o,draftThreadsByThreadKey:i,logicalProjectDraftThreadKeyByLogicalProjectKey:n}}function ry(e,t){let n={},r=new Map;if(t&&typeof t==`object`)for(let[e,n]of Object.entries(t)){if(typeof n!=`string`||n.length===0)continue;let t=xr(e);if(!t)continue;let i=gn(n);if(i){r.set(i.threadId,i.environmentId);continue}r.set(n,t.environmentId)}if(e&&typeof e==`object`)for(let[t,i]of Object.entries(e)){if(typeof t!=`string`||t.length===0||!i||typeof i!=`object`)continue;let e=i,a=gn(t),o=Wv(t),s=a?.threadId??(typeof e.threadId==`string`&&e.threadId.length>0?e.threadId:t),c=a?.environmentId??(typeof e.environmentId==`string`&&e.environmentId.length>0?e.environmentId:r.get(t)),l=e.projectId,u=e.createdAt,d=e.branch,f=e.worktreePath,p=typeof f==`string`?f:null,m=e.promotedTo,h=m&&typeof m==`object`?m:null,g=h&&typeof h.environmentId==`string`&&h.environmentId.length>0&&typeof h.threadId==`string`&&h.threadId.length>0?C(h.environmentId,h.threadId):null;if(typeof l!=`string`||l.length===0||c===void 0)continue;let _=c;n[o]={threadId:s,environmentId:_,projectId:l,logicalProjectKey:typeof e.logicalProjectKey==`string`&&e.logicalProjectKey.length>0?e.logicalProjectKey:a?Vv(Ln(_,l)):t,createdAt:typeof u==`string`&&u.length>0?u:new Date().toISOString(),runtimeMode:_v(e.runtimeMode)?e.runtimeMode:op,interactionMode:e.interactionMode===`plan`||e.interactionMode==="default"?e.interactionMode:sp,branch:typeof d==`string`?d:null,worktreePath:p,envMode:Bv(e.envMode,p),promotedTo:g}}let i={};if(t&&typeof t==`object`)for(let[e,a]of Object.entries(t)){if(typeof a!=`string`||a.length===0)continue;let t=xr(e),o=gn(a),s=Wv(a);if(i[e]=s,o&&r.set(o.threadId,o.environmentId),!t){let t=n[s];t&&!t.logicalProjectKey&&(n[s]={...t,logicalProjectKey:e});continue}n[s]?(n[s]?.projectId!==t.projectId||n[s]?.environmentId!==t.environmentId)&&(n[s]={...n[s],threadId:n[s].threadId,environmentId:t.environmentId,projectId:t.projectId,logicalProjectKey:e}):n[s]={threadId:o?.threadId??s,environmentId:t.environmentId,projectId:t.projectId,logicalProjectKey:e,createdAt:new Date().toISOString(),runtimeMode:op,interactionMode:sp,branch:null,worktreePath:null,envMode:`local`,promotedTo:null}}return{draftThreadsByThreadKey:n,logicalProjectDraftThreadKeyByLogicalProjectKey:i}}function iy(e,t){if(!e||typeof e!=`object`)return{};let n=new Map;for(let[e,r]of Object.entries(t)){let t=Gv(e);t&&n.set(t.threadId,r.environmentId)}let r={};for(let[i,a]of Object.entries(e)){if(typeof i!=`string`||i.length===0||!a||typeof a!=`object`)continue;let e=a,o=typeof e.prompt==`string`?e.prompt:``,s=typeof e.lastGeneratedPullRequestPrompt==`string`?e.lastGeneratedPullRequestPrompt:void 0,c=Array.isArray(e.attachments)?e.attachments.flatMap(e=>{let t=K_(e);return t?[t]:[]}):[],l=Array.isArray(e.files)?e.files.flatMap(e=>{let t=q_(e);return t?[t]:[]}):[],u=Array.isArray(e.terminalContexts)?e.terminalContexts.flatMap(e=>{let t=zv(e);return t?[t]:[]}):[],d=Array.isArray(e.stashTerminalContexts)?e.stashTerminalContexts.flatMap(e=>{let t=zv(e),n=typeof e.text==`string`?e.text:``;return t&&n.length>0?[{...t,text:n}]:[]}):[],f=_v(e.runtimeMode)?e.runtimeMode:null,p=e.interactionMode===`plan`||e.interactionMode==="default"?e.interactionMode:null,m=A_(e.stagedSubmission,{attachment:K_,file:q_,terminalContext:zv,modelSelection:e=>lv(e)??null,runtimeMode:_v}),h=Wm(o,u.length),g=a,_={},v=null;if(e.modelSelectionByProvider&&typeof e.modelSelectionByProvider==`object`)_=e.modelSelectionByProvider,v=av(e.activeProvider);else{let e=cv(g.modelOptions,void 0,g)??null,t=lv(g.modelSelection,{provider:g.provider,model:g.model,modelOptions:e??g.modelOptions,legacyCodex:g}),n=dv(t,e),r=uv(t,n);_=pv(r,n),v=r?.provider??null}let y=Object.keys(_).length>0||v!==null;if(o.length===0&&c.length===0&&l.length===0&&u.length===0&&d.length===0&&!y&&!f&&!p&&!m)continue;let b=gn(i)===null?t[i]===void 0?(()=>{let e=n.get(i);return e?Wv(i,{environmentId:e}):i})():i:Wv(i);r[b]={prompt:h,...s===void 0?{}:{lastGeneratedPullRequestPrompt:s},attachments:c,...l.length>0?{files:l}:{},...u.length>0?{terminalContexts:u}:{},...d.length>0?{stashTerminalContexts:d}:{},...y?{modelSelectionByProvider:_,activeProvider:v}:{},...f?{runtimeMode:f}:{},...p?{interactionMode:p}:{},...m?{stagedSubmission:m}:{}}}return r}function ay(e){if(!e||typeof e!=`object`)return kv;let t=e,n=t.draftsByThreadKey??t.draftsByThreadId,r=t.draftThreadsByThreadKey??t.draftThreadsByThreadId,i=t.logicalProjectDraftThreadKeyByLogicalProjectKey??t.projectDraftThreadKeyByProjectKey??t.projectDraftThreadIdByProjectKey??t.projectDraftThreadIdByProjectId,a=cv(t.stickyModelOptions)??{},o=lv(t.stickyModelSelection,{provider:t.stickyProvider??`codex`,model:t.stickyModel,modelOptions:a}),s=dv(o,a),c=pv(uv(o,s),s),l=av(t.stickyProvider)??null,{draftThreadsByThreadKey:u,logicalProjectDraftThreadKeyByLogicalProjectKey:d}=ry(r,i);return{draftsByThreadKey:iy(n,u),draftThreadsByThreadKey:u,logicalProjectDraftThreadKeyByLogicalProjectKey:d,stickyModelSelectionByProvider:c,stickyActiveProvider:l}}function oy(e){let t={};for(let[n,r]of Object.entries(e.draftsByThreadKey)){if(typeof n!=`string`||n.length===0)continue;let e=Object.keys(r.modelSelectionByProvider).length>0||r.activeProvider!==null;r.prompt.length===0&&r.lastGeneratedPullRequestPrompt===void 0&&r.persistedAttachments.length===0&&(r.files?.length??0)===0&&r.terminalContexts.length===0&&!e&&r.runtimeMode===null&&r.interactionMode===null&&r.stagedSubmission==null||(t[n]={prompt:r.prompt,...r.lastGeneratedPullRequestPrompt===void 0?{}:{lastGeneratedPullRequestPrompt:r.lastGeneratedPullRequestPrompt},attachments:r.persistedAttachments,...(r.files?.length??0)>0?{files:r.files.map(({file:e,type:t,...n})=>n)}:{},...r.terminalContexts.length>0?{terminalContexts:r.terminalContexts.map(e=>({id:e.id,threadId:e.threadId,createdAt:e.createdAt,terminalId:e.terminalId,terminalLabel:e.terminalLabel,lineStart:e.lineStart,lineEnd:e.lineEnd}))}:{},...r.stashTerminalContexts&&r.stashTerminalContexts.length>0?{stashTerminalContexts:r.stashTerminalContexts.map(e=>({id:e.id,threadId:e.threadId,createdAt:e.createdAt,terminalId:e.terminalId,terminalLabel:e.terminalLabel,lineStart:e.lineStart,lineEnd:e.lineEnd,text:e.text}))}:{},...e?{modelSelectionByProvider:r.modelSelectionByProvider,activeProvider:r.activeProvider}:{},...r.runtimeMode?{runtimeMode:r.runtimeMode}:{},...r.interactionMode?{interactionMode:r.interactionMode}:{},...r.stagedSubmission?{stagedSubmission:M_(r.stagedSubmission)}:{}})}return{draftsByThreadKey:t,draftThreadsByThreadKey:e.draftThreadsByThreadKey,logicalProjectDraftThreadKeyByLogicalProjectKey:e.logicalProjectDraftThreadKeyByLogicalProjectKey,stickyModelSelectionByProvider:e.stickyModelSelectionByProvider,stickyActiveProvider:e.stickyActiveProvider}}function sy(e){if(!e||typeof e!=`object`)return kv;let t=e,{draftThreadsByThreadKey:n,logicalProjectDraftThreadKeyByLogicalProjectKey:r}=ry(t.draftThreadsByThreadKey??t.draftThreadsByThreadId,t.logicalProjectDraftThreadKeyByLogicalProjectKey??t.projectDraftThreadKeyByProjectKey??t.projectDraftThreadIdByProjectKey??t.projectDraftThreadIdByProjectId),i={},a=null;if(t.stickyModelSelectionByProvider&&typeof t.stickyModelSelectionByProvider==`object`)i=t.stickyModelSelectionByProvider,a=av(t.stickyActiveProvider);else{let e=cv(t.stickyModelOptions)??{},n=lv(t.stickyModelSelection,{provider:t.stickyProvider,model:t.stickyModel,modelOptions:e}),r=dv(n,e);i=pv(uv(n,r),r),a=av(t.stickyProvider)}return{draftsByThreadKey:iy(t.draftsByThreadKey??t.draftsByThreadId,n),draftThreadsByThreadKey:n,logicalProjectDraftThreadKeyByLogicalProjectKey:r,stickyModelSelectionByProvider:i,stickyActiveProvider:a}}function cy(e){if(e.length===0)return[];try{let t=Mn(mv,wv);return!t||t.version!==hv?[]:(t.state.draftsByThreadKey[e]?.attachments??[]).map(e=>e.id)}catch{return[]}}function ly(e){if(e.length===0)return null;try{let t=bv.getItem(mv);if(typeof t!=`string`)return null;let n=Tv(JSON.parse(t));return!n||n.version!==hv?null:n.state.draftsByThreadKey[e]??null}catch{return null}}function uy(e,t,n){let r=new Set;try{bv.flush(),r=new Set(cy(e))}catch{r=new Set}n(n=>{let i=n.draftsByThreadKey[e];if(!i)return n;let a=new Set(i.images.map(e=>e.id)),o=t.filter(e=>a.has(e.id)&&r.has(e.id)),s=i.images.map(e=>e.id).filter(e=>!r.has(e)),c={...i,persistedAttachments:o,nonPersistedImageIds:s},l={...n.draftsByThreadKey};return N(c)?delete l[e]:l[e]=c,{draftsByThreadKey:l}})}function dy(e,t){return e.length>0?e:t?.prompt??``}function fy(e,t){return e?.length?e:t??[]}function py(e){let t=e.stagedSubmission;return{prompt:dy(e.prompt,t),attachments:fy(e.attachments,t?.attachments),files:fy(e.files,t?.files),terminalContexts:fy(e.terminalContexts,t?.terminalContexts)}}function my(e){let t=e.modelSelectionByProvider??{},n=av(e.activeProvider)??null,r=py(e);return{prompt:r.prompt,...e.lastGeneratedPullRequestPrompt===void 0?{}:{lastGeneratedPullRequestPrompt:e.lastGeneratedPullRequestPrompt},images:ev(r.attachments),files:r.files.map(e=>({...e,type:`file`,file:null})),nonPersistedImageIds:[],persistedAttachments:[...r.attachments],terminalContexts:r.terminalContexts.map(t=>{let n=e.stashTerminalContexts?.find(e=>e.id===t.id);return Object.assign({},t,{text:n?.text??``})}),...e.stashTerminalContexts&&e.stashTerminalContexts.length>0?{stashTerminalContexts:e.stashTerminalContexts.map(e=>({...e}))}:{},modelSelectionByProvider:t,activeProvider:n,runtimeMode:e.runtimeMode??null,interactionMode:e.interactionMode??null,stagedSubmission:N_(e.stagedSubmission)}}function hy(e){return{threadId:e.threadId,environmentId:e.environmentId,projectId:e.projectId,logicalProjectKey:e.logicalProjectKey??Vv(Ln(e.environmentId,e.projectId)),createdAt:e.createdAt,runtimeMode:e.runtimeMode,interactionMode:e.interactionMode,branch:e.branch,worktreePath:e.worktreePath,envMode:e.envMode,promotedTo:e.promotedTo?C(e.promotedTo.environmentId,e.promotedTo.threadId):null,linkedPullRequest:e.linkedPullRequest??null}}var gy=Oa()(Wf((e,t)=>{let n=e;return{draftsByThreadKey:{},draftThreadsByThreadKey:{},logicalProjectDraftThreadKeyByLogicalProjectKey:{},stickyModelSelectionByProvider:{},stickyActiveProvider:null,getComposerDraft:e=>Jv(t(),e),getDraftThreadByLogicalProjectKey:e=>t().getDraftSessionByLogicalProjectKey(e),getDraftSessionByLogicalProjectKey:e=>{let n=Hv(e);if(n.length===0)return null;let r=t().logicalProjectDraftThreadKeyByLogicalProjectKey[n];if(!r)return null;let i=t().draftThreadsByThreadKey[r];return!i||$v(i)?null:Xv(xa.make(r),i)},getDraftThreadByProjectRef:e=>t().getDraftSessionByProjectRef(e),getDraftSessionByProjectRef:e=>{for(let[n,r]of Object.entries(t().draftThreadsByThreadKey))if(!$v(r)&&r.projectId===e.projectId&&r.environmentId===e.environmentId)return Xv(xa.make(n),r);return null},getDraftSession:e=>t().draftThreadsByThreadKey[e]??null,getDraftSessionByRef:e=>{for(let n of Object.values(t().draftThreadsByThreadKey))if(n.environmentId===e.environmentId&&n.threadId===e.threadId)return n;return null},getDraftThread:e=>typeof e==`string`?t().getDraftSession(xa.make(e)):t().getDraftSessionByRef(e),getDraftThreadByRef:e=>t().getDraftSessionByRef(e),listDraftThreadKeys:()=>Object.values(t().draftThreadsByThreadKey).map(e=>Rn(C(e.environmentId,e.threadId))),hasDraftThreadsInEnvironment:e=>Object.values(t().draftThreadsByThreadKey).some(t=>t.environmentId===e),setLogicalProjectDraftThreadId:(e,t,r,i)=>{let a=Hv(e);a.length!==0&&r.length!==0&&n(e=>{let n=e.draftThreadsByThreadKey[r],o=e.logicalProjectDraftThreadKeyByLogicalProjectKey[a],s=Zv(t,i?.threadId??n?.threadId??Br.make(r),a,n,i);if(o===r&&ey(n,s))return e;let c={...e.logicalProjectDraftThreadKeyByLogicalProjectKey,[a]:r},l={...e.draftThreadsByThreadKey,[r]:s},u=e.draftsByThreadKey,d=o===void 0?void 0:l[o];return o&&o!==r&&!Yv(c,o)&&!$v(d)&&(delete l[o],e.draftsByThreadKey[o]!==void 0&&(u={...e.draftsByThreadKey},delete u[o])),{draftsByThreadKey:u,draftThreadsByThreadKey:l,logicalProjectDraftThreadKeyByLogicalProjectKey:c}})},setProjectDraftThreadId:(e,n,r)=>{t().setLogicalProjectDraftThreadId(Vv(e),e,n,r)},setDraftThreadContext:(e,r)=>{let i=P(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftThreadsByThreadKey[i];if(!t)return e;let n=r.projectRef??{environmentId:t.environmentId,projectId:t.projectId};if(n.projectId.length===0||n.environmentId.length===0)return e;let a=n.environmentId!==t.environmentId||n.projectId!==t.projectId,o=r.worktreePath===void 0?a?null:t.worktreePath:r.worktreePath??null,s=r.branch===void 0?a?null:t.branch:r.branch??null,c=r.anchorKind===void 0?t.anchorKind:r.anchorKind??void 0,l={threadId:t.threadId,environmentId:n.environmentId,projectId:n.projectId,logicalProjectKey:t.logicalProjectKey,createdAt:r.createdAt===void 0?t.createdAt:r.createdAt||t.createdAt,runtimeMode:r.runtimeMode??t.runtimeMode,interactionMode:r.interactionMode??t.interactionMode,branch:s,worktreePath:o,envMode:r.envMode??(o?`worktree`:a?`local`:t.envMode??`local`),promotedTo:t.promotedTo??null,cmmdTaskId:r.cmmdTaskId===void 0?t.cmmdTaskId??null:r.cmmdTaskId,anchorCmmdId:r.anchorCmmdId===void 0?t.anchorCmmdId??null:r.anchorCmmdId,linkedPullRequest:r.linkedPullRequest===void 0?t.linkedPullRequest??null:r.linkedPullRequest,...c===void 0?{}:{anchorKind:c}};return l.environmentId===t.environmentId&&l.projectId===t.projectId&&l.logicalProjectKey===t.logicalProjectKey&&l.createdAt===t.createdAt&&l.runtimeMode===t.runtimeMode&&l.interactionMode===t.interactionMode&&l.branch===t.branch&&l.worktreePath===t.worktreePath&&l.envMode===t.envMode&&(l.anchorKind??void 0)===(t.anchorKind??void 0)&&(l.anchorCmmdId??null)===(t.anchorCmmdId??null)&&ty(l.linkedPullRequest,t.linkedPullRequest)&&Qv(l.promotedTo,t.promotedTo)?e:{draftThreadsByThreadKey:{...e.draftThreadsByThreadKey,[i]:l}}})},clearProjectDraftThreadId:e=>{n(t=>{let n=Object.entries(t.draftThreadsByThreadKey).find(([,t])=>t.projectId===e.projectId&&t.environmentId===e.environmentId);return n?ny(t,n[0]):t})},clearProjectDraftThreadById:(e,r)=>{let i=P(t(),r)??``;i.length!==0&&n(t=>{let n=t.draftThreadsByThreadKey[i];return!n||n.projectId!==e.projectId||n.environmentId!==e.environmentId?t:ny(t,i)})},markDraftThreadPromoting:(e,r)=>{let i=P(t(),e);i&&n(e=>{let t=e.draftThreadsByThreadKey[i];if(!t)return e;let n=r??C(t.environmentId,t.threadId);return Qv(t.promotedTo,n)?e:{draftThreadsByThreadKey:{...e.draftThreadsByThreadKey,[i]:{...t,promotedTo:n}}}})},finalizePromotedDraftThread:e=>{let r=P(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftThreadsByThreadKey[r];if(!$v(t))return e;let n=Uv(t.promotedTo),i=e.draftsByThreadKey[n],a=e.draftsByThreadKey[r];return ny(a?{...e,draftsByThreadKey:{...e.draftsByThreadKey,[n]:i?{...i,modelSelectionByProvider:{...i.modelSelectionByProvider,...a.modelSelectionByProvider},activeProvider:a.activeProvider,runtimeMode:a.runtimeMode,interactionMode:a.interactionMode}:a}}:e,r)})},clearDraftThread:e=>{let r=P(t(),e)??``;if(r.length===0)return;let i=t().draftsByThreadKey[r];if(i)for(let e of i.images)G_(e.previewUrl);n(e=>{let t=e.draftThreadsByThreadKey[r]!==void 0,n=Object.values(e.logicalProjectDraftThreadKeyByLogicalProjectKey).includes(r),i=e.draftsByThreadKey[r]!==void 0;return!t&&!n&&!i?e:ny(e,r)})},setStickyModelSelection:e=>{let t=lv(e);n(e=>{if(!t)return e;let n={...e.stickyModelSelectionByProvider,[t.provider]:t};return rt(e.stickyModelSelectionByProvider,n)?e.stickyActiveProvider===t.provider?e:{stickyActiveProvider:t.provider}:{stickyModelSelectionByProvider:n,stickyActiveProvider:t.provider}})},applyStickyState:e=>{let r=P(t(),e)??``;r.length!==0&&n(e=>{let t=e.stickyModelSelectionByProvider,n=e.stickyActiveProvider;if(Object.keys(t).length===0&&n===null)return e;let i=e.draftsByThreadKey[r]??Rv(),a={...i.modelSelectionByProvider};for(let[e,n]of Object.entries(t))if(n){let t=a[e];a[e]={...n,model:t?.model??n.model}}if(rt(i.modelSelectionByProvider,a)&&i.activeProvider===n)return e;let o={...i,modelSelectionByProvider:a,activeProvider:n},s={...e.draftsByThreadKey};return N(o)?delete s[r]:s[r]=o,{draftsByThreadKey:s}})},setPrompt:(e,r)=>{let i=P(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??Rv();if(t.prompt===r)return e;let n={...t,prompt:r},a={...e.draftsByThreadKey};return N(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},setGeneratedPullRequestPrompt:(e,r)=>{let i=P(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??Rv();return{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,lastGeneratedPullRequestPrompt:r}}}})},setPendingAutoSubmit:(e,r)=>{let i=P(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??Rv();if((t.pendingAutoSubmit??!1)===r)return e;let n=r?{...t,pendingAutoSubmit:!0}:(()=>{let{pendingAutoSubmit:e,...n}=t;return n})(),a={...e.draftsByThreadKey};return N(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},stageComposerSubmission:(e,r,i,a,o,s,c)=>{let l=P(t(),e)??``;l.length!==0&&(n(e=>{let t=e.draftsByThreadKey[l];if(!t)return e;let n={prompt:t.prompt,attachments:[...c??t.persistedAttachments],files:(t.files??[]).map(({file:e,type:t,...n})=>n),terminalContexts:[...t.terminalContexts],startedAt:r,commandId:i,messageId:a,...o?{executionIntent:o}:{},...s},u={...e.draftsByThreadKey};return u[l]={...t,stagedSubmission:n},{draftsByThreadKey:u}}),bv.flush())},setStagedComposerExecutionIntent:(e,r)=>{let i=P(t(),e)??``;i.length!==0&&(n(e=>{let t=e.draftsByThreadKey[i];return t?.stagedSubmission?{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,stagedSubmission:{...t.stagedSubmission,executionIntent:r}}}}:e}),bv.flush())},clearStagedComposerSubmission:e=>{let r=P(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t?.stagedSubmission)return e;let n={...t,stagedSubmission:null},i={...e.draftsByThreadKey};return N(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},setTerminalContexts:(e,r,i)=>{let a=P(t(),e),o=qv(t(),e);if(!a||!o)return;let s=z_(o,r);n(e=>{let t=e.draftsByThreadKey[a]??Rv(),n={...t,prompt:Wm(t.prompt,s.length),terminalContexts:s,...i?.preserveTextForReload?{stashTerminalContexts:s}:{stashTerminalContexts:[]}},r={...e.draftsByThreadKey};return N(n)?delete r[a]:r[a]=n,{draftsByThreadKey:r}})},setModelSelection:(e,r)=>{let i=P(t(),e)??``;if(i.length===0)return;let a=lv(r);n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??Rv(),r={...n.modelSelectionByProvider};if(a){let e=r[a.provider];a.options===void 0?r[a.provider]={provider:a.provider,model:a.model,...`providerAccountId`in a&&a.providerAccountId?{providerAccountId:a.providerAccountId}:e&&`providerAccountId`in e&&e.providerAccountId?{providerAccountId:e.providerAccountId}:{},...e?.options?{options:e.options}:{}}:r[a.provider]=a}let o=a?.provider??n.activeProvider;if(rt(n.modelSelectionByProvider,r)&&n.activeProvider===o)return e;let s={...n,modelSelectionByProvider:r,activeProvider:o},c={...e.draftsByThreadKey};return N(s)?delete c[i]:c[i]=s,{draftsByThreadKey:c}})},setModelOptions:(e,r)=>{let i=P(t(),e)??``;if(i.length===0)return;let a=cv(r);n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??Rv(),r={...n.modelSelectionByProvider};for(let e of[`codex`,`claudeAgent`]){if(!a||!(e in a))continue;let t=a[e],n=r[e];if(t)r[e]={provider:e,model:n?.model??Ii[e],...n&&`providerAccountId`in n&&n.providerAccountId?{providerAccountId:n.providerAccountId}:{},options:t};else if(n?.options){let{options:t,...i}=n;r[e]=i}}if(rt(n.modelSelectionByProvider,r))return e;let o={...n,modelSelectionByProvider:r},s={...e.draftsByThreadKey};return N(o)?delete s[i]:s[i]=o,{draftsByThreadKey:s}})},setProviderModelOptions:(e,r,i,a)=>{let o=P(t(),e)??``;if(o.length===0)return;let s=av(r);if(s===null)return;let c=cv({[s]:i},s)?.[s];n(e=>{let t=e.draftsByThreadKey[o]??Rv(),n={...t.modelSelectionByProvider},r=n[s];if(c)n[s]={provider:s,model:r?.model??Ii[s],...r&&`providerAccountId`in r&&r.providerAccountId?{providerAccountId:r.providerAccountId}:{},options:c};else if(r?.options){let{options:e,...t}=r;n[s]=t}let i=e.stickyModelSelectionByProvider,l=e.stickyActiveProvider;if(a?.persistSticky===!0){i={...e.stickyModelSelectionByProvider};let n=i[s]??t.modelSelectionByProvider[s]??{provider:s,model:Ii[s]};if(c)i[s]={...n,provider:s,options:c};else if(n.options){let{options:e,...t}=n;i[s]=t}l=t.activeProvider??s}if(rt(t.modelSelectionByProvider,n)&&rt(e.stickyModelSelectionByProvider,i)&&e.stickyActiveProvider===l)return e;let u={...t,modelSelectionByProvider:n},d={...e.draftsByThreadKey};return N(u)?delete d[o]:d[o]=u,{draftsByThreadKey:d,...a?.persistSticky===!0?{stickyModelSelectionByProvider:i,stickyActiveProvider:l}:{}}})},setRuntimeMode:(e,r)=>{let i=P(t(),e)??``;if(i.length===0)return;let a=_v(r)?r:null;n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??Rv();if(n.runtimeMode===a)return e;let r={...n,runtimeMode:a},o={...e.draftsByThreadKey};return N(r)?delete o[i]:o[i]=r,{draftsByThreadKey:o}})},setInteractionMode:(e,r)=>{let i=P(t(),e)??``;if(i.length===0)return;let a=r===`plan`||r==="default"?r:null;n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??Rv();if(n.interactionMode===a)return e;let r={...n,interactionMode:a},o={...e.draftsByThreadKey};return N(r)?delete o[i]:o[i]=r,{draftsByThreadKey:o}})},addImage:(e,n)=>{let r=P(t(),e),i=qv(t(),e);!r||!i||t().addImages(typeof e==`string`?xa.make(r):e,[n])},addImages:(e,r)=>{let i=P(t(),e)??``;i.length!==0&&r.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??Rv(),n=new Set(t.images.map(e=>e.id)),a=new Set(t.images.map(e=>I_(e))),o=new Set(t.images.map(e=>e.previewUrl)),s=[];for(let e of r){let t=I_(e);if(n.has(e.id)||a.has(t)){o.has(e.previewUrl)||G_(e.previewUrl);continue}s.push(e),n.add(e.id),a.add(t),o.add(e.previewUrl)}return s.length===0?e:{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,images:[...t.images,...s]}}}})},addFiles:(e,r)=>{let i=P(t(),e)??``;i.length!==0&&r.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??Rv(),n=new Set((t.files??[]).map(e=>e.id)),a=Math.max(0,8-t.images.length-(t.files?.length??0)),o=r.filter(e=>!n.has(e.id)).slice(0,a);return o.length===0?e:{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,files:[...t.files??[],...o]}}}})},setFiles:(e,r)=>{let i=P(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??Rv();return{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,files:[...r]}}}})},removeImage:(e,r)=>{let i=P(t(),e)??``;if(i.length===0)return;let a=t().draftsByThreadKey[i];if(!a)return;let o=a.images.find(e=>e.id===r);o&&G_(o.previewUrl),n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={...t,images:t.images.filter(e=>e.id!==r),nonPersistedImageIds:t.nonPersistedImageIds.filter(e=>e!==r),persistedAttachments:t.persistedAttachments.filter(e=>e.id!==r)},a={...e.draftsByThreadKey};return N(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},insertTerminalContext:(e,r,i,a)=>{let o=P(t(),e),s=qv(t(),e);if(!o||!s)return!1;let c=!1;return n(e=>{let t=e.draftsByThreadKey[o]??Rv(),n=R_(s,i);if(!n)return e;let l=L_(n);if(t.terminalContexts.some(e=>e.id===n.id)||t.terminalContexts.some(e=>L_(e)===l))return e;c=!0;let u=Math.max(0,Math.min(t.terminalContexts.length,a)),d={...t,prompt:r,terminalContexts:[...t.terminalContexts.slice(0,u),n,...t.terminalContexts.slice(u)]};return{draftsByThreadKey:{...e.draftsByThreadKey,[o]:d}}}),c},addTerminalContext:(e,n)=>{let r=P(t(),e),i=qv(t(),e);!r||!i||t().addTerminalContexts(typeof e==`string`?xa.make(r):e,[n])},addTerminalContexts:(e,r)=>{let i=P(t(),e),a=qv(t(),e);!i||!a||r.length===0||n(e=>{let t=e.draftsByThreadKey[i]??Rv(),n=z_(a,[...t.terminalContexts,...r]).slice(t.terminalContexts.length);return n.length===0?e:{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,prompt:Wm(t.prompt,t.terminalContexts.length+n.length),terminalContexts:[...t.terminalContexts,...n]}}}})},removeTerminalContext:(e,r)=>{let i=P(t(),e)??``;i.length!==0&&r.length!==0&&n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={...t,terminalContexts:t.terminalContexts.filter(e=>e.id!==r)},a={...e.draftsByThreadKey};return N(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},clearTerminalContexts:e=>{let r=P(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t||t.terminalContexts.length===0)return e;let n={...t,terminalContexts:[]},i={...e.draftsByThreadKey};return N(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},clearPersistedAttachments:e=>{let r=P(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t)return e;let n={...t,persistedAttachments:[],nonPersistedImageIds:[]},i={...e.draftsByThreadKey};return N(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},syncPersistedAttachments:(e,r)=>{let i=P(t(),e);if(!i)return;let a=new Set(r.map(e=>e.id));n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={...t,persistedAttachments:r,nonPersistedImageIds:t.nonPersistedImageIds.filter(e=>!a.has(e))},o={...e.draftsByThreadKey};return N(n)?delete o[i]:o[i]=n,{draftsByThreadKey:o}}),Promise.resolve().then(()=>{uy(i,r,n)})},moveComposerDraft:(e,r)=>{let i=dm(t().draftsByThreadKey,e,r);return i!==null&&(n({draftsByThreadKey:i}),bv.flush(),!0)},clearComposerContent:e=>{let r=P(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t)return e;let n=iv(t),i={...e.draftsByThreadKey};return N(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},clearComposerContentIfUnchanged:(e,r)=>{let i=P(t(),e)??``;if(i.length===0)return!1;let a=!1;return n(e=>{let t=e.draftsByThreadKey[i];if(!t||!rv(t,r))return e;let n=iv(t),o={...e.draftsByThreadKey};return N(n)?delete o[i]:o[i]=n,a=!0,{draftsByThreadKey:o}}),a},restoreComposerStash:(e,r)=>{let i=P(t(),e)??``,a=qv(t(),e);if(i.length===0||!a)return!1;let o,s;if(n(e=>{let t=P_(e.draftsByThreadKey,i,a,r);return t?(o=t.previousDraft,s=t.restoredDraft,{draftsByThreadKey:t.drafts}):e}),!s)return!1;let c=!1;try{bv.flush();let e=ly(i),n=t().draftsByThreadKey[i];e!==null&&n===s&&W_(e,n)&&(c=!0)}catch{}if(c&&(r.onPersisted?.()??!0))return!0;n(e=>{if(e.draftsByThreadKey[i]!==s)return e;let t={...e.draftsByThreadKey};return o?t[i]=o:delete t[i],{draftsByThreadKey:t}});try{bv.flush()}catch{}return!1}}},{name:mv,version:hv,storage:Hf(()=>bv),migrate:ay,partialize:oy,merge:(e,t)=>{let n=sy(e),r=Object.fromEntries(Object.entries(n.draftsByThreadKey).map(([e,t])=>[e,my(t)])),i=Object.fromEntries(Object.entries(n.draftThreadsByThreadKey).map(([e,t])=>[e,hy(t)]));return{...t,draftsByThreadKey:r,draftThreadsByThreadKey:i,logicalProjectDraftThreadKeyByLogicalProjectKey:n.logicalProjectDraftThreadKeyByLogicalProjectKey,stickyModelSelectionByProvider:n.stickyModelSelectionByProvider??{},stickyActiveProvider:n.stickyActiveProvider??null}}}));function _y(e){let t=(0,A.c)(2),n;return t[0]===e?n=t[1]:(n=t=>Jv(t,e)??Lv,t[0]=e,t[1]=n),gy(n)}function vy(e){let t=(0,A.c)(2),n;return t[0]===e?n=t[1]:(n=t=>{let n=Jv(t,e);return n?{activeProvider:n.activeProvider,modelSelectionByProvider:n.modelSelectionByProvider}:Iv},t[0]=e,t[1]=n),gy(eh(n))}function yy(e){let t=gy.getState();for(let[n,r]of Object.entries(t.draftThreadsByThreadKey))r.environmentId===e.environmentId&&r.threadId===e.threadId&&t.markDraftThreadPromoting(xa.make(n),e)}function by(e){for(let t of e)yy(t)}function xy(e){let t=gy.getState();for(let[n,r]of Object.entries(t.draftThreadsByThreadKey))r.promotedTo&&r.promotedTo.environmentId===e.environmentId&&r.promotedTo.threadId===e.threadId&&t.finalizePromotedDraftThread(xa.make(n))}var Sy=null;function Cy(e){Sy=e}function wy(){if(Sy===null)throw Error(`Environment event handling was used before the service was configured.`);return Sy}function Ty(e){let t=new Set,n=new Map(e.snapshotThreads.map(e=>[e.key,e]));for(let n of e.snapshotThreads)n.deletedAt===null&&n.archivedAt===null&&t.add(n.key);for(let r of e.draftThreadKeys){let e=n.get(r);e&&(e.deletedAt!==null||e.archivedAt!==null)||t.add(r)}return t}function Ey(e){let t=new Map,n=!1;for(let r of e)switch(r.type){case`thread.turn-diff-completed`:case`thread.reverted`:n=!0;break;case`thread.created`:t.set(r.payload.threadId,{clearPromotedDraft:!0,clearDeletedThread:!1,removeTerminalState:!1});break;case`thread.deleted`:t.set(r.payload.threadId,{clearPromotedDraft:!1,clearDeletedThread:!0,removeTerminalState:!0});break;case`thread.archived`:t.set(r.payload.threadId,{clearPromotedDraft:!1,clearDeletedThread:!1,removeTerminalState:!0});break;case`thread.unarchived`:t.set(r.payload.threadId,{clearPromotedDraft:!1,clearDeletedThread:!1,removeTerminalState:!1})}let r=[],i=[],a=[];for(let[e,n]of t)n.clearPromotedDraft&&r.push(e),n.clearDeletedThread&&i.push(e),n.removeTerminalState&&a.push(e);return{promoteDraftThreadIds:r,clearDeletedThreadIds:i,removeTerminalStateThreadIds:a,needsProviderInvalidation:n}}var Dy={threadRef:null,open:!1,minimized:!1,dock:`floating`,position:null};function Oy(e){return{x:Math.max(12,Math.min(e.position.x,e.viewportWidth-e.width-12)),y:Math.max(12,Math.min(e.position.y,e.viewportHeight-e.height-12))}}function ky(e,t){return{...e,threadRef:t,open:!0,minimized:!1}}function Ay(e){let t=e.companion.threadRef;return!e.companion.open||t===null?!1:e.routeThreadRef?.environmentId!==t.environmentId||e.routeThreadRef.threadId!==t.threadId}var jy=`forge:ui-state:v1`,My=[`t3code:ui-state:v1`,`t3code:renderer-state:v8`,`t3code:renderer-state:v7`,`t3code:renderer-state:v6`,`t3code:renderer-state:v5`,`t3code:renderer-state:v4`,`t3code:renderer-state:v3`,`codething:renderer-state:v4`,`codething:renderer-state:v3`,`codething:renderer-state:v2`,`codething:renderer-state:v1`],Ny=`months`,Py=new Set([`weeks`,`months`,`quarters`]);function Fy(e){return typeof e==`string`&&Py.has(e)?e:Ny}function Iy(e){return Number.isFinite(e)?Math.round(Math.min(560,Math.max(200,e))):360}var Ly={projectExpandedById:{},projectOrder:[],projectGroupOrder:[],lastActiveProject:null,threadLastVisitedAtById:{},threadChangedFilesExpandedById:{},pinnedThreadById:{},threadLinkedPrById:{},workspaceDensityById:{},timelineWorkColumnWidth:360,timelineScale:Ny,projectLeadCompanion:Dy},Ry=new Set,zy=[],By=new Map,Vy=!1;function Hy(){if(typeof window>`u`)return Ly;try{let e=window.localStorage.getItem(jy);if(!e){for(let e of My){let t=window.localStorage.getItem(e);if(t)return qy(JSON.parse(t)),Ly}return Ly}let t=JSON.parse(e);return qy(t),{...Ly,projectGroupOrder:Uy(t.projectGroupOrderKeys),threadChangedFilesExpandedById:Ky(t.threadChangedFilesExpandedById),pinnedThreadById:Wy(t.pinnedThreadKeys),threadLinkedPrById:Gy(t.threadLinkedPrById),timelineWorkColumnWidth:Iy(t.timelineWorkColumnWidth??360),timelineScale:Fy(t.timelineScale)}}catch{return Ly}}function Uy(e){return Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`&&e.length>0))]:[]}function Wy(e){if(!Array.isArray(e))return{};let t={};for(let n of e)typeof n==`string`&&n.length>0&&(t[n]=!0);return t}function Gy(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e))typeof n==`string`&&n.length!==0&&typeof r==`string`&&r.trim().length!==0&&(t[n]=r);return t}function Ky(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e)){if(!n||!r||typeof r!=`object`)continue;let e={};for(let[t,n]of Object.entries(r))t&&typeof n==`boolean`&&n===!1&&(e[t]=!1);Object.keys(e).length>0&&(t[n]=e)}return t}function qy(e){Ry.clear(),zy.length=0;for(let t of e.expandedProjectCwds??[])typeof t==`string`&&t.length>0&&Ry.add(t);for(let t of e.projectOrderCwds??[])typeof t==`string`&&t.length>0&&!zy.includes(t)&&zy.push(t)}function Jy(e){if(!(typeof window>`u`))try{let t=Object.entries(e.projectExpandedById).filter(([,e])=>e).flatMap(([e])=>{let t=By.get(e);return t?[t]:[]}),n=e.projectOrder.flatMap(e=>{let t=By.get(e);return t?[t]:[]}),r=Object.fromEntries(Object.entries(e.threadChangedFilesExpandedById).flatMap(([e,t])=>{let n=Object.fromEntries(Object.entries(t).filter(([,e])=>e===!1));return Object.keys(n).length>0?[[e,n]]:[]}));if(window.localStorage.setItem(jy,JSON.stringify({expandedProjectCwds:t,projectOrderCwds:n,projectGroupOrderKeys:e.projectGroupOrder,threadChangedFilesExpandedById:r,pinnedThreadKeys:Object.keys(e.pinnedThreadById).filter(t=>e.pinnedThreadById[t]),threadLinkedPrById:e.threadLinkedPrById,timelineWorkColumnWidth:e.timelineWorkColumnWidth,timelineScale:e.timelineScale})),!Vy){Vy=!0;for(let e of My)window.localStorage.removeItem(e)}}catch{}}var Yy=new Aa(Jy,{wait:500});function Xy(e,t){let n=Object.entries(e),r=Object.entries(t);if(n.length!==r.length)return!1;for(let[e,r]of n)if(t[e]!==r)return!1;return!0}function Zy(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Qy(e,t){let n=Object.entries(e),r=Object.entries(t);if(n.length!==r.length)return!1;for(let[e,r]of n)if(!(e in t)||!Xy(r,t[e]))return!1;return!0}function $y(e,t){let n=new Map(By),r=new Map([...n.entries()].map(([e,t])=>[t,e]));By.clear();for(let e of t)By.set(e.key,e.cwd);let i=n.size!==By.size||t.some(e=>n.get(e.key)!==e.cwd),a={},o=e.projectExpandedById,s=new Map(zy.map((e,t)=>[e,t])),c=t.map((e,t)=>{let n=r.get(e.cwd),i=o[e.key]??(n?o[n]:void 0)??(Ry.size>0?Ry.has(e.cwd):!0);return a[e.key]=i,{id:e.key,cwd:e.cwd,incomingIndex:t}}),l=e.projectOrder.length>0?(()=>{let t=new Map(c.map(e=>[e.cwd,e.id])),r=new Set,i=[];for(let o of e.projectOrder){let e=(o in a?o:void 0)??(()=>{let e=n.get(o);return e?t.get(e):void 0})();!e||r.has(e)||(r.add(e),i.push(e))}for(let e of c)r.has(e.id)||i.push(e.id);return i})():c.map(e=>({id:e.id,incomingIndex:e.incomingIndex,orderIndex:s.get(e.cwd)??zy.length+e.incomingIndex})).toSorted((e,t)=>{let n=e.orderIndex-t.orderIndex;return n===0?e.incomingIndex-t.incomingIndex:n}).map(e=>e.id);return Xy(e.projectExpandedById,a)&&Zy(e.projectOrder,l)&&!i?e:{...e,projectExpandedById:a,projectOrder:l}}function eb(e,t){let n=new Set(t.map(e=>e.key)),r=Object.fromEntries(Object.entries(e.threadLastVisitedAtById).filter(([e])=>n.has(e)));for(let e of t)r[e.key]===void 0&&e.seedVisitedAt!==void 0&&e.seedVisitedAt.length>0&&(r[e.key]=e.seedVisitedAt);let i=Object.fromEntries(Object.entries(e.threadChangedFilesExpandedById).filter(([e])=>n.has(e))),a=Object.fromEntries(Object.entries(e.pinnedThreadById).filter(([e,t])=>n.has(e)&&t)),o=Object.fromEntries(Object.entries(e.threadLinkedPrById).filter(([e])=>n.has(e)));return Xy(e.threadLastVisitedAtById,r)&&Qy(e.threadChangedFilesExpandedById,i)&&Xy(e.pinnedThreadById,a)&&Xy(e.threadLinkedPrById,o)?e:{...e,threadLastVisitedAtById:r,threadChangedFilesExpandedById:i,pinnedThreadById:a,threadLinkedPrById:o}}function tb(e,t,n){let r=n??new Date().toISOString(),i=Date.parse(r),a=e.threadLastVisitedAtById[t],o=a?Date.parse(a):NaN;return Number.isFinite(o)&&Number.isFinite(i)&&o>=i?e:{...e,threadLastVisitedAtById:{...e.threadLastVisitedAtById,[t]:r}}}function nb(e,t,n){if(!n)return e;let r=Date.parse(n);if(Number.isNaN(r))return e;let i=new Date(r-1).toISOString();return e.threadLastVisitedAtById[t]===i?e:{...e,threadLastVisitedAtById:{...e.threadLastVisitedAtById,[t]:i}}}function rb(e,t){let n=t in e.threadLastVisitedAtById,r=t in e.threadChangedFilesExpandedById,i=t in e.pinnedThreadById,a=t in e.threadLinkedPrById;if(!n&&!r&&!i&&!a)return e;let o={...e.threadLastVisitedAtById},s={...e.threadChangedFilesExpandedById},c={...e.pinnedThreadById},l={...e.threadLinkedPrById};return delete o[t],delete s[t],delete c[t],delete l[t],{...e,threadLastVisitedAtById:o,threadChangedFilesExpandedById:s,pinnedThreadById:c,threadLinkedPrById:l}}function ib(e,t,n){if(e.pinnedThreadById[t]===!0===n)return e;if(n)return{...e,pinnedThreadById:{...e.pinnedThreadById,[t]:!0}};let r={...e.pinnedThreadById};return delete r[t],{...e,pinnedThreadById:r}}function ab(e,t){return ib(e,t,e.pinnedThreadById[t]!==!0)}function ob(e,t,n){return e.threadLinkedPrById[t]===n?e:{...e,threadLinkedPrById:{...e.threadLinkedPrById,[t]:n}}}function sb(e,t){if(!(t in e.threadLinkedPrById))return e;let n={...e.threadLinkedPrById};return delete n[t],{...e,threadLinkedPrById:n}}function cb(e,t,n,r){let i=e.threadChangedFilesExpandedById[t]??{};return i[n]===r?e:{...e,threadChangedFilesExpandedById:{...e.threadChangedFilesExpandedById,[t]:{...i,[n]:r}}}}function lb(e,t){return e.lastActiveProject?.environmentId===t?.environmentId&&e.lastActiveProject?.projectId===t?.projectId?e:{...e,lastActiveProject:t}}function ub(e,t,n){return e.workspaceDensityById[t]===n?e:{...e,workspaceDensityById:{...e.workspaceDensityById,[t]:n}}}function db(e,t){let n=e.projectExpandedById[t]??!0;return{...e,projectExpandedById:{...e.projectExpandedById,[t]:!n}}}function fb(e,t,n){return(e.projectExpandedById[t]??!0)===n?e:{...e,projectExpandedById:{...e.projectExpandedById,[t]:n}}}function pb(e,t,n){if(t.length===0)return e;let r=new Set(t),i=new Set(n);if(t.every(e=>i.has(e)))return e;let a=e.projectOrder.findIndex(e=>i.has(e));if(a<0)return e;let o=[...e.projectOrder],s=[],c=0;for(let e=o.length-1;e>=0;e--)r.has(o[e])&&(s.unshift(o.splice(e,1)[0]),e<a&&c++);if(s.length===0)return e;let l=a-Math.max(0,c-1);return o.splice(l,0,...s),{...e,projectOrder:o}}function mb(e,t){let n=[...new Set(t)],r=new Set(n),i=e.projectGroupOrder.filter(e=>r.has(e)),a=new Set(i);for(let e of n)a.has(e)||i.push(e);return Zy(e.projectGroupOrder,i)?e:{...e,projectGroupOrder:i}}function hb(e,t,n){if(t===n)return e;let r=e.projectGroupOrder.indexOf(t),i=e.projectGroupOrder.indexOf(n);if(r<0||i<0)return e;let a=[...e.projectGroupOrder],[o]=a.splice(r,1);return o===void 0?e:(a.splice(i,0,o),{...e,projectGroupOrder:a})}var gb=Oa(e=>({...Hy(),syncProjects:t=>e(e=>$y(e,t)),syncProjectGroups:t=>e(e=>mb(e,t)),syncThreads:t=>e(e=>eb(e,t)),markThreadVisited:(t,n)=>e(e=>tb(e,t,n)),markThreadUnread:(t,n)=>e(e=>nb(e,t,n)),clearThreadUi:t=>e(e=>rb(e,t)),setThreadPinned:(t,n)=>e(e=>ib(e,t,n)),toggleThreadPinned:t=>e(e=>ab(e,t)),setThreadLinkedPr:(t,n)=>e(e=>ob(e,t,n)),clearThreadLinkedPr:t=>e(e=>sb(e,t)),setThreadChangedFilesExpanded:(t,n,r)=>e(e=>cb(e,t,n,r)),setWorkspaceDensity:(t,n)=>e(e=>ub(e,t,n)),toggleProject:t=>e(e=>db(e,t)),setProjectExpanded:(t,n)=>e(e=>fb(e,t,n)),reorderProjects:(t,n)=>e(e=>pb(e,t,n)),reorderProjectGroups:(t,n)=>e(e=>hb(e,t,n)),setLastActiveProject:t=>e(e=>lb(e,t)),setTimelineWorkColumnWidth:t=>e(e=>({...e,timelineWorkColumnWidth:Iy(t)})),setTimelineScale:t=>e(e=>({...e,timelineScale:t})),openProjectLeadCompanion:t=>e(e=>({...e,projectLeadCompanion:ky(e.projectLeadCompanion,t)})),closeProjectLeadCompanion:()=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,open:!1}})),setProjectLeadCompanionMinimized:t=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,minimized:t}})),setProjectLeadCompanionDock:t=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,dock:t}})),setProjectLeadCompanionPosition:t=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,position:t}}))}));function _b(e){gb.getState().openProjectLeadCompanion(e)}gb.subscribe(e=>Yy.maybeExecute(e)),typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`beforeunload`,()=>{Yy.flush()});var F=new Map;function vb(e){return!e.isWorking||e.msSinceLastEvent<e.stallThresholdMs?`none`:e.recoveryAttempts<e.maxResubscribeAttempts?`resubscribe`:e.recoveryAttempts<e.maxTotalAttempts?`reconnect`:`none`}var yb=3e4,bb=1e4,xb=[/(?:^|\s)\/(?:Users|var|private|tmp|project|repo|home)\/[^\s'"<>)]*/i,/(?:^|\s)[A-Za-z]:\\[^\s'"<>)]*/];function Sb(e){let t=e?.trim();return t&&t.length>0?t:null}function Cb(e){return Sb(e)??`Project`}function wb(e,t=`safe`){let n=Sb(e);return n?t===`full`?n:n.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)??`Local checkout`:`Local checkout`}function Tb(e,t=`Something went wrong. Try again.`){let n=e instanceof Error?e.message:typeof e==`string`?e:String(e),r=fr(n,{fallback:t});return!r||xb.some(e=>e.test(r))?t:r}var Eb=`Thread not found or you no longer have access.`;function Db(e){if(e==null)return Eb;let t=Tb(qt(e)?ke(e):e,Eb);return/\bnot found\b/i.test(t)?Eb:t}function Ob(e,t,n){S.getState().setThreadSubscriptionError(e,t,Db(n))}var kb=null;function Ab(e){kb=e}function jb(){if(kb===null)throw Error(`Thread detail subscriptions were used before the service was configured.`);return kb}var Mb=9e5,Nb=()=>void 0;function Pb(e,t){return Rn(C(e,t))}function Fb(e){return e.evictionTimeoutId!==null&&(clearTimeout(e.evictionTimeoutId),e.evictionTimeoutId=null),e}function Ib(e){let t=C(e.environmentId,e.threadId),n=S.getState(),r=En(n,t);if(r&&Rb(r))return!0;let i=Cn(n,t);return i?Lb(i.session?.orchestrationStatus)||i.latestTurn?.state===`running`||i.pendingSourceProposedPlan!==void 0:!1}function Lb(e){return!!(e&&e!==`idle`&&e!==`stopped`)}function Rb(e){return e.hasPendingApprovals||e.hasPendingUserInput||e.hasActionableProposedPlan||Lb(e.session?.orchestrationStatus)||e.latestTurn?.state===`running`}function zb(e){return e.refCount===0&&!Ib(e)}function Bb(e){let t=jb().readConnection(e.environmentId);return e.unsubscribe===Nb&&!t?!1:(e.unsubscribeConnectionListener!==null&&(e.unsubscribeConnectionListener(),e.unsubscribeConnectionListener=null),e.unsubscribe!==Nb||!t||(e.unsubscribe=t.client.orchestration.subscribeThread({threadId:e.threadId},t=>{e.lastEventAt=Date.now(),e.recoveryAttempts=0,t.kind===`event`?jb().applyEvent(t.event,e.environmentId):t.kind===`snapshot`&&(S.getState().syncServerThreadDetail(t.snapshot.thread,e.environmentId),S.getState().clearThreadSubscriptionError(e.environmentId,e.threadId))},{onError:t=>Ob(e.environmentId,e.threadId,t)})),!0)}function Vb(e){e.unsubscribeConnectionListener===null&&(e.unsubscribeConnectionListener=jb().subscribeConnections(()=>{Bb(e)&&(e.lastAccessedAt=Date.now())}),Bb(e))}var Hb=null;function Ub(e){let t=C(e.environmentId,e.threadId),n=S.getState(),r=En(n,t);if(r?.latestTurn?.state===`running`||r?.session?.orchestrationStatus===`running`)return!0;let i=Cn(n,t);return i?.latestTurn?.state===`running`||i?.session?.orchestrationStatus===`running`}function Wb(e){e.unsubscribe!==Nb&&(e.unsubscribe(),e.unsubscribe=Nb),Bb(e)||Vb(e)}function Gb(e,t,n){if(e.recoveryAttempts+=1,e.lastEventAt=Date.now(),console.warn(`[forge] thread-detail liveness watchdog recovering`,{action:t,threadId:String(e.threadId),environmentId:String(e.environmentId),msSinceLastEvent:Math.round(n),recoveryAttempts:e.recoveryAttempts}),t===`resubscribe`){Wb(e);return}jb().readConnection(e.environmentId)?.reconnect().catch(t=>{Hn(t,{route:`thread-detail-liveness-watchdog-reconnect-failed`,threadId:String(e.threadId),environmentId:String(e.environmentId),msSinceLastEvent:String(Math.round(n)),recoveryAttempts:String(e.recoveryAttempts)})})}function Kb(){let e=Date.now();for(let t of F.values()){let n=vb({isWorking:Ub(t),msSinceLastEvent:e-t.lastEventAt,stallThresholdMs:yb,recoveryAttempts:t.recoveryAttempts,maxResubscribeAttempts:2,maxTotalAttempts:4});n!==`none`&&Gb(t,n,e-t.lastEventAt)}}function qb(){Hb===null&&(Hb=setInterval(Kb,bb))}function Jb(){F.size>0||Hb!==null&&(clearInterval(Hb),Hb=null)}function Yb(e){let t=F.get(e);return t?(Fb(t),t.unsubscribeConnectionListener?.(),t.unsubscribeConnectionListener=null,F.delete(e),t.unsubscribe(),t.unsubscribe=Nb,Jb(),!0):!1}function Xb(e){Zb(e,!0),j.getState().clear(e)}function Zb(e,t=!1){for(let[n,r]of F)if(r.environmentId===e){if(r.refCount===0||t){Yb(n);continue}r.unsubscribe(),r.unsubscribe=Nb,Vb(r)}}function Qb(e){for(let t=e.messages.length-1;t>=0;--t){let n=e.messages[t];if(n?.role===`user`)return n.createdAt}return null}function $b(e){return e.session?{threadId:e.id,updatedAt:e.session.updatedAt,providerName:e.session.provider,runtimeMode:e.runtimeMode,activeTurnId:e.session.activeTurnId??null,lastError:e.session.lastError??null,status:e.session.orchestrationStatus}:null}function ex(e,t){return{updatedAt:e.updatedAt??e.createdAt,latestUserMessageAt:t?.latestUserMessageAt??Qb(e),titleRegeneration:e.titleRegeneration??null}}function tx(e){return{hasPendingApprovals:e?.hasPendingApprovals??!1,hasPendingUserInput:e?.hasPendingUserInput??!1,hasActionableProposedPlan:e?.hasActionableProposedPlan??!1}}function nx(e){let t=C(e.environmentId,e.threadId),n=S.getState(),r=Cn(n,t);if(!r)return null;let i=En(n,t);return{id:r.id,projectId:r.projectId,title:r.title,modelSelection:r.modelSelection,runtimeMode:r.runtimeMode,interactionMode:r.interactionMode,branch:r.branch,worktreePath:r.worktreePath,latestTurn:r.latestTurn,createdAt:r.createdAt,...ex(r,i),...tx(i),archivedAt:r.archivedAt,session:$b(r),anchorKind:r.anchorKind,anchorCmmdId:r.anchorCmmdId,kind:r.kind,parentThreadId:r.parentThreadId,status:r.status,workerRole:r.workerRole,goal:r.goal}}function rx(e,t){if(F.size===0)return e;let n=new Set(e.threads.map(e=>e.id)),r=[];for(let e of F.values()){if(e.environmentId!==t||e.refCount<=0||n.has(e.threadId))continue;let i=nx(e);i&&(n.add(i.id),r.push(i))}return r.length===0?e:{...e,threads:[...e.threads,...r]}}function ix(e,t){let n=new Set(t);for(let[t,r]of F)r.environmentId===e&&!n.has(r.threadId)&&zb(r)&&Yb(t)}function ax(e){Fb(e),zb(e)&&(e.evictionTimeoutId=setTimeout(()=>{let t=F.get(Pb(e.environmentId,e.threadId));t&&(t.evictionTimeoutId=null,zb(t)&&Yb(Pb(e.environmentId,e.threadId)))},Mb))}function ox(){if(F.size<=32)return;let e=[...F.entries()].filter(([,e])=>zb(e)).toSorted(([,e],[,t])=>e.lastAccessedAt-t.lastAccessedAt);for(let[t]of e){if(F.size<=32)return;Yb(t)}}function sx(e){Fb(e),zb(e)&&ax(e)}function cx(e,t){let n=F.get(Pb(e,t));n&&sx(n)}function lx(e){for(let t of F.values())t.environmentId===e&&sx(t);ox()}function ux(e){let t=!1;return()=>{t||(t=!0,e.refCount=Math.max(0,e.refCount-1),e.lastAccessedAt=Date.now(),e.refCount===0&&(sx(e),ox()))}}function dx(e,t){let n=Pb(e,t),r=F.get(n);if(r)return Fb(r),r.refCount+=1,r.lastAccessedAt=Date.now(),Bb(r)||Vb(r),ux(r);let i={environmentId:e,threadId:t,unsubscribe:Nb,unsubscribeConnectionListener:null,refCount:1,lastAccessedAt:Date.now(),evictionTimeoutId:null,lastEventAt:Date.now(),recoveryAttempts:0};return F.set(n,i),Bb(i)||Vb(i),qb(),ox(),ux(i)}function fx(e,t){return e.type!==`thread.message-sent`||t.type!==`thread.message-sent`||e.payload.threadId!==t.payload.threadId||e.payload.messageId!==t.payload.messageId?null:{...t,payload:{...t.payload,attachments:t.payload.attachments??e.payload.attachments,createdAt:e.payload.createdAt,text:!t.payload.streaming&&t.payload.text.length>0?t.payload.text:e.payload.text+t.payload.text}}}function px(e){if(e.length<2)return[...e];let t=[];for(let n of e){let e=t.at(-1),r=e?fx(e,n):null;if(r){t[t.length-1]=r;continue}t.push(n)}return t}function mx(){let e=Tn(S.getState());gb.getState().syncProjects(e.map(e=>({key:In(Ln(e.environmentId,e.id)),cwd:e.cwd})))}function hx(){let e=hn(S.getState());gb.getState().syncThreads(e.map(e=>({key:Rn(C(e.environmentId,e.id)),seedVisitedAt:e.updatedAt??e.createdAt}))),by(e.map(e=>C(e.environmentId,e.id)))}function gx(){mx(),hx();let e=Ty({snapshotThreads:hn(S.getState()).map(e=>({key:Rn(C(e.environmentId,e.id)),deletedAt:null,archivedAt:e.archivedAt})),draftThreadKeys:gy.getState().listDraftThreadKeys()});lm.getState().removeOrphanedTerminalStates(e)}function _x(e){return e.serverThreadArchivedAt===void 0?e.hasDraftThread:e.serverThreadArchivedAt===null}function vx(e,t){if(e.length===0)return;let n=Ey(e),r=px(e),i=e.some(e=>e.type===`project.created`||e.type===`project.meta-updated`||e.type===`project.deleted`);if(n.needsProviderInvalidation&&wy().notifyProviderInvalidation(),S.getState().applyOrchestrationEvents(r,t),i){let e=Tn(S.getState());gb.getState().syncProjects(e.map(e=>({key:In(Ln(e.environmentId,e.id)),cwd:e.cwd})))}if(e.some(e=>e.type===`thread.created`||e.type===`thread.deleted`)){let e=hn(S.getState());gb.getState().syncThreads(e.map(e=>({key:Rn(C(e.environmentId,e.id)),seedVisitedAt:e.updatedAt??e.createdAt})))}let a=gy.getState();for(let e of n.promoteDraftThreadIds)yy(C(t,e));for(let e of n.clearDeletedThreadIds)a.clearDraftThread(C(t,e)),gb.getState().clearThreadUi(Rn(C(t,e)));for(let e of n.removeTerminalStateThreadIds){let n=C(t,e);lm.getState().removeTerminalState(n),Pf.getState().clearBrowserState(n)}lx(t)}function yx(e,t){vx([e],t)}function bx(e,t){let n=e.kind===`thread-upserted`?e.thread.id:e.kind===`thread-removed`?e.threadId:null,r=n?C(t,n):null,i=r?Cn(S.getState(),r):void 0;switch(S.getState().applyShellEvent(e,t),e.kind){case`project-upserted`:case`project-removed`:mx();return;case`thread-upserted`:hx(),!i&&r&&yy(r),i?.archivedAt===null&&e.thread.archivedAt!==null&&r&&(lm.getState().removeTerminalState(r),Pf.getState().clearBrowserState(r)),cx(t,e.thread.id),ox();return;case`thread-removed`:r&&(Yb(Rn(r)),gy.getState().clearDraftThread(r),gb.getState().clearThreadUi(Rn(r)),lm.getState().removeTerminalState(r),Pf.getState().clearBrowserState(r)),hx();return}}function xx(e,t){return e.invalidateQueries({queryKey:Rf.all(t)})}function Sx(e){return{onWelcome:(t,n)=>{e?.(t);let r=wy().readQueryClient();r&&xx(r,n)},applyShellEvent:bx,syncShellSnapshot:(e,t)=>{let n=rx(e,t);S.getState().syncServerShellSnapshot(n,t),ix(t,n.threads.map(e=>e.id)),lx(t),gx()},applyTerminalEvent:(e,t)=>{let n=C(t,Br.make(e.threadId)),r=Cn(S.getState(),n),i=gy.getState().getDraftThreadByRef(n)!==null;_x({serverThreadArchivedAt:r?.archivedAt,hasDraftThread:i})&&lm.getState().applyTerminalEvent(n,e)},applyBrowserEvent:(e,t)=>{let n=C(t,Br.make(e.threadId)),r=Cn(S.getState(),n),i=gy.getState().getDraftThreadByRef(n)!==null;_x({serverThreadArchivedAt:r?.archivedAt,hasDraftThread:i})&&Pf.getState().applyBrowserEvent(n,e)},onShellSubscriptionError:(e,t)=>{wy().setRuntimeError(t,e)}}}function Cx(){return new Date().toISOString()}function wx(e){j.getState().patch(e,{connectionState:`connecting`,lastError:null,lastErrorAt:null})}function Tx(e){let t=Cx();j.getState().patch(e,{connectionState:`connected`,authState:`authenticated`,connectedAt:t,disconnectedAt:null,lastError:null,lastErrorAt:null}),ar.getState().markConnected(e,t)}function Ex(e,t){j.getState().patch(e,{descriptor:t.environment,serverConfig:t})}function Dx(e,t){j.getState().patch(e,{connectionState:`disconnected`,disconnectedAt:Cx(),...t&&t.trim().length>0?{lastError:t,lastErrorAt:Cx()}:{}})}function Ox(e,t){j.getState().patch(e,{connectionState:`error`,...yl(t)})}function kx(){return new Date().toISOString()}function Ax(e){let t=gr();if(!t?.environmentId)throw Error(`Unable to resolve the primary environment.`);let n=e.readConnection(t.environmentId);if(n)return n;let r=of(),i=t.source===`paired-bearer`||!0;return e.registerConnection(Jl({kind:`primary`,knownEnvironment:t,client:cf(t),resolveEnvironmentId:()=>gr()?.environmentId??t.environmentId,...i?{readiness:r?{bearerToken:r.bearerToken}:{}}:{},...Sx()}))}async function jx(e){let t=sf();if(!t)throw Error(`Desktop Local runtime is not authenticated. Sign in with CMMD again before importing local projects.`);let n=await Ll({httpBaseUrl:t.httpBaseUrl,bearerToken:t.bearerToken}),r=e.readConnection(n.environmentId);if(r)return r;let i=Sn({id:n.environmentId,label:t.label,source:`desktop-managed`,target:{httpBaseUrl:t.httpBaseUrl,wsBaseUrl:t.wsBaseUrl}});return e.registerConnection(Jl({kind:`desktop-local`,knownEnvironment:{...i,environmentId:n.environmentId,label:n.label},client:lf({environmentId:n.environmentId,httpBaseUrl:t.httpBaseUrl,wsBaseUrl:t.wsBaseUrl,bearerToken:t.bearerToken,onConnecting:wx,onConnected:Tx,onError:(e,t)=>{j.getState().patch(e,{connectionState:`error`,lastError:t,lastErrorAt:kx()})},onDisconnected:Dx}),...Sx()}))}var Mx=new Map;function Nx(e){for(let t of e){let e=Mx.get(t);e===void 0||e<=1?Mx.delete(t):Mx.set(t,e-1)}}async function Px(e,t){let n=e.environmentId;Mx.set(n,(Mx.get(n)??0)+1);try{return t.readConnection(n)||await t.ensureCmmdRuntimeSavedEnvironmentConnection(e),!0}catch{return Nx([n]),!1}}async function Fx(e){await $n();let t=(await Promise.all(or().map(async t=>await Px(t,e)?t.environmentId:null))).flatMap(e=>e===null?[]:[e]),n=!1;return()=>{n||(n=!0,Nx(t))}}function Ix(){return new Date().toISOString()}async function Lx(e,t){t.readConnection(e)?.kind===`saved`&&(j.getState().clear(e),await t.removeConnection(e).catch(()=>!1))}async function Rx(e,t){let n=tr(e);if(!n)throw Error(`Saved environment not found.`);let r=t.readConnection(e);if(!r){try{await t.ensureCmmdRuntimeSavedEnvironmentConnection(n)}catch(t){throw Ox(e,t),t}return}wx(e);try{await r.reconnect()}catch(t){throw Ox(e,t),t}}async function zx(e,t){t.invalidate(e),ar.getState().remove(e),await hr(e),await Lx(e,t)}async function Bx(e,t){let{existing:n,replacedRecord:r}=hl({environmentId:Ur.make(e.environment.environmentId),replacesEnvironmentId:e.environment.replacesEnvironmentId}),i=Vx(e.environment,n);ol(e.signal);let a=await gl(n),o=t.readConnection(i.environmentId)!==null&&ml({existing:n,replacedRecord:r,record:i});return o||(t.invalidate(i.environmentId),await t.removeConnection(i.environmentId).catch(()=>!1)),r&&(t.invalidate(r.environmentId),await t.removeConnection(r.environmentId).catch(()=>!1)),await t.ensureCmmdRuntimeSavedEnvironmentConnection(i,{bearerToken:e.bearerToken,registryExpectation:n&&!r?{kind:`existing-record`,record:n}:{kind:`initial-add`},...e.signal?{signal:e.signal}:{},...e.onBootstrapRetry?{onBootstrapRetry:e.onBootstrapRetry}:{}}),Hx({record:i,replacedRecord:r,persistenceRollback:a,keepsLiveConnection:o,signal:e.signal,dependencies:t})}function Vx(e,t){let n=Ur.make(e.environmentId),{kind:r,cmmdOrganizationId:i,cmmdProjectId:a,runtimeId:o,runtimeTicketExpiresAt:s}=e;return{environmentId:n,label:e.label,wsBaseUrl:Yr(e.wsBaseUrl),httpBaseUrl:e.httpBaseUrl,createdAt:t?.createdAt??Ix(),lastConnectedAt:Ix(),...r===void 0?{}:{kind:r},...i===void 0?{}:{cmmdOrganizationId:i},...a===void 0?{}:{cmmdProjectId:a},...o===void 0?{}:{runtimeId:o},...s===void 0?{}:{runtimeTicketExpiresAt:s}}}async function Hx(e){let{record:t,replacedRecord:n,persistenceRollback:r,keepsLiveConnection:i,signal:a,dependencies:o}=e,s=!1;try{return ol(a),await vl({record:t,replacedRecord:n,rollback:r,...a?{signal:a}:{}}),s=!0,ol(a),ar.getState().upsert(dl(t)),n&&o.retireEnvironmentId(n.environmentId),t}catch(e){throw i||await o.removeConnection(t.environmentId).catch(()=>!1),s&&await _l({record:t,replacedRecord:n,rollback:r}),ol(a),e}}var Ux=`forge.deviceRegistry.deviceKey`,Wx=`forge.deviceRegistry.runtimeId`;function Gx(e){let t=Jx(Ux,e.desktopIdentity?.deviceKey,`device`),n=Jx(Wx,e.desktopIdentity?.runtimeId,`runtime`),r=qx(e.desktopIdentity?.hostKey),i=$x(),a=e.desktopAvailable?`desktop`:eS(),o=e.desktopAvailable?Qx(e.desktopIdentity)??tS(i):nS(i);return{device:{...r?{hostKey:r}:{},deviceKey:t,displayName:o,platform:i,deviceType:a,metadata:{clientKind:e.desktopAvailable?`forge-desktop`:`forge-web`,userAgent:window.navigator.userAgent,origin:window.location.origin,...e.desktopIdentity?{desktopIdentity:{hostName:e.desktopIdentity.hostName,computerName:e.desktopIdentity.computerName,platform:e.desktopIdentity.platform}}:{}}},...e.desktopAvailable&&e.includeExecutableRuntime!==!1?{runtime:{runtimeId:n,runtimeKind:`desktop-local`,displayName:`Local Forge Desktop`,endpointUrl:e.desktopEndpointUrl??null,status:`online`,metadata:{origin:window.location.origin}}}:{}}}async function Kx(){let e=await window.desktopBridge?.getDeviceIdentity?.()??null;return Gx({desktopAvailable:!!window.desktopBridge,desktopIdentity:e,includeExecutableRuntime:!1})}function qx(e){let t=e?.trim()??``;return t.length>0?t:null}function Jx(e,t,n){let r=qx(t);return r?(Dn(e,r),r):Zx(e,n)}function Yx(){return Nn(Wx)}function Xx(){return Nn(Ux)}function Zx(e,t){let n=Nn(e);if(n)return n;let r=`${t}_${crypto.randomUUID()}`;return Dn(e,r),r}function Qx(e){let t=e?.displayName?.trim()??``;return t.length>0?t:null}function $x(){let e=window.navigator.userAgent.toLowerCase();return e.includes(`iphone`)||e.includes(`ipad`)?`ios`:e.includes(`android`)?`android`:e.includes(`mac`)?`macos`:e.includes(`win`)?`windows`:e.includes(`linux`)?`linux`:`unknown`}function eS(){let e=window.navigator.userAgent.toLowerCase();return e.includes(`ipad`)||e.includes(`tablet`)?`tablet`:e.includes(`mobi`)||e.includes(`iphone`)||e.includes(`android`)?`mobile`:`browser`}function tS(e){return e===`macos`?`Mac`:e===`windows`?`Windows PC`:e===`linux`?`Linux Desktop`:`Desktop`}function nS(e){return e===`web`?`Browser`:e===`macos`?`Mac Browser`:e===`windows`?`Windows Browser`:e===`linux`?`Linux Browser`:`Browser`}var rS=`forge.relayControlJournal.v1`;function iS(){if(globalThis.localStorage===void 0)throw Error(`Forge relay control recovery requires durable browser storage.`);return globalThis.localStorage}var aS={read:()=>iS().getItem(rS),write:e=>iS().setItem(rS,e)},oS=null,sS=Oa()(e=>({byRuntimeId:{},replace:t=>e({byRuntimeId:t})}));function cS(e){e.subscribe(e=>{let t=new Set(e.records.map(e=>e.runtimeId));sS.getState().replace(Object.fromEntries([...t].map(t=>[t,ua(e.records,t)])))})}function lS(){return oS===null&&(oS=da({storage:aS}),cS(oS)),oS}function uS(){let e=(0,A.c)(1),t=sS(fS),n;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0],(0,O.useEffect)(dS,n),t}function dS(){lS()}function fS(e){return e.byRuntimeId}function pS(e){let t=lS();for(let n of t.records())n.runtimeId===e&&(n.status===`failed`||n.status===`outcome-unknown`)&&t.acknowledge(n.runtimeId,n.actorSessionId,n.transportRequestId)}var mS=class extends Error{code;constructor(e,t){super(t),this.name=`RelayControlRouteError`,this.code=e}};function hS(e){let t=e&&typeof e==`object`?e.code:null;throw t===`PROTOCOL_INCOMPATIBLE`?new mS(`FORGE_RUNTIME_UPDATE_REQUIRED`,`Update Forge on the target runtime before connecting remotely.`):t===`PROTOCOL_ROLLOUT_DENIED`?new mS(`FORGE_REMOTE_CONTROL_NOT_ENABLED`,`Remote control is not enabled for this CMMD account. Synced runtime inventory remains available.`):e}async function gS(e){let t=e.getStoredDeviceKey(),n=t?await e.apiClient.getDeviceRegistry():await e.apiClient.registerDevice(await e.buildDeviceRegistration());return t&&!n.devices.some(e=>e.deviceKey===t)&&(n=await e.apiClient.registerDevice(await e.buildDeviceRegistration())),t??=e.getStoredDeviceKey(),{deviceKey:t,registry:n}}function _S(e){if(!e.deviceKey)throw new mS(`FORGE_CONTROL_DEVICE_UNAUTHORIZED`,`This Forge control surface could not establish CMMD identity.`);let t=e.registry.devices.find(t=>t.deviceKey===e.deviceKey);if(t?.trustState===`revoked`||t?.authorization?.revoked===!0)throw new mS(`FORGE_CONTROL_DEVICE_REVOKED`,`This Forge control surface was revoked by CMMD.`);if(!t||t.trustState!==`trusted`)throw new mS(`FORGE_CONTROL_DEVICE_UNAUTHORIZED`,`This Forge control surface is not trusted by CMMD.`);return t}function vS(e,t){let n=async()=>_S(await gS(t));return{acquireRoute:async()=>{let r=await n(),i=await la();try{let n=await t.apiClient.issueRelayControlRoute(e,{controlDeviceId:r.id,controlSessionId:t.controlSessionId,scopes:[...wi],protocolMinVersion:4,protocolMaxVersion:4,...Xi(i)});return ea({route:n,runtimeId:e,endpoint:i})}catch(e){if(e instanceof ca)throw new mS(`FORGE_RUNTIME_UPDATE_REQUIRED`,e.message);return hS(e)}},acquireActionGrant:async r=>{let i=await n();try{return(await t.apiClient.issueRelayActionGrant(e,{controlDeviceId:i.id,controlSessionId:t.controlSessionId,...r})).token}catch(e){return hS(e)}}}}var yS=new Map;async function bS(e,t){let n=Ur.make(e.runtimeId),r=t.readConnection(n);if(r)return r;wx(n);let i=lS(),a=vS(e.runtimeId,{apiClient:lr,getStoredDeviceKey:Xx,buildDeviceRegistration:Kx,controlSessionId:i.controlSessionId}),o;try{o=await a.acquireRoute()}catch(e){throw Ox(n,e),e}let s=o,c=_a({acquireRoute:async()=>{let e=s;return s=null,e??a.acquireRoute()},acquireActionGrant:a.acquireActionGrant,journal:i,lifecycle:{onConnecting:()=>wx(n),onAuthenticated:()=>Tx(n),onDisconnected:e=>Dx(n,e.reason),onError:e=>Ox(n,Object.assign(Error(e.message),e))}}),l=af(new ud(o.relayWebSocketUrl,{trackGlobalConnection:!1},{layer:c,makeClient:$i(wi)})),u=Jl({kind:`saved`,knownEnvironment:{...Sn({id:n,label:e.label,source:`manual`,target:{httpBaseUrl:ia()?.target.httpBaseUrl??o.relayWebSocketUrl,wsBaseUrl:o.relayWebSocketUrl}}),environmentId:n},client:l,tolerateReportedEnvironmentIdentity:!0,onConfigSnapshot:e=>Ex(n,e),...Sx(e=>{j.getState().patch(n,{descriptor:e.environment})})});try{let[,e]=await Promise.all([u.ensureBootstrapped(),l.server.getConfig()]);return Ex(n,e),Tx(n),t.registerConnection(u)}catch(e){throw Ox(n,e),await u.dispose().catch(()=>void 0),e}}function xS(e,t){let n=Ur.make(e.runtimeId),r=t.readConnection(n);if(r)return Promise.resolve(r);let i=yS.get(n);if(i)return i;let a=bS(e,t).finally(()=>{yS.delete(n)});return yS.set(n,a),a}var SS=new Set([`CMMD_AUTH_REQUIRED`,`CMMD_AUTH_EXPIRED`,`INVALID_OR_NON_USER_TOKEN`,`NON_USER_BEARER`,`CMMD_REST_AUTH_ERROR`]);function CS(e){if(!e||typeof e!=`object`)return null;let t=e.code;return typeof t!=`string`||!SS.has(t)?null:t}function wS(e,t){return e===401||e===403||CS(t)!==null}function TS(e){if(!e||typeof e!=`object`)return!1;let t=e.status,n=e.code;return wS(typeof t==`number`?t:void 0,typeof n==`string`?{code:n}:void 0)}var ES=[1e3,2e3,4e3,8e3,12e3,16e3,2e4],DS=9e4,OS=[`all fibers interrupted without error`,`timed out while waiting for forge cloud runtime metadata`,`timed out while waiting for`,`to stream its shell snapshot`,`forge runtime route not found`,`fly-replay`,`could not find a good candidate`,`instance refused connection`],kS=[`Unknown socket error`,`Failed to fetch remote auth endpoint`,`Forge runtime replay target is unavailable`,`Remote auth request failed (502)`,`Remote auth request failed (503)`,`Remote auth request failed (504)`,`Unable to connect to the Forge server WebSocket`];function AS(e){if(typeof e!=`object`||!e)return null;let t=e.status;return typeof t==`number`&&Number.isInteger(t)?t:null}function jS(e){if(TS(e))return!1;let t=AS(e);if(t===502||t===503||t===504||e._tag===`OrchestrationGetSnapshotError`)return!0;let n=e instanceof Error?e.message:String(e),r=n.toLowerCase();return OS.some(e=>r.includes(e))||kS.some(e=>n.includes(e))}function MS(e){return ES[e]??ES[ES.length-1]}function NS(){return DS}function PS(e,t){if(!fl(e))return t;let n=null,r=new Promise((t,r)=>{n=globalThis.setTimeout(()=>{r(Error(`Timed out while waiting for Forge Cloud runtime metadata for ${e.environmentId}. The VM may still be starting.`))},NS())});return Promise.race([t,r]).finally(()=>{n!==null&&globalThis.clearTimeout(n)})}function FS(e){let t=e.toLowerCase();return t.includes(`authentication`)||t.includes(`unauthorized`)||t.includes(`forbidden`)||t.includes(`credential`)||t.includes(`runtime ticket`)||t.includes(`status 401`)||t.includes(`status 403`)}var IS=`forge:cloud-runtime-handoffs:v2`,LS=3e5,RS=new Map,zS={clear:()=>RS.clear(),getItem:e=>RS.get(e)??null,key:e=>Array.from(RS.keys())[e]??null,get length(){return RS.size},removeItem:e=>RS.delete(e),setItem:(e,t)=>RS.set(e,t)};function BS(){return typeof window<`u`?window.localStorage:globalThis.localStorage??zS}var VS=Oa()(Wf(e=>({byRuntimeId:{},record:t=>e(e=>({byRuntimeId:{...e.byRuntimeId,[t.runtimeId]:t}})),clearRuntime:t=>e(e=>t in e.byRuntimeId?{byRuntimeId:Object.fromEntries(Object.entries(e.byRuntimeId).filter(([e])=>e!==t))}:e),reconcileCatalog:(t,n=Date.now())=>e(e=>{let r=Object.entries(e.byRuntimeId).filter(([,e])=>{if(n-e.recordedAt>LS)return!1;let r=t.find(t=>t.cmmdOrganizationId===e.cmmdOrganizationId&&t.cmmdProjectId===e.cmmdProjectId);return r?.runtimeId===e.previousCatalogRuntimeId&&r.registeredAt===e.catalogRegisteredAt});return r.length===Object.keys(e.byRuntimeId).length?e:{byRuntimeId:Object.fromEntries(r)}}),reset:()=>e({byRuntimeId:{}})}),{name:IS,storage:Hf(BS),partialize:e=>({byRuntimeId:e.byRuntimeId}),version:2}));function HS(e){VS.getState().record({...e,recordedAt:Date.now()})}function US(e){VS.getState().clearRuntime(e)}var WS=new Set([`filesystem`,`terminal`,`git`,`project-write`]);function GS(e){return e===`desktop-local`}function KS(e){return e===`cloud`||e===`cloud-vm`||e===`cmmd`||e===`github`}function qS(e){return e.actionKind===`cloud-api`?{available:!0,route:`cloud`,requiresPermissionGate:!1,title:`Cloud API route`,description:`Cloud and Command work routes through authenticated Forge Cloud APIs.`}:WS.has(e.actionKind)?KS(e.workSource)?e.workSource===`cloud-vm`&&e.executionRuntime===`cloud`?{available:!0,route:`cloud-vm`,requiresPermissionGate:!1,title:`Cloud VM route`,description:`Filesystem, terminal, git, and project writes run inside the user's Forge Cloud VM.`}:e.executionRuntime===`cloud`?{available:!0,route:`cloud`,requiresPermissionGate:!1,title:`Cloud work route`,description:`Cloud-scoped filesystem, terminal, git, and project writes run in the Forge Cloud runtime.`}:{available:!1,route:`blocked`,requiresPermissionGate:!1,title:`Open in Forge Cloud`,description:`Cloud projects must execute inside the Forge Cloud runtime. Local Desktop cannot run cloud project filesystem, terminal, git, or project-write actions.`}:GS(e.workSource)?e.surface===`desktop-local`||e.executionRuntime===`desktop-local`?{available:!0,route:`desktop-local`,requiresPermissionGate:!1,title:`Desktop local route`,description:`Local filesystem, terminal, git, and project writes run through the Desktop local backend.`}:e.executionRuntime===`dev-local-web`?{available:!0,route:`dev-local-web`,requiresPermissionGate:!1,title:`Dev local route`,description:`Local Web is a development-only projection and routes local actions through the dev server.`}:{available:!1,route:`blocked`,requiresPermissionGate:!1,title:`Switch to Desktop Local`,description:`Local projects must execute in the Desktop Local runtime. Forge Cloud cannot run local filesystem, terminal, git, or project-write actions.`}:{available:!1,route:`blocked`,requiresPermissionGate:!1,title:`Unknown work source`,description:`Forge cannot safely route local actions for this work source yet.`}:{available:!1,route:`blocked`,requiresPermissionGate:!1,title:`Unsupported route`,description:`Forge does not have a runtime route for this action yet.`}}var JS=`Ready to use. Your cloud project starts when you open the first thread.`;function YS(e){let t=qS({actionKind:`project-write`,surface:`cloud-official`,workSource:`cloud-vm`,executionRuntime:`cloud`});return{actionAuthority:`runtime`,surface:`cloud-official`,hostKind:`user-cloud-vm`,workSource:`cloud-vm`,executionRuntime:`cloud`,modelRuntime:`cloud`,linkState:`cloud-only`,workspaceIdentity:null,hideLocalPath:!0,label:`Cloud project`,description:e?`This project runs in your Forge Cloud VM.`:JS,actionRouteLabel:t.title,actionRouteDescription:t.description,actionRouteAvailable:t.available,requiresPermissionGate:t.requiresPermissionGate}}var XS=3e5;function ZS(e,t,n=Date.now()){let r=new Map,i=new Map;for(let t of e){let e={cmmdOrganizationId:t.cmmdOrganizationId,cmmdProjectId:t.cmmdProjectId};r.set(eC(e),e),t.runtimeId!==null&&i.set(t.runtimeId,e)}for(let a of t){if(n-a.recordedAt>XS)continue;let t=r.get(eC({cmmdOrganizationId:a.cmmdOrganizationId,cmmdProjectId:a.cmmdProjectId})),o=e.find(e=>e.cmmdOrganizationId===a.cmmdOrganizationId&&e.cmmdProjectId===a.cmmdProjectId);t&&o?.runtimeId===a.previousCatalogRuntimeId&&o.registeredAt===a.catalogRegisteredAt&&!i.has(a.runtimeId)&&i.set(a.runtimeId,t)}return i}function QS(e){return e.environmentId??`cmmd-cloud-project:${e.cmmdOrganizationId}:${e.cmmdProjectId}`}function $S(e){return{environmentId:QS(e),workspaceRoot:e.workspaceRoot,resolvedRef:e.resolvedRef}}function eC(e){return`cloud:${e.cmmdOrganizationId}:${e.cmmdProjectId}`}function tC(e){let t=/^cloud:(\d+):(\d+)$/.exec(e??``);return t?{cmmdOrganizationId:Number(t[1]),cmmdProjectId:Number(t[2])}:null}function nC(e){return`cloud-runtime:${e}`}var rC=`cloud-unconnected:`;function iC(e,t,n=[]){let r=eC(e);return aC({id:Si.make(`${rC}${r}`),environmentId:Ur.make(QS(e)),name:e.projectName,cwd:``,repositoryIdentity:null,availability:void 0,defaultModelSelection:null,createdAt:void 0,updatedAt:void 0,scripts:[],projectKey:r,environmentPresence:`remote-only`,source:YS(e.runtimeId!==null),memberProjectRefs:t?[t]:[],remoteEnvironmentLabels:[],worktreeMembers:[],activeWorktreeKey:null,preConnectCloud:{runtimeId:e.runtimeId,cmmdOrganizationId:e.cmmdOrganizationId,cmmdProjectId:e.cmmdProjectId,cmmdEnvironmentId:e.cmmdEnvironmentId,registeredAt:e.registeredAt,projectName:e.projectName,githubRepoFullName:e.githubRepoFullName,workspaceRoot:e.workspaceRoot,iconUrl:e.iconUrl,icon:e.icon,status:e.status,removal:e.removal},cloudRemoval:e.removal},n)}function aC(e,t){if(t.length===0)return e;let n=[...e.memberProjectRefs],r=new Set(n.map(e=>`${e.environmentId}:${e.projectId}`));for(let e of t){let t=`${e.environmentId}:${e.projectId}`;r.has(t)||(r.add(t),n.push(e))}return n.length===e.memberProjectRefs.length?e:{...e,memberProjectRefs:n}}function oC(e,t,n,r){if(!e)return null;let i=t.find(t=>t.cmmdEnvironmentId===String(e));if(i)return{row:i,runtimeId:i.runtimeId,matchedByHandoff:!1};let a=yr(e).legacyRuntimeId;if(a){let e=t.find(e=>e.runtimeId===a);if(e)return{row:e,runtimeId:a,matchedByHandoff:!1};let i=ZS(t,n,r).get(a);if(!i)return null;let o=t.find(e=>e.cmmdOrganizationId===i.cmmdOrganizationId&&e.cmmdProjectId===i.cmmdProjectId);return o?{row:o,runtimeId:a,matchedByHandoff:!0}:null}let o=t.find(t=>t.runtimeId===null&&QS(t)===String(e));return o?{row:o,runtimeId:null,matchedByHandoff:!1}:null}function sC(e,t=e.runtimeId){return{runtimeId:t,cmmdOrganizationId:e.cmmdOrganizationId,cmmdProjectId:e.cmmdProjectId,cmmdEnvironmentId:e.cmmdEnvironmentId,registeredAt:e.registeredAt,projectName:e.projectName,githubRepoFullName:e.githubRepoFullName,workspaceRoot:e.workspaceRoot,iconUrl:e.iconUrl,icon:e.icon,status:e.status,desiredState:e.desiredState}}function cC(e){return e.desiredState===`stopped`}var lC=15e3;function uC(e){return e===401||e===403}function dC(e){return typeof e!=`object`||!e?!1:e.retryable===!0}function fC(e){return uC(e.status)||e.attempt>=e.maxAttempts||e.status>=200&&e.status<300?!1:e.status>=500||e.status===409&&dC(e.body)}function pC(e,t){let n=e?.trim();if(!n)return null;if(/^-?\d+$/.test(n))return Number(n)*1e3;let r=Date.parse(n);return Number.isNaN(r)?null:r-t}function mC(e){let t=e=>Math.min(lC,Math.max(0,e)),n=pC(e.retryAfter,e.nowMs??Date.now());return t(n===null?300*2**Math.max(0,e.attempt-1):n)}var hC=6e4;function gC(e,t){if(!e||typeof e!=`object`)return t;let n=e.error;return typeof n==`string`&&n.trim().length>0?n:t}var _C=`CMMD returned an invalid Cloud runtime connection descriptor.`;function vC(e,t){let n=e[t];if(typeof n!=`string`||n.length===0)throw Error(_C);return n}function yC(e){if(!e||typeof e!=`object`)throw Error(_C);let t=e;return{httpBaseUrl:vC(t,`httpBaseUrl`),wsBaseUrl:vC(t,`wsBaseUrl`),bearerToken:vC(t,`bearerToken`),expiresAt:vC(t,`expiresAt`)}}async function bC(e){let t=Yi(`/api/cmmd/forge-runtimes/${encodeURIComponent(e.runtimeId)}/connect`),n=na({method:`POST`,...e.signal?{signal:e.signal}:{},headers:{"Content-Type":`application/json`},body:JSON.stringify(e.organizationId===void 0?{}:{organizationId:e.organizationId})});for(let r=1;r<=8;r+=1){let i=await fetch(t,n),a=await i.json().catch(()=>null);if(i.ok)return yC(a);if(!fC({status:i.status,body:a,attempt:r,maxAttempts:8})){let e=wS(i.status,a)?`CMMD authentication expired while renewing the Cloud runtime connection. Sign in again.`:`CMMD could not renew the Cloud runtime connection (${i.status}).`;throw Object.assign(Error(gC(a,e)),{status:i.status,...CS(a)?{code:CS(a)}:{}})}await cl(mC({attempt:r,retryAfter:i.headers.get(`retry-after`)}),e.signal)}throw Error(`Cloud runtime connection retry budget was exhausted.`)}function xC(e,t){if(!e?.expiresAt)return!0;let n=Date.parse(e.expiresAt);return!Number.isFinite(n)||n<=t+hC}function SC(e){let t=e.requestDescriptor??bC,n=e.now??Date.now,r=e.initialDescriptor??null,i=null,a=!1,o=new AbortController,s=e=>sl(e,o.signal),c=()=>i||(i=s(t({runtimeId:e.runtimeId,...e.organizationId===void 0?{}:{organizationId:e.organizationId},signal:o.signal})).then(async t=>(await s(Promise.resolve(e.validateDescriptor?.(t))),await s(Promise.resolve(e.persistDescriptor?.(t))),await s(Promise.resolve()),r=t,a=!1,t)).then(e=>(i=null,e),e=>{throw i=null,e}),i);return{acquire:e=>{if(o.signal.aborted)return s(Promise.resolve(r));let t=e?.forceRefresh||a||xC(r,n())?c():Promise.resolve(r);return sl(s(t),e?.signal)},invalidate:()=>{a=!0},dispose:()=>{o.abort()}}}function CC(e){let t=e.runtimeId?.trim();if(t)return t;let n=yr(e.environmentId).legacyRuntimeId;if(n)return n;let r=dr().rows,i=Object.values(VS.getState().byRuntimeId);return oC(e.environmentId,r,i)?.runtimeId??null}function wC(e,t,n,r){let i=e,a=SC({runtimeId:t,...e.cmmdOrganizationId===void 0?{}:{organizationId:e.cmmdOrganizationId},...n===void 0?{}:{initialDescriptor:{httpBaseUrl:e.httpBaseUrl,wsBaseUrl:e.wsBaseUrl,bearerToken:n,expiresAt:e.runtimeTicketExpiresAt??null}},validateDescriptor:async e=>{await Il({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken})},persistDescriptor:async e=>{if(r&&!r())throw Error(`Saved environment changed while its connection was being acquired.`);let t={...dl(i),httpBaseUrl:e.httpBaseUrl,wsBaseUrl:Yr(e.wsBaseUrl),...e.expiresAt===null?{}:{runtimeTicketExpiresAt:e.expiresAt},lastConnectedAt:new Date().toISOString()};await Kn(t),await hr(t.environmentId),ar.getState().upsert(t),i=t}});return Sl(e.environmentId,a),a}function TC(e){let t={wsBaseUrl:e.record.wsBaseUrl,httpBaseUrl:e.record.httpBaseUrl,bearerToken:e.bearerToken,expiresAt:e.record.runtimeTicketExpiresAt??null};return{acquire:()=>Promise.resolve(t)}}var EC=12e4,DC=3e4,OC=3e4;function kC(e){let t=e.expiresAt?Date.parse(e.expiresAt):NaN;if(!Number.isFinite(t))throw Error(`Cloud runtime authority descriptor has no valid expiry.`);return t}function AC(e){if(!e||typeof e!=`object`)return!1;let t=e.status;return t===401||t===403}function jC(e){let t=e.now??Date.now,n=e.renewalSkewMs??EC,r=!1,i=null,a=null,o=kC(e.initialDescriptor),s=()=>{i!==null&&(globalThis.clearTimeout(i),i=null)},c=a=>{if(r)return;s();let c=kC(a);o=c;let l=Math.max(t(),c-n);e.onState?.({kind:`scheduled`,expiresAt:new Date(c).toISOString(),renewAt:new Date(l).toISOString()}),i=globalThis.setTimeout(()=>{i=null,u().catch(()=>void 0)},Math.max(0,l-t()))},l=()=>{if(r)return null;let e=t()+OC;return e>=o?null:(i=globalThis.setTimeout(()=>{i=null,u().catch(()=>void 0)},OC),new Date(e).toISOString())},u=()=>{if(r)return Promise.resolve();if(a)return a;s(),e.onState?.({kind:`renewing`,expiresAt:new Date(o).toISOString()});let n=e.renew().then(async n=>{let i=kC(n);if(i<=t())throw Error(`Cloud runtime authority descriptor is already expired.`);r||(e.onState?.({kind:`ready`,expiresAt:new Date(i).toISOString(),renewedAt:new Date(t()).toISOString()}),c(n))}).catch(t=>{if(r)return;let n=AC(t);throw e.onState?.({kind:`error`,code:n?`authority_auth_rejected`:`authority_renewal_failed`,retryAt:n?null:l()}),t}).finally(()=>{a=null});return a=n,n};return c(e.initialDescriptor),{ensureLive:()=>o>t()+DC?Promise.resolve():u(),renewNow:u,dispose:()=>{r=!0,s()}}}function MC(){return new Date().toISOString()}function NC(e,t,n,r,i){return n()&&j.getState().ensure(e.environmentId),af(new ud(async()=>{let e=e=>zl({wsBaseUrl:e.wsBaseUrl,httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken,...r?{runtimeTicket:e.bearerToken}:{}}),n=await t.acquire();try{return await e(n)}catch(n){if(!r||!zn(n))throw n;return e(await t.acquire({forceRefresh:!0}))}},{trackGlobalConnection:!1,onAttempt:()=>{n()&&i.setConnecting(e.environmentId)},onOpen:()=>{n()&&i.setConnected(e.environmentId)},onError:i=>{r&&FS(i)&&t.invalidate?.(),n()&&j.getState().patch(e.environmentId,{connectionState:`error`,lastError:i,lastErrorAt:MC()})},onClose:a=>{r&&(a.code===1008||FS(a.reason))&&t.invalidate?.(),n()&&i.setDisconnected(e.environmentId,a.reason)}}))}async function PC(e,t,n,r,i,a,o){let s=await xl(t,o),[c,l]=await Promise.all([a?Promise.resolve(a):n.server.getConfig(),Il({httpBaseUrl:s.httpBaseUrl,bearerToken:s.bearerToken,...o?{signal:o}:{}})]);return r()?(j.getState().patch(e.environmentId,{authState:l.authenticated?`authenticated`:`requires-auth`,descriptor:c.environment,serverConfig:c,role:l.authenticated?l.role??i??null:null}),FC(e,c,l.authenticated,r),!0):!1}function FC(e,t,n,r){if(!n||!r())return;let i=tr(e.environmentId);i&&ar.getState().upsert({...i,lastAuthenticatedPullRequestCapability:t.environment.capabilities?.pullRequests===!0})}async function IC(e,t,n,r){let i=n.findConnection(e.environmentId);if(i)return i;let a=r?.registryExpectation??{kind:`existing-record`,record:e},o=()=>n.canCommit({record:e,generation:t,registryExpectation:a}),{isCmmdRuntime:s,targetProvider:c,initialTarget:l}=await LC(e,r,o);if(!o())throw RC(e.environmentId,c,s),Error(`Saved environment changed while its connection was being acquired.`);let u=r?.client??NC(e,c,o,s,n),d=BC({record:e,initialTarget:l,targetProvider:c,isCmmdRuntime:s,client:u,canCommit:o,dependencies:n});try{if(!await n.withMetadataTimeout(e,PC(e,c,u,o,r?.role??null,r?.serverConfig??null,r?.signal))||!o())throw Error(`Saved environment changed while its connection was being acquired.`);return n.registerConnection(d)}catch(t){throw s&&wl(e.environmentId,c),o()&&n.setError(e.environmentId,t),await d.dispose().catch(()=>void 0),t}}async function LC(e,t,n){let r=fl(e)?CC(e):null,i=r!==null,a=await zC(e,t,i,n),o=i?wC(e,r,a??void 0,n):TC({record:e,bearerToken:a});try{return{isCmmdRuntime:i,targetProvider:o,initialTarget:await xl(o,t?.signal)}}catch(t){throw RC(e.environmentId,o,i),t}}function RC(e,t,n){n&&wl(e,t)}async function zC(e,t,n,r){if(n)return t?.bearerToken;let i=t?.bearerToken??await rr(e.environmentId);if(i)return i;throw r()&&j.getState().patch(e.environmentId,{authState:`requires-auth`,role:null,connectionState:`disconnected`,lastError:`Saved environment is missing its saved credential. Pair it again.`,lastErrorAt:MC()}),Error(`Saved environment is missing its saved credential.`)}function BC(e){let{record:t,initialTarget:n,targetProvider:r,isCmmdRuntime:i,client:a,canCommit:o,dependencies:s}=e,c=Sn({id:t.environmentId,label:t.label,source:`manual`,target:{httpBaseUrl:n.httpBaseUrl,wsBaseUrl:n.wsBaseUrl}}),l=i&&n.expiresAt?jC({initialDescriptor:{...n,expiresAt:n.expiresAt},renew:async()=>{let e=await r.acquire({forceRefresh:!0});return{...e,expiresAt:e.expiresAt??null}},onState:e=>{o()&&j.getState().patch(t.environmentId,{providerAuthority:e})}}):null;return Jl({kind:`saved`,knownEnvironment:{...c,environmentId:t.environmentId},client:a,readiness:{bearerToken:n.bearerToken},tolerateReportedEnvironmentIdentity:i,refreshMetadata:async()=>{await PC(t,r,a,o)},...l?{ensureProviderAuthority:l.ensureLive,onDispose:l.dispose}:{},onConfigSnapshot:e=>{o()&&j.getState().patch(t.environmentId,{descriptor:e.environment,serverConfig:e})},...s.createHandlers(e=>{o()&&j.getState().patch(t.environmentId,{descriptor:e.environment})})})}var VC=class{readRecord;hasSameTarget;generations=new Map;acquisitions=new Map;constructor(e,t){this.readRecord=e,this.hasSameTarget=t}invalidate(e){this.generations.set(e,this.readGeneration(e)+1)}generationFor(e){return this.readGeneration(e)}isCurrent(e){if(this.readGeneration(e.record.environmentId)!==e.generation)return!1;let t=this.readRecord(e.record.environmentId);return e.registryExpectation.kind===`initial-add`?t===null||this.hasSameTarget(t,e.record):t!==null&&this.hasSameTarget(t,e.registryExpectation.record)}ensure(e,t){let n=this.readGeneration(e.environmentId),r=this.acquisitions.get(e.environmentId);if(r&&r.generation===n&&this.hasSameTarget(r.record,e))return r.promise;let i=t(e,n).finally(()=>{this.acquisitions.get(e.environmentId)?.promise===i&&this.acquisitions.delete(e.environmentId)});return this.acquisitions.set(e.environmentId,{generation:n,record:e,promise:i}),i}async sync(e){await ir(e.records);let t=new Map(e.records.map(e=>[e.environmentId,e]));for(let[e,n]of this.acquisitions){let r=t.get(e);(!r||!this.hasSameTarget(r,n.record))&&this.invalidate(e)}let n=new Set(t.keys());await Promise.all(e.connectedSavedEnvironmentIds.filter(e=>!n.has(e)).map(async t=>{this.invalidate(t),await e.disconnect(t)}))}clear(){this.generations.clear(),this.acquisitions.clear()}readGeneration(e){return this.generations.get(e)??0}};async function HC(e,t,n){if(!fl(e))return n.ensureSavedEnvironmentConnection(e,t);let r=n.getGeneration(e.environmentId),i=()=>n.registry.isCurrent({record:e,generation:r,registryExpectation:t?.registryExpectation??{kind:`existing-record`,record:e}}),a=null;for(let r=0;r<8;r+=1){ol(t?.signal);try{let r=await n.ensureSavedEnvironmentConnection(e,t);return await sl(r.ensureBootstrapped(),t?.signal),r}catch(o){a=o,await UC({error:o,attemptIndex:r,record:e,options:t,dependencies:n,canCommit:i})}}let o=a instanceof Error?a:Error(String(a));throw i()&&n.setRuntimeError(e.environmentId,o),o}async function UC(e){let{error:t,attemptIndex:n,record:r,options:i,dependencies:a,canCommit:o}=e;if(!o())throw t;if(await a.removeConnection(r.environmentId).catch(()=>!1),ol(i?.signal),n>=7||!jS(t))throw o()&&a.setRuntimeError(r.environmentId,t),t;let s=MS(n);i?.onBootstrapRetry?.({attempt:n+2,maxAttempts:8,retryDelayMs:s,error:t}),o()&&j.getState().patch(r.environmentId,{connectionState:`connecting`,lastError:null,lastErrorAt:null}),await cl(s,i?.signal)}var WC=new Map,GC=new VC(e=>tr(e),pl),KC=new Set,qC=jl({createPrimaryEnvironmentConnection:QC,syncSavedEnvironmentConnections:ew});function JC(){qC.notifyProviderInvalidation()}function YC(){for(let e of KC)e()}function XC(e){let t=WC.get(e.environmentId);if(t&&t!==e)throw Error(`Environment ${e.environmentId} already has an active connection.`);return WC.set(e.environmentId,e),YC(),e}async function ZC(e){let t=WC.get(e);return t?(WC.delete(e),wl(e),Zb(e),YC(),await t.dispose(),!0):!1}function QC(){return Ax({readConnection:nw,registerConnection:XC})}async function $C(e,t){return WC.get(e.environmentId)||GC.ensure(e,(e,n)=>IC(e,n,{findConnection:e=>WC.get(e),registerConnection:XC,canCommit:GC.isCurrent.bind(GC),createHandlers:Sx,withMetadataTimeout:PS,setConnecting:wx,setConnected:Tx,setDisconnected:Dx,setError:Ox},t))}async function ew(e){await GC.sync({records:e,connectedSavedEnvironmentIds:[...WC.values()].filter(e=>e.kind===`saved`).map(e=>e.environmentId),disconnect:cw})}function tw(e){return KC.add(e),()=>{KC.delete(e)}}function nw(e){return WC.get(e)??null}function rw(e){return xS(e,{readConnection:nw,registerConnection:XC})}function iw(e){let t=nw(e);if(!t)throw Error(`No websocket client registered for environment ${e}.`);return t}function aw(){return QC()}async function ow(){return jx({readConnection:nw,registerConnection:XC})}function sw(){return{readConnection:nw,removeConnection:ZC,ensureSavedEnvironmentConnection:$C,ensureCmmdRuntimeSavedEnvironmentConnection:pw,invalidate:e=>GC.invalidate(e),retireEnvironmentId:Xb}}async function cw(e){await Lx(e,sw())}async function lw(e){await Rx(e,sw())}async function uw(){return Fx({readConnection:nw,ensureCmmdRuntimeSavedEnvironmentConnection:pw})}async function dw(e){await zx(e,sw())}async function fw(e){return Bx(e,sw())}async function pw(e,t){return HC(e,t,{ensureSavedEnvironmentConnection:$C,getGeneration:e=>GC.generationFor(e),registry:GC,removeConnection:ZC,setRuntimeError:Ox})}async function mw(e){await WC.get(e)?.ensureBootstrapped()}async function hw(e){let t=WC.get(e);if(t?.ensureProviderAuthority){await t.ensureProviderAuthority();return}if(Cl(e))throw Error(`Cloud runtime provider authority is not available.`)}function gw(e){return qC.start(e)}Ab({applyEvent:yx,readConnection:nw,subscribeConnections:tw}),Cy({notifyProviderInvalidation:JC,readQueryClient:()=>qC.readActiveService()?.queryClient??null,setRuntimeError:Ox});var _w=fn(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);function vw(e){return{environmentId:e.environmentId,threadId:e.threadId}}function yw(e){return{draftId:e}}function bw(e){return!e.environmentId||!e.threadId?null:C(e.environmentId,e.threadId)}function xw(e){return e.environmentId&&e.threadId?{kind:`server`,threadRef:C(e.environmentId,e.threadId)}:e.draftId?{kind:`draft`,draftId:e.draftId}:null}function I(e){let t=(0,A.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=wa(`relative overflow-hidden rounded-sm bg-muted [--skeleton-highlight:--alpha(var(--color-white)/64%)] after:absolute after:inset-0 after:animate-skeleton after:bg-[linear-gradient(120deg,transparent_40%,var(--skeleton-highlight),transparent_60%)] motion-reduce:after:content-none dark:[--skeleton-highlight:--alpha(var(--color-white)/4%)]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,k.jsx)(`div`,{className:i,"data-slot":`skeleton`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Sw(e){let t=e.browser,n=t?{openSession:t.openSession,listSessions:t.listSessions,closeSession:t.closeSession,getSession:t.getSession,command:t.command,clearBrowsingData:t.clearBrowsingData,attachDisplay:t.attachDisplay,addDisplayIceCandidate:async e=>{await t.addDisplayIceCandidate(e)},onEvent:(e,n)=>t.onEvent(e,n)}:void 0;return{...n?{browser:n}:{},attachments:{createUploadUrl:t=>e.attachments.createUploadUrl(t),delete:t=>e.attachments.delete(t)},computer:{input:t=>e.computer.input(t)},threadDevRuntime:{get:t=>e.threadDevRuntime.get(t),allocatePort:t=>e.threadDevRuntime.allocatePort(t),release:t=>e.threadDevRuntime.release(t)},devTunnel:{register:t=>e.devTunnel.register(t),unregister:t=>e.devTunnel.unregister(t),list:t=>e.devTunnel.list(t)},terminal:{open:t=>e.terminal.open(t),write:t=>e.terminal.write(t),resize:t=>e.terminal.resize(t),signal:t=>e.terminal.signal(t),clear:t=>e.terminal.clear(t),restart:t=>e.terminal.restart(t),close:t=>e.terminal.close(t),onEvent:t=>e.terminal.onEvent(t)},projects:{searchContents:e.projects.searchContents,searchEntries:e.projects.searchEntries,readFile:e.projects.readFile,writeFile:e.projects.writeFile},workspace:{environmentPreflight:e.workspace.environmentPreflight,ensureScratch:e.workspace.ensureScratch},shell:{openInEditor:t=>e.shell.openInEditor(t)},git:{pull:e.git.pull,refreshStatus:e.git.refreshStatus,onStatus:(t,n,r)=>e.git.onStatus(t,n,r),listBranches:e.git.listBranches,createWorktree:e.git.createWorktree,removeWorktree:e.git.removeWorktree,createBranch:e.git.createBranch,checkout:e.git.checkout,init:e.git.init,resolvePullRequest:e.git.resolvePullRequest,preparePullRequestThread:e.git.preparePullRequestThread},pullRequests:{list:t=>e.pullRequests.list(t),listStats:t=>e.pullRequests.listStats(t),detail:t=>e.pullRequests.detail(t),activity:t=>e.pullRequests.activity(t),threadComments:t=>e.pullRequests.threadComments(t),diffFileContents:t=>e.pullRequests.diffFileContents(t),runAction:t=>e.pullRequests.runAction(t),update:t=>e.pullRequests.update(t),comment:t=>e.pullRequests.comment(t),updateComment:t=>e.pullRequests.updateComment(t),submitReview:t=>e.pullRequests.submitReview(t),replyToThread:t=>e.pullRequests.replyToThread(t),setThreadResolution:t=>e.pullRequests.setThreadResolution(t),setReaction:t=>e.pullRequests.setReaction(t),invalidate:t=>e.pullRequests.invalidate(t),reviewerCandidates:t=>e.pullRequests.reviewerCandidates(t),requestReviewers:t=>e.pullRequests.requestReviewers(t)},orchestration:{dispatchCommand:e.orchestration.dispatchCommand,getTurnDiff:e.orchestration.getTurnDiff,getFullThreadDiff:e.orchestration.getFullThreadDiff,subscribeShell:(t,n)=>e.orchestration.subscribeShell(t,n),subscribeThread:(t,n,r)=>e.orchestration.subscribeThread(t,n,r)}}}function Cw(e){if(typeof window>`u`||!e)return;let t=nw(e);return t?Sw(t.client):void 0}function ww(e){let t=(0,A.c)(4),n;t[0]===e?n=t[1]:(n=()=>nw(e),t[0]=e,t[1]=n);let r=(0,O.useSyncExternalStore)(tw,n,Tw),i,a;return t[2]===r?a=t[3]:(a=r?Sw(r.client):void 0,t[2]=r,t[3]=a),i=a,i}function Tw(){return null}function Ew(e){let t=Cw(e);if(!t)throw Error(`Environment API not found for environment ${e}`);return t}function Dw(e){let t=e.payload&&typeof e.payload==`object`?e.payload:null,n=t?.plan;if(!Array.isArray(n))return null;let r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=e;if(typeof t.step!=`string`)continue;let n=t.status===`completed`||t.status===`inProgress`?t.status:`pending`;r.push({step:t.step,status:n})}return r.length===0?null:{createdAt:e.createdAt,turnId:e.turnId,...t&&`explanation`in t?{explanation:t.explanation}:{},steps:r}}function Ow(e){let t=new Map;return e.map(e=>{let n=t.get(e.step)??0;return t.set(e.step,n+1),{key:`${e.step}:${n}`,step:e}})}function kw(e,t){let n=new Map,r;for(let e of t){let t=Dw(e),i=Date.parse(e.createdAt);if(!(!t||Number.isNaN(i))){r??=i;for(let{key:e,step:r}of Ow(t.steps)){let t=n.get(e)??{};r.status===`inProgress`&&t.startedAt===void 0&&(t.startedAt=i),r.status===`completed`&&t.completedAt===void 0&&(t.completedAt=i),n.set(e,t)}}}let i=new Map,a=r;for(let[e,t]of[...n.entries()].toSorted((e,t)=>(e[1].completedAt??1/0)-(t[1].completedAt??1/0))){let n=t.completedAt,r=t.startedAt??a;n!==void 0&&(r!==void 0&&n>r&&i.set(e,n-r),a=n)}return{...e,steps:Ow(e.steps).map(({key:e,step:t})=>{if(t.status!==`completed`)return t;let n=i.get(e);return n===void 0?t:Object.assign({},t,{durationMs:n})})}}function Aw(e){let t=Mw(e?.data),n=Mw(t?.item),r=Mw(n?.result),i=Mw(n?.input),a=Nw(e?.itemType),o=Nw(e?.detail),s=[e?.command,n?.command,i?.command,r?.command,t?.command,a===`command_execution`&&o?jw(o).output:null];for(let e of s){let t=Uw(e);if(t)return{command:t,rawCommand:Ww(e,t)}}return{command:null,rawCommand:null}}function jw(e){let t=e.trim(),n=/^(?<output>[\s\S]*?)(?:\s*<exited with exit code (?<code>\d+)>)\s*$/i.exec(t);if(!n?.groups)return{output:t.length>0?t:null};let r=Number.parseInt(n.groups.code??``,10),i=n.groups.output?.trim()??``;return{output:i.length>0?i:null,...Number.isInteger(r)?{exitCode:r}:{}}}function Mw(e){return e&&typeof e==`object`?e:null}function Nw(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Pw(e){let t=e.trim();if(t.startsWith(`'`)&&t.endsWith(`'`)||t.startsWith(`"`)&&t.endsWith(`"`)){let e=t.slice(1,-1).trim();return e.length>0?e:t}return t}function Fw(e){let t=Pw(e);if(t.length===0)return null;let n=t.replace(/\\/g,`/`).split(`/`).at(-1)?.trim()??``;return n.length>0?n.toLowerCase():null}function Iw(e){let t=e.trim();if(t.length===0)return null;if(t.startsWith(`"`)||t.startsWith(`'`)){let e=t.charAt(0),n=t.indexOf(e,1);return n<=0?null:{executable:t.slice(0,n+1),rest:t.slice(n+1).trim()}}let n=t.search(/\s/);return n<0?{executable:t,rest:``}:{executable:t.slice(0,n),rest:t.slice(n).trim()}}var Lw=[{executables:[`pwsh`,`pwsh.exe`,`powershell`,`powershell.exe`],wrapperFlagPattern:/(?:^|\s)-command\s+/i},{executables:[`cmd`,`cmd.exe`],wrapperFlagPattern:/(?:^|\s)\/c\s+/i},{executables:[`bash`,`sh`,`zsh`],wrapperFlagPattern:/(?:^|\s)-(?:l)?c\s+/i}];function Rw(e){return Lw.find(t=>t.executables.includes(e))}function zw(e,t){let n=t.exec(e);if(!n)return null;let r=e.slice(n.index+n[0].length).trim();if(r.length===0)return null;let i=r[0];if((i===`'`||i===`"`)&&!r.endsWith(i))return null;let a=Pw(r);return a.length>0?a:null}function Bw(e){let t=Iw(e);if(!t||t.rest.length===0)return e;let n=Fw(t.executable);if(!n)return e;let r=Rw(n);return r?zw(t.rest,r.wrapperFlagPattern)??e:e}function Vw(e){return/[\s"'`]/.test(e)?`"${e.replace(/"/g,`\\"`)}"`:e}function Hw(e){let t=Nw(e);if(t)return t;if(!Array.isArray(e))return null;let n=[];for(let t of e){let e=Nw(t);e!==null&&n.push(e)}return n.length===0?null:n.map(e=>Vw(e)).join(` `)}function Uw(e){let t=Hw(e);return t?Bw(t):null}function Ww(e,t){let n=Hw(e);return!n||t===null||n===t?null:n}function Gw(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Kw(e){return typeof e==`string`&&e.trim().length>0?e:null}function qw(e){let t=Kw(e);if(t)return t;let n=Array.isArray(e)?e:null,r=Gw(e)?.content,i=Kw(r);if(i)return i;let a=n??(Array.isArray(r)?r:null);if(!a)return null;let o=a.flatMap(e=>{let t=Kw(e)??Kw(Gw(e)?.text);return t?[t]:[]});return o.length>0?o.join(`
|
|
17
|
-
`):null}function
|
|
16
|
+
`);return{...e,prompt:Wm(o,a.contexts.length),images:r.images,files:i,persistedAttachments:r.attachments,terminalContexts:a.contexts,stashTerminalContexts:[...e.stashTerminalContexts??[],...a.restoredSnapshots]}}function V_(e,t){let n=new Set(e.map(e=>e.id));return[...e,...t.filter(e=>!n.has(e.id))]}function H_(e,t){let n=new Map(t.attachments.map(e=>[e.id,e])),r=[...e.images],i=e.persistedAttachments.filter(t=>e.images.some(e=>e.id===t.id)),a=new Set(r.map(e=>e.id)),o=new Set(r.map(I_));for(let e of t.images){let t=n.get(e.id);if(!t)return null;let s=I_(e);a.has(e.id)||o.has(s)||(r.push(e),i.push(t),a.add(e.id),o.add(s))}return r.length>8?null:{images:r,attachments:i}}function U_(e,t,n){let r=[...e.terminalContexts],i=new Set(r.map(e=>e.id)),a=new Set(r.map(L_)),o=[];for(let e of t.terminalContexts){let t=R_(n,e);!t||i.has(t.id)||a.has(L_(t))||(r.push(t),o.push(t),i.add(t.id),a.add(L_(t)))}return{contexts:r,restoredSnapshots:o}}function W_(e,t){return e.prompt===t.prompt&&JSON.stringify(e.attachments)===JSON.stringify(t.persistedAttachments)&&JSON.stringify(e.files??[])===JSON.stringify((t.files??[]).map(({file:e,type:t,...n})=>n))&&JSON.stringify(e.terminalContexts??[])===JSON.stringify(t.terminalContexts.map(({text:e,...t})=>t))&&JSON.stringify(e.stashTerminalContexts??[])===JSON.stringify(t.stashTerminalContexts??[])}function G_(e){typeof URL<`u`&&e.startsWith(`blob:`)&&URL.revokeObjectURL(e)}function K_(e){if(!e||typeof e!=`object`)return null;let{id:t,name:n,mimeType:r,sizeBytes:i,dataUrl:a}=e;return typeof t!=`string`||typeof n!=`string`||typeof r!=`string`||typeof i!=`number`||!Number.isFinite(i)||typeof a!=`string`||t.length===0||a.length===0?null:{id:t,name:n,mimeType:r,sizeBytes:i,dataUrl:a}}function q_(e){if(!e||typeof e!=`object`)return null;let{id:t,name:n,mimeType:r,sizeBytes:i}=e;return typeof t!=`string`||t.length===0||typeof n!=`string`||typeof r!=`string`||typeof i!=`number`||!Number.isSafeInteger(i)||i<0?null:{id:t,name:n,mimeType:r,sizeBytes:i}}async function J_(e,t){let n=await Promise.all(e.map(async e=>{let n=await t.read(e);return{...e,type:`file`,file:n}}));return n.length===e.length?n:null}function Y_(e){let t=X_(e.dataUrl,e.mimeType);return t?new File([t.content],e.name,{type:t.mimeType}):null}function X_(e,t){let n=e.indexOf(`,`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n+1);if(i.length===0)return null;try{return r.includes(`;base64`)?{content:$_(i),mimeType:t}:{content:Q_(i),mimeType:Z_(r,t)}}catch{return null}}function Z_(e,t){return!e.startsWith(`data:`)||!e.includes(`;`)?t:e.slice(5,e.indexOf(`;`))||t}function Q_(e){return decodeURIComponent(e)}function $_(e){let t=atob(e),n=new Uint8Array(new ArrayBuffer(t.length));for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function ev(e){return e.flatMap(e=>{let t=Y_(e);return t?[{type:`image`,id:e.id,name:e.name,mimeType:e.mimeType,sizeBytes:e.sizeBytes,previewUrl:e.dataUrl,file:t}]:[]})}function tv(e){return{prompt:e.prompt,images:[...e.images],files:[...e.files??[]],persistedAttachments:[...e.persistedAttachments],terminalContexts:[...e.terminalContexts]}}function nv({file:e,previewUrl:t,...n}){return n}function rv(e,t){return e.prompt===t.prompt&&JSON.stringify(e.images.map(nv))===JSON.stringify(t.images.map(nv))&&JSON.stringify((e.files??[]).map(({file:e,...t})=>t))===JSON.stringify(t.files.map(({file:e,...t})=>t))&&JSON.stringify(e.persistedAttachments)===JSON.stringify(t.persistedAttachments)&&JSON.stringify(e.terminalContexts)===JSON.stringify(t.terminalContexts)}function iv(e){let{lastGeneratedPullRequestPrompt:t,...n}=e;return{...n,prompt:``,images:[],files:[],nonPersistedImageIds:[],persistedAttachments:[],terminalContexts:[],stashTerminalContexts:[]}}function N(e){return e.prompt.length===0&&e.lastGeneratedPullRequestPrompt===void 0&&e.images.length===0&&(e.files?.length??0)===0&&e.persistedAttachments.length===0&&e.terminalContexts.length===0&&Object.keys(e.modelSelectionByProvider).length===0&&e.activeProvider===null&&e.runtimeMode===null&&e.interactionMode===null&&e.stagedSubmission==null}function av(e){switch(e){case`codex`:case`claudeAgent`:case`ollama`:case`cmmd`:case`apex`:case`cursor`:case`opencode`:return e;default:return null}}function ov(e){return vi.some(t=>t===e)}function sv(e){return Ti.some(t=>t===e)}function cv(e,t,n){let r=e&&typeof e==`object`?e:null,i=r?.codex&&typeof r.codex==`object`?r.codex:null,a=r?.claudeAgent&&typeof r.claudeAgent==`object`?r.claudeAgent:null,o=ov(i?.reasoningEffort)?i.reasoningEffort:t===`codex`&&ov(n?.effort)?n.effort:void 0,s=i?.fastMode===!0?!0:i?.fastMode===!1?!1:t===`codex`&&n?.codexFastMode===!0||typeof n?.serviceTier==`string`&&n.serviceTier===`fast`||void 0,c=o!==void 0||s!==void 0?{...o===void 0?{}:{reasoningEffort:o},...s===void 0?{}:{fastMode:s}}:void 0,l=a?.thinking===!0||a?.thinking!==!1&&void 0,u=sv(a?.effort)?a.effort:void 0,d=a?.fastMode===!0||a?.fastMode!==!1&&void 0,f=typeof a?.contextWindow==`string`&&a.contextWindow.length>0?a.contextWindow:void 0,p=l!==void 0||u!==void 0||d!==void 0||f!==void 0?{...l===void 0?{}:{thinking:l},...u===void 0?{}:{effort:u},...d===void 0?{}:{fastMode:d},...f===void 0?{}:{contextWindow:f}}:void 0;return!c&&!p?null:{...c?{codex:c}:{},...p?{claudeAgent:p}:{}}}function lv(e,t){let n=e&&typeof e==`object`?e:null,r=av(n?.provider??t?.provider);if(r===null)return null;let i=n?.model??t?.model;if(typeof i!=`string`)return null;let a=On(i,r);if(!a)return null;let o=cv(n?.options?{[r]:n.options}:t?.modelOptions,r,r===`codex`?t?.legacyCodex:void 0),s=r===`codex`?o?.codex:o?.claudeAgent,c=n?.providerAccountId,l=typeof c==`string`&&c.trim().length>0?c.trim():void 0;return{provider:r,model:a,...l?{providerAccountId:l}:{},...s?{options:s}:{}}}function uv(e,t){if(e===null)return null;let n=t?.[e.provider];return{provider:e.provider,model:e.model,...`providerAccountId`in e&&e.providerAccountId?{providerAccountId:e.providerAccountId}:{},...n?{options:n}:{}}}function dv(e,t){return e?.options===void 0?cv(t):fv(cv(t),e.provider,e.options)}function fv(e,t,n){let{[t]:r,...i}=e??{},a=cv({[t]:n},t);return cv({...i,...a||{}})}function pv(e,t){let n={};if(t)for(let r of[`codex`,`claudeAgent`]){let i=t[r];i&&Object.keys(i).length>0&&(n[r]={provider:r,model:e?.provider===r?e.model:Ii[r],options:i})}return e&&(n[e.provider]=e),n}var mv=`forge:composer-drafts:v1`,hv=5,gv=ki([`local`,`worktree`]),_v=Vr(gi),vv=300,yv=fh({storage:typeof localStorage<`u`?localStorage:_r(),version:hv,canMigrate:Ev}),bv=_n(yv,vv);typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`beforeunload`,()=>{bv.flush()});var xv=Bi({prompt:E,lastGeneratedPullRequestPrompt:w(E),attachments:Mi(S_),files:w(Mi(C_)),terminalContexts:w(Mi(w_)),stashTerminalContexts:w(Mi(Bi({...w_.fields,text:E}))),modelSelectionByProvider:w(si(pi,w(Di))),activeProvider:w(yi(pi)),runtimeMode:w(gi),interactionMode:w(Fi),stagedSubmission:w(T_)});Bi({effort:w(ki(vi)),codexFastMode:w(fi),serviceTier:w(E)}),Bi({provider:w(pi),model:w(E),modelOptions:w(yi(Dr))}),Bi({stickyProvider:w(pi),stickyModel:w(E),stickyModelOptions:w(yi(Dr))});var Sv=Bi({threadId:Br,environmentId:E,projectId:Si,logicalProjectKey:w(E),createdAt:E,runtimeMode:gi,interactionMode:Fi,branch:yi(E),worktreePath:yi(E),envMode:gv,promotedTo:w(yi(Bi({environmentId:E,threadId:E}))),anchorKind:w(Wr),anchorCmmdId:w(yi(E)),linkedPullRequest:w(yi(Pi))}),Cv=Bi({draftsByThreadKey:si(E,xv),draftThreadsByThreadKey:si(E,Sv),logicalProjectDraftThreadKeyByLogicalProjectKey:si(E,E),stickyModelSelectionByProvider:w(si(pi,w(Di))),stickyActiveProvider:w(yi(pi))}),wv=Bi({version:_i,state:Cv}),Tv=Ci(wv);function Ev(e,t){if(e===null)return!0;try{let n=JSON.parse(e);if(!n||typeof n!=`object`)return!1;let r=n;return r.version===t?(Tv(n),!0):typeof r.version==`number`&&Number.isInteger(r.version)&&r.version>=1&&r.version<t&&r.state!==null&&typeof r.state==`object`}catch{return!1}}function Dv(e){if(e===null)return new Set;try{let t=Tv(JSON.parse(e));if(t.version!==hv)return null;let n=new Set;for(let e of Object.values(t.state.draftsByThreadKey)){for(let t of e.files??[])n.add(t.id);for(let t of e.stagedSubmission?.files??[])n.add(t.id)}return n}catch{return null}}function Ov(){bv.flush()}var kv=Object.freeze({draftsByThreadKey:{},draftThreadsByThreadKey:{},logicalProjectDraftThreadKeyByLogicalProjectKey:{},stickyModelSelectionByProvider:{},stickyActiveProvider:null}),Av=[],jv=[],Mv=[],Nv=[],Pv=[];Object.freeze(Av),Object.freeze(Mv),Object.freeze(Nv);var Fv=Object.freeze({}),Iv=Object.freeze({activeProvider:null,modelSelectionByProvider:Fv}),Lv=Object.freeze({prompt:``,images:Av,files:jv,nonPersistedImageIds:Mv,persistedAttachments:Nv,terminalContexts:Pv,modelSelectionByProvider:Fv,activeProvider:null,runtimeMode:null,interactionMode:null,stagedSubmission:null});function P(){return{prompt:``,images:[],files:[],nonPersistedImageIds:[],persistedAttachments:[],terminalContexts:[],modelSelectionByProvider:{},activeProvider:null,runtimeMode:null,interactionMode:null,stagedSubmission:null}}function Rv(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.id,r=t.threadId,i=t.createdAt,a=t.lineStart,o=t.lineEnd;if(typeof n!=`string`||n.length===0||typeof r!=`string`||r.length===0||typeof i!=`string`||i.length===0||typeof a!=`number`||!Number.isFinite(a)||typeof o!=`number`||!Number.isFinite(o))return null;let s=typeof t.terminalId==`string`?t.terminalId.trim():``,c=typeof t.terminalLabel==`string`?t.terminalLabel.trim():``;if(s.length===0||c.length===0)return null;let l=Math.max(1,Math.floor(a));return{id:n,threadId:r,createdAt:i,terminalId:s,terminalLabel:c,lineStart:l,lineEnd:Math.max(l,Math.floor(o))}}function zv(e,t){return e===`local`||e===`worktree`?e:t?`worktree`:`local`}function Bv(e){return In(e)}function Vv(e){return e.trim()}function Hv(e){return typeof e==`string`?e.trim():Rn(e)}function Uv(e,t){let n=gn(e);return n?Hv(n):t?.environmentId?Hv(C(t.environmentId,e)):e}function Wv(e){return gn(e)}function Gv(e,t){if(typeof t==`string`){let e=t.trim();return e.length>0?xa.make(e):null}return t}function F(e,t){let n=Gv(e,t);if(!n)return null;if(typeof n!=`string`){let t=Hv(n);if(e.draftsByThreadKey[t])return t;for(let[t,r]of Object.entries(e.draftThreadsByThreadKey))if(r.environmentId===n.environmentId&&r.threadId===n.threadId)return t;return t}let r=Hv(n);return r.length>0?r:null}function Kv(e,t){let n=Gv(e,t);return n?typeof n==`string`?e.draftThreadsByThreadKey[n]?.threadId??Br.make(n):n.threadId:null}function qv(e,t){let n=F(e,t);return n?e.draftsByThreadKey[n]??null:null}function Jv(e,t){return Object.values(e).includes(t)}function Yv(e,t){return{draftId:e,...t}}function Xv(e,t,n,r,i){let a=r!==void 0&&(r.environmentId!==e.environmentId||r.projectId!==e.projectId),o=i?.worktreePath===void 0?a?null:r?.worktreePath??null:i.worktreePath??null,s=i?.branch===void 0?a?null:r?.branch??null:i.branch??null,c=i?.anchorKind===void 0?r?.anchorKind:i.anchorKind??void 0;return{threadId:t,environmentId:e.environmentId,projectId:e.projectId,logicalProjectKey:n,createdAt:i?.createdAt??r?.createdAt??new Date().toISOString(),runtimeMode:i?.runtimeMode??r?.runtimeMode??`full-access`,interactionMode:i?.interactionMode??r?.interactionMode??`default`,branch:s,worktreePath:o,envMode:i?.envMode??(o?`worktree`:a?`local`:r?.envMode??`local`),promotedTo:null,cmmdTaskId:i?.cmmdTaskId===void 0?r?.cmmdTaskId??null:i.cmmdTaskId,anchorCmmdId:i?.anchorCmmdId===void 0?r?.anchorCmmdId??null:i.anchorCmmdId,linkedPullRequest:i?.linkedPullRequest===void 0?r?.linkedPullRequest??null:i.linkedPullRequest,...c===void 0?{}:{anchorKind:c}}}function Zv(e,t){return!e||!t?e===t:e.environmentId===t.environmentId&&e.threadId===t.threadId}function Qv(e){return e?.promotedTo!==null&&e?.promotedTo!==void 0}function $v(e,t){return!!e&&e.threadId===t.threadId&&e.environmentId===t.environmentId&&e.projectId===t.projectId&&e.logicalProjectKey===t.logicalProjectKey&&e.createdAt===t.createdAt&&e.runtimeMode===t.runtimeMode&&e.interactionMode===t.interactionMode&&e.branch===t.branch&&e.worktreePath===t.worktreePath&&e.envMode===t.envMode&&(e.anchorKind??void 0)===(t.anchorKind??void 0)&&(e.anchorCmmdId??null)===(t.anchorCmmdId??null)&&ey(e.linkedPullRequest,t.linkedPullRequest)&&Zv(e.promotedTo,t.promotedTo)}function ey(e,t){return(e?.projectId??null)===(t?.projectId??null)&&(e?.projectRepositoryId??null)===(t?.projectRepositoryId??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.host??null)===(t?.host??null)&&(e?.repository??null)===(t?.repository??null)&&(e?.number??null)===(t?.number??null)&&(e?.url??null)===(t?.url??null)}function ty(e,t){let n=Object.fromEntries(Object.entries(e.logicalProjectDraftThreadKeyByLogicalProjectKey).filter(([,e])=>e!==t)),{[t]:r,...i}=e.draftThreadsByThreadKey,{[t]:a,...o}=e.draftsByThreadKey;return{draftsByThreadKey:o,draftThreadsByThreadKey:i,logicalProjectDraftThreadKeyByLogicalProjectKey:n}}function ny(e,t){let n={},r=new Map;if(t&&typeof t==`object`)for(let[e,n]of Object.entries(t)){if(typeof n!=`string`||n.length===0)continue;let t=xr(e);if(!t)continue;let i=gn(n);if(i){r.set(i.threadId,i.environmentId);continue}r.set(n,t.environmentId)}if(e&&typeof e==`object`)for(let[t,i]of Object.entries(e)){if(typeof t!=`string`||t.length===0||!i||typeof i!=`object`)continue;let e=i,a=gn(t),o=Uv(t),s=a?.threadId??(typeof e.threadId==`string`&&e.threadId.length>0?e.threadId:t),c=a?.environmentId??(typeof e.environmentId==`string`&&e.environmentId.length>0?e.environmentId:r.get(t)),l=e.projectId,u=e.createdAt,d=e.branch,f=e.worktreePath,p=typeof f==`string`?f:null,m=e.promotedTo,h=m&&typeof m==`object`?m:null,g=h&&typeof h.environmentId==`string`&&h.environmentId.length>0&&typeof h.threadId==`string`&&h.threadId.length>0?C(h.environmentId,h.threadId):null;if(typeof l!=`string`||l.length===0||c===void 0)continue;let _=c;n[o]={threadId:s,environmentId:_,projectId:l,logicalProjectKey:typeof e.logicalProjectKey==`string`&&e.logicalProjectKey.length>0?e.logicalProjectKey:a?Bv(Ln(_,l)):t,createdAt:typeof u==`string`&&u.length>0?u:new Date().toISOString(),runtimeMode:_v(e.runtimeMode)?e.runtimeMode:op,interactionMode:e.interactionMode===`plan`||e.interactionMode==="default"?e.interactionMode:sp,branch:typeof d==`string`?d:null,worktreePath:p,envMode:zv(e.envMode,p),promotedTo:g}}let i={};if(t&&typeof t==`object`)for(let[e,a]of Object.entries(t)){if(typeof a!=`string`||a.length===0)continue;let t=xr(e),o=gn(a),s=Uv(a);if(i[e]=s,o&&r.set(o.threadId,o.environmentId),!t){let t=n[s];t&&!t.logicalProjectKey&&(n[s]={...t,logicalProjectKey:e});continue}n[s]?(n[s]?.projectId!==t.projectId||n[s]?.environmentId!==t.environmentId)&&(n[s]={...n[s],threadId:n[s].threadId,environmentId:t.environmentId,projectId:t.projectId,logicalProjectKey:e}):n[s]={threadId:o?.threadId??s,environmentId:t.environmentId,projectId:t.projectId,logicalProjectKey:e,createdAt:new Date().toISOString(),runtimeMode:op,interactionMode:sp,branch:null,worktreePath:null,envMode:`local`,promotedTo:null}}return{draftThreadsByThreadKey:n,logicalProjectDraftThreadKeyByLogicalProjectKey:i}}function ry(e,t){if(!e||typeof e!=`object`)return{};let n=new Map;for(let[e,r]of Object.entries(t)){let t=Wv(e);t&&n.set(t.threadId,r.environmentId)}let r={};for(let[i,a]of Object.entries(e)){if(typeof i!=`string`||i.length===0||!a||typeof a!=`object`)continue;let e=a,o=typeof e.prompt==`string`?e.prompt:``,s=typeof e.lastGeneratedPullRequestPrompt==`string`?e.lastGeneratedPullRequestPrompt:void 0,c=Array.isArray(e.attachments)?e.attachments.flatMap(e=>{let t=K_(e);return t?[t]:[]}):[],l=Array.isArray(e.files)?e.files.flatMap(e=>{let t=q_(e);return t?[t]:[]}):[],u=Array.isArray(e.terminalContexts)?e.terminalContexts.flatMap(e=>{let t=Rv(e);return t?[t]:[]}):[],d=Array.isArray(e.stashTerminalContexts)?e.stashTerminalContexts.flatMap(e=>{let t=Rv(e),n=typeof e.text==`string`?e.text:``;return t&&n.length>0?[{...t,text:n}]:[]}):[],f=_v(e.runtimeMode)?e.runtimeMode:null,p=e.interactionMode===`plan`||e.interactionMode==="default"?e.interactionMode:null,m=A_(e.stagedSubmission,{attachment:K_,file:q_,terminalContext:Rv,modelSelection:e=>lv(e)??null,runtimeMode:_v}),h=Wm(o,u.length),g=a,_={},v=null;if(e.modelSelectionByProvider&&typeof e.modelSelectionByProvider==`object`)_=e.modelSelectionByProvider,v=av(e.activeProvider);else{let e=cv(g.modelOptions,void 0,g)??null,t=lv(g.modelSelection,{provider:g.provider,model:g.model,modelOptions:e??g.modelOptions,legacyCodex:g}),n=dv(t,e),r=uv(t,n);_=pv(r,n),v=r?.provider??null}let y=Object.keys(_).length>0||v!==null;if(o.length===0&&c.length===0&&l.length===0&&u.length===0&&d.length===0&&!y&&!f&&!p&&!m)continue;let b=gn(i)===null?t[i]===void 0?(()=>{let e=n.get(i);return e?Uv(i,{environmentId:e}):i})():i:Uv(i);r[b]={prompt:h,...s===void 0?{}:{lastGeneratedPullRequestPrompt:s},attachments:c,...l.length>0?{files:l}:{},...u.length>0?{terminalContexts:u}:{},...d.length>0?{stashTerminalContexts:d}:{},...y?{modelSelectionByProvider:_,activeProvider:v}:{},...f?{runtimeMode:f}:{},...p?{interactionMode:p}:{},...m?{stagedSubmission:m}:{}}}return r}function iy(e){if(!e||typeof e!=`object`)return kv;let t=e,n=t.draftsByThreadKey??t.draftsByThreadId,r=t.draftThreadsByThreadKey??t.draftThreadsByThreadId,i=t.logicalProjectDraftThreadKeyByLogicalProjectKey??t.projectDraftThreadKeyByProjectKey??t.projectDraftThreadIdByProjectKey??t.projectDraftThreadIdByProjectId,a=cv(t.stickyModelOptions)??{},o=lv(t.stickyModelSelection,{provider:t.stickyProvider??`codex`,model:t.stickyModel,modelOptions:a}),s=dv(o,a),c=pv(uv(o,s),s),l=av(t.stickyProvider)??null,{draftThreadsByThreadKey:u,logicalProjectDraftThreadKeyByLogicalProjectKey:d}=ny(r,i);return{draftsByThreadKey:ry(n,u),draftThreadsByThreadKey:u,logicalProjectDraftThreadKeyByLogicalProjectKey:d,stickyModelSelectionByProvider:c,stickyActiveProvider:l}}function ay(e){let t={};for(let[n,r]of Object.entries(e.draftsByThreadKey)){if(typeof n!=`string`||n.length===0)continue;let e=Object.keys(r.modelSelectionByProvider).length>0||r.activeProvider!==null;r.prompt.length===0&&r.lastGeneratedPullRequestPrompt===void 0&&r.persistedAttachments.length===0&&(r.files?.length??0)===0&&r.terminalContexts.length===0&&!e&&r.runtimeMode===null&&r.interactionMode===null&&r.stagedSubmission==null||(t[n]={prompt:r.prompt,...r.lastGeneratedPullRequestPrompt===void 0?{}:{lastGeneratedPullRequestPrompt:r.lastGeneratedPullRequestPrompt},attachments:r.persistedAttachments,...(r.files?.length??0)>0?{files:r.files.map(({file:e,type:t,...n})=>n)}:{},...r.terminalContexts.length>0?{terminalContexts:r.terminalContexts.map(e=>({id:e.id,threadId:e.threadId,createdAt:e.createdAt,terminalId:e.terminalId,terminalLabel:e.terminalLabel,lineStart:e.lineStart,lineEnd:e.lineEnd}))}:{},...r.stashTerminalContexts&&r.stashTerminalContexts.length>0?{stashTerminalContexts:r.stashTerminalContexts.map(e=>({id:e.id,threadId:e.threadId,createdAt:e.createdAt,terminalId:e.terminalId,terminalLabel:e.terminalLabel,lineStart:e.lineStart,lineEnd:e.lineEnd,text:e.text}))}:{},...e?{modelSelectionByProvider:r.modelSelectionByProvider,activeProvider:r.activeProvider}:{},...r.runtimeMode?{runtimeMode:r.runtimeMode}:{},...r.interactionMode?{interactionMode:r.interactionMode}:{},...r.stagedSubmission?{stagedSubmission:M_(r.stagedSubmission)}:{}})}return{draftsByThreadKey:t,draftThreadsByThreadKey:e.draftThreadsByThreadKey,logicalProjectDraftThreadKeyByLogicalProjectKey:e.logicalProjectDraftThreadKeyByLogicalProjectKey,stickyModelSelectionByProvider:e.stickyModelSelectionByProvider,stickyActiveProvider:e.stickyActiveProvider}}function oy(e){if(!e||typeof e!=`object`)return kv;let t=e,{draftThreadsByThreadKey:n,logicalProjectDraftThreadKeyByLogicalProjectKey:r}=ny(t.draftThreadsByThreadKey??t.draftThreadsByThreadId,t.logicalProjectDraftThreadKeyByLogicalProjectKey??t.projectDraftThreadKeyByProjectKey??t.projectDraftThreadIdByProjectKey??t.projectDraftThreadIdByProjectId),i={},a=null;if(t.stickyModelSelectionByProvider&&typeof t.stickyModelSelectionByProvider==`object`)i=t.stickyModelSelectionByProvider,a=av(t.stickyActiveProvider);else{let e=cv(t.stickyModelOptions)??{},n=lv(t.stickyModelSelection,{provider:t.stickyProvider,model:t.stickyModel,modelOptions:e}),r=dv(n,e);i=pv(uv(n,r),r),a=av(t.stickyProvider)}return{draftsByThreadKey:ry(t.draftsByThreadKey??t.draftsByThreadId,n),draftThreadsByThreadKey:n,logicalProjectDraftThreadKeyByLogicalProjectKey:r,stickyModelSelectionByProvider:i,stickyActiveProvider:a}}function sy(e){if(e.length===0)return[];try{let t=Mn(mv,wv);return!t||t.version!==hv?[]:(t.state.draftsByThreadKey[e]?.attachments??[]).map(e=>e.id)}catch{return[]}}function cy(e){if(e.length===0)return null;try{let t=bv.getItem(mv);if(typeof t!=`string`)return null;let n=Tv(JSON.parse(t));return!n||n.version!==hv?null:n.state.draftsByThreadKey[e]??null}catch{return null}}function ly(e,t,n){let r=new Set;try{bv.flush(),r=new Set(sy(e))}catch{r=new Set}n(n=>{let i=n.draftsByThreadKey[e];if(!i)return n;let a=new Set(i.images.map(e=>e.id)),o=t.filter(e=>a.has(e.id)&&r.has(e.id)),s=i.images.map(e=>e.id).filter(e=>!r.has(e)),c={...i,persistedAttachments:o,nonPersistedImageIds:s},l={...n.draftsByThreadKey};return N(c)?delete l[e]:l[e]=c,{draftsByThreadKey:l}})}function uy(e,t){return e.length>0?e:t?.prompt??``}function dy(e,t){return e?.length?e:t??[]}function fy(e){let t=e.stagedSubmission;return{prompt:uy(e.prompt,t),attachments:dy(e.attachments,t?.attachments),files:dy(e.files,t?.files),terminalContexts:dy(e.terminalContexts,t?.terminalContexts)}}function py(e){let t=e.modelSelectionByProvider??{},n=av(e.activeProvider)??null,r=fy(e);return{prompt:r.prompt,...e.lastGeneratedPullRequestPrompt===void 0?{}:{lastGeneratedPullRequestPrompt:e.lastGeneratedPullRequestPrompt},images:ev(r.attachments),files:r.files.map(e=>({...e,type:`file`,file:null})),nonPersistedImageIds:[],persistedAttachments:[...r.attachments],terminalContexts:r.terminalContexts.map(t=>{let n=e.stashTerminalContexts?.find(e=>e.id===t.id);return Object.assign({},t,{text:n?.text??``})}),...e.stashTerminalContexts&&e.stashTerminalContexts.length>0?{stashTerminalContexts:e.stashTerminalContexts.map(e=>({...e}))}:{},modelSelectionByProvider:t,activeProvider:n,runtimeMode:e.runtimeMode??null,interactionMode:e.interactionMode??null,stagedSubmission:N_(e.stagedSubmission)}}function my(e){return{threadId:e.threadId,environmentId:e.environmentId,projectId:e.projectId,logicalProjectKey:e.logicalProjectKey??Bv(Ln(e.environmentId,e.projectId)),createdAt:e.createdAt,runtimeMode:e.runtimeMode,interactionMode:e.interactionMode,branch:e.branch,worktreePath:e.worktreePath,envMode:e.envMode,promotedTo:e.promotedTo?C(e.promotedTo.environmentId,e.promotedTo.threadId):null,linkedPullRequest:e.linkedPullRequest??null}}var hy=Oa()(Wf((e,t)=>{let n=e;return{draftsByThreadKey:{},draftThreadsByThreadKey:{},logicalProjectDraftThreadKeyByLogicalProjectKey:{},stickyModelSelectionByProvider:{},stickyActiveProvider:null,getComposerDraft:e=>qv(t(),e),getDraftThreadByLogicalProjectKey:e=>t().getDraftSessionByLogicalProjectKey(e),getDraftSessionByLogicalProjectKey:e=>{let n=Vv(e);if(n.length===0)return null;let r=t().logicalProjectDraftThreadKeyByLogicalProjectKey[n];if(!r)return null;let i=t().draftThreadsByThreadKey[r];return!i||Qv(i)?null:Yv(xa.make(r),i)},getDraftThreadByProjectRef:e=>t().getDraftSessionByProjectRef(e),getDraftSessionByProjectRef:e=>{for(let[n,r]of Object.entries(t().draftThreadsByThreadKey))if(!Qv(r)&&r.projectId===e.projectId&&r.environmentId===e.environmentId)return Yv(xa.make(n),r);return null},getDraftSession:e=>t().draftThreadsByThreadKey[e]??null,getDraftSessionByRef:e=>{for(let n of Object.values(t().draftThreadsByThreadKey))if(n.environmentId===e.environmentId&&n.threadId===e.threadId)return n;return null},getDraftThread:e=>typeof e==`string`?t().getDraftSession(xa.make(e)):t().getDraftSessionByRef(e),getDraftThreadByRef:e=>t().getDraftSessionByRef(e),listDraftThreadKeys:()=>Object.values(t().draftThreadsByThreadKey).map(e=>Rn(C(e.environmentId,e.threadId))),hasDraftThreadsInEnvironment:e=>Object.values(t().draftThreadsByThreadKey).some(t=>t.environmentId===e),setLogicalProjectDraftThreadId:(e,t,r,i)=>{let a=Vv(e);a.length!==0&&r.length!==0&&n(e=>{let n=e.draftThreadsByThreadKey[r],o=e.logicalProjectDraftThreadKeyByLogicalProjectKey[a],s=Xv(t,i?.threadId??n?.threadId??Br.make(r),a,n,i);if(o===r&&$v(n,s))return e;let c={...e.logicalProjectDraftThreadKeyByLogicalProjectKey,[a]:r},l={...e.draftThreadsByThreadKey,[r]:s},u=e.draftsByThreadKey,d=o===void 0?void 0:l[o];return o&&o!==r&&!Jv(c,o)&&!Qv(d)&&(delete l[o],e.draftsByThreadKey[o]!==void 0&&(u={...e.draftsByThreadKey},delete u[o])),{draftsByThreadKey:u,draftThreadsByThreadKey:l,logicalProjectDraftThreadKeyByLogicalProjectKey:c}})},setProjectDraftThreadId:(e,n,r)=>{t().setLogicalProjectDraftThreadId(Bv(e),e,n,r)},setDraftThreadContext:(e,r)=>{let i=F(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftThreadsByThreadKey[i];if(!t)return e;let n=r.projectRef??{environmentId:t.environmentId,projectId:t.projectId};if(n.projectId.length===0||n.environmentId.length===0)return e;let a=n.environmentId!==t.environmentId||n.projectId!==t.projectId,o=r.worktreePath===void 0?a?null:t.worktreePath:r.worktreePath??null,s=r.branch===void 0?a?null:t.branch:r.branch??null,c=r.anchorKind===void 0?t.anchorKind:r.anchorKind??void 0,l={threadId:t.threadId,environmentId:n.environmentId,projectId:n.projectId,logicalProjectKey:t.logicalProjectKey,createdAt:r.createdAt===void 0?t.createdAt:r.createdAt||t.createdAt,runtimeMode:r.runtimeMode??t.runtimeMode,interactionMode:r.interactionMode??t.interactionMode,branch:s,worktreePath:o,envMode:r.envMode??(o?`worktree`:a?`local`:t.envMode??`local`),promotedTo:t.promotedTo??null,cmmdTaskId:r.cmmdTaskId===void 0?t.cmmdTaskId??null:r.cmmdTaskId,anchorCmmdId:r.anchorCmmdId===void 0?t.anchorCmmdId??null:r.anchorCmmdId,linkedPullRequest:r.linkedPullRequest===void 0?t.linkedPullRequest??null:r.linkedPullRequest,...c===void 0?{}:{anchorKind:c}};return l.environmentId===t.environmentId&&l.projectId===t.projectId&&l.logicalProjectKey===t.logicalProjectKey&&l.createdAt===t.createdAt&&l.runtimeMode===t.runtimeMode&&l.interactionMode===t.interactionMode&&l.branch===t.branch&&l.worktreePath===t.worktreePath&&l.envMode===t.envMode&&(l.anchorKind??void 0)===(t.anchorKind??void 0)&&(l.anchorCmmdId??null)===(t.anchorCmmdId??null)&&ey(l.linkedPullRequest,t.linkedPullRequest)&&Zv(l.promotedTo,t.promotedTo)?e:{draftThreadsByThreadKey:{...e.draftThreadsByThreadKey,[i]:l}}})},clearProjectDraftThreadId:e=>{n(t=>{let n=Object.entries(t.draftThreadsByThreadKey).find(([,t])=>t.projectId===e.projectId&&t.environmentId===e.environmentId);return n?ty(t,n[0]):t})},clearProjectDraftThreadById:(e,r)=>{let i=F(t(),r)??``;i.length!==0&&n(t=>{let n=t.draftThreadsByThreadKey[i];return!n||n.projectId!==e.projectId||n.environmentId!==e.environmentId?t:ty(t,i)})},markDraftThreadPromoting:(e,r)=>{let i=F(t(),e);i&&n(e=>{let t=e.draftThreadsByThreadKey[i];if(!t)return e;let n=r??C(t.environmentId,t.threadId);return Zv(t.promotedTo,n)?e:{draftThreadsByThreadKey:{...e.draftThreadsByThreadKey,[i]:{...t,promotedTo:n}}}})},finalizePromotedDraftThread:e=>{let r=F(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftThreadsByThreadKey[r];if(!Qv(t))return e;let n=Hv(t.promotedTo),i=e.draftsByThreadKey[n],a=e.draftsByThreadKey[r];return ty(a?{...e,draftsByThreadKey:{...e.draftsByThreadKey,[n]:i?{...i,modelSelectionByProvider:{...i.modelSelectionByProvider,...a.modelSelectionByProvider},activeProvider:a.activeProvider,runtimeMode:a.runtimeMode,interactionMode:a.interactionMode}:a}}:e,r)})},clearDraftThread:e=>{let r=F(t(),e)??``;if(r.length===0)return;let i=t().draftsByThreadKey[r];if(i)for(let e of i.images)G_(e.previewUrl);n(e=>{let t=e.draftThreadsByThreadKey[r]!==void 0,n=Object.values(e.logicalProjectDraftThreadKeyByLogicalProjectKey).includes(r),i=e.draftsByThreadKey[r]!==void 0;return!t&&!n&&!i?e:ty(e,r)})},setStickyModelSelection:e=>{let t=lv(e);n(e=>{if(!t)return e;let n={...e.stickyModelSelectionByProvider,[t.provider]:t};return rt(e.stickyModelSelectionByProvider,n)?e.stickyActiveProvider===t.provider?e:{stickyActiveProvider:t.provider}:{stickyModelSelectionByProvider:n,stickyActiveProvider:t.provider}})},applyStickyState:e=>{let r=F(t(),e)??``;r.length!==0&&n(e=>{let t=e.stickyModelSelectionByProvider,n=e.stickyActiveProvider;if(Object.keys(t).length===0&&n===null)return e;let i=e.draftsByThreadKey[r]??P(),a={...i.modelSelectionByProvider};for(let[e,n]of Object.entries(t))if(n){let t=a[e];a[e]={...n,model:t?.model??n.model}}if(rt(i.modelSelectionByProvider,a)&&i.activeProvider===n)return e;let o={...i,modelSelectionByProvider:a,activeProvider:n},s={...e.draftsByThreadKey};return N(o)?delete s[r]:s[r]=o,{draftsByThreadKey:s}})},setPrompt:(e,r)=>{let i=F(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??P();if(t.prompt===r)return e;let n={...t,prompt:r},a={...e.draftsByThreadKey};return N(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},setGeneratedPullRequestPrompt:(e,r)=>{let i=F(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??P();return{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,lastGeneratedPullRequestPrompt:r}}}})},setPendingAutoSubmit:(e,r)=>{let i=F(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??P();if((t.pendingAutoSubmit??!1)===r)return e;let n=r?{...t,pendingAutoSubmit:!0}:(()=>{let{pendingAutoSubmit:e,...n}=t;return n})(),a={...e.draftsByThreadKey};return N(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},stageComposerSubmission:(e,r,i,a,o,s,c)=>{let l=F(t(),e)??``;l.length!==0&&(n(e=>{let t=e.draftsByThreadKey[l];if(!t)return e;let n={prompt:t.prompt,attachments:[...c??t.persistedAttachments],files:(t.files??[]).map(({file:e,type:t,...n})=>n),terminalContexts:[...t.terminalContexts],startedAt:r,commandId:i,messageId:a,...o?{executionIntent:o}:{},...s},u={...e.draftsByThreadKey};return u[l]={...t,stagedSubmission:n},{draftsByThreadKey:u}}),bv.flush())},setStagedComposerExecutionIntent:(e,r)=>{let i=F(t(),e)??``;i.length!==0&&(n(e=>{let t=e.draftsByThreadKey[i];return t?.stagedSubmission?{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,stagedSubmission:{...t.stagedSubmission,executionIntent:r}}}}:e}),bv.flush())},clearStagedComposerSubmission:e=>{let r=F(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t?.stagedSubmission)return e;let n={...t,stagedSubmission:null},i={...e.draftsByThreadKey};return N(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},setTerminalContexts:(e,r,i)=>{let a=F(t(),e),o=Kv(t(),e);if(!a||!o)return;let s=z_(o,r);n(e=>{let t=e.draftsByThreadKey[a]??P(),n={...t,prompt:Wm(t.prompt,s.length),terminalContexts:s,...i?.preserveTextForReload?{stashTerminalContexts:s}:{stashTerminalContexts:[]}},r={...e.draftsByThreadKey};return N(n)?delete r[a]:r[a]=n,{draftsByThreadKey:r}})},setModelSelection:(e,r)=>{let i=F(t(),e)??``;if(i.length===0)return;let a=lv(r);n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??P(),r={...n.modelSelectionByProvider};if(a){let e=r[a.provider];a.options===void 0?r[a.provider]={provider:a.provider,model:a.model,...`providerAccountId`in a&&a.providerAccountId?{providerAccountId:a.providerAccountId}:e&&`providerAccountId`in e&&e.providerAccountId?{providerAccountId:e.providerAccountId}:{},...e?.options?{options:e.options}:{}}:r[a.provider]=a}let o=a?.provider??n.activeProvider;if(rt(n.modelSelectionByProvider,r)&&n.activeProvider===o)return e;let s={...n,modelSelectionByProvider:r,activeProvider:o},c={...e.draftsByThreadKey};return N(s)?delete c[i]:c[i]=s,{draftsByThreadKey:c}})},setModelOptions:(e,r)=>{let i=F(t(),e)??``;if(i.length===0)return;let a=cv(r);n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??P(),r={...n.modelSelectionByProvider};for(let e of[`codex`,`claudeAgent`]){if(!a||!(e in a))continue;let t=a[e],n=r[e];if(t)r[e]={provider:e,model:n?.model??Ii[e],...n&&`providerAccountId`in n&&n.providerAccountId?{providerAccountId:n.providerAccountId}:{},options:t};else if(n?.options){let{options:t,...i}=n;r[e]=i}}if(rt(n.modelSelectionByProvider,r))return e;let o={...n,modelSelectionByProvider:r},s={...e.draftsByThreadKey};return N(o)?delete s[i]:s[i]=o,{draftsByThreadKey:s}})},setProviderModelOptions:(e,r,i,a)=>{let o=F(t(),e)??``;if(o.length===0)return;let s=av(r);if(s===null)return;let c=cv({[s]:i},s)?.[s];n(e=>{let t=e.draftsByThreadKey[o]??P(),n={...t.modelSelectionByProvider},r=n[s];if(c)n[s]={provider:s,model:r?.model??Ii[s],...r&&`providerAccountId`in r&&r.providerAccountId?{providerAccountId:r.providerAccountId}:{},options:c};else if(r?.options){let{options:e,...t}=r;n[s]=t}let i=e.stickyModelSelectionByProvider,l=e.stickyActiveProvider;if(a?.persistSticky===!0){i={...e.stickyModelSelectionByProvider};let n=i[s]??t.modelSelectionByProvider[s]??{provider:s,model:Ii[s]};if(c)i[s]={...n,provider:s,options:c};else if(n.options){let{options:e,...t}=n;i[s]=t}l=t.activeProvider??s}if(rt(t.modelSelectionByProvider,n)&&rt(e.stickyModelSelectionByProvider,i)&&e.stickyActiveProvider===l)return e;let u={...t,modelSelectionByProvider:n},d={...e.draftsByThreadKey};return N(u)?delete d[o]:d[o]=u,{draftsByThreadKey:d,...a?.persistSticky===!0?{stickyModelSelectionByProvider:i,stickyActiveProvider:l}:{}}})},setRuntimeMode:(e,r)=>{let i=F(t(),e)??``;if(i.length===0)return;let a=_v(r)?r:null;n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??P();if(n.runtimeMode===a)return e;let r={...n,runtimeMode:a},o={...e.draftsByThreadKey};return N(r)?delete o[i]:o[i]=r,{draftsByThreadKey:o}})},setInteractionMode:(e,r)=>{let i=F(t(),e)??``;if(i.length===0)return;let a=r===`plan`||r==="default"?r:null;n(e=>{let t=e.draftsByThreadKey[i];if(!t&&a===null)return e;let n=t??P();if(n.interactionMode===a)return e;let r={...n,interactionMode:a},o={...e.draftsByThreadKey};return N(r)?delete o[i]:o[i]=r,{draftsByThreadKey:o}})},addImage:(e,n)=>{let r=F(t(),e),i=Kv(t(),e);!r||!i||t().addImages(typeof e==`string`?xa.make(r):e,[n])},addImages:(e,r)=>{let i=F(t(),e)??``;i.length!==0&&r.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??P(),n=new Set(t.images.map(e=>e.id)),a=new Set(t.images.map(e=>I_(e))),o=new Set(t.images.map(e=>e.previewUrl)),s=[];for(let e of r){let t=I_(e);if(n.has(e.id)||a.has(t)){o.has(e.previewUrl)||G_(e.previewUrl);continue}s.push(e),n.add(e.id),a.add(t),o.add(e.previewUrl)}return s.length===0?e:{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,images:[...t.images,...s]}}}})},addFiles:(e,r)=>{let i=F(t(),e)??``;i.length!==0&&r.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??P(),n=new Set((t.files??[]).map(e=>e.id)),a=Math.max(0,8-t.images.length-(t.files?.length??0)),o=r.filter(e=>!n.has(e.id)).slice(0,a);return o.length===0?e:{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,files:[...t.files??[],...o]}}}})},setFiles:(e,r)=>{let i=F(t(),e)??``;i.length!==0&&n(e=>{let t=e.draftsByThreadKey[i]??P();return{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,files:[...r]}}}})},removeImage:(e,r)=>{let i=F(t(),e)??``;if(i.length===0)return;let a=t().draftsByThreadKey[i];if(!a)return;let o=a.images.find(e=>e.id===r);o&&G_(o.previewUrl),n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={...t,images:t.images.filter(e=>e.id!==r),nonPersistedImageIds:t.nonPersistedImageIds.filter(e=>e!==r),persistedAttachments:t.persistedAttachments.filter(e=>e.id!==r)},a={...e.draftsByThreadKey};return N(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},insertTerminalContext:(e,r,i,a)=>{let o=F(t(),e),s=Kv(t(),e);if(!o||!s)return!1;let c=!1;return n(e=>{let t=e.draftsByThreadKey[o]??P(),n=R_(s,i);if(!n)return e;let l=L_(n);if(t.terminalContexts.some(e=>e.id===n.id)||t.terminalContexts.some(e=>L_(e)===l))return e;c=!0;let u=Math.max(0,Math.min(t.terminalContexts.length,a)),d={...t,prompt:r,terminalContexts:[...t.terminalContexts.slice(0,u),n,...t.terminalContexts.slice(u)]};return{draftsByThreadKey:{...e.draftsByThreadKey,[o]:d}}}),c},addTerminalContext:(e,n)=>{let r=F(t(),e),i=Kv(t(),e);!r||!i||t().addTerminalContexts(typeof e==`string`?xa.make(r):e,[n])},addTerminalContexts:(e,r)=>{let i=F(t(),e),a=Kv(t(),e);!i||!a||r.length===0||n(e=>{let t=e.draftsByThreadKey[i]??P(),n=z_(a,[...t.terminalContexts,...r]).slice(t.terminalContexts.length);return n.length===0?e:{draftsByThreadKey:{...e.draftsByThreadKey,[i]:{...t,prompt:Wm(t.prompt,t.terminalContexts.length+n.length),terminalContexts:[...t.terminalContexts,...n]}}}})},removeTerminalContext:(e,r)=>{let i=F(t(),e)??``;i.length!==0&&r.length!==0&&n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={...t,terminalContexts:t.terminalContexts.filter(e=>e.id!==r)},a={...e.draftsByThreadKey};return N(n)?delete a[i]:a[i]=n,{draftsByThreadKey:a}})},clearTerminalContexts:e=>{let r=F(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t||t.terminalContexts.length===0)return e;let n={...t,terminalContexts:[]},i={...e.draftsByThreadKey};return N(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},clearPersistedAttachments:e=>{let r=F(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t)return e;let n={...t,persistedAttachments:[],nonPersistedImageIds:[]},i={...e.draftsByThreadKey};return N(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},syncPersistedAttachments:(e,r)=>{let i=F(t(),e);if(!i)return;let a=new Set(r.map(e=>e.id));n(e=>{let t=e.draftsByThreadKey[i];if(!t)return e;let n={...t,persistedAttachments:r,nonPersistedImageIds:t.nonPersistedImageIds.filter(e=>!a.has(e))},o={...e.draftsByThreadKey};return N(n)?delete o[i]:o[i]=n,{draftsByThreadKey:o}}),Promise.resolve().then(()=>{ly(i,r,n)})},moveComposerDraft:(e,r)=>{let i=dm(t().draftsByThreadKey,e,r);return i!==null&&(n({draftsByThreadKey:i}),bv.flush(),!0)},clearComposerContent:e=>{let r=F(t(),e)??``;r.length!==0&&n(e=>{let t=e.draftsByThreadKey[r];if(!t)return e;let n=iv(t),i={...e.draftsByThreadKey};return N(n)?delete i[r]:i[r]=n,{draftsByThreadKey:i}})},clearComposerContentIfUnchanged:(e,r)=>{let i=F(t(),e)??``;if(i.length===0)return!1;let a=!1;return n(e=>{let t=e.draftsByThreadKey[i];if(!t||!rv(t,r))return e;let n=iv(t),o={...e.draftsByThreadKey};return N(n)?delete o[i]:o[i]=n,a=!0,{draftsByThreadKey:o}}),a},restoreComposerStash:(e,r)=>{let i=F(t(),e)??``,a=Kv(t(),e);if(i.length===0||!a)return!1;let o,s;if(n(e=>{let t=P_(e.draftsByThreadKey,i,a,r);return t?(o=t.previousDraft,s=t.restoredDraft,{draftsByThreadKey:t.drafts}):e}),!s)return!1;let c=!1;try{bv.flush();let e=cy(i),n=t().draftsByThreadKey[i];e!==null&&n===s&&W_(e,n)&&(c=!0)}catch{}if(c&&(r.onPersisted?.()??!0))return!0;n(e=>{if(e.draftsByThreadKey[i]!==s)return e;let t={...e.draftsByThreadKey};return o?t[i]=o:delete t[i],{draftsByThreadKey:t}});try{bv.flush()}catch{}return!1}}},{name:mv,version:hv,storage:Hf(()=>bv),migrate:iy,partialize:ay,merge:(e,t)=>{let n=oy(e),r=Object.fromEntries(Object.entries(n.draftsByThreadKey).map(([e,t])=>[e,py(t)])),i=Object.fromEntries(Object.entries(n.draftThreadsByThreadKey).map(([e,t])=>[e,my(t)]));return{...t,draftsByThreadKey:r,draftThreadsByThreadKey:i,logicalProjectDraftThreadKeyByLogicalProjectKey:n.logicalProjectDraftThreadKeyByLogicalProjectKey,stickyModelSelectionByProvider:n.stickyModelSelectionByProvider??{},stickyActiveProvider:n.stickyActiveProvider??null}}}));function gy(e){let t=(0,A.c)(2),n;return t[0]===e?n=t[1]:(n=t=>qv(t,e)??Lv,t[0]=e,t[1]=n),hy(n)}function _y(e){let t=(0,A.c)(2),n;return t[0]===e?n=t[1]:(n=t=>{let n=qv(t,e);return n?{activeProvider:n.activeProvider,modelSelectionByProvider:n.modelSelectionByProvider}:Iv},t[0]=e,t[1]=n),hy(eh(n))}function vy(e){let t=hy.getState();for(let[n,r]of Object.entries(t.draftThreadsByThreadKey))r.environmentId===e.environmentId&&r.threadId===e.threadId&&t.markDraftThreadPromoting(xa.make(n),e)}function yy(e){for(let t of e)vy(t)}function by(e){let t=hy.getState();for(let[n,r]of Object.entries(t.draftThreadsByThreadKey))r.promotedTo&&r.promotedTo.environmentId===e.environmentId&&r.promotedTo.threadId===e.threadId&&t.finalizePromotedDraftThread(xa.make(n))}var xy=null;function Sy(e){xy=e}function Cy(){if(xy===null)throw Error(`Environment event handling was used before the service was configured.`);return xy}function wy(e){let t=new Set,n=new Map(e.snapshotThreads.map(e=>[e.key,e]));for(let n of e.snapshotThreads)n.deletedAt===null&&n.archivedAt===null&&t.add(n.key);for(let r of e.draftThreadKeys){let e=n.get(r);e&&(e.deletedAt!==null||e.archivedAt!==null)||t.add(r)}return t}function Ty(e){let t=new Map,n=!1;for(let r of e)switch(r.type){case`thread.turn-diff-completed`:case`thread.reverted`:n=!0;break;case`thread.created`:t.set(r.payload.threadId,{clearPromotedDraft:!0,clearDeletedThread:!1,removeTerminalState:!1});break;case`thread.deleted`:t.set(r.payload.threadId,{clearPromotedDraft:!1,clearDeletedThread:!0,removeTerminalState:!0});break;case`thread.archived`:t.set(r.payload.threadId,{clearPromotedDraft:!1,clearDeletedThread:!1,removeTerminalState:!0});break;case`thread.unarchived`:t.set(r.payload.threadId,{clearPromotedDraft:!1,clearDeletedThread:!1,removeTerminalState:!1})}let r=[],i=[],a=[];for(let[e,n]of t)n.clearPromotedDraft&&r.push(e),n.clearDeletedThread&&i.push(e),n.removeTerminalState&&a.push(e);return{promoteDraftThreadIds:r,clearDeletedThreadIds:i,removeTerminalStateThreadIds:a,needsProviderInvalidation:n}}var Ey={threadRef:null,open:!1,minimized:!1,dock:`floating`,position:null};function Dy(e){return{x:Math.max(12,Math.min(e.position.x,e.viewportWidth-e.width-12)),y:Math.max(12,Math.min(e.position.y,e.viewportHeight-e.height-12))}}function Oy(e,t){return{...e,threadRef:t,open:!0,minimized:!1}}function ky(e){let t=e.companion.threadRef;return!e.companion.open||t===null?!1:e.routeThreadRef?.environmentId!==t.environmentId||e.routeThreadRef.threadId!==t.threadId}var Ay=`forge:ui-state:v1`,jy=[`t3code:ui-state:v1`,`t3code:renderer-state:v8`,`t3code:renderer-state:v7`,`t3code:renderer-state:v6`,`t3code:renderer-state:v5`,`t3code:renderer-state:v4`,`t3code:renderer-state:v3`,`codething:renderer-state:v4`,`codething:renderer-state:v3`,`codething:renderer-state:v2`,`codething:renderer-state:v1`],My=`months`,Ny=new Set([`weeks`,`months`,`quarters`]);function Py(e){return typeof e==`string`&&Ny.has(e)?e:My}function Fy(e){return Number.isFinite(e)?Math.round(Math.min(560,Math.max(200,e))):360}var Iy={projectExpandedById:{},projectOrder:[],projectGroupOrder:[],lastActiveProject:null,threadLastVisitedAtById:{},threadChangedFilesExpandedById:{},pinnedThreadById:{},threadLinkedPrById:{},workspaceDensityById:{},timelineWorkColumnWidth:360,timelineScale:My,projectLeadCompanion:Ey},Ly=new Set,Ry=[],zy=new Map,By=!1;function Vy(){if(typeof window>`u`)return Iy;try{let e=window.localStorage.getItem(Ay);if(!e){for(let e of jy){let t=window.localStorage.getItem(e);if(t)return Ky(JSON.parse(t)),Iy}return Iy}let t=JSON.parse(e);return Ky(t),{...Iy,projectGroupOrder:Hy(t.projectGroupOrderKeys),threadChangedFilesExpandedById:Gy(t.threadChangedFilesExpandedById),pinnedThreadById:Uy(t.pinnedThreadKeys),threadLinkedPrById:Wy(t.threadLinkedPrById),timelineWorkColumnWidth:Fy(t.timelineWorkColumnWidth??360),timelineScale:Py(t.timelineScale)}}catch{return Iy}}function Hy(e){return Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`&&e.length>0))]:[]}function Uy(e){if(!Array.isArray(e))return{};let t={};for(let n of e)typeof n==`string`&&n.length>0&&(t[n]=!0);return t}function Wy(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e))typeof n==`string`&&n.length!==0&&typeof r==`string`&&r.trim().length!==0&&(t[n]=r);return t}function Gy(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e)){if(!n||!r||typeof r!=`object`)continue;let e={};for(let[t,n]of Object.entries(r))t&&typeof n==`boolean`&&n===!1&&(e[t]=!1);Object.keys(e).length>0&&(t[n]=e)}return t}function Ky(e){Ly.clear(),Ry.length=0;for(let t of e.expandedProjectCwds??[])typeof t==`string`&&t.length>0&&Ly.add(t);for(let t of e.projectOrderCwds??[])typeof t==`string`&&t.length>0&&!Ry.includes(t)&&Ry.push(t)}function qy(e){if(!(typeof window>`u`))try{let t=Object.entries(e.projectExpandedById).filter(([,e])=>e).flatMap(([e])=>{let t=zy.get(e);return t?[t]:[]}),n=e.projectOrder.flatMap(e=>{let t=zy.get(e);return t?[t]:[]}),r=Object.fromEntries(Object.entries(e.threadChangedFilesExpandedById).flatMap(([e,t])=>{let n=Object.fromEntries(Object.entries(t).filter(([,e])=>e===!1));return Object.keys(n).length>0?[[e,n]]:[]}));if(window.localStorage.setItem(Ay,JSON.stringify({expandedProjectCwds:t,projectOrderCwds:n,projectGroupOrderKeys:e.projectGroupOrder,threadChangedFilesExpandedById:r,pinnedThreadKeys:Object.keys(e.pinnedThreadById).filter(t=>e.pinnedThreadById[t]),threadLinkedPrById:e.threadLinkedPrById,timelineWorkColumnWidth:e.timelineWorkColumnWidth,timelineScale:e.timelineScale})),!By){By=!0;for(let e of jy)window.localStorage.removeItem(e)}}catch{}}var Jy=new Aa(qy,{wait:500});function Yy(e,t){let n=Object.entries(e),r=Object.entries(t);if(n.length!==r.length)return!1;for(let[e,r]of n)if(t[e]!==r)return!1;return!0}function Xy(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Zy(e,t){let n=Object.entries(e),r=Object.entries(t);if(n.length!==r.length)return!1;for(let[e,r]of n)if(!(e in t)||!Yy(r,t[e]))return!1;return!0}function Qy(e,t){let n=new Map(zy),r=new Map([...n.entries()].map(([e,t])=>[t,e]));zy.clear();for(let e of t)zy.set(e.key,e.cwd);let i=n.size!==zy.size||t.some(e=>n.get(e.key)!==e.cwd),a={},o=e.projectExpandedById,s=new Map(Ry.map((e,t)=>[e,t])),c=t.map((e,t)=>{let n=r.get(e.cwd),i=o[e.key]??(n?o[n]:void 0)??(Ly.size>0?Ly.has(e.cwd):!0);return a[e.key]=i,{id:e.key,cwd:e.cwd,incomingIndex:t}}),l=e.projectOrder.length>0?(()=>{let t=new Map(c.map(e=>[e.cwd,e.id])),r=new Set,i=[];for(let o of e.projectOrder){let e=(o in a?o:void 0)??(()=>{let e=n.get(o);return e?t.get(e):void 0})();!e||r.has(e)||(r.add(e),i.push(e))}for(let e of c)r.has(e.id)||i.push(e.id);return i})():c.map(e=>({id:e.id,incomingIndex:e.incomingIndex,orderIndex:s.get(e.cwd)??Ry.length+e.incomingIndex})).toSorted((e,t)=>{let n=e.orderIndex-t.orderIndex;return n===0?e.incomingIndex-t.incomingIndex:n}).map(e=>e.id);return Yy(e.projectExpandedById,a)&&Xy(e.projectOrder,l)&&!i?e:{...e,projectExpandedById:a,projectOrder:l}}function $y(e,t){let n=new Set(t.map(e=>e.key)),r=Object.fromEntries(Object.entries(e.threadLastVisitedAtById).filter(([e])=>n.has(e)));for(let e of t)r[e.key]===void 0&&e.seedVisitedAt!==void 0&&e.seedVisitedAt.length>0&&(r[e.key]=e.seedVisitedAt);let i=Object.fromEntries(Object.entries(e.threadChangedFilesExpandedById).filter(([e])=>n.has(e))),a=Object.fromEntries(Object.entries(e.pinnedThreadById).filter(([e,t])=>n.has(e)&&t)),o=Object.fromEntries(Object.entries(e.threadLinkedPrById).filter(([e])=>n.has(e)));return Yy(e.threadLastVisitedAtById,r)&&Zy(e.threadChangedFilesExpandedById,i)&&Yy(e.pinnedThreadById,a)&&Yy(e.threadLinkedPrById,o)?e:{...e,threadLastVisitedAtById:r,threadChangedFilesExpandedById:i,pinnedThreadById:a,threadLinkedPrById:o}}function eb(e,t,n){let r=n??new Date().toISOString(),i=Date.parse(r),a=e.threadLastVisitedAtById[t],o=a?Date.parse(a):NaN;return Number.isFinite(o)&&Number.isFinite(i)&&o>=i?e:{...e,threadLastVisitedAtById:{...e.threadLastVisitedAtById,[t]:r}}}function tb(e,t,n){if(!n)return e;let r=Date.parse(n);if(Number.isNaN(r))return e;let i=new Date(r-1).toISOString();return e.threadLastVisitedAtById[t]===i?e:{...e,threadLastVisitedAtById:{...e.threadLastVisitedAtById,[t]:i}}}function nb(e,t){let n=t in e.threadLastVisitedAtById,r=t in e.threadChangedFilesExpandedById,i=t in e.pinnedThreadById,a=t in e.threadLinkedPrById;if(!n&&!r&&!i&&!a)return e;let o={...e.threadLastVisitedAtById},s={...e.threadChangedFilesExpandedById},c={...e.pinnedThreadById},l={...e.threadLinkedPrById};return delete o[t],delete s[t],delete c[t],delete l[t],{...e,threadLastVisitedAtById:o,threadChangedFilesExpandedById:s,pinnedThreadById:c,threadLinkedPrById:l}}function rb(e,t,n){if(e.pinnedThreadById[t]===!0===n)return e;if(n)return{...e,pinnedThreadById:{...e.pinnedThreadById,[t]:!0}};let r={...e.pinnedThreadById};return delete r[t],{...e,pinnedThreadById:r}}function ib(e,t){return rb(e,t,e.pinnedThreadById[t]!==!0)}function ab(e,t,n){return e.threadLinkedPrById[t]===n?e:{...e,threadLinkedPrById:{...e.threadLinkedPrById,[t]:n}}}function ob(e,t){if(!(t in e.threadLinkedPrById))return e;let n={...e.threadLinkedPrById};return delete n[t],{...e,threadLinkedPrById:n}}function sb(e,t,n,r){let i=e.threadChangedFilesExpandedById[t]??{};return i[n]===r?e:{...e,threadChangedFilesExpandedById:{...e.threadChangedFilesExpandedById,[t]:{...i,[n]:r}}}}function cb(e,t){return e.lastActiveProject?.environmentId===t?.environmentId&&e.lastActiveProject?.projectId===t?.projectId?e:{...e,lastActiveProject:t}}function lb(e,t,n){return e.workspaceDensityById[t]===n?e:{...e,workspaceDensityById:{...e.workspaceDensityById,[t]:n}}}function ub(e,t){let n=e.projectExpandedById[t]??!0;return{...e,projectExpandedById:{...e.projectExpandedById,[t]:!n}}}function db(e,t,n){return(e.projectExpandedById[t]??!0)===n?e:{...e,projectExpandedById:{...e.projectExpandedById,[t]:n}}}function fb(e,t,n){if(t.length===0)return e;let r=new Set(t),i=new Set(n);if(t.every(e=>i.has(e)))return e;let a=e.projectOrder.findIndex(e=>i.has(e));if(a<0)return e;let o=[...e.projectOrder],s=[],c=0;for(let e=o.length-1;e>=0;e--)r.has(o[e])&&(s.unshift(o.splice(e,1)[0]),e<a&&c++);if(s.length===0)return e;let l=a-Math.max(0,c-1);return o.splice(l,0,...s),{...e,projectOrder:o}}function pb(e,t){let n=[...new Set(t)],r=new Set(n),i=e.projectGroupOrder.filter(e=>r.has(e)),a=new Set(i);for(let e of n)a.has(e)||i.push(e);return Xy(e.projectGroupOrder,i)?e:{...e,projectGroupOrder:i}}function mb(e,t,n){if(t===n)return e;let r=e.projectGroupOrder.indexOf(t),i=e.projectGroupOrder.indexOf(n);if(r<0||i<0)return e;let a=[...e.projectGroupOrder],[o]=a.splice(r,1);return o===void 0?e:(a.splice(i,0,o),{...e,projectGroupOrder:a})}var hb=Oa(e=>({...Vy(),syncProjects:t=>e(e=>Qy(e,t)),syncProjectGroups:t=>e(e=>pb(e,t)),syncThreads:t=>e(e=>$y(e,t)),markThreadVisited:(t,n)=>e(e=>eb(e,t,n)),markThreadUnread:(t,n)=>e(e=>tb(e,t,n)),clearThreadUi:t=>e(e=>nb(e,t)),setThreadPinned:(t,n)=>e(e=>rb(e,t,n)),toggleThreadPinned:t=>e(e=>ib(e,t)),setThreadLinkedPr:(t,n)=>e(e=>ab(e,t,n)),clearThreadLinkedPr:t=>e(e=>ob(e,t)),setThreadChangedFilesExpanded:(t,n,r)=>e(e=>sb(e,t,n,r)),setWorkspaceDensity:(t,n)=>e(e=>lb(e,t,n)),toggleProject:t=>e(e=>ub(e,t)),setProjectExpanded:(t,n)=>e(e=>db(e,t,n)),reorderProjects:(t,n)=>e(e=>fb(e,t,n)),reorderProjectGroups:(t,n)=>e(e=>mb(e,t,n)),setLastActiveProject:t=>e(e=>cb(e,t)),setTimelineWorkColumnWidth:t=>e(e=>({...e,timelineWorkColumnWidth:Fy(t)})),setTimelineScale:t=>e(e=>({...e,timelineScale:t})),openProjectLeadCompanion:t=>e(e=>({...e,projectLeadCompanion:Oy(e.projectLeadCompanion,t)})),closeProjectLeadCompanion:()=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,open:!1}})),setProjectLeadCompanionMinimized:t=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,minimized:t}})),setProjectLeadCompanionDock:t=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,dock:t}})),setProjectLeadCompanionPosition:t=>e(e=>({...e,projectLeadCompanion:{...e.projectLeadCompanion,position:t}}))}));function gb(e){hb.getState().openProjectLeadCompanion(e)}hb.subscribe(e=>Jy.maybeExecute(e)),typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`beforeunload`,()=>{Jy.flush()});var I=new Map;function _b(e){return!e.isWorking||e.msSinceLastEvent<e.stallThresholdMs?`none`:e.recoveryAttempts<e.maxResubscribeAttempts?`resubscribe`:e.recoveryAttempts<e.maxTotalAttempts?`reconnect`:`none`}var vb=3e4,yb=1e4,bb=[/(?:^|\s)\/(?:Users|var|private|tmp|project|repo|home)\/[^\s'"<>)]*/i,/(?:^|\s)[A-Za-z]:\\[^\s'"<>)]*/];function xb(e){let t=e?.trim();return t&&t.length>0?t:null}function Sb(e){return xb(e)??`Project`}function Cb(e,t=`safe`){let n=xb(e);return n?t===`full`?n:n.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)??`Local checkout`:`Local checkout`}function wb(e,t=`Something went wrong. Try again.`){let n=e instanceof Error?e.message:typeof e==`string`?e:String(e),r=fr(n,{fallback:t});return!r||bb.some(e=>e.test(r))?t:r}var Tb=`Thread not found or you no longer have access.`;function Eb(e){if(e==null)return Tb;let t=wb(qt(e)?ke(e):e,Tb);return/\bnot found\b/i.test(t)?Tb:t}function Db(e,t,n){S.getState().setThreadSubscriptionError(e,t,Eb(n))}var Ob=null;function kb(e){Ob=e}function Ab(){if(Ob===null)throw Error(`Thread detail subscriptions were used before the service was configured.`);return Ob}var jb=9e5,Mb=()=>void 0;function Nb(e,t){return Rn(C(e,t))}function Pb(e){return e.evictionTimeoutId!==null&&(clearTimeout(e.evictionTimeoutId),e.evictionTimeoutId=null),e}function Fb(e){let t=C(e.environmentId,e.threadId),n=S.getState(),r=En(n,t);if(r&&Lb(r))return!0;let i=Cn(n,t);return i?Ib(i.session?.orchestrationStatus)||i.latestTurn?.state===`running`||i.pendingSourceProposedPlan!==void 0:!1}function Ib(e){return!!(e&&e!==`idle`&&e!==`stopped`)}function Lb(e){return e.hasPendingApprovals||e.hasPendingUserInput||e.hasActionableProposedPlan||Ib(e.session?.orchestrationStatus)||e.latestTurn?.state===`running`}function Rb(e){return e.refCount===0&&!Fb(e)}function zb(e){let t=Ab().readConnection(e.environmentId);return e.unsubscribe===Mb&&!t?!1:(e.unsubscribeConnectionListener!==null&&(e.unsubscribeConnectionListener(),e.unsubscribeConnectionListener=null),e.unsubscribe!==Mb||!t||(e.unsubscribe=t.client.orchestration.subscribeThread({threadId:e.threadId},t=>{e.lastEventAt=Date.now(),e.recoveryAttempts=0,t.kind===`event`?Ab().applyEvent(t.event,e.environmentId):t.kind===`snapshot`&&(S.getState().syncServerThreadDetail(t.snapshot.thread,e.environmentId),S.getState().clearThreadSubscriptionError(e.environmentId,e.threadId))},{onError:t=>Db(e.environmentId,e.threadId,t)})),!0)}function Bb(e){e.unsubscribeConnectionListener===null&&(e.unsubscribeConnectionListener=Ab().subscribeConnections(()=>{zb(e)&&(e.lastAccessedAt=Date.now())}),zb(e))}var Vb=null;function Hb(e){let t=C(e.environmentId,e.threadId),n=S.getState(),r=En(n,t);if(r?.latestTurn?.state===`running`||r?.session?.orchestrationStatus===`running`)return!0;let i=Cn(n,t);return i?.latestTurn?.state===`running`||i?.session?.orchestrationStatus===`running`}function Ub(e){e.unsubscribe!==Mb&&(e.unsubscribe(),e.unsubscribe=Mb),zb(e)||Bb(e)}function Wb(e,t,n){if(e.recoveryAttempts+=1,e.lastEventAt=Date.now(),console.warn(`[forge] thread-detail liveness watchdog recovering`,{action:t,threadId:String(e.threadId),environmentId:String(e.environmentId),msSinceLastEvent:Math.round(n),recoveryAttempts:e.recoveryAttempts}),t===`resubscribe`){Ub(e);return}Ab().readConnection(e.environmentId)?.reconnect().catch(t=>{Hn(t,{route:`thread-detail-liveness-watchdog-reconnect-failed`,threadId:String(e.threadId),environmentId:String(e.environmentId),msSinceLastEvent:String(Math.round(n)),recoveryAttempts:String(e.recoveryAttempts)})})}function Gb(){let e=Date.now();for(let t of I.values()){let n=_b({isWorking:Hb(t),msSinceLastEvent:e-t.lastEventAt,stallThresholdMs:vb,recoveryAttempts:t.recoveryAttempts,maxResubscribeAttempts:2,maxTotalAttempts:4});n!==`none`&&Wb(t,n,e-t.lastEventAt)}}function Kb(){Vb===null&&(Vb=setInterval(Gb,yb))}function qb(){I.size>0||Vb!==null&&(clearInterval(Vb),Vb=null)}function Jb(e){let t=I.get(e);return t?(Pb(t),t.unsubscribeConnectionListener?.(),t.unsubscribeConnectionListener=null,I.delete(e),t.unsubscribe(),t.unsubscribe=Mb,qb(),!0):!1}function Yb(e){Xb(e,!0),j.getState().clear(e)}function Xb(e,t=!1){for(let[n,r]of I)if(r.environmentId===e){if(r.refCount===0||t){Jb(n);continue}r.unsubscribe(),r.unsubscribe=Mb,Bb(r)}}function Zb(e){for(let t=e.messages.length-1;t>=0;--t){let n=e.messages[t];if(n?.role===`user`)return n.createdAt}return null}function Qb(e){return e.session?{threadId:e.id,updatedAt:e.session.updatedAt,providerName:e.session.provider,runtimeMode:e.runtimeMode,activeTurnId:e.session.activeTurnId??null,lastError:e.session.lastError??null,status:e.session.orchestrationStatus}:null}function $b(e,t){return{updatedAt:e.updatedAt??e.createdAt,latestUserMessageAt:t?.latestUserMessageAt??Zb(e),titleRegeneration:e.titleRegeneration??null}}function ex(e){return{hasPendingApprovals:e?.hasPendingApprovals??!1,hasPendingUserInput:e?.hasPendingUserInput??!1,hasActionableProposedPlan:e?.hasActionableProposedPlan??!1}}function tx(e){let t=C(e.environmentId,e.threadId),n=S.getState(),r=Cn(n,t);if(!r)return null;let i=En(n,t);return{id:r.id,projectId:r.projectId,title:r.title,modelSelection:r.modelSelection,runtimeMode:r.runtimeMode,interactionMode:r.interactionMode,branch:r.branch,worktreePath:r.worktreePath,latestTurn:r.latestTurn,createdAt:r.createdAt,...$b(r,i),...ex(i),archivedAt:r.archivedAt,session:Qb(r),anchorKind:r.anchorKind,anchorCmmdId:r.anchorCmmdId,kind:r.kind,parentThreadId:r.parentThreadId,status:r.status,workerRole:r.workerRole,goal:r.goal}}function nx(e,t){if(I.size===0)return e;let n=new Set(e.threads.map(e=>e.id)),r=[];for(let e of I.values()){if(e.environmentId!==t||e.refCount<=0||n.has(e.threadId))continue;let i=tx(e);i&&(n.add(i.id),r.push(i))}return r.length===0?e:{...e,threads:[...e.threads,...r]}}function rx(e,t){let n=new Set(t);for(let[t,r]of I)r.environmentId===e&&!n.has(r.threadId)&&Rb(r)&&Jb(t)}function ix(e){Pb(e),Rb(e)&&(e.evictionTimeoutId=setTimeout(()=>{let t=I.get(Nb(e.environmentId,e.threadId));t&&(t.evictionTimeoutId=null,Rb(t)&&Jb(Nb(e.environmentId,e.threadId)))},jb))}function ax(){if(I.size<=32)return;let e=[...I.entries()].filter(([,e])=>Rb(e)).toSorted(([,e],[,t])=>e.lastAccessedAt-t.lastAccessedAt);for(let[t]of e){if(I.size<=32)return;Jb(t)}}function ox(e){Pb(e),Rb(e)&&ix(e)}function sx(e,t){let n=I.get(Nb(e,t));n&&ox(n)}function cx(e){for(let t of I.values())t.environmentId===e&&ox(t);ax()}function lx(e){let t=!1;return()=>{t||(t=!0,e.refCount=Math.max(0,e.refCount-1),e.lastAccessedAt=Date.now(),e.refCount===0&&(ox(e),ax()))}}function ux(e,t){let n=Nb(e,t),r=I.get(n);if(r)return Pb(r),r.refCount+=1,r.lastAccessedAt=Date.now(),zb(r)||Bb(r),lx(r);let i={environmentId:e,threadId:t,unsubscribe:Mb,unsubscribeConnectionListener:null,refCount:1,lastAccessedAt:Date.now(),evictionTimeoutId:null,lastEventAt:Date.now(),recoveryAttempts:0};return I.set(n,i),zb(i)||Bb(i),Kb(),ax(),lx(i)}function dx(e,t){return e.type!==`thread.message-sent`||t.type!==`thread.message-sent`||e.payload.threadId!==t.payload.threadId||e.payload.messageId!==t.payload.messageId?null:{...t,payload:{...t.payload,attachments:t.payload.attachments??e.payload.attachments,createdAt:e.payload.createdAt,text:!t.payload.streaming&&t.payload.text.length>0?t.payload.text:e.payload.text+t.payload.text}}}function fx(e){if(e.length<2)return[...e];let t=[];for(let n of e){let e=t.at(-1),r=e?dx(e,n):null;if(r){t[t.length-1]=r;continue}t.push(n)}return t}function px(){let e=Tn(S.getState());hb.getState().syncProjects(e.map(e=>({key:In(Ln(e.environmentId,e.id)),cwd:e.cwd})))}function mx(){let e=hn(S.getState());hb.getState().syncThreads(e.map(e=>({key:Rn(C(e.environmentId,e.id)),seedVisitedAt:e.updatedAt??e.createdAt}))),yy(e.map(e=>C(e.environmentId,e.id)))}function hx(){px(),mx();let e=wy({snapshotThreads:hn(S.getState()).map(e=>({key:Rn(C(e.environmentId,e.id)),deletedAt:null,archivedAt:e.archivedAt})),draftThreadKeys:hy.getState().listDraftThreadKeys()});lm.getState().removeOrphanedTerminalStates(e)}function gx(e){return e.serverThreadArchivedAt===void 0?e.hasDraftThread:e.serverThreadArchivedAt===null}function _x(e,t){if(e.length===0)return;let n=Ty(e),r=fx(e),i=e.some(e=>e.type===`project.created`||e.type===`project.meta-updated`||e.type===`project.deleted`);if(n.needsProviderInvalidation&&Cy().notifyProviderInvalidation(),S.getState().applyOrchestrationEvents(r,t),i){let e=Tn(S.getState());hb.getState().syncProjects(e.map(e=>({key:In(Ln(e.environmentId,e.id)),cwd:e.cwd})))}if(e.some(e=>e.type===`thread.created`||e.type===`thread.deleted`)){let e=hn(S.getState());hb.getState().syncThreads(e.map(e=>({key:Rn(C(e.environmentId,e.id)),seedVisitedAt:e.updatedAt??e.createdAt})))}let a=hy.getState();for(let e of n.promoteDraftThreadIds)vy(C(t,e));for(let e of n.clearDeletedThreadIds)a.clearDraftThread(C(t,e)),hb.getState().clearThreadUi(Rn(C(t,e)));for(let e of n.removeTerminalStateThreadIds){let n=C(t,e);lm.getState().removeTerminalState(n),Pf.getState().clearBrowserState(n)}cx(t)}function vx(e,t){_x([e],t)}function yx(e,t){let n=e.kind===`thread-upserted`?e.thread.id:e.kind===`thread-removed`?e.threadId:null,r=n?C(t,n):null,i=r?Cn(S.getState(),r):void 0;switch(S.getState().applyShellEvent(e,t),e.kind){case`project-upserted`:case`project-removed`:px();return;case`thread-upserted`:mx(),!i&&r&&vy(r),i?.archivedAt===null&&e.thread.archivedAt!==null&&r&&(lm.getState().removeTerminalState(r),Pf.getState().clearBrowserState(r)),sx(t,e.thread.id),ax();return;case`thread-removed`:r&&(Jb(Rn(r)),hy.getState().clearDraftThread(r),hb.getState().clearThreadUi(Rn(r)),lm.getState().removeTerminalState(r),Pf.getState().clearBrowserState(r)),mx();return}}function bx(e,t){return e.invalidateQueries({queryKey:Rf.all(t)})}function xx(e){return{onWelcome:(t,n)=>{e?.(t);let r=Cy().readQueryClient();r&&bx(r,n)},applyShellEvent:yx,syncShellSnapshot:(e,t)=>{let n=nx(e,t);S.getState().syncServerShellSnapshot(n,t),rx(t,n.threads.map(e=>e.id)),cx(t),hx()},applyTerminalEvent:(e,t)=>{let n=C(t,Br.make(e.threadId)),r=Cn(S.getState(),n),i=hy.getState().getDraftThreadByRef(n)!==null;gx({serverThreadArchivedAt:r?.archivedAt,hasDraftThread:i})&&lm.getState().applyTerminalEvent(n,e)},applyBrowserEvent:(e,t)=>{let n=C(t,Br.make(e.threadId)),r=Cn(S.getState(),n),i=hy.getState().getDraftThreadByRef(n)!==null;gx({serverThreadArchivedAt:r?.archivedAt,hasDraftThread:i})&&Pf.getState().applyBrowserEvent(n,e)},onShellSubscriptionError:(e,t)=>{Cy().setRuntimeError(t,e)}}}function Sx(){return new Date().toISOString()}function Cx(e){j.getState().patch(e,{connectionState:`connecting`,lastError:null,lastErrorAt:null})}function wx(e){let t=Sx();j.getState().patch(e,{connectionState:`connected`,authState:`authenticated`,connectedAt:t,disconnectedAt:null,lastError:null,lastErrorAt:null}),ar.getState().markConnected(e,t)}function Tx(e,t){j.getState().patch(e,{descriptor:t.environment,serverConfig:t})}function Ex(e,t){j.getState().patch(e,{connectionState:`disconnected`,disconnectedAt:Sx(),...t&&t.trim().length>0?{lastError:t,lastErrorAt:Sx()}:{}})}function Dx(e,t){j.getState().patch(e,{connectionState:`error`,...yl(t)})}function Ox(){return new Date().toISOString()}function kx(e){let t=gr();if(!t?.environmentId)throw Error(`Unable to resolve the primary environment.`);let n=e.readConnection(t.environmentId);if(n)return n;let r=of(),i=t.source===`paired-bearer`||!0;return e.registerConnection(Jl({kind:`primary`,knownEnvironment:t,client:cf(t),resolveEnvironmentId:()=>gr()?.environmentId??t.environmentId,...i?{readiness:r?{bearerToken:r.bearerToken}:{}}:{},...xx()}))}async function Ax(e){let t=sf();if(!t)throw Error(`Desktop Local runtime is not authenticated. Sign in with CMMD again before importing local projects.`);let n=await Ll({httpBaseUrl:t.httpBaseUrl,bearerToken:t.bearerToken}),r=e.readConnection(n.environmentId);if(r)return r;let i=Sn({id:n.environmentId,label:t.label,source:`desktop-managed`,target:{httpBaseUrl:t.httpBaseUrl,wsBaseUrl:t.wsBaseUrl}});return e.registerConnection(Jl({kind:`desktop-local`,knownEnvironment:{...i,environmentId:n.environmentId,label:n.label},client:lf({environmentId:n.environmentId,httpBaseUrl:t.httpBaseUrl,wsBaseUrl:t.wsBaseUrl,bearerToken:t.bearerToken,onConnecting:Cx,onConnected:wx,onError:(e,t)=>{j.getState().patch(e,{connectionState:`error`,lastError:t,lastErrorAt:Ox()})},onDisconnected:Ex}),...xx()}))}var jx=new Map;function Mx(e){for(let t of e){let e=jx.get(t);e===void 0||e<=1?jx.delete(t):jx.set(t,e-1)}}async function Nx(e,t){let n=e.environmentId;jx.set(n,(jx.get(n)??0)+1);try{return t.readConnection(n)||await t.ensureCmmdRuntimeSavedEnvironmentConnection(e),!0}catch{return Mx([n]),!1}}async function Px(e){await $n();let t=(await Promise.all(or().map(async t=>await Nx(t,e)?t.environmentId:null))).flatMap(e=>e===null?[]:[e]),n=!1;return()=>{n||(n=!0,Mx(t))}}function Fx(){return new Date().toISOString()}async function Ix(e,t){t.readConnection(e)?.kind===`saved`&&(j.getState().clear(e),await t.removeConnection(e).catch(()=>!1))}async function Lx(e,t){let n=tr(e);if(!n)throw Error(`Saved environment not found.`);let r=t.readConnection(e);if(!r){try{await t.ensureCmmdRuntimeSavedEnvironmentConnection(n)}catch(t){throw Dx(e,t),t}return}Cx(e);try{await r.reconnect()}catch(t){throw Dx(e,t),t}}async function Rx(e,t){t.invalidate(e),ar.getState().remove(e),await hr(e),await Ix(e,t)}async function zx(e,t){let{existing:n,replacedRecord:r}=hl({environmentId:Ur.make(e.environment.environmentId),replacesEnvironmentId:e.environment.replacesEnvironmentId}),i=Bx(e.environment,n);ol(e.signal);let a=await gl(n),o=t.readConnection(i.environmentId)!==null&&ml({existing:n,replacedRecord:r,record:i});return o||(t.invalidate(i.environmentId),await t.removeConnection(i.environmentId).catch(()=>!1)),r&&(t.invalidate(r.environmentId),await t.removeConnection(r.environmentId).catch(()=>!1)),await t.ensureCmmdRuntimeSavedEnvironmentConnection(i,{bearerToken:e.bearerToken,registryExpectation:n&&!r?{kind:`existing-record`,record:n}:{kind:`initial-add`},...e.signal?{signal:e.signal}:{},...e.onBootstrapRetry?{onBootstrapRetry:e.onBootstrapRetry}:{}}),Vx({record:i,replacedRecord:r,persistenceRollback:a,keepsLiveConnection:o,signal:e.signal,dependencies:t})}function Bx(e,t){let n=Ur.make(e.environmentId),{kind:r,cmmdOrganizationId:i,cmmdProjectId:a,runtimeId:o,runtimeTicketExpiresAt:s}=e;return{environmentId:n,label:e.label,wsBaseUrl:Yr(e.wsBaseUrl),httpBaseUrl:e.httpBaseUrl,createdAt:t?.createdAt??Fx(),lastConnectedAt:Fx(),...r===void 0?{}:{kind:r},...i===void 0?{}:{cmmdOrganizationId:i},...a===void 0?{}:{cmmdProjectId:a},...o===void 0?{}:{runtimeId:o},...s===void 0?{}:{runtimeTicketExpiresAt:s}}}async function Vx(e){let{record:t,replacedRecord:n,persistenceRollback:r,keepsLiveConnection:i,signal:a,dependencies:o}=e,s=!1;try{return ol(a),await vl({record:t,replacedRecord:n,rollback:r,...a?{signal:a}:{}}),s=!0,ol(a),ar.getState().upsert(dl(t)),n&&o.retireEnvironmentId(n.environmentId),t}catch(e){throw i||await o.removeConnection(t.environmentId).catch(()=>!1),s&&await _l({record:t,replacedRecord:n,rollback:r}),ol(a),e}}var Hx=`forge.deviceRegistry.deviceKey`,Ux=`forge.deviceRegistry.runtimeId`;function Wx(e){let t=qx(Hx,e.desktopIdentity?.deviceKey,`device`),n=qx(Ux,e.desktopIdentity?.runtimeId,`runtime`),r=Kx(e.desktopIdentity?.hostKey),i=Qx(),a=e.desktopAvailable?`desktop`:$x(),o=e.desktopAvailable?Zx(e.desktopIdentity)??eS(i):tS(i);return{device:{...r?{hostKey:r}:{},deviceKey:t,displayName:o,platform:i,deviceType:a,metadata:{clientKind:e.desktopAvailable?`forge-desktop`:`forge-web`,userAgent:window.navigator.userAgent,origin:window.location.origin,...e.desktopIdentity?{desktopIdentity:{hostName:e.desktopIdentity.hostName,computerName:e.desktopIdentity.computerName,platform:e.desktopIdentity.platform}}:{}}},...e.desktopAvailable&&e.includeExecutableRuntime!==!1?{runtime:{runtimeId:n,runtimeKind:`desktop-local`,displayName:`Local Forge Desktop`,endpointUrl:e.desktopEndpointUrl??null,status:`online`,metadata:{origin:window.location.origin}}}:{}}}async function Gx(){let e=await window.desktopBridge?.getDeviceIdentity?.()??null;return Wx({desktopAvailable:!!window.desktopBridge,desktopIdentity:e,includeExecutableRuntime:!1})}function Kx(e){let t=e?.trim()??``;return t.length>0?t:null}function qx(e,t,n){let r=Kx(t);return r?(Dn(e,r),r):Xx(e,n)}function Jx(){return Nn(Ux)}function Yx(){return Nn(Hx)}function Xx(e,t){let n=Nn(e);if(n)return n;let r=`${t}_${crypto.randomUUID()}`;return Dn(e,r),r}function Zx(e){let t=e?.displayName?.trim()??``;return t.length>0?t:null}function Qx(){let e=window.navigator.userAgent.toLowerCase();return e.includes(`iphone`)||e.includes(`ipad`)?`ios`:e.includes(`android`)?`android`:e.includes(`mac`)?`macos`:e.includes(`win`)?`windows`:e.includes(`linux`)?`linux`:`unknown`}function $x(){let e=window.navigator.userAgent.toLowerCase();return e.includes(`ipad`)||e.includes(`tablet`)?`tablet`:e.includes(`mobi`)||e.includes(`iphone`)||e.includes(`android`)?`mobile`:`browser`}function eS(e){return e===`macos`?`Mac`:e===`windows`?`Windows PC`:e===`linux`?`Linux Desktop`:`Desktop`}function tS(e){return e===`web`?`Browser`:e===`macos`?`Mac Browser`:e===`windows`?`Windows Browser`:e===`linux`?`Linux Browser`:`Browser`}var nS=`forge.relayControlJournal.v1`;function rS(){if(globalThis.localStorage===void 0)throw Error(`Forge relay control recovery requires durable browser storage.`);return globalThis.localStorage}var iS={read:()=>rS().getItem(nS),write:e=>rS().setItem(nS,e)},aS=null,oS=Oa()(e=>({byRuntimeId:{},replace:t=>e({byRuntimeId:t})}));function sS(e){e.subscribe(e=>{let t=new Set(e.records.map(e=>e.runtimeId));oS.getState().replace(Object.fromEntries([...t].map(t=>[t,ua(e.records,t)])))})}function cS(){return aS===null&&(aS=da({storage:iS}),sS(aS)),aS}function lS(){let e=(0,A.c)(1),t=oS(dS),n;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0],(0,O.useEffect)(uS,n),t}function uS(){cS()}function dS(e){return e.byRuntimeId}function fS(e){let t=cS();for(let n of t.records())n.runtimeId===e&&(n.status===`failed`||n.status===`outcome-unknown`)&&t.acknowledge(n.runtimeId,n.actorSessionId,n.transportRequestId)}var pS=class extends Error{code;constructor(e,t){super(t),this.name=`RelayControlRouteError`,this.code=e}};function mS(e){let t=e&&typeof e==`object`?e.code:null;throw t===`PROTOCOL_INCOMPATIBLE`?new pS(`FORGE_RUNTIME_UPDATE_REQUIRED`,`Update Forge on the target runtime before connecting remotely.`):t===`PROTOCOL_ROLLOUT_DENIED`?new pS(`FORGE_REMOTE_CONTROL_NOT_ENABLED`,`Remote control is not enabled for this CMMD account. Synced runtime inventory remains available.`):e}async function hS(e){let t=e.getStoredDeviceKey(),n=t?await e.apiClient.getDeviceRegistry():await e.apiClient.registerDevice(await e.buildDeviceRegistration());return t&&!n.devices.some(e=>e.deviceKey===t)&&(n=await e.apiClient.registerDevice(await e.buildDeviceRegistration())),t??=e.getStoredDeviceKey(),{deviceKey:t,registry:n}}function gS(e){if(!e.deviceKey)throw new pS(`FORGE_CONTROL_DEVICE_UNAUTHORIZED`,`This Forge control surface could not establish CMMD identity.`);let t=e.registry.devices.find(t=>t.deviceKey===e.deviceKey);if(t?.trustState===`revoked`||t?.authorization?.revoked===!0)throw new pS(`FORGE_CONTROL_DEVICE_REVOKED`,`This Forge control surface was revoked by CMMD.`);if(!t||t.trustState!==`trusted`)throw new pS(`FORGE_CONTROL_DEVICE_UNAUTHORIZED`,`This Forge control surface is not trusted by CMMD.`);return t}function _S(e,t){let n=async()=>gS(await hS(t));return{acquireRoute:async()=>{let r=await n(),i=await la();try{let n=await t.apiClient.issueRelayControlRoute(e,{controlDeviceId:r.id,controlSessionId:t.controlSessionId,scopes:[...wi],protocolMinVersion:4,protocolMaxVersion:4,...Xi(i)});return ea({route:n,runtimeId:e,endpoint:i})}catch(e){if(e instanceof ca)throw new pS(`FORGE_RUNTIME_UPDATE_REQUIRED`,e.message);return mS(e)}},acquireActionGrant:async r=>{let i=await n();try{return(await t.apiClient.issueRelayActionGrant(e,{controlDeviceId:i.id,controlSessionId:t.controlSessionId,...r})).token}catch(e){return mS(e)}}}}var vS=new Map;async function yS(e,t){let n=Ur.make(e.runtimeId),r=t.readConnection(n);if(r)return r;Cx(n);let i=cS(),a=_S(e.runtimeId,{apiClient:lr,getStoredDeviceKey:Yx,buildDeviceRegistration:Gx,controlSessionId:i.controlSessionId}),o;try{o=await a.acquireRoute()}catch(e){throw Dx(n,e),e}let s=o,c=_a({acquireRoute:async()=>{let e=s;return s=null,e??a.acquireRoute()},acquireActionGrant:a.acquireActionGrant,journal:i,lifecycle:{onConnecting:()=>Cx(n),onAuthenticated:()=>wx(n),onDisconnected:e=>Ex(n,e.reason),onError:e=>Dx(n,Object.assign(Error(e.message),e))}}),l=af(new ud(o.relayWebSocketUrl,{trackGlobalConnection:!1},{layer:c,makeClient:$i(wi)})),u=Jl({kind:`saved`,knownEnvironment:{...Sn({id:n,label:e.label,source:`manual`,target:{httpBaseUrl:ia()?.target.httpBaseUrl??o.relayWebSocketUrl,wsBaseUrl:o.relayWebSocketUrl}}),environmentId:n},client:l,tolerateReportedEnvironmentIdentity:!0,onConfigSnapshot:e=>Tx(n,e),...xx(e=>{j.getState().patch(n,{descriptor:e.environment})})});try{let[,e]=await Promise.all([u.ensureBootstrapped(),l.server.getConfig()]);return Tx(n,e),wx(n),t.registerConnection(u)}catch(e){throw Dx(n,e),await u.dispose().catch(()=>void 0),e}}function bS(e,t){let n=Ur.make(e.runtimeId),r=t.readConnection(n);if(r)return Promise.resolve(r);let i=vS.get(n);if(i)return i;let a=yS(e,t).finally(()=>{vS.delete(n)});return vS.set(n,a),a}var xS=new Set([`CMMD_AUTH_REQUIRED`,`CMMD_AUTH_EXPIRED`,`INVALID_OR_NON_USER_TOKEN`,`NON_USER_BEARER`,`CMMD_REST_AUTH_ERROR`]);function SS(e){if(!e||typeof e!=`object`)return null;let t=e.code;return typeof t!=`string`||!xS.has(t)?null:t}function CS(e,t){return e===401||e===403||SS(t)!==null}function wS(e){if(!e||typeof e!=`object`)return!1;let t=e.status,n=e.code;return CS(typeof t==`number`?t:void 0,typeof n==`string`?{code:n}:void 0)}var TS=[1e3,2e3,4e3,8e3,12e3,16e3,2e4],ES=9e4,DS=[`all fibers interrupted without error`,`timed out while waiting for forge cloud runtime metadata`,`timed out while waiting for`,`to stream its shell snapshot`,`forge runtime route not found`,`fly-replay`,`could not find a good candidate`,`instance refused connection`],OS=[`Unknown socket error`,`Failed to fetch remote auth endpoint`,`Forge runtime replay target is unavailable`,`Remote auth request failed (502)`,`Remote auth request failed (503)`,`Remote auth request failed (504)`,`Unable to connect to the Forge server WebSocket`];function kS(e){if(typeof e!=`object`||!e)return null;let t=e.status;return typeof t==`number`&&Number.isInteger(t)?t:null}function AS(e){if(wS(e))return!1;let t=kS(e);if(t===502||t===503||t===504||e._tag===`OrchestrationGetSnapshotError`)return!0;let n=e instanceof Error?e.message:String(e),r=n.toLowerCase();return DS.some(e=>r.includes(e))||OS.some(e=>n.includes(e))}function jS(e){return TS[e]??TS[TS.length-1]}function MS(){return ES}function NS(e,t){if(!fl(e))return t;let n=null,r=new Promise((t,r)=>{n=globalThis.setTimeout(()=>{r(Error(`Timed out while waiting for Forge Cloud runtime metadata for ${e.environmentId}. The VM may still be starting.`))},MS())});return Promise.race([t,r]).finally(()=>{n!==null&&globalThis.clearTimeout(n)})}function PS(e){let t=e.toLowerCase();return t.includes(`authentication`)||t.includes(`unauthorized`)||t.includes(`forbidden`)||t.includes(`credential`)||t.includes(`runtime ticket`)||t.includes(`status 401`)||t.includes(`status 403`)}var FS=`forge:cloud-runtime-handoffs:v2`,IS=3e5,LS=new Map,RS={clear:()=>LS.clear(),getItem:e=>LS.get(e)??null,key:e=>Array.from(LS.keys())[e]??null,get length(){return LS.size},removeItem:e=>LS.delete(e),setItem:(e,t)=>LS.set(e,t)};function zS(){return typeof window<`u`?window.localStorage:globalThis.localStorage??RS}var BS=Oa()(Wf(e=>({byRuntimeId:{},record:t=>e(e=>({byRuntimeId:{...e.byRuntimeId,[t.runtimeId]:t}})),clearRuntime:t=>e(e=>t in e.byRuntimeId?{byRuntimeId:Object.fromEntries(Object.entries(e.byRuntimeId).filter(([e])=>e!==t))}:e),reconcileCatalog:(t,n=Date.now())=>e(e=>{let r=Object.entries(e.byRuntimeId).filter(([,e])=>{if(n-e.recordedAt>IS)return!1;let r=t.find(t=>t.cmmdOrganizationId===e.cmmdOrganizationId&&t.cmmdProjectId===e.cmmdProjectId);return r?.runtimeId===e.previousCatalogRuntimeId&&r.registeredAt===e.catalogRegisteredAt});return r.length===Object.keys(e.byRuntimeId).length?e:{byRuntimeId:Object.fromEntries(r)}}),reset:()=>e({byRuntimeId:{}})}),{name:FS,storage:Hf(zS),partialize:e=>({byRuntimeId:e.byRuntimeId}),version:2}));function VS(e){BS.getState().record({...e,recordedAt:Date.now()})}function HS(e){BS.getState().clearRuntime(e)}var US=new Set([`filesystem`,`terminal`,`git`,`project-write`]);function WS(e){return e===`desktop-local`}function GS(e){return e===`cloud`||e===`cloud-vm`||e===`cmmd`||e===`github`}function KS(e){return e.actionKind===`cloud-api`?{available:!0,route:`cloud`,requiresPermissionGate:!1,title:`Cloud API route`,description:`Cloud and Command work routes through authenticated Forge Cloud APIs.`}:US.has(e.actionKind)?GS(e.workSource)?e.workSource===`cloud-vm`&&e.executionRuntime===`cloud`?{available:!0,route:`cloud-vm`,requiresPermissionGate:!1,title:`Cloud VM route`,description:`Filesystem, terminal, git, and project writes run inside the user's Forge Cloud VM.`}:e.executionRuntime===`cloud`?{available:!0,route:`cloud`,requiresPermissionGate:!1,title:`Cloud work route`,description:`Cloud-scoped filesystem, terminal, git, and project writes run in the Forge Cloud runtime.`}:{available:!1,route:`blocked`,requiresPermissionGate:!1,title:`Open in Forge Cloud`,description:`Cloud projects must execute inside the Forge Cloud runtime. Local Desktop cannot run cloud project filesystem, terminal, git, or project-write actions.`}:WS(e.workSource)?e.surface===`desktop-local`||e.executionRuntime===`desktop-local`?{available:!0,route:`desktop-local`,requiresPermissionGate:!1,title:`Desktop local route`,description:`Local filesystem, terminal, git, and project writes run through the Desktop local backend.`}:e.executionRuntime===`dev-local-web`?{available:!0,route:`dev-local-web`,requiresPermissionGate:!1,title:`Dev local route`,description:`Local Web is a development-only projection and routes local actions through the dev server.`}:{available:!1,route:`blocked`,requiresPermissionGate:!1,title:`Switch to Desktop Local`,description:`Local projects must execute in the Desktop Local runtime. Forge Cloud cannot run local filesystem, terminal, git, or project-write actions.`}:{available:!1,route:`blocked`,requiresPermissionGate:!1,title:`Unknown work source`,description:`Forge cannot safely route local actions for this work source yet.`}:{available:!1,route:`blocked`,requiresPermissionGate:!1,title:`Unsupported route`,description:`Forge does not have a runtime route for this action yet.`}}var qS=`Ready to use. Your cloud project starts when you open the first thread.`;function JS(e){let t=KS({actionKind:`project-write`,surface:`cloud-official`,workSource:`cloud-vm`,executionRuntime:`cloud`});return{actionAuthority:`runtime`,surface:`cloud-official`,hostKind:`user-cloud-vm`,workSource:`cloud-vm`,executionRuntime:`cloud`,modelRuntime:`cloud`,linkState:`cloud-only`,workspaceIdentity:null,hideLocalPath:!0,label:`Cloud project`,description:e?`This project runs in your Forge Cloud VM.`:qS,actionRouteLabel:t.title,actionRouteDescription:t.description,actionRouteAvailable:t.available,requiresPermissionGate:t.requiresPermissionGate}}var YS=3e5;function XS(e,t,n=Date.now()){let r=new Map,i=new Map;for(let t of e){let e={cmmdOrganizationId:t.cmmdOrganizationId,cmmdProjectId:t.cmmdProjectId};r.set($S(e),e),t.runtimeId!==null&&i.set(t.runtimeId,e)}for(let a of t){if(n-a.recordedAt>YS)continue;let t=r.get($S({cmmdOrganizationId:a.cmmdOrganizationId,cmmdProjectId:a.cmmdProjectId})),o=e.find(e=>e.cmmdOrganizationId===a.cmmdOrganizationId&&e.cmmdProjectId===a.cmmdProjectId);t&&o?.runtimeId===a.previousCatalogRuntimeId&&o.registeredAt===a.catalogRegisteredAt&&!i.has(a.runtimeId)&&i.set(a.runtimeId,t)}return i}function ZS(e){return e.environmentId??`cmmd-cloud-project:${e.cmmdOrganizationId}:${e.cmmdProjectId}`}function QS(e){return{environmentId:ZS(e),workspaceRoot:e.workspaceRoot,resolvedRef:e.resolvedRef}}function $S(e){return`cloud:${e.cmmdOrganizationId}:${e.cmmdProjectId}`}function eC(e){let t=/^cloud:(\d+):(\d+)$/.exec(e??``);return t?{cmmdOrganizationId:Number(t[1]),cmmdProjectId:Number(t[2])}:null}function tC(e){return`cloud-runtime:${e}`}var nC=`cloud-unconnected:`;function rC(e,t,n=[]){let r=$S(e);return iC({id:Si.make(`${nC}${r}`),environmentId:Ur.make(ZS(e)),name:e.projectName,cwd:``,repositoryIdentity:null,availability:void 0,defaultModelSelection:null,createdAt:void 0,updatedAt:void 0,scripts:[],projectKey:r,environmentPresence:`remote-only`,source:JS(e.runtimeId!==null),memberProjectRefs:t?[t]:[],remoteEnvironmentLabels:[],worktreeMembers:[],activeWorktreeKey:null,preConnectCloud:{runtimeId:e.runtimeId,cmmdOrganizationId:e.cmmdOrganizationId,cmmdProjectId:e.cmmdProjectId,cmmdEnvironmentId:e.cmmdEnvironmentId,registeredAt:e.registeredAt,projectName:e.projectName,githubRepoFullName:e.githubRepoFullName,workspaceRoot:e.workspaceRoot,iconUrl:e.iconUrl,icon:e.icon,status:e.status,removal:e.removal},cloudRemoval:e.removal},n)}function iC(e,t){if(t.length===0)return e;let n=[...e.memberProjectRefs],r=new Set(n.map(e=>`${e.environmentId}:${e.projectId}`));for(let e of t){let t=`${e.environmentId}:${e.projectId}`;r.has(t)||(r.add(t),n.push(e))}return n.length===e.memberProjectRefs.length?e:{...e,memberProjectRefs:n}}function aC(e,t,n,r){if(!e)return null;let i=t.find(t=>t.cmmdEnvironmentId===String(e));if(i)return{row:i,runtimeId:i.runtimeId,matchedByHandoff:!1};let a=yr(e).legacyRuntimeId;if(a){let e=t.find(e=>e.runtimeId===a);if(e)return{row:e,runtimeId:a,matchedByHandoff:!1};let i=XS(t,n,r).get(a);if(!i)return null;let o=t.find(e=>e.cmmdOrganizationId===i.cmmdOrganizationId&&e.cmmdProjectId===i.cmmdProjectId);return o?{row:o,runtimeId:a,matchedByHandoff:!0}:null}let o=t.find(t=>t.runtimeId===null&&ZS(t)===String(e));return o?{row:o,runtimeId:null,matchedByHandoff:!1}:null}function oC(e,t=e.runtimeId){return{runtimeId:t,cmmdOrganizationId:e.cmmdOrganizationId,cmmdProjectId:e.cmmdProjectId,cmmdEnvironmentId:e.cmmdEnvironmentId,registeredAt:e.registeredAt,projectName:e.projectName,githubRepoFullName:e.githubRepoFullName,workspaceRoot:e.workspaceRoot,iconUrl:e.iconUrl,icon:e.icon,status:e.status,desiredState:e.desiredState}}function sC(e){return e.desiredState===`stopped`}var cC=15e3;function lC(e){return e===401||e===403}function uC(e){return typeof e!=`object`||!e?!1:e.retryable===!0}function dC(e){return lC(e.status)||e.attempt>=e.maxAttempts||e.status>=200&&e.status<300?!1:e.status>=500||e.status===409&&uC(e.body)}function fC(e,t){let n=e?.trim();if(!n)return null;if(/^-?\d+$/.test(n))return Number(n)*1e3;let r=Date.parse(n);return Number.isNaN(r)?null:r-t}function pC(e){let t=e=>Math.min(cC,Math.max(0,e)),n=fC(e.retryAfter,e.nowMs??Date.now());return t(n===null?300*2**Math.max(0,e.attempt-1):n)}var mC=6e4;function hC(e,t){if(!e||typeof e!=`object`)return t;let n=e.error;return typeof n==`string`&&n.trim().length>0?n:t}var gC=`CMMD returned an invalid Cloud runtime connection descriptor.`;function _C(e,t){let n=e[t];if(typeof n!=`string`||n.length===0)throw Error(gC);return n}function vC(e){if(!e||typeof e!=`object`)throw Error(gC);let t=e;return{httpBaseUrl:_C(t,`httpBaseUrl`),wsBaseUrl:_C(t,`wsBaseUrl`),bearerToken:_C(t,`bearerToken`),expiresAt:_C(t,`expiresAt`)}}async function yC(e){let t=Yi(`/api/cmmd/forge-runtimes/${encodeURIComponent(e.runtimeId)}/connect`),n=na({method:`POST`,...e.signal?{signal:e.signal}:{},headers:{"Content-Type":`application/json`},body:JSON.stringify(e.organizationId===void 0?{}:{organizationId:e.organizationId})});for(let r=1;r<=8;r+=1){let i=await fetch(t,n),a=await i.json().catch(()=>null);if(i.ok)return vC(a);if(!dC({status:i.status,body:a,attempt:r,maxAttempts:8})){let e=CS(i.status,a)?`CMMD authentication expired while renewing the Cloud runtime connection. Sign in again.`:`CMMD could not renew the Cloud runtime connection (${i.status}).`;throw Object.assign(Error(hC(a,e)),{status:i.status,...SS(a)?{code:SS(a)}:{}})}await cl(pC({attempt:r,retryAfter:i.headers.get(`retry-after`)}),e.signal)}throw Error(`Cloud runtime connection retry budget was exhausted.`)}function bC(e,t){if(!e?.expiresAt)return!0;let n=Date.parse(e.expiresAt);return!Number.isFinite(n)||n<=t+mC}function xC(e){let t=e.requestDescriptor??yC,n=e.now??Date.now,r=e.initialDescriptor??null,i=null,a=!1,o=new AbortController,s=e=>sl(e,o.signal),c=()=>i||(i=s(t({runtimeId:e.runtimeId,...e.organizationId===void 0?{}:{organizationId:e.organizationId},signal:o.signal})).then(async t=>(await s(Promise.resolve(e.validateDescriptor?.(t))),await s(Promise.resolve(e.persistDescriptor?.(t))),await s(Promise.resolve()),r=t,a=!1,t)).then(e=>(i=null,e),e=>{throw i=null,e}),i);return{acquire:e=>{if(o.signal.aborted)return s(Promise.resolve(r));let t=e?.forceRefresh||a||bC(r,n())?c():Promise.resolve(r);return sl(s(t),e?.signal)},invalidate:()=>{a=!0},dispose:()=>{o.abort()}}}function SC(e){let t=e.runtimeId?.trim();if(t)return t;let n=yr(e.environmentId).legacyRuntimeId;if(n)return n;let r=dr().rows,i=Object.values(BS.getState().byRuntimeId);return aC(e.environmentId,r,i)?.runtimeId??null}function CC(e,t,n,r){let i=e,a=xC({runtimeId:t,...e.cmmdOrganizationId===void 0?{}:{organizationId:e.cmmdOrganizationId},...n===void 0?{}:{initialDescriptor:{httpBaseUrl:e.httpBaseUrl,wsBaseUrl:e.wsBaseUrl,bearerToken:n,expiresAt:e.runtimeTicketExpiresAt??null}},validateDescriptor:async e=>{await Il({httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken})},persistDescriptor:async e=>{if(r&&!r())throw Error(`Saved environment changed while its connection was being acquired.`);let t={...dl(i),httpBaseUrl:e.httpBaseUrl,wsBaseUrl:Yr(e.wsBaseUrl),...e.expiresAt===null?{}:{runtimeTicketExpiresAt:e.expiresAt},lastConnectedAt:new Date().toISOString()};await Kn(t),await hr(t.environmentId),ar.getState().upsert(t),i=t}});return Sl(e.environmentId,a),a}function wC(e){let t={wsBaseUrl:e.record.wsBaseUrl,httpBaseUrl:e.record.httpBaseUrl,bearerToken:e.bearerToken,expiresAt:e.record.runtimeTicketExpiresAt??null};return{acquire:()=>Promise.resolve(t)}}var TC=12e4,EC=3e4,DC=3e4;function OC(e){let t=e.expiresAt?Date.parse(e.expiresAt):NaN;if(!Number.isFinite(t))throw Error(`Cloud runtime authority descriptor has no valid expiry.`);return t}function kC(e){if(!e||typeof e!=`object`)return!1;let t=e.status;return t===401||t===403}function AC(e){let t=e.now??Date.now,n=e.renewalSkewMs??TC,r=!1,i=null,a=null,o=OC(e.initialDescriptor),s=()=>{i!==null&&(globalThis.clearTimeout(i),i=null)},c=a=>{if(r)return;s();let c=OC(a);o=c;let l=Math.max(t(),c-n);e.onState?.({kind:`scheduled`,expiresAt:new Date(c).toISOString(),renewAt:new Date(l).toISOString()}),i=globalThis.setTimeout(()=>{i=null,u().catch(()=>void 0)},Math.max(0,l-t()))},l=()=>{if(r)return null;let e=t()+DC;return e>=o?null:(i=globalThis.setTimeout(()=>{i=null,u().catch(()=>void 0)},DC),new Date(e).toISOString())},u=()=>{if(r)return Promise.resolve();if(a)return a;s(),e.onState?.({kind:`renewing`,expiresAt:new Date(o).toISOString()});let n=e.renew().then(async n=>{let i=OC(n);if(i<=t())throw Error(`Cloud runtime authority descriptor is already expired.`);r||(e.onState?.({kind:`ready`,expiresAt:new Date(i).toISOString(),renewedAt:new Date(t()).toISOString()}),c(n))}).catch(t=>{if(r)return;let n=kC(t);throw e.onState?.({kind:`error`,code:n?`authority_auth_rejected`:`authority_renewal_failed`,retryAt:n?null:l()}),t}).finally(()=>{a=null});return a=n,n};return c(e.initialDescriptor),{ensureLive:()=>o>t()+EC?Promise.resolve():u(),renewNow:u,dispose:()=>{r=!0,s()}}}function jC(){return new Date().toISOString()}function MC(e,t,n,r,i){return n()&&j.getState().ensure(e.environmentId),af(new ud(async()=>{let e=e=>zl({wsBaseUrl:e.wsBaseUrl,httpBaseUrl:e.httpBaseUrl,bearerToken:e.bearerToken,...r?{runtimeTicket:e.bearerToken}:{}}),n=await t.acquire();try{return await e(n)}catch(n){if(!r||!zn(n))throw n;return e(await t.acquire({forceRefresh:!0}))}},{trackGlobalConnection:!1,onAttempt:()=>{n()&&i.setConnecting(e.environmentId)},onOpen:()=>{n()&&i.setConnected(e.environmentId)},onError:i=>{r&&PS(i)&&t.invalidate?.(),n()&&j.getState().patch(e.environmentId,{connectionState:`error`,lastError:i,lastErrorAt:jC()})},onClose:a=>{r&&(a.code===1008||PS(a.reason))&&t.invalidate?.(),n()&&i.setDisconnected(e.environmentId,a.reason)}}))}async function NC(e,t,n,r,i,a,o){let s=await xl(t,o),[c,l]=await Promise.all([a?Promise.resolve(a):n.server.getConfig(),Il({httpBaseUrl:s.httpBaseUrl,bearerToken:s.bearerToken,...o?{signal:o}:{}})]);return r()?(j.getState().patch(e.environmentId,{authState:l.authenticated?`authenticated`:`requires-auth`,descriptor:c.environment,serverConfig:c,role:l.authenticated?l.role??i??null:null}),PC(e,c,l.authenticated,r),!0):!1}function PC(e,t,n,r){if(!n||!r())return;let i=tr(e.environmentId);i&&ar.getState().upsert({...i,lastAuthenticatedPullRequestCapability:t.environment.capabilities?.pullRequests===!0})}async function FC(e,t,n,r){let i=n.findConnection(e.environmentId);if(i)return i;let a=r?.registryExpectation??{kind:`existing-record`,record:e},o=()=>n.canCommit({record:e,generation:t,registryExpectation:a}),{isCmmdRuntime:s,targetProvider:c,initialTarget:l}=await IC(e,r,o);if(!o())throw LC(e.environmentId,c,s),Error(`Saved environment changed while its connection was being acquired.`);let u=r?.client??MC(e,c,o,s,n),d=zC({record:e,initialTarget:l,targetProvider:c,isCmmdRuntime:s,client:u,canCommit:o,dependencies:n});try{if(!await n.withMetadataTimeout(e,NC(e,c,u,o,r?.role??null,r?.serverConfig??null,r?.signal))||!o())throw Error(`Saved environment changed while its connection was being acquired.`);return n.registerConnection(d)}catch(t){throw s&&wl(e.environmentId,c),o()&&n.setError(e.environmentId,t),await d.dispose().catch(()=>void 0),t}}async function IC(e,t,n){let r=fl(e)?SC(e):null,i=r!==null,a=await RC(e,t,i,n),o=i?CC(e,r,a??void 0,n):wC({record:e,bearerToken:a});try{return{isCmmdRuntime:i,targetProvider:o,initialTarget:await xl(o,t?.signal)}}catch(t){throw LC(e.environmentId,o,i),t}}function LC(e,t,n){n&&wl(e,t)}async function RC(e,t,n,r){if(n)return t?.bearerToken;let i=t?.bearerToken??await rr(e.environmentId);if(i)return i;throw r()&&j.getState().patch(e.environmentId,{authState:`requires-auth`,role:null,connectionState:`disconnected`,lastError:`Saved environment is missing its saved credential. Pair it again.`,lastErrorAt:jC()}),Error(`Saved environment is missing its saved credential.`)}function zC(e){let{record:t,initialTarget:n,targetProvider:r,isCmmdRuntime:i,client:a,canCommit:o,dependencies:s}=e,c=Sn({id:t.environmentId,label:t.label,source:`manual`,target:{httpBaseUrl:n.httpBaseUrl,wsBaseUrl:n.wsBaseUrl}}),l=i&&n.expiresAt?AC({initialDescriptor:{...n,expiresAt:n.expiresAt},renew:async()=>{let e=await r.acquire({forceRefresh:!0});return{...e,expiresAt:e.expiresAt??null}},onState:e=>{o()&&j.getState().patch(t.environmentId,{providerAuthority:e})}}):null;return Jl({kind:`saved`,knownEnvironment:{...c,environmentId:t.environmentId},client:a,readiness:{bearerToken:n.bearerToken},tolerateReportedEnvironmentIdentity:i,refreshMetadata:async()=>{await NC(t,r,a,o)},...l?{ensureProviderAuthority:l.ensureLive,onDispose:l.dispose}:{},onConfigSnapshot:e=>{o()&&j.getState().patch(t.environmentId,{descriptor:e.environment,serverConfig:e})},...s.createHandlers(e=>{o()&&j.getState().patch(t.environmentId,{descriptor:e.environment})})})}var BC=class{readRecord;hasSameTarget;generations=new Map;acquisitions=new Map;constructor(e,t){this.readRecord=e,this.hasSameTarget=t}invalidate(e){this.generations.set(e,this.readGeneration(e)+1)}generationFor(e){return this.readGeneration(e)}isCurrent(e){if(this.readGeneration(e.record.environmentId)!==e.generation)return!1;let t=this.readRecord(e.record.environmentId);return e.registryExpectation.kind===`initial-add`?t===null||this.hasSameTarget(t,e.record):t!==null&&this.hasSameTarget(t,e.registryExpectation.record)}ensure(e,t){let n=this.readGeneration(e.environmentId),r=this.acquisitions.get(e.environmentId);if(r&&r.generation===n&&this.hasSameTarget(r.record,e))return r.promise;let i=t(e,n).finally(()=>{this.acquisitions.get(e.environmentId)?.promise===i&&this.acquisitions.delete(e.environmentId)});return this.acquisitions.set(e.environmentId,{generation:n,record:e,promise:i}),i}async sync(e){await ir(e.records);let t=new Map(e.records.map(e=>[e.environmentId,e]));for(let[e,n]of this.acquisitions){let r=t.get(e);(!r||!this.hasSameTarget(r,n.record))&&this.invalidate(e)}let n=new Set(t.keys());await Promise.all(e.connectedSavedEnvironmentIds.filter(e=>!n.has(e)).map(async t=>{this.invalidate(t),await e.disconnect(t)}))}clear(){this.generations.clear(),this.acquisitions.clear()}readGeneration(e){return this.generations.get(e)??0}};async function VC(e,t,n){if(!fl(e))return n.ensureSavedEnvironmentConnection(e,t);let r=n.getGeneration(e.environmentId),i=()=>n.registry.isCurrent({record:e,generation:r,registryExpectation:t?.registryExpectation??{kind:`existing-record`,record:e}}),a=null;for(let r=0;r<8;r+=1){ol(t?.signal);try{let r=await n.ensureSavedEnvironmentConnection(e,t);return await sl(r.ensureBootstrapped(),t?.signal),r}catch(o){a=o,await HC({error:o,attemptIndex:r,record:e,options:t,dependencies:n,canCommit:i})}}let o=a instanceof Error?a:Error(String(a));throw i()&&n.setRuntimeError(e.environmentId,o),o}async function HC(e){let{error:t,attemptIndex:n,record:r,options:i,dependencies:a,canCommit:o}=e;if(!o())throw t;if(await a.removeConnection(r.environmentId).catch(()=>!1),ol(i?.signal),n>=7||!AS(t))throw o()&&a.setRuntimeError(r.environmentId,t),t;let s=jS(n);i?.onBootstrapRetry?.({attempt:n+2,maxAttempts:8,retryDelayMs:s,error:t}),o()&&j.getState().patch(r.environmentId,{connectionState:`connecting`,lastError:null,lastErrorAt:null}),await cl(s,i?.signal)}var UC=new Map,WC=new BC(e=>tr(e),pl),GC=new Set,KC=jl({createPrimaryEnvironmentConnection:ZC,syncSavedEnvironmentConnections:$C});function qC(){KC.notifyProviderInvalidation()}function JC(){for(let e of GC)e()}function YC(e){let t=UC.get(e.environmentId);if(t&&t!==e)throw Error(`Environment ${e.environmentId} already has an active connection.`);return UC.set(e.environmentId,e),JC(),e}async function XC(e){let t=UC.get(e);return t?(UC.delete(e),wl(e),Xb(e),JC(),await t.dispose(),!0):!1}function ZC(){return kx({readConnection:tw,registerConnection:YC})}async function QC(e,t){return UC.get(e.environmentId)||WC.ensure(e,(e,n)=>FC(e,n,{findConnection:e=>UC.get(e),registerConnection:YC,canCommit:WC.isCurrent.bind(WC),createHandlers:xx,withMetadataTimeout:NS,setConnecting:Cx,setConnected:wx,setDisconnected:Ex,setError:Dx},t))}async function $C(e){await WC.sync({records:e,connectedSavedEnvironmentIds:[...UC.values()].filter(e=>e.kind===`saved`).map(e=>e.environmentId),disconnect:sw})}function ew(e){return GC.add(e),()=>{GC.delete(e)}}function tw(e){return UC.get(e)??null}function nw(e){return bS(e,{readConnection:tw,registerConnection:YC})}function rw(e){let t=tw(e);if(!t)throw Error(`No websocket client registered for environment ${e}.`);return t}function iw(){return ZC()}async function aw(){return Ax({readConnection:tw,registerConnection:YC})}function ow(){return{readConnection:tw,removeConnection:XC,ensureSavedEnvironmentConnection:QC,ensureCmmdRuntimeSavedEnvironmentConnection:fw,invalidate:e=>WC.invalidate(e),retireEnvironmentId:Yb}}async function sw(e){await Ix(e,ow())}async function cw(e){await Lx(e,ow())}async function lw(){return Px({readConnection:tw,ensureCmmdRuntimeSavedEnvironmentConnection:fw})}async function uw(e){await Rx(e,ow())}async function dw(e){return zx(e,ow())}async function fw(e,t){return VC(e,t,{ensureSavedEnvironmentConnection:QC,getGeneration:e=>WC.generationFor(e),registry:WC,removeConnection:XC,setRuntimeError:Dx})}async function pw(e){await UC.get(e)?.ensureBootstrapped()}async function mw(e){let t=UC.get(e);if(t?.ensureProviderAuthority){await t.ensureProviderAuthority();return}if(Cl(e))throw Error(`Cloud runtime provider authority is not available.`)}function hw(e){return KC.start(e)}kb({applyEvent:vx,readConnection:tw,subscribeConnections:ew}),Sy({notifyProviderInvalidation:qC,readQueryClient:()=>KC.readActiveService()?.queryClient??null,setRuntimeError:Dx});var gw=fn(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);function _w(e){return{environmentId:e.environmentId,threadId:e.threadId}}function vw(e){return{draftId:e}}function yw(e){return!e.environmentId||!e.threadId?null:C(e.environmentId,e.threadId)}function bw(e){return e.environmentId&&e.threadId?{kind:`server`,threadRef:C(e.environmentId,e.threadId)}:e.draftId?{kind:`draft`,draftId:e.draftId}:null}function xw(e){let t=(0,A.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=wa(`relative overflow-hidden rounded-sm bg-muted [--skeleton-highlight:--alpha(var(--color-white)/64%)] after:absolute after:inset-0 after:animate-skeleton after:bg-[linear-gradient(120deg,transparent_40%,var(--skeleton-highlight),transparent_60%)] motion-reduce:after:content-none dark:[--skeleton-highlight:--alpha(var(--color-white)/4%)]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,k.jsx)(`div`,{className:i,"data-slot":`skeleton`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Sw(e,t){if(!De(e)||!De(t))return t;let n={...e};for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];n[e]=De(t)&&De(r)?Sw(t,r):r}return n}function Cw(e,t){return un(t).pipe(ln,sn(e))}function ww(e){return{issues:e.issues,providers:e.providers,settings:e.settings}}var Tw=[],Ew=[],Dw=[],Ow=e=>e?.availableEditors??Tw,kw=e=>e?.keybindings??Ew,Aw=e=>e?.keybindingsConfigPath??null,jw=e=>e?.observability??null,Mw=e=>e?.providers??Dw,Nw=e=>e?.settings??Ri,Pw=Cw(`server-welcome`,null),Fw=Cw(`server-config`,null),Iw=Cw(`server-config-updated`,null),Lw=Cw(`server-providers-updated`,null);function Rw(){return cn.get(Fw)}function zw(){return cn.get(Iw)}function Bw(e){Yw(e),Xw({providers:e.providers}),Zw(ww(e),`snapshot`)}function Vw(e){switch(e.type){case`snapshot`:Bw(e.config);return;case`keybindingsUpdated`:{let t=Rw();if(!t)return;let n={...t,issues:e.payload.issues,keybindings:e.payload.keybindings};Yw(n),Zw(ww(n),e.type);return}case`providerStatuses`:Hw(e.payload);return;case`settingsUpdated`:Uw(e.payload.settings);return;case`environmentUpdated`:Ww(e.payload.environment);return}}function Hw(e){let t=Rw();if(Xw(e),!t)return;let n={...t,providers:e.providers};Yw(n),Zw(ww(n),`providerStatuses`)}function Uw(e){let t=Rw();if(!t)return;let n={...t,settings:e};Yw(n),Zw(ww(n),`settingsUpdated`)}function Ww(e){let t=Rw();if(br()?.environmentId===e.environmentId&&yn(e),!t)return;let n={...t,environment:e};Yw(n),Zw(ww(n),`environmentUpdated`)}function Gw(e){cn.set(Pw,e)}function Kw(e){return Qw(Iw,t=>{e(t.payload,t.source)})}function qw(e){let t=!1,n=[e.subscribeLifecycle(e=>{e.type===`welcome`&&Gw(e.payload)}),e.subscribeConfig(e=>{Vw(e)})];return Rw()===null&&e.getConfig().then(e=>{t||Rw()!==null||Bw(e)}).catch(()=>void 0),()=>{t=!0;for(let e of n)e()}}var Jw=1;function Yw(e){cn.set(Fw,e)}function Xw(e){cn.set(Lw,e)}function Zw(e,t){cn.set(Iw,{id:Jw++,payload:e,source:t})}function Qw(e,t){return cn.subscribe(e,e=>{e!==null&&t(e)},{immediate:!0})}function $w(e,t){let n=(0,O.useRef)(t);n.current=t;let r=(0,O.useCallback)(e=>{e!==null&&n.current(e)},[]);va(e,r,{immediate:!0})}function eT(){return ha(Fw)}function tT(){return ha(Fw,Nw)}function nT(){return ha(Fw,Mw)}function rT(){return ha(Fw,kw)}function iT(){return ha(Fw,Ow)}function aT(){return ha(Fw,Aw)}function oT(){return ha(Fw,jw)}function sT(e){$w(Pw,e)}function cT(){return ha(Pw)}function lT(e){$w(Iw,e)}var uT=`[CLIENT_SETTINGS]`,dT=new Set,fT=ui,pT=!1,mT=null,hT=`pending`;function gT(e){hT!==e&&(hT=e,_T())}function _T(){for(let e of dT)e()}function vT(){return fT}function yT(e){fT=e,_T()}function bT(e){return dT.add(e),xT(),()=>{dT.delete(e)}}async function xT(){if(pT)return;if(mT)return mT;let e=(async()=>{try{let e=await nr();e&&yT(e),pT=!0,gT(`ready`)}catch(e){console.error(`${uT} hydrate failed`,e),gT(`failed`)}})().finally(()=>{mT===e&&(mT=null)});return mT=e,mT}var ST=new Set(ti(Li.fields));function CT(e){let t={},n={};for(let[r,i]of Object.entries(e))ST.has(r)?t[r]=i:n[r]=i;return{serverPatch:t,clientPatch:n}}function wT(){return xT()}var TT=Promise.resolve();function ET(e){let t=TT.then(async()=>{if(await wT(),kT()!==`ready`)throw Error(`${uT} hydration failed; refusing to persist settings.`);return e()});return TT=t.then(()=>void 0,()=>void 0),t}function DT(e){return ET(async()=>{let t=e(vT());await sr(t),yT(t)})}function OT(){return(0,O.useSyncExternalStore)(bT,kT,kT)}function kT(){return hT}function AT(e){let t=tT(),n=(0,O.useSyncExternalStore)(bT,vT,()=>ui),r=(0,O.useMemo)(()=>({...t,...n}),[n,t]);return(0,O.useMemo)(()=>e?e(r):r,[r,e])}function jT(){let e=(0,A.c)(2),t=MT,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t(Er)},e[0]=n):n=e[0];let r=n,i;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={updateSettings:t,resetSettings:r},e[1]=i):i=e[1],i}function MT(e){let{serverPatch:t,clientPatch:n}=CT(e);if(Object.keys(t).length>0){let e=Rw();e&&Uw(Sw(e.settings,t)),iw().client.server.updateSettings(t)}Object.keys(n).length>0&&ET(async()=>{let e={...vT(),...n};yT(e),await sr(e).catch(PT)}).catch(NT)}function NT(e){console.error(`${uT} persist failed`,e)}function PT(e){console.error(`${uT} persist failed`,e)}function FT(e){return t=>e?mn(t,e.environmentId).projectById[e.projectId]:void 0}function IT(e){let t,n,r;return i=>{let a=e(i);if(!a)return;let o=mn(i,a.environmentId);return r&&t===o&&n===a.threadId?r:(t=o,n=a.threadId,r=Fn(o,a.threadId),r)}}function LT(e){return IT(()=>e)}function RT(e){return t=>{if(e)return mn(t,e.environmentId).threadSubscriptionErrorById[e.threadId]}}function zT(e){let t,n,r,i;return a=>{if(!e){i=void 0,t=void 0,n=void 0,r=void 0;return}let o=mn(a,e.environmentId).threadShellById,s=o[e.threadId];if(!s){i=void 0,t=void 0,n=void 0,r=void 0;return}let c=s.kind===`master`?s.id:s.parentThreadId,l=c==null?void 0:o[c];if(i&&t===o&&n===s&&r===l)return i;let u=[];if(c!=null){for(let e of Object.values(o))e.kind===`worker`&&e.parentThreadId===c&&u.push(e);u.sort((e,t)=>e.createdAt.localeCompare(t.createdAt))}return t=o,n=s,r=l,i={you:s,master:l,workers:u},i}}function BT(e,t){let n=new Set(e.filter(e=>e.bootstrapped).map(e=>String(e.ref.environmentId))),r=e.filter(e=>{let r=t?.(e.ref.environmentId)??null;return r===null||!n.has(r)}),i=r.filter(e=>e.bootstrapped);return(i.find(e=>e.active)??i.at(-1)??r.find(e=>e.active)??r[0])?.ref}function VT(e,t){return IT(n=>{if(e)return BT(Object.entries(n.environmentStateById).filter(([,t])=>t.threadShellById[e]).map(([t,r])=>({ref:{environmentId:t,threadId:e},active:n.activeEnvironmentId===t,bootstrapped:r.bootstrapComplete})),t)})}var HT,UT=[];function WT(e){return HT===e.environmentStateById&&UT!==void 0?UT:(HT=e.environmentStateById,UT=Object.values(e.environmentStateById).flatMap(e=>Object.values(e.sidebarThreadSummaryById)),UT)}function GT(e){let t=e.payload&&typeof e.payload==`object`?e.payload:null,n=t?.plan;if(!Array.isArray(n))return null;let r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=e;if(typeof t.step!=`string`)continue;let n=t.status===`completed`||t.status===`inProgress`?t.status:`pending`;r.push({step:t.step,status:n})}return r.length===0?null:{createdAt:e.createdAt,turnId:e.turnId,...t&&`explanation`in t?{explanation:t.explanation}:{},steps:r}}function KT(e){let t=new Map;return e.map(e=>{let n=t.get(e.step)??0;return t.set(e.step,n+1),{key:`${e.step}:${n}`,step:e}})}function qT(e,t){let n=new Map,r;for(let e of t){let t=GT(e),i=Date.parse(e.createdAt);if(!(!t||Number.isNaN(i))){r??=i;for(let{key:e,step:r}of KT(t.steps)){let t=n.get(e)??{};r.status===`inProgress`&&t.startedAt===void 0&&(t.startedAt=i),r.status===`completed`&&t.completedAt===void 0&&(t.completedAt=i),n.set(e,t)}}}let i=new Map,a=r;for(let[e,t]of[...n.entries()].toSorted((e,t)=>(e[1].completedAt??1/0)-(t[1].completedAt??1/0))){let n=t.completedAt,r=t.startedAt??a;n!==void 0&&(r!==void 0&&n>r&&i.set(e,n-r),a=n)}return{...e,steps:KT(e.steps).map(({key:e,step:t})=>{if(t.status!==`completed`)return t;let n=i.get(e);return n===void 0?t:Object.assign({},t,{durationMs:n})})}}function JT(e){let t=XT(e?.data),n=XT(t?.item),r=XT(n?.result),i=XT(n?.input),a=ZT(e?.itemType),o=ZT(e?.detail),s=[e?.command,n?.command,i?.command,r?.command,t?.command,a===`command_execution`&&o?YT(o).output:null];for(let e of s){let t=sE(e);if(t)return{command:t,rawCommand:cE(e,t)}}return{command:null,rawCommand:null}}function YT(e){let t=e.trim(),n=/^(?<output>[\s\S]*?)(?:\s*<exited with exit code (?<code>\d+)>)\s*$/i.exec(t);if(!n?.groups)return{output:t.length>0?t:null};let r=Number.parseInt(n.groups.code??``,10),i=n.groups.output?.trim()??``;return{output:i.length>0?i:null,...Number.isInteger(r)?{exitCode:r}:{}}}function XT(e){return e&&typeof e==`object`?e:null}function ZT(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function QT(e){let t=e.trim();if(t.startsWith(`'`)&&t.endsWith(`'`)||t.startsWith(`"`)&&t.endsWith(`"`)){let e=t.slice(1,-1).trim();return e.length>0?e:t}return t}function $T(e){let t=QT(e);if(t.length===0)return null;let n=t.replace(/\\/g,`/`).split(`/`).at(-1)?.trim()??``;return n.length>0?n.toLowerCase():null}function eE(e){let t=e.trim();if(t.length===0)return null;if(t.startsWith(`"`)||t.startsWith(`'`)){let e=t.charAt(0),n=t.indexOf(e,1);return n<=0?null:{executable:t.slice(0,n+1),rest:t.slice(n+1).trim()}}let n=t.search(/\s/);return n<0?{executable:t,rest:``}:{executable:t.slice(0,n),rest:t.slice(n).trim()}}var tE=[{executables:[`pwsh`,`pwsh.exe`,`powershell`,`powershell.exe`],wrapperFlagPattern:/(?:^|\s)-command\s+/i},{executables:[`cmd`,`cmd.exe`],wrapperFlagPattern:/(?:^|\s)\/c\s+/i},{executables:[`bash`,`sh`,`zsh`],wrapperFlagPattern:/(?:^|\s)-(?:l)?c\s+/i}];function nE(e){return tE.find(t=>t.executables.includes(e))}function rE(e,t){let n=t.exec(e);if(!n)return null;let r=e.slice(n.index+n[0].length).trim();if(r.length===0)return null;let i=r[0];if((i===`'`||i===`"`)&&!r.endsWith(i))return null;let a=QT(r);return a.length>0?a:null}function iE(e){let t=eE(e);if(!t||t.rest.length===0)return e;let n=$T(t.executable);if(!n)return e;let r=nE(n);return r?rE(t.rest,r.wrapperFlagPattern)??e:e}function aE(e){return/[\s"'`]/.test(e)?`"${e.replace(/"/g,`\\"`)}"`:e}function oE(e){let t=ZT(e);if(t)return t;if(!Array.isArray(e))return null;let n=[];for(let t of e){let e=ZT(t);e!==null&&n.push(e)}return n.length===0?null:n.map(e=>aE(e)).join(` `)}function sE(e){let t=oE(e);return t?iE(t):null}function cE(e,t){let n=oE(e);return!n||t===null||n===t?null:n}function lE(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function uE(e){return typeof e==`string`&&e.trim().length>0?e:null}function dE(e){let t=uE(e);if(t)return t;let n=Array.isArray(e)?e:null,r=lE(e)?.content,i=uE(r);if(i)return i;let a=n??(Array.isArray(r)?r:null);if(!a)return null;let o=a.flatMap(e=>{let t=uE(e)??uE(lE(e)?.text);return t?[t]:[]});return o.length>0?o.join(`
|
|
17
|
+
`):null}function fE(e){let t=lE(e),n=lE(t?.item),r=lE(n?.result),i=lE(t?.rawOutput),a=[uE(i?.stdout),uE(i?.stderr)].filter(e=>e!==null),o=Array.isArray(t?.content)?t.content.flatMap(e=>{let t=lE(e),n=lE(t?.content),r=t?.type===`content`?uE(n?.text):null;return r?[r]:[]}).join(`
|
|
18
18
|
`):null,s=[n?.aggregatedOutput,r?.content,t?.rawOutput,i?.content,a.length>0?a.join(`
|
|
19
|
-
`):null,i?.output,o,t?.result];for(let e of s){let t=
|
|
20
|
-
`)}function R(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}var jT={};function MT(e){return typeof e==`string`&&e.trim().length>0}function NT(e){let t=R(e);if(!t||!MT(t.requestId)||!R(t.answers)||!R(t.attachmentsByQuestionId))return!1;let n=R(t.questionTextById);if(t.questionTextById!==void 0&&!n)return!1;if(n){for(let e of Object.values(n))if(typeof e!=`string`)return!1}for(let e of Object.values(t.attachmentsByQuestionId)){if(!Array.isArray(e))return!1;for(let t of e){let e=R(t);if(!e||!MT(e.id)||!MT(e.name))return!1}}return!0}function PT(e,t){if(typeof e==`string`)return t.get(e)??e;if(Array.isArray(e))return e.map(e=>PT(e,t));let n=R(e);return n&&`answers`in n?{...n,answers:PT(n.answers,t)}:e}function FT(e,t){let n=t.map(e=>typeof e==`string`?e.trim():``);return n.length>0&&n.every(Boolean)?JSON.stringify([e,n.sort()]):void 0}function IT(e){return e&&typeof e==`object`?e:null}function LT(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function RT(e,t){let n=IT(e.item),r=e.toolName??e.tool??n?.tool??t;if(typeof r!=`string`)return{};let i=r.split(/__|[./]/).at(-1)?.replace(/[_\s]/g,``).toLowerCase();if(!i||!/^(askuserquestion|requestuserinput(?:async)?|askquestion|question)$/.test(i))return{};let a=IT(e.input??e.rawInput??IT(e.state)?.input??n?.arguments),o=a?.questions??IT(a?.params)?.questions;return Array.isArray(o)?{input:{questions:o.map(e=>{let t=IT(e);return{question:LT(t?.question??t?.question_text??t?.prompt??t?.title)}})}}:{}}function zT(e){let t=new Set;for(let n of e){if(n.kind!==`user-input.answer-submitted`||!n.turnId)continue;let e=R(n.payload),r=Object.values(R(e?.questionTextById)??jT),i=FT(n.turnId,r);i&&t.add(i)}if(t.size===0)return e;let n=new Set;for(let r of e){if(!r.kind.startsWith(`tool.`)||!r.turnId)continue;let e=R(r.payload);if(typeof e?.toolCallId!=`string`)continue;let i=RT(R(e.data)??{},e.title).input;if(!i)continue;let a=FT(r.turnId,i.questions.map(e=>e.question));a&&t.has(a)&&n.add(JSON.stringify([r.turnId,e.toolCallId]))}return e.filter(e=>{let t=R(e.payload),r=t?.toolCallId;return e.tone===`error`||/^(failed|declined|stopped|cancelled)$/.test(String(t?.status))||!e.kind.startsWith(`tool.`)||typeof r!=`string`||!n.has(JSON.stringify([e.turnId,r]))})}function BT(e){let t=new Map;for(let n of e){if(n.kind!==`user-input.requested`&&n.kind!==`user-input.resolved`&&n.kind!==`user-input.answer-submitted`)continue;let e=R(n.payload)?.requestId;if(typeof e!=`string`||!e)continue;let r=t.get(e)??[];r.push(n),t.set(e,r)}let n=new Map;for(let[e,r]of t){let t=r.map(e=>R(e.payload)),i=new Map,a=new Map;for(let e of t){for(let[t,n]of Object.entries(R(e.questionTextById)??jT))a.set(t,n);for(let t of Array.isArray(e.questions)?e.questions:[]){let e=R(t);typeof e?.id==`string`&&(i.set(e.id,e),typeof e.question==`string`&&a.set(e.id,e.question))}}let o=Object.fromEntries(a),s=R(R(r.findLast(e=>e.kind===`user-input.answer-submitted`&&R(R(e.payload)?.answers))?.payload)?.answers)??t.map(e=>R(e.answers)).findLast(Boolean)??{},c=Object.fromEntries(Object.entries(s).map(([e,t])=>{let n=i.get(e)?.options,r=new Map;for(let e of Array.isArray(n)?n:[]){let t=R(e);typeof t?.label==`string`&&(typeof t.value==`string`&&r.set(t.value,t.label),r.set(t.label,t.label))}return[e,PT(t,r)]})),l=Object.fromEntries(t.flatMap(e=>Object.entries(R(e.attachmentsByQuestionId)??jT))),u={requestId:e,questionTextById:o,answers:c,attachmentsByQuestionId:l};if(!NT(u))continue;let d=Object.keys(c).length>0||Object.keys(l).length>0;for(let e of r)n.set(e,null);n.set(r[0],{...r[0],kind:`user-input.answer-submitted`,tone:`tool`,summary:d?`User input submitted`:r.some(e=>e.kind===`user-input.resolved`)?`User input dismissed`:`User input requested`,payload:u})}return zT(e.flatMap(e=>{let t=n.get(e);return t===null?[]:[t??e]}))}function VT(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(VT).filter(Boolean).join(`, `);let t=R(e);return t?VT(t.answers):``}function HT(e){let t=Object.values(e.answers).map(VT).filter(Boolean),n=Object.values(e.attachmentsByQuestionId).flat().map(e=>e.name);return(t.length>0?t.join(` · `):n.length>0?n.join(`, `):Object.values(e.questionTextById??{}).join(` · `)).replace(/\s+/g,` `).trim()}function UT(e){return Object.values(e.answers).some(VT)||Object.values(e.attachmentsByQuestionId).some(e=>e.length>0)}function WT(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function GT(e,t){if(typeof e!=`string`)return;let n=e.trim();return n&&n.length<=t?n:void 0}function KT(e){let t=GT(e,4096);if(t)try{let e=new URL(t);return e.protocol===`http:`||e.protocol===`https:`||e.protocol===`data:`?e.href:void 0}catch{return}}function qT(e){let t=GT(e,4096);if(t)try{let e=new URL(t);return e.protocol===`http:`||e.protocol===`https:`?e.href:void 0}catch{return}}function JT(e){let t=WT(e),n=GT(t?.appId,512);if(t?._tag===`app-id`&&n&&/^[A-Za-z0-9._-]+$/u.test(n))return{_tag:`app-id`,appId:n};let r=GT(t?.displayName,160);if(t?._tag===`display-name`&&r)return{_tag:`display-name`,displayName:r}}function YT(e){let t=WT(e);if(t?._tag===`website`){let e=qT(t.pageUrl),n=KT(t.faviconUrl),r=KT(t.faviconUrlDark);if(e)return{_tag:`website`,pageUrl:e,...n?{faviconUrl:n}:{},...r?{faviconUrlDark:r}:{}}}if(t?._tag===`native-app`){let e=JT(t.app);if(e)return{_tag:`native-app`,app:e}}if(t?._tag===`themed-logo`){let e=KT(t.logoUrl),n=KT(t.logoUrlDark);if(e)return{_tag:`themed-logo`,logoUrl:e,...n?{logoUrlDark:n}:{}}}}function XT(e){let t=WT(e),n=GT(t?.key,512),r=GT(t?.name,160),i=t?.kind;if(!n||!r||i!==`browser`&&i!==`computer`&&i!==`integration`)return;let a=YT(t?.icon);return{key:n,name:r,kind:i,...a?{icon:a}:{}}}function ZT(e){let t=WT(e),n=t?.toolSurface===`browser`||t?.toolSurface===`computer`?t.toolSurface:void 0,r=YT(t?.toolIcon),i=XT(t?.toolSource);return{...n?{toolSurface:n}:{},...r?{toolIcon:r}:{},...i?{toolSource:i}:{}}}function QT(e,t,n){return e===t||e.endsWith(`.${t}`)?!0:n!==void 0&&e.split(`.`).includes(n)}function $T(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`&&t.protocol!==`http:`)return null;let n=t.hostname.toLowerCase();if(QT(n,`github.com`,`github`)){let e=/^\/([^/]+\/[^/]+)\/pull\/(\d+)(?:\/|$)/u.exec(t.pathname);if(e)return eE(n,e)}let r=/^\/([^/]+(?:\/[^/]+)+)\/pulls\/(\d+)(?:\/|$)/u.exec(t.pathname);if(r){let e=eE(n,r);return e===null?null:{...e,authority:t.host.toLowerCase()}}let i=/^\/([^/]+(?:\/[^/]+)+)\/-\/merge_requests\/(\d+)(?:\/|$)/u.exec(t.pathname);return i?eE(n,i):QT(n,`bitbucket.org`,`bitbucket`)?eE(n,/^\/([^/]+\/[^/]+)\/pull-requests\/(\d+)(?:\/|$)/u.exec(t.pathname)):QT(n,`dev.azure.com`)||n.endsWith(`.visualstudio.com`)?eE(n,/^\/((?:[^/]+\/)*_git\/[^/]+)\/pullrequest\/(\d+)(?:\/|$)/u.exec(t.pathname)):null}function eE(e,t){let n=t?.[1],r=Number(t?.[2]);return n&&Number.isSafeInteger(r)&&r>0?{host:e,repository:n.toLowerCase(),number:r}:null}function tE(e){return e.replace(/\s+(?:complete|completed)\s*$/i,``).trim()}var nE={link_pull_request:[`Link`,`Linking`,`Linked`,`a pull request`],unlink_pull_request:[`Unlink`,`Unlinking`,`Unlinked`,`a pull request`],list_thread_pull_requests:[`Check`,`Checking`,`Checked`,`linked pull requests`],orchestrator_capabilities:[`Get`,`Getting`,`Got`,`orchestration capabilities`],delegate_task:[`Delegate`,`Delegating`,`Delegated`,`a child task`],task_status:[`Get`,`Getting`,`Got`,`delegated task status`],task_cancel:[`Cancel`,`Canceling`,`Canceled`,`delegated task`],schedule_task:[`Schedule`,`Scheduling`,`Scheduled`,`a recurring task`],list_scheduled_tasks:[`List`,`Listing`,`Listed`,`scheduled tasks`],update_scheduled_task:[`Update`,`Updating`,`Updated`,`a scheduled task`],delete_scheduled_task:[`Delete`,`Deleting`,`Deleted`,`a scheduled task`],create_threads:[`Create`,`Creating`,`Created`,`T3 threads`],t3_thread_start:[`Start`,`Starting`,`Started`,`a T3 thread`],t3_thread_list:[`List`,`Listing`,`Listed`,`T3 threads`],t3_thread_read:[`Read`,`Reading`,`Read`,`a T3 thread`],t3_thread_send:[`Send`,`Sending`,`Sent`,`to a T3 thread`],t3_thread_wait:[`Wait`,`Waiting`,`Waited`,`for a T3 thread`],t3_thread_interrupt:[`Interrupt`,`Interrupting`,`Interrupted`,`a T3 thread`],t3_worktree_handoff:[`Hand off`,`Handing off`,`Handed off`,`thread to a git worktree`],t3_worktree_status:[`Get`,`Getting`,`Got`,`thread worktree status`],preview_status:[`Get`,`Getting`,`Got`,`preview browser status`],preview_open:[`Open`,`Opening`,`Opened`,`a page in the preview browser`],preview_navigate:[`Navigate`,`Navigating`,`Navigated`,`the preview browser`],preview_snapshot:[`Take a snapshot of`,`Taking a snapshot of`,`Took a snapshot of`,`the preview page`],preview_click:[`Click`,`Clicking`,`Clicked`,`in the preview browser`],preview_press:[`Press`,`Pressing`,`Pressed`,`a key in the preview browser`],preview_type:[`Type`,`Typing`,`Typed`,`in the preview browser`],preview_scroll:[`Scroll`,`Scrolling`,`Scrolled`,`the preview browser`],preview_resize:[`Resize`,`Resizing`,`Resized`,`the preview browser`],preview_evaluate:[`Evaluate`,`Evaluating`,`Evaluated`,`script in the preview browser`],preview_wait_for:[`Wait`,`Waiting`,`Waited`,`for the preview page`],preview_set_appearance:[`Set`,`Setting`,`Set`,`preview browser appearance`],preview_recording_start:[`Start`,`Starting`,`Started`,`recording the preview browser`],preview_recording_stop:[`Stop`,`Stopping`,`Stopped`,`recording the preview browser`],device_list:[`List`,`Listing`,`Listed`,`simulators and emulators`],device_open:[`Open`,`Opening`,`Opened`,`a device in the Device panel`],device_screenshot:[`Take a screenshot of`,`Taking a screenshot of`,`Took a screenshot of`,`the device`],device_close:[`Close`,`Closing`,`Closed`,`a device`]},rE={link_pull_request:`link-pr`,unlink_pull_request:`unlink-pr`,list_thread_pull_requests:`list-prs`};function iE(e,t,n){if(!e)return null;let r=tE(e).replace(/^(?:mcp__(?:t3-code|t3_code|t3code)__|(?:t3-code|t3_code|t3code)(?:[.:/]|\s*·\s*))/i,``);if(!Object.hasOwn(nE,r))return null;let[i,a,o,s]=nE[r],c=t===`inProgress`?a:t===`completed`?o:t===`failed`?`Failed to ${i.toLowerCase()}`:t===`declined`?`Declined to ${i.toLowerCase()}`:t===`stopped`?`Stopped ${a.toLowerCase()}`:a,l=Object.hasOwn(rE,r)?rE[r]:void 0,u=sE(n),d=sE(u?.arguments)??sE(u?.input)??sE(u?.rawInput),f=(typeof d?.url==`string`?$T(d.url):null)?.number??d?.number;return{displayName:`${c} ${l!==void 0&&l!==`list-prs`&&typeof f==`number`&&Number.isSafeInteger(f)&&f>0?`PR #${f}`:s}`,icon:l===void 0?r.startsWith(`preview_`)?`browser`:r.startsWith(`device_`)?`device`:`t3-code`:`pull-request`,...l===void 0?{}:{action:l}}}function aE(e,t){return e===`failed`||e===`declined`||e===`stopped`?e:t||e===`inProgress`?`inProgress`:`completed`}function oE(e,t){let n=e.toolLifecycleStatus??t,r=e.toolData;if(typeof r==`object`&&r){if(`server`in r&&typeof r.server==`string`&&`tool`in r&&typeof r.tool==`string`)return iE(`${r.server}.${r.tool}`,n,r);if(`toolName`in r&&typeof r.toolName==`string`)return iE(r.toolName,n,r)}return iE(e.toolTitle,n,r)??iE(e.label,n,r)}function sE(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function cE(e){let t=sE(e);switch(t?.status){case`pending`:case`running`:case`waiting`:return`inProgress`;case`cancelled`:case`interrupted`:return`stopped`;case`idle`:return t.taskType===`subagent_batch`?`stopped`:void 0;case`inProgress`:case`completed`:case`failed`:case`declined`:case`stopped`:return t.status;default:return}}function lE(e){return e.tone===`tool`||e.tone===`thinking`||e.tone===`error`||e.command!==void 0&&e.command.trim().length>0||e.requestKind!==void 0||e.itemType!==void 0&&Kr(e.itemType)}function uE(e){let t=e.toLowerCase();return t.includes(`file not found`)||t.includes(`no files found`)||t.includes(`enoent`)||t.includes(`no such file or directory`)||t.includes(`no such file`)||t.includes(`commandnotfoundexception`)||t.includes(`command not found`)||t.includes(`cannot find path`)&&t.includes(`because it does not exist`)||t.includes(`is not recognized`)&&t.includes(`the term '`)||t.includes(`is not recognized as the name of a cmdlet`)||t.includes(`a parameter cannot be found that matches parameter name`)||/<exited with exit code\s+[1-9]\d*\s*>/i.test(e)||/exit(?:ed)? with exit code\s+[1-9]\d*/i.test(e)||/exit code\s*[:\s]\s*[1-9]\d*\b/i.test(e)}function dE(e,t){if(e.tone===`error`||e.toolLifecycleStatus===`failed`||e.toolLifecycleStatus===`declined`)return!0;if(!lE(e))return!1;let n=t?[e.detail,e.command].filter(Boolean).join(`
|
|
21
|
-
`):e.detail??``;return n.length>0&&uE(n)}function fE(e){return dE(e,!0)}function pE(e){return dE(e,!1)}function mE(e){return lE(e)&&!fE(e)&&e.tone!==`thinking`&&e.toolLifecycleStatus!==`inProgress`&&e.toolLifecycleStatus!==`stopped`}function hE(e){let t=e.taskId??``,n=t.indexOf(`:wf:`);return n===-1?e.agentSpawn?.workflowId?`wf:${e.agentSpawn.workflowId}`:e.isWorkflowCoordinator?`wf:${t}`:e.turnId?`direct:${e.turnId}`:`direct:task:${t}`:`wf:${t.slice(0,n)}`}function gE(e){if(e.sourceActivityKind===`tool.updated`||e.sourceActivityKind===`tool.completed`)return e.toolCallId?`tool:${e.turnId??`no-turn`}:${e.toolCallId}`:void 0}function _E(e){let t=[],n=new Map,r=new Map,i=new Map;for(let a of e){if(a.taskId!==void 0&&!a.isBackgroundTask&&(a.sourceActivityKind===`task.started`||a.sourceActivityKind===`task.progress`||a.sourceActivityKind===`task.completed`)&&a.taskId!==void 0){let e=r.get(a.taskId),i=e??hE(a);e===void 0&&r.set(a.taskId,i);let o=i.startsWith(`wf:`)?i.slice(3):null,s=n.get(i);if(s!==void 0){let e=t[s],n=e.agentSpawn?.agentTaskIds.includes(a.taskId)?e.agentSpawn.agentTaskIds:[...e.agentSpawn?.agentTaskIds??[],a.taskId];t[s]={...yE(e,a),id:e.id,createdAt:e.createdAt,turnId:e.turnId??null,...e.taskId===void 0?{}:{taskId:e.taskId},label:e.label,agentSpawn:{workflowId:o,agentTaskIds:n}};continue}n.set(i,t.length),t.push({...a,agentSpawn:{workflowId:o,agentTaskIds:[a.taskId]}});continue}let e=gE(a);if(e!==void 0){let n=i.get(e),r=n===void 0?void 0:t[n];if(n!==void 0&&r&&vE(r,a)){t[n]=yE(r,a);continue}i.delete(e)}let o=t.at(-1);if(o&&vE(o,a)){let e=t.length-1,n=gE(o);n!==void 0&&i.delete(n);let r=yE(o,a);t[e]=r;let s=gE(r);s!==void 0&&i.set(s,e);continue}t.push(a),e!==void 0&&i.set(e,t.length-1)}return t}function vE(e,t){return e.sourceActivityKind!==`tool.updated`&&e.sourceActivityKind!==`tool.completed`||t.sourceActivityKind!==`tool.updated`&&t.sourceActivityKind!==`tool.completed`||e.turnId!==t.turnId||e.sourceActivityKind===`tool.completed`?!1:e.collapseKey!==void 0&&e.collapseKey===t.collapseKey||e.toolCallId!==void 0&&t.toolCallId===void 0&&e.itemType===t.itemType&&tE(e.toolTitle??e.label)===tE(t.toolTitle??t.label)}function yE(e,t){let n=bE(e.changedFiles,t.changedFiles),r=t.detail??e.detail,i=t.viewedImagePath??e.viewedImagePath,a=t.command??e.command,o=t.rawCommand??e.rawCommand,s=t.toolTitle??e.toolTitle,c=t.toolSurface??e.toolSurface,l=t.toolIcon??e.toolIcon,u=t.toolSource??e.toolSource,d=t.itemType??e.itemType,f=t.requestKind??e.requestKind,p=t.collapseKey??e.collapseKey,m=t.toolCallId??e.toolCallId,h=t.toolLifecycleStatus??e.toolLifecycleStatus,g=t.toolData??e.toolData;return{...e,...t,...r?{detail:r}:{},...i?{viewedImagePath:i}:{},...a?{command:a}:{},...o?{rawCommand:o}:{},...n.length>0?{changedFiles:n}:{},...s?{toolTitle:s}:{},...c?{toolSurface:c}:{},...l?{toolIcon:l}:{},...u?{toolSource:u}:{},...d?{itemType:d}:{},...f?{requestKind:f}:{},...p?{collapseKey:p}:{},...m?{toolCallId:m}:{},...h===void 0?{}:{toolLifecycleStatus:h},...g===void 0?{}:{toolData:g}}}function bE(e,t){let n=[...e??[],...t??[]];return n.length===0?[]:[...new Set(n)]}function xE(e){if(e.taskId&&(e.sourceActivityKind===`task.progress`||e.sourceActivityKind===`task.completed`))return`task${e.taskId}`;if(e.sourceActivityKind!==`tool.updated`&&e.sourceActivityKind!==`tool.completed`)return;if(e.toolCallId)return`tool:${e.turnId??`no-turn`}:${e.toolCallId}`;let t=tE(e.toolTitle??e.label),n=e.detail?.trim()??``,r=e.itemType??``;if(t.length!==0||n.length!==0||r.length!==0)return[r,t,n].join(``)}function SE(e){let t=OE(e?.data);return kE(e?.toolCallId)??kE(t?.toolCallId)}function CE(e){switch(e){case`command_execution_approval`:case`exec_command_approval`:return`command`;case`file_read_approval`:return`file-read`;case`file_change_approval`:case`apply_patch_approval`:return`file-change`;default:return null}}function wE(e){return e?.requestKind===`command`||e?.requestKind===`file-read`||e?.requestKind===`file-change`?e.requestKind:CE(e?.requestType)??void 0}function TE(e,t,n){let r=kE(n);!r||t.has(r)||(t.add(r),e.push(r))}function EE(e,t,n,r){if(r>4||t.length>=12)return;if(Array.isArray(e)){for(let i of e)if(EE(i,t,n,r+1),t.length>=12)return;return}let i=OE(e);if(i){TE(t,n,i.path),TE(t,n,i.filePath),TE(t,n,i.relativePath),TE(t,n,i.filename),TE(t,n,i.newPath),TE(t,n,i.oldPath);for(let e of[`item`,`result`,`input`,`data`,`changes`,`files`,`edits`,`patch`,`patches`,`operations`])if(e in i&&(EE(i[e],t,n,r+1),t.length>=12))return}}function DE(e){let t=[],n=new Set;return EE(OE(e?.data),t,n,0),t}function OE(e){return e&&typeof e==`object`?e:null}function kE(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}var AE=new WeakMap;function jE(e){return!(e.agentSpawn!==void 0||!lE(e)||fE(e)||mE(e))}function ME(e){let t=AE.get(e);if(t)return t;let n=e.payload&&typeof e.payload==`object`?e.payload:null,r=Aw(n),i=DE(n),a=mT(n),o=ZT(n),s=e.kind===`task.progress`||e.kind===`task.completed`,c=s&&typeof n?.summary==`string`&&n.summary.length>0?n.summary:null,l=s&&!c&&typeof n?.detail==`string`&&n.detail.length>0?n.detail:null,u=c||l,d=s?!l&&n&&typeof n.detail==`string`&&n.detail.length>0?jw(n.detail).output:null:cT(n,a??e.summary),f=s?null:SE(n),p={id:e.id,createdAt:e.createdAt,turnId:e.turnId,label:u||e.summary,tone:e.kind===`task.progress`?`thinking`:e.tone,sourceActivityKind:e.kind};if(e.kind===`user-input.answer-submitted`){let e=n&&NT(n)?n:null;e&&(p.questionAnswer={requestId:e.requestId,questionTextById:e.questionTextById,answers:e.answers,attachmentsByQuestionId:e.attachmentsByQuestionId})}let m=$w(n),h=wE(n),g=kE(OE(n?.data)?.imagePath);if(d)p.detail=d;else if(e.kind===`runtime.error`||e.kind===`runtime.warning`){let t=Qw(n,e.summary);t&&(p.detail=t)}if(g&&(p.viewedImagePath=g),r.command&&(p.command=r.command),r.rawCommand&&(p.rawCommand=r.rawCommand),i.length>0&&(p.changedFiles=i),a&&(p.toolTitle=a),o.toolSurface&&(p.toolSurface=o.toolSurface),o.toolIcon&&(p.toolIcon=o.toolIcon),o.toolSource&&(p.toolSource=o.toolSource),m===`mcp_tool_call`){let e=OE(n?.data),t=typeof e?.toolName==`string`?e.item??e:e?.item;t!==void 0&&(p.toolData=t)}m&&(p.itemType=m),h&&(p.requestKind=h),f&&(p.toolCallId=f);let _=cE(n);!_&&e.kind===`tool.completed`&&(_=`completed`),_&&(p.toolLifecycleStatus=_);let v=e.kind===`task.started`||e.kind===`task.progress`||e.kind===`task.completed`;v&&typeof n?.taskId==`string`&&n.taskId.length>0&&(p.taskId=n.taskId),v&&typeof n?.role==`string`&&n.role.length>0&&(p.agentRole=n.role),v&&(n?.taskType===`local_workflow`||typeof n?.workflowName==`string`&&n.workflowName.length>0)&&(p.isWorkflowCoordinator=!0),v&&n&&n.agentKind!==`agent`&&(p.isBackgroundTask=!0);let y=yT(n);if(y)p.githubConfirmation=y,p.tone=`approval`,p.label=`GitHub action needs approval`,p.toolTitle=CT(y.operation),p.detail=wT(y);else{let e=bT(n);e&&(p.githubActionRequired=e,p.tone=`approval`,p.label=TT(e.action),p.toolTitle=`GitHub setup required`,p.detail=DT(e))}let b=xE(p);return b&&(p.collapseKey=b),AE.set(e,p),p}var NE=new Set([`tool.started`,`task.started`,`context-window.updated`,`text-generation.usage`,`worktree.stage`,`launch.agent-starting`,`turn.terminal-status`]);function PE(e){return NE.has(e.kind)||e.summary===`Checkpoint captured`}function FE(e,t){return!t.latestTurnId||e.turnId===t.latestTurnId||IE(e)?!0:LE(e,t.latestTurnStartedAt)}function IE(e){return e.kind.startsWith(`worktree.`)||e.kind.startsWith(`setup-script.`)}function LE(e,t){return e.turnId!==null||e.tone!==`error`||t===null?!1:e.createdAt>=t}function RE(e){return e.agentKind===`agent`}function zE(e){let t=e.payload&&typeof e.payload==`object`?e.payload:null;return!t||typeof t.taskId!=`string`?!1:RE(t)}function BE(e){let t=e.payload&&typeof e.payload==`object`?e.payload:null;return t?e.kind===`task.started`||e.kind===`task.progress`||e.kind===`task.updated`||e.kind===`task.completed`?typeof t.agentId==`string`&&t.agentId.trim().length>0||t.timelineBypass===!0?!(e.kind!==`task.updated`&&typeof t.taskId==`string`&&RE(t)):!1:t.timelineBypass===!0||typeof t.agentId==`string`&&t.agentId.trim().length>0:!1}function VE(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`forge:debug-mode`)===`true`}catch{return!1}}function HE(e){if(e.kind!==`tool.updated`&&e.kind!==`tool.completed`)return!1;let t=e.payload&&typeof e.payload==`object`?e.payload:null;return typeof t?.detail==`string`&&t.detail.startsWith(`ExitPlanMode:`)}function UE(e,t,n){let r=VE(),i={latestTurnId:t,latestTurnStartedAt:n??null},a=[...e].toSorted(WE),o=new Set;for(let e of a)if((e.kind===`task.started`||e.kind===`task.progress`||e.kind===`task.completed`)&&zE(e)){let t=kE(OE(e.payload)?.toolUseId);t&&o.add(t)}let s=[];for(let e of BT(a)){if(!FE(e,i)||!(e.kind===`task.started`&&zE(e))&&PE(e)||e.kind===`task.started`&&!zE(e)||e.kind===`task.updated`||e.kind===`tool.progress`||e.kind===`turn.plan.updated`||!r&&Zw(e)||HE(e)||BE(e))continue;let t=ME(e);if(e.kind===`tool.updated`&&t.itemType===`collab_agent_tool_call`&&t.toolLifecycleStatus===`inProgress`&&t.tone!==`error`){let t=OE(OE(e.payload)?.data)?.toolName;if(t===`Agent`||t===`Task`)continue}(e.kind===`tool.updated`||e.kind===`tool.completed`)&&t.toolCallId&&o.has(t.toolCallId)&&t.tone!==`error`&&t.toolLifecycleStatus!==`failed`||s.push(t)}return _E(s).map(({sourceActivityKind:e,collapseKey:t,isWorkflowCoordinator:n,isBackgroundTask:r,...i})=>i)}function WE(e,t){if(e.sequence!==void 0&&t.sequence!==void 0){if(e.sequence!==t.sequence)return e.sequence-t.sequence}else if(e.sequence!==void 0)return 1;else if(t.sequence!==void 0)return-1;let n=e.createdAt.localeCompare(t.createdAt);if(n!==0)return n;let r=GE(e.kind)-GE(t.kind);return r===0?e.id.localeCompare(t.id):r}function GE(e){return e.endsWith(`.started`)||e===`tool.started`?0:e.endsWith(`.progress`)||e.endsWith(`.updated`)?1:e.endsWith(`.completed`)||e.endsWith(`.resolved`)?2:1}function KE(e){return{id:e.id,kind:`message`,createdAt:e.createdAt,message:e}}function qE(e){return{id:e.id,kind:`proposed-plan`,createdAt:e.createdAt,proposedPlan:e}}function JE(e){return{id:e.id,kind:`work`,createdAt:e.createdAt,entry:e}}function YE(e,t){return e.createdAt.localeCompare(t.createdAt)}function XE(e){switch(e.kind){case`message`:return 0;case`proposed-plan`:return 1;case`work`:return 2}}function ZE(e,t){let n=YE(e,t);return n===0?XE(e)<=XE(t):n<0}function QE(e,t){if(e===t)return!0;if(t.length<e.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function $E(e,t){if(t.length===0)return[...e];let n=e.at(-1),r=!0;for(let e=1;e<t.length;e+=1)if(YE(t[e-1],t[e])>0){r=!1;break}if(r&&(n===void 0||ZE(n,t[0])))return[...e,...t];let i=[],a=0,o=0;for(;a<e.length||o<t.length;){let n=e[a],r=t[o];n!==void 0&&(r===void 0||ZE(n,r))?(i.push(n),a+=1):r!==void 0&&(i.push(r),o+=1)}return i}var eD=e=>e===`assistant`||e===`reasoning`;function tD(e,t){if(!eD(e.role)||e.role!==t.role||!e.streaming||!t.streaming)return!1;let{text:n,updatedAt:r,...i}=e,{text:a,updatedAt:o,...s}=t;return $m(i,s)}function nD(e,t){if(e.length!==t.messages.length)return null;let n=new Map;for(let[r,i]of e.entries()){let e=t.messages[r];if(i!==e){if(!tD(e,i))return null;n.set(e,i)}}return n.size===0?t.entries:t.entries.map(e=>{let t=e.kind===`message`?n.get(e.message):void 0;return t?KE(t):e})}function rD(e,t,n,r=null){if(r!==null&&r.proposedPlans.length===t.length&&r.workEntries.length===n.length&&QE(r.proposedPlans,t)&&QE(r.workEntries,n)){let i=nD(e,r);if(i!==null)return{messages:e,proposedPlans:t,workEntries:n,entries:i}}let i=new Set(n.flatMap(e=>e.questionAnswer?[`async-answer:${e.questionAnswer.requestId}`]:[])),a=e=>e.role!==`user`||!i.has(e.id);if(r!==null&&!r.entries.some(e=>e.kind===`message`&&!a(e.message))&&QE(r.messages,e)&&QE(r.proposedPlans,t)&&QE(r.workEntries,n)){let i=e.slice(r.messages.length).filter(a).map(KE),o=t.slice(r.proposedPlans.length).map(qE),s=n.slice(r.workEntries.length).map(JE),c=[...i,...o,...s].toSorted(YE);return{messages:e,proposedPlans:t,workEntries:n,entries:$E(r.entries,c)}}let o=e.filter(a).map(KE),s=t.map(qE),c=n.map(JE);return{messages:e,proposedPlans:t,workEntries:n,entries:[...o,...s,...c].toSorted(YE)}}var iD=[{value:`codex`,label:`Codex`,available:!0},{value:`claudeAgent`,label:`Claude`,available:!0},{value:`cmmd`,label:`CMMD`,available:!0},{value:`ollama`,label:`Ollama`,available:!1},{value:`cursor`,label:`Cursor`,available:!1}];function aD(e){if(!Number.isFinite(e)||e<0)return`0ms`;if(e<1e3)return`${Math.max(1,Math.round(e))}ms`;if(e<1e4)return`${(e/1e3).toFixed(1)}s`;if(e<6e4)return`${Math.round(e/1e3)}s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return n===0?`${t}m`:n===60?`${t+1}m`:`${t}m ${n}s`}function oD(e,t){if(!t)return null;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)||r<n?null:aD(r-n)}function sD(e,t){return!e?.startedAt||!e.completedAt?!1:!t||t.orchestrationStatus!==`running`}function cD(e,t,n){let r=t?.orchestrationStatus===`running`?t.activeTurnId??null:null;return r===null?sD(e,t)?n:e?.startedAt??n:e?.turnId===r?e.startedAt??n:n}function lD(e){let t=e?.toLowerCase();return t?t.includes(`stale pending approval request`)||t.includes(`stale pending user-input request`)||t.includes(`unknown pending approval request`)||t.includes(`unknown pending permission request`)||t.includes(`unknown pending user-input request`):!1}function uD(e){let t=new Map,n=[...e].toSorted(WE);for(let e of n){let n=e.payload&&typeof e.payload==`object`?e.payload:null,r=n&&typeof n.requestId==`string`?Ar.make(n.requestId):null,i=n&&(n.requestKind===`command`||n.requestKind===`file-read`||n.requestKind===`file-change`)?n.requestKind:n?CE(n.requestType):null,a=n&&typeof n.detail==`string`?n.detail:void 0;if(e.kind===`approval.requested`&&r&&i){t.set(r,{requestId:r,requestKind:i,createdAt:e.createdAt,...a?{detail:a}:{}});continue}if(e.kind===`approval.resolved`&&r){t.delete(r);continue}if(e.kind===`provider.approval.respond.failed`&&r&&lD(a)){t.delete(r);continue}}return[...t.values()].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function dD(e){let t=e?.questions;if(!Array.isArray(t))return null;let n=t.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.id!=`string`||typeof t.header!=`string`||typeof t.question!=`string`||!Array.isArray(t.options))return null;let n=t.options.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return typeof t.label!=`string`||typeof t.description!=`string`?null:{label:t.label,description:t.description}}).filter(e=>e!==null);return n.length===0?null:{id:t.id,header:t.header,question:t.question,options:n,multiSelect:t.multiSelect===!0}}).filter(e=>e!==null);return n.length>0?n:null}function fD(e){let t=new Map,n=[...e].toSorted(WE);for(let e of n){let n=e.payload&&typeof e.payload==`object`?e.payload:null,r=n&&typeof n.requestId==`string`?Ar.make(n.requestId):null,i=n&&typeof n.detail==`string`?n.detail:void 0;if(e.kind===`user-input.requested`&&r){let i=dD(n);if(!i)continue;t.set(r,{requestId:r,createdAt:e.createdAt,questions:i});continue}if(e.kind===`user-input.resolved`&&r){t.delete(r);continue}e.kind===`provider.user-input.respond.failed`&&r&&lD(i)&&t.delete(r)}return[...t.values()].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function pD(e,t){if(!t)return null;let n=[...e].toSorted(WE),r=null;for(let e of n){let t=bT(e.payload&&typeof e.payload==`object`?e.payload:null);t&&(r={request:t,turnId:e.turnId})}return!r||r.turnId!==t?null:r.request}function mD(e,t){let n=[...e].toSorted(WE),r=n.filter(e=>e.kind===`turn.plan.updated`),i=(t?r.findLast(e=>e.turnId===t):void 0)??r.at(-1)??null;if(!i)return null;let a=Dw(i);if(!a)return null;let o=r.filter(e=>e.turnId===i.turnId),s=o.findLastIndex(e=>Dw(e)===null),c=kw(a,o.slice(s+1)),l=i.turnId!==null&&n.some(e=>e.kind===`turn.completed`&&e.turnId===i.turnId&&WE(i,e)<0);return{...c,steps:l?c.steps.map(e=>e.status===`inProgress`?{...e,status:`completed`}:e):c.steps}}function hD(e,t){if(t){let n=[...e].filter(e=>e.turnId===t).toSorted((e,t)=>e.updatedAt.localeCompare(t.updatedAt)||e.id.localeCompare(t.id)).at(-1);if(n)return jD(n)}let n=[...e].toSorted((e,t)=>e.updatedAt.localeCompare(t.updatedAt)||e.id.localeCompare(t.id)).at(-1);return n?jD(n):null}function gD(e){let t=e.threads.find(t=>t.id===e.threadId)?.proposedPlans??[];if(!e.latestTurnSettled){let t=e.latestTurn?.sourceProposedPlan;if(t){let n=e.threads.find(e=>e.id===t.threadId)?.proposedPlans.find(e=>e.id===t.planId);if(n)return jD(n)}}return hD(t,e.latestTurn?.turnId??null)}function _D(e){return e!==null&&e.implementedAt===null}function vD(e,t){return t?e.some(e=>e.turnId===t&&e.tone===`tool`):!1}var yD=new WeakMap;function bD(e,t){if(e.role!==`assistant`)return[];let n=SD(e.text,{workEntries:t,createdAt:e.createdAt});if(!n)return[];let r=yD.get(e),i=`${e.id}:github-confirmation:${n.confirmationId}`;if(r&&r[0]?.id===i)return r;let a=[{id:i,kind:`work`,createdAt:e.createdAt,entry:{id:i,createdAt:e.createdAt,label:`GitHub action needs approval`,detail:wT(n),tone:`approval`,toolTitle:CT(n.operation),githubConfirmation:n}}];return yD.set(e,a),a}function xD(e,t,n,r){let i=rD(e,t,n,r),a=e.flatMap(e=>bD(e,n));if(a.length===0)return i;let o=new Set(i.entries.map(e=>e.id)),s=a.filter(e=>!o.has(e.id));return s.length===0?i:{...i,entries:[...i.entries,...s].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}}function SD(e,t){if(!e.includes(`confirm_github_tool`))return null;let n=DD(e,/\b(?:New confirmation id|Confirmation id):\s*`?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})`?/i)??null,r=/\bRepo(?: to create)?:\s*(private|public|internal)\s+`?([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)`?/i.exec(e);if(!n)return null;let i=CD(e,n,t);if(i)return i;if(!r)return null;let a=r[1]?.toLowerCase(),o=r[2],s=r[3];return!o||!s?null:{confirmationId:n,toolName:`forge_github_create_repository`,operation:`create_repository`,request:{owner:o,name:s,visibility:a}}}function CD(e,t,n){if(!wD(e))return null;let r=TD(n?.workEntries??[],n?.createdAt,`forge_github_refresh_credentials`)?.request,i=r?ED(r.cwd):null;return i?{confirmationId:t,toolName:`forge_github_refresh_credentials`,operation:`refresh_credentials`,request:{cwd:i}}:null}function wD(e){return/\bforge_github_refresh_credentials\b/i.test(e)||/\bcredential refresh\b/i.test(e)||/\brefresh(?:ing)? GitHub credentials\b/i.test(e)}function TD(e,t,n){for(let r of e.toReversed()){if(t!==void 0&&r.createdAt>t)continue;let e=r.githubConfirmation;if(e?.toolName===n)return e}return null}function ED(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function DD(e,t){return t.exec(e)?.[1]??null}function OD(e){let t=[...e].toSorted((e,t)=>e.completedAt.localeCompare(t.completedAt)),n={};for(let e=0;e<t.length;e+=1){let r=t[e];r&&(n[r.turnId]=e+1)}return n}function kD(e){return!e||e.status===`closed`?`disconnected`:e.status===`connecting`?`connecting`:e.status===`running`?`running`:`ready`}function AD(e,t){if(t===`disconnected`||t===`connecting`)return null;for(let t of e.toReversed())if(t.kind===`work`&&t.entry.githubConfirmation)return t.entry.githubConfirmation;return null}function jD(e){return{id:e.id,createdAt:e.createdAt,updatedAt:e.updatedAt,turnId:e.turnId,planMarkdown:e.planMarkdown,implementedAt:e.implementedAt,implementationThreadId:e.implementationThreadId}}var MD=[`preview`,`terminal`,`canvas`,`diff`,`plan`,`task`,`simulator`,`display`,`agents`,`file`,`pull-request`],ND={isOpen:!1,isMaximized:!1,activeSurfaceId:null,surfaces:[]};function PD(e){return e===null?{id:`browser:new`,kind:`preview`,resourceId:null}:{id:`browser:${e}`,kind:`preview`,resourceId:e}}function FD(e,t,n,r=`execution-intent`){return{id:`file:${e}`,kind:`file`,relativePath:e,revealLine:t,revealRequestId:n,readPolicy:r}}function ID(e){let t=[e.provider,e.environmentId,e.repositoryLinkId??``,e.projectId,e.host.toLowerCase(),e.repository,String(e.number)].map(e=>encodeURIComponent(e)).join(`:`);return{...e,id:`pull-request:${t}`,kind:`pull-request`}}function LD(e){return e===`diff`?{id:`diff`,kind:`diff`,turnId:null,filePath:null}:{id:e,kind:e}}var RD=`workspace:pull-requests`;function zD(e){return typeof e==`object`&&!!e}function BD(e){return typeof e==`string`&&MD.includes(e)}function VD(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(1,Math.trunc(e)):null}function HD(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:0}function UD(e){let t=e.relativePath;return typeof t!=`string`||t.length===0?null:{id:`file:${t}`,kind:`file`,relativePath:t,revealLine:VD(e.revealLine),revealRequestId:HD(e.revealRequestId),readPolicy:e.readPolicy===`connected-only`?`connected-only`:`execution-intent`}}function WD(e){let t=e.resourceId;return t==null?{id:`browser:new`,kind:`preview`,resourceId:null}:typeof t!=`string`||t.length===0?null:{id:`browser:${t}`,kind:`preview`,resourceId:t}}function GD(e){let t=e.turnId,n=e.filePath,r=typeof t==`string`&&t.length>0?Hr.make(t):null;return{id:`diff`,kind:`diff`,turnId:r,filePath:r&&typeof n==`string`&&n.length>0?n:null}}var KD=new Set([`github`,`gitlab`,`azure-devops`,`bitbucket`,`unknown`]);function qD(e){return typeof e==`string`&&e.length>0}function JD(e){return e===null||typeof e==`string`}function YD(e){return e===void 0||JD(e)}function XD(e){let t=e.provider,n=e.environmentId,r=e.repositoryLinkId,i=e.projectId,a=e.host,o=e.repository,s=VD(e.number),c=e.title;return![qD(t)&&KD.has(t),qD(n),JD(r),qD(i),qD(a),qD(o),s!==null,YD(c)].every(Boolean)||!qD(t)||!qD(n)?null:ID({provider:t,environmentId:Ur.make(n),repositoryLinkId:r,projectId:Si.make(i),host:a,repository:o,number:s,...typeof c==`string`||c===null?{title:c}:{}})}function ZD(e){let t=e.label;if(typeof t!=`string`)return;let n=t.trim();return n.length>0?n:void 0}function QD(e){if(!zD(e)||!BD(e.kind))return null;let t=e.kind,n=t===`file`?UD(e):t===`preview`?WD(e):t===`diff`?GD(e):t===`pull-request`?XD(e):{id:t,kind:t};if(n===null)return null;let r=ZD(e);return r===void 0?n:{...n,label:r}}function $D(e){let t=[],n=new Set;for(let r of Array.isArray(e)?e:[]){let e=QD(r);!e||n.has(e.id)||(n.add(e.id),t.push(e))}return t}function eO(e){if(!zD(e))return null;let t=$D(e.surfaces);if(t.length===0)return null;let n=e.activeSurfaceId,r=t.some(e=>e.id===n),i=typeof n==`string`&&r?n:t[0]?.id??null;return{isOpen:e.isOpen===!0,activeSurfaceId:i,surfaces:t}}function tO(e){if(!zD(e)||!zD(e.byThreadKey))return{byThreadKey:{}};let t={};for(let[n,r]of Object.entries(e.byThreadKey)){if(n===RD)continue;let e=eO(r);e&&(t[n]=e)}return{byThreadKey:t}}var nO=`forge:right-panel-state`,rO=3,iO=e=>e===`workspace:pull-requests`;function aO(e){return`draft:${e}`}function oO(e){return e.startsWith(`draft:`)}function sO(e){return e==null||!Number.isFinite(e)?null:Math.max(1,Math.trunc(e))}var cO=(e,t,n=!0)=>({...e,isOpen:!0,surfaces:e.surfaces.some(e=>e.id===t.id)?e.surfaces:[...e.surfaces,t],activeSurfaceId:n?t.id:e.activeSurfaceId});function lO(e,t){if(t.length===0){let{label:t,...n}=e;return n}return{...e,label:t}}var z=(e,t,n)=>{let r=e[t]??ND,i=n(r);if(!i.isOpen&&i.activeSurfaceId===null&&i.surfaces.length===0){if(!(t in e))return e;let{[t]:n,...r}=e;return r}return i===r?e:{...e,[t]:i}},uO=Oa()(Wf(e=>({byThreadKey:{},open:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>cO(e,e.surfaces.find(e=>e.kind===n)??LD(n)))})),openBrowser:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t=n?e.surfaces.filter(e=>e.id!==`browser:new`):e.surfaces;return cO({...e,surfaces:t},PD(n))})})),revealBrowser:t=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>cO(e,e.surfaces.find(e=>e.kind===`preview`)??PD(null)))})),openDiff:(t,n,r)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t={id:`diff`,kind:`diff`,turnId:n??null,filePath:n?r??null:null};return{...e,isOpen:!0,activeSurfaceId:t.id,surfaces:e.surfaces.some(e=>e.id===`diff`)?e.surfaces.map(e=>e.id===`diff`?t:e):[...e.surfaces,t]}})})),openFile:(t,n,r,i=`execution-intent`)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t=`file:${n}`,a=e.surfaces.find(e=>e.id===t&&e.kind===`file`),o=FD(n,sO(r),(a?.revealRequestId??0)+1,i);return{...e,isOpen:!0,activeSurfaceId:o.id,surfaces:a?e.surfaces.map(e=>e.id===o.id?o:e):[...e.surfaces,o]}})})),openPullRequest:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>cO(e,ID(n)))})),activateSurface:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>e.surfaces.some(e=>e.id===n)?{...e,isOpen:!0,activeSurfaceId:n}:e)})),closeSurface:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t=e.surfaces.findIndex(e=>e.id===n);if(t<0)return e;let r=e.surfaces.filter(e=>e.id!==n);if(e.activeSurfaceId!==n)return{...e,isOpen:r.length>0&&e.isOpen,surfaces:r};let i=r[Math.min(t,r.length-1)]??null;return{...e,isOpen:r.length>0&&e.isOpen,surfaces:r,activeSurfaceId:i?.id??null}})})),closeOtherSurfaces:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t=e.surfaces.find(e=>e.id===n);return!t||e.surfaces.length===1?e:{...e,isOpen:!0,surfaces:[t],activeSurfaceId:t.id}})})),closeSurfacesToRight:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t=e.surfaces.findIndex(e=>e.id===n);if(t<0||t===e.surfaces.length-1)return e;let r=e.surfaces.slice(0,t+1),i=r.some(t=>t.id===e.activeSurfaceId);return{...e,surfaces:r,activeSurfaceId:i?e.activeSurfaceId:n}})})),closeAllSurfaces:t=>e(e=>({byThreadKey:z(e.byThreadKey,t,()=>ND)})),renameSurface:(t,n,r)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t=r.trim();return{...e,surfaces:e.surfaces.map(e=>e.id===n?lO(e,t):e)}})})),show:t=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>({...e,isOpen:!0}))})),close:t=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>e.isOpen?{...e,isOpen:!1,isMaximized:!1}:e)})),toggleVisibility:t=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>({...e,isOpen:!e.isOpen}))})),toggleMaximized:t=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>e.isOpen?{...e,isMaximized:!(e.isMaximized??!1)}:e)})),removeThread:t=>e(e=>{if(!(t in e.byThreadKey))return e;let{[t]:n,...r}=e.byThreadKey;return{byThreadKey:r}})}),{name:nO,version:rO,storage:Hf(()=>jn),partialize:e=>({byThreadKey:Object.fromEntries(Object.entries(e.byThreadKey).filter(([e])=>!oO(e)&&!iO(e)))}),migrate:e=>tO(e)}));function dO(e,t){if(!De(e)||!De(t))return t;let n={...e};for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];n[e]=De(t)&&De(r)?dO(t,r):r}return n}function fO(e,t){return un(t).pipe(ln,sn(e))}function pO(e){return{issues:e.issues,providers:e.providers,settings:e.settings}}var mO=[],hO=[],gO=[],_O=e=>e?.availableEditors??mO,vO=e=>e?.keybindings??hO,yO=e=>e?.keybindingsConfigPath??null,bO=e=>e?.observability??null,xO=e=>e?.providers??gO,SO=e=>e?.settings??Ri,CO=fO(`server-welcome`,null),wO=fO(`server-config`,null),TO=fO(`server-config-updated`,null),EO=fO(`server-providers-updated`,null);function DO(){return cn.get(wO)}function OO(){return cn.get(TO)}function kO(e){RO(e),zO({providers:e.providers}),BO(pO(e),`snapshot`)}function AO(e){switch(e.type){case`snapshot`:kO(e.config);return;case`keybindingsUpdated`:{let t=DO();if(!t)return;let n={...t,issues:e.payload.issues,keybindings:e.payload.keybindings};RO(n),BO(pO(n),e.type);return}case`providerStatuses`:jO(e.payload);return;case`settingsUpdated`:MO(e.payload.settings);return;case`environmentUpdated`:NO(e.payload.environment);return}}function jO(e){let t=DO();if(zO(e),!t)return;let n={...t,providers:e.providers};RO(n),BO(pO(n),`providerStatuses`)}function MO(e){let t=DO();if(!t)return;let n={...t,settings:e};RO(n),BO(pO(n),`settingsUpdated`)}function NO(e){let t=DO();if(br()?.environmentId===e.environmentId&&yn(e),!t)return;let n={...t,environment:e};RO(n),BO(pO(n),`environmentUpdated`)}function PO(e){cn.set(CO,e)}function FO(e){return VO(TO,t=>{e(t.payload,t.source)})}function IO(e){let t=!1,n=[e.subscribeLifecycle(e=>{e.type===`welcome`&&PO(e.payload)}),e.subscribeConfig(e=>{AO(e)})];return DO()===null&&e.getConfig().then(e=>{t||DO()!==null||kO(e)}).catch(()=>void 0),()=>{t=!0;for(let e of n)e()}}var LO=1;function RO(e){cn.set(wO,e)}function zO(e){cn.set(EO,e)}function BO(e,t){cn.set(TO,{id:LO++,payload:e,source:t})}function VO(e,t){return cn.subscribe(e,e=>{e!==null&&t(e)},{immediate:!0})}function HO(e,t){let n=(0,O.useRef)(t);n.current=t;let r=(0,O.useCallback)(e=>{e!==null&&n.current(e)},[]);va(e,r,{immediate:!0})}function UO(){return ha(wO)}function WO(){return ha(wO,SO)}function GO(){return ha(wO,xO)}function KO(){return ha(wO,vO)}function qO(){return ha(wO,_O)}function JO(){return ha(wO,yO)}function YO(){return ha(wO,bO)}function XO(e){HO(CO,e)}function ZO(){return ha(CO)}function QO(e){HO(TO,e)}var $O=`[CLIENT_SETTINGS]`,ek=new Set,tk=ui,nk=!1,rk=null,ik=`pending`;function ak(e){ik!==e&&(ik=e,ok())}function ok(){for(let e of ek)e()}function sk(){return tk}function ck(e){tk=e,ok()}function lk(e){return ek.add(e),uk(),()=>{ek.delete(e)}}async function uk(){if(nk)return;if(rk)return rk;let e=(async()=>{try{let e=await nr();e&&ck(e),nk=!0,ak(`ready`)}catch(e){console.error(`${$O} hydrate failed`,e),ak(`failed`)}})().finally(()=>{rk===e&&(rk=null)});return rk=e,rk}var dk=new Set(ti(Li.fields));function fk(e){let t={},n={};for(let[r,i]of Object.entries(e))dk.has(r)?t[r]=i:n[r]=i;return{serverPatch:t,clientPatch:n}}function pk(){return uk()}var mk=Promise.resolve();function hk(e){let t=mk.then(async()=>{if(await pk(),vk()!==`ready`)throw Error(`${$O} hydration failed; refusing to persist settings.`);return e()});return mk=t.then(()=>void 0,()=>void 0),t}function gk(e){return hk(async()=>{let t=e(sk());await sr(t),ck(t)})}function _k(){return(0,O.useSyncExternalStore)(lk,vk,vk)}function vk(){return ik}function yk(e){let t=WO(),n=(0,O.useSyncExternalStore)(lk,sk,()=>ui),r=(0,O.useMemo)(()=>({...t,...n}),[n,t]);return(0,O.useMemo)(()=>e?e(r):r,[r,e])}function bk(){let e=(0,A.c)(2),t=xk,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{t(Er)},e[0]=n):n=e[0];let r=n,i;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={updateSettings:t,resetSettings:r},e[1]=i):i=e[1],i}function xk(e){let{serverPatch:t,clientPatch:n}=fk(e);if(Object.keys(t).length>0){let e=DO();e&&MO(dO(e.settings,t)),aw().client.server.updateSettings(t)}Object.keys(n).length>0&&hk(async()=>{let e={...sk(),...n};ck(e),await sr(e).catch(Ck)}).catch(Sk)}function Sk(e){console.error(`${$O} persist failed`,e)}function Ck(e){console.error(`${$O} persist failed`,e)}function wk(e){return t=>e?mn(t,e.environmentId).projectById[e.projectId]:void 0}function Tk(e){let t,n,r;return i=>{let a=e(i);if(!a)return;let o=mn(i,a.environmentId);return r&&t===o&&n===a.threadId?r:(t=o,n=a.threadId,r=Fn(o,a.threadId),r)}}function Ek(e){return Tk(()=>e)}function Dk(e){return t=>{if(e)return mn(t,e.environmentId).threadSubscriptionErrorById[e.threadId]}}function Ok(e){let t,n,r,i;return a=>{if(!e){i=void 0,t=void 0,n=void 0,r=void 0;return}let o=mn(a,e.environmentId).threadShellById,s=o[e.threadId];if(!s){i=void 0,t=void 0,n=void 0,r=void 0;return}let c=s.kind===`master`?s.id:s.parentThreadId,l=c==null?void 0:o[c];if(i&&t===o&&n===s&&r===l)return i;let u=[];if(c!=null){for(let e of Object.values(o))e.kind===`worker`&&e.parentThreadId===c&&u.push(e);u.sort((e,t)=>e.createdAt.localeCompare(t.createdAt))}return t=o,n=s,r=l,i={you:s,master:l,workers:u},i}}function kk(e,t){let n=new Set(e.filter(e=>e.bootstrapped).map(e=>String(e.ref.environmentId))),r=e.filter(e=>{let r=t?.(e.ref.environmentId)??null;return r===null||!n.has(r)}),i=r.filter(e=>e.bootstrapped);return(i.find(e=>e.active)??i.at(-1)??r.find(e=>e.active)??r[0])?.ref}function Ak(e,t){return Tk(n=>{if(e)return kk(Object.entries(n.environmentStateById).filter(([,t])=>t.threadShellById[e]).map(([t,r])=>({ref:{environmentId:t,threadId:e},active:n.activeEnvironmentId===t,bootstrapped:r.bootstrapComplete})),t)})}function jk(e,t){let n={hour:`numeric`,minute:`2-digit`,...t?{second:`2-digit`}:{}};return e===`locale`?n:{...n,hour12:e===`12-hour`}}var Mk=new Map;function Nk(e,t){let n=`${e}:${t?`seconds`:`minutes`}`,r=Mk.get(n);if(r)return r;let i=new Intl.DateTimeFormat(void 0,jk(e,t));return Mk.set(n,i),i}function Pk(e,t){return Nk(t,!0).format(new Date(e))}function Fk(e,t){return Nk(t,!1).format(new Date(e))}function Ik(e){let t=Date.now()-new Date(e).getTime();if(t<0)return{value:`just now`,suffix:null};let n=Math.floor(t/1e3);if(n<60)return{value:`just now`,suffix:null};let r=Math.floor(n/60);if(r<60)return{value:`${r}m`,suffix:`ago`};let i=Math.floor(r/60);return i<24?{value:`${i}h`,suffix:`ago`}:{value:`${Math.floor(i/24)}d`,suffix:`ago`}}function Lk(e){let t=Ik(e);return t.suffix?`${t.value} ${t.suffix}`:t.value}function Rk(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}var zk=Object.freeze({data:null,error:null,cause:null,isPending:!1}),Bk=Object.freeze({...zk,isPending:!0}),Vk=un(zk).pipe(ln,sn(`git-status:null`)),Hk=()=>void 0,Uk=new Map,Wk=new Set,Gk=new Map,Kk=new Map,qk=1e3,Jk=on(e=>(Wk.add(e),un(Bk).pipe(ln,sn(`git-status:${e}`))));function Yk(e){return e.environmentId===null||Rk(e.cwd)===null?null:`${e.environmentId}:${e.cwd}`}function Xk(e){if(e.environmentId===null)return null;let t=nw(e.environmentId);return t?{clientIdentity:t.environmentId,client:t.client.git}:null}function Zk(e){let t=Yk(e);return t===null?zk:cn.get(Jk(t))}function Qk(e,t){let n=Yk(e);if(n===null)return Hk;let r=Uk.get(n);return r?(r.refCount+=1,()=>tA(n)):(Uk.set(n,{refCount:1,unsubscribe:nA(n,e,t)}),()=>tA(n))}function $k(e,t){let n=Yk(e),r=Rk(e.cwd);if(n===null||r===null)return Promise.resolve(null);let i=t??Xk(e)?.client;if(!i)return Promise.resolve(Zk(e).data);let a=Gk.get(n);if(a)return a;let o=Kk.get(n)??0;if(Date.now()-o<qk)return Promise.resolve(Zk(e).data);Kk.set(n,Date.now());let s=i.refreshStatus({cwd:r}).finally(()=>{Gk.delete(n)});return Gk.set(n,s),s}function eA(e){let t=(0,A.c)(4),n=Yk(e),r,i;t[0]!==e.cwd||t[1]!==e.environmentId?(r=()=>Qk({environmentId:e.environmentId,cwd:e.cwd}),i=[e.environmentId,e.cwd],t[0]=e.cwd,t[1]=e.environmentId,t[2]=r,t[3]=i):(r=t[2],i=t[3]),(0,O.useEffect)(r,i);let a=ha(n===null?Vk:Jk(n));return n===null?zk:a}function tA(e){let t=Uk.get(e);t&&(--t.refCount,!(t.refCount>0)&&(t.unsubscribe(),Uk.delete(e)))}function nA(e,t,n){let r=Rk(t.cwd);if(r===null)return Hk;let i=null,a=Hk,o=()=>{let o=n?{clientIdentity:`provided:${e}`,client:n}:Xk(t);if(!o){i!==null&&(a(),a=Hk,i=null),iA(e);return}i!==o.clientIdentity&&(a(),i=o.clientIdentity,a=rA(e,r,o.client))},s=n?Hk:tw(o);return o(),()=>{s(),a()}}function rA(e,t,n){return iA(e),n.onStatus({cwd:t},t=>{cn.set(Jk(e),{data:t,error:null,cause:null,isPending:!1})},{onResubscribe:()=>{iA(e)}})}function iA(e){let t=Jk(e),n=cn.get(t),r=n.data===null?Bk:{...n,error:null,cause:null,isPending:!0};(n.data!==r.data||n.error!==r.error||n.cause!==r.cause||n.isPending!==r.isPending)&&cn.set(t,r)}function aA(e){let t=[];for(let n of e){let e=n.children??[];if(e.length>0){t.push({item:n,isGroupLabel:!0});for(let n of e)t.push({item:n,isGroupLabel:!1});continue}Array.isArray(n.children)||t.push({item:n,isGroupLabel:!1})}return t}function oA(e){let t=document.createElement(`div`);return t.textContent=e,t.className=`px-2 pt-1.5 pb-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground/70`,t}function sA(e){let t=document.createElement(`button`);return t.type=`button`,t.textContent=e.label,t.disabled=e.disabled,t.className=e.disabled?`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[11px] text-muted-foreground/50 cursor-not-allowed`:e.destructive?`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[11px] text-destructive transition-colors hover:bg-accent`:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[11px] text-popover-foreground transition-colors hover:bg-accent`,t}function cA(e,t){return new Promise(n=>{let r=document.createElement(`div`);r.style.cssText=`position:fixed;inset:0;z-index:9999`;let i=document.createElement(`div`);i.className=`fixed z-[10000] min-w-[160px] rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg/5 outline-none before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`;let a=t?.x??0,o=t?.y??0;i.style.top=`${o}px`,i.style.left=`${a}px`;function s(e){document.removeEventListener(`keydown`,c),r.remove(),i.remove(),n(e)}function c(e){e.key===`Escape`&&(e.preventDefault(),s(null))}r.addEventListener(`mousedown`,()=>s(null)),document.addEventListener(`keydown`,c);let l=!1;for(let{item:t,isGroupLabel:n}of aA(e)){if(n){i.appendChild(oA(t.label));continue}let e=t.destructive===!0||t.id===`delete`,r=t.disabled===!0;if(e&&!l){let e=document.createElement(`div`);e.className=`-mx-1 my-1 h-px bg-border`,i.appendChild(e),l=!0}let a=sA({label:t.label,disabled:r,destructive:e});r||a.addEventListener(`click`,()=>s(t.id)),i.appendChild(a)}document.body.appendChild(r),document.body.appendChild(i),requestAnimationFrame(()=>{let e=i.getBoundingClientRect();e.right>window.innerWidth&&(i.style.left=`${window.innerWidth-e.width-4}px`),e.bottom>window.innerHeight&&(i.style.top=`${window.innerHeight-e.height-4}px`)})})}var lA;function uA(){return dA(aw().client)}function dA(e){return{getConfig:e.server.getConfig,refreshProviders:e.server.refreshProviders,startProviderAuth:e.server.startProviderAuth,repairProviderAuthRuntime:e.server.repairProviderAuthRuntime,disconnectProviderAuth:e.server.disconnectProviderAuth,getProviderAuthSession:e.server.getProviderAuthSession,cancelProviderAuth:e.server.cancelProviderAuth,submitProviderAuthCode:e.server.submitProviderAuthCode,syncPersonalCodexToCloud:e.server.syncPersonalCodexToCloud,syncPersonalClaudeToCloud:e.server.syncPersonalClaudeToCloud,upsertKeybinding:e.server.upsertKeybinding,removeKeybinding:e.server.removeKeybinding,getSettings:e.server.getSettings,updateSettings:e.server.updateSettings,updateEnvironmentDisplayName:async t=>{let n=await e.server.updateEnvironmentDisplayName({displayName:t});return NO(n.environment),n}}}function fA(e,t){return{...e,...t,dialogs:{...e.dialogs,...t.dialogs},shell:{...e.shell,...t.shell},contextMenu:{...e.contextMenu,...t.contextMenu},persistence:{...e.persistence,...t.persistence},server:{...e.server,...t.server}}}function pA(e){return{dialogs:{pickFolder:async()=>window.desktopBridge?window.desktopBridge.pickFolder():null,confirm:async e=>window.desktopBridge?window.desktopBridge.confirm(e):window.confirm(e)},shell:{openInEditor:(t,n)=>e.shell.openInEditor({cwd:t,editor:n}),openExternal:async e=>{if(window.desktopBridge){if(!await window.desktopBridge.openExternal(e))throw Error(`Unable to open link.`);return}window.open(e,`_blank`,`noopener,noreferrer`)}},contextMenu:{show:async(e,t)=>window.desktopBridge?window.desktopBridge.showContextMenu(e,t):cA(e,t)},persistence:{getClientSettings:nr,setClientSettings:sr,getSavedEnvironmentRegistry:mr,setSavedEnvironmentRegistry:ir,getSavedEnvironmentSecret:qn,setSavedEnvironmentSecret:Qn,removeSavedEnvironmentSecret:Yn},server:dA(e)}}function mA(){if(typeof window>`u`)return;if(lA)return lA;let e=pA(aw().client);return window.nativeApi?(lA=fA(e,window.nativeApi),lA):(lA=e,lA)}function hA(){let e=mA();if(!e)throw Error(`Local API not found`);return e}function gA(){let e=(0,A.c)(2),[t,n]=(0,O.useState)(_A),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>(n(La()),Fa(()=>{n(La())})),i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,O.useEffect)(r,i),t}function _A(){return La()}function vA(e,t){e.style.setProperty(`--appearance-contrast-base`,`${Math.min(t,100)}%`),e.style.setProperty(`--appearance-contrast-boost`,`${Math.max(t-100,0)}%`),e.style.setProperty(`--appearance-contrast-border-boost`,`${Math.max(t-100,0)/4}%`)}var yA=`-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif`,bA=`ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace`;function xA(e){let t=e.trim();return t.length===0?``:/^(['"]).*\1$/u.test(t)||/^[a-zA-Z][a-zA-Z0-9-]*$/u.test(t)?t:`"${t.replaceAll(`"`,``)}"`}function SA(e){let t=e.split(`,`).map(xA).filter(e=>e.length>0);return t.length>0?t.join(`, `):null}var CA={appearanceContrastBase:`--appearance-contrast-base`,appearanceContrastBoost:`--appearance-contrast-boost`,appearanceContrastBorderBoost:`--appearance-contrast-border-boost`,fontSans:`--font-sans`,fontMono:`--font-mono`,fontComposer:`--font-composer`,fontTerminal:`--font-terminal`,promptFontSize:`--forge-prompt-font-size`,terminalFontSize:`--forge-terminal-font-size`,glassOpacity:`--glass-opacity`};function wA(e,t){let n=[[CA.fontSans,t.fontFamilySans,yA],[CA.fontMono,t.fontFamilyCode,bA],[CA.fontComposer,t.fontFamilyComposer,`var(--font-sans)`],[CA.fontTerminal,t.fontFamilyTerminal,`var(--font-mono)`]];for(let[t,r,i]of n){let n=SA(r);if(n===null){e.style.removeProperty(t);continue}e.style.setProperty(t,`${n}, ${i}`)}e.style.setProperty(CA.promptFontSize,`${String(t.promptFontSize)}px`),e.style.setProperty(CA.terminalFontSize,`${String(t.terminalFontSize)}px`),e.style.setProperty(CA.glassOpacity,`${String(t.glassOpacity)}%`),vA(e,t.appearanceContrast),t.fontSmoothing?e.style.setProperty(`-webkit-font-smoothing`,`antialiased`):e.style.removeProperty(`-webkit-font-smoothing`)}function TA(){return typeof window<`u`&&typeof localStorage<`u`}function EA(){if(!TA())return{};try{let e=JSON.parse(window.localStorage.getItem(`forge:theme-halves:v1`)??`null`);if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let n of[`light`,`dark`]){let r=e[n];typeof r==`string`&&(t[n]=r)}return t}catch{return{}}}function DA(){if(!TA())return null;try{return Pa(window.localStorage.getItem(za))}catch{return null}}function OA(e){if(TA())try{e===null||e.light===void 0&&e.dark===void 0?window.localStorage.removeItem(za):window.localStorage.setItem(za,JSON.stringify(e))}catch{}}function kA(e,t,n){let r={...e};return n===null?delete r[t]:r[t]=n,r}function AA(e){return e!==null&&(e.light!==void 0||e.dark!==void 0)?e:null}function jA(e,t){let n=(0,A.c)(13),[r,i]=(0,O.useState)(MA),a=gA(),o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(e,t)=>{let n=kA(EA(),e,t);return OA(n),i(AA(n)),!0},n[0]=o):o=n[0];let s=o,c;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>(OA(null),i(null),!0),n[1]=c):c=n[1];let l=c,u;n[2]!==t||n[3]!==r||n[4]!==e?(u=()=>{let n=t===`dark`?`dark`:`light`;Ia(Ra(e,r,n),n)},n[2]=t,n[3]=r,n[4]=e,n[5]=u):u=n[5];let d;n[6]!==a||n[7]!==t||n[8]!==r||n[9]!==e?(d=[e,t,r,a],n[6]=a,n[7]=t,n[8]=r,n[9]=e,n[10]=d):d=n[10],(0,O.useEffect)(u,d);let f;return n[11]===r?f=n[12]:(f={themeHalves:r,setThemeHalf:s,clearThemeHalves:l},n[11]=r,n[12]=f),f}function MA(){return DA()}var NA=`theme-color`,PA=`meta[name="${NA}"][data-dynamic-theme-color="true"]`,FA={dark:`#0a0a0a`,light:`#ffffff`};function IA(){let e=document.querySelector(PA);return e||(e=document.createElement(`meta`),e.name=NA,e.setAttribute(`data-dynamic-theme-color`,`true`),document.head.append(e),e)}function LA(e){let t=e?.trim().toLowerCase();return!t||t===`transparent`||t===`rgba(0, 0, 0, 0)`||t===`rgba(0 0 0 / 0)`?null:e?.trim()??null}function RA(){return document.querySelector(`main[data-slot='sidebar-inset']`)??document.querySelector(`[data-slot='sidebar-inner']`)??document.body}function zA(){return document.documentElement.classList.contains(`dark`)?`dark`:`light`}function BA(e=zA()){if(typeof document>`u`||typeof getComputedStyle>`u`)return;document.documentElement.style.backgroundColor=``,document.body.style.backgroundColor=``;let t=LA(getComputedStyle(RA()).backgroundColor),n=LA(getComputedStyle(document.body).backgroundColor),r=t??n??FA[e];document.documentElement.style.backgroundColor=r,document.body.style.backgroundColor=r,IA().setAttribute(`content`,r)}var VA=`forge:theme`,HA=`(prefers-color-scheme: dark)`;function UA(e){return e===`system`||e===`light`||e===`dark`}function WA(e,t){return typeof e!=`number`||!Number.isFinite(e)?t:Math.min(20,Math.max(11,Math.round(e)))}function GA(){if(!TA())return{theme:`system`,uiFontSize:16,codeFontSize:13};try{let e=window.localStorage.getItem(Xn);if(e){let t=Wn(JSON.parse(e));return{theme:UA(t.theme)?t.theme:`system`,uiFontSize:WA(t.uiFontSize,16),codeFontSize:WA(t.codeFontSize,13)}}let t=window.localStorage.getItem(VA);return{theme:UA(t)?t:`system`,uiFontSize:16,codeFontSize:13}}catch{return{theme:`system`,uiFontSize:16,codeFontSize:13}}}function KA(){return typeof window>`u`||typeof window.matchMedia!=`function`||window.matchMedia(HA).matches?`dark`:`light`}function qA(e){return e===`system`?KA():e}function JA(e){if(typeof window>`u`)return;let t=window.desktopBridge;t&&t.setTheme(e).catch(()=>{})}function YA(e,t=!1){let n=qA(e);return typeof document>`u`||typeof window>`u`?n:(t&&document.documentElement.classList.add(`no-transitions`),document.documentElement.classList.toggle(`dark`,n===`dark`),document.documentElement.dataset.theme=e,document.documentElement.style.colorScheme=n,BA(n),JA(e),t&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove(`no-transitions`)})),n)}function XA(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-ui-font-size`,`${WA(e,16)}px`)}function ZA(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-code-font-size`,`${WA(e,13)}px`)}function QA(e){XA(e.uiFontSize),ZA(e.codeFontSize)}if(typeof document<`u`){let e=GA();YA(e.theme),QA(e)}function $A(){let e=(0,A.c)(33),t=yk(rj),n=yk(nj),r=yk(tj),i=yk(ej),{updateSettings:a}=bk(),o;e[0]===t?o=e[1]:(o=()=>qA(t),e[0]=t,e[1]=o);let[s,c]=(0,O.useState)(o),{themeHalves:l,setThemeHalf:u,clearThemeHalves:d}=jA(n,s),f;e[2]===a?f=e[3]:(f=e=>{a({theme:e}),c(YA(e,!0))},e[2]=a,e[3]=f);let p=f,m;e[4]===a?m=e[5]:(m=e=>{a({themeId:e})},e[4]=a,e[5]=m);let h=m,g;e[6]===a?g=e[7]:(g=e=>{let t=WA(e,16);a({uiFontSize:t}),XA(t)},e[6]=a,e[7]=g);let _=g,v;e[8]===a?v=e[9]:(v=e=>{let t=WA(e,13);a({codeFontSize:t}),ZA(t)},e[8]=a,e[9]=v);let y=v,b,x;e[10]===t?(b=e[11],x=e[12]):(b=()=>{c(YA(t))},x=[t],e[10]=t,e[11]=b,e[12]=x),(0,O.useEffect)(b,x);let ee,te;e[13]!==i||e[14]!==r?(ee=()=>{QA({uiFontSize:r,codeFontSize:i})},te=[r,i],e[13]=i,e[14]=r,e[15]=ee,e[16]=te):(ee=e[15],te=e[16]),(0,O.useEffect)(ee,te);let ne,re;e[17]===t?(ne=e[18],re=e[19]):(re=()=>{if(t!==`system`||typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(HA),n=()=>{c(YA(`system`,!0))};return e.addEventListener(`change`,n),()=>{e.removeEventListener(`change`,n)}},ne=[t],e[17]=t,e[18]=ne,e[19]=re),(0,O.useEffect)(re,ne);let ie;return e[20]!==d||e[21]!==i||e[22]!==s||e[23]!==y||e[24]!==p||e[25]!==u||e[26]!==h||e[27]!==_||e[28]!==t||e[29]!==l||e[30]!==n||e[31]!==r?(ie={theme:t,setTheme:p,themeId:n,setThemeId:h,resolvedTheme:s,themeHalves:l,setThemeHalf:u,clearThemeHalves:d,uiFontSize:r,codeFontSize:i,setUiFontSize:_,setCodeFontSize:y},e[20]=d,e[21]=i,e[22]=s,e[23]=y,e[24]=p,e[25]=u,e[26]=h,e[27]=_,e[28]=t,e[29]=l,e[30]=n,e[31]=r,e[32]=ie):ie=e[32],ie}function ej(e){return e.codeFontSize}function tj(e){return e.uiFontSize}function nj(e){return e.themeId}function rj(e){return e.theme}function ij(){let e=(0,A.c)(11),t=yk(pj),n=yk(fj),r=yk(dj),i=yk(uj),a=yk(lj),o=yk(cj),s=yk(sj),c=yk(oj),l=yk(aj),u,d;e[0]!==t||e[1]!==r||e[2]!==i||e[3]!==n||e[4]!==a||e[5]!==c||e[6]!==l||e[7]!==o||e[8]!==s?(u=()=>{typeof document>`u`||wA(document.documentElement,{appearanceContrast:t,fontFamilyCode:r,fontFamilyComposer:i,fontFamilySans:n,fontFamilyTerminal:a,fontSmoothing:c,glassOpacity:l,promptFontSize:o,terminalFontSize:s})},d=[t,r,i,n,a,c,l,o,s],e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=c,e[6]=l,e[7]=o,e[8]=s,e[9]=u,e[10]=d):(u=e[9],d=e[10]),(0,O.useEffect)(u,d)}function aj(e){return e.glassOpacity}function oj(e){return e.fontSmoothing}function sj(e){return e.terminalFontSize}function cj(e){return e.promptFontSize}function lj(e){return e.fontFamilyTerminal}function uj(e){return e.fontFamilyComposer}function dj(e){return e.fontFamilyCode}function fj(e){return e.fontFamilySans}function pj(e){return e.appearanceContrast}var mj=`forge:last-editor`;function hj(e){let t=(0,A.c)(5),[n,r]=Pn(mj,null,xi),i;bb0:{if(n&&e.includes(n)){i=n;break bb0}let r;t[0]===e?r=t[1]:(r=Cr.find(t=>e.includes(t.id))?.id??null,t[0]=e,t[1]=r),i=r}let a=i,o;return t[2]!==a||t[3]!==r?(o=[a,r],t[2]=a,t[3]=r,t[4]=o):o=t[4],o}function gj(e){let t=new Set(e),n=Mn(mj,xi);if(n&&t.has(n))return n;let r=Cr.find(e=>t.has(e.id))?.id??null;return r&&vr(mj,r,xi),r??null}async function _j(e,t){let{availableEditors:n}=await e.server.getConfig(),r=gj(n);if(!r)throw Error(`No available editors found.`);return await e.shell.openInEditor(t,r),r}var vj=/https?:\/\/[^\s"'`<>]+/g,yj=/(?:~\/|\.{1,2}\/|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}/g,bj=/[.,;!?]+$/;function xj(e){let t=e.replace(bj,``);if(t.length===0)return t;let n=(e,n)=>{for(;t.endsWith(n);){if(t.split(e).length-1>=t.split(n).length-1)return;t=t.slice(0,-1)}};return n(`(`,`)`),n(`[`,`]`),n(`{`,`}`),t}function Sj(e,t){return e.start<t.end&&t.start<e.end}function Cj(e,t,n,r){let i=[];n.lastIndex=0;for(let a of e.matchAll(n)){let e=a[0],n=a.index??-1;if(n<0||e.length===0)continue;let o=xj(e);if(o.length===0||t===`path`&&/^https?:\/\//i.test(o))continue;let s={kind:t,text:o,start:n,end:n+o.length};[...r,...i].some(e=>Sj(s,e))||i.push(s)}return i}function wj(e){return/^[A-Za-z]:[\\/]/.test(e)||e.startsWith(`\\\\`)}function Tj(e){return e.startsWith(`/`)||wj(e)}function Ej(e){return wj(e)||/[A-Za-z]:\\/.test(e)}function Dj(e,t,n){let r=e.replace(/[\\/]+$/,``);return n===`\\`?`${r}\\${t.replaceAll(`/`,`\\`)}`:`${r}/${t.replace(/^\/+/,``)}`}function Oj(e){let t=e.match(/^\/Users\/([^/]+)/);if(t?.[1])return`/Users/${t[1]}`;let n=e.match(/^\/home\/([^/]+)/);if(n?.[1])return`/home/${n[1]}`;let r=e.match(/^([A-Za-z]:\\Users\\[^\\]+)/);if(r?.[1])return r[1]}function kj(e){let t=e,n,r,i=t.match(/:(\d+)$/);if(!i?.[1])return{path:t,line:void 0,column:void 0};n=i[1],t=t.slice(0,-i[0].length);let a=t.match(/:(\d+)$/);return a?.[1]?(r=a[1],t=t.slice(0,-a[0].length)):(r=n,n=void 0),{path:t,line:r,column:n}}function Aj(e){let t=Cj(e,`url`,vj,[]),n=Cj(e,`path`,yj,t);return[...t,...n].toSorted((e,t)=>e.start-t.start)}function jj(e,t){let n=t(e-1);if(!n)return null;let r=e,i=n;for(;r>1&&i.isWrapped;){let e=t(r-2);if(!e)return null;--r,i=e}let a=[],o=0,s=r;for(;;){let e=t(s-1);if(!e)break;let n=t(s)?.isWrapped===!0,r=e.translateToString(!n);if(a.push({bufferLineNumber:s,text:r,startIndex:o,endIndex:o+r.length}),o+=r.length,!n)break;s+=1}return{text:a.map(e=>e.text).join(``),segments:a}}function Mj(e,t){for(let n of e)if(t<n.endIndex)return{x:t-n.startIndex+1,y:n.bufferLineNumber};let n=e[e.length-1];return{x:Math.max(n?.text.length??0,1),y:n?.bufferLineNumber??1}}function Nj(e,t){return{start:Mj(e.segments,t.start),end:Mj(e.segments,t.end-1)}}function Pj(e,t){return e.start.y<=t&&t<=e.end.y}function Fj(e,t=typeof navigator>`u`?``:navigator.platform){return t.length===0?!1:Ca(t)?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Ij(e,t){let{path:n,line:r,column:i}=kj(e),a=n;if(n.startsWith(`~/`)){let e=Oj(t);if(e){let t=Ej(e)?`\\`:`/`;a=Dj(e,n.slice(2),t)}}else Tj(n)||(a=Dj(t,n,Ej(t)?`\\`:`/`));return r?`${a}:${r}${i?`:${i}`:``}`:a}var Lj=`diffs-container`,Rj=(()=>{try{return!1}catch{return!1}})(),zj=/(?=^From [a-f0-9]+ .+$)/m,Bj=/(?=^diff --git)/gm,Vj=/(?<=\n)/,Hj=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Uj=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,Wj=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,Gj=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,Kj=`header-prefix`,qj=`header-filename-suffix`,Jj=`header-metadata`,Yj=`header-custom`,Xj={dark:`pierre-dark`,light:`pierre-light`},Zj=`data-theme-css`,Qj=`data-unsafe-css`,$j=`data-diffs-scrollbar-measure`,eM=`data-diffs-code-view-header`,tM=`data-diffs-code-view-footer`,nM=`--diffs-scrollbar-gutter-measured`,rM=1e5,iM={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8},aM={...iM,hunkLineCount:1},oM={paddingTop:8,paddingBottom:8,gap:8},sM={omega:.015,positionEpsilon:.5,velocityEpsilon:.05},cM=Object.freeze({fromStart:0,fromEnd:0}),lM={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},uM={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0},dM=new Set,fM=null;function pM(e){dM.add(e),fM??=requestAnimationFrame(hM)}function mM(e){dM.delete(e)&&dM.size===0&&fM!=null&&(cancelAnimationFrame(fM),fM=null)}function hM(e){let t=new Set(dM);dM.clear();for(let n of t)try{n(e)}catch(e){console.error(e)}fM=dM.size>0?requestAnimationFrame(hM):null}function gM(e,t,n){if(e===t||e==null||t==null)return e===t;let r=new Set(n),i=Object.keys(e),a=new Set(Object.keys(t));for(let n of i)if(a.delete(n),!r.has(n)&&(!(n in t)||e[n]!==t[n]))return!1;for(let e of Array.from(a))if(!r.has(e))return!1;return!0}function _M(e,t){return e==null||t==null||typeof e==`string`||typeof t==`string`?e===t:e.dark===t.dark&&e.light===t.light}function vM(e,t){let n=e?.theme??Xj,r=t?.theme??Xj,i=yM(e),a=yM(t);return _M(n,r)&&gM(e,t,[`theme`,`parseDiffOptions`])&&gM(i,a)}function yM(e){if(e!=null&&`parseDiffOptions`in e)return e.parseDiffOptions}function bM(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}function xM({scrollTop:e,scrollHeight:t,height:n,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:a}){let o=n+a*2,s=r?n+i*2:o;if(t=Math.max(t,s),o>=t||r){let n=Math.max(e-i,0),r=Math.min(e+s,t);return{top:n,bottom:Math.max(r,n)}}let c=e+n/2-o/2,l=c+o;return c<0&&(c=0),l>t&&(l=t),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(l,t),c))}}function SM(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}function CM(e,t){return e-(t===0?0:1)}function wM(e,t){return CM(e,t)+t}var TM=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},EM=new class extends TM{};function DM(e,t,n){return EM.diff(e,t,n)}function OM(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function kM(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function AM(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function jM(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function MM(e,t){return AM(e,t,``)}function NM(e,t){return jM(e,t,``)}function PM(e,t){return t.slice(0,FM(e,t))}function FM(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function IM(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function LM(e,t){if(t)return zM(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function RM(e,t){if(t)return zM(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function zM(e,t){if(!t)return[RM(e),LM(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=IM(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var BM=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,VM=RegExp(`[${BM}]+|\\s+|[^${BM}]`,`ug`);new class extends TM{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=IM(e,r)}else n=e.match(VM)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&HM(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&HM(n,i,r,null,t.intlSegmenter),e}};function HM(e,t,n,r,i){if(t&&n){let[a,o]=zM(t.value,i),[s,c]=zM(n.value,i);if(e){let r=OM(a,s);e.value=jM(e.value,s,r),t.value=MM(t.value,r),n.value=MM(n.value,r)}if(r){let e=kM(o,c);r.value=AM(r.value,c,e),t.value=NM(t.value,e),n.value=NM(n.value,e)}}else if(n){if(e){let e=RM(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=RM(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=RM(r.value,i),[a,o]=zM(t.value,i),s=OM(n,a);t.value=MM(t.value,s);let c=kM(MM(n,s),o);t.value=NM(t.value,c),r.value=AM(r.value,n,c),e.value=jM(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=RM(r.value,i),n=PM(LM(t.value,i),e);t.value=NM(t.value,n)}else if(e){let n=PM(LM(e.value,i),RM(t.value,i));t.value=MM(t.value,n)}}var UM=new class extends TM{tokenize(e){let t=RegExp(`(\\r?\\n)|[${BM}]+|[^\\S\\n\\r]+|[^${BM}]`,`ug`);return e.match(t)||[]}};function WM(e,t,n){return UM.diff(e,t,n)}var GM=new class extends TM{constructor(){super(...arguments),this.tokenize=qM}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
19
|
+
`):null,i?.output,o,t?.result];for(let e of s){let t=dE(e);if(t)return t}return null}function pE(e,t){let n=e.endsWith(`...`)?e.slice(0,-3):e.endsWith(`…`)?e.slice(0,-1):null;return t.some(t=>{let r=t?.trim();return r?r===e||n!==null&&n.length>0&&r.length>n.length&&r.startsWith(n):!1})}function mE(e){let t=uE(e.toolName)?.trim(),n=e.detail.trim(),r=[e.command,e.rawCommand];if(t){let e=`${t}:`;if(n.toLowerCase().startsWith(e.toLowerCase())&&pE(n.slice(e.length).trim(),r))return!0}if(!pE(n,r))return!1;let i=lE(e.data),a=lE(i?.item),o=lE(a?.input),s=lE(a?.result);return![a?.command,o?.command,s?.command,i?.command].some(e=>Array.isArray(e)?e.some(e=>uE(e)!==null):uE(e)!==null)||a!==null||i?.toolCallId!==void 0||uE(i?.kind)?.toLowerCase()===`execute`}function hE(e){return e.kind===`runtime.warning`&&e.summary.endsWith(`(no displayable text content)`)}function gE(e,t){let n=kE(e?.message);return n&&bE(n)!==bE(t)?n:null}function _E(e){if(typeof e?.itemType==`string`&&Kr(e.itemType))return e.itemType}function vE(e){return e.replace(/\s+/g,` `).trim()}function yE(e,t=84){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`}function bE(e){let t=kE(e);return t?DE(vE(t)).toLowerCase():null}function xE(e){let t=[];for(let n of e.split(/\r?\n/u)){let e=vE(n);e.length>0&&t.push(e)}let n=t.find(e=>e!=="```");return n?yE(n):t.length>1?`${t.length.toLocaleString()} lines`:null}function SE(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function CE(e){let t=OE(OE(e?.data)?.rawOutput);if(!t)return null;let n=SE(t.totalFiles);if(n!==null){let e=t.truncated===!0?`+`:``;return`${n.toLocaleString()} file${n===1?``:`s`}${e}`}let r=kE(t.content);if(r)return xE(r);let i=kE(t.stdout);return i?xE(i):null}function wE(e){let t=fE(e?.data);return t?YT(t).output:null}function TE(e,t){let n=kE(OE(e?.data)?.kind)?.toLowerCase(),r=kE(e?.title??t)?.toLowerCase();return _E(e)===`command_execution`||n===`execute`||r===`terminal`||r===`ran command`}function EE(e,t){let n=kE(e?.detail),r=n?YT(n).output:null,i=bE(t),a=bE(r),o=TE(e,t),s=o?JT(e):{command:null,rawCommand:null},c=s.command;if(o&&c){let t=wE(e);if(t)return t}let l=OE(e?.data),u=r!==null&&mE({detail:r,command:c,rawCommand:s.rawCommand,toolName:l?.toolName,data:l});if(r&&i!==a&&(!o||!u))return r;if(o)return null;let d=CE(e);return d&&bE(d)!==i?d:null}function DE(e){return e.replace(/\s+(?:complete|completed)\s*$/i,``).trim()}function OE(e){return e&&typeof e==`object`?e:null}function kE(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function AE(e){return e&&typeof e==`object`?e:null}function jE(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function ME(e){return NE(e)??jE(e?.title)}function NE(e){if(!e)return null;let t=AE(e.data),n=AE(t?.item),r=AE(n?.input)??AE(t?.input),i=jE(e.title),a=jE(e.itemType),o=jE(n?.name)??jE(n?.toolName)??jE(t?.name)??jE(e.toolName)??i,s=jE(e.detail),c=[o,i,a,s].filter(Boolean).join(` `).toLowerCase();if(!c.includes(`browser`)&&!c.includes(`forge-browser`))return null;switch(PE(o,r,s)){case`open-session`:return`Opened browser session`;case`name-session`:return`Named browser session`;case`new-tab`:return FE(r)??`Opened browser tab`;case`navigate`:return FE(r)??`Navigated browser`;case`reload`:return`Reloaded page`;case`back`:return`Went back`;case`forward`:return`Went forward`;case`screenshot`:return`Captured screenshot`;case`snapshot`:return`Read DOM snapshot`;case`logs`:return`Read console logs`;case`click`:return`Clicked page`;case`type`:return`Typed text`;case`scroll`:return`Scrolled page`;case`viewport`:return`Updated viewport`;case`visibility`:return`Updated browser visibility`;default:return null}}function PE(e,t,n){let r=[jE(t?.type)??jE(t?.command),e,n].filter(Boolean).join(` `).toLowerCase();return/\b(open[-_.\s]?session|create[-_.\s]?session|session[-_.\s]?open)\b/.test(r)?`open-session`:/\b(name[-_.\s]?session|session[-_.\s]?name)\b/.test(r)?`name-session`:/\b(new[-_.\s]?tab|create[-_.\s]?tab|open[-_.\s]?tab)\b/.test(r)?`new-tab`:/\b(navigate|goto|go[-_.\s]?to)\b/.test(r)?`navigate`:/\breload\b/.test(r)?`reload`:/\b(go[-_.\s]?back|back)\b/.test(r)?`back`:/\b(go[-_.\s]?forward|forward)\b/.test(r)?`forward`:/\b(screenshot|capture)\b/.test(r)?`screenshot`:/\b(snapshot|dom[-_.\s]?snapshot|read[-_.\s]?dom)\b/.test(r)?`snapshot`:/\b(console[-_.\s]?logs?|logs?)\b/.test(r)?`logs`:/\bclick\b/.test(r)?`click`:/\btype|fill\b/.test(r)?`type`:/\bscroll\b/.test(r)?`scroll`:/\bviewport\b/.test(r)?`viewport`:/\bvisibility|visible|hidden\b/.test(r)?`visibility`:null}function FE(e){let t=jE(e?.url)??jE(e?.initialUrl);if(!t)return null;try{let e=new URL(t);return e.hostname.length===0?null:`Navigated to ${e.hostname}`}catch{return null}}function IE(e){return e&&typeof e==`object`?e:null}function L(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function LE(e){for(let t of zE(e)){if(t.userActionRequired!==`confirm_github_tool`)continue;let e=IE(t.confirmation),n=IE(e?.request),r=L(e?.confirmationId),i=L(e?.toolName),a=L(e?.operation);if(!(!r||!i||!a||!n))return{confirmationId:r,toolName:i,operation:a,request:n}}return null}function RE(e){let t=zE(e)[0];if(!t)return null;let n=L(t.userActionRequired);return!n||n===`confirm_github_tool`?null:{action:n,toolName:L(t.toolName),message:L(t.error)??L(t.message)}}function zE(e){if(!e)return[];let t=[],n=new Set,r=(e,i)=>{if(i>8||e==null)return;if(typeof e==`string`){let n=L(e);if(!n)return;let r=BE(n);r&&L(r.userActionRequired)&&t.push(r);return}if(typeof e!=`object`||n.has(e))return;if(n.add(e),Array.isArray(e)){for(let t of e)r(t,i+1);return}let a=e;if(L(a.userActionRequired)){t.push(a);return}for(let e of Object.values(a))r(e,i+1)};return r(e,0),t}function BE(e){try{return IE(JSON.parse(e))}catch{return null}}function VE(e){switch(e){case`create_repository`:return`Create GitHub repository`;case`link_project_repository`:return`Link project repository`;case`push_branch`:return`Push Git branch`;case`create_pull_request`:return`Create pull request`;case`rerun_workflow`:return`Rerun GitHub Actions workflow`;default:return e.split(`_`).filter(Boolean).map(e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`).join(` `)}}function HE(e){return[L(e.request.repoFullName)??(L(e.request.owner)&&L(e.request.name)?`${L(e.request.owner)}/${L(e.request.name)}`:null),L(e.request.cwd),L(e.request.branch),L(e.request.title)].filter(Boolean).join(` - `)}function UE(e){switch(e){case`connect_github`:return`Connect GitHub to continue`;case`connect_cmmd`:return`Forge couldn't authorize this action`;case`start_from_authenticated_forge_session`:return`Open this thread in Forge`;case`link_project_repository`:return`Link this project to GitHub`;case`create_branch`:return`Create a branch before pushing`;case`retry_in_user_vm`:return`Retry in the project VM`;default:return e.split(`_`).filter(Boolean).map(e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`).join(` `)}}function WE(e){switch(e){case`connect_github`:return`Connect GitHub so agents can create repos, push branches, and open PRs.`;case`connect_cmmd`:return`Reconnect Forge, then retry. Your conversation is preserved.`;case`start_from_authenticated_forge_session`:return`Open it in Forge so this action uses your signed-in account.`;case`link_project_repository`:return`Link a GitHub repo to this project before pushing or opening PRs.`;case`create_branch`:return`Forge needs a branch before it can push to GitHub.`;case`retry_in_user_vm`:return`This has to run from the project's cloud VM.`;default:return`Finish the required setup, then retry.`}}function GE(e){return e.action===`connect_cmmd`?WE(e.action):e.message??WE(e.action)}function KE(e,t){return e.action===t.action&&e.toolName===t.toolName&&e.message===t.message}function qE(e){switch(e){case`connect_cmmd`:return`Reconnect Forge`;case`connect_github`:return`Connect GitHub`;default:return`Open Git settings`}}function JE(e){return[`The required Forge GitHub setup has been completed by the user.`,e.toolName?`Retry the previous GitHub tool request for \`${e.toolName}\`.`:`Retry the previous GitHub tool request.`,`Continue the previous GitHub lifecycle request using Forge brokered GitHub tools only.`,"Do not use shell `gh` or direct GitHub CLI commands."].join(`
|
|
20
|
+
`)}function R(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}var YE={};function XE(e){return typeof e==`string`&&e.trim().length>0}function ZE(e){let t=R(e);if(!t||!XE(t.requestId)||!R(t.answers)||!R(t.attachmentsByQuestionId))return!1;let n=R(t.questionTextById);if(t.questionTextById!==void 0&&!n)return!1;if(n){for(let e of Object.values(n))if(typeof e!=`string`)return!1}for(let e of Object.values(t.attachmentsByQuestionId)){if(!Array.isArray(e))return!1;for(let t of e){let e=R(t);if(!e||!XE(e.id)||!XE(e.name))return!1}}return!0}function QE(e,t){if(typeof e==`string`)return t.get(e)??e;if(Array.isArray(e))return e.map(e=>QE(e,t));let n=R(e);return n&&`answers`in n?{...n,answers:QE(n.answers,t)}:e}function $E(e,t){let n=t.map(e=>typeof e==`string`?e.trim():``);return n.length>0&&n.every(Boolean)?JSON.stringify([e,n.sort()]):void 0}function eD(e){return e&&typeof e==`object`?e:null}function tD(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function nD(e,t){let n=eD(e.item),r=e.toolName??e.tool??n?.tool??t;if(typeof r!=`string`)return{};let i=r.split(/__|[./]/).at(-1)?.replace(/[_\s]/g,``).toLowerCase();if(!i||!/^(askuserquestion|requestuserinput(?:async)?|askquestion|question)$/.test(i))return{};let a=eD(e.input??e.rawInput??eD(e.state)?.input??n?.arguments),o=a?.questions??eD(a?.params)?.questions;return Array.isArray(o)?{input:{questions:o.map(e=>{let t=eD(e);return{question:tD(t?.question??t?.question_text??t?.prompt??t?.title)}})}}:{}}function rD(e){let t=new Set;for(let n of e){if(n.kind!==`user-input.answer-submitted`||!n.turnId)continue;let e=R(n.payload),r=Object.values(R(e?.questionTextById)??YE),i=$E(n.turnId,r);i&&t.add(i)}if(t.size===0)return e;let n=new Set;for(let r of e){if(!r.kind.startsWith(`tool.`)||!r.turnId)continue;let e=R(r.payload);if(typeof e?.toolCallId!=`string`)continue;let i=nD(R(e.data)??{},e.title).input;if(!i)continue;let a=$E(r.turnId,i.questions.map(e=>e.question));a&&t.has(a)&&n.add(JSON.stringify([r.turnId,e.toolCallId]))}return e.filter(e=>{let t=R(e.payload),r=t?.toolCallId;return e.tone===`error`||/^(failed|declined|stopped|cancelled)$/.test(String(t?.status))||!e.kind.startsWith(`tool.`)||typeof r!=`string`||!n.has(JSON.stringify([e.turnId,r]))})}function iD(e){let t=new Map;for(let n of e){if(n.kind!==`user-input.requested`&&n.kind!==`user-input.resolved`&&n.kind!==`user-input.answer-submitted`)continue;let e=R(n.payload)?.requestId;if(typeof e!=`string`||!e)continue;let r=t.get(e)??[];r.push(n),t.set(e,r)}let n=new Map;for(let[e,r]of t){let t=r.map(e=>R(e.payload)),i=new Map,a=new Map;for(let e of t){for(let[t,n]of Object.entries(R(e.questionTextById)??YE))a.set(t,n);for(let t of Array.isArray(e.questions)?e.questions:[]){let e=R(t);typeof e?.id==`string`&&(i.set(e.id,e),typeof e.question==`string`&&a.set(e.id,e.question))}}let o=Object.fromEntries(a),s=R(R(r.findLast(e=>e.kind===`user-input.answer-submitted`&&R(R(e.payload)?.answers))?.payload)?.answers)??t.map(e=>R(e.answers)).findLast(Boolean)??{},c=Object.fromEntries(Object.entries(s).map(([e,t])=>{let n=i.get(e)?.options,r=new Map;for(let e of Array.isArray(n)?n:[]){let t=R(e);typeof t?.label==`string`&&(typeof t.value==`string`&&r.set(t.value,t.label),r.set(t.label,t.label))}return[e,QE(t,r)]})),l=Object.fromEntries(t.flatMap(e=>Object.entries(R(e.attachmentsByQuestionId)??YE))),u={requestId:e,questionTextById:o,answers:c,attachmentsByQuestionId:l};if(!ZE(u))continue;let d=Object.keys(c).length>0||Object.keys(l).length>0;for(let e of r)n.set(e,null);n.set(r[0],{...r[0],kind:`user-input.answer-submitted`,tone:`tool`,summary:d?`User input submitted`:r.some(e=>e.kind===`user-input.resolved`)?`User input dismissed`:`User input requested`,payload:u})}return rD(e.flatMap(e=>{let t=n.get(e);return t===null?[]:[t??e]}))}function aD(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(aD).filter(Boolean).join(`, `);let t=R(e);return t?aD(t.answers):``}function oD(e){let t=Object.values(e.answers).map(aD).filter(Boolean),n=Object.values(e.attachmentsByQuestionId).flat().map(e=>e.name);return(t.length>0?t.join(` · `):n.length>0?n.join(`, `):Object.values(e.questionTextById??{}).join(` · `)).replace(/\s+/g,` `).trim()}function sD(e){return Object.values(e.answers).some(aD)||Object.values(e.attachmentsByQuestionId).some(e=>e.length>0)}function cD(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function lD(e,t){if(typeof e!=`string`)return;let n=e.trim();return n&&n.length<=t?n:void 0}function uD(e){let t=lD(e,4096);if(t)try{let e=new URL(t);return e.protocol===`http:`||e.protocol===`https:`||e.protocol===`data:`?e.href:void 0}catch{return}}function dD(e){let t=lD(e,4096);if(t)try{let e=new URL(t);return e.protocol===`http:`||e.protocol===`https:`?e.href:void 0}catch{return}}function fD(e){let t=cD(e),n=lD(t?.appId,512);if(t?._tag===`app-id`&&n&&/^[A-Za-z0-9._-]+$/u.test(n))return{_tag:`app-id`,appId:n};let r=lD(t?.displayName,160);if(t?._tag===`display-name`&&r)return{_tag:`display-name`,displayName:r}}function pD(e){let t=cD(e);if(t?._tag===`website`){let e=dD(t.pageUrl),n=uD(t.faviconUrl),r=uD(t.faviconUrlDark);if(e)return{_tag:`website`,pageUrl:e,...n?{faviconUrl:n}:{},...r?{faviconUrlDark:r}:{}}}if(t?._tag===`native-app`){let e=fD(t.app);if(e)return{_tag:`native-app`,app:e}}if(t?._tag===`themed-logo`){let e=uD(t.logoUrl),n=uD(t.logoUrlDark);if(e)return{_tag:`themed-logo`,logoUrl:e,...n?{logoUrlDark:n}:{}}}}function mD(e){let t=cD(e),n=lD(t?.key,512),r=lD(t?.name,160),i=t?.kind;if(!n||!r||i!==`browser`&&i!==`computer`&&i!==`integration`)return;let a=pD(t?.icon);return{key:n,name:r,kind:i,...a?{icon:a}:{}}}function hD(e){let t=cD(e),n=t?.toolSurface===`browser`||t?.toolSurface===`computer`?t.toolSurface:void 0,r=pD(t?.toolIcon),i=mD(t?.toolSource);return{...n?{toolSurface:n}:{},...r?{toolIcon:r}:{},...i?{toolSource:i}:{}}}function gD(e,t,n){return e===t||e.endsWith(`.${t}`)?!0:n!==void 0&&e.split(`.`).includes(n)}function _D(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`&&t.protocol!==`http:`)return null;let n=t.hostname.toLowerCase();if(gD(n,`github.com`,`github`)){let e=/^\/([^/]+\/[^/]+)\/pull\/(\d+)(?:\/|$)/u.exec(t.pathname);if(e)return vD(n,e)}let r=/^\/([^/]+(?:\/[^/]+)+)\/pulls\/(\d+)(?:\/|$)/u.exec(t.pathname);if(r){let e=vD(n,r);return e===null?null:{...e,authority:t.host.toLowerCase()}}let i=/^\/([^/]+(?:\/[^/]+)+)\/-\/merge_requests\/(\d+)(?:\/|$)/u.exec(t.pathname);return i?vD(n,i):gD(n,`bitbucket.org`,`bitbucket`)?vD(n,/^\/([^/]+\/[^/]+)\/pull-requests\/(\d+)(?:\/|$)/u.exec(t.pathname)):gD(n,`dev.azure.com`)||n.endsWith(`.visualstudio.com`)?vD(n,/^\/((?:[^/]+\/)*_git\/[^/]+)\/pullrequest\/(\d+)(?:\/|$)/u.exec(t.pathname)):null}function vD(e,t){let n=t?.[1],r=Number(t?.[2]);return n&&Number.isSafeInteger(r)&&r>0?{host:e,repository:n.toLowerCase(),number:r}:null}function yD(e){return e.replace(/\s+(?:complete|completed)\s*$/i,``).trim()}var bD={link_pull_request:[`Link`,`Linking`,`Linked`,`a pull request`],unlink_pull_request:[`Unlink`,`Unlinking`,`Unlinked`,`a pull request`],list_thread_pull_requests:[`Check`,`Checking`,`Checked`,`linked pull requests`],orchestrator_capabilities:[`Get`,`Getting`,`Got`,`orchestration capabilities`],delegate_task:[`Delegate`,`Delegating`,`Delegated`,`a child task`],task_status:[`Get`,`Getting`,`Got`,`delegated task status`],task_cancel:[`Cancel`,`Canceling`,`Canceled`,`delegated task`],schedule_task:[`Schedule`,`Scheduling`,`Scheduled`,`a recurring task`],list_scheduled_tasks:[`List`,`Listing`,`Listed`,`scheduled tasks`],update_scheduled_task:[`Update`,`Updating`,`Updated`,`a scheduled task`],delete_scheduled_task:[`Delete`,`Deleting`,`Deleted`,`a scheduled task`],create_threads:[`Create`,`Creating`,`Created`,`T3 threads`],t3_thread_start:[`Start`,`Starting`,`Started`,`a T3 thread`],t3_thread_list:[`List`,`Listing`,`Listed`,`T3 threads`],t3_thread_read:[`Read`,`Reading`,`Read`,`a T3 thread`],t3_thread_send:[`Send`,`Sending`,`Sent`,`to a T3 thread`],t3_thread_wait:[`Wait`,`Waiting`,`Waited`,`for a T3 thread`],t3_thread_interrupt:[`Interrupt`,`Interrupting`,`Interrupted`,`a T3 thread`],t3_worktree_handoff:[`Hand off`,`Handing off`,`Handed off`,`thread to a git worktree`],t3_worktree_status:[`Get`,`Getting`,`Got`,`thread worktree status`],preview_status:[`Get`,`Getting`,`Got`,`preview browser status`],preview_open:[`Open`,`Opening`,`Opened`,`a page in the preview browser`],preview_navigate:[`Navigate`,`Navigating`,`Navigated`,`the preview browser`],preview_snapshot:[`Take a snapshot of`,`Taking a snapshot of`,`Took a snapshot of`,`the preview page`],preview_click:[`Click`,`Clicking`,`Clicked`,`in the preview browser`],preview_press:[`Press`,`Pressing`,`Pressed`,`a key in the preview browser`],preview_type:[`Type`,`Typing`,`Typed`,`in the preview browser`],preview_scroll:[`Scroll`,`Scrolling`,`Scrolled`,`the preview browser`],preview_resize:[`Resize`,`Resizing`,`Resized`,`the preview browser`],preview_evaluate:[`Evaluate`,`Evaluating`,`Evaluated`,`script in the preview browser`],preview_wait_for:[`Wait`,`Waiting`,`Waited`,`for the preview page`],preview_set_appearance:[`Set`,`Setting`,`Set`,`preview browser appearance`],preview_recording_start:[`Start`,`Starting`,`Started`,`recording the preview browser`],preview_recording_stop:[`Stop`,`Stopping`,`Stopped`,`recording the preview browser`],device_list:[`List`,`Listing`,`Listed`,`simulators and emulators`],device_open:[`Open`,`Opening`,`Opened`,`a device in the Device panel`],device_screenshot:[`Take a screenshot of`,`Taking a screenshot of`,`Took a screenshot of`,`the device`],device_close:[`Close`,`Closing`,`Closed`,`a device`]},xD={link_pull_request:`link-pr`,unlink_pull_request:`unlink-pr`,list_thread_pull_requests:`list-prs`};function SD(e,t,n){if(!e)return null;let r=yD(e).replace(/^(?:mcp__(?:t3-code|t3_code|t3code)__|(?:t3-code|t3_code|t3code)(?:[.:/]|\s*·\s*))/i,``);if(!Object.hasOwn(bD,r))return null;let[i,a,o,s]=bD[r],c=t===`inProgress`?a:t===`completed`?o:t===`failed`?`Failed to ${i.toLowerCase()}`:t===`declined`?`Declined to ${i.toLowerCase()}`:t===`stopped`?`Stopped ${a.toLowerCase()}`:a,l=Object.hasOwn(xD,r)?xD[r]:void 0,u=TD(n),d=TD(u?.arguments)??TD(u?.input)??TD(u?.rawInput),f=(typeof d?.url==`string`?_D(d.url):null)?.number??d?.number;return{displayName:`${c} ${l!==void 0&&l!==`list-prs`&&typeof f==`number`&&Number.isSafeInteger(f)&&f>0?`PR #${f}`:s}`,icon:l===void 0?r.startsWith(`preview_`)?`browser`:r.startsWith(`device_`)?`device`:`t3-code`:`pull-request`,...l===void 0?{}:{action:l}}}function CD(e,t){return e===`failed`||e===`declined`||e===`stopped`?e:t||e===`inProgress`?`inProgress`:`completed`}function wD(e,t){let n=e.toolLifecycleStatus??t,r=e.toolData;if(typeof r==`object`&&r){if(`server`in r&&typeof r.server==`string`&&`tool`in r&&typeof r.tool==`string`)return SD(`${r.server}.${r.tool}`,n,r);if(`toolName`in r&&typeof r.toolName==`string`)return SD(r.toolName,n,r)}return SD(e.toolTitle,n,r)??SD(e.label,n,r)}function TD(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function ED(e){let t=TD(e);switch(t?.status){case`pending`:case`running`:case`waiting`:return`inProgress`;case`cancelled`:case`interrupted`:return`stopped`;case`idle`:return t.taskType===`subagent_batch`?`stopped`:void 0;case`inProgress`:case`completed`:case`failed`:case`declined`:case`stopped`:return t.status;default:return}}function DD(e){return e.tone===`tool`||e.tone===`thinking`||e.tone===`error`||e.command!==void 0&&e.command.trim().length>0||e.requestKind!==void 0||e.itemType!==void 0&&Kr(e.itemType)}function OD(e){let t=e.toLowerCase();return t.includes(`file not found`)||t.includes(`no files found`)||t.includes(`enoent`)||t.includes(`no such file or directory`)||t.includes(`no such file`)||t.includes(`commandnotfoundexception`)||t.includes(`command not found`)||t.includes(`cannot find path`)&&t.includes(`because it does not exist`)||t.includes(`is not recognized`)&&t.includes(`the term '`)||t.includes(`is not recognized as the name of a cmdlet`)||t.includes(`a parameter cannot be found that matches parameter name`)||/<exited with exit code\s+[1-9]\d*\s*>/i.test(e)||/exit(?:ed)? with exit code\s+[1-9]\d*/i.test(e)||/exit code\s*[:\s]\s*[1-9]\d*\b/i.test(e)}function kD(e,t){if(e.tone===`error`||e.toolLifecycleStatus===`failed`||e.toolLifecycleStatus===`declined`)return!0;if(!DD(e))return!1;let n=t?[e.detail,e.command].filter(Boolean).join(`
|
|
21
|
+
`):e.detail??``;return n.length>0&&OD(n)}function AD(e){return kD(e,!0)}function jD(e){return kD(e,!1)}function MD(e){return DD(e)&&!AD(e)&&e.tone!==`thinking`&&e.toolLifecycleStatus!==`inProgress`&&e.toolLifecycleStatus!==`stopped`}function ND(e){let t=e.taskId??``,n=t.indexOf(`:wf:`);return n===-1?e.agentSpawn?.workflowId?`wf:${e.agentSpawn.workflowId}`:e.isWorkflowCoordinator?`wf:${t}`:e.turnId?`direct:${e.turnId}`:`direct:task:${t}`:`wf:${t.slice(0,n)}`}function PD(e){if(e.sourceActivityKind===`tool.updated`||e.sourceActivityKind===`tool.completed`)return e.toolCallId?`tool:${e.turnId??`no-turn`}:${e.toolCallId}`:void 0}function FD(e){let t=[],n=new Map,r=new Map,i=new Map;for(let a of e){if(a.taskId!==void 0&&!a.isBackgroundTask&&(a.sourceActivityKind===`task.started`||a.sourceActivityKind===`task.progress`||a.sourceActivityKind===`task.completed`)&&a.taskId!==void 0){let e=r.get(a.taskId),i=e??ND(a);e===void 0&&r.set(a.taskId,i);let o=i.startsWith(`wf:`)?i.slice(3):null,s=n.get(i);if(s!==void 0){let e=t[s],n=e.agentSpawn?.agentTaskIds.includes(a.taskId)?e.agentSpawn.agentTaskIds:[...e.agentSpawn?.agentTaskIds??[],a.taskId];t[s]={...LD(e,a),id:e.id,createdAt:e.createdAt,turnId:e.turnId??null,...e.taskId===void 0?{}:{taskId:e.taskId},label:e.label,agentSpawn:{workflowId:o,agentTaskIds:n}};continue}n.set(i,t.length),t.push({...a,agentSpawn:{workflowId:o,agentTaskIds:[a.taskId]}});continue}let e=PD(a);if(e!==void 0){let n=i.get(e),r=n===void 0?void 0:t[n];if(n!==void 0&&r&&ID(r,a)){t[n]=LD(r,a);continue}i.delete(e)}let o=t.at(-1);if(o&&ID(o,a)){let e=t.length-1,n=PD(o);n!==void 0&&i.delete(n);let r=LD(o,a);t[e]=r;let s=PD(r);s!==void 0&&i.set(s,e);continue}t.push(a),e!==void 0&&i.set(e,t.length-1)}return t}function ID(e,t){return e.sourceActivityKind!==`tool.updated`&&e.sourceActivityKind!==`tool.completed`||t.sourceActivityKind!==`tool.updated`&&t.sourceActivityKind!==`tool.completed`||e.turnId!==t.turnId||e.sourceActivityKind===`tool.completed`?!1:e.collapseKey!==void 0&&e.collapseKey===t.collapseKey||e.toolCallId!==void 0&&t.toolCallId===void 0&&e.itemType===t.itemType&&yD(e.toolTitle??e.label)===yD(t.toolTitle??t.label)}function LD(e,t){let n=RD(e.changedFiles,t.changedFiles),r=t.detail??e.detail,i=t.viewedImagePath??e.viewedImagePath,a=t.command??e.command,o=t.rawCommand??e.rawCommand,s=t.toolTitle??e.toolTitle,c=t.toolSurface??e.toolSurface,l=t.toolIcon??e.toolIcon,u=t.toolSource??e.toolSource,d=t.itemType??e.itemType,f=t.requestKind??e.requestKind,p=t.collapseKey??e.collapseKey,m=t.toolCallId??e.toolCallId,h=t.toolLifecycleStatus??e.toolLifecycleStatus,g=t.toolData??e.toolData;return{...e,...t,...r?{detail:r}:{},...i?{viewedImagePath:i}:{},...a?{command:a}:{},...o?{rawCommand:o}:{},...n.length>0?{changedFiles:n}:{},...s?{toolTitle:s}:{},...c?{toolSurface:c}:{},...l?{toolIcon:l}:{},...u?{toolSource:u}:{},...d?{itemType:d}:{},...f?{requestKind:f}:{},...p?{collapseKey:p}:{},...m?{toolCallId:m}:{},...h===void 0?{}:{toolLifecycleStatus:h},...g===void 0?{}:{toolData:g}}}function RD(e,t){let n=[...e??[],...t??[]];return n.length===0?[]:[...new Set(n)]}function zD(e){if(e.taskId&&(e.sourceActivityKind===`task.progress`||e.sourceActivityKind===`task.completed`))return`task${e.taskId}`;if(e.sourceActivityKind!==`tool.updated`&&e.sourceActivityKind!==`tool.completed`)return;if(e.toolCallId)return`tool:${e.turnId??`no-turn`}:${e.toolCallId}`;let t=yD(e.toolTitle??e.label),n=e.detail?.trim()??``,r=e.itemType??``;if(t.length!==0||n.length!==0||r.length!==0)return[r,t,n].join(``)}function BD(e){let t=KD(e?.data);return qD(e?.toolCallId)??qD(t?.toolCallId)}function VD(e){switch(e){case`command_execution_approval`:case`exec_command_approval`:return`command`;case`file_read_approval`:return`file-read`;case`file_change_approval`:case`apply_patch_approval`:return`file-change`;default:return null}}function HD(e){return e?.requestKind===`command`||e?.requestKind===`file-read`||e?.requestKind===`file-change`?e.requestKind:VD(e?.requestType)??void 0}function UD(e,t,n){let r=qD(n);!r||t.has(r)||(t.add(r),e.push(r))}function WD(e,t,n,r){if(r>4||t.length>=12)return;if(Array.isArray(e)){for(let i of e)if(WD(i,t,n,r+1),t.length>=12)return;return}let i=KD(e);if(i){UD(t,n,i.path),UD(t,n,i.filePath),UD(t,n,i.relativePath),UD(t,n,i.filename),UD(t,n,i.newPath),UD(t,n,i.oldPath);for(let e of[`item`,`result`,`input`,`data`,`changes`,`files`,`edits`,`patch`,`patches`,`operations`])if(e in i&&(WD(i[e],t,n,r+1),t.length>=12))return}}function GD(e){let t=[],n=new Set;return WD(KD(e?.data),t,n,0),t}function KD(e){return e&&typeof e==`object`?e:null}function qD(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}var JD=new WeakMap;function YD(e){return!(e.agentSpawn!==void 0||!DD(e)||AD(e)||MD(e))}function XD(e){let t=JD.get(e);if(t)return t;let n=e.payload&&typeof e.payload==`object`?e.payload:null,r=JT(n),i=GD(n),a=ME(n),o=hD(n),s=e.kind===`task.progress`||e.kind===`task.completed`,c=s&&typeof n?.summary==`string`&&n.summary.length>0?n.summary:null,l=s&&!c&&typeof n?.detail==`string`&&n.detail.length>0?n.detail:null,u=c||l,d=s?!l&&n&&typeof n.detail==`string`&&n.detail.length>0?YT(n.detail).output:null:EE(n,a??e.summary),f=s?null:BD(n),p={id:e.id,createdAt:e.createdAt,turnId:e.turnId,label:u||e.summary,tone:e.kind===`task.progress`?`thinking`:e.tone,sourceActivityKind:e.kind};if(e.kind===`user-input.answer-submitted`){let e=n&&ZE(n)?n:null;e&&(p.questionAnswer={requestId:e.requestId,questionTextById:e.questionTextById,answers:e.answers,attachmentsByQuestionId:e.attachmentsByQuestionId})}let m=_E(n),h=HD(n),g=qD(KD(n?.data)?.imagePath);if(d)p.detail=d;else if(e.kind===`runtime.error`||e.kind===`runtime.warning`){let t=gE(n,e.summary);t&&(p.detail=t)}if(g&&(p.viewedImagePath=g),r.command&&(p.command=r.command),r.rawCommand&&(p.rawCommand=r.rawCommand),i.length>0&&(p.changedFiles=i),a&&(p.toolTitle=a),o.toolSurface&&(p.toolSurface=o.toolSurface),o.toolIcon&&(p.toolIcon=o.toolIcon),o.toolSource&&(p.toolSource=o.toolSource),m===`mcp_tool_call`){let e=KD(n?.data),t=typeof e?.toolName==`string`?e.item??e:e?.item;t!==void 0&&(p.toolData=t)}m&&(p.itemType=m),h&&(p.requestKind=h),f&&(p.toolCallId=f);let _=ED(n);!_&&e.kind===`tool.completed`&&(_=`completed`),_&&(p.toolLifecycleStatus=_);let v=e.kind===`task.started`||e.kind===`task.progress`||e.kind===`task.completed`;v&&typeof n?.taskId==`string`&&n.taskId.length>0&&(p.taskId=n.taskId),v&&typeof n?.role==`string`&&n.role.length>0&&(p.agentRole=n.role),v&&(n?.taskType===`local_workflow`||typeof n?.workflowName==`string`&&n.workflowName.length>0)&&(p.isWorkflowCoordinator=!0),v&&n&&n.agentKind!==`agent`&&(p.isBackgroundTask=!0);let y=LE(n);if(y)p.githubConfirmation=y,p.tone=`approval`,p.label=`GitHub action needs approval`,p.toolTitle=VE(y.operation),p.detail=HE(y);else{let e=RE(n);e&&(p.githubActionRequired=e,p.tone=`approval`,p.label=UE(e.action),p.toolTitle=`GitHub setup required`,p.detail=GE(e))}let b=zD(p);return b&&(p.collapseKey=b),JD.set(e,p),p}var ZD=new Set([`tool.started`,`task.started`,`context-window.updated`,`text-generation.usage`,`worktree.stage`,`launch.agent-starting`,`turn.terminal-status`]);function QD(e){return ZD.has(e.kind)||e.summary===`Checkpoint captured`}function $D(e,t){return!t.latestTurnId||e.turnId===t.latestTurnId||eO(e)?!0:tO(e,t.latestTurnStartedAt)}function eO(e){return e.kind.startsWith(`worktree.`)||e.kind.startsWith(`setup-script.`)}function tO(e,t){return e.turnId!==null||e.tone!==`error`||t===null?!1:e.createdAt>=t}function nO(e){return e.agentKind===`agent`}function rO(e){let t=e.payload&&typeof e.payload==`object`?e.payload:null;return!t||typeof t.taskId!=`string`?!1:nO(t)}function iO(e){let t=e.payload&&typeof e.payload==`object`?e.payload:null;return t?e.kind===`task.started`||e.kind===`task.progress`||e.kind===`task.updated`||e.kind===`task.completed`?typeof t.agentId==`string`&&t.agentId.trim().length>0||t.timelineBypass===!0?!(e.kind!==`task.updated`&&typeof t.taskId==`string`&&nO(t)):!1:t.timelineBypass===!0||typeof t.agentId==`string`&&t.agentId.trim().length>0:!1}function aO(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`forge:debug-mode`)===`true`}catch{return!1}}function oO(e){if(e.kind!==`tool.updated`&&e.kind!==`tool.completed`)return!1;let t=e.payload&&typeof e.payload==`object`?e.payload:null;return typeof t?.detail==`string`&&t.detail.startsWith(`ExitPlanMode:`)}function sO(e,t,n){let r=aO(),i={latestTurnId:t,latestTurnStartedAt:n??null},a=[...e].toSorted(cO),o=new Set;for(let e of a)if((e.kind===`task.started`||e.kind===`task.progress`||e.kind===`task.completed`)&&rO(e)){let t=qD(KD(e.payload)?.toolUseId);t&&o.add(t)}let s=[];for(let e of iD(a)){if(!$D(e,i)||!(e.kind===`task.started`&&rO(e))&&QD(e)||e.kind===`task.started`&&!rO(e)||e.kind===`task.updated`||e.kind===`tool.progress`||e.kind===`turn.plan.updated`||!r&&hE(e)||oO(e)||iO(e))continue;let t=XD(e);if(e.kind===`tool.updated`&&t.itemType===`collab_agent_tool_call`&&t.toolLifecycleStatus===`inProgress`&&t.tone!==`error`){let t=KD(KD(e.payload)?.data)?.toolName;if(t===`Agent`||t===`Task`)continue}(e.kind===`tool.updated`||e.kind===`tool.completed`)&&t.toolCallId&&o.has(t.toolCallId)&&t.tone!==`error`&&t.toolLifecycleStatus!==`failed`||s.push(t)}return FD(s).map(({sourceActivityKind:e,collapseKey:t,isWorkflowCoordinator:n,isBackgroundTask:r,...i})=>i)}function cO(e,t){if(e.sequence!==void 0&&t.sequence!==void 0){if(e.sequence!==t.sequence)return e.sequence-t.sequence}else if(e.sequence!==void 0)return 1;else if(t.sequence!==void 0)return-1;let n=e.createdAt.localeCompare(t.createdAt);if(n!==0)return n;let r=lO(e.kind)-lO(t.kind);return r===0?e.id.localeCompare(t.id):r}function lO(e){return e.endsWith(`.started`)||e===`tool.started`?0:e.endsWith(`.progress`)||e.endsWith(`.updated`)?1:e.endsWith(`.completed`)||e.endsWith(`.resolved`)?2:1}function uO(e){return{id:e.id,kind:`message`,createdAt:e.createdAt,message:e}}function dO(e){return{id:e.id,kind:`proposed-plan`,createdAt:e.createdAt,proposedPlan:e}}function fO(e){return{id:e.id,kind:`work`,createdAt:e.createdAt,entry:e}}function pO(e,t){return e.createdAt.localeCompare(t.createdAt)}function mO(e){switch(e.kind){case`message`:return 0;case`proposed-plan`:return 1;case`work`:return 2}}function hO(e,t){let n=pO(e,t);return n===0?mO(e)<=mO(t):n<0}function gO(e,t){if(e===t)return!0;if(t.length<e.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function _O(e,t){if(t.length===0)return[...e];let n=e.at(-1),r=!0;for(let e=1;e<t.length;e+=1)if(pO(t[e-1],t[e])>0){r=!1;break}if(r&&(n===void 0||hO(n,t[0])))return[...e,...t];let i=[],a=0,o=0;for(;a<e.length||o<t.length;){let n=e[a],r=t[o];n!==void 0&&(r===void 0||hO(n,r))?(i.push(n),a+=1):r!==void 0&&(i.push(r),o+=1)}return i}var vO=e=>e===`assistant`||e===`reasoning`;function yO(e,t){if(!vO(e.role)||e.role!==t.role||!e.streaming||!t.streaming)return!1;let{text:n,updatedAt:r,...i}=e,{text:a,updatedAt:o,...s}=t;return $m(i,s)}function bO(e,t){if(e.length!==t.messages.length)return null;let n=new Map;for(let[r,i]of e.entries()){let e=t.messages[r];if(i!==e){if(!yO(e,i))return null;n.set(e,i)}}return n.size===0?t.entries:t.entries.map(e=>{let t=e.kind===`message`?n.get(e.message):void 0;return t?uO(t):e})}function xO(e,t,n,r=null){if(r!==null&&r.proposedPlans.length===t.length&&r.workEntries.length===n.length&&gO(r.proposedPlans,t)&&gO(r.workEntries,n)){let i=bO(e,r);if(i!==null)return{messages:e,proposedPlans:t,workEntries:n,entries:i}}let i=new Set(n.flatMap(e=>e.questionAnswer?[`async-answer:${e.questionAnswer.requestId}`]:[])),a=e=>e.role!==`user`||!i.has(e.id);if(r!==null&&!r.entries.some(e=>e.kind===`message`&&!a(e.message))&&gO(r.messages,e)&&gO(r.proposedPlans,t)&&gO(r.workEntries,n)){let i=e.slice(r.messages.length).filter(a).map(uO),o=t.slice(r.proposedPlans.length).map(dO),s=n.slice(r.workEntries.length).map(fO),c=[...i,...o,...s].toSorted(pO);return{messages:e,proposedPlans:t,workEntries:n,entries:_O(r.entries,c)}}let o=e.filter(a).map(uO),s=t.map(dO),c=n.map(fO);return{messages:e,proposedPlans:t,workEntries:n,entries:[...o,...s,...c].toSorted(pO)}}var SO=[{value:`codex`,label:`Codex`,available:!0},{value:`claudeAgent`,label:`Claude`,available:!0},{value:`cmmd`,label:`CMMD`,available:!0},{value:`ollama`,label:`Ollama`,available:!1},{value:`cursor`,label:`Cursor`,available:!1}];function CO(e){if(!Number.isFinite(e)||e<0)return`0ms`;if(e<1e3)return`${Math.max(1,Math.round(e))}ms`;if(e<1e4)return`${(e/1e3).toFixed(1)}s`;if(e<6e4)return`${Math.round(e/1e3)}s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return n===0?`${t}m`:n===60?`${t+1}m`:`${t}m ${n}s`}function wO(e,t){if(!t)return null;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)||r<n?null:CO(r-n)}function TO(e,t){return!e?.startedAt||!e.completedAt?!1:!t||t.orchestrationStatus!==`running`}function EO(e,t,n){let r=t?.orchestrationStatus===`running`?t.activeTurnId??null:null;return r===null?TO(e,t)?n:e?.startedAt??n:e?.turnId===r?e.startedAt??n:n}function DO(e){let t=e?.toLowerCase();return t?t.includes(`stale pending approval request`)||t.includes(`stale pending user-input request`)||t.includes(`unknown pending approval request`)||t.includes(`unknown pending permission request`)||t.includes(`unknown pending user-input request`):!1}function OO(e){let t=new Map,n=[...e].toSorted(cO);for(let e of n){let n=e.payload&&typeof e.payload==`object`?e.payload:null,r=n&&typeof n.requestId==`string`?Ar.make(n.requestId):null,i=n&&(n.requestKind===`command`||n.requestKind===`file-read`||n.requestKind===`file-change`)?n.requestKind:n?VD(n.requestType):null,a=n&&typeof n.detail==`string`?n.detail:void 0;if(e.kind===`approval.requested`&&r&&i){t.set(r,{requestId:r,requestKind:i,createdAt:e.createdAt,...a?{detail:a}:{}});continue}if(e.kind===`approval.resolved`&&r){t.delete(r);continue}if(e.kind===`provider.approval.respond.failed`&&r&&DO(a)){t.delete(r);continue}}return[...t.values()].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function kO(e){let t=e?.questions;if(!Array.isArray(t))return null;let n=t.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.id!=`string`||typeof t.header!=`string`||typeof t.question!=`string`||!Array.isArray(t.options))return null;let n=t.options.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return typeof t.label!=`string`||typeof t.description!=`string`?null:{label:t.label,description:t.description}}).filter(e=>e!==null);return n.length===0?null:{id:t.id,header:t.header,question:t.question,options:n,multiSelect:t.multiSelect===!0}}).filter(e=>e!==null);return n.length>0?n:null}function AO(e){let t=new Map,n=[...e].toSorted(cO);for(let e of n){let n=e.payload&&typeof e.payload==`object`?e.payload:null,r=n&&typeof n.requestId==`string`?Ar.make(n.requestId):null,i=n&&typeof n.detail==`string`?n.detail:void 0;if(e.kind===`user-input.requested`&&r){let i=kO(n);if(!i)continue;t.set(r,{requestId:r,createdAt:e.createdAt,questions:i});continue}if(e.kind===`user-input.resolved`&&r){t.delete(r);continue}e.kind===`provider.user-input.respond.failed`&&r&&DO(i)&&t.delete(r)}return[...t.values()].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}function jO(e,t){if(!t)return null;let n=[...e].toSorted(cO),r=null;for(let e of n){let t=RE(e.payload&&typeof e.payload==`object`?e.payload:null);t&&(r={request:t,turnId:e.turnId})}return!r||r.turnId!==t?null:r.request}function MO(e,t){let n=[...e].toSorted(cO),r=n.filter(e=>e.kind===`turn.plan.updated`),i=(t?r.findLast(e=>e.turnId===t):void 0)??r.at(-1)??null;if(!i)return null;let a=GT(i);if(!a)return null;let o=r.filter(e=>e.turnId===i.turnId),s=o.findLastIndex(e=>GT(e)===null),c=qT(a,o.slice(s+1)),l=i.turnId!==null&&n.some(e=>e.kind===`turn.completed`&&e.turnId===i.turnId&&cO(i,e)<0);return{...c,steps:l?c.steps.map(e=>e.status===`inProgress`?{...e,status:`completed`}:e):c.steps}}function NO(e,t){if(t){let n=[...e].filter(e=>e.turnId===t).toSorted((e,t)=>e.updatedAt.localeCompare(t.updatedAt)||e.id.localeCompare(t.id)).at(-1);if(n)return YO(n)}let n=[...e].toSorted((e,t)=>e.updatedAt.localeCompare(t.updatedAt)||e.id.localeCompare(t.id)).at(-1);return n?YO(n):null}function PO(e){let t=e.threads.find(t=>t.id===e.threadId)?.proposedPlans??[];if(!e.latestTurnSettled){let t=e.latestTurn?.sourceProposedPlan;if(t){let n=e.threads.find(e=>e.id===t.threadId)?.proposedPlans.find(e=>e.id===t.planId);if(n)return YO(n)}}return NO(t,e.latestTurn?.turnId??null)}function FO(e){return e!==null&&e.implementedAt===null}function IO(e,t){return t?e.some(e=>e.turnId===t&&e.tone===`tool`):!1}var LO=new WeakMap;function RO(e,t){if(e.role!==`assistant`)return[];let n=BO(e.text,{workEntries:t,createdAt:e.createdAt});if(!n)return[];let r=LO.get(e),i=`${e.id}:github-confirmation:${n.confirmationId}`;if(r&&r[0]?.id===i)return r;let a=[{id:i,kind:`work`,createdAt:e.createdAt,entry:{id:i,createdAt:e.createdAt,label:`GitHub action needs approval`,detail:HE(n),tone:`approval`,toolTitle:VE(n.operation),githubConfirmation:n}}];return LO.set(e,a),a}function zO(e,t,n,r){let i=xO(e,t,n,r),a=e.flatMap(e=>RO(e,n));if(a.length===0)return i;let o=new Set(i.entries.map(e=>e.id)),s=a.filter(e=>!o.has(e.id));return s.length===0?i:{...i,entries:[...i.entries,...s].toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt))}}function BO(e,t){if(!e.includes(`confirm_github_tool`))return null;let n=GO(e,/\b(?:New confirmation id|Confirmation id):\s*`?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})`?/i)??null,r=/\bRepo(?: to create)?:\s*(private|public|internal)\s+`?([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)`?/i.exec(e);if(!n)return null;let i=VO(e,n,t);if(i)return i;if(!r)return null;let a=r[1]?.toLowerCase(),o=r[2],s=r[3];return!o||!s?null:{confirmationId:n,toolName:`forge_github_create_repository`,operation:`create_repository`,request:{owner:o,name:s,visibility:a}}}function VO(e,t,n){if(!HO(e))return null;let r=UO(n?.workEntries??[],n?.createdAt,`forge_github_refresh_credentials`)?.request,i=r?WO(r.cwd):null;return i?{confirmationId:t,toolName:`forge_github_refresh_credentials`,operation:`refresh_credentials`,request:{cwd:i}}:null}function HO(e){return/\bforge_github_refresh_credentials\b/i.test(e)||/\bcredential refresh\b/i.test(e)||/\brefresh(?:ing)? GitHub credentials\b/i.test(e)}function UO(e,t,n){for(let r of e.toReversed()){if(t!==void 0&&r.createdAt>t)continue;let e=r.githubConfirmation;if(e?.toolName===n)return e}return null}function WO(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function GO(e,t){return t.exec(e)?.[1]??null}function KO(e){let t=[...e].toSorted((e,t)=>e.completedAt.localeCompare(t.completedAt)),n={};for(let e=0;e<t.length;e+=1){let r=t[e];r&&(n[r.turnId]=e+1)}return n}function qO(e){return!e||e.status===`closed`?`disconnected`:e.status===`connecting`?`connecting`:e.status===`running`?`running`:`ready`}function JO(e,t){if(t===`disconnected`||t===`connecting`)return null;for(let t of e.toReversed())if(t.kind===`work`&&t.entry.githubConfirmation)return t.entry.githubConfirmation;return null}function YO(e){return{id:e.id,createdAt:e.createdAt,updatedAt:e.updatedAt,turnId:e.turnId,planMarkdown:e.planMarkdown,implementedAt:e.implementedAt,implementationThreadId:e.implementationThreadId}}function XO(e){let t=e.browser,n=t?{openSession:t.openSession,listSessions:t.listSessions,closeSession:t.closeSession,getSession:t.getSession,command:t.command,clearBrowsingData:t.clearBrowsingData,attachDisplay:t.attachDisplay,addDisplayIceCandidate:async e=>{await t.addDisplayIceCandidate(e)},onEvent:(e,n)=>t.onEvent(e,n)}:void 0;return{...n?{browser:n}:{},attachments:{createUploadUrl:t=>e.attachments.createUploadUrl(t),delete:t=>e.attachments.delete(t)},computer:{input:t=>e.computer.input(t)},threadDevRuntime:{get:t=>e.threadDevRuntime.get(t),allocatePort:t=>e.threadDevRuntime.allocatePort(t),release:t=>e.threadDevRuntime.release(t)},devTunnel:{register:t=>e.devTunnel.register(t),unregister:t=>e.devTunnel.unregister(t),list:t=>e.devTunnel.list(t)},terminal:{open:t=>e.terminal.open(t),write:t=>e.terminal.write(t),resize:t=>e.terminal.resize(t),signal:t=>e.terminal.signal(t),clear:t=>e.terminal.clear(t),restart:t=>e.terminal.restart(t),close:t=>e.terminal.close(t),onEvent:t=>e.terminal.onEvent(t)},projects:{searchContents:e.projects.searchContents,searchEntries:e.projects.searchEntries,readFile:e.projects.readFile,writeFile:e.projects.writeFile},workspace:{environmentPreflight:e.workspace.environmentPreflight,ensureScratch:e.workspace.ensureScratch},shell:{openInEditor:t=>e.shell.openInEditor(t)},git:{pull:e.git.pull,refreshStatus:e.git.refreshStatus,onStatus:(t,n,r)=>e.git.onStatus(t,n,r),listBranches:e.git.listBranches,createWorktree:e.git.createWorktree,removeWorktree:e.git.removeWorktree,createBranch:e.git.createBranch,checkout:e.git.checkout,init:e.git.init,resolvePullRequest:e.git.resolvePullRequest,preparePullRequestThread:e.git.preparePullRequestThread},pullRequests:{list:t=>e.pullRequests.list(t),listStats:t=>e.pullRequests.listStats(t),detail:t=>e.pullRequests.detail(t),activity:t=>e.pullRequests.activity(t),threadComments:t=>e.pullRequests.threadComments(t),diffFileContents:t=>e.pullRequests.diffFileContents(t),runAction:t=>e.pullRequests.runAction(t),update:t=>e.pullRequests.update(t),comment:t=>e.pullRequests.comment(t),updateComment:t=>e.pullRequests.updateComment(t),submitReview:t=>e.pullRequests.submitReview(t),replyToThread:t=>e.pullRequests.replyToThread(t),setThreadResolution:t=>e.pullRequests.setThreadResolution(t),setReaction:t=>e.pullRequests.setReaction(t),invalidate:t=>e.pullRequests.invalidate(t),reviewerCandidates:t=>e.pullRequests.reviewerCandidates(t),requestReviewers:t=>e.pullRequests.requestReviewers(t)},orchestration:{dispatchCommand:e.orchestration.dispatchCommand,getTurnDiff:e.orchestration.getTurnDiff,getFullThreadDiff:e.orchestration.getFullThreadDiff,subscribeShell:(t,n)=>e.orchestration.subscribeShell(t,n),subscribeThread:(t,n,r)=>e.orchestration.subscribeThread(t,n,r)}}}function ZO(e){if(typeof window>`u`||!e)return;let t=tw(e);return t?XO(t.client):void 0}function QO(e){let t=(0,A.c)(4),n;t[0]===e?n=t[1]:(n=()=>tw(e),t[0]=e,t[1]=n);let r=(0,O.useSyncExternalStore)(ew,n,$O),i,a;return t[2]===r?a=t[3]:(a=r?XO(r.client):void 0,t[2]=r,t[3]=a),i=a,i}function $O(){return null}function ek(e){let t=ZO(e);if(!t)throw Error(`Environment API not found for environment ${e}`);return t}var tk=[`preview`,`terminal`,`canvas`,`diff`,`plan`,`task`,`simulator`,`display`,`agents`,`file`,`pull-request`],nk={isOpen:!1,isMaximized:!1,activeSurfaceId:null,surfaces:[]};function rk(e){return e===null?{id:`browser:new`,kind:`preview`,resourceId:null}:{id:`browser:${e}`,kind:`preview`,resourceId:e}}function ik(e,t,n,r=`execution-intent`){return{id:`file:${e}`,kind:`file`,relativePath:e,revealLine:t,revealRequestId:n,readPolicy:r}}function ak(e){let t=[e.provider,e.environmentId,e.repositoryLinkId??``,e.projectId,e.host.toLowerCase(),e.repository,String(e.number)].map(e=>encodeURIComponent(e)).join(`:`);return{...e,id:`pull-request:${t}`,kind:`pull-request`}}function ok(e){return e===`diff`?{id:`diff`,kind:`diff`,turnId:null,filePath:null}:{id:e,kind:e}}var sk=`workspace:pull-requests`;function ck(e){return typeof e==`object`&&!!e}function lk(e){return typeof e==`string`&&tk.includes(e)}function uk(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(1,Math.trunc(e)):null}function dk(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:0}function fk(e){let t=e.relativePath;return typeof t!=`string`||t.length===0?null:{id:`file:${t}`,kind:`file`,relativePath:t,revealLine:uk(e.revealLine),revealRequestId:dk(e.revealRequestId),readPolicy:e.readPolicy===`connected-only`?`connected-only`:`execution-intent`}}function pk(e){let t=e.resourceId;return t==null?{id:`browser:new`,kind:`preview`,resourceId:null}:typeof t!=`string`||t.length===0?null:{id:`browser:${t}`,kind:`preview`,resourceId:t}}function mk(e){let t=e.turnId,n=e.filePath,r=typeof t==`string`&&t.length>0?Hr.make(t):null;return{id:`diff`,kind:`diff`,turnId:r,filePath:r&&typeof n==`string`&&n.length>0?n:null}}var hk=new Set([`github`,`gitlab`,`azure-devops`,`bitbucket`,`unknown`]);function gk(e){return typeof e==`string`&&e.length>0}function _k(e){return e===null||typeof e==`string`}function vk(e){return e===void 0||_k(e)}function yk(e){let t=e.provider,n=e.environmentId,r=e.repositoryLinkId,i=e.projectId,a=e.host,o=e.repository,s=uk(e.number),c=e.title;return![gk(t)&&hk.has(t),gk(n),_k(r),gk(i),gk(a),gk(o),s!==null,vk(c)].every(Boolean)||!gk(t)||!gk(n)?null:ak({provider:t,environmentId:Ur.make(n),repositoryLinkId:r,projectId:Si.make(i),host:a,repository:o,number:s,...typeof c==`string`||c===null?{title:c}:{}})}function bk(e){let t=e.label;if(typeof t!=`string`)return;let n=t.trim();return n.length>0?n:void 0}function xk(e){if(!ck(e)||!lk(e.kind))return null;let t=e.kind,n=t===`file`?fk(e):t===`preview`?pk(e):t===`diff`?mk(e):t===`pull-request`?yk(e):{id:t,kind:t};if(n===null)return null;let r=bk(e);return r===void 0?n:{...n,label:r}}function Sk(e){let t=[],n=new Set;for(let r of Array.isArray(e)?e:[]){let e=xk(r);!e||n.has(e.id)||(n.add(e.id),t.push(e))}return t}function Ck(e){if(!ck(e))return null;let t=Sk(e.surfaces);if(t.length===0)return null;let n=e.activeSurfaceId,r=t.some(e=>e.id===n),i=typeof n==`string`&&r?n:t[0]?.id??null;return{isOpen:e.isOpen===!0,activeSurfaceId:i,surfaces:t}}function wk(e){if(!ck(e)||!ck(e.byThreadKey))return{byThreadKey:{}};let t={};for(let[n,r]of Object.entries(e.byThreadKey)){if(n===sk)continue;let e=Ck(r);e&&(t[n]=e)}return{byThreadKey:t}}var Tk=`forge:right-panel-state`,Ek=3,Dk=e=>e===`workspace:pull-requests`;function Ok(e){return`draft:${e}`}function kk(e){return e.startsWith(`draft:`)}function Ak(e){return e==null||!Number.isFinite(e)?null:Math.max(1,Math.trunc(e))}var jk=(e,t,n=!0)=>({...e,isOpen:!0,surfaces:e.surfaces.some(e=>e.id===t.id)?e.surfaces:[...e.surfaces,t],activeSurfaceId:n?t.id:e.activeSurfaceId});function Mk(e,t){if(t.length===0){let{label:t,...n}=e;return n}return{...e,label:t}}var z=(e,t,n)=>{let r=e[t]??nk,i=n(r);if(!i.isOpen&&i.activeSurfaceId===null&&i.surfaces.length===0){if(!(t in e))return e;let{[t]:n,...r}=e;return r}return i===r?e:{...e,[t]:i}},Nk=Oa()(Wf(e=>({byThreadKey:{},open:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>jk(e,e.surfaces.find(e=>e.kind===n)??ok(n)))})),openBrowser:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t=n?e.surfaces.filter(e=>e.id!==`browser:new`):e.surfaces;return jk({...e,surfaces:t},rk(n))})})),revealBrowser:t=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>jk(e,e.surfaces.find(e=>e.kind===`preview`)??rk(null)))})),openDiff:(t,n,r)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t={id:`diff`,kind:`diff`,turnId:n??null,filePath:n?r??null:null};return{...e,isOpen:!0,activeSurfaceId:t.id,surfaces:e.surfaces.some(e=>e.id===`diff`)?e.surfaces.map(e=>e.id===`diff`?t:e):[...e.surfaces,t]}})})),openFile:(t,n,r,i=`execution-intent`)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t=`file:${n}`,a=e.surfaces.find(e=>e.id===t&&e.kind===`file`),o=ik(n,Ak(r),(a?.revealRequestId??0)+1,i);return{...e,isOpen:!0,activeSurfaceId:o.id,surfaces:a?e.surfaces.map(e=>e.id===o.id?o:e):[...e.surfaces,o]}})})),openPullRequest:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>jk(e,ak(n)))})),activateSurface:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>e.surfaces.some(e=>e.id===n)?{...e,isOpen:!0,activeSurfaceId:n}:e)})),closeSurface:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t=e.surfaces.findIndex(e=>e.id===n);if(t<0)return e;let r=e.surfaces.filter(e=>e.id!==n);if(e.activeSurfaceId!==n)return{...e,isOpen:r.length>0&&e.isOpen,surfaces:r};let i=r[Math.min(t,r.length-1)]??null;return{...e,isOpen:r.length>0&&e.isOpen,surfaces:r,activeSurfaceId:i?.id??null}})})),closeOtherSurfaces:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t=e.surfaces.find(e=>e.id===n);return!t||e.surfaces.length===1?e:{...e,isOpen:!0,surfaces:[t],activeSurfaceId:t.id}})})),closeSurfacesToRight:(t,n)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t=e.surfaces.findIndex(e=>e.id===n);if(t<0||t===e.surfaces.length-1)return e;let r=e.surfaces.slice(0,t+1),i=r.some(t=>t.id===e.activeSurfaceId);return{...e,surfaces:r,activeSurfaceId:i?e.activeSurfaceId:n}})})),closeAllSurfaces:t=>e(e=>({byThreadKey:z(e.byThreadKey,t,()=>nk)})),renameSurface:(t,n,r)=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>{let t=r.trim();return{...e,surfaces:e.surfaces.map(e=>e.id===n?Mk(e,t):e)}})})),show:t=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>({...e,isOpen:!0}))})),close:t=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>e.isOpen?{...e,isOpen:!1,isMaximized:!1}:e)})),toggleVisibility:t=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>({...e,isOpen:!e.isOpen}))})),toggleMaximized:t=>e(e=>({byThreadKey:z(e.byThreadKey,t,e=>e.isOpen?{...e,isMaximized:!(e.isMaximized??!1)}:e)})),removeThread:t=>e(e=>{if(!(t in e.byThreadKey))return e;let{[t]:n,...r}=e.byThreadKey;return{byThreadKey:r}})}),{name:Tk,version:Ek,storage:Hf(()=>jn),partialize:e=>({byThreadKey:Object.fromEntries(Object.entries(e.byThreadKey).filter(([e])=>!kk(e)&&!Dk(e)))}),migrate:e=>wk(e)}));function Pk(e,t){let n={hour:`numeric`,minute:`2-digit`,...t?{second:`2-digit`}:{}};return e===`locale`?n:{...n,hour12:e===`12-hour`}}var Fk=new Map;function Ik(e,t){let n=`${e}:${t?`seconds`:`minutes`}`,r=Fk.get(n);if(r)return r;let i=new Intl.DateTimeFormat(void 0,Pk(e,t));return Fk.set(n,i),i}function Lk(e,t){return Ik(t,!0).format(new Date(e))}function Rk(e,t){return Ik(t,!1).format(new Date(e))}function zk(e){let t=Date.now()-new Date(e).getTime();if(t<0)return{value:`just now`,suffix:null};let n=Math.floor(t/1e3);if(n<60)return{value:`just now`,suffix:null};let r=Math.floor(n/60);if(r<60)return{value:`${r}m`,suffix:`ago`};let i=Math.floor(r/60);return i<24?{value:`${i}h`,suffix:`ago`}:{value:`${Math.floor(i/24)}d`,suffix:`ago`}}function Bk(e){let t=zk(e);return t.suffix?`${t.value} ${t.suffix}`:t.value}function Vk(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}var Hk=Object.freeze({data:null,error:null,cause:null,isPending:!1}),Uk=Object.freeze({...Hk,isPending:!0}),Wk=un(Hk).pipe(ln,sn(`git-status:null`)),Gk=()=>void 0,Kk=new Map,qk=new Set,Jk=new Map,Yk=new Map,Xk=1e3,Zk=on(e=>(qk.add(e),un(Uk).pipe(ln,sn(`git-status:${e}`))));function Qk(e){return e.environmentId===null||Vk(e.cwd)===null?null:`${e.environmentId}:${e.cwd}`}function $k(e){if(e.environmentId===null)return null;let t=tw(e.environmentId);return t?{clientIdentity:t.environmentId,client:t.client.git}:null}function eA(e){let t=Qk(e);return t===null?Hk:cn.get(Zk(t))}function tA(e,t){let n=Qk(e);if(n===null)return Gk;let r=Kk.get(n);return r?(r.refCount+=1,()=>iA(n)):(Kk.set(n,{refCount:1,unsubscribe:aA(n,e,t)}),()=>iA(n))}function nA(e,t){let n=Qk(e),r=Vk(e.cwd);if(n===null||r===null)return Promise.resolve(null);let i=t??$k(e)?.client;if(!i)return Promise.resolve(eA(e).data);let a=Jk.get(n);if(a)return a;let o=Yk.get(n)??0;if(Date.now()-o<Xk)return Promise.resolve(eA(e).data);Yk.set(n,Date.now());let s=i.refreshStatus({cwd:r}).finally(()=>{Jk.delete(n)});return Jk.set(n,s),s}function rA(e){let t=(0,A.c)(4),n=Qk(e),r,i;t[0]!==e.cwd||t[1]!==e.environmentId?(r=()=>tA({environmentId:e.environmentId,cwd:e.cwd}),i=[e.environmentId,e.cwd],t[0]=e.cwd,t[1]=e.environmentId,t[2]=r,t[3]=i):(r=t[2],i=t[3]),(0,O.useEffect)(r,i);let a=ha(n===null?Wk:Zk(n));return n===null?Hk:a}function iA(e){let t=Kk.get(e);t&&(--t.refCount,!(t.refCount>0)&&(t.unsubscribe(),Kk.delete(e)))}function aA(e,t,n){let r=Vk(t.cwd);if(r===null)return Gk;let i=null,a=Gk,o=()=>{let o=n?{clientIdentity:`provided:${e}`,client:n}:$k(t);if(!o){i!==null&&(a(),a=Gk,i=null),sA(e);return}i!==o.clientIdentity&&(a(),i=o.clientIdentity,a=oA(e,r,o.client))},s=n?Gk:ew(o);return o(),()=>{s(),a()}}function oA(e,t,n){return sA(e),n.onStatus({cwd:t},t=>{cn.set(Zk(e),{data:t,error:null,cause:null,isPending:!1})},{onResubscribe:()=>{sA(e)}})}function sA(e){let t=Zk(e),n=cn.get(t),r=n.data===null?Uk:{...n,error:null,cause:null,isPending:!0};(n.data!==r.data||n.error!==r.error||n.cause!==r.cause||n.isPending!==r.isPending)&&cn.set(t,r)}function cA(e){let t=[];for(let n of e){let e=n.children??[];if(e.length>0){t.push({item:n,isGroupLabel:!0});for(let n of e)t.push({item:n,isGroupLabel:!1});continue}Array.isArray(n.children)||t.push({item:n,isGroupLabel:!1})}return t}function lA(e){let t=document.createElement(`div`);return t.textContent=e,t.className=`px-2 pt-1.5 pb-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground/70`,t}function uA(e){let t=document.createElement(`button`);return t.type=`button`,t.textContent=e.label,t.disabled=e.disabled,t.className=e.disabled?`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[11px] text-muted-foreground/50 cursor-not-allowed`:e.destructive?`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[11px] text-destructive transition-colors hover:bg-accent`:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[11px] text-popover-foreground transition-colors hover:bg-accent`,t}function dA(e,t){return new Promise(n=>{let r=document.createElement(`div`);r.style.cssText=`position:fixed;inset:0;z-index:9999`;let i=document.createElement(`div`);i.className=`fixed z-[10000] min-w-[160px] rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg/5 outline-none before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`;let a=t?.x??0,o=t?.y??0;i.style.top=`${o}px`,i.style.left=`${a}px`;function s(e){document.removeEventListener(`keydown`,c),r.remove(),i.remove(),n(e)}function c(e){e.key===`Escape`&&(e.preventDefault(),s(null))}r.addEventListener(`mousedown`,()=>s(null)),document.addEventListener(`keydown`,c);let l=!1;for(let{item:t,isGroupLabel:n}of cA(e)){if(n){i.appendChild(lA(t.label));continue}let e=t.destructive===!0||t.id===`delete`,r=t.disabled===!0;if(e&&!l){let e=document.createElement(`div`);e.className=`-mx-1 my-1 h-px bg-border`,i.appendChild(e),l=!0}let a=uA({label:t.label,disabled:r,destructive:e});r||a.addEventListener(`click`,()=>s(t.id)),i.appendChild(a)}document.body.appendChild(r),document.body.appendChild(i),requestAnimationFrame(()=>{let e=i.getBoundingClientRect();e.right>window.innerWidth&&(i.style.left=`${window.innerWidth-e.width-4}px`),e.bottom>window.innerHeight&&(i.style.top=`${window.innerHeight-e.height-4}px`)})})}var fA;function pA(){return mA(iw().client)}function mA(e){return{getConfig:e.server.getConfig,refreshProviders:e.server.refreshProviders,startProviderAuth:e.server.startProviderAuth,repairProviderAuthRuntime:e.server.repairProviderAuthRuntime,disconnectProviderAuth:e.server.disconnectProviderAuth,getProviderAuthSession:e.server.getProviderAuthSession,cancelProviderAuth:e.server.cancelProviderAuth,submitProviderAuthCode:e.server.submitProviderAuthCode,syncPersonalCodexToCloud:e.server.syncPersonalCodexToCloud,syncPersonalClaudeToCloud:e.server.syncPersonalClaudeToCloud,upsertKeybinding:e.server.upsertKeybinding,removeKeybinding:e.server.removeKeybinding,getSettings:e.server.getSettings,updateSettings:e.server.updateSettings,updateEnvironmentDisplayName:async t=>{let n=await e.server.updateEnvironmentDisplayName({displayName:t});return Ww(n.environment),n}}}function hA(e,t){return{...e,...t,dialogs:{...e.dialogs,...t.dialogs},shell:{...e.shell,...t.shell},contextMenu:{...e.contextMenu,...t.contextMenu},persistence:{...e.persistence,...t.persistence},server:{...e.server,...t.server}}}function gA(e){return{dialogs:{pickFolder:async()=>window.desktopBridge?window.desktopBridge.pickFolder():null,confirm:async e=>window.desktopBridge?window.desktopBridge.confirm(e):window.confirm(e)},shell:{openInEditor:(t,n)=>e.shell.openInEditor({cwd:t,editor:n}),openExternal:async e=>{if(window.desktopBridge){if(!await window.desktopBridge.openExternal(e))throw Error(`Unable to open link.`);return}window.open(e,`_blank`,`noopener,noreferrer`)}},contextMenu:{show:async(e,t)=>window.desktopBridge?window.desktopBridge.showContextMenu(e,t):dA(e,t)},persistence:{getClientSettings:nr,setClientSettings:sr,getSavedEnvironmentRegistry:mr,setSavedEnvironmentRegistry:ir,getSavedEnvironmentSecret:qn,setSavedEnvironmentSecret:Qn,removeSavedEnvironmentSecret:Yn},server:mA(e)}}function _A(){if(typeof window>`u`)return;if(fA)return fA;let e=gA(iw().client);return window.nativeApi?(fA=hA(e,window.nativeApi),fA):(fA=e,fA)}function vA(){let e=_A();if(!e)throw Error(`Local API not found`);return e}function yA(){let e=(0,A.c)(2),[t,n]=(0,O.useState)(bA),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>(n(La()),Fa(()=>{n(La())})),i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,O.useEffect)(r,i),t}function bA(){return La()}function xA(e,t){e.style.setProperty(`--appearance-contrast-base`,`${Math.min(t,100)}%`),e.style.setProperty(`--appearance-contrast-boost`,`${Math.max(t-100,0)}%`),e.style.setProperty(`--appearance-contrast-border-boost`,`${Math.max(t-100,0)/4}%`)}var SA=`-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif`,CA=`ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace`;function wA(e){let t=e.trim();return t.length===0?``:/^(['"]).*\1$/u.test(t)||/^[a-zA-Z][a-zA-Z0-9-]*$/u.test(t)?t:`"${t.replaceAll(`"`,``)}"`}function TA(e){let t=e.split(`,`).map(wA).filter(e=>e.length>0);return t.length>0?t.join(`, `):null}var EA={appearanceContrastBase:`--appearance-contrast-base`,appearanceContrastBoost:`--appearance-contrast-boost`,appearanceContrastBorderBoost:`--appearance-contrast-border-boost`,fontSans:`--font-sans`,fontMono:`--font-mono`,fontComposer:`--font-composer`,fontTerminal:`--font-terminal`,promptFontSize:`--forge-prompt-font-size`,terminalFontSize:`--forge-terminal-font-size`,glassOpacity:`--glass-opacity`};function DA(e,t){let n=[[EA.fontSans,t.fontFamilySans,SA],[EA.fontMono,t.fontFamilyCode,CA],[EA.fontComposer,t.fontFamilyComposer,`var(--font-sans)`],[EA.fontTerminal,t.fontFamilyTerminal,`var(--font-mono)`]];for(let[t,r,i]of n){let n=TA(r);if(n===null){e.style.removeProperty(t);continue}e.style.setProperty(t,`${n}, ${i}`)}e.style.setProperty(EA.promptFontSize,`${String(t.promptFontSize)}px`),e.style.setProperty(EA.terminalFontSize,`${String(t.terminalFontSize)}px`),e.style.setProperty(EA.glassOpacity,`${String(t.glassOpacity)}%`),xA(e,t.appearanceContrast),t.fontSmoothing?e.style.setProperty(`-webkit-font-smoothing`,`antialiased`):e.style.removeProperty(`-webkit-font-smoothing`)}function OA(){return typeof window<`u`&&typeof localStorage<`u`}function kA(){if(!OA())return{};try{let e=JSON.parse(window.localStorage.getItem(`forge:theme-halves:v1`)??`null`);if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let n of[`light`,`dark`]){let r=e[n];typeof r==`string`&&(t[n]=r)}return t}catch{return{}}}function AA(){if(!OA())return null;try{return Pa(window.localStorage.getItem(za))}catch{return null}}function jA(e){if(OA())try{e===null||e.light===void 0&&e.dark===void 0?window.localStorage.removeItem(za):window.localStorage.setItem(za,JSON.stringify(e))}catch{}}function MA(e,t,n){let r={...e};return n===null?delete r[t]:r[t]=n,r}function NA(e){return e!==null&&(e.light!==void 0||e.dark!==void 0)?e:null}function PA(e,t){let n=(0,A.c)(13),[r,i]=(0,O.useState)(FA),a=yA(),o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(e,t)=>{let n=MA(kA(),e,t);return jA(n),i(NA(n)),!0},n[0]=o):o=n[0];let s=o,c;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>(jA(null),i(null),!0),n[1]=c):c=n[1];let l=c,u;n[2]!==t||n[3]!==r||n[4]!==e?(u=()=>{let n=t===`dark`?`dark`:`light`;Ia(Ra(e,r,n),n)},n[2]=t,n[3]=r,n[4]=e,n[5]=u):u=n[5];let d;n[6]!==a||n[7]!==t||n[8]!==r||n[9]!==e?(d=[e,t,r,a],n[6]=a,n[7]=t,n[8]=r,n[9]=e,n[10]=d):d=n[10],(0,O.useEffect)(u,d);let f;return n[11]===r?f=n[12]:(f={themeHalves:r,setThemeHalf:s,clearThemeHalves:l},n[11]=r,n[12]=f),f}function FA(){return AA()}var IA=`theme-color`,LA=`meta[name="${IA}"][data-dynamic-theme-color="true"]`,RA={dark:`#0a0a0a`,light:`#ffffff`};function zA(){let e=document.querySelector(LA);return e||(e=document.createElement(`meta`),e.name=IA,e.setAttribute(`data-dynamic-theme-color`,`true`),document.head.append(e),e)}function BA(e){let t=e?.trim().toLowerCase();return!t||t===`transparent`||t===`rgba(0, 0, 0, 0)`||t===`rgba(0 0 0 / 0)`?null:e?.trim()??null}function VA(){return document.querySelector(`main[data-slot='sidebar-inset']`)??document.querySelector(`[data-slot='sidebar-inner']`)??document.body}function HA(){return document.documentElement.classList.contains(`dark`)?`dark`:`light`}function UA(e=HA()){if(typeof document>`u`||typeof getComputedStyle>`u`)return;document.documentElement.style.backgroundColor=``,document.body.style.backgroundColor=``;let t=BA(getComputedStyle(VA()).backgroundColor),n=BA(getComputedStyle(document.body).backgroundColor),r=t??n??RA[e];document.documentElement.style.backgroundColor=r,document.body.style.backgroundColor=r,zA().setAttribute(`content`,r)}var WA=`forge:theme`,GA=`(prefers-color-scheme: dark)`;function KA(e){return e===`system`||e===`light`||e===`dark`}function qA(e,t){return typeof e!=`number`||!Number.isFinite(e)?t:Math.min(20,Math.max(11,Math.round(e)))}function JA(){if(!OA())return{theme:`system`,uiFontSize:16,codeFontSize:13};try{let e=window.localStorage.getItem(Xn);if(e){let t=Wn(JSON.parse(e));return{theme:KA(t.theme)?t.theme:`system`,uiFontSize:qA(t.uiFontSize,16),codeFontSize:qA(t.codeFontSize,13)}}let t=window.localStorage.getItem(WA);return{theme:KA(t)?t:`system`,uiFontSize:16,codeFontSize:13}}catch{return{theme:`system`,uiFontSize:16,codeFontSize:13}}}function YA(){return typeof window>`u`||typeof window.matchMedia!=`function`||window.matchMedia(GA).matches?`dark`:`light`}function XA(e){return e===`system`?YA():e}function ZA(e){if(typeof window>`u`)return;let t=window.desktopBridge;t&&t.setTheme(e).catch(()=>{})}function QA(e,t=!1){let n=XA(e);return typeof document>`u`||typeof window>`u`?n:(t&&document.documentElement.classList.add(`no-transitions`),document.documentElement.classList.toggle(`dark`,n===`dark`),document.documentElement.dataset.theme=e,document.documentElement.style.colorScheme=n,UA(n),ZA(e),t&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove(`no-transitions`)})),n)}function $A(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-ui-font-size`,`${qA(e,16)}px`)}function ej(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-code-font-size`,`${qA(e,13)}px`)}function tj(e){$A(e.uiFontSize),ej(e.codeFontSize)}if(typeof document<`u`){let e=JA();QA(e.theme),tj(e)}function nj(){let e=(0,A.c)(33),t=AT(oj),n=AT(aj),r=AT(ij),i=AT(rj),{updateSettings:a}=jT(),o;e[0]===t?o=e[1]:(o=()=>XA(t),e[0]=t,e[1]=o);let[s,c]=(0,O.useState)(o),{themeHalves:l,setThemeHalf:u,clearThemeHalves:d}=PA(n,s),f;e[2]===a?f=e[3]:(f=e=>{a({theme:e}),c(QA(e,!0))},e[2]=a,e[3]=f);let p=f,m;e[4]===a?m=e[5]:(m=e=>{a({themeId:e})},e[4]=a,e[5]=m);let h=m,g;e[6]===a?g=e[7]:(g=e=>{let t=qA(e,16);a({uiFontSize:t}),$A(t)},e[6]=a,e[7]=g);let _=g,v;e[8]===a?v=e[9]:(v=e=>{let t=qA(e,13);a({codeFontSize:t}),ej(t)},e[8]=a,e[9]=v);let y=v,b,x;e[10]===t?(b=e[11],x=e[12]):(b=()=>{c(QA(t))},x=[t],e[10]=t,e[11]=b,e[12]=x),(0,O.useEffect)(b,x);let ee,te;e[13]!==i||e[14]!==r?(ee=()=>{tj({uiFontSize:r,codeFontSize:i})},te=[r,i],e[13]=i,e[14]=r,e[15]=ee,e[16]=te):(ee=e[15],te=e[16]),(0,O.useEffect)(ee,te);let ne,re;e[17]===t?(ne=e[18],re=e[19]):(re=()=>{if(t!==`system`||typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(GA),n=()=>{c(QA(`system`,!0))};return e.addEventListener(`change`,n),()=>{e.removeEventListener(`change`,n)}},ne=[t],e[17]=t,e[18]=ne,e[19]=re),(0,O.useEffect)(re,ne);let ie;return e[20]!==d||e[21]!==i||e[22]!==s||e[23]!==y||e[24]!==p||e[25]!==u||e[26]!==h||e[27]!==_||e[28]!==t||e[29]!==l||e[30]!==n||e[31]!==r?(ie={theme:t,setTheme:p,themeId:n,setThemeId:h,resolvedTheme:s,themeHalves:l,setThemeHalf:u,clearThemeHalves:d,uiFontSize:r,codeFontSize:i,setUiFontSize:_,setCodeFontSize:y},e[20]=d,e[21]=i,e[22]=s,e[23]=y,e[24]=p,e[25]=u,e[26]=h,e[27]=_,e[28]=t,e[29]=l,e[30]=n,e[31]=r,e[32]=ie):ie=e[32],ie}function rj(e){return e.codeFontSize}function ij(e){return e.uiFontSize}function aj(e){return e.themeId}function oj(e){return e.theme}function sj(){let e=(0,A.c)(11),t=AT(gj),n=AT(hj),r=AT(mj),i=AT(pj),a=AT(fj),o=AT(dj),s=AT(uj),c=AT(lj),l=AT(cj),u,d;e[0]!==t||e[1]!==r||e[2]!==i||e[3]!==n||e[4]!==a||e[5]!==c||e[6]!==l||e[7]!==o||e[8]!==s?(u=()=>{typeof document>`u`||DA(document.documentElement,{appearanceContrast:t,fontFamilyCode:r,fontFamilyComposer:i,fontFamilySans:n,fontFamilyTerminal:a,fontSmoothing:c,glassOpacity:l,promptFontSize:o,terminalFontSize:s})},d=[t,r,i,n,a,c,l,o,s],e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=c,e[6]=l,e[7]=o,e[8]=s,e[9]=u,e[10]=d):(u=e[9],d=e[10]),(0,O.useEffect)(u,d)}function cj(e){return e.glassOpacity}function lj(e){return e.fontSmoothing}function uj(e){return e.terminalFontSize}function dj(e){return e.promptFontSize}function fj(e){return e.fontFamilyTerminal}function pj(e){return e.fontFamilyComposer}function mj(e){return e.fontFamilyCode}function hj(e){return e.fontFamilySans}function gj(e){return e.appearanceContrast}var _j=`forge:last-editor`;function vj(e){let t=(0,A.c)(5),[n,r]=Pn(_j,null,xi),i;bb0:{if(n&&e.includes(n)){i=n;break bb0}let r;t[0]===e?r=t[1]:(r=Cr.find(t=>e.includes(t.id))?.id??null,t[0]=e,t[1]=r),i=r}let a=i,o;return t[2]!==a||t[3]!==r?(o=[a,r],t[2]=a,t[3]=r,t[4]=o):o=t[4],o}function yj(e){let t=new Set(e),n=Mn(_j,xi);if(n&&t.has(n))return n;let r=Cr.find(e=>t.has(e.id))?.id??null;return r&&vr(_j,r,xi),r??null}async function bj(e,t){let{availableEditors:n}=await e.server.getConfig(),r=yj(n);if(!r)throw Error(`No available editors found.`);return await e.shell.openInEditor(t,r),r}var xj=/https?:\/\/[^\s"'`<>]+/g,Sj=/(?:~\/|\.{1,2}\/|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}/g,Cj=/[.,;!?]+$/;function wj(e){let t=e.replace(Cj,``);if(t.length===0)return t;let n=(e,n)=>{for(;t.endsWith(n);){if(t.split(e).length-1>=t.split(n).length-1)return;t=t.slice(0,-1)}};return n(`(`,`)`),n(`[`,`]`),n(`{`,`}`),t}function Tj(e,t){return e.start<t.end&&t.start<e.end}function Ej(e,t,n,r){let i=[];n.lastIndex=0;for(let a of e.matchAll(n)){let e=a[0],n=a.index??-1;if(n<0||e.length===0)continue;let o=wj(e);if(o.length===0||t===`path`&&/^https?:\/\//i.test(o))continue;let s={kind:t,text:o,start:n,end:n+o.length};[...r,...i].some(e=>Tj(s,e))||i.push(s)}return i}function Dj(e){return/^[A-Za-z]:[\\/]/.test(e)||e.startsWith(`\\\\`)}function Oj(e){return e.startsWith(`/`)||Dj(e)}function kj(e){return Dj(e)||/[A-Za-z]:\\/.test(e)}function Aj(e,t,n){let r=e.replace(/[\\/]+$/,``);return n===`\\`?`${r}\\${t.replaceAll(`/`,`\\`)}`:`${r}/${t.replace(/^\/+/,``)}`}function jj(e){let t=e.match(/^\/Users\/([^/]+)/);if(t?.[1])return`/Users/${t[1]}`;let n=e.match(/^\/home\/([^/]+)/);if(n?.[1])return`/home/${n[1]}`;let r=e.match(/^([A-Za-z]:\\Users\\[^\\]+)/);if(r?.[1])return r[1]}function Mj(e){let t=e,n,r,i=t.match(/:(\d+)$/);if(!i?.[1])return{path:t,line:void 0,column:void 0};n=i[1],t=t.slice(0,-i[0].length);let a=t.match(/:(\d+)$/);return a?.[1]?(r=a[1],t=t.slice(0,-a[0].length)):(r=n,n=void 0),{path:t,line:r,column:n}}function Nj(e){let t=Ej(e,`url`,xj,[]),n=Ej(e,`path`,Sj,t);return[...t,...n].toSorted((e,t)=>e.start-t.start)}function Pj(e,t){let n=t(e-1);if(!n)return null;let r=e,i=n;for(;r>1&&i.isWrapped;){let e=t(r-2);if(!e)return null;--r,i=e}let a=[],o=0,s=r;for(;;){let e=t(s-1);if(!e)break;let n=t(s)?.isWrapped===!0,r=e.translateToString(!n);if(a.push({bufferLineNumber:s,text:r,startIndex:o,endIndex:o+r.length}),o+=r.length,!n)break;s+=1}return{text:a.map(e=>e.text).join(``),segments:a}}function Fj(e,t){for(let n of e)if(t<n.endIndex)return{x:t-n.startIndex+1,y:n.bufferLineNumber};let n=e[e.length-1];return{x:Math.max(n?.text.length??0,1),y:n?.bufferLineNumber??1}}function Ij(e,t){return{start:Fj(e.segments,t.start),end:Fj(e.segments,t.end-1)}}function Lj(e,t){return e.start.y<=t&&t<=e.end.y}function Rj(e,t=typeof navigator>`u`?``:navigator.platform){return t.length===0?!1:Ca(t)?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function zj(e,t){let{path:n,line:r,column:i}=Mj(e),a=n;if(n.startsWith(`~/`)){let e=jj(t);if(e){let t=kj(e)?`\\`:`/`;a=Aj(e,n.slice(2),t)}}else Oj(n)||(a=Aj(t,n,kj(t)?`\\`:`/`));return r?`${a}:${r}${i?`:${i}`:``}`:a}var Bj=`diffs-container`,Vj=(()=>{try{return!1}catch{return!1}})(),Hj=/(?=^From [a-f0-9]+ .+$)/m,Uj=/(?=^diff --git)/gm,Wj=/(?<=\n)/,Gj=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Kj=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,qj=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,Jj=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,Yj=`header-prefix`,Xj=`header-filename-suffix`,Zj=`header-metadata`,Qj=`header-custom`,$j={dark:`pierre-dark`,light:`pierre-light`},eM=`data-theme-css`,tM=`data-unsafe-css`,nM=`data-diffs-scrollbar-measure`,rM=`data-diffs-code-view-header`,iM=`data-diffs-code-view-footer`,aM=`--diffs-scrollbar-gutter-measured`,oM=1e5,sM={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8},cM={...sM,hunkLineCount:1},lM={paddingTop:8,paddingBottom:8,gap:8},uM={omega:.015,positionEpsilon:.5,velocityEpsilon:.05},dM=Object.freeze({fromStart:0,fromEnd:0}),fM={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},pM={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0},mM=new Set,hM=null;function gM(e){mM.add(e),hM??=requestAnimationFrame(vM)}function _M(e){mM.delete(e)&&mM.size===0&&hM!=null&&(cancelAnimationFrame(hM),hM=null)}function vM(e){let t=new Set(mM);mM.clear();for(let n of t)try{n(e)}catch(e){console.error(e)}hM=mM.size>0?requestAnimationFrame(vM):null}function yM(e,t,n){if(e===t||e==null||t==null)return e===t;let r=new Set(n),i=Object.keys(e),a=new Set(Object.keys(t));for(let n of i)if(a.delete(n),!r.has(n)&&(!(n in t)||e[n]!==t[n]))return!1;for(let e of Array.from(a))if(!r.has(e))return!1;return!0}function bM(e,t){return e==null||t==null||typeof e==`string`||typeof t==`string`?e===t:e.dark===t.dark&&e.light===t.light}function xM(e,t){let n=e?.theme??$j,r=t?.theme??$j,i=SM(e),a=SM(t);return bM(n,r)&&yM(e,t,[`theme`,`parseDiffOptions`])&&yM(i,a)}function SM(e){if(e!=null&&`parseDiffOptions`in e)return e.parseDiffOptions}function CM(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}function wM({scrollTop:e,scrollHeight:t,height:n,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:a}){let o=n+a*2,s=r?n+i*2:o;if(t=Math.max(t,s),o>=t||r){let n=Math.max(e-i,0),r=Math.min(e+s,t);return{top:n,bottom:Math.max(r,n)}}let c=e+n/2-o/2,l=c+o;return c<0&&(c=0),l>t&&(l=t),c=Math.floor(Math.max(c,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(l,t),c))}}function TM(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}function EM(e,t){return e-(t===0?0:1)}function DM(e,t){return EM(e,t)+t}var OM=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},kM=new class extends OM{};function AM(e,t,n){return kM.diff(e,t,n)}function jM(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function MM(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function NM(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function PM(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function FM(e,t){return NM(e,t,``)}function IM(e,t){return PM(e,t,``)}function LM(e,t){return t.slice(0,RM(e,t))}function RM(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function zM(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function BM(e,t){if(t)return HM(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function VM(e,t){if(t)return HM(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function HM(e,t){if(!t)return[VM(e),BM(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=zM(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var UM=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,WM=RegExp(`[${UM}]+|\\s+|[^${UM}]`,`ug`);new class extends OM{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=zM(e,r)}else n=e.match(WM)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&GM(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&GM(n,i,r,null,t.intlSegmenter),e}};function GM(e,t,n,r,i){if(t&&n){let[a,o]=HM(t.value,i),[s,c]=HM(n.value,i);if(e){let r=jM(a,s);e.value=PM(e.value,s,r),t.value=FM(t.value,r),n.value=FM(n.value,r)}if(r){let e=MM(o,c);r.value=NM(r.value,c,e),t.value=IM(t.value,e),n.value=IM(n.value,e)}}else if(n){if(e){let e=VM(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=VM(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=VM(r.value,i),[a,o]=HM(t.value,i),s=jM(n,a);t.value=FM(t.value,s);let c=MM(FM(n,s),o);t.value=IM(t.value,c),r.value=NM(r.value,n,c),e.value=PM(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=VM(r.value,i),n=LM(BM(t.value,i),e);t.value=IM(t.value,n)}else if(e){let n=LM(BM(e.value,i),VM(t.value,i));t.value=FM(t.value,n)}}var KM=new class extends OM{tokenize(e){let t=RegExp(`(\\r?\\n)|[${UM}]+|[^\\S\\n\\r]+|[^${UM}]`,`ug`);return e.match(t)||[]}};function qM(e,t,n){return KM.diff(e,t,n)}var JM=new class extends OM{constructor(){super(...arguments),this.tokenize=XM}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
22
22
|
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
23
23
|
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
24
24
|
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
25
|
-
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function
|
|
26
|
-
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function
|
|
27
|
-
`)?e.lines[t]=e.lines[t].slice(0,-1):(e.lines.splice(t+1,0,`\`),t++);return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:a,hunks:o}}}function
|
|
28
|
-
`)}let n=[];if(e.isGit){if(t=
|
|
25
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function YM(e,t,n){return JM.diff(e,t,n)}function XM(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
26
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function ZM(e){return e==`.`||e==`!`||e==`?`}new class extends OM{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(ZM(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends OM{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends OM{constructor(){super(...arguments),this.tokenize=XM}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(QM(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function QM(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=QM(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=QM(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends OM{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};function $M(e){for(let t=0;t<e.length;t++)if(e[t]<` `||e[t]>`~`||e[t]===`"`||e[t]===`\\`)return!0;return!1}function eN(e){if(!$M(e))return e;let t=`"`,n=new TextEncoder().encode(e),r=0;for(;r<n.length;){let e=n[r];t+=e===7?`\\a`:e===8?`\\b`:e===9?`\\t`:e===10?`\\n`:e===11?`\\v`:e===12?`\\f`:e===13?`\\r`:e===34?`\\"`:e===92?`\\\\`:e>=32&&e<=126?String.fromCharCode(e):`\\`+e.toString(8).padStart(3,`0`),r++}return t+=`"`,t}var tN={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function nN(e,t,n,r,i,a,o){let s;s=o?typeof o==`function`?{callback:o}:o:{},s.context===void 0&&(s.context=4);let c=s.context;if(s.newlineIsToken)throw Error(`newlineIsToken may not be used with patch-generation functions, only with diffing functions`);if(s.callback){let{callback:e}=s;YM(n,r,Object.assign(Object.assign({},s),{callback:t=>{let n=l(t);e(n)}}))}else return l(YM(n,r,s));function l(n){if(!n)return;n.push({value:``,lines:[]});function r(e){return e.map(function(e){return` `+e})}let o=[],s=0,l=0,u=[],d=1,f=1;for(let e=0;e<n.length;e++){let t=n[e],i=t.lines||aN(t.value);if(t.lines=i,t.added||t.removed){if(!s){let t=n[e-1];s=d,l=f,t&&(u=c>0?r(t.lines.slice(-c)):[],s-=u.length,l-=u.length)}for(let e of i)u.push((t.added?`+`:`-`)+e);t.added?f+=i.length:d+=i.length}else{if(s)if(i.length<=c*2&&e<n.length-2)for(let e of r(i))u.push(e);else{let e=Math.min(i.length,c);for(let t of r(i.slice(0,e)))u.push(t);let t={oldStart:s,oldLines:d-s+e,newStart:l,newLines:f-l+e,lines:u};o.push(t),s=0,l=0,u=[]}d+=i.length,f+=i.length}}for(let e of o)for(let t=0;t<e.lines.length;t++)e.lines[t].endsWith(`
|
|
27
|
+
`)?e.lines[t]=e.lines[t].slice(0,-1):(e.lines.splice(t+1,0,`\`),t++);return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:a,hunks:o}}}function rN(e,t){if(t||=tN,Array.isArray(e)){if(e.length>1&&!t.includeFileHeaders&&!e.every(e=>e.isGit))throw Error(`Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)`);return e.map(e=>rN(e,t)).join(`
|
|
28
|
+
`)}let n=[];if(e.isGit){if(t=tN,!e.oldFileName)throw Error(`oldFileName must be specified for Git patches`);if(!e.newFileName)throw Error(`newFileName must be specified for Git patches`);let r=e.oldFileName,i=e.newFileName;e.isCreate&&r===`/dev/null`?r=i.replace(/^b\//,`a/`):e.isDelete&&i===`/dev/null`&&(i=r.replace(/^a\//,`b/`)),n.push(`diff --git `+eN(r)+` `+eN(i)),e.isDelete&&n.push(`deleted file mode `+(e.oldMode??`100644`)),e.isCreate&&n.push(`new file mode `+(e.newMode??`100644`)),e.oldMode&&e.newMode&&!e.isDelete&&!e.isCreate&&(n.push(`old mode `+e.oldMode),n.push(`new mode `+e.newMode)),e.isRename&&(n.push(`rename from `+eN((e.oldFileName??``).replace(/^a\//,``))),n.push(`rename to `+eN((e.newFileName??``).replace(/^b\//,``)))),e.isCopy&&(n.push(`copy from `+eN((e.oldFileName??``).replace(/^a\//,``))),n.push(`copy to `+eN((e.newFileName??``).replace(/^b\//,``))))}else t.includeIndex&&e.oldFileName==e.newFileName&&e.oldFileName!==void 0&&n.push(`Index: `+e.oldFileName),t.includeUnderline&&n.push(`===================================================================`);let r=e.hunks.length>0;t.includeFileHeaders&&e.oldFileName!==void 0&&e.newFileName!==void 0&&(!e.isGit||r)&&(n.push(`--- `+eN(e.oldFileName)+(e.oldHeader?` `+e.oldHeader:``)),n.push(`+++ `+eN(e.newFileName)+(e.newHeader?` `+e.newHeader:``)));for(let t=0;t<e.hunks.length;t++){let r=e.hunks[t],i=r.oldLines===0?r.oldStart-1:r.oldStart,a=r.newLines===0?r.newStart-1:r.newStart;n.push(`@@ -`+i+`,`+r.oldLines+` +`+a+`,`+r.newLines+` @@`);for(let e of r.lines)n.push(e)}return n.join(`
|
|
29
29
|
`)+`
|
|
30
|
-
`}function
|
|
30
|
+
`}function iN(e,t,n,r,i,a,o){if(typeof o==`function`&&(o={callback:o}),o?.callback){let{callback:s}=o;nN(e,t,n,r,i,a,Object.assign(Object.assign({},o),{callback:e=>{s(e?rN(e,o.headerOptions):void 0)}}))}else{let s=nN(e,t,n,r,i,a,o);return s?rN(s,o?.headerOptions):void 0}}function aN(e){let t=e.endsWith(`
|
|
31
31
|
`),n=e.split(`
|
|
32
32
|
`).map(e=>e+`
|
|
33
|
-
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function rN(e,t){return e?.cacheKey===t?.cacheKey&&e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}function iN(e){return{type:`text`,value:e}}function B({tagName:e,children:t=[],properties:n={}}){return{type:`element`,tagName:e,properties:n,children:t}}function aN({name:e,width:t=16,height:n=16,properties:r}){return B({tagName:`svg`,properties:{width:t,height:n,viewBox:`0 0 16 16`,...r},children:[B({tagName:`use`,properties:{href:`#${e.replace(/^#/,``)}`}})]})}function oN(e){let t=e.children[0];for(;t!=null;){if(t.type===`element`&&t.tagName===`code`)return t;t=`children`in t?t.children[0]:null}}function sN(e){return B({tagName:`div`,properties:{"data-gutter":``},children:e})}function cN(e,t,n,r={}){return B({tagName:`div`,properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...r},children:t==null?void 0:[B({tagName:`span`,properties:{"data-line-number-content":``},children:[iN(`${t}`)]})]})}function lN(e,t,n){return B({tagName:`div`,properties:{"data-gutter-buffer":t,"data-buffer-size":n,"data-line-type":t===`annotation`?void 0:e,style:t===`annotation`?`grid-row: span ${n};`:`grid-row: span ${n};min-height:calc(${n} * 1lh);`}})}function uN(){return B({tagName:`button`,properties:{"data-utility-button":``,type:`button`},children:[aN({name:`diffs-icon-plus`,properties:{"data-icon":``}})]})}function dN(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side}function fN(e){for(let t of e)if(t instanceof HTMLElement&&(t.hasAttribute(`data-utility-button`)||t.hasAttribute(`data-gutter-utility-slot`)||t.getAttribute(`slot`)===`gutter-utility-slot`||t.getAttribute(`name`)===`gutter-utility-slot`))return!0;return!1}var pN=[`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`image`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`],mN=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};mN.prototype.normal={},mN.prototype.property={},mN.prototype.space=void 0;function hN(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new mN(n,r,t)}function gN(e){return e.toLowerCase()}var _N=class{constructor(e,t){this.attribute=t,this.property=e}};_N.prototype.attribute=``,_N.prototype.booleanish=!1,_N.prototype.boolean=!1,_N.prototype.commaOrSpaceSeparated=!1,_N.prototype.commaSeparated=!1,_N.prototype.defined=!1,_N.prototype.mustUseProperty=!1,_N.prototype.number=!1,_N.prototype.overloadedBoolean=!1,_N.prototype.property=``,_N.prototype.spaceSeparated=!1,_N.prototype.space=void 0;var vN=e({boolean:()=>V,booleanish:()=>H,commaOrSpaceSeparated:()=>SN,commaSeparated:()=>xN,number:()=>U,overloadedBoolean:()=>bN,spaceSeparated:()=>W}),yN=0,V=CN(),H=CN(),bN=CN(),U=CN(),W=CN(),xN=CN(),SN=CN();function CN(){return 2**++yN}var wN=Object.keys(vN),TN=class extends _N{constructor(e,t,n,r){let i=-1;if(super(e,t),EN(this,`space`,r),typeof n==`number`)for(;++i<wN.length;){let e=wN[i];EN(this,wN[i],(n&vN[e])===vN[e])}}};TN.prototype.defined=!0;function EN(e,t,n){n&&(e[t]=n)}function DN(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new TN(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[gN(r)]=r,n[gN(a.attribute)]=r}return new mN(t,n,e.space)}var ON=DN({properties:{ariaActiveDescendant:null,ariaAtomic:H,ariaAutoComplete:null,ariaBusy:H,ariaChecked:H,ariaColCount:U,ariaColIndex:U,ariaColSpan:U,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:H,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:H,ariaFlowTo:W,ariaGrabbed:H,ariaHasPopup:null,ariaHidden:H,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:U,ariaLive:null,ariaModal:H,ariaMultiLine:H,ariaMultiSelectable:H,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:U,ariaPressed:H,ariaReadOnly:H,ariaRelevant:null,ariaRequired:H,ariaRoleDescription:W,ariaRowCount:U,ariaRowIndex:U,ariaRowSpan:U,ariaSelected:H,ariaSetSize:U,ariaSort:null,ariaValueMax:U,ariaValueMin:U,ariaValueNow:U,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function kN(e,t){return t in e?e[t]:t}function AN(e,t){return kN(e,t.toLowerCase())}var jN=DN({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:xN,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:V,allowPaymentRequest:V,allowUserMedia:V,alt:null,as:null,async:V,autoCapitalize:null,autoComplete:W,autoFocus:V,autoPlay:V,blocking:W,capture:null,charSet:null,checked:V,cite:null,className:W,cols:U,colSpan:null,content:null,contentEditable:H,controls:V,controlsList:W,coords:U|xN,crossOrigin:null,data:null,dateTime:null,decoding:null,default:V,defer:V,dir:null,dirName:null,disabled:V,download:bN,draggable:H,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:V,formTarget:null,headers:W,height:U,hidden:bN,high:U,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:V,inputMode:null,integrity:null,is:null,isMap:V,itemId:null,itemProp:W,itemRef:W,itemScope:V,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:V,low:U,manifest:null,max:null,maxLength:U,media:null,method:null,min:null,minLength:U,multiple:V,muted:V,name:null,nonce:null,noModule:V,noValidate:V,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:V,optimum:U,pattern:null,ping:W,placeholder:null,playsInline:V,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:V,referrerPolicy:null,rel:W,required:V,reversed:V,rows:U,rowSpan:U,sandbox:W,scope:null,scoped:V,seamless:V,selected:V,shadowRootClonable:V,shadowRootDelegatesFocus:V,shadowRootMode:null,shape:null,size:U,sizes:null,slot:null,span:U,spellCheck:H,src:null,srcDoc:null,srcLang:null,srcSet:null,start:U,step:null,style:null,tabIndex:U,target:null,title:null,translate:null,type:null,typeMustMatch:V,useMap:null,value:H,width:U,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:U,borderColor:null,bottomMargin:U,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:V,declare:V,event:null,face:null,frame:null,frameBorder:null,hSpace:U,leftMargin:U,link:null,longDesc:null,lowSrc:null,marginHeight:U,marginWidth:U,noResize:V,noHref:V,noShade:V,noWrap:V,object:null,profile:null,prompt:null,rev:null,rightMargin:U,rules:null,scheme:null,scrolling:H,standby:null,summary:null,text:null,topMargin:U,valueType:null,version:null,vAlign:null,vLink:null,vSpace:U,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:V,disableRemotePlayback:V,prefix:null,property:null,results:U,security:null,unselectable:null},space:`html`,transform:AN}),MN=DN({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:SN,accentHeight:U,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:U,amplitude:U,arabicForm:null,ascent:U,attributeName:null,attributeType:null,azimuth:U,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:U,by:null,calcMode:null,capHeight:U,className:W,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:U,diffuseConstant:U,direction:null,display:null,dur:null,divisor:U,dominantBaseline:null,download:V,dx:null,dy:null,edgeMode:null,editable:null,elevation:U,enableBackground:null,end:null,event:null,exponent:U,externalResourcesRequired:null,fill:null,fillOpacity:U,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:xN,g2:xN,glyphName:xN,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:U,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:U,horizOriginX:U,horizOriginY:U,id:null,ideographic:U,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:U,k:U,k1:U,k2:U,k3:U,k4:U,kernelMatrix:SN,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:U,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:U,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:U,overlineThickness:U,paintOrder:null,panose1:null,path:null,pathLength:U,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:U,pointsAtY:U,pointsAtZ:U,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:SN,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:SN,rev:SN,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:SN,requiredFeatures:SN,requiredFonts:SN,requiredFormats:SN,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:U,specularExponent:U,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:U,strikethroughThickness:U,string:null,stroke:null,strokeDashArray:SN,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:U,strokeOpacity:U,strokeWidth:null,style:null,surfaceScale:U,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:SN,tabIndex:U,tableValues:null,target:null,targetX:U,targetY:U,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:SN,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:U,underlineThickness:U,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:U,values:null,vAlphabetic:U,vMathematical:U,vectorEffect:null,vHanging:U,vIdeographic:U,version:null,vertAdvY:U,vertOriginX:U,vertOriginY:U,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:U,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:kN}),NN=DN({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),PN=DN({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:AN}),FN=DN({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),IN=/[A-Z]/g,LN=/-[a-z]/g,RN=/^data[-\w.:]+$/i;function zN(e,t){let n=gN(t),r=t,i=_N;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&RN.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(LN,VN);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!LN.test(e)){let n=e.replace(IN,BN);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=TN}return new i(r,t)}function BN(e){return`-`+e.toLowerCase()}function VN(e){return e.charAt(1).toUpperCase()}var HN=hN([ON,jN,NN,PN,FN],`html`),UN=hN([ON,MN,NN,PN,FN],`svg`),WN={}.hasOwnProperty;function GN(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&WN.call(t,e)){let n=String(t[e]);i=WN.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var KN=/["&'<>`]/g,qN=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,JN=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,YN=/[|\\{}()[\]^$+*?.]/g,XN=new WeakMap;function ZN(e,t){if(e=e.replace(t.subset?QN(t.subset):KN,r),t.subset||t.escapeOnly)return e;return e.replace(qN,n).replace(JN,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function QN(e){let t=XN.get(e);return t||(t=$N(e),XN.set(e,t)),t}function $N(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(YN,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var eP=/[\dA-Fa-f]/;function tP(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!eP.test(String.fromCharCode(t))?r:r+`;`}var nP=/\d/;function rP(e,t,n){let r=`&#`+String(e);return n&&t&&!nP.test(String.fromCharCode(t))?r:r+`;`}var iP=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),aP={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:``,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:``,zwj:``,lrm:``,rlm:``,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},oP=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],sP={}.hasOwnProperty,cP={},lP;for(lP in aP)sP.call(aP,lP)&&(cP[aP[lP]]=lP);var uP=/[^\dA-Za-z]/;function dP(e,t,n,r){let i=String.fromCharCode(e);if(sP.call(cP,i)){let e=cP[i],a=`&`+e;return n&&iP.includes(e)&&!oP.includes(e)&&(!r||t&&t!==61&&uP.test(String.fromCharCode(t)))?a:a+`;`}return``}function fP(e,t,n){let r=tP(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=dP(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=rP(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function pP(e,t){return ZN(e,Object.assign({format:fP},t))}var mP=/^>|^->|<!--|-->|--!>|<!-$/g,hP=[`>`],gP=[`<`,`>`];function _P(e,t,n,r){return r.settings.bogusComments?`<?`+pP(e.value,Object.assign({},r.settings.characterReferences,{subset:hP}))+`>`:`<!--`+e.value.replace(mP,i)+`-->`;function i(e){return pP(e,Object.assign({},r.settings.characterReferences,{subset:gP}))}}function vP(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}function yP(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function bP(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function xP(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}function SP(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function CP(e){return e.join(` `).trim()}var wP=/[ \t\n\f\r]/g;function TP(e){return typeof e==`object`?e.type===`text`&&EP(e.value):EP(e)}function EP(e){return e.replace(wP,``)===``}var G=kP(1),DP=kP(-1),OP=[];function kP(e){return t;function t(t,n,r){let i=t?t.children:OP,a=(n||0)+e,o=i[a];if(!r)for(;o&&TP(o);)a+=e,o=i[a];return o}}var AP={}.hasOwnProperty;function jP(e){return t;function t(t,n,r){return AP.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var MP=jP({body:FP,caption:NP,colgroup:NP,dd:zP,dt:RP,head:NP,html:PP,li:LP,optgroup:VP,option:HP,p:IP,rp:BP,rt:BP,tbody:WP,td:qP,tfoot:GP,th:qP,thead:UP,tr:KP});function NP(e,t,n){let r=G(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&TP(r.value.charAt(0)))}function PP(e,t,n){let r=G(n,t);return!r||r.type!==`comment`}function FP(e,t,n){let r=G(n,t);return!r||r.type!==`comment`}function IP(e,t,n){let r=G(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||n.type!==`element`||n.tagName!==`a`&&n.tagName!==`audio`&&n.tagName!==`del`&&n.tagName!==`ins`&&n.tagName!==`map`&&n.tagName!==`noscript`&&n.tagName!==`video`}function LP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&r.tagName===`li`}function RP(e,t,n){let r=G(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function zP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function BP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function VP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function HP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function UP(e,t,n){let r=G(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function WP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function GP(e,t,n){return!G(n,t)}function KP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function qP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var JP=jP({body:ZP,colgroup:QP,head:XP,html:YP,tbody:$P});function YP(e){let t=G(e,-1);return!t||t.type!==`comment`}function XP(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function ZP(e){let t=G(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&TP(t.value.charAt(0)))&&(t.type!==`element`||t.tagName!==`meta`&&t.tagName!==`link`&&t.tagName!==`script`&&t.tagName!==`style`&&t.tagName!==`template`)}function QP(e,t,n){let r=DP(n,t),i=G(e,-1,!0);return n&&r&&r.type===`element`&&r.tagName===`colgroup`&&MP(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`col`)}function $P(e,t,n){let r=DP(n,t),i=G(e,-1);return n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&MP(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`tr`)}var eF={name:[[`
|
|
33
|
+
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function oN(e,t){return e?.cacheKey===t?.cacheKey&&e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}function sN(e){return{type:`text`,value:e}}function B({tagName:e,children:t=[],properties:n={}}){return{type:`element`,tagName:e,properties:n,children:t}}function cN({name:e,width:t=16,height:n=16,properties:r}){return B({tagName:`svg`,properties:{width:t,height:n,viewBox:`0 0 16 16`,...r},children:[B({tagName:`use`,properties:{href:`#${e.replace(/^#/,``)}`}})]})}function lN(e){let t=e.children[0];for(;t!=null;){if(t.type===`element`&&t.tagName===`code`)return t;t=`children`in t?t.children[0]:null}}function uN(e){return B({tagName:`div`,properties:{"data-gutter":``},children:e})}function dN(e,t,n,r={}){return B({tagName:`div`,properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...r},children:t==null?void 0:[B({tagName:`span`,properties:{"data-line-number-content":``},children:[sN(`${t}`)]})]})}function fN(e,t,n){return B({tagName:`div`,properties:{"data-gutter-buffer":t,"data-buffer-size":n,"data-line-type":t===`annotation`?void 0:e,style:t===`annotation`?`grid-row: span ${n};`:`grid-row: span ${n};min-height:calc(${n} * 1lh);`}})}function pN(){return B({tagName:`button`,properties:{"data-utility-button":``,type:`button`},children:[cN({name:`diffs-icon-plus`,properties:{"data-icon":``}})]})}function mN(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side}function hN(e){for(let t of e)if(t instanceof HTMLElement&&(t.hasAttribute(`data-utility-button`)||t.hasAttribute(`data-gutter-utility-slot`)||t.getAttribute(`slot`)===`gutter-utility-slot`||t.getAttribute(`name`)===`gutter-utility-slot`))return!0;return!1}var gN=[`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`image`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`],_N=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};_N.prototype.normal={},_N.prototype.property={},_N.prototype.space=void 0;function vN(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new _N(n,r,t)}function yN(e){return e.toLowerCase()}var bN=class{constructor(e,t){this.attribute=t,this.property=e}};bN.prototype.attribute=``,bN.prototype.booleanish=!1,bN.prototype.boolean=!1,bN.prototype.commaOrSpaceSeparated=!1,bN.prototype.commaSeparated=!1,bN.prototype.defined=!1,bN.prototype.mustUseProperty=!1,bN.prototype.number=!1,bN.prototype.overloadedBoolean=!1,bN.prototype.property=``,bN.prototype.spaceSeparated=!1,bN.prototype.space=void 0;var xN=e({boolean:()=>V,booleanish:()=>H,commaOrSpaceSeparated:()=>TN,commaSeparated:()=>wN,number:()=>U,overloadedBoolean:()=>CN,spaceSeparated:()=>W}),SN=0,V=EN(),H=EN(),CN=EN(),U=EN(),W=EN(),wN=EN(),TN=EN();function EN(){return 2**++SN}var DN=Object.keys(xN),ON=class extends bN{constructor(e,t,n,r){let i=-1;if(super(e,t),kN(this,`space`,r),typeof n==`number`)for(;++i<DN.length;){let e=DN[i];kN(this,DN[i],(n&xN[e])===xN[e])}}};ON.prototype.defined=!0;function kN(e,t,n){n&&(e[t]=n)}function AN(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new ON(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[yN(r)]=r,n[yN(a.attribute)]=r}return new _N(t,n,e.space)}var jN=AN({properties:{ariaActiveDescendant:null,ariaAtomic:H,ariaAutoComplete:null,ariaBusy:H,ariaChecked:H,ariaColCount:U,ariaColIndex:U,ariaColSpan:U,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:H,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:H,ariaFlowTo:W,ariaGrabbed:H,ariaHasPopup:null,ariaHidden:H,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:U,ariaLive:null,ariaModal:H,ariaMultiLine:H,ariaMultiSelectable:H,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:U,ariaPressed:H,ariaReadOnly:H,ariaRelevant:null,ariaRequired:H,ariaRoleDescription:W,ariaRowCount:U,ariaRowIndex:U,ariaRowSpan:U,ariaSelected:H,ariaSetSize:U,ariaSort:null,ariaValueMax:U,ariaValueMin:U,ariaValueNow:U,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function MN(e,t){return t in e?e[t]:t}function NN(e,t){return MN(e,t.toLowerCase())}var PN=AN({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:wN,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:V,allowPaymentRequest:V,allowUserMedia:V,alt:null,as:null,async:V,autoCapitalize:null,autoComplete:W,autoFocus:V,autoPlay:V,blocking:W,capture:null,charSet:null,checked:V,cite:null,className:W,cols:U,colSpan:null,content:null,contentEditable:H,controls:V,controlsList:W,coords:U|wN,crossOrigin:null,data:null,dateTime:null,decoding:null,default:V,defer:V,dir:null,dirName:null,disabled:V,download:CN,draggable:H,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:V,formTarget:null,headers:W,height:U,hidden:CN,high:U,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:V,inputMode:null,integrity:null,is:null,isMap:V,itemId:null,itemProp:W,itemRef:W,itemScope:V,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:V,low:U,manifest:null,max:null,maxLength:U,media:null,method:null,min:null,minLength:U,multiple:V,muted:V,name:null,nonce:null,noModule:V,noValidate:V,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:V,optimum:U,pattern:null,ping:W,placeholder:null,playsInline:V,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:V,referrerPolicy:null,rel:W,required:V,reversed:V,rows:U,rowSpan:U,sandbox:W,scope:null,scoped:V,seamless:V,selected:V,shadowRootClonable:V,shadowRootDelegatesFocus:V,shadowRootMode:null,shape:null,size:U,sizes:null,slot:null,span:U,spellCheck:H,src:null,srcDoc:null,srcLang:null,srcSet:null,start:U,step:null,style:null,tabIndex:U,target:null,title:null,translate:null,type:null,typeMustMatch:V,useMap:null,value:H,width:U,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:U,borderColor:null,bottomMargin:U,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:V,declare:V,event:null,face:null,frame:null,frameBorder:null,hSpace:U,leftMargin:U,link:null,longDesc:null,lowSrc:null,marginHeight:U,marginWidth:U,noResize:V,noHref:V,noShade:V,noWrap:V,object:null,profile:null,prompt:null,rev:null,rightMargin:U,rules:null,scheme:null,scrolling:H,standby:null,summary:null,text:null,topMargin:U,valueType:null,version:null,vAlign:null,vLink:null,vSpace:U,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:V,disableRemotePlayback:V,prefix:null,property:null,results:U,security:null,unselectable:null},space:`html`,transform:NN}),FN=AN({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:TN,accentHeight:U,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:U,amplitude:U,arabicForm:null,ascent:U,attributeName:null,attributeType:null,azimuth:U,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:U,by:null,calcMode:null,capHeight:U,className:W,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:U,diffuseConstant:U,direction:null,display:null,dur:null,divisor:U,dominantBaseline:null,download:V,dx:null,dy:null,edgeMode:null,editable:null,elevation:U,enableBackground:null,end:null,event:null,exponent:U,externalResourcesRequired:null,fill:null,fillOpacity:U,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:wN,g2:wN,glyphName:wN,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:U,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:U,horizOriginX:U,horizOriginY:U,id:null,ideographic:U,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:U,k:U,k1:U,k2:U,k3:U,k4:U,kernelMatrix:TN,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:U,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:U,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:U,overlineThickness:U,paintOrder:null,panose1:null,path:null,pathLength:U,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:U,pointsAtY:U,pointsAtZ:U,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:TN,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:TN,rev:TN,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:TN,requiredFeatures:TN,requiredFonts:TN,requiredFormats:TN,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:U,specularExponent:U,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:U,strikethroughThickness:U,string:null,stroke:null,strokeDashArray:TN,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:U,strokeOpacity:U,strokeWidth:null,style:null,surfaceScale:U,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:TN,tabIndex:U,tableValues:null,target:null,targetX:U,targetY:U,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:TN,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:U,underlineThickness:U,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:U,values:null,vAlphabetic:U,vMathematical:U,vectorEffect:null,vHanging:U,vIdeographic:U,version:null,vertAdvY:U,vertOriginX:U,vertOriginY:U,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:U,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:MN}),IN=AN({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),LN=AN({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:NN}),RN=AN({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),zN=/[A-Z]/g,BN=/-[a-z]/g,VN=/^data[-\w.:]+$/i;function HN(e,t){let n=yN(t),r=t,i=bN;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&VN.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(BN,WN);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!BN.test(e)){let n=e.replace(zN,UN);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=ON}return new i(r,t)}function UN(e){return`-`+e.toLowerCase()}function WN(e){return e.charAt(1).toUpperCase()}var GN=vN([jN,PN,IN,LN,RN],`html`),KN=vN([jN,FN,IN,LN,RN],`svg`),qN={}.hasOwnProperty;function JN(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&qN.call(t,e)){let n=String(t[e]);i=qN.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var YN=/["&'<>`]/g,XN=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,ZN=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,QN=/[|\\{}()[\]^$+*?.]/g,$N=new WeakMap;function eP(e,t){if(e=e.replace(t.subset?tP(t.subset):YN,r),t.subset||t.escapeOnly)return e;return e.replace(XN,n).replace(ZN,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function tP(e){let t=$N.get(e);return t||(t=nP(e),$N.set(e,t)),t}function nP(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(QN,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var rP=/[\dA-Fa-f]/;function iP(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!rP.test(String.fromCharCode(t))?r:r+`;`}var aP=/\d/;function oP(e,t,n){let r=`&#`+String(e);return n&&t&&!aP.test(String.fromCharCode(t))?r:r+`;`}var sP=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),cP={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:``,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:``,zwj:``,lrm:``,rlm:``,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},lP=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],uP={}.hasOwnProperty,dP={},fP;for(fP in cP)uP.call(cP,fP)&&(dP[cP[fP]]=fP);var pP=/[^\dA-Za-z]/;function mP(e,t,n,r){let i=String.fromCharCode(e);if(uP.call(dP,i)){let e=dP[i],a=`&`+e;return n&&sP.includes(e)&&!lP.includes(e)&&(!r||t&&t!==61&&pP.test(String.fromCharCode(t)))?a:a+`;`}return``}function hP(e,t,n){let r=iP(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=mP(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=oP(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function gP(e,t){return eP(e,Object.assign({format:hP},t))}var _P=/^>|^->|<!--|-->|--!>|<!-$/g,vP=[`>`],yP=[`<`,`>`];function bP(e,t,n,r){return r.settings.bogusComments?`<?`+gP(e.value,Object.assign({},r.settings.characterReferences,{subset:vP}))+`>`:`<!--`+e.value.replace(_P,i)+`-->`;function i(e){return gP(e,Object.assign({},r.settings.characterReferences,{subset:yP}))}}function xP(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}function SP(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function CP(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function wP(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}function TP(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function EP(e){return e.join(` `).trim()}var DP=/[ \t\n\f\r]/g;function OP(e){return typeof e==`object`?e.type===`text`&&kP(e.value):kP(e)}function kP(e){return e.replace(DP,``)===``}var G=MP(1),AP=MP(-1),jP=[];function MP(e){return t;function t(t,n,r){let i=t?t.children:jP,a=(n||0)+e,o=i[a];if(!r)for(;o&&OP(o);)a+=e,o=i[a];return o}}var NP={}.hasOwnProperty;function PP(e){return t;function t(t,n,r){return NP.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var FP=PP({body:RP,caption:IP,colgroup:IP,dd:HP,dt:VP,head:IP,html:LP,li:BP,optgroup:WP,option:GP,p:zP,rp:UP,rt:UP,tbody:qP,td:XP,tfoot:JP,th:XP,thead:KP,tr:YP});function IP(e,t,n){let r=G(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&OP(r.value.charAt(0)))}function LP(e,t,n){let r=G(n,t);return!r||r.type!==`comment`}function RP(e,t,n){let r=G(n,t);return!r||r.type!==`comment`}function zP(e,t,n){let r=G(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||n.type!==`element`||n.tagName!==`a`&&n.tagName!==`audio`&&n.tagName!==`del`&&n.tagName!==`ins`&&n.tagName!==`map`&&n.tagName!==`noscript`&&n.tagName!==`video`}function BP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&r.tagName===`li`}function VP(e,t,n){let r=G(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function HP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function UP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function WP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function GP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function KP(e,t,n){let r=G(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function qP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function JP(e,t,n){return!G(n,t)}function YP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function XP(e,t,n){let r=G(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var ZP=PP({body:eF,colgroup:tF,head:$P,html:QP,tbody:nF});function QP(e){let t=G(e,-1);return!t||t.type!==`comment`}function $P(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function eF(e){let t=G(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&OP(t.value.charAt(0)))&&(t.type!==`element`||t.tagName!==`meta`&&t.tagName!==`link`&&t.tagName!==`script`&&t.tagName!==`style`&&t.tagName!==`template`)}function tF(e,t,n){let r=AP(n,t),i=G(e,-1,!0);return n&&r&&r.type===`element`&&r.tagName===`colgroup`&&FP(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`col`)}function nF(e,t,n){let r=AP(n,t),i=G(e,-1);return n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&FP(r,n.children.indexOf(r),n)?!1:!!(i&&i.type===`element`&&i.tagName===`tr`)}var rF={name:[[`
|
|
34
34
|
\f\r &/=>`.split(``),`
|
|
35
35
|
\f\r "&'/=>\``.split(``)],[`\0
|
|
36
36
|
\f\r "&'/<=>`.split(``),`\0
|
|
@@ -38,12 +38,12 @@ import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{$ as r,$
|
|
|
38
38
|
\f\r &>`.split(``),`\0
|
|
39
39
|
\f\r "&'<=>\``.split(``)],[`\0
|
|
40
40
|
\f\r "&'<=>\``.split(``),`\0
|
|
41
|
-
\f\r "&'<=>\``.split(``)]],single:[[`&'`.split(``),`"&'\``.split(``)],[`\0&'`.split(``),`\0"&'\``.split(``)]],double:[[`"&`.split(``),`"&'\``.split(``)],[`\0"&`.split(``),`\0"&'\``.split(``)]]};function tF(e,t,n,r){let i=r.schema,a=i.space!==`svg`&&r.settings.omitOptionalTags,o=i.space===`svg`?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),s=[],c;i.space===`html`&&e.tagName===`svg`&&(r.schema=UN);let l=nF(r,e.properties),u=r.all(i.space===`html`&&e.tagName===`template`?e.content:e);return r.schema=i,u&&(o=!1),(l||!a||!JP(e,t,n))&&(s.push(`<`,e.tagName,l?` `+l:``),o&&(i.space===`svg`||r.settings.closeSelfClosing)&&(c=l.charAt(l.length-1),(!r.settings.tightSelfClosing||c===`/`||c&&c!==`"`&&c!==`'`)&&s.push(` `),s.push(`/`)),s.push(`>`)),s.push(u),!o&&(!a||!MP(e,t,n))&&s.push(`</`+e.tagName+`>`),s.join(``)}function nF(e,t){let n=[],r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){let r=rF(e,i,t[i]);r&&n.push(r)}}for(;++r<n.length;){let t=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&t!==`"`&&t!==`'`&&(n[r]+=` `)}return n.join(``)}function rF(e,t,n){let r=zN(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space===`html`?0:1,a=+!e.settings.allowDangerousCharacters,o=e.quote,s;if(r.overloadedBoolean&&(n===r.attribute||n===``)?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!=`string`||n===r.attribute||n===``)&&(n=!!n),n==null||n===!1||typeof n==`number`&&Number.isNaN(n))return``;let c=pP(r.attribute,Object.assign({},e.settings.characterReferences,{subset:eF.name[i][a]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?xP:CP)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?c:(e.settings.preferUnquoted&&(s=pP(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:eF.unquoted[i][a]}))),s!==n&&(e.settings.quoteSmart&&yP(n,o)>yP(n,e.alternative)&&(o=e.alternative),s=o+pP(n,Object.assign({},e.settings.characterReferences,{subset:(o===`'`?eF.single:eF.double)[i][a],attribute:!0}))+o),c+(s&&`=`+s))}var iF=[`<`,`&`];function aF(e,t,n,r){return n&&n.type===`element`&&(n.tagName===`script`||n.tagName===`style`)?e.value:pP(e.value,Object.assign({},r.settings.characterReferences,{subset:iF}))}function oF(e,t,n,r){return r.settings.allowDangerousHtml?e.value:aF(e,t,n,r)}function sF(e,t,n,r){return r.all(e)}var cF=GN(`type`,{invalid:lF,unknown:uF,handlers:{comment:_P,doctype:vP,element:tF,raw:oF,root:sF,text:aF}});function lF(e){throw Error("Expected node, not `"+e+"`")}function uF(e){throw Error("Cannot compile unknown node `"+e.type+"`")}var dF={},fF={},pF=[];function mF(e,t){let n=t||dF,r=n.quote||`"`,i=r===`"`?`'`:`"`;if(r!==`"`&&r!==`'`)throw Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:hF,all:gF,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||pN,characterReferences:n.characterReferences||fF,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space===`svg`?UN:HN,quote:r,alternative:i}.one(Array.isArray(e)?{type:`root`,children:e}:e,void 0,void 0)}function hF(e,t,n){return cF(e,t,n,this)}function gF(e){let t=[],n=e&&e.children||pF,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join(``)}var _F=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;selectedRangeHighlightSide;selectedRangeLineNumberOnly=!1;editorActiveLine=null;editorActiveLineSide;editorLineNumberOnly=!1;proposedSelectedRange;renderedSelectedLinesState;renderedEditorActiveLineState;selectionAnchor;pointerSession={mode:`idle`};constructor(e,t){this.mode=e,this.options=t}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener(`click`,this.handlePointerClick),this.pre?.removeEventListener(`pointerdown`,this.handlePointerDown),this.pre?.removeEventListener(`pointermove`,this.handlePointerMove),this.pre?.removeEventListener(`pointerleave`,this.handlePointerLeave),this.pre?.removeAttribute(`data-interactive-lines`),this.pre?.removeAttribute(`data-interactive-line-numbers`),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),mM(this.renderSelection),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1,this.setSelectionDirty()}setup(e){this.setSelectionDirty();let{usesCustomGutterUtility:t=!1,enableGutterUtility:n=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),n?this.ensureGutterUtilityNode(t):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode===`gutterSelecting`&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectedLinesState=void 0,this.renderedEditorActiveLineState=void 0}isSelectionDirty(){return this.renderedSelectedLinesState===void 0||this.renderedEditorActiveLineState===void 0}setSelection(e,t){let n=!(e===this.selectedRange||bM(e??void 0,this.selectedRange??void 0)),r=t?.lineNumberOnly??!1,i=t?.activeLineSide!==this.selectedRangeHighlightSide||r!==this.selectedRangeLineNumberOnly;!this.isSelectionDirty()&&!n&&!i||(this.proposedSelectedRange=void 0,this.selectedRange=e,this.selectedRangeHighlightSide=t?.activeLineSide,this.selectedRangeLineNumberOnly=r,this.renderSelection(),this.placeUtility(),n&&t?.notify!==!1&&this.notifySelectionCommitted(e))}setEditorActiveLine(e,{lineNumberOnly:t=!1,side:n}={}){let r=e!==this.editorActiveLine,i=n!==this.editorActiveLineSide||t!==this.editorLineNumberOnly;!this.isSelectionDirty()&&!r&&!i||(this.editorActiveLine=e,this.editorActiveLineSide=n,this.editorLineNumberOnly=t,this.renderSelection())}getSelection(){return this.selectedRange}getHoveredLine=()=>{let e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode===`diff`&&e.type===`diff-line`)return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode===`file`&&e.type===`line`)return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{let{onHunkExpand:t,onLineClick:n,onLineNumberClick:r,onTokenClick:i,onMergeConflictActionClick:a}=this.options;(t!=null||n!=null||r!=null||a!=null||i!=null)&&(this.options.onGutterUtilityClick!=null&&fN(e.composedPath())||(IF(this.options.__debugPointerEvents,`click`,`FileDiff.DEBUG.handlePointerClick:`,e),this.handlePointerEvent({eventType:`click`,event:e})))};handlePointerMove=e=>{if(e.pointerType!==`mouse`)return;let{lineHoverHighlight:t=`disabled`,onLineEnter:n,onLineLeave:r,onTokenEnter:i,onTokenLeave:a,enableGutterUtility:o=!1}=this.options;t===`disabled`&&!o&&n==null&&r==null&&i==null&&a==null||(IF(this.options.__debugPointerEvents,`move`,`FileDiff.DEBUG.handlePointerMove:`,e),this.handlePointerEvent({eventType:`move`,event:e}))};handlePointerLeave=e=>{let{__debugPointerEvents:t}=this.options;if(IF(t,`move`,`FileDiff.DEBUG.handlePointerLeave: no event`),this.hoveredLine==null&&this.hoveredToken==null){IF(t,`move`,`FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token`);return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:t}){let{__debugPointerEvents:n}=this.options,r=t.composedPath();IF(n,e,`FileDiff.DEBUG.handlePointerEvent:`,{eventType:e,composedPath:r});let i=this.resolvePointerTarget(r);IF(n,e,`FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:`,i);let{onLineClick:a,onLineNumberClick:o,onLineEnter:s,onLineLeave:c,onTokenClick:l,onTokenEnter:u,onTokenLeave:d,onHunkExpand:f,onMergeConflictActionClick:p}=this.options;switch(e){case`move`:{let e=SF(i)&&this.hoveredLine?.lineElement===i.lineElement;xF(i)&&this.hoveredToken?.tokenElement===i.tokenElement||(this.hoveredToken!=null&&(d?.(this.hoveredToken,t),this.clearHoveredToken()),xF(i)&&(this.setHoveredToken(this.toTokenEventBaseProps(i)),u?.(this.hoveredToken,t))),e||(this.hoveredLine!=null&&(c?.({...this.hoveredLine,event:t}),this.clearHoveredLine()),SF(i)?(this.setHoveredLine(this.toEventBaseProps(i)),this.placeUtility(),s?.({...this.hoveredLine,event:t})):this.placeUtility());break}case`click`:{if(i==null)break;if(wF(i)&&p!=null){p(i);break}if(CF(i)&&f!=null){f(i.hunkIndex,i.all||t.shiftKey?`both`:i.direction,i.all||t.shiftKey?1/0:void 0);break}if(!SF(i))break;xF(i)&&l!=null&&l(this.toTokenEventBaseProps(i),t);let e=this.toEventBaseProps(i);o!=null&&i.numberColumn?o({...e,event:t}):a?.({...e,event:t});break}}}syncPointerListeners(e){let{__debugPointerEvents:t,lineHoverHighlight:n=`disabled`,onLineClick:r,onLineNumberClick:i,onLineEnter:a,onLineLeave:o,onTokenClick:s,onTokenEnter:c,onTokenLeave:l,onHunkExpand:u,onMergeConflictActionClick:d,enableGutterUtility:f=!1,enableLineSelection:p=!1,onGutterUtilityClick:m}=this.options,h=m!=null,g=n!==`disabled`||r!=null||i!=null||a!=null||o!=null||s!=null||c!=null||l!=null||u!=null||d!=null||f||p||h;g&&!this.hasPointerListeners?(e.addEventListener(`click`,this.handlePointerClick),e.addEventListener(`pointerdown`,this.handlePointerDown),e.addEventListener(`pointermove`,this.handlePointerMove),e.addEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!0,IF(t,`click`,`FileDiff.DEBUG.attachEventListeners: Attaching click events for:`,(()=>{let e=[];return(t===`both`||t===`click`)&&(r!=null&&e.push(`onLineClick`),i!=null&&e.push(`onLineNumberClick`),u!=null&&e.push(`expandable hunk separators`),d!=null&&e.push(`merge conflict actions`)),e})()),IF(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer move event`),IF(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event`)):!g&&this.hasPointerListeners&&(e.removeEventListener(`click`,this.handlePointerClick),e.removeEventListener(`pointerdown`,this.handlePointerDown),e.removeEventListener(`pointermove`,this.handlePointerMove),e.removeEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!1);let _=this.pointerSession.mode===`selecting`||this.pointerSession.mode===`pendingSingleLineUnselect`,v=this.pointerSession.mode===`gutterSelecting`;(!p&&_||!h&&v)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;let{onLineClick:e,onLineNumberClick:t,enableLineSelection:n=!1}=this.options,r=e!=null,i=t!=null||n;r&&!this.interactiveLinesAttr?(this.pre.setAttribute(`data-interactive-lines`,``),this.interactiveLinesAttr=!0):!r&&this.interactiveLinesAttr&&(this.pre.removeAttribute(`data-interactive-lines`),this.interactiveLinesAttr=!1),i&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute(`data-interactive-line-numbers`,``),this.interactiveLineNumbersAttr=!0):!i&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute(`data-interactive-line-numbers`),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType===`mouse`&&e.button!==0||this.pre==null||this.pointerSession.mode!==`idle`)return;let t=e.composedPath();fN(t)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!==`mouse`&&this.revealUtilityFromGutterPath(t),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){let{enableLineSelection:t=!1}=this.options;if(!t)return;let n=this.resolveSelectionInfo(e,{source:`event-path`,requireNumberColumn:!0});if(n==null)return;let{pre:r}=this;if(r==null)return;let{lineNumber:i,eventSide:a,lineIndex:o}=n;if(e.shiftKey&&this.selectedRange!=null){let t=this.getIndexesFromSelection(this.selectedRange,r.getAttribute(`data-diff-type`)===`split`);if(t==null)return;let n=t.start<=t.end?o>=t.start:o<=t.end;this.selectionAnchor={lineNumber:n?this.selectedRange.start:this.selectedRange.end,side:n?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===i&&this.selectedRange?.end===i){let t={lineNumber:i,side:a};this.selectionAnchor=t,this.pointerSession={mode:`pendingSingleLineUnselect`,pointerId:e.pointerId,anchor:t,pending:t},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:i,side:a},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){let{onGutterUtilityClick:t}=this.options;if(t==null)return;let n=this.currentSelectionEnds(),r=n?.bottom??this.resolveSelectionPoint(e,{source:`event-path`,excludeUtility:!1}),i=n?.top??r;r!=null&&i!=null&&(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:`gutterSelecting`,pointerId:e.pointerId,anchor:i,current:r},this.selectionAnchor={lineNumber:i.lineNumber,side:i.side},this.updateSelection(r.lineNumber,r.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionPoint(e,{source:`coordinates-first`});if(t==null)return;this.pointerSession.current=t,this.updateSelection(t.lineNumber,t.side);return}case`selecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case`pendingSingleLineUnselect`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;let n={lineNumber:t.lineNumber,side:t.eventSide};if(dN(this.pointerSession.pending,n))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:`selecting`,pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{let{onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{let{pointerSession:n}=this;if(e.pointerId!==n.pointerId)return;e.preventDefault();let r=this.resolveSelectionPoint(e,{source:`coordinates-first`});r!=null&&(n.current=r,this.updateSelection(r.lineNumber,r.side));let i=this.buildSelectedLineRange(n.anchor,n.current);t?.({...i}),this.selectionAnchor=void 0,this.notifySelectionEnd(i),this.notifySelectionCommitted(i),this.clearProposedSelection(),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case`pendingSingleLineUnselect`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection();return;case`selecting`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:case`selecting`:case`pendingSingleLineUnselect`:if(`pointerId`in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute(`data-hovered`),this.hoveredLine.numberElement.removeAttribute(`data-hovered`),this.hoveredLine=void 0)}setHoveredLine(e){let{lineHoverHighlight:t=`disabled`}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,t!==`disabled`&&((t===`both`||t===`line`)&&this.hoveredLine.lineElement.setAttribute(`data-hovered`,``),(t===`both`||t===`number`)&&this.hoveredLine.numberElement.setAttribute(`data-hovered`,``))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer??(this.gutterUtilityContainer=document.createElement(`div`),this.gutterUtilityContainer.setAttribute(`data-gutter-utility-slot`,``)),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot??(this.gutterUtilitySlot=document.createElement(`slot`),this.gutterUtilitySlot.name=`gutter-utility-slot`),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){let e=document.createElement(`div`);e.innerHTML=mF(uN());let t=e.firstElementChild;if(!(t instanceof HTMLButtonElement))throw Error(`InteractionManager.ensureGutterUtilityNode: Node element should be a button`);t.remove(),this.gutterUtilityButton=t}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;let t=this.resolvePointerTarget(e);bF(t)&&t.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(t))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){let e=this.currentSelectionEnds();if(e==null)return!1;let t=this.targetForSelectionPoint(e.bottom);return t==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(t)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){let e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){let t={lineNumber:e.start,side:e.side},n={lineNumber:e.end,side:e.endSide??e.side},r=this.selectionPointRowIndex(t),i=this.selectionPointRowIndex(n);if(r!=null&&i!=null)return r>i?{top:n,bottom:t}:{top:t,bottom:n}}selectionPointRowIndex(e){let t=this.getLineIndex(e.lineNumber,e.side);if(t!=null)return this.isSplitDiff()?t[1]:t[0]}targetForSelectionPoint(e){if(this.pre==null)return;let t=this.getLineIndex(e.lineNumber,e.side);if(t==null)return;let n=this.mode===`diff`?`${t[0]},${t[1]}`:`${t[0]}`,r=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${n}"]`);for(let t of r){if(!(t instanceof HTMLElement))continue;let n=this.resolvePointerTarget(DF(t));if(bF(n)&&(this.mode!==`diff`||e.side==null||n.side===e.side))return n}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||=(document.addEventListener(`pointermove`,this.handleDocumentPointerMove),document.addEventListener(`pointerup`,this.handleDocumentPointerUp),document.addEventListener(`pointercancel`,this.handleDocumentPointerCancel),!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&=(document.removeEventListener(`pointermove`,this.handleDocumentPointerMove),document.removeEventListener(`pointerup`,this.handleDocumentPointerUp),document.removeEventListener(`pointercancel`,this.handleDocumentPointerCancel),!1)}clearPointerSession(){this.pointerSession={mode:`idle`}}clearPendingSingleLineState(){this.pointerSession.mode===`pendingSingleLineUnselect`&&(this.pointerSession={mode:`idle`})}selectionInfoFromPath(e,t){let n=this.resolvePointerTarget(e);if(bF(n)&&!(t&&!n.numberColumn)&&n.splitLineIndex!=null)return{lineIndex:n.splitLineIndex,lineNumber:n.lineNumber,eventSide:this.mode===`diff`?n.side:void 0}}resolveSelectionInfo(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionInfoFromPath(n,t.requireNumberColumn)}selectionPointFromPath(e){let t=this.resolvePointerTarget(e);if(bF(t))return{lineNumber:t.lineNumber,side:this.mode===`diff`?t.side:void 0}}resolveSelectionPoint(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionPointFromPath(n)}resolveSelectionPath(e,t){let n=t.excludeUtility!==!1;switch(t.source){case`event-path`:return this.pathFromEventPath(e.composedPath(),n);case`coordinates-first`:{let t=this.pathFromCoordinates(e,n);return t===void 0?this.pathFromEventPath(e.composedPath(),n):t??void 0}}}pathFromCoordinates(e,t){let n=this.hitTest(e);if(n!==void 0)return n===null?null:this.pathFromElement(n,t)??null}pathFromEventPath(e,t){if(!(t&&fN(e))){for(let n of e)if(n instanceof Element)return this.pathFromElement(n,t)}}pathFromElement(e,t){let n=DF(e);if(t&&fN(n))return;let r=OF(e);return r==null?this.pathFromAnnotationSlot(e):DF(r)}pathFromAnnotationSlot(e){let t=AF(kF(e));if(t==null)return;let n=this.targetForSelectionPoint(t);return n==null?void 0:DF(n.lineElement)}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;let t=this.pre?.getRootNode(),n=jF(t)?t:jF(document)?document:void 0;if(n!=null)return n.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,t){let{getLineIndex:n}=this.options;return n==null?[e-1,e-1]:n(e,t)}getCurrentSelectionRange(){return this.proposedSelectedRange===void 0?this.selectedRange:this.proposedSelectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,t,n=!0){let r=this.getCurrentSelectionRange(),i;if(e==null)i=null;else{let n=this.selectionAnchor?.side??t,r=this.selectionAnchor?.lineNumber??e;i=this.buildSelectionRange(r,e,n,t)}bM(r??void 0,i??void 0)||(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=i:(this.selectedRange=i,pM(this.renderSelection)),this.placeUtility(),n&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,t){if(this.pre==null)return;let n=this.getLineIndex(e.start,e.side),r=this.getLineIndex(e.end,e.endSide??e.side);return n!=null&&r!=null?{start:t?n[1]:n[0],end:t?r[1]:r[0]}:void 0}getSelectionRenderState(){return{selectedLines:{range:this.selectedRange,highlightSide:this.selectedRangeHighlightSide,lineNumberOnly:this.selectedRangeLineNumberOnly},editorActiveLine:{range:this.editorActiveLine==null?null:{start:this.editorActiveLine,end:this.editorActiveLine,side:this.editorActiveLineSide},highlightSide:this.editorActiveLineSide,lineNumberOnly:this.editorLineNumberOnly}}}resolveLineRenderRange(e,t,n){if(e.range==null)return;let r=this.getIndexesFromSelection(e.range,t);if(r==null)throw console.error({rowRange:r,range:e.range}),Error(`InteractionManager.renderSelection: No valid ${n} rowRange`);return r}getLineRenderColumns(e,t,n,r){if(this.pre==null||t==null&&r==null)return[];let{children:i}=this.pre;if(i.length>2)throw console.error(i),Error(`InteractionManager.renderSelection: Somehow there are more than 2 code elements...`);let a=[];for(let o of i){let i=o.hasAttribute(`data-deletions`)?`deletions`:o.hasAttribute(`data-additions`)?`additions`:void 0,s=e!=null&&t!=null&&(e.highlightSide==null||i==null||e.highlightSide===i),c=n!=null&&r!=null&&(n.highlightSide==null||i==null||n.highlightSide===i);if(!s&&!c)continue;let[l,u]=o.children;if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))throw Error(`InteractionManager.renderSelection: missing gutter or content element`);if(u.children.length!==l.children.length)throw Error(`InteractionManager.renderSelection: gutter and content children dont match, something is wrong`);a.push({content:u,gutter:l,renderEditorActiveLine:c,renderSelectedLines:s})}return a}renderSelection=()=>{mM(this.renderSelection);let e=this.getSelectionRenderState();if(this.pre==null)return;let{editorActiveLine:t,selectedLines:n}=e,r=!NF(this.renderedSelectedLinesState,n),i=!NF(this.renderedEditorActiveLineState,t);if(!r&&!i)return;r&&(this.renderedSelectedLinesState=void 0),i&&(this.renderedEditorActiveLineState=void 0);let a=this.pre.getAttribute(`data-diff-type`)===`split`,o=r?this.resolveLineRenderRange(n,a,`selected-lines`):void 0,s=i?this.resolveLineRenderRange(t,a,`editor-active-line`):void 0,c=this.getLineRenderColumns(r?n:void 0,o,i?t:void 0,s),l=n.range==null||c.some(e=>e.renderSelectedLines),u=t.range==null||c.some(e=>e.renderEditorActiveLine);if(r)for(let e of this.pre.querySelectorAll(`[data-selected-line]`))e.removeAttribute(`data-selected-line`);if(i)for(let e of this.pre.querySelectorAll(`[data-editor-active-line]`))e.removeAttribute(`data-editor-active-line`);let d=o==null?void 0:Math.min(o.start,o.end),f=o==null?void 0:Math.max(o.start,o.end),p=d===f,m=s?.start;for(let e of c){let{content:r,gutter:i,renderEditorActiveLine:o,renderSelectedLines:s}=e,c=Math.max(s?f??-1/0:-1/0,o?m??-1/0:-1/0),l=r.children.length;for(let e=0;e<l;e++){let l=r.children[e],u=i.children[e];if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))continue;let h=this.parseLineIndex(l,a);if((h??0)>c)break;if(h!=null){if(s&&d!=null&&f!=null&&h>=d&&h<=f){let e=p?`single`:h===d?`first`:h===f?`last`:``;u.setAttribute(`data-selected-line`,e),n.lineNumberOnly||(l.setAttribute(`data-selected-line`,e),u.nextSibling instanceof HTMLElement&&l.nextSibling instanceof HTMLElement&&(l.nextSibling.hasAttribute(`data-line-annotation`)||l.nextSibling.hasAttribute(`data-merge-conflict-actions`))&&(p?(e=`last`,l.setAttribute(`data-selected-line`,`first`)):h===d?e=``:h===f&&l.setAttribute(`data-selected-line`,``),l.nextSibling.setAttribute(`data-selected-line`,e),u.nextSibling.setAttribute(`data-selected-line`,e)))}o&&h===m&&(u.setAttribute(`data-editor-active-line`,``),t.lineNumberOnly||l.setAttribute(`data-editor-active-line`,``))}}}r&&l&&(this.renderedSelectedLinesState=n),i&&u&&(this.renderedEditorActiveLineState=t)};notifySelectionCommitted(e){this.options.onLineSelected?.(e)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode===`file`?{type:`line`,lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:`diff-line`,annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}){return this.mode===`file`?{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,tokenElement:i,tokenText:a}:{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}}buildSelectedLineRange(e,t){return this.buildSelectionRange(e.lineNumber,t.lineNumber,e.side,t.side)}buildSelectionRange(e,t,n,r){return{start:e,end:t,...n==null?{}:{side:n},...n!==r&&r!=null?{endSide:r}:{}}}resolvePointerTarget(e){let t=!1,n,r,i,a,o,s,c,l,u,d;for(let f of e){if(!(f instanceof HTMLElement))continue;if(d==null&&f.hasAttribute(`data-merge-conflict-action`)){let e=f.getAttribute(`data-merge-conflict-action`)??void 0,t=f.getAttribute(`data-merge-conflict-conflict-index`)??void 0,n=t==null?NaN:Number.parseInt(t,10);TF(e)&&Number.isFinite(n)&&(d={kind:`merge-conflict-action`,resolution:e,conflictIndex:n})}if(s==null&&f.hasAttribute(`data-char`)){s=f;let e=f.getAttribute(`data-char`);if(e!=null){let t=Number.parseInt(e,10);if(!Number.isNaN(t)){let e=f.textContent??``,n=t+e.length;(e.trim()!==``||this.options.enableTokenInteractionsOnWhitespace===!0)&&(c={tokenElement:s,lineCharStart:t,lineCharEnd:n,tokenText:e});continue}}}let e=o==null?f.getAttribute(`data-column-number`)??void 0:void 0;if(e!=null){o=f,u=Number.parseInt(e,10),t=!0,n=FF(f),a=f.getAttribute(`data-line-index`)??void 0;continue}let p=i==null?f.getAttribute(`data-line`)??void 0:void 0;if(p!=null){i=f,u=Number.parseInt(p,10),n=FF(f),a=f.getAttribute(`data-line-index`)??void 0;continue}if(l==null&&(f.hasAttribute(`data-expand-button`)||f.hasAttribute(`data-unmodified-lines`))){l={hunkIndex:void 0,direction:f.hasAttribute(`data-expand-up`)?`up`:f.hasAttribute(`data-expand-down`)?`down`:`both`,all:f.hasAttribute(`data-expand-all-button`)};continue}let m=l==null?void 0:f.getAttribute(`data-expand-index`)??void 0;if(l!=null&&m!=null){let e=Number.parseInt(m,10);Number.isNaN(e)||(l.hunkIndex=e);continue}if(r==null&&f.hasAttribute(`data-code`)){r=f;break}}if(d!=null)return d;if(l?.hunkIndex!=null)return{type:`line-info`,hunkIndex:l.hunkIndex,direction:l.direction,all:l.all};if(i??=a==null?void 0:EF(r,`[data-line][data-line-index="${a}"]`),o??=a==null?void 0:EF(r,`[data-column-number][data-line-index="${a}"]`),r==null||i==null||o==null||n==null||u==null||Number.isNaN(u))return;let f=this.parseLineIndex(i,this.isSplitDiff());return c==null?this.mode===`file`?{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f}:{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:PF(n,r),splitLineIndex:f}:this.mode===`file`?{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f,...c}:{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:PF(n,r),splitLineIndex:f,...c}}isSplitDiff(){return this.pre?.getAttribute(`data-diff-type`)===`split`}parseLineIndex(e,t){let n=(e.getAttribute(`data-line-index`)??``).split(`,`).map(e=>Number.parseInt(e,10)).filter(e=>!Number.isNaN(e));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function vF({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:t,lineHoverHighlight:n,onGutterUtilityClick:r,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,renderGutterUtility:d,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v},y,b,x){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:yF({enableGutterUtility:t,renderGutterUtility:d,onGutterUtilityClick:r}),usesCustomGutterUtility:d!=null,lineHoverHighlight:n,onGutterUtilityClick:r,onHunkExpand:y,onMergeConflictActionClick:x,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v,getLineIndex:b}}function yF({enableGutterUtility:e,renderGutterUtility:t,onGutterUtilityClick:n}){if(n!=null&&t!=null)throw Error(`Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.`);return e??!1}function bF(e){return e!=null&&`kind`in e&&e.kind===`line`}function xF(e){return e!=null&&`kind`in e&&e.kind===`token`}function SF(e){return bF(e)||xF(e)}function CF(e){return`type`in e&&e.type===`line-info`}function wF(e){return`kind`in e&&e.kind===`merge-conflict-action`}function TF(e){return e===`current`||e===`incoming`||e===`both`}function EF(e,t){let n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function DF(e){let t=[],n=e;for(;n!=null;)t.push(n),n=n.parentNode;return t}function OF(e){let t=e.closest(`[data-line], [data-column-number]`);if(t instanceof HTMLElement)return t;let n=e.closest(`[data-line-annotation], [data-gutter-buffer="annotation"]`);if(!(n instanceof HTMLElement))return;let r=n.previousElementSibling;return r instanceof HTMLElement&&(r.hasAttribute(`data-line`)||r.hasAttribute(`data-column-number`))?r:void 0}function kF(e){let t=e.closest(`[slot^="annotation-"]`);if(t instanceof HTMLElement)return t.getAttribute(`slot`)??void 0;if(e instanceof HTMLElement){let t=e.getAttribute(`name`)??void 0;return t!=null&&t.startsWith(`annotation-`)?t:void 0}}function AF(e){if(e==null)return;let t=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(t==null)return;let n=Number.parseInt(t[2],10);if(!(!Number.isFinite(n)||n<=0))return{lineNumber:n,side:t[1]}}function jF(e){return e!=null&&typeof e.elementFromPoint==`function`}function MF(e,t){return e===t||bM(e??void 0,t??void 0)}function NF(e,t){return e?.highlightSide===t.highlightSide&&e?.lineNumberOnly===t.lineNumberOnly&&MF(e?.range??null,t.range)}function PF(e,t){switch(e){case`change-deletion`:return`deletions`;case`change-addition`:return`additions`;default:return t.hasAttribute(`data-deletions`)?`deletions`:`additions`}}function FF(e){let t=e.getAttribute(`data-line-type`);if(t!=null)switch(t){case`change-deletion`:case`change-addition`:case`context`:case`context-expanded`:return t;default:return}}function IF(e=`none`,t,...n){switch(e){case`none`:return;case`both`:break;case`click`:if(t!==`click`)return;break;case`move`:if(t!==`move`)return}console.log(...n)}var LF=class e{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){let t=e.resizeObserver??new ResizeObserver(e.handleSharedResizeEntries);return e.resizeObserver=t,t}static handleSharedResizeEntries(t){let n=new Map;for(let r of t){let t=e.managersByElement.get(r.target);if(t==null)continue;let i=n.get(t);i==null?n.set(t,[r]):i.push(r)}for(let[e,t]of n)e.handleResizeEntries(t)}observedNodes=new Map;setup(e,{disableAnnotations:t,columnVariables:n=`apply`}){let r=new Set,i=n===`apply`,a=0,o=new Map(this.observedNodes);this.observedNodes.clear();for(let t of e.children){if(a===2)break;let e=(()=>{if(t instanceof HTMLElement&&t.tagName===`CODE`)return t})();if(e==null)continue;a++;let n=o.get(e);if(n!=null&&n.type!==`code`)throw Error(`ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible`);let r=e.firstElementChild;r instanceof HTMLElement||(r=null),n==null?(n={type:`code`,codeElement:e,numberElement:r,codeWidth:`auto`,numberWidth:0,applyColumnVariables:i},this.observedNodes.set(e,n),this.observe(e),r!=null&&(this.observedNodes.set(r,n),this.observe(r))):(this.observedNodes.set(e,n),o.delete(e),n.numberElement===r?n.numberElement==null?n.numberWidth=0:(o.delete(n.numberElement),this.observedNodes.set(n.numberElement,n)):(n.numberElement!=null&&(this.unobserve(n.numberElement),o.delete(n.numberElement)),r!=null&&(this.observe(r),o.delete(r),this.observedNodes.set(r,n)),n.numberElement=r,n.numberWidth=0),BF(n,i))}if(a>1&&!t){let t=e.querySelectorAll(`[data-line-annotation*=","]`),n=new Map;for(let e of t){if(!(e instanceof HTMLElement))continue;let t=e.getAttribute(`data-line-annotation`)??``;if(!/^-?\d+,-?\d+$/.test(t)){console.error(`DiffFileRenderer.setupResizeObserver: Invalid element or annotation`,{lineAnnotation:t,element:e});continue}let r=n.get(t);r??(r=[],n.set(t,r)),r.push(e)}for(let[e,t]of n){if(t.length!==2){console.error(`DiffFileRenderer.setupResizeObserver: Bad Pair`,e,t);continue}let[n,i]=t,a=n.firstElementChild,s=i.firstElementChild;if(!(n instanceof HTMLElement)||!(i instanceof HTMLElement)||!(a instanceof HTMLElement)||!(s instanceof HTMLElement))continue;let c=o.get(a);if(c!=null){this.observedNodes.set(a,c),this.observedNodes.set(s,c),o.delete(a),o.delete(s);continue}let l=a.getBoundingClientRect().height,u=s.getBoundingClientRect().height;c={type:`annotations`,column1:{container:n,child:a,childHeight:l},column2:{container:i,child:s,childHeight:u},currentHeight:`auto`},r.add({child1:a,child2:s,item:c,newHeight:Math.max(l,u)})}for(let e of r)this.applyNewHeight(e.item,e.newHeight),this.observedNodes.set(e.child1,e.item),this.observedNodes.set(e.child2,e.item),this.observe(e.child1),this.observe(e.child2);r.clear()}for(let[e,t]of o)this.unobserve(e),t.type===`code`?UF(t):WF(t);o.clear()}cleanUp(){for(let e of this.observedNodes.keys())this.unobserve(e);this.observedNodes.clear()}observe(t){let{managersByElement:n}=e,r=n.get(t);if(r!==this){if(r!=null&&r!==this)throw Error(`ResizeManager.observe: element is already owned by another ResizeManager`);n.set(t,this),e.getResizeObserver().observe(t)}}unobserve(t){let{managersByElement:n,resizeObserver:r}=e,i=n.get(t);if(i!=null){if(i!==this)throw Error(`ResizeManager.unobserve: element is owned by another ResizeManager`);n.delete(t),r?.unobserve(t),r!=null&&n.size===0&&(r.disconnect(),e.resizeObserver=void 0)}}handleResizeEntries(e){let t=new Map,n=new Set;for(let r of e){let{target:e,borderBoxSize:i,contentBoxSize:a}=r;if(!(e instanceof HTMLElement)){console.error(`ResizeManager.handleResizeEntries: Invalid element for ResizeObserver`,r);continue}let o=this.observedNodes.get(e);if(o==null){console.error(`ResizeManager.handleResizeEntries: Not a valid observed node`,r);continue}if(o.type===`annotations`){let t=(()=>{if(e===o.column1.child)return o.column1;if(e===o.column2.child)return o.column2})();if(t==null){console.error(`ResizeManager.handleResizeEntries: Couldn't find a column for`,{item:o,target:e});continue}t.childHeight=i[0].blockSize,n.add(o)}else if(o.type===`code`){let n=t.get(o)??{},r=a[0].inlineSize;e===o.codeElement?n.codeInlineSize=r:e===o.numberElement&&(n.numberInlineSize=r),t.set(o,n)}}this.applyAnnotationUpdates(n),n.clear(),this.applyColumnUpdates(t),t.clear()}applyAnnotationUpdates(e){for(let t of e)this.applyNewHeight(t,Math.max(t.column1.childHeight,t.column2.childHeight))}applyColumnUpdates=e=>{for(let[t,n]of e){let e=n.codeInlineSize==null?t.codeWidth:RF(n.codeInlineSize),r=n.numberInlineSize==null?t.numberWidth:zF(n.numberInlineSize),i=e!==t.codeWidth,a=r!==t.numberWidth;!i&&!a||(t.codeWidth=e,t.numberWidth=r,t.applyColumnVariables&&VF(t,{codeWidthChanged:i,numberWidthChanged:a}))}};applyNewHeight(e,t){t!==e.currentHeight&&(e.currentHeight=Math.max(t,0),e.column1.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`),e.column2.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`))}};function RF(e){let t=Math.max(Math.floor(e),0);return t===0?`auto`:t}function zF(e){return Math.max(Math.ceil(e),0)}function BF(e,t){e.applyColumnVariables!==t&&(e.applyColumnVariables=t,t?VF(e,{codeWidthChanged:!0,numberWidthChanged:!0}):HF(e))}function VF(e,{codeWidthChanged:t,numberWidthChanged:n}){let{codeElement:r,codeWidth:i,numberWidth:a}=e;if(t&&r.style.setProperty(`--diffs-column-width`,`${typeof i==`number`?`${i}px`:`auto`}`),n&&r.style.setProperty(`--diffs-column-number-width`,`${a===0?`auto`:`${a}px`}`),t||n&&i!==`auto`){let e=typeof i==`number`?Math.max(i-a,0):0;r.style.setProperty(`--diffs-column-content-width`,`${e>0?`${e}px`:`auto`}`)}}function HF(e){e.codeElement.style.removeProperty(`--diffs-column-content-width`),e.codeElement.style.removeProperty(`--diffs-column-number-width`),e.codeElement.style.removeProperty(`--diffs-column-width`)}function UF(e){e.codeElement.isConnected&&HF(e)}function WF(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty(`--diffs-annotation-min-height`),e.column2.container.isConnected&&e.column2.container.style.removeProperty(`--diffs-annotation-min-height`)}var GF=new Map,KF=new Map,qF=new Map,JF=new Set;function YF(e){for(let t of Array.isArray(e)?e:[e])if(t!==`text`&&t!==`ansi`&&!JF.has(t))return!1;return!0}function XF(e,t){e=Array.isArray(e)?e:[e];for(let n of e){if(JF.has(n.name))continue;let e=GF.get(n.name);e??(e=n,GF.set(n.name,e)),JF.add(e.name),t.loadLanguageSync(e.data)}}function ZF(){return typeof WorkerGlobalScope<`u`&&typeof self<`u`&&self instanceof WorkerGlobalScope}var QF=Object.defineProperty,$F=Object.getOwnPropertyDescriptor,eI=Object.getOwnPropertyNames,tI=Object.prototype.hasOwnProperty,nI=(e,t)=>{let n={};for(var r in e)QF(n,r,{get:e[r],enumerable:!0});return t||QF(n,Symbol.toStringTag,{value:`Module`}),n},rI=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=eI(t),a=0,o=i.length,s;a<o;a++)s=i[a],!tI.call(e,s)&&s!==n&&QF(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=$F(t,s))||r.enumerable});return e},iI=(e,t,n)=>(rI(e,t,`default`),n&&rI(n,t,`default`)),aI=[{id:`abap`,name:`ABAP`,import:(()=>D(()=>import(`./abap-CLvhMVsD.js`),[]))},{id:`actionscript-3`,name:`ActionScript`,import:(()=>D(()=>import(`./actionscript-3--17pq3dv.js`),[]))},{id:`ada`,name:`Ada`,import:(()=>D(()=>import(`./ada-C5qYipkI.js`),[]))},{id:`angular-html`,name:`Angular HTML`,import:(()=>D(()=>import(`./angular-html-B8mrqUL5.js`).then(e=>e.n),__vite__mapDeps([4,1,5,6,7])))},{id:`angular-ts`,name:`Angular TypeScript`,import:(()=>D(()=>import(`./angular-ts-Bzix210W.js`),__vite__mapDeps([8,4,1,5,6,7,9])))},{id:`apache`,name:`Apache Conf`,import:(()=>D(()=>import(`./apache-U0d_L8uA.js`),[]))},{id:`apex`,name:`Apex`,import:(()=>D(()=>import(`./apex-CGTLDQj6.js`),[]))},{id:`apl`,name:`APL`,import:(()=>D(()=>import(`./apl-Dhin1L29.js`),__vite__mapDeps([10,6,1,7,5,11,12,13])))},{id:`applescript`,name:`AppleScript`,import:(()=>D(()=>import(`./applescript-CCn79oCD.js`),[]))},{id:`ara`,name:`Ara`,import:(()=>D(()=>import(`./ara-4CJ0cIlV.js`),[]))},{id:`asciidoc`,name:`AsciiDoc`,aliases:[`adoc`],import:(()=>D(()=>import(`./asciidoc-DE70LPWp.js`),[]))},{id:`asm`,name:`Assembly`,import:(()=>D(()=>import(`./asm-Cmm7eHzH.js`),[]))},{id:`astro`,name:`Astro`,import:(()=>D(()=>import(`./astro-B-4NNgOP.js`),__vite__mapDeps([14,6,1,7,13,15,16,17])))},{id:`awk`,name:`AWK`,import:(()=>D(()=>import(`./awk-BWXHIvNe.js`),[]))},{id:`ballerina`,name:`Ballerina`,import:(()=>D(()=>import(`./ballerina-B7ZEbQpA.js`),[]))},{id:`bat`,name:`Batch File`,aliases:[`batch`],import:(()=>D(()=>import(`./bat-Bo4NYOV-.js`),[]))},{id:`beancount`,name:`Beancount`,import:(()=>D(()=>import(`./beancount-D-usSTwE.js`),[]))},{id:`berry`,name:`Berry`,aliases:[`be`],import:(()=>D(()=>import(`./berry-DKpUyyne.js`),[]))},{id:`bibtex`,name:`BibTeX`,import:(()=>D(()=>import(`./bibtex-Ci_nEsc7.js`),[]))},{id:`bicep`,name:`Bicep`,import:(()=>D(()=>import(`./bicep-CUHmPFLl.js`),[]))},{id:`bird2`,name:`BIRD2 Configuration`,aliases:[`bird`],import:(()=>D(()=>import(`./bird2-C6vDhewU.js`),[]))},{id:`blade`,name:`Blade`,import:(()=>D(()=>import(`./blade-Wr94ul2N.js`),__vite__mapDeps([18,6,1,7,5,11,12,13,19,20])))},{id:`bsl`,name:`1C (Enterprise)`,aliases:[`1c`],import:(()=>D(()=>import(`./bsl-BkkzgIyY.js`),__vite__mapDeps([21,22])))},{id:`c`,name:`C`,import:(()=>D(()=>import(`./c-iCihek07.js`).then(e=>e.n),__vite__mapDeps([23,1])))},{id:`c3`,name:`C3`,import:(()=>D(()=>import(`./c3-CnJL0r0V.js`),[]))},{id:`cadence`,name:`Cadence`,aliases:[`cdc`],import:(()=>D(()=>import(`./cadence-CQ2zXKGN.js`),[]))},{id:`cairo`,name:`Cairo`,import:(()=>D(()=>import(`./cairo-DLTphjLi.js`),__vite__mapDeps([24,25])))},{id:`clarity`,name:`Clarity`,import:(()=>D(()=>import(`./clarity-SemFz856.js`),[]))},{id:`clojure`,name:`Clojure`,aliases:[`clj`],import:(()=>D(()=>import(`./clojure-DqKBuwfJ.js`),[]))},{id:`cmake`,name:`CMake`,import:(()=>D(()=>import(`./cmake-Bj61d0ZC.js`),[]))},{id:`cobol`,name:`COBOL`,import:(()=>D(()=>import(`./cobol-Cw2-KvLW.js`),__vite__mapDeps([26,5,1,6,7,12])))},{id:`codeowners`,name:`CODEOWNERS`,import:(()=>D(()=>import(`./codeowners-C8r90Shi.js`),[]))},{id:`codeql`,name:`CodeQL`,aliases:[`ql`],import:(()=>D(()=>import(`./codeql-oeQT6MSM.js`),[]))},{id:`coffee`,name:`CoffeeScript`,aliases:[`coffeescript`],import:(()=>D(()=>import(`./coffee-CiiSLhB6.js`),__vite__mapDeps([27,6,1])))},{id:`common-lisp`,name:`Common Lisp`,aliases:[`lisp`],import:(()=>D(()=>import(`./common-lisp-Cv5bFMCO.js`),[]))},{id:`coq`,name:`Coq`,import:(()=>D(()=>import(`./coq-BrsZFFmf.js`),[]))},{id:`cpp`,name:`C++`,aliases:[`c++`],import:(()=>D(()=>import(`./cpp-DjoE5qBx.js`).then(e=>e.n),__vite__mapDeps([28,1,20,29,30,23])))},{id:`crystal`,name:`Crystal`,import:(()=>D(()=>import(`./crystal-wCJpIkgB.js`),__vite__mapDeps([31,6,1,7,5,20,23,32])))},{id:`csharp`,name:`C#`,aliases:[`c#`,`cs`],import:(()=>D(()=>import(`./csharp-Ct8U2NOr.js`),[]))},{id:`css`,name:`CSS`,import:(()=>D(()=>import(`./css-CNuuLpMC.js`).then(e=>e.n),__vite__mapDeps([7,1])))},{id:`csv`,name:`CSV`,import:(()=>D(()=>import(`./csv-Dx-8-gkx.js`),[]))},{id:`cue`,name:`CUE`,import:(()=>D(()=>import(`./cue-CE9AQfxI.js`),[]))},{id:`cypher`,name:`Cypher`,aliases:[`cql`],import:(()=>D(()=>import(`./cypher-ClKdZ_lG.js`),[]))},{id:`d`,name:`D`,import:(()=>D(()=>import(`./d-qD-0Kul2.js`),[]))},{id:`dart`,name:`Dart`,import:(()=>D(()=>import(`./dart-CnvKMtbv.js`),[]))},{id:`dax`,name:`DAX`,import:(()=>D(()=>import(`./dax-BkyTk9wS.js`),[]))},{id:`desktop`,name:`Desktop`,import:(()=>D(()=>import(`./desktop-Dlh5hvp9.js`),[]))},{id:`diff`,name:`Diff`,import:(()=>D(()=>import(`./diff-woXpYk--.js`),[]))},{id:`docker`,name:`Dockerfile`,aliases:[`dockerfile`],import:(()=>D(()=>import(`./docker-IyjqRm3v.js`),[]))},{id:`dotenv`,name:`dotEnv`,import:(()=>D(()=>import(`./dotenv-_5a1GRtc.js`),[]))},{id:`dream-maker`,name:`Dream Maker`,import:(()=>D(()=>import(`./dream-maker-DW3nJb8Q.js`),[]))},{id:`edge`,name:`Edge`,import:(()=>D(()=>import(`./edge-DCY0a-ow.js`),__vite__mapDeps([33,5,1,6,7,15,19])))},{id:`elixir`,name:`Elixir`,import:(()=>D(()=>import(`./elixir-DP304Xio.js`),__vite__mapDeps([34,5,1,6,7])))},{id:`elm`,name:`Elm`,import:(()=>D(()=>import(`./elm-o4NJxfws.js`),__vite__mapDeps([35,30,1,23])))},{id:`emacs-lisp`,name:`Emacs Lisp`,aliases:[`elisp`],import:(()=>D(()=>import(`./emacs-lisp-B4R74twV.js`),[]))},{id:`erb`,name:`ERB`,import:(()=>D(()=>import(`./erb-BcNYoZVd.js`),__vite__mapDeps([36,5,1,6,7,37,11,12,20,23,28,29,30,32,38,39,15,17,40,41,42])))},{id:`erlang`,name:`Erlang`,aliases:[`erl`],import:(()=>D(()=>import(`./erlang-Cphh6RMH.js`),__vite__mapDeps([43,44])))},{id:`fennel`,name:`Fennel`,import:(()=>D(()=>import(`./fennel-DQxkIbk2.js`),[]))},{id:`fish`,name:`Fish`,import:(()=>D(()=>import(`./fish-BJitypiv.js`),[]))},{id:`fluent`,name:`Fluent`,aliases:[`ftl`],import:(()=>D(()=>import(`./fluent-C03EYrpw.js`),[]))},{id:`fortran-fixed-form`,name:`Fortran (Fixed Form)`,aliases:[`f`,`for`,`f77`],import:(()=>D(()=>import(`./fortran-fixed-form-DEKoE2YW.js`),__vite__mapDeps([45,46])))},{id:`fortran-free-form`,name:`Fortran (Free Form)`,aliases:[`f90`,`f95`,`f03`,`f08`,`f18`],import:(()=>D(()=>import(`./fortran-free-form-CYNrtFtB.js`),[]))},{id:`fsharp`,name:`F#`,aliases:[`f#`,`fs`],import:(()=>D(()=>import(`./fsharp-D13ZGOAj.js`),__vite__mapDeps([47,44])))},{id:`gdresource`,name:`GDResource`,aliases:[`tscn`,`tres`],import:(()=>D(()=>import(`./gdresource-C0sCabJj.js`),__vite__mapDeps([48,49,50])))},{id:`gdscript`,name:`GDScript`,aliases:[`gd`],import:(()=>D(()=>import(`./gdscript-Cp2uCuqX.js`),[]))},{id:`gdshader`,name:`GDShader`,import:(()=>D(()=>import(`./gdshader-CBce3t8t.js`),[]))},{id:`genie`,name:`Genie`,import:(()=>D(()=>import(`./genie-CV2tkWYe.js`),[]))},{id:`gherkin`,name:`Gherkin`,import:(()=>D(()=>import(`./gherkin-DExj1W_8.js`),[]))},{id:`git-commit`,name:`Git Commit Message`,import:(()=>D(()=>import(`./git-commit-BSykSTBG.js`),__vite__mapDeps([51,52])))},{id:`git-rebase`,name:`Git Rebase Message`,import:(()=>D(()=>import(`./git-rebase-BDPpS8w6.js`),__vite__mapDeps([53,32,1])))},{id:`gleam`,name:`Gleam`,import:(()=>D(()=>import(`./gleam-CSRkHgEL.js`),[]))},{id:`glimmer-js`,name:`Glimmer JS`,aliases:[`gjs`],import:(()=>D(()=>import(`./glimmer-js-BONyzAsu.js`),__vite__mapDeps([54,6,1,7,5,15])))},{id:`glimmer-ts`,name:`Glimmer TS`,aliases:[`gts`],import:(()=>D(()=>import(`./glimmer-ts-f9c0GCOe.js`),__vite__mapDeps([55,6,1,7,5,15])))},{id:`glsl`,name:`GLSL`,import:(()=>D(()=>import(`./glsl-D5MA2a_X.js`).then(e=>e.n),__vite__mapDeps([30,1,23])))},{id:`gn`,name:`GN`,import:(()=>D(()=>import(`./gn-ilITqXS6.js`),[]))},{id:`gnuplot`,name:`Gnuplot`,import:(()=>D(()=>import(`./gnuplot-7GGW24-e.js`),[]))},{id:`go`,name:`Go`,import:(()=>D(()=>import(`./go-rLFTqkRN.js`),[]))},{id:`graphql`,name:`GraphQL`,aliases:[`gql`],import:(()=>D(()=>import(`./graphql-Ctjuxyvl.js`).then(e=>e.n),__vite__mapDeps([39,1,6,15,17,40])))},{id:`groovy`,name:`Groovy`,import:(()=>D(()=>import(`./groovy-CacY0gHj.js`),[]))},{id:`hack`,name:`Hack`,import:(()=>D(()=>import(`./hack-7ztQ7Up-.js`),__vite__mapDeps([56,5,1,6,7,20])))},{id:`haml`,name:`Ruby Haml`,import:(()=>D(()=>import(`./haml-CwEpbK1d.js`).then(e=>e.n),__vite__mapDeps([38,1,6,7])))},{id:`handlebars`,name:`Handlebars`,aliases:[`hbs`],import:(()=>D(()=>import(`./handlebars-ryMP1rBR.js`),__vite__mapDeps([57,6,1,7,5,42])))},{id:`haskell`,name:`Haskell`,aliases:[`hs`],import:(()=>D(()=>import(`./haskell-D8IpX4py.js`),[]))},{id:`haxe`,name:`Haxe`,import:(()=>D(()=>import(`./haxe-OTjmBuCE.js`),[]))},{id:`hcl`,name:`HashiCorp HCL`,import:(()=>D(()=>import(`./hcl-Dh228itO.js`),[]))},{id:`hjson`,name:`Hjson`,import:(()=>D(()=>import(`./hjson-CxZEssPk.js`),[]))},{id:`hlsl`,name:`HLSL`,import:(()=>D(()=>import(`./hlsl-Cvrh5tZx.js`),[]))},{id:`html`,name:`HTML`,import:(()=>D(()=>import(`./html-XwrE-1r6.js`).then(e=>e.n),__vite__mapDeps([5,1,6,7])))},{id:`html-derivative`,name:`HTML (Derivative)`,import:(()=>D(()=>import(`./html-derivative-i4STDFnl.js`),__vite__mapDeps([19,5,1,6,7])))},{id:`http`,name:`HTTP`,import:(()=>D(()=>import(`./http-kmH8AyfE.js`),__vite__mapDeps([58,11,1,12,13,32,39,6,15,17,40])))},{id:`hurl`,name:`Hurl`,import:(()=>D(()=>import(`./hurl-DCZHXKU4.js`),__vite__mapDeps([59,11,1,12,60,39,6,15,17,40])))},{id:`hxml`,name:`HXML`,import:(()=>D(()=>import(`./hxml-B0Qn7Nwc.js`),__vite__mapDeps([61,62])))},{id:`hy`,name:`Hy`,import:(()=>D(()=>import(`./hy-CZbG8q4J.js`),[]))},{id:`imba`,name:`Imba`,import:(()=>D(()=>import(`./imba-DsUTQ-LC.js`),[]))},{id:`ini`,name:`INI`,aliases:[`properties`],import:(()=>D(()=>import(`./ini-B5eOa1yu.js`),[]))},{id:`java`,name:`Java`,import:(()=>D(()=>import(`./java-DdHNQ9hk.js`).then(e=>e.n),__vite__mapDeps([12,1])))},{id:`javascript`,name:`JavaScript`,aliases:[`js`,`cjs`,`mjs`],import:(()=>D(()=>import(`./javascript-obGGvMPs.js`).then(e=>e.n),__vite__mapDeps([6,1])))},{id:`jinja`,name:`Jinja`,import:(()=>D(()=>import(`./jinja-B-tLrNsM.js`),__vite__mapDeps([63,5,1,6,7])))},{id:`jison`,name:`Jison`,import:(()=>D(()=>import(`./jison-CBjhYtSs.js`),__vite__mapDeps([64,6,1])))},{id:`json`,name:`JSON`,import:(()=>D(()=>import(`./json-DAgxKhMr.js`).then(e=>e.n),__vite__mapDeps([13,1])))},{id:`json5`,name:`JSON5`,import:(()=>D(()=>import(`./json5-BR5RXkoi.js`),[]))},{id:`jsonc`,name:`JSON with Comments`,import:(()=>D(()=>import(`./jsonc-CYpm1nAK.js`),[]))},{id:`jsonl`,name:`JSON Lines`,import:(()=>D(()=>import(`./jsonl-CmCQp5Yx.js`),[]))},{id:`jsonnet`,name:`Jsonnet`,import:(()=>D(()=>import(`./jsonnet-CJTPZ8u_.js`),[]))},{id:`jssm`,name:`JSSM`,aliases:[`fsl`],import:(()=>D(()=>import(`./jssm-DXw9l8Rf.js`),[]))},{id:`jsx`,name:`JSX`,import:(()=>D(()=>import(`./jsx-gTgmArGx.js`).then(e=>e.n),__vite__mapDeps([40,1])))},{id:`julia`,name:`Julia`,aliases:[`jl`],import:(()=>D(()=>import(`./julia-CjHxn3vf.js`),__vite__mapDeps([65,6,1,20,25,28,29,30,23,66])))},{id:`just`,name:`Just`,import:(()=>D(()=>import(`./just-CZ9bduw9.js`),__vite__mapDeps([67,6,1,15,25,32,37,7,5,11,12,20,23,28,29,30,38,39,17,40,41,42,68])))},{id:`kdl`,name:`KDL`,import:(()=>D(()=>import(`./kdl-CsD5j6eV.js`),[]))},{id:`kotlin`,name:`Kotlin`,aliases:[`kt`,`kts`],import:(()=>D(()=>import(`./kotlin-DhhofPvG.js`),[]))},{id:`kusto`,name:`Kusto`,aliases:[`kql`],import:(()=>D(()=>import(`./kusto-C7mF5XQf.js`),[]))},{id:`latex`,name:`LaTeX`,import:(()=>D(()=>import(`./latex-D9bvcAJr.js`),__vite__mapDeps([69,70,66,1])))},{id:`lean`,name:`Lean 4`,aliases:[`lean4`],import:(()=>D(()=>import(`./lean-CewbzKMR.js`),[]))},{id:`less`,name:`Less`,import:(()=>D(()=>import(`./less-DVTAwKKz.js`),[]))},{id:`liquid`,name:`Liquid`,import:(()=>D(()=>import(`./liquid-G0MH4h_m.js`),__vite__mapDeps([71,6,1,7,5,13])))},{id:`llvm`,name:`LLVM IR`,import:(()=>D(()=>import(`./llvm-Cm23YOpf.js`),[]))},{id:`log`,name:`Log file`,import:(()=>D(()=>import(`./log-BNLmms1o.js`),[]))},{id:`logo`,name:`Logo`,import:(()=>D(()=>import(`./logo-Cluzi2Zq.js`),[]))},{id:`lua`,name:`Lua`,import:(()=>D(()=>import(`./lua-FONpmTUP.js`).then(e=>e.n),__vite__mapDeps([41,1,23])))},{id:`luau`,name:`Luau`,import:(()=>D(()=>import(`./luau-CNKltnaQ.js`),[]))},{id:`make`,name:`Makefile`,aliases:[`makefile`],import:(()=>D(()=>import(`./make-Dixweg8N.js`),[]))},{id:`markdown`,name:`Markdown`,aliases:[`md`],import:(()=>D(()=>import(`./markdown-BYOwaDjH.js`),[]))},{id:`marko`,name:`Marko`,import:(()=>D(()=>import(`./marko-DV5GrDmo.js`),__vite__mapDeps([72,7,1,9,15,73])))},{id:`matlab`,name:`MATLAB`,import:(()=>D(()=>import(`./matlab-D7qyCx1q.js`),[]))},{id:`mdc`,name:`MDC`,import:(()=>D(()=>import(`./mdc-cg1lnqpW.js`),__vite__mapDeps([74,19,5,1,6,7,42,44])))},{id:`mdx`,name:`MDX`,import:(()=>D(()=>import(`./mdx-DQZ5AkYe.js`),[]))},{id:`mermaid`,name:`Mermaid`,aliases:[`mmd`],import:(()=>D(()=>import(`./mermaid-Bk4SNUv9.js`),[]))},{id:`mipsasm`,name:`MIPS Assembly`,aliases:[`mips`],import:(()=>D(()=>import(`./mipsasm-BMqwQI7S.js`),[]))},{id:`mojo`,name:`Mojo`,import:(()=>D(()=>import(`./mojo-BgCJLMeH.js`),[]))},{id:`moonbit`,name:`MoonBit`,aliases:[`mbt`,`mbti`],import:(()=>D(()=>import(`./moonbit-CaWjb8XO.js`),[]))},{id:`move`,name:`Move`,import:(()=>D(()=>import(`./move-B1IS1UjX.js`),[]))},{id:`narrat`,name:`Narrat Language`,aliases:[`nar`],import:(()=>D(()=>import(`./narrat-_X_XdTYD.js`),[]))},{id:`nextflow`,name:`Nextflow`,aliases:[`nf`],import:(()=>D(()=>import(`./nextflow-BJtWHP5T.js`),__vite__mapDeps([75,76])))},{id:`nextflow-groovy`,name:`Nextflow Groovy`,import:(()=>D(()=>import(`./nextflow-groovy-DJMQeKeT.js`),[]))},{id:`nginx`,name:`Nginx`,import:(()=>D(()=>import(`./nginx-BTMw9COX.js`),__vite__mapDeps([77,41,1,23])))},{id:`nim`,name:`Nim`,import:(()=>D(()=>import(`./nim-B6yJ_yaC.js`),__vite__mapDeps([78,6,1,7,5,11,12,23,30,44])))},{id:`nix`,name:`Nix`,import:(()=>D(()=>import(`./nix-IvuFDN5E.js`),[]))},{id:`nushell`,name:`nushell`,aliases:[`nu`],import:(()=>D(()=>import(`./nushell-DcLAeLz5.js`),[]))},{id:`objective-c`,name:`Objective-C`,aliases:[`objc`],import:(()=>D(()=>import(`./objective-c-D1A_Heim.js`),[]))},{id:`objective-cpp`,name:`Objective-C++`,import:(()=>D(()=>import(`./objective-cpp-BsSzOQcm.js`),[]))},{id:`ocaml`,name:`OCaml`,import:(()=>D(()=>import(`./ocaml-O90oeIOV.js`),[]))},{id:`odin`,name:`Odin`,import:(()=>D(()=>import(`./odin-B1RWQWA5.js`),[]))},{id:`openscad`,name:`OpenSCAD`,aliases:[`scad`],import:(()=>D(()=>import(`./openscad-BUDT5pXO.js`),[]))},{id:`pascal`,name:`Pascal`,import:(()=>D(()=>import(`./pascal-4ZHwLPI5.js`),[]))},{id:`perl`,name:`Perl`,import:(()=>D(()=>import(`./perl-BAov3eih.js`),__vite__mapDeps([68,6,1,7,5,11,12,20])))},{id:`php`,name:`PHP`,import:(()=>D(()=>import(`./php-Cg76ANFt.js`),__vite__mapDeps([79,6,1,7,5,11,12,13,20])))},{id:`pkl`,name:`Pkl`,import:(()=>D(()=>import(`./pkl-ot-7Btpt.js`),[]))},{id:`plsql`,name:`PL/SQL`,import:(()=>D(()=>import(`./plsql-DGHpHOYJ.js`),[]))},{id:`po`,name:`Gettext PO`,aliases:[`pot`,`potx`],import:(()=>D(()=>import(`./po-BiJDBrnU.js`),[]))},{id:`polar`,name:`Polar`,import:(()=>D(()=>import(`./polar-C7UOKdEL.js`),[]))},{id:`postcss`,name:`PostCSS`,import:(()=>D(()=>import(`./postcss-BXeXVLqQ.js`),[]))},{id:`powerquery`,name:`PowerQuery`,import:(()=>D(()=>import(`./powerquery-DNMTfnFr.js`),[]))},{id:`powershell`,name:`PowerShell`,aliases:[`ps`,`ps1`],import:(()=>D(()=>import(`./powershell-DshXNtvi.js`),[]))},{id:`prisma`,name:`Prisma`,import:(()=>D(()=>import(`./prisma-BsRQq5mF.js`),[]))},{id:`prolog`,name:`Prolog`,import:(()=>D(()=>import(`./prolog-iXnhIJG7.js`),[]))},{id:`proto`,name:`Protocol Buffer 3`,aliases:[`protobuf`],import:(()=>D(()=>import(`./proto-DB4EqR-F.js`),[]))},{id:`pug`,name:`Pug`,aliases:[`jade`],import:(()=>D(()=>import(`./pug-DkgDHZci.js`),__vite__mapDeps([80,6,1,7,5])))},{id:`puppet`,name:`Puppet`,import:(()=>D(()=>import(`./puppet-CDv2pdJW.js`),[]))},{id:`purescript`,name:`PureScript`,import:(()=>D(()=>import(`./purescript-9MfHhQsQ.js`),[]))},{id:`python`,name:`Python`,aliases:[`py`],import:(()=>D(()=>import(`./python-gzcpVVnB.js`),[]))},{id:`qml`,name:`QML`,import:(()=>D(()=>import(`./qml-_a-QhfPD.js`),__vite__mapDeps([81,6,1])))},{id:`qmldir`,name:`QML Directory`,import:(()=>D(()=>import(`./qmldir-DCQb3MpD.js`),[]))},{id:`qss`,name:`Qt Style Sheets`,import:(()=>D(()=>import(`./qss-Fe1Jh2GI.js`),[]))},{id:`r`,name:`R`,import:(()=>D(()=>import(`./r-D6UWEOL2.js`).then(e=>e.n),__vite__mapDeps([66,1])))},{id:`racket`,name:`Racket`,import:(()=>D(()=>import(`./racket-DcIDlBhZ.js`),[]))},{id:`raku`,name:`Raku`,aliases:[`perl6`],import:(()=>D(()=>import(`./raku-B3gFvitq.js`),[]))},{id:`razor`,name:`ASP.NET Razor`,import:(()=>D(()=>import(`./razor-D3EoCAik.js`),__vite__mapDeps([82,5,1,6,7,83])))},{id:`reg`,name:`Windows Registry Script`,import:(()=>D(()=>import(`./reg-CRGYupPL.js`),[]))},{id:`regexp`,name:`RegExp`,aliases:[`regex`],import:(()=>D(()=>import(`./regexp-DR20uMnK.js`).then(e=>e.n),__vite__mapDeps([29,1])))},{id:`rel`,name:`Rel`,import:(()=>D(()=>import(`./rel-BtDbiS_P.js`),[]))},{id:`riscv`,name:`RISC-V`,import:(()=>D(()=>import(`./riscv-Ckw8ddFX.js`),[]))},{id:`ron`,name:`RON`,import:(()=>D(()=>import(`./ron-VUp2lXgN.js`),[]))},{id:`rosmsg`,name:`ROS Interface`,import:(()=>D(()=>import(`./rosmsg-CAekHB0j.js`),[]))},{id:`rst`,name:`reStructuredText`,import:(()=>D(()=>import(`./rst-YTmaoyaq.js`),__vite__mapDeps([84,6,1,19,5,7,25,85,28,20,29,30,23,32,42,37,11,12,38,39,15,17,40,41])))},{id:`ruby`,name:`Ruby`,aliases:[`rb`],import:(()=>D(()=>import(`./ruby-2bd251b9.js`),__vite__mapDeps([37,6,1,7,5,11,12,20,23,28,29,30,32,38,39,15,17,40,41,42])))},{id:`rust`,name:`Rust`,aliases:[`rs`],import:(()=>D(()=>import(`./rust-Cfkwpbl8.js`),[]))},{id:`sas`,name:`SAS`,import:(()=>D(()=>import(`./sas-B6p8-ynO.js`),__vite__mapDeps([86,20,1])))},{id:`sass`,name:`Sass`,import:(()=>D(()=>import(`./sass-DXrisJhu.js`),[]))},{id:`scala`,name:`Scala`,import:(()=>D(()=>import(`./scala-DKOlJaKm.js`),[]))},{id:`scheme`,name:`Scheme`,import:(()=>D(()=>import(`./scheme-DQCgrYNe.js`),[]))},{id:`scss`,name:`SCSS`,import:(()=>D(()=>import(`./scss-YesllqfO.js`).then(e=>e.n),__vite__mapDeps([9,1,7])))},{id:`sdbl`,name:`1C (Query)`,aliases:[`1c-query`],import:(()=>D(()=>import(`./sdbl-bTVj8UrX.js`),[]))},{id:`shaderlab`,name:`ShaderLab`,aliases:[`shader`],import:(()=>D(()=>import(`./shaderlab-TOUzSsQk.js`),__vite__mapDeps([87,88])))},{id:`shellscript`,name:`Shell`,aliases:[`bash`,`sh`,`shell`,`zsh`],import:(()=>D(()=>import(`./shellscript-Da78Ox-3.js`).then(e=>e.n),__vite__mapDeps([32,1])))},{id:`shellsession`,name:`Shell Session`,aliases:[`console`],import:(()=>D(()=>import(`./shellsession-CVsQGYfZ.js`),__vite__mapDeps([89,32,1])))},{id:`smalltalk`,name:`Smalltalk`,import:(()=>D(()=>import(`./smalltalk-B16xEiuN.js`),[]))},{id:`solidity`,name:`Solidity`,import:(()=>D(()=>import(`./solidity-CKzVLygQ.js`),[]))},{id:`soy`,name:`Closure Templates`,aliases:[`closure-templates`],import:(()=>D(()=>import(`./soy-DEd-qcad.js`),__vite__mapDeps([90,5,1,6,7])))},{id:`sparql`,name:`SPARQL`,import:(()=>D(()=>import(`./sparql-D_iOobhT.js`),__vite__mapDeps([91,92])))},{id:`splunk`,name:`Splunk Query Language`,aliases:[`spl`],import:(()=>D(()=>import(`./splunk-BC2Px7Mm.js`),[]))},{id:`sql`,name:`SQL`,import:(()=>D(()=>import(`./sql-ClgswhA6.js`).then(e=>e.n),__vite__mapDeps([20,1])))},{id:`ssh-config`,name:`SSH Config`,import:(()=>D(()=>import(`./ssh-config-BgfXC-Er.js`),[]))},{id:`stata`,name:`Stata`,import:(()=>D(()=>import(`./stata-RoaAgbqU.js`),__vite__mapDeps([93,20,1])))},{id:`stylus`,name:`Stylus`,aliases:[`styl`],import:(()=>D(()=>import(`./stylus-B6D30XZt.js`),[]))},{id:`surrealql`,name:`SurrealQL`,aliases:[`surql`],import:(()=>D(()=>import(`./surrealql-DIn4NJsS.js`),__vite__mapDeps([94,6,1])))},{id:`svelte`,name:`Svelte`,import:(()=>D(()=>import(`./svelte-Bj3Hmc9F.js`),__vite__mapDeps([95,6,1,7,15,16])))},{id:`swift`,name:`Swift`,import:(()=>D(()=>import(`./swift-DonLKvLd.js`),[]))},{id:`system-verilog`,name:`SystemVerilog`,import:(()=>D(()=>import(`./system-verilog-DJ5XKQeo.js`),[]))},{id:`systemd`,name:`Systemd Units`,import:(()=>D(()=>import(`./systemd-BxMlprV5.js`),[]))},{id:`talonscript`,name:`TalonScript`,aliases:[`talon`],import:(()=>D(()=>import(`./talonscript-CohzipZa.js`),[]))},{id:`tasl`,name:`Tasl`,import:(()=>D(()=>import(`./tasl-DMoTqEGO.js`),[]))},{id:`tcl`,name:`Tcl`,import:(()=>D(()=>import(`./tcl-CZd0xW_V.js`),[]))},{id:`templ`,name:`Templ`,import:(()=>D(()=>import(`./templ-TjxbArHn.js`),__vite__mapDeps([96,6,1,7,97])))},{id:`terraform`,name:`Terraform`,aliases:[`tf`,`tfvars`],import:(()=>D(()=>import(`./terraform-DswuEJGm.js`),[]))},{id:`tex`,name:`TeX`,import:(()=>D(()=>import(`./tex-0w6-Dtgt.js`),__vite__mapDeps([70,66,1])))},{id:`toml`,name:`TOML`,import:(()=>D(()=>import(`./toml-CcmNWLt0.js`),[]))},{id:`ts-tags`,name:`TypeScript with Tags`,aliases:[`lit`],import:(()=>D(()=>import(`./ts-tags-DFwAVxhO.js`),__vite__mapDeps([98,6,1,7,5,11,12,15,20,30,23])))},{id:`tsv`,name:`TSV`,import:(()=>D(()=>import(`./tsv-sltzmVWM.js`),[]))},{id:`tsx`,name:`TSX`,import:(()=>D(()=>import(`./tsx-CUOciP0b.js`).then(e=>e.n),__vite__mapDeps([17,1])))},{id:`turtle`,name:`Turtle`,import:(()=>D(()=>import(`./turtle-ByJddavk.js`),[]))},{id:`twig`,name:`Twig`,import:(()=>D(()=>import(`./twig-BbcH-NR0.js`),__vite__mapDeps([99,6,1,7,9,25,37,5,11,12,20,23,28,29,30,32,38,39,15,17,40,41,42,79,13])))},{id:`typescript`,name:`TypeScript`,aliases:[`ts`,`cts`,`mts`],import:(()=>D(()=>import(`./typescript-BydbNFcO.js`).then(e=>e.n),__vite__mapDeps([15,1])))},{id:`typespec`,name:`TypeSpec`,aliases:[`tsp`],import:(()=>D(()=>import(`./typespec-BRdr0IET.js`),[]))},{id:`typst`,name:`Typst`,aliases:[`typ`],import:(()=>D(()=>import(`./typst-DI99ib-x.js`),[]))},{id:`v`,name:`V`,import:(()=>D(()=>import(`./v-DETTlOr0.js`),[]))},{id:`vala`,name:`Vala`,import:(()=>D(()=>import(`./vala-zf12oZj6.js`),[]))},{id:`vb`,name:`Visual Basic`,aliases:[`cmd`],import:(()=>D(()=>import(`./vb-Djn5o6TS.js`),[]))},{id:`verilog`,name:`Verilog`,import:(()=>D(()=>import(`./verilog-CiiDBU1e.js`),[]))},{id:`vhdl`,name:`VHDL`,import:(()=>D(()=>import(`./vhdl-BroJfC0k.js`),[]))},{id:`viml`,name:`Vim Script`,aliases:[`vim`,`vimscript`],import:(()=>D(()=>import(`./viml-DvXPmvsu.js`),[]))},{id:`vue`,name:`Vue`,import:(()=>D(()=>import(`./vue-BNi0qJZP.js`),__vite__mapDeps([100,6,1,7,5,13,15,19])))},{id:`vue-html`,name:`Vue HTML`,import:(()=>D(()=>import(`./vue-html-DkKkQnZL.js`),__vite__mapDeps([101,6,1])))},{id:`vue-vine`,name:`Vue Vine`,import:(()=>D(()=>import(`./vue-vine-DFaKYU4X.js`),__vite__mapDeps([102,6,1,7,9,16,73,103])))},{id:`vyper`,name:`Vyper`,aliases:[`vy`],import:(()=>D(()=>import(`./vyper-CgoNMtux.js`),[]))},{id:`wasm`,name:`WebAssembly`,import:(()=>D(()=>import(`./wasm-ByWQv1Qj.js`),[]))},{id:`wenyan`,name:`Wenyan`,aliases:[`文言`],import:(()=>D(()=>import(`./wenyan-C8pVoKbM.js`),[]))},{id:`wgsl`,name:`WGSL`,import:(()=>D(()=>import(`./wgsl-BsKzXJz4.js`),[]))},{id:`wikitext`,name:`Wikitext`,aliases:[`mediawiki`,`wiki`],import:(()=>D(()=>import(`./wikitext-ClFFjSW2.js`),[]))},{id:`wit`,name:`WebAssembly Interface Types`,import:(()=>D(()=>import(`./wit-DdvCle-K.js`),[]))},{id:`wolfram`,name:`Wolfram`,aliases:[`wl`],import:(()=>D(()=>import(`./wolfram-DLL8P-h_.js`),[]))},{id:`xml`,name:`XML`,import:(()=>D(()=>import(`./xml-BlnrEAEy.js`).then(e=>e.n),__vite__mapDeps([11,1,12])))},{id:`xsl`,name:`XSL`,import:(()=>D(()=>import(`./xsl-BOPS8gLt.js`),__vite__mapDeps([104,11,1,12])))},{id:`yaml`,name:`YAML`,aliases:[`yml`],import:(()=>D(()=>import(`./yaml-Du_6cdrH.js`).then(e=>e.n),__vite__mapDeps([42,1])))},{id:`zenscript`,name:`ZenScript`,import:(()=>D(()=>import(`./zenscript-BnlCZFoB.js`),[]))},{id:`zig`,name:`Zig`,import:(()=>D(()=>import(`./zig-CMLA9XwU.js`),[]))}],oI=Object.fromEntries(aI.map(e=>[e.id,e.import])),sI=Object.fromEntries(aI.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),cI={...oI,...sI},lI=Object.fromEntries([{id:`andromeeda`,displayName:`Andromeeda`,type:`dark`,import:(()=>D(()=>import(`./andromeeda-WkhI09AS.js`),[]))},{id:`aurora-x`,displayName:`Aurora X`,type:`dark`,import:(()=>D(()=>import(`./aurora-x-C7CFqhAd.js`),[]))},{id:`ayu-dark`,displayName:`Ayu Dark`,type:`dark`,import:(()=>D(()=>import(`./ayu-dark-CRu61w6_.js`),[]))},{id:`ayu-light`,displayName:`Ayu Light`,type:`light`,import:(()=>D(()=>import(`./ayu-light-Dn6O_aYR.js`),[]))},{id:`ayu-mirage`,displayName:`Ayu Mirage`,type:`dark`,import:(()=>D(()=>import(`./ayu-mirage-CTjYAbs-.js`),[]))},{id:`catppuccin-frappe`,displayName:`Catppuccin Frappé`,type:`dark`,import:(()=>D(()=>import(`./catppuccin-frappe-DFlFW5gh.js`),[]))},{id:`catppuccin-latte`,displayName:`Catppuccin Latte`,type:`light`,import:(()=>D(()=>import(`./catppuccin-latte-CpxdcXpJ.js`),[]))},{id:`catppuccin-macchiato`,displayName:`Catppuccin Macchiato`,type:`dark`,import:(()=>D(()=>import(`./catppuccin-macchiato-DIdIQ04K.js`),[]))},{id:`catppuccin-mocha`,displayName:`Catppuccin Mocha`,type:`dark`,import:(()=>D(()=>import(`./catppuccin-mocha-Co3Xjl64.js`),[]))},{id:`dark-plus`,displayName:`Dark Plus`,type:`dark`,import:(()=>D(()=>import(`./dark-plus-GAt2ZgX8.js`),[]))},{id:`dracula`,displayName:`Dracula Theme`,type:`dark`,import:(()=>D(()=>import(`./dracula-C2uKkzgK.js`),[]))},{id:`dracula-soft`,displayName:`Dracula Theme Soft`,type:`dark`,import:(()=>D(()=>import(`./dracula-soft-D1bVjxWZ.js`),[]))},{id:`everforest-dark`,displayName:`Everforest Dark`,type:`dark`,import:(()=>D(()=>import(`./everforest-dark-D-DlICQR.js`),[]))},{id:`everforest-light`,displayName:`Everforest Light`,type:`light`,import:(()=>D(()=>import(`./everforest-light-CeVdGHYG.js`),[]))},{id:`github-dark`,displayName:`GitHub Dark`,type:`dark`,import:(()=>D(()=>import(`./github-dark-DwbbXv51.js`),[]))},{id:`github-dark-default`,displayName:`GitHub Dark Default`,type:`dark`,import:(()=>D(()=>import(`./github-dark-default-CxjRwzl6.js`),[]))},{id:`github-dark-dimmed`,displayName:`GitHub Dark Dimmed`,type:`dark`,import:(()=>D(()=>import(`./github-dark-dimmed-Cr1oaoul.js`),[]))},{id:`github-dark-high-contrast`,displayName:`GitHub Dark High Contrast`,type:`dark`,import:(()=>D(()=>import(`./github-dark-high-contrast-B4qJZLZa.js`),[]))},{id:`github-light`,displayName:`GitHub Light`,type:`light`,import:(()=>D(()=>import(`./github-light-CsVXhIlR.js`),[]))},{id:`github-light-default`,displayName:`GitHub Light Default`,type:`light`,import:(()=>D(()=>import(`./github-light-default-DB_IwZa6.js`),[]))},{id:`github-light-high-contrast`,displayName:`GitHub Light High Contrast`,type:`light`,import:(()=>D(()=>import(`./github-light-high-contrast-DLgVeSB-.js`),[]))},{id:`gruvbox-dark-hard`,displayName:`Gruvbox Dark Hard`,type:`dark`,import:(()=>D(()=>import(`./gruvbox-dark-hard-DXm60lX3.js`),[]))},{id:`gruvbox-dark-medium`,displayName:`Gruvbox Dark Medium`,type:`dark`,import:(()=>D(()=>import(`./gruvbox-dark-medium-GE2thSmD.js`),[]))},{id:`gruvbox-dark-soft`,displayName:`Gruvbox Dark Soft`,type:`dark`,import:(()=>D(()=>import(`./gruvbox-dark-soft-04Cj-4VZ.js`),[]))},{id:`gruvbox-light-hard`,displayName:`Gruvbox Light Hard`,type:`light`,import:(()=>D(()=>import(`./gruvbox-light-hard-K6wSn29D.js`),[]))},{id:`gruvbox-light-medium`,displayName:`Gruvbox Light Medium`,type:`light`,import:(()=>D(()=>import(`./gruvbox-light-medium-CVy3aSlc.js`),[]))},{id:`gruvbox-light-soft`,displayName:`Gruvbox Light Soft`,type:`light`,import:(()=>D(()=>import(`./gruvbox-light-soft-DNgJjaY0.js`),[]))},{id:`horizon`,displayName:`Horizon`,type:`dark`,import:(()=>D(()=>import(`./horizon-0-RkHfro.js`),[]))},{id:`horizon-bright`,displayName:`Horizon Bright`,type:`light`,import:(()=>D(()=>import(`./horizon-bright-BgL2X9oq.js`),[]))},{id:`houston`,displayName:`Houston`,type:`dark`,import:(()=>D(()=>import(`./houston-KyjWKfuY.js`),[]))},{id:`kanagawa-dragon`,displayName:`Kanagawa Dragon`,type:`dark`,import:(()=>D(()=>import(`./kanagawa-dragon-7TqgsUPC.js`),[]))},{id:`kanagawa-lotus`,displayName:`Kanagawa Lotus`,type:`light`,import:(()=>D(()=>import(`./kanagawa-lotus-CqxMQulh.js`),[]))},{id:`kanagawa-wave`,displayName:`Kanagawa Wave`,type:`dark`,import:(()=>D(()=>import(`./kanagawa-wave-D8CNn6T_.js`),[]))},{id:`laserwave`,displayName:`LaserWave`,type:`dark`,import:(()=>D(()=>import(`./laserwave-CQkdhozh.js`),[]))},{id:`light-plus`,displayName:`Light Plus`,type:`light`,import:(()=>D(()=>import(`./light-plus-CNQ8_7Y0.js`),[]))},{id:`material-theme`,displayName:`Material Theme`,type:`dark`,import:(()=>D(()=>import(`./material-theme-CAtLaHa3.js`),[]))},{id:`material-theme-darker`,displayName:`Material Theme Darker`,type:`dark`,import:(()=>D(()=>import(`./material-theme-darker-k-s5Bc6K.js`),[]))},{id:`material-theme-lighter`,displayName:`Material Theme Lighter`,type:`light`,import:(()=>D(()=>import(`./material-theme-lighter-CD6a-c4d.js`),[]))},{id:`material-theme-ocean`,displayName:`Material Theme Ocean`,type:`dark`,import:(()=>D(()=>import(`./material-theme-ocean-B3mraInd.js`),[]))},{id:`material-theme-palenight`,displayName:`Material Theme Palenight`,type:`dark`,import:(()=>D(()=>import(`./material-theme-palenight-DEhAARHw.js`),[]))},{id:`min-dark`,displayName:`Min Dark`,type:`dark`,import:(()=>D(()=>import(`./min-dark-BFqTAwCr.js`),[]))},{id:`min-light`,displayName:`Min Light`,type:`light`,import:(()=>D(()=>import(`./min-light-O7UdaaxX.js`),[]))},{id:`monokai`,displayName:`Monokai`,type:`dark`,import:(()=>D(()=>import(`./monokai-C0p7Qecz.js`),[]))},{id:`night-owl`,displayName:`Night Owl`,type:`dark`,import:(()=>D(()=>import(`./night-owl-BsnCLAKc.js`),[]))},{id:`night-owl-light`,displayName:`Night Owl Light`,type:`light`,import:(()=>D(()=>import(`./night-owl-light-BODRhcTU.js`),[]))},{id:`nord`,displayName:`Nord`,type:`dark`,import:(()=>D(()=>import(`./nord-Cd-F4txO.js`),[]))},{id:`one-dark-pro`,displayName:`One Dark Pro`,type:`dark`,import:(()=>D(()=>import(`./one-dark-pro-DUS_IGRK.js`),[]))},{id:`one-light`,displayName:`One Light`,type:`light`,import:(()=>D(()=>import(`./one-light-CVUd7yD5.js`),[]))},{id:`plastic`,displayName:`Plastic`,type:`dark`,import:(()=>D(()=>import(`./plastic-CF8VZTnn.js`),[]))},{id:`poimandres`,displayName:`Poimandres`,type:`dark`,import:(()=>D(()=>import(`./poimandres-BX2TyY6j.js`),[]))},{id:`red`,displayName:`Red`,type:`dark`,import:(()=>D(()=>import(`./red-7ga_dcKu.js`),[]))},{id:`rose-pine`,displayName:`Rosé Pine`,type:`dark`,import:(()=>D(()=>import(`./rose-pine-rh6ipraJ.js`),[]))},{id:`rose-pine-dawn`,displayName:`Rosé Pine Dawn`,type:`light`,import:(()=>D(()=>import(`./rose-pine-dawn-DSuRaP6u.js`),[]))},{id:`rose-pine-moon`,displayName:`Rosé Pine Moon`,type:`dark`,import:(()=>D(()=>import(`./rose-pine-moon-DdHjCvFQ.js`),[]))},{id:`slack-dark`,displayName:`Slack Dark`,type:`dark`,import:(()=>D(()=>import(`./slack-dark-DYvUXyrP.js`),[]))},{id:`slack-ochin`,displayName:`Slack Ochin`,type:`light`,import:(()=>D(()=>import(`./slack-ochin-bqtMVDfH.js`),[]))},{id:`snazzy-light`,displayName:`Snazzy Light`,type:`light`,import:(()=>D(()=>import(`./snazzy-light-D8dzFmq5.js`),[]))},{id:`solarized-dark`,displayName:`Solarized Dark`,type:`dark`,import:(()=>D(()=>import(`./solarized-dark-BQwPDzxK.js`),[]))},{id:`solarized-light`,displayName:`Solarized Light`,type:`light`,import:(()=>D(()=>import(`./solarized-light-BLaijb3X.js`),[]))},{id:`synthwave-84`,displayName:`Synthwave '84`,type:`dark`,import:(()=>D(()=>import(`./synthwave-84-CIknw8y7.js`),[]))},{id:`tokyo-night`,displayName:`Tokyo Night`,type:`dark`,import:(()=>D(()=>import(`./tokyo-night-iIspnLcq.js`),[]))},{id:`vesper`,displayName:`Vesper`,type:`dark`,import:(()=>D(()=>import(`./vesper-D5bVUKB1.js`),[]))},{id:`vitesse-black`,displayName:`Vitesse Black`,type:`dark`,import:(()=>D(()=>import(`./vitesse-black-D082JcaE.js`),[]))},{id:`vitesse-dark`,displayName:`Vitesse Dark`,type:`dark`,import:(()=>D(()=>import(`./vitesse-dark-z-nr_5O8.js`),[]))},{id:`vitesse-light`,displayName:`Vitesse Light`,type:`light`,import:(()=>D(()=>import(`./vitesse-light-ojz42ZLy.js`),[]))}].map(e=>[e.id,e.import])),uI=e({createOnigurumaEngine:()=>II,getDefaultWasmLoader:()=>FI,loadWasm:()=>kI,setDefaultWasmLoader:()=>PI}),dI=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function fI(){return 2147483648}function pI(){return typeof performance<`u`?performance.now():Date.now()}var mI=(e,t)=>e+(t-e%t)%t;async function hI(e){let t,n,r={};function i(e){n=e,r.HEAPU8=new Uint8Array(e),r.HEAPU32=new Uint32Array(e)}function a(e,t,n){r.HEAPU8.copyWithin(e,t,t+n)}function o(e){try{return t.grow(e-n.byteLength+65535>>>16),i(t.buffer),1}catch{}}function s(e){let t=r.HEAPU8.length;e>>>=0;let n=fI();if(e>n)return!1;for(let r=1;r<=4;r*=2){let i=t*(1+.2/r);if(i=Math.min(i,e+100663296),o(Math.min(n,mI(Math.max(e,i),65536))))return!0}return!1}let c=typeof TextDecoder<`u`?new TextDecoder(`utf8`):void 0;function l(e,t,n=1024){let r=t+n,i=t;for(;e[i]&&!(i>=r);)++i;if(i-t>16&&e.buffer&&c)return c.decode(e.subarray(t,i));let a=``;for(;t<i;){let n=e[t++];if(!(n&128)){a+=String.fromCharCode(n);continue}let r=e[t++]&63;if((n&224)==192){a+=String.fromCharCode((n&31)<<6|r);continue}let i=e[t++]&63;if(n=(n&240)==224?(n&15)<<12|r<<6|i:(n&7)<<18|r<<12|i<<6|e[t++]&63,n<65536)a+=String.fromCharCode(n);else{let e=n-65536;a+=String.fromCharCode(55296|e>>10,56320|e&1023)}}return a}function u(e,t){return e?l(r.HEAPU8,e,t):``}let d={emscripten_get_now:pI,emscripten_memcpy_big:a,emscripten_resize_heap:s,fd_write:()=>0};async function f(){let n=await e({env:d,wasi_snapshot_preview1:d});t=n.memory,i(t.buffer),Object.assign(r,n),r.UTF8ToString=u}return await f(),r}var gI=Object.defineProperty,_I=(e,t,n)=>t in e?gI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,K=(e,t,n)=>_I(e,typeof t==`symbol`?t:t+``,n),q=null;function vI(e){throw new dI(e.UTF8ToString(e.getLastOnigError()))}var yI=class e{constructor(t){K(this,`utf16Length`),K(this,`utf8Length`),K(this,`utf16Value`),K(this,`utf8Value`),K(this,`utf16OffsetToUtf8`),K(this,`utf8OffsetToUtf16`);let n=t.length,r=e._utf8ByteLength(t),i=r!==n,a=i?new Uint32Array(n+1):null;i&&(a[n]=r);let o=i?new Uint32Array(r+1):null;i&&(o[r]=n);let s=new Uint8Array(r),c=0;for(let e=0;e<n;e++){let r=t.charCodeAt(e),l=r,u=!1;if(r>=55296&&r<=56319&&e+1<n){let n=t.charCodeAt(e+1);n>=56320&&n<=57343&&(l=(r-55296<<10)+65536|n-56320,u=!0)}i&&(a[e]=c,u&&(a[e+1]=c),l<=127?o[c+0]=e:l<=2047?(o[c+0]=e,o[c+1]=e):l<=65535?(o[c+0]=e,o[c+1]=e,o[c+2]=e):(o[c+0]=e,o[c+1]=e,o[c+2]=e,o[c+3]=e)),l<=127?s[c++]=l:l<=2047?(s[c++]=192|(l&1984)>>>6,s[c++]=128|(l&63)>>>0):l<=65535?(s[c++]=224|(l&61440)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0):(s[c++]=240|(l&1835008)>>>18,s[c++]=128|(l&258048)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0),u&&e++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=s,this.utf16OffsetToUtf8=a,this.utf8OffsetToUtf16=o}static _utf8ByteLength(e){let t=0;for(let n=0,r=e.length;n<r;n++){let i=e.charCodeAt(n),a=i,o=!1;if(i>=55296&&i<=56319&&n+1<r){let t=e.charCodeAt(n+1);t>=56320&&t<=57343&&(a=(i-55296<<10)+65536|t-56320,o=!0)}t+=a<=127?1:a<=2047?2:a<=65535?3:4,o&&n++}return t}createString(e){let t=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,t),t}},bI=class e{constructor(t){if(K(this,`id`,++e.LAST_ID),K(this,`_onigBinding`),K(this,`content`),K(this,`utf16Length`),K(this,`utf8Length`),K(this,`utf16OffsetToUtf8`),K(this,`utf8OffsetToUtf16`),K(this,`ptr`),!q)throw new dI(`Must invoke loadWasm first.`);this._onigBinding=q,this.content=t;let n=new yI(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!e._sharedPtrInUse?(e._sharedPtr||=q.omalloc(1e4),e._sharedPtrInUse=!0,q.HEAPU8.set(n.utf8Value,e._sharedPtr),this.ptr=e._sharedPtr):this.ptr=n.createString(q)}convertUtf8OffsetToUtf16(e){return this.utf8OffsetToUtf16?e<0?0:e>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[e]:e}convertUtf16OffsetToUtf8(e){return this.utf16OffsetToUtf8?e<0?0:e>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[e]:e}dispose(){this.ptr===e._sharedPtr?e._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};K(bI,`LAST_ID`,0),K(bI,`_sharedPtr`,0),K(bI,`_sharedPtrInUse`,!1);var xI=bI,SI=class{constructor(e){if(K(this,`_onigBinding`),K(this,`_ptr`),!q)throw new dI(`Must invoke loadWasm first.`);let t=[],n=[];for(let r=0,i=e.length;r<i;r++){let i=new yI(e[r]);t[r]=i.createString(q),n[r]=i.utf8Length}let r=q.omalloc(4*e.length);q.HEAPU32.set(t,r/4);let i=q.omalloc(4*e.length);q.HEAPU32.set(n,i/4);let a=q.createOnigScanner(r,i,e.length);for(let n=0,r=e.length;n<r;n++)q.ofree(t[n]);q.ofree(i),q.ofree(r),a===0&&vI(q),this._onigBinding=q,this._ptr=a}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,t,n){let r=0;if(typeof n==`number`&&(r=n),typeof e==`string`){e=new xI(e);let n=this._findNextMatchSync(e,t,!1,r);return e.dispose(),n}return this._findNextMatchSync(e,t,!1,r)}_findNextMatchSync(e,t,n,r){let i=this._onigBinding,a=i.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(t),r);if(a===0)return null;let o=i.HEAPU32,s=a/4,c=o[s++],l=o[s++],u=[];for(let t=0;t<l;t++){let n=e.convertUtf8OffsetToUtf16(o[s++]),r=e.convertUtf8OffsetToUtf16(o[s++]);u[t]={start:n,end:r,length:r-n}}return{index:c,captureIndices:u}}};function CI(e){return typeof e.instantiator==`function`}function wI(e){return typeof e.default==`function`}function TI(e){return e.data!==void 0}function EI(e){return typeof Response<`u`&&e instanceof Response}function DI(e){return typeof ArrayBuffer<`u`&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<`u`&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||typeof Uint32Array<`u`&&e instanceof Uint32Array}var OI;function kI(e){if(OI)return OI;async function t(){q=await hI(async t=>{let n=e;return n=await n,typeof n==`function`&&(n=await n(t)),typeof n==`function`&&(n=await n(t)),CI(n)?n=await n.instantiator(t):wI(n)?n=await n.default(t):(TI(n)&&(n=n.data),EI(n)?n=typeof WebAssembly.instantiateStreaming==`function`?await jI(n)(t):await MI(n)(t):DI(n)||n instanceof WebAssembly.Module?n=await AI(n)(t):`default`in n&&n.default instanceof WebAssembly.Module&&(n=await AI(n.default)(t))),`instance`in n&&(n=n.instance),`exports`in n&&(n=n.exports),n})}return OI=t(),OI}function AI(e){return t=>WebAssembly.instantiate(e,t)}function jI(e){return t=>WebAssembly.instantiateStreaming(e,t)}function MI(e){return async t=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var NI;function PI(e){NI=e}function FI(){return NI}async function II(e){return e&&await kI(e),{createScanner(e){return new SI(e.map(e=>typeof e==`string`?e:e.source))},createString(e){return new xI(e)}}}var LI=nI({});iI(LI,uI);var J=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function RI(e){return zI(e)}function zI(e){return Array.isArray(e)?BI(e):e instanceof RegExp?e:typeof e==`object`?VI(e):e}function BI(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=zI(e[n]);return t}function VI(e){let t={};for(let n in e)t[n]=zI(e[n]);return t}function HI(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function UI(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?UI(e.substring(0,e.length-1)):e.substr(~t+1)}var WI=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,GI=class{static hasCaptures(e){return e!==null&&(WI.lastIndex=0,WI.test(e))}static replaceCaptures(e,t,n){return e.replace(WI,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function KI(e,t){return e<t?-1:+(e>t)}function qI(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=KI(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function JI(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function YI(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var XI=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},ZI=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(nL(e),t)}static createFromParsedTheme(e,t){return iL(e,t)}_cachedMatchRoot=new XI(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>$I(e.parent,t.parentScopes));return n?new tL(n.fontStyle,n.foreground,n.background):null}},QI=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e||this.parent!==null&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function $I(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!eL(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function eL(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var tL=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function nL(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8}}let s=null;typeof i.settings.foreground==`string`&&JI(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&JI(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new rL(l,u,e,o,s,c)}}return n}var rL=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}},Y=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(Y||{});function iL(e,t){e.sort((e,t)=>{let n=KI(e.scope,t.scope);return n!==0||(n=qI(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new aL(t),o=new tL(n,a.getId(r),a.getId(i)),s=new cL(new sL(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new ZI(a,o,s)}var aL=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},oL=Object.freeze([]),sL=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||oL,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},cL=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),sL.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(qI(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new sL(e,t,n,r,i))}},lL=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return!!(e&1024)}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=dL(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function uL(e){return e}function dL(e){return e}function fL(e,t){let n=[],r=mL(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(pL(i)){let e=[];do e.push(i),i=r.next();while(pL(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function pL(e){return!!e&&!!e.match(/[\w\.:]+/)}function mL(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function hL(e){typeof e.dispose==`function`&&e.dispose()}var gL=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},_L=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},vL=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},yL=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new gL(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new vL;for(let n of e)bL(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof gL){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function bL(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof gL?SL({baseGrammar:a,selfGrammar:i},r):xL(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new gL(e))}function xL(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];CL([r],t,n)}}function SL(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&CL(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&CL(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function CL(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?HI({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&CL(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=kL(i);switch(a.kind){case 0:SL({...t,selfGrammar:t.baseGrammar},n);break;case 1:SL(t,n);break;case 2:xL(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?xL(a.ruleName,i,n):SL(i,n)}else a.kind===4?n.add(new _L(a.scopeName,a.ruleName)):n.add(new gL(a.scopeName))}}}var wL=class{kind=0},TL=class{kind=1},EL=class{constructor(e){this.ruleName=e}kind=2},DL=class{constructor(e){this.scopeName=e}kind=3},OL=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function kL(e){if(e===`$base`)return new wL;if(e===`$self`)return new TL;let t=e.indexOf(`#`);return t===-1?new DL(e):t===0?new EL(e.substring(1)):new OL(e.substring(0,t),e.substring(t+1))}var AL=/\\(\d+)/,jL=/\\(\d+)/g,ML=-1,NL=-2;function PL(e){return e}function FL(e){return e}var IL=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=GI.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=GI.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${UI(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:GI.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:GI.replaceCaptures(this._contentName,e,t)}},LL=class extends IL{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},RL=class extends IL{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new UL(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new WL,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},zL=class extends IL{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new WL,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},BL=class extends IL{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new UL(i,this.id),this.beginCaptures=a,this._end=new UL(o||``,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new WL;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},VL=class extends IL{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new UL(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new UL(o,NL),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new WL;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new WL,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||``),this._cachedCompiledWhilePatterns}},HL=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new LL(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new RL(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=HI({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new zL(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new VL(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new BL(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=kL(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository)}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof zL||e instanceof BL||e instanceof VL)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},UL=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this._anchorCache=this.hasAnchor?this._buildAnchorCache():null,this.ruleId=t,this.hasBackReferences=typeof this.source==`string`&&AL.test(this.source)}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return jL.lastIndex=0,this.source.replace(jL,(e,t)=>YI(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=``,t[i+1]=``,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=``,t[i+1]=`G`,n[i+1]=``,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},WL=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new GL(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new GL(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},GL=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
|
|
42
|
-
`)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},
|
|
43
|
-
`;let a=this.createOnigString(e),o=a.content.length,s=new mR(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=XL(this,a,i,0,t,s,!0,r);return hL(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function uR(e,t){return e=RI(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var dR=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=QI.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new QI(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new QI(null,t),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(n,i,o);return new e(null,a,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),lL.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(t.tokenAttributes,i,o);return new e(t,a,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},fR=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t!==null&&e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?dR.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:FL(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=dR.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,PL(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,dR.fromExtension(r,n.contentNameScopesList))}},pR=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):fL(e,sR).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>fL(e,sR).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},mR=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=lL.set(n,0,uL(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=lL.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},hR=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,aR(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},gR=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new hR(ZI.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(ZI.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new pR(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new yL(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},_R=fR.NULL;function vR(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function yR(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function bR(e){return Array.isArray(e)?e:[e]}async function xR(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function SR(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function CR(e){return e===`ansi`||SR(e)}function wR(e){return e===`none`}function TR(e){return wR(e)}function ER(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(/(\r?\n)/g),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}var DR={light:`#333333`,dark:`#bbbbbb`},OR={light:`#fffffe`,dark:`#1e1e1e`},kR=`__shiki_resolved`;function AR(e){if(e?.[kR])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?DR.light:DR.dark,n||=t.type===`light`?OR.light:OR.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,kR,{enumerable:!1,writable:!1,value:!0}),t}async function jR(e){return Array.from(new Set((await Promise.all(e.filter(e=>!CR(e)).map(async e=>await xR(e).then(e=>Array.isArray(e)?e:[e])))).flat()))}async function MR(e){return(await Promise.all(e.map(async e=>TR(e)?null:AR(await xR(e))))).filter(e=>!!e)}function NR(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new J(`Circular alias \`${Array.from(n).join(` -> `)} -> ${e}\``);n.add(e)}}return e}var PR=class extends gR{_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=AR(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=ZI.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=NR(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null,t.size)for(let e of t)this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(e.scopeName),this._syncRegistry?._grammars?.delete(e.scopeName),this.loadLanguage(this._langMap.get(e.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=Array.from(this._langGraph.entries()),n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new J(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},FR=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}},IR=0;function LR(e){IR+=1,e.warnings!==!1&&IR>=10&&IR%10==0&&console.warn(`[Shiki] ${IR} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new J("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(AR),i=new PR(new FR(e.engine,n),r,n,e.langAlias),a;function o(t){return NR(t,e.langAlias)}function s(e){g();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new J(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};g();let t=i.getTheme(e);if(!t)throw new J(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){g();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return g(),i.getLoadedThemes()}function d(){return g(),i.getLoadedLanguages()}function f(...e){g(),i.loadLanguages(e.flat(1))}async function p(...e){return f(await jR(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await MR(e))}function g(){if(t)throw new J(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--IR)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:o,loadLanguage:p,loadLanguageSync:f,loadTheme:h,loadThemeSync:m,dispose:_,[Symbol.dispose]:_}}async function RR(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([MR(e.themes||[]),jR(e.langs||[]),e.engine]);return LR({...e,themes:t,langs:n,engine:r})}var zR=new WeakMap;function BR(e,t){zR.set(e,t)}function VR(e){return zR.get(e)}var HR=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(bR(n).map(e=>[e,_R])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return UR(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function UR(e){let t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function WR(e,t){if(!(e instanceof HR))throw new J(`Invalid grammar state`);return e.getInternalStack(t)}function GR(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(SR(e.resolveLangAlias(n.lang||`text`))||wR(r))return ER(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new J(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new J(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return qR(t,o,i,a,n)}function KR(...e){if(e.length===2)return VR(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(SR(i)||wR(a))throw new J(`Plain language does not have grammar state`);if(i===`ansi`)throw new J(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new HR(JR(n,c,o,s,r).stateStack,c.name,o.name)}function qR(e,t,n,r,i){let a=JR(e,t,n,r,i),o=new HR(a.stateStack,t.name,n.name);return BR(a.tokens,o),a.tokens}function JR(e,t,n,r,i){let a=vR(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500}=i,c=ER(e),l=i.grammarState?WR(i.grammarState,n.name)??_R:i.grammarContextCode==null?_R:JR(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,u=[],d=[];for(let e=0,f=c.length;e<f;e++){let[f,p]=c[e];if(f===``){u=[],d.push([]);continue}if(o>0&&f.length>=o){u=[],d.push([{content:f,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;i.includeExplanation&&(m=t.tokenizeLine(f,l,s),h=m.tokens,g=0);let _=t.tokenizeLine2(f,l,s),v=_.tokens.length/2;for(let e=0;e<v;e++){let t=_.tokens[2*e],o=e+1<v?_.tokens[2*e+2]:f.length;if(t===o)continue;let s=_.tokens[2*e+1],c=yR(r[lL.getForeground(s)],a),l=lL.getFontStyle(s),d={content:f.substring(t,o),offset:p+t,color:c,fontStyle:l};if(i.includeExplanation){let e=[];if(i.includeExplanation!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(/,/).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(/ /))})}d.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=f.substring(t.startIndex,t.endIndex);r+=n.length,d.explanation.push({content:n,scopes:i.includeExplanation===`scopeName`?YR(t.scopes):XR(e,t.scopes)}),g+=1}}u.push(d)}d.push(u),u=[],l=_.ruleStack}return{tokens:d,stateStack:l}}function YR(e){return e.map(e=>({scopeName:e}))}function XR(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:$R(e,i,t.slice(0,r))}}return n}function ZR(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function QR(e,t,n){if(!ZR(e[e.length-1],t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)ZR(e[r],n[i])&&--r,--i;return r===-1}function $R(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(QR(e,t,n)){r.push(a);break}return r}function ez(e,t,n,r=GR){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:VR(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=tz(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new HR(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&BR(s,c),s}function tz(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}function nz(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class==`string`&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(/\s+/g);for(let t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}function rz(e){let t=ER(e,!0).map(([e])=>e);function n(n){if(n===e.length)return{line:t.length-1,character:t[t.length-1].length};let r=n,i=0;for(let e of t){if(r<e.length)break;r-=e.length,i++}return{line:i,character:r}}function r(e,n){let r=0;for(let n=0;n<e;n++)r+=t[n].length;return r+=n,r}return{lines:t,indexToPos:n,posToIndex:r}}function iz(e,t,n){let r=new Set;for(let t of e.matchAll(/:?lang=["']([^"']+)["']/g)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(/\\begin\{([\w-]+)\}/g)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let e=t[1].toLowerCase().trim(),n=e.includes(`/`)?e.split(`/`).pop():e;n&&r.add(n)}if(!n)return Array.from(r);let i=n.getBundledLanguages();return Array.from(r).filter(e=>e&&i[e])}var az=`light-dark()`,oz=[`color`,`background-color`];function sz(e,t){let n=0,r=[];for(let i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function cz(e,t){let n=Array.from(t instanceof Set?t:new Set(t)).sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{let t=n.filter(t=>e.offset<t&&t<e.offset+e.content.length).map(t=>t-e.offset).sort((e,t)=>e-t);return t.length?sz(e,t):e})):e}function lz(e,t,n,r,i=`css-vars`){let a={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>uz(e.variants[t])),s=new Set(o.flatMap(e=>Object.keys(e))),c={},l=(e,r)=>{let i=r===`color`?``:r===`background-color`?`-bg`:`-${r}`;return n+t[e]+(r===`color`?``:i)};return o.forEach((e,n)=>{for(let a of s){let s=e[a]||`inherit`;if(n===0&&r&&oz.includes(a))if(r===az&&o.length>1){let e=t.findIndex(e=>e===`light`),r=t.findIndex(e=>e===`dark`);if(e===-1||r===-1)throw new J('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');c[a]=`light-dark(${o[e][a]||`inherit`}, ${o[r][a]||`inherit`})`,i===`css-vars`&&(c[l(n,a)]=s)}else c[a]=s;else i===`css-vars`&&(c[l(n,a)]=s)}}),a.htmlStyle=c,a}function uz(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t[`background-color`]=e.bgColor),e.fontStyle){e.fontStyle&Y.Italic&&(t[`font-style`]=`italic`),e.fontStyle&Y.Bold&&(t[`font-weight`]=`bold`);let n=[];e.fontStyle&Y.Underline&&n.push(`underline`),e.fontStyle&Y.Strikethrough&&n.push(`line-through`),n.length&&(t[`text-decoration`]=n.join(` `))}return t}function dz(e){return typeof e==`string`?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function fz(){let e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=rz(t.source);function r(e){if(typeof e==`number`){if(e<0||e>t.source.length)throw new J(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...n.indexToPos(e),offset:e}}{let t=n.lines[e.line];if(t===void 0)throw new J(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${n.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new J(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:n.posToIndex(e.line,r)}}}let i=(t.options.decorations||[]).map(e=>({...e,start:r(e.start),end:r(e.end)}));pz(i),e.set(t.meta,{decorations:i,converter:n,source:t.source})}return e.get(t.meta)}return{name:`shiki:decorations`,tokens(e){if(this.options.decorations?.length)return cz(e,t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]))},code(e){if(!this.options.decorations?.length)return;let n=t(this),r=Array.from(e.children).filter(e=>e.type===`element`&&e.tagName===`span`);if(r.length!==n.converter.lines.length)throw new J(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function i(e,t,n,i){let a=r[e],s=``,c=-1,l=-1;if(t===0&&(c=0),n===0&&(l=0),n===1/0&&(l=a.children.length),c===-1||l===-1)for(let e=0;e<a.children.length;e++)s+=mz(a.children[e]),c===-1&&s.length===t&&(c=e+1),l===-1&&s.length===n&&(l=e+1);if(c===-1)throw new J(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(l===-1)throw new J(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let u=a.children.slice(c,l);if(!i.alwaysWrap&&u.length===a.children.length)o(a,i,`line`);else if(!i.alwaysWrap&&u.length===1&&u[0].type===`element`)o(u[0],i,`token`);else{let e={type:`element`,tagName:`span`,properties:{},children:u};o(e,i,`wrapper`),a.children.splice(c,u.length,e)}}function a(e,t){r[e]=o(r[e],t,`line`)}function o(e,t,n){let r=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||`span`,e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&nz(e,t.properties.class),e=i(e,n)||e,e}let s=[],c=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(let e of c){let{start:t,end:n}=e;if(t.line===n.line)i(t.line,t.character,n.character,e);else if(t.line<n.line){i(t.line,t.character,1/0,e);for(let r=t.line+1;r<n.line;r++)s.unshift(()=>a(r,e));i(n.line,0,n.character,e)}}s.forEach(e=>e())}}}function pz(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new J(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let t=e[r],i=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,a=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,s=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(i||a||o||s){if(i&&a||o&&s||o&&n.start.offset===n.end.offset||a&&t.start.offset===t.end.offset)continue;throw new J(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}function mz(e){return e.type===`text`?e.value:e.type===`element`?e.children.map(mz).join(``):``}var hz=[fz()];function gz(e){let t=_z(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...hz]}function _z(e){let t=[],n=[],r=[];for(let i of e)switch(i.enforce){case`pre`:t.push(i);break;case`post`:n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var vz=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],yz={1:`bold`,2:`dim`,3:`italic`,4:`underline`,7:`reverse`,8:`hidden`,9:`strikethrough`};function bz(e,t){let n=e.indexOf(`\x1B`,t);if(n!==-1&&e[n+1]===`[`){let t=e.indexOf(`m`,n);if(t!==-1)return{sequence:e.substring(n+2,t).split(`;`),startPosition:n,position:t+1}}return{position:e.length}}function xz(e){let t=e.shift();if(t===`2`){let t=e.splice(0,3).map(e=>Number.parseInt(e));return t.length!==3||t.some(e=>Number.isNaN(e))?void 0:{type:`rgb`,rgb:t}}if(t===`5`){let t=e.shift();if(t)return{type:`table`,index:Number(t)}}}function Sz(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:`resetAll`});else if(r<=9)yz[r]&&t.push({type:`setDecoration`,value:yz[r]});else if(r<=29){let e=yz[r-20];e&&(t.push({type:`resetDecoration`,value:e}),e===`dim`&&t.push({type:`resetDecoration`,value:`bold`}))}else if(r<=37)t.push({type:`setForegroundColor`,value:{type:`named`,name:vz[r-30]}});else if(r===38){let n=xz(e);n&&t.push({type:`setForegroundColor`,value:n})}else if(r===39)t.push({type:`resetForegroundColor`});else if(r<=47)t.push({type:`setBackgroundColor`,value:{type:`named`,name:vz[r-40]}});else if(r===48){let n=xz(e);n&&t.push({type:`setBackgroundColor`,value:n})}else r===49?t.push({type:`resetBackgroundColor`}):r===53?t.push({type:`setDecoration`,value:`overline`}):r===55?t.push({type:`resetDecoration`,value:`overline`}):r>=90&&r<=97?t.push({type:`setForegroundColor`,value:{type:`named`,name:vz[r-90+8]}}):r>=100&&r<=107&&t.push({type:`setBackgroundColor`,value:{type:`named`,name:vz[r-100+8]}})}return t}function Cz(){let e=null,t=null,n=new Set;return{parse(r){let i=[],a=0;do{let o=bz(r,a),s=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(s.length>0&&i.push({value:s,foreground:e,background:t,decorations:new Set(n)}),o.sequence){let r=Sz(o.sequence);for(let i of r)i.type===`resetAll`?(e=null,t=null,n.clear()):i.type===`resetForegroundColor`?e=null:i.type===`resetBackgroundColor`?t=null:i.type===`resetDecoration`&&n.delete(i.value);for(let i of r)i.type===`setForegroundColor`?e=i.value:i.type===`setBackgroundColor`?t=i.value:i.type===`setDecoration`&&n.add(i.value)}a=o.position}while(a<r.length);return i}}}var wz={black:`#000000`,red:`#bb0000`,green:`#00bb00`,yellow:`#bbbb00`,blue:`#0000bb`,magenta:`#ff00ff`,cyan:`#00bbbb`,white:`#eeeeee`,brightBlack:`#555555`,brightRed:`#ff5555`,brightGreen:`#00ff00`,brightYellow:`#ffff55`,brightBlue:`#5555ff`,brightMagenta:`#ff55ff`,brightCyan:`#55ffff`,brightWhite:`#ffffff`};function Tz(e=wz){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,`0`)).join(``)}`}let r;function i(){if(r)return r;r=[];for(let e=0;e<vz.length;e++)r.push(t(vz[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)r.push(n([e[t],e[i],e[a]]));let i=8;for(let e=0;e<24;e++,i+=10)r.push(n([i,i,i]));return r}function a(e){return i()[e]}function o(e){switch(e.type){case`named`:return t(e.name);case`rgb`:return n(e.rgb);case`table`:return a(e.index)}}return{value:o}}var Ez={black:`#000000`,red:`#cd3131`,green:`#0DBC79`,yellow:`#E5E510`,blue:`#2472C8`,magenta:`#BC3FBC`,cyan:`#11A8CD`,white:`#E5E5E5`,brightBlack:`#666666`,brightRed:`#F14C4C`,brightGreen:`#23D18B`,brightYellow:`#F5F543`,brightBlue:`#3B8EEA`,brightMagenta:`#D670D6`,brightCyan:`#29B8DB`,brightWhite:`#FFFFFF`};function Dz(e,t,n){let r=vR(e,n),i=ER(t),a=Tz(Object.fromEntries(vz.map(t=>{let n=`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`;return[t,e.colors?.[n]||Ez[t]]}))),o=Cz();return i.map(t=>o.parse(t[0]).map(n=>{let i,o;n.decorations.has(`reverse`)?(i=n.background?a.value(n.background):e.bg,o=n.foreground?a.value(n.foreground):e.fg):(i=n.foreground?a.value(n.foreground):e.fg,o=n.background?a.value(n.background):void 0),i=yR(i,r),o=yR(o,r),n.decorations.has(`dim`)&&(i=Oz(i));let s=Y.None;return n.decorations.has(`bold`)&&(s|=Y.Bold),n.decorations.has(`italic`)&&(s|=Y.Italic),n.decorations.has(`underline`)&&(s|=Y.Underline),n.decorations.has(`strikethrough`)&&(s|=Y.Strikethrough),{content:n.value,offset:t[1],color:i,bgColor:o,fontStyle:s}}))}function Oz(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let e=t[1];if(e.length===8){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,`0`);return`#${e.slice(0,6)}${t}`}if(e.length===6)return`#${e}80`;if(e.length===4){let t=e[0],n=e[1],r=e[2],i=e[3];return`#${t}${t}${n}${n}${r}${r}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,`0`)}`}if(e.length===3){let t=e[0],n=e[1],r=e[2];return`#${t}${t}${n}${n}${r}${r}80`}}let n=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:e}function kz(e,t,n={}){let r=e.resolveLangAlias(n.lang||`text`),{theme:i=e.getLoadedThemes()[0]}=n;if(!SR(r)&&!wR(i)&&r===`ansi`){let{theme:r}=e.setTheme(i);return Dz(r,t,n)}return GR(e,t,n)}function Az(e,t,n){let r,i,a,o,s,c;if(`themes`in n){let{defaultColor:l=`light`,cssVariablePrefix:u=`--shiki-`,colorsRendering:d=`css-vars`}=n,f=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===l?-1:+(t.color===l));if(f.length===0)throw new J("`themes` option must not be empty");let p=ez(e,t,n,kz);if(c=VR(p),l&&az!==l&&!f.find(e=>e.color===l))throw new J(`\`themes\` option must contain the defaultColor key \`${l}\``);let m=f.map(t=>e.getTheme(t.theme)),h=f.map(e=>e.color);a=p.map(e=>e.map(e=>lz(e,h,u,l,d))),c&&BR(a,c);let g=f.map(e=>vR(e.theme,n));i=jz(f,m,g,u,l,`fg`,d),r=jz(f,m,g,u,l,`bg`,d),o=`shiki-themes ${m.map(e=>e.name).join(` `)}`,s=l?void 0:[i,r].join(`;`)}else if(`theme`in n){let s=vR(n.theme,n);a=kz(e,t,n);let l=e.getTheme(n.theme);r=yR(l.bg,s),i=yR(l.fg,s),o=l.name,c=VR(a)}else throw new J("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:o,rootStyle:s,grammarState:c}}function jz(e,t,n,r,i,a,o){return e.map((s,c)=>{let l=yR(t[c][a],n[c])||`inherit`,u=`${r+s.color}${a===`bg`?`-bg`:``}:${l}`;if(c===0&&i){if(i===az&&e.length>1){let r=e.findIndex(e=>e.color===`light`),i=e.findIndex(e=>e.color===`dark`);if(r===-1||i===-1)throw new J('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${yR(t[r][a],n[r])||`inherit`}, ${yR(t[i][a],n[i])||`inherit`});${u}`}return l}return o===`css-vars`?u:null}).filter(e=>!!e).join(`;`)}function Mz(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>Mz(e,t,n),codeToTokens:(t,n)=>Az(e,t,n)}){let i=t;for(let e of gz(n))i=e.preprocess?.call(r,i,n)||i;let{tokens:a,fg:o,bg:s,themeName:c,rootStyle:l,grammarState:u}=Az(e,i,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?a=Pz(a):d===`never`&&(a=Fz(a)),f&&(a=Iz(a));let p={...r,get source(){return i}};for(let e of gz(n))a=e.tokens?.call(p,a)||a;return Nz(a,{...n,fg:o,bg:s,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},p,u)}function Nz(e,t,n,r=VR(e)){let i=gz(t),a=[],o={type:`root`,children:[]},{structure:s=`classic`,tabindex:c=`0`}=t,l={class:`shiki ${t.themeName||``}`};t.rootStyle!==!1&&(l.style=t.rootStyle==null?`background-color:${t.bg};color:${t.fg}`:t.rootStyle),c!==!1&&c!=null&&(l.tabindex=c.toString());for(let[e,n]of Object.entries(t.meta||{}))e.startsWith(`_`)||(l[e]=n);let u={type:`element`,tagName:`pre`,properties:l,children:[],data:t.data},d={type:`element`,tagName:`code`,properties:{},children:a},f=[],p={...n,structure:s,addClassToHast:nz,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return u},get code(){return d},get lines(){return f}};if(e.forEach((e,t)=>{t&&(s===`inline`?o.children.push({type:`element`,tagName:`br`,properties:{},children:[]}):s===`classic`&&a.push({type:`text`,value:`
|
|
44
|
-
`}));let n={type:`element`,tagName:`span`,properties:{class:`line`},children:[]},r=0;for(let a of e){let e={type:`element`,tagName:`span`,properties:{...a.htmlAttrs},children:[{type:`text`,value:a.content}]},c=
|
|
41
|
+
\f\r "&'<=>\``.split(``)]],single:[[`&'`.split(``),`"&'\``.split(``)],[`\0&'`.split(``),`\0"&'\``.split(``)]],double:[[`"&`.split(``),`"&'\``.split(``)],[`\0"&`.split(``),`\0"&'\``.split(``)]]};function iF(e,t,n,r){let i=r.schema,a=i.space!==`svg`&&r.settings.omitOptionalTags,o=i.space===`svg`?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),s=[],c;i.space===`html`&&e.tagName===`svg`&&(r.schema=KN);let l=aF(r,e.properties),u=r.all(i.space===`html`&&e.tagName===`template`?e.content:e);return r.schema=i,u&&(o=!1),(l||!a||!ZP(e,t,n))&&(s.push(`<`,e.tagName,l?` `+l:``),o&&(i.space===`svg`||r.settings.closeSelfClosing)&&(c=l.charAt(l.length-1),(!r.settings.tightSelfClosing||c===`/`||c&&c!==`"`&&c!==`'`)&&s.push(` `),s.push(`/`)),s.push(`>`)),s.push(u),!o&&(!a||!FP(e,t,n))&&s.push(`</`+e.tagName+`>`),s.join(``)}function aF(e,t){let n=[],r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){let r=oF(e,i,t[i]);r&&n.push(r)}}for(;++r<n.length;){let t=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&t!==`"`&&t!==`'`&&(n[r]+=` `)}return n.join(``)}function oF(e,t,n){let r=HN(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space===`html`?0:1,a=+!e.settings.allowDangerousCharacters,o=e.quote,s;if(r.overloadedBoolean&&(n===r.attribute||n===``)?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!=`string`||n===r.attribute||n===``)&&(n=!!n),n==null||n===!1||typeof n==`number`&&Number.isNaN(n))return``;let c=gP(r.attribute,Object.assign({},e.settings.characterReferences,{subset:rF.name[i][a]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?wP:EP)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?c:(e.settings.preferUnquoted&&(s=gP(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:rF.unquoted[i][a]}))),s!==n&&(e.settings.quoteSmart&&SP(n,o)>SP(n,e.alternative)&&(o=e.alternative),s=o+gP(n,Object.assign({},e.settings.characterReferences,{subset:(o===`'`?rF.single:rF.double)[i][a],attribute:!0}))+o),c+(s&&`=`+s))}var sF=[`<`,`&`];function cF(e,t,n,r){return n&&n.type===`element`&&(n.tagName===`script`||n.tagName===`style`)?e.value:gP(e.value,Object.assign({},r.settings.characterReferences,{subset:sF}))}function lF(e,t,n,r){return r.settings.allowDangerousHtml?e.value:cF(e,t,n,r)}function uF(e,t,n,r){return r.all(e)}var dF=JN(`type`,{invalid:fF,unknown:pF,handlers:{comment:bP,doctype:xP,element:iF,raw:lF,root:uF,text:cF}});function fF(e){throw Error("Expected node, not `"+e+"`")}function pF(e){throw Error("Cannot compile unknown node `"+e.type+"`")}var mF={},hF={},gF=[];function _F(e,t){let n=t||mF,r=n.quote||`"`,i=r===`"`?`'`:`"`;if(r!==`"`&&r!==`'`)throw Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:vF,all:yF,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||gN,characterReferences:n.characterReferences||hF,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space===`svg`?KN:GN,quote:r,alternative:i}.one(Array.isArray(e)?{type:`root`,children:e}:e,void 0,void 0)}function vF(e,t,n){return dF(e,t,n,this)}function yF(e){let t=[],n=e&&e.children||gF,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join(``)}var bF=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;selectedRangeHighlightSide;selectedRangeLineNumberOnly=!1;editorActiveLine=null;editorActiveLineSide;editorLineNumberOnly=!1;proposedSelectedRange;renderedSelectedLinesState;renderedEditorActiveLineState;selectionAnchor;pointerSession={mode:`idle`};constructor(e,t){this.mode=e,this.options=t}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener(`click`,this.handlePointerClick),this.pre?.removeEventListener(`pointerdown`,this.handlePointerDown),this.pre?.removeEventListener(`pointermove`,this.handlePointerMove),this.pre?.removeEventListener(`pointerleave`,this.handlePointerLeave),this.pre?.removeAttribute(`data-interactive-lines`),this.pre?.removeAttribute(`data-interactive-line-numbers`),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),_M(this.renderSelection),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1,this.setSelectionDirty()}setup(e){this.setSelectionDirty();let{usesCustomGutterUtility:t=!1,enableGutterUtility:n=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),n?this.ensureGutterUtilityNode(t):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode===`gutterSelecting`&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectedLinesState=void 0,this.renderedEditorActiveLineState=void 0}isSelectionDirty(){return this.renderedSelectedLinesState===void 0||this.renderedEditorActiveLineState===void 0}setSelection(e,t){let n=!(e===this.selectedRange||CM(e??void 0,this.selectedRange??void 0)),r=t?.lineNumberOnly??!1,i=t?.activeLineSide!==this.selectedRangeHighlightSide||r!==this.selectedRangeLineNumberOnly;!this.isSelectionDirty()&&!n&&!i||(this.proposedSelectedRange=void 0,this.selectedRange=e,this.selectedRangeHighlightSide=t?.activeLineSide,this.selectedRangeLineNumberOnly=r,this.renderSelection(),this.placeUtility(),n&&t?.notify!==!1&&this.notifySelectionCommitted(e))}setEditorActiveLine(e,{lineNumberOnly:t=!1,side:n}={}){let r=e!==this.editorActiveLine,i=n!==this.editorActiveLineSide||t!==this.editorLineNumberOnly;!this.isSelectionDirty()&&!r&&!i||(this.editorActiveLine=e,this.editorActiveLineSide=n,this.editorLineNumberOnly=t,this.renderSelection())}getSelection(){return this.selectedRange}getHoveredLine=()=>{let e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode===`diff`&&e.type===`diff-line`)return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode===`file`&&e.type===`line`)return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{let{onHunkExpand:t,onLineClick:n,onLineNumberClick:r,onTokenClick:i,onMergeConflictActionClick:a}=this.options;(t!=null||n!=null||r!=null||a!=null||i!=null)&&(this.options.onGutterUtilityClick!=null&&hN(e.composedPath())||(zF(this.options.__debugPointerEvents,`click`,`FileDiff.DEBUG.handlePointerClick:`,e),this.handlePointerEvent({eventType:`click`,event:e})))};handlePointerMove=e=>{if(e.pointerType!==`mouse`)return;let{lineHoverHighlight:t=`disabled`,onLineEnter:n,onLineLeave:r,onTokenEnter:i,onTokenLeave:a,enableGutterUtility:o=!1}=this.options;t===`disabled`&&!o&&n==null&&r==null&&i==null&&a==null||(zF(this.options.__debugPointerEvents,`move`,`FileDiff.DEBUG.handlePointerMove:`,e),this.handlePointerEvent({eventType:`move`,event:e}))};handlePointerLeave=e=>{let{__debugPointerEvents:t}=this.options;if(zF(t,`move`,`FileDiff.DEBUG.handlePointerLeave: no event`),this.hoveredLine==null&&this.hoveredToken==null){zF(t,`move`,`FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token`);return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:t}){let{__debugPointerEvents:n}=this.options,r=t.composedPath();zF(n,e,`FileDiff.DEBUG.handlePointerEvent:`,{eventType:e,composedPath:r});let i=this.resolvePointerTarget(r);zF(n,e,`FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:`,i);let{onLineClick:a,onLineNumberClick:o,onLineEnter:s,onLineLeave:c,onTokenClick:l,onTokenEnter:u,onTokenLeave:d,onHunkExpand:f,onMergeConflictActionClick:p}=this.options;switch(e){case`move`:{let e=TF(i)&&this.hoveredLine?.lineElement===i.lineElement;wF(i)&&this.hoveredToken?.tokenElement===i.tokenElement||(this.hoveredToken!=null&&(d?.(this.hoveredToken,t),this.clearHoveredToken()),wF(i)&&(this.setHoveredToken(this.toTokenEventBaseProps(i)),u?.(this.hoveredToken,t))),e||(this.hoveredLine!=null&&(c?.({...this.hoveredLine,event:t}),this.clearHoveredLine()),TF(i)?(this.setHoveredLine(this.toEventBaseProps(i)),this.placeUtility(),s?.({...this.hoveredLine,event:t})):this.placeUtility());break}case`click`:{if(i==null)break;if(DF(i)&&p!=null){p(i);break}if(EF(i)&&f!=null){f(i.hunkIndex,i.all||t.shiftKey?`both`:i.direction,i.all||t.shiftKey?1/0:void 0);break}if(!TF(i))break;wF(i)&&l!=null&&l(this.toTokenEventBaseProps(i),t);let e=this.toEventBaseProps(i);o!=null&&i.numberColumn?o({...e,event:t}):a?.({...e,event:t});break}}}syncPointerListeners(e){let{__debugPointerEvents:t,lineHoverHighlight:n=`disabled`,onLineClick:r,onLineNumberClick:i,onLineEnter:a,onLineLeave:o,onTokenClick:s,onTokenEnter:c,onTokenLeave:l,onHunkExpand:u,onMergeConflictActionClick:d,enableGutterUtility:f=!1,enableLineSelection:p=!1,onGutterUtilityClick:m}=this.options,h=m!=null,g=n!==`disabled`||r!=null||i!=null||a!=null||o!=null||s!=null||c!=null||l!=null||u!=null||d!=null||f||p||h;g&&!this.hasPointerListeners?(e.addEventListener(`click`,this.handlePointerClick),e.addEventListener(`pointerdown`,this.handlePointerDown),e.addEventListener(`pointermove`,this.handlePointerMove),e.addEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!0,zF(t,`click`,`FileDiff.DEBUG.attachEventListeners: Attaching click events for:`,(()=>{let e=[];return(t===`both`||t===`click`)&&(r!=null&&e.push(`onLineClick`),i!=null&&e.push(`onLineNumberClick`),u!=null&&e.push(`expandable hunk separators`),d!=null&&e.push(`merge conflict actions`)),e})()),zF(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer move event`),zF(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event`)):!g&&this.hasPointerListeners&&(e.removeEventListener(`click`,this.handlePointerClick),e.removeEventListener(`pointerdown`,this.handlePointerDown),e.removeEventListener(`pointermove`,this.handlePointerMove),e.removeEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!1);let _=this.pointerSession.mode===`selecting`||this.pointerSession.mode===`pendingSingleLineUnselect`,v=this.pointerSession.mode===`gutterSelecting`;(!p&&_||!h&&v)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;let{onLineClick:e,onLineNumberClick:t,enableLineSelection:n=!1}=this.options,r=e!=null,i=t!=null||n;r&&!this.interactiveLinesAttr?(this.pre.setAttribute(`data-interactive-lines`,``),this.interactiveLinesAttr=!0):!r&&this.interactiveLinesAttr&&(this.pre.removeAttribute(`data-interactive-lines`),this.interactiveLinesAttr=!1),i&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute(`data-interactive-line-numbers`,``),this.interactiveLineNumbersAttr=!0):!i&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute(`data-interactive-line-numbers`),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType===`mouse`&&e.button!==0||this.pre==null||this.pointerSession.mode!==`idle`)return;let t=e.composedPath();hN(t)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!==`mouse`&&this.revealUtilityFromGutterPath(t),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){let{enableLineSelection:t=!1}=this.options;if(!t)return;let n=this.resolveSelectionInfo(e,{source:`event-path`,requireNumberColumn:!0});if(n==null)return;let{pre:r}=this;if(r==null)return;let{lineNumber:i,eventSide:a,lineIndex:o}=n;if(e.shiftKey&&this.selectedRange!=null){let t=this.getIndexesFromSelection(this.selectedRange,r.getAttribute(`data-diff-type`)===`split`);if(t==null)return;let n=t.start<=t.end?o>=t.start:o<=t.end;this.selectionAnchor={lineNumber:n?this.selectedRange.start:this.selectedRange.end,side:n?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===i&&this.selectedRange?.end===i){let t={lineNumber:i,side:a};this.selectionAnchor=t,this.pointerSession={mode:`pendingSingleLineUnselect`,pointerId:e.pointerId,anchor:t,pending:t},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:i,side:a},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){let{onGutterUtilityClick:t}=this.options;if(t==null)return;let n=this.currentSelectionEnds(),r=n?.bottom??this.resolveSelectionPoint(e,{source:`event-path`,excludeUtility:!1}),i=n?.top??r;r!=null&&i!=null&&(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:`gutterSelecting`,pointerId:e.pointerId,anchor:i,current:r},this.selectionAnchor={lineNumber:i.lineNumber,side:i.side},this.updateSelection(r.lineNumber,r.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionPoint(e,{source:`coordinates-first`});if(t==null)return;this.pointerSession.current=t,this.updateSelection(t.lineNumber,t.side);return}case`selecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case`pendingSingleLineUnselect`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;let n={lineNumber:t.lineNumber,side:t.eventSide};if(mN(this.pointerSession.pending,n))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:`selecting`,pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{let{onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{let{pointerSession:n}=this;if(e.pointerId!==n.pointerId)return;e.preventDefault();let r=this.resolveSelectionPoint(e,{source:`coordinates-first`});r!=null&&(n.current=r,this.updateSelection(r.lineNumber,r.side));let i=this.buildSelectedLineRange(n.anchor,n.current);t?.({...i}),this.selectionAnchor=void 0,this.notifySelectionEnd(i),this.notifySelectionCommitted(i),this.clearProposedSelection(),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case`pendingSingleLineUnselect`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection();return;case`selecting`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:case`selecting`:case`pendingSingleLineUnselect`:if(`pointerId`in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute(`data-hovered`),this.hoveredLine.numberElement.removeAttribute(`data-hovered`),this.hoveredLine=void 0)}setHoveredLine(e){let{lineHoverHighlight:t=`disabled`}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,t!==`disabled`&&((t===`both`||t===`line`)&&this.hoveredLine.lineElement.setAttribute(`data-hovered`,``),(t===`both`||t===`number`)&&this.hoveredLine.numberElement.setAttribute(`data-hovered`,``))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer??(this.gutterUtilityContainer=document.createElement(`div`),this.gutterUtilityContainer.setAttribute(`data-gutter-utility-slot`,``)),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot??(this.gutterUtilitySlot=document.createElement(`slot`),this.gutterUtilitySlot.name=`gutter-utility-slot`),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){let e=document.createElement(`div`);e.innerHTML=_F(pN());let t=e.firstElementChild;if(!(t instanceof HTMLButtonElement))throw Error(`InteractionManager.ensureGutterUtilityNode: Node element should be a button`);t.remove(),this.gutterUtilityButton=t}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;let t=this.resolvePointerTarget(e);CF(t)&&t.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(t))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){let e=this.currentSelectionEnds();if(e==null)return!1;let t=this.targetForSelectionPoint(e.bottom);return t==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(t)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){let e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){let t={lineNumber:e.start,side:e.side},n={lineNumber:e.end,side:e.endSide??e.side},r=this.selectionPointRowIndex(t),i=this.selectionPointRowIndex(n);if(r!=null&&i!=null)return r>i?{top:n,bottom:t}:{top:t,bottom:n}}selectionPointRowIndex(e){let t=this.getLineIndex(e.lineNumber,e.side);if(t!=null)return this.isSplitDiff()?t[1]:t[0]}targetForSelectionPoint(e){if(this.pre==null)return;let t=this.getLineIndex(e.lineNumber,e.side);if(t==null)return;let n=this.mode===`diff`?`${t[0]},${t[1]}`:`${t[0]}`,r=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${n}"]`);for(let t of r){if(!(t instanceof HTMLElement))continue;let n=this.resolvePointerTarget(AF(t));if(CF(n)&&(this.mode!==`diff`||e.side==null||n.side===e.side))return n}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||=(document.addEventListener(`pointermove`,this.handleDocumentPointerMove),document.addEventListener(`pointerup`,this.handleDocumentPointerUp),document.addEventListener(`pointercancel`,this.handleDocumentPointerCancel),!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&=(document.removeEventListener(`pointermove`,this.handleDocumentPointerMove),document.removeEventListener(`pointerup`,this.handleDocumentPointerUp),document.removeEventListener(`pointercancel`,this.handleDocumentPointerCancel),!1)}clearPointerSession(){this.pointerSession={mode:`idle`}}clearPendingSingleLineState(){this.pointerSession.mode===`pendingSingleLineUnselect`&&(this.pointerSession={mode:`idle`})}selectionInfoFromPath(e,t){let n=this.resolvePointerTarget(e);if(CF(n)&&!(t&&!n.numberColumn)&&n.splitLineIndex!=null)return{lineIndex:n.splitLineIndex,lineNumber:n.lineNumber,eventSide:this.mode===`diff`?n.side:void 0}}resolveSelectionInfo(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionInfoFromPath(n,t.requireNumberColumn)}selectionPointFromPath(e){let t=this.resolvePointerTarget(e);if(CF(t))return{lineNumber:t.lineNumber,side:this.mode===`diff`?t.side:void 0}}resolveSelectionPoint(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionPointFromPath(n)}resolveSelectionPath(e,t){let n=t.excludeUtility!==!1;switch(t.source){case`event-path`:return this.pathFromEventPath(e.composedPath(),n);case`coordinates-first`:{let t=this.pathFromCoordinates(e,n);return t===void 0?this.pathFromEventPath(e.composedPath(),n):t??void 0}}}pathFromCoordinates(e,t){let n=this.hitTest(e);if(n!==void 0)return n===null?null:this.pathFromElement(n,t)??null}pathFromEventPath(e,t){if(!(t&&hN(e))){for(let n of e)if(n instanceof Element)return this.pathFromElement(n,t)}}pathFromElement(e,t){let n=AF(e);if(t&&hN(n))return;let r=jF(e);return r==null?this.pathFromAnnotationSlot(e):AF(r)}pathFromAnnotationSlot(e){let t=NF(MF(e));if(t==null)return;let n=this.targetForSelectionPoint(t);return n==null?void 0:AF(n.lineElement)}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;let t=this.pre?.getRootNode(),n=PF(t)?t:PF(document)?document:void 0;if(n!=null)return n.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,t){let{getLineIndex:n}=this.options;return n==null?[e-1,e-1]:n(e,t)}getCurrentSelectionRange(){return this.proposedSelectedRange===void 0?this.selectedRange:this.proposedSelectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,t,n=!0){let r=this.getCurrentSelectionRange(),i;if(e==null)i=null;else{let n=this.selectionAnchor?.side??t,r=this.selectionAnchor?.lineNumber??e;i=this.buildSelectionRange(r,e,n,t)}CM(r??void 0,i??void 0)||(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=i:(this.selectedRange=i,gM(this.renderSelection)),this.placeUtility(),n&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,t){if(this.pre==null)return;let n=this.getLineIndex(e.start,e.side),r=this.getLineIndex(e.end,e.endSide??e.side);return n!=null&&r!=null?{start:t?n[1]:n[0],end:t?r[1]:r[0]}:void 0}getSelectionRenderState(){return{selectedLines:{range:this.selectedRange,highlightSide:this.selectedRangeHighlightSide,lineNumberOnly:this.selectedRangeLineNumberOnly},editorActiveLine:{range:this.editorActiveLine==null?null:{start:this.editorActiveLine,end:this.editorActiveLine,side:this.editorActiveLineSide},highlightSide:this.editorActiveLineSide,lineNumberOnly:this.editorLineNumberOnly}}}resolveLineRenderRange(e,t,n){if(e.range==null)return;let r=this.getIndexesFromSelection(e.range,t);if(r==null)throw console.error({rowRange:r,range:e.range}),Error(`InteractionManager.renderSelection: No valid ${n} rowRange`);return r}getLineRenderColumns(e,t,n,r){if(this.pre==null||t==null&&r==null)return[];let{children:i}=this.pre;if(i.length>2)throw console.error(i),Error(`InteractionManager.renderSelection: Somehow there are more than 2 code elements...`);let a=[];for(let o of i){let i=o.hasAttribute(`data-deletions`)?`deletions`:o.hasAttribute(`data-additions`)?`additions`:void 0,s=e!=null&&t!=null&&(e.highlightSide==null||i==null||e.highlightSide===i),c=n!=null&&r!=null&&(n.highlightSide==null||i==null||n.highlightSide===i);if(!s&&!c)continue;let[l,u]=o.children;if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))throw Error(`InteractionManager.renderSelection: missing gutter or content element`);if(u.children.length!==l.children.length)throw Error(`InteractionManager.renderSelection: gutter and content children dont match, something is wrong`);a.push({content:u,gutter:l,renderEditorActiveLine:c,renderSelectedLines:s})}return a}renderSelection=()=>{_M(this.renderSelection);let e=this.getSelectionRenderState();if(this.pre==null)return;let{editorActiveLine:t,selectedLines:n}=e,r=!IF(this.renderedSelectedLinesState,n),i=!IF(this.renderedEditorActiveLineState,t);if(!r&&!i)return;r&&(this.renderedSelectedLinesState=void 0),i&&(this.renderedEditorActiveLineState=void 0);let a=this.pre.getAttribute(`data-diff-type`)===`split`,o=r?this.resolveLineRenderRange(n,a,`selected-lines`):void 0,s=i?this.resolveLineRenderRange(t,a,`editor-active-line`):void 0,c=this.getLineRenderColumns(r?n:void 0,o,i?t:void 0,s),l=n.range==null||c.some(e=>e.renderSelectedLines),u=t.range==null||c.some(e=>e.renderEditorActiveLine);if(r)for(let e of this.pre.querySelectorAll(`[data-selected-line]`))e.removeAttribute(`data-selected-line`);if(i)for(let e of this.pre.querySelectorAll(`[data-editor-active-line]`))e.removeAttribute(`data-editor-active-line`);let d=o==null?void 0:Math.min(o.start,o.end),f=o==null?void 0:Math.max(o.start,o.end),p=d===f,m=s?.start;for(let e of c){let{content:r,gutter:i,renderEditorActiveLine:o,renderSelectedLines:s}=e,c=Math.max(s?f??-1/0:-1/0,o?m??-1/0:-1/0),l=r.children.length;for(let e=0;e<l;e++){let l=r.children[e],u=i.children[e];if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))continue;let h=this.parseLineIndex(l,a);if((h??0)>c)break;if(h!=null){if(s&&d!=null&&f!=null&&h>=d&&h<=f){let e=p?`single`:h===d?`first`:h===f?`last`:``;u.setAttribute(`data-selected-line`,e),n.lineNumberOnly||(l.setAttribute(`data-selected-line`,e),u.nextSibling instanceof HTMLElement&&l.nextSibling instanceof HTMLElement&&(l.nextSibling.hasAttribute(`data-line-annotation`)||l.nextSibling.hasAttribute(`data-merge-conflict-actions`))&&(p?(e=`last`,l.setAttribute(`data-selected-line`,`first`)):h===d?e=``:h===f&&l.setAttribute(`data-selected-line`,``),l.nextSibling.setAttribute(`data-selected-line`,e),u.nextSibling.setAttribute(`data-selected-line`,e)))}o&&h===m&&(u.setAttribute(`data-editor-active-line`,``),t.lineNumberOnly||l.setAttribute(`data-editor-active-line`,``))}}}r&&l&&(this.renderedSelectedLinesState=n),i&&u&&(this.renderedEditorActiveLineState=t)};notifySelectionCommitted(e){this.options.onLineSelected?.(e)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode===`file`?{type:`line`,lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:`diff-line`,annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}){return this.mode===`file`?{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,tokenElement:i,tokenText:a}:{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}}buildSelectedLineRange(e,t){return this.buildSelectionRange(e.lineNumber,t.lineNumber,e.side,t.side)}buildSelectionRange(e,t,n,r){return{start:e,end:t,...n==null?{}:{side:n},...n!==r&&r!=null?{endSide:r}:{}}}resolvePointerTarget(e){let t=!1,n,r,i,a,o,s,c,l,u,d;for(let f of e){if(!(f instanceof HTMLElement))continue;if(d==null&&f.hasAttribute(`data-merge-conflict-action`)){let e=f.getAttribute(`data-merge-conflict-action`)??void 0,t=f.getAttribute(`data-merge-conflict-conflict-index`)??void 0,n=t==null?NaN:Number.parseInt(t,10);OF(e)&&Number.isFinite(n)&&(d={kind:`merge-conflict-action`,resolution:e,conflictIndex:n})}if(s==null&&f.hasAttribute(`data-char`)){s=f;let e=f.getAttribute(`data-char`);if(e!=null){let t=Number.parseInt(e,10);if(!Number.isNaN(t)){let e=f.textContent??``,n=t+e.length;(e.trim()!==``||this.options.enableTokenInteractionsOnWhitespace===!0)&&(c={tokenElement:s,lineCharStart:t,lineCharEnd:n,tokenText:e});continue}}}let e=o==null?f.getAttribute(`data-column-number`)??void 0:void 0;if(e!=null){o=f,u=Number.parseInt(e,10),t=!0,n=RF(f),a=f.getAttribute(`data-line-index`)??void 0;continue}let p=i==null?f.getAttribute(`data-line`)??void 0:void 0;if(p!=null){i=f,u=Number.parseInt(p,10),n=RF(f),a=f.getAttribute(`data-line-index`)??void 0;continue}if(l==null&&(f.hasAttribute(`data-expand-button`)||f.hasAttribute(`data-unmodified-lines`))){l={hunkIndex:void 0,direction:f.hasAttribute(`data-expand-up`)?`up`:f.hasAttribute(`data-expand-down`)?`down`:`both`,all:f.hasAttribute(`data-expand-all-button`)};continue}let m=l==null?void 0:f.getAttribute(`data-expand-index`)??void 0;if(l!=null&&m!=null){let e=Number.parseInt(m,10);Number.isNaN(e)||(l.hunkIndex=e);continue}if(r==null&&f.hasAttribute(`data-code`)){r=f;break}}if(d!=null)return d;if(l?.hunkIndex!=null)return{type:`line-info`,hunkIndex:l.hunkIndex,direction:l.direction,all:l.all};if(i??=a==null?void 0:kF(r,`[data-line][data-line-index="${a}"]`),o??=a==null?void 0:kF(r,`[data-column-number][data-line-index="${a}"]`),r==null||i==null||o==null||n==null||u==null||Number.isNaN(u))return;let f=this.parseLineIndex(i,this.isSplitDiff());return c==null?this.mode===`file`?{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f}:{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:LF(n,r),splitLineIndex:f}:this.mode===`file`?{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f,...c}:{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:LF(n,r),splitLineIndex:f,...c}}isSplitDiff(){return this.pre?.getAttribute(`data-diff-type`)===`split`}parseLineIndex(e,t){let n=(e.getAttribute(`data-line-index`)??``).split(`,`).map(e=>Number.parseInt(e,10)).filter(e=>!Number.isNaN(e));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function xF({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:t,lineHoverHighlight:n,onGutterUtilityClick:r,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,renderGutterUtility:d,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v},y,b,x){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:SF({enableGutterUtility:t,renderGutterUtility:d,onGutterUtilityClick:r}),usesCustomGutterUtility:d!=null,lineHoverHighlight:n,onGutterUtilityClick:r,onHunkExpand:y,onMergeConflictActionClick:x,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v,getLineIndex:b}}function SF({enableGutterUtility:e,renderGutterUtility:t,onGutterUtilityClick:n}){if(n!=null&&t!=null)throw Error(`Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.`);return e??!1}function CF(e){return e!=null&&`kind`in e&&e.kind===`line`}function wF(e){return e!=null&&`kind`in e&&e.kind===`token`}function TF(e){return CF(e)||wF(e)}function EF(e){return`type`in e&&e.type===`line-info`}function DF(e){return`kind`in e&&e.kind===`merge-conflict-action`}function OF(e){return e===`current`||e===`incoming`||e===`both`}function kF(e,t){let n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function AF(e){let t=[],n=e;for(;n!=null;)t.push(n),n=n.parentNode;return t}function jF(e){let t=e.closest(`[data-line], [data-column-number]`);if(t instanceof HTMLElement)return t;let n=e.closest(`[data-line-annotation], [data-gutter-buffer="annotation"]`);if(!(n instanceof HTMLElement))return;let r=n.previousElementSibling;return r instanceof HTMLElement&&(r.hasAttribute(`data-line`)||r.hasAttribute(`data-column-number`))?r:void 0}function MF(e){let t=e.closest(`[slot^="annotation-"]`);if(t instanceof HTMLElement)return t.getAttribute(`slot`)??void 0;if(e instanceof HTMLElement){let t=e.getAttribute(`name`)??void 0;return t!=null&&t.startsWith(`annotation-`)?t:void 0}}function NF(e){if(e==null)return;let t=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(t==null)return;let n=Number.parseInt(t[2],10);if(!(!Number.isFinite(n)||n<=0))return{lineNumber:n,side:t[1]}}function PF(e){return e!=null&&typeof e.elementFromPoint==`function`}function FF(e,t){return e===t||CM(e??void 0,t??void 0)}function IF(e,t){return e?.highlightSide===t.highlightSide&&e?.lineNumberOnly===t.lineNumberOnly&&FF(e?.range??null,t.range)}function LF(e,t){switch(e){case`change-deletion`:return`deletions`;case`change-addition`:return`additions`;default:return t.hasAttribute(`data-deletions`)?`deletions`:`additions`}}function RF(e){let t=e.getAttribute(`data-line-type`);if(t!=null)switch(t){case`change-deletion`:case`change-addition`:case`context`:case`context-expanded`:return t;default:return}}function zF(e=`none`,t,...n){switch(e){case`none`:return;case`both`:break;case`click`:if(t!==`click`)return;break;case`move`:if(t!==`move`)return}console.log(...n)}var BF=class e{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){let t=e.resizeObserver??new ResizeObserver(e.handleSharedResizeEntries);return e.resizeObserver=t,t}static handleSharedResizeEntries(t){let n=new Map;for(let r of t){let t=e.managersByElement.get(r.target);if(t==null)continue;let i=n.get(t);i==null?n.set(t,[r]):i.push(r)}for(let[e,t]of n)e.handleResizeEntries(t)}observedNodes=new Map;setup(e,{disableAnnotations:t,columnVariables:n=`apply`}){let r=new Set,i=n===`apply`,a=0,o=new Map(this.observedNodes);this.observedNodes.clear();for(let t of e.children){if(a===2)break;let e=(()=>{if(t instanceof HTMLElement&&t.tagName===`CODE`)return t})();if(e==null)continue;a++;let n=o.get(e);if(n!=null&&n.type!==`code`)throw Error(`ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible`);let r=e.firstElementChild;r instanceof HTMLElement||(r=null),n==null?(n={type:`code`,codeElement:e,numberElement:r,codeWidth:`auto`,numberWidth:0,applyColumnVariables:i},this.observedNodes.set(e,n),this.observe(e),r!=null&&(this.observedNodes.set(r,n),this.observe(r))):(this.observedNodes.set(e,n),o.delete(e),n.numberElement===r?n.numberElement==null?n.numberWidth=0:(o.delete(n.numberElement),this.observedNodes.set(n.numberElement,n)):(n.numberElement!=null&&(this.unobserve(n.numberElement),o.delete(n.numberElement)),r!=null&&(this.observe(r),o.delete(r),this.observedNodes.set(r,n)),n.numberElement=r,n.numberWidth=0),UF(n,i))}if(a>1&&!t){let t=e.querySelectorAll(`[data-line-annotation*=","]`),n=new Map;for(let e of t){if(!(e instanceof HTMLElement))continue;let t=e.getAttribute(`data-line-annotation`)??``;if(!/^-?\d+,-?\d+$/.test(t)){console.error(`DiffFileRenderer.setupResizeObserver: Invalid element or annotation`,{lineAnnotation:t,element:e});continue}let r=n.get(t);r??(r=[],n.set(t,r)),r.push(e)}for(let[e,t]of n){if(t.length!==2){console.error(`DiffFileRenderer.setupResizeObserver: Bad Pair`,e,t);continue}let[n,i]=t,a=n.firstElementChild,s=i.firstElementChild;if(!(n instanceof HTMLElement)||!(i instanceof HTMLElement)||!(a instanceof HTMLElement)||!(s instanceof HTMLElement))continue;let c=o.get(a);if(c!=null){this.observedNodes.set(a,c),this.observedNodes.set(s,c),o.delete(a),o.delete(s);continue}let l=a.getBoundingClientRect().height,u=s.getBoundingClientRect().height;c={type:`annotations`,column1:{container:n,child:a,childHeight:l},column2:{container:i,child:s,childHeight:u},currentHeight:`auto`},r.add({child1:a,child2:s,item:c,newHeight:Math.max(l,u)})}for(let e of r)this.applyNewHeight(e.item,e.newHeight),this.observedNodes.set(e.child1,e.item),this.observedNodes.set(e.child2,e.item),this.observe(e.child1),this.observe(e.child2);r.clear()}for(let[e,t]of o)this.unobserve(e),t.type===`code`?KF(t):qF(t);o.clear()}cleanUp(){for(let e of this.observedNodes.keys())this.unobserve(e);this.observedNodes.clear()}observe(t){let{managersByElement:n}=e,r=n.get(t);if(r!==this){if(r!=null&&r!==this)throw Error(`ResizeManager.observe: element is already owned by another ResizeManager`);n.set(t,this),e.getResizeObserver().observe(t)}}unobserve(t){let{managersByElement:n,resizeObserver:r}=e,i=n.get(t);if(i!=null){if(i!==this)throw Error(`ResizeManager.unobserve: element is owned by another ResizeManager`);n.delete(t),r?.unobserve(t),r!=null&&n.size===0&&(r.disconnect(),e.resizeObserver=void 0)}}handleResizeEntries(e){let t=new Map,n=new Set;for(let r of e){let{target:e,borderBoxSize:i,contentBoxSize:a}=r;if(!(e instanceof HTMLElement)){console.error(`ResizeManager.handleResizeEntries: Invalid element for ResizeObserver`,r);continue}let o=this.observedNodes.get(e);if(o==null){console.error(`ResizeManager.handleResizeEntries: Not a valid observed node`,r);continue}if(o.type===`annotations`){let t=(()=>{if(e===o.column1.child)return o.column1;if(e===o.column2.child)return o.column2})();if(t==null){console.error(`ResizeManager.handleResizeEntries: Couldn't find a column for`,{item:o,target:e});continue}t.childHeight=i[0].blockSize,n.add(o)}else if(o.type===`code`){let n=t.get(o)??{},r=a[0].inlineSize;e===o.codeElement?n.codeInlineSize=r:e===o.numberElement&&(n.numberInlineSize=r),t.set(o,n)}}this.applyAnnotationUpdates(n),n.clear(),this.applyColumnUpdates(t),t.clear()}applyAnnotationUpdates(e){for(let t of e)this.applyNewHeight(t,Math.max(t.column1.childHeight,t.column2.childHeight))}applyColumnUpdates=e=>{for(let[t,n]of e){let e=n.codeInlineSize==null?t.codeWidth:VF(n.codeInlineSize),r=n.numberInlineSize==null?t.numberWidth:HF(n.numberInlineSize),i=e!==t.codeWidth,a=r!==t.numberWidth;!i&&!a||(t.codeWidth=e,t.numberWidth=r,t.applyColumnVariables&&WF(t,{codeWidthChanged:i,numberWidthChanged:a}))}};applyNewHeight(e,t){t!==e.currentHeight&&(e.currentHeight=Math.max(t,0),e.column1.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`),e.column2.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`))}};function VF(e){let t=Math.max(Math.floor(e),0);return t===0?`auto`:t}function HF(e){return Math.max(Math.ceil(e),0)}function UF(e,t){e.applyColumnVariables!==t&&(e.applyColumnVariables=t,t?WF(e,{codeWidthChanged:!0,numberWidthChanged:!0}):GF(e))}function WF(e,{codeWidthChanged:t,numberWidthChanged:n}){let{codeElement:r,codeWidth:i,numberWidth:a}=e;if(t&&r.style.setProperty(`--diffs-column-width`,`${typeof i==`number`?`${i}px`:`auto`}`),n&&r.style.setProperty(`--diffs-column-number-width`,`${a===0?`auto`:`${a}px`}`),t||n&&i!==`auto`){let e=typeof i==`number`?Math.max(i-a,0):0;r.style.setProperty(`--diffs-column-content-width`,`${e>0?`${e}px`:`auto`}`)}}function GF(e){e.codeElement.style.removeProperty(`--diffs-column-content-width`),e.codeElement.style.removeProperty(`--diffs-column-number-width`),e.codeElement.style.removeProperty(`--diffs-column-width`)}function KF(e){e.codeElement.isConnected&&GF(e)}function qF(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty(`--diffs-annotation-min-height`),e.column2.container.isConnected&&e.column2.container.style.removeProperty(`--diffs-annotation-min-height`)}var JF=new Map,YF=new Map,XF=new Map,ZF=new Set;function QF(e){for(let t of Array.isArray(e)?e:[e])if(t!==`text`&&t!==`ansi`&&!ZF.has(t))return!1;return!0}function $F(e,t){e=Array.isArray(e)?e:[e];for(let n of e){if(ZF.has(n.name))continue;let e=JF.get(n.name);e??(e=n,JF.set(n.name,e)),ZF.add(e.name),t.loadLanguageSync(e.data)}}function eI(){return typeof WorkerGlobalScope<`u`&&typeof self<`u`&&self instanceof WorkerGlobalScope}var tI=Object.defineProperty,nI=Object.getOwnPropertyDescriptor,rI=Object.getOwnPropertyNames,iI=Object.prototype.hasOwnProperty,aI=(e,t)=>{let n={};for(var r in e)tI(n,r,{get:e[r],enumerable:!0});return t||tI(n,Symbol.toStringTag,{value:`Module`}),n},oI=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=rI(t),a=0,o=i.length,s;a<o;a++)s=i[a],!iI.call(e,s)&&s!==n&&tI(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=nI(t,s))||r.enumerable});return e},sI=(e,t,n)=>(oI(e,t,`default`),n&&oI(n,t,`default`)),cI=[{id:`abap`,name:`ABAP`,import:(()=>D(()=>import(`./abap-CLvhMVsD.js`),[]))},{id:`actionscript-3`,name:`ActionScript`,import:(()=>D(()=>import(`./actionscript-3--17pq3dv.js`),[]))},{id:`ada`,name:`Ada`,import:(()=>D(()=>import(`./ada-C5qYipkI.js`),[]))},{id:`angular-html`,name:`Angular HTML`,import:(()=>D(()=>import(`./angular-html-B8mrqUL5.js`).then(e=>e.n),__vite__mapDeps([4,1,5,6,7])))},{id:`angular-ts`,name:`Angular TypeScript`,import:(()=>D(()=>import(`./angular-ts-Bzix210W.js`),__vite__mapDeps([8,4,1,5,6,7,9])))},{id:`apache`,name:`Apache Conf`,import:(()=>D(()=>import(`./apache-U0d_L8uA.js`),[]))},{id:`apex`,name:`Apex`,import:(()=>D(()=>import(`./apex-CGTLDQj6.js`),[]))},{id:`apl`,name:`APL`,import:(()=>D(()=>import(`./apl-Dhin1L29.js`),__vite__mapDeps([10,6,1,7,5,11,12,13])))},{id:`applescript`,name:`AppleScript`,import:(()=>D(()=>import(`./applescript-CCn79oCD.js`),[]))},{id:`ara`,name:`Ara`,import:(()=>D(()=>import(`./ara-4CJ0cIlV.js`),[]))},{id:`asciidoc`,name:`AsciiDoc`,aliases:[`adoc`],import:(()=>D(()=>import(`./asciidoc-DE70LPWp.js`),[]))},{id:`asm`,name:`Assembly`,import:(()=>D(()=>import(`./asm-Cmm7eHzH.js`),[]))},{id:`astro`,name:`Astro`,import:(()=>D(()=>import(`./astro-B-4NNgOP.js`),__vite__mapDeps([14,6,1,7,13,15,16,17])))},{id:`awk`,name:`AWK`,import:(()=>D(()=>import(`./awk-BWXHIvNe.js`),[]))},{id:`ballerina`,name:`Ballerina`,import:(()=>D(()=>import(`./ballerina-B7ZEbQpA.js`),[]))},{id:`bat`,name:`Batch File`,aliases:[`batch`],import:(()=>D(()=>import(`./bat-Bo4NYOV-.js`),[]))},{id:`beancount`,name:`Beancount`,import:(()=>D(()=>import(`./beancount-D-usSTwE.js`),[]))},{id:`berry`,name:`Berry`,aliases:[`be`],import:(()=>D(()=>import(`./berry-DKpUyyne.js`),[]))},{id:`bibtex`,name:`BibTeX`,import:(()=>D(()=>import(`./bibtex-Ci_nEsc7.js`),[]))},{id:`bicep`,name:`Bicep`,import:(()=>D(()=>import(`./bicep-CUHmPFLl.js`),[]))},{id:`bird2`,name:`BIRD2 Configuration`,aliases:[`bird`],import:(()=>D(()=>import(`./bird2-C6vDhewU.js`),[]))},{id:`blade`,name:`Blade`,import:(()=>D(()=>import(`./blade-Wr94ul2N.js`),__vite__mapDeps([18,6,1,7,5,11,12,13,19,20])))},{id:`bsl`,name:`1C (Enterprise)`,aliases:[`1c`],import:(()=>D(()=>import(`./bsl-BkkzgIyY.js`),__vite__mapDeps([21,22])))},{id:`c`,name:`C`,import:(()=>D(()=>import(`./c-iCihek07.js`).then(e=>e.n),__vite__mapDeps([23,1])))},{id:`c3`,name:`C3`,import:(()=>D(()=>import(`./c3-CnJL0r0V.js`),[]))},{id:`cadence`,name:`Cadence`,aliases:[`cdc`],import:(()=>D(()=>import(`./cadence-CQ2zXKGN.js`),[]))},{id:`cairo`,name:`Cairo`,import:(()=>D(()=>import(`./cairo-DLTphjLi.js`),__vite__mapDeps([24,25])))},{id:`clarity`,name:`Clarity`,import:(()=>D(()=>import(`./clarity-SemFz856.js`),[]))},{id:`clojure`,name:`Clojure`,aliases:[`clj`],import:(()=>D(()=>import(`./clojure-DqKBuwfJ.js`),[]))},{id:`cmake`,name:`CMake`,import:(()=>D(()=>import(`./cmake-Bj61d0ZC.js`),[]))},{id:`cobol`,name:`COBOL`,import:(()=>D(()=>import(`./cobol-Cw2-KvLW.js`),__vite__mapDeps([26,5,1,6,7,12])))},{id:`codeowners`,name:`CODEOWNERS`,import:(()=>D(()=>import(`./codeowners-C8r90Shi.js`),[]))},{id:`codeql`,name:`CodeQL`,aliases:[`ql`],import:(()=>D(()=>import(`./codeql-oeQT6MSM.js`),[]))},{id:`coffee`,name:`CoffeeScript`,aliases:[`coffeescript`],import:(()=>D(()=>import(`./coffee-CiiSLhB6.js`),__vite__mapDeps([27,6,1])))},{id:`common-lisp`,name:`Common Lisp`,aliases:[`lisp`],import:(()=>D(()=>import(`./common-lisp-Cv5bFMCO.js`),[]))},{id:`coq`,name:`Coq`,import:(()=>D(()=>import(`./coq-BrsZFFmf.js`),[]))},{id:`cpp`,name:`C++`,aliases:[`c++`],import:(()=>D(()=>import(`./cpp-DjoE5qBx.js`).then(e=>e.n),__vite__mapDeps([28,1,20,29,30,23])))},{id:`crystal`,name:`Crystal`,import:(()=>D(()=>import(`./crystal-wCJpIkgB.js`),__vite__mapDeps([31,6,1,7,5,20,23,32])))},{id:`csharp`,name:`C#`,aliases:[`c#`,`cs`],import:(()=>D(()=>import(`./csharp-Ct8U2NOr.js`),[]))},{id:`css`,name:`CSS`,import:(()=>D(()=>import(`./css-CNuuLpMC.js`).then(e=>e.n),__vite__mapDeps([7,1])))},{id:`csv`,name:`CSV`,import:(()=>D(()=>import(`./csv-Dx-8-gkx.js`),[]))},{id:`cue`,name:`CUE`,import:(()=>D(()=>import(`./cue-CE9AQfxI.js`),[]))},{id:`cypher`,name:`Cypher`,aliases:[`cql`],import:(()=>D(()=>import(`./cypher-ClKdZ_lG.js`),[]))},{id:`d`,name:`D`,import:(()=>D(()=>import(`./d-qD-0Kul2.js`),[]))},{id:`dart`,name:`Dart`,import:(()=>D(()=>import(`./dart-CnvKMtbv.js`),[]))},{id:`dax`,name:`DAX`,import:(()=>D(()=>import(`./dax-BkyTk9wS.js`),[]))},{id:`desktop`,name:`Desktop`,import:(()=>D(()=>import(`./desktop-Dlh5hvp9.js`),[]))},{id:`diff`,name:`Diff`,import:(()=>D(()=>import(`./diff-woXpYk--.js`),[]))},{id:`docker`,name:`Dockerfile`,aliases:[`dockerfile`],import:(()=>D(()=>import(`./docker-IyjqRm3v.js`),[]))},{id:`dotenv`,name:`dotEnv`,import:(()=>D(()=>import(`./dotenv-_5a1GRtc.js`),[]))},{id:`dream-maker`,name:`Dream Maker`,import:(()=>D(()=>import(`./dream-maker-DW3nJb8Q.js`),[]))},{id:`edge`,name:`Edge`,import:(()=>D(()=>import(`./edge-DCY0a-ow.js`),__vite__mapDeps([33,5,1,6,7,15,19])))},{id:`elixir`,name:`Elixir`,import:(()=>D(()=>import(`./elixir-DP304Xio.js`),__vite__mapDeps([34,5,1,6,7])))},{id:`elm`,name:`Elm`,import:(()=>D(()=>import(`./elm-o4NJxfws.js`),__vite__mapDeps([35,30,1,23])))},{id:`emacs-lisp`,name:`Emacs Lisp`,aliases:[`elisp`],import:(()=>D(()=>import(`./emacs-lisp-B4R74twV.js`),[]))},{id:`erb`,name:`ERB`,import:(()=>D(()=>import(`./erb-BcNYoZVd.js`),__vite__mapDeps([36,5,1,6,7,37,11,12,20,23,28,29,30,32,38,39,15,17,40,41,42])))},{id:`erlang`,name:`Erlang`,aliases:[`erl`],import:(()=>D(()=>import(`./erlang-Cphh6RMH.js`),__vite__mapDeps([43,44])))},{id:`fennel`,name:`Fennel`,import:(()=>D(()=>import(`./fennel-DQxkIbk2.js`),[]))},{id:`fish`,name:`Fish`,import:(()=>D(()=>import(`./fish-BJitypiv.js`),[]))},{id:`fluent`,name:`Fluent`,aliases:[`ftl`],import:(()=>D(()=>import(`./fluent-C03EYrpw.js`),[]))},{id:`fortran-fixed-form`,name:`Fortran (Fixed Form)`,aliases:[`f`,`for`,`f77`],import:(()=>D(()=>import(`./fortran-fixed-form-DEKoE2YW.js`),__vite__mapDeps([45,46])))},{id:`fortran-free-form`,name:`Fortran (Free Form)`,aliases:[`f90`,`f95`,`f03`,`f08`,`f18`],import:(()=>D(()=>import(`./fortran-free-form-CYNrtFtB.js`),[]))},{id:`fsharp`,name:`F#`,aliases:[`f#`,`fs`],import:(()=>D(()=>import(`./fsharp-D13ZGOAj.js`),__vite__mapDeps([47,44])))},{id:`gdresource`,name:`GDResource`,aliases:[`tscn`,`tres`],import:(()=>D(()=>import(`./gdresource-C0sCabJj.js`),__vite__mapDeps([48,49,50])))},{id:`gdscript`,name:`GDScript`,aliases:[`gd`],import:(()=>D(()=>import(`./gdscript-Cp2uCuqX.js`),[]))},{id:`gdshader`,name:`GDShader`,import:(()=>D(()=>import(`./gdshader-CBce3t8t.js`),[]))},{id:`genie`,name:`Genie`,import:(()=>D(()=>import(`./genie-CV2tkWYe.js`),[]))},{id:`gherkin`,name:`Gherkin`,import:(()=>D(()=>import(`./gherkin-DExj1W_8.js`),[]))},{id:`git-commit`,name:`Git Commit Message`,import:(()=>D(()=>import(`./git-commit-BSykSTBG.js`),__vite__mapDeps([51,52])))},{id:`git-rebase`,name:`Git Rebase Message`,import:(()=>D(()=>import(`./git-rebase-BDPpS8w6.js`),__vite__mapDeps([53,32,1])))},{id:`gleam`,name:`Gleam`,import:(()=>D(()=>import(`./gleam-CSRkHgEL.js`),[]))},{id:`glimmer-js`,name:`Glimmer JS`,aliases:[`gjs`],import:(()=>D(()=>import(`./glimmer-js-BONyzAsu.js`),__vite__mapDeps([54,6,1,7,5,15])))},{id:`glimmer-ts`,name:`Glimmer TS`,aliases:[`gts`],import:(()=>D(()=>import(`./glimmer-ts-f9c0GCOe.js`),__vite__mapDeps([55,6,1,7,5,15])))},{id:`glsl`,name:`GLSL`,import:(()=>D(()=>import(`./glsl-D5MA2a_X.js`).then(e=>e.n),__vite__mapDeps([30,1,23])))},{id:`gn`,name:`GN`,import:(()=>D(()=>import(`./gn-ilITqXS6.js`),[]))},{id:`gnuplot`,name:`Gnuplot`,import:(()=>D(()=>import(`./gnuplot-7GGW24-e.js`),[]))},{id:`go`,name:`Go`,import:(()=>D(()=>import(`./go-rLFTqkRN.js`),[]))},{id:`graphql`,name:`GraphQL`,aliases:[`gql`],import:(()=>D(()=>import(`./graphql-Ctjuxyvl.js`).then(e=>e.n),__vite__mapDeps([39,1,6,15,17,40])))},{id:`groovy`,name:`Groovy`,import:(()=>D(()=>import(`./groovy-CacY0gHj.js`),[]))},{id:`hack`,name:`Hack`,import:(()=>D(()=>import(`./hack-7ztQ7Up-.js`),__vite__mapDeps([56,5,1,6,7,20])))},{id:`haml`,name:`Ruby Haml`,import:(()=>D(()=>import(`./haml-CwEpbK1d.js`).then(e=>e.n),__vite__mapDeps([38,1,6,7])))},{id:`handlebars`,name:`Handlebars`,aliases:[`hbs`],import:(()=>D(()=>import(`./handlebars-ryMP1rBR.js`),__vite__mapDeps([57,6,1,7,5,42])))},{id:`haskell`,name:`Haskell`,aliases:[`hs`],import:(()=>D(()=>import(`./haskell-D8IpX4py.js`),[]))},{id:`haxe`,name:`Haxe`,import:(()=>D(()=>import(`./haxe-OTjmBuCE.js`),[]))},{id:`hcl`,name:`HashiCorp HCL`,import:(()=>D(()=>import(`./hcl-Dh228itO.js`),[]))},{id:`hjson`,name:`Hjson`,import:(()=>D(()=>import(`./hjson-CxZEssPk.js`),[]))},{id:`hlsl`,name:`HLSL`,import:(()=>D(()=>import(`./hlsl-Cvrh5tZx.js`),[]))},{id:`html`,name:`HTML`,import:(()=>D(()=>import(`./html-XwrE-1r6.js`).then(e=>e.n),__vite__mapDeps([5,1,6,7])))},{id:`html-derivative`,name:`HTML (Derivative)`,import:(()=>D(()=>import(`./html-derivative-i4STDFnl.js`),__vite__mapDeps([19,5,1,6,7])))},{id:`http`,name:`HTTP`,import:(()=>D(()=>import(`./http-kmH8AyfE.js`),__vite__mapDeps([58,11,1,12,13,32,39,6,15,17,40])))},{id:`hurl`,name:`Hurl`,import:(()=>D(()=>import(`./hurl-DCZHXKU4.js`),__vite__mapDeps([59,11,1,12,60,39,6,15,17,40])))},{id:`hxml`,name:`HXML`,import:(()=>D(()=>import(`./hxml-B0Qn7Nwc.js`),__vite__mapDeps([61,62])))},{id:`hy`,name:`Hy`,import:(()=>D(()=>import(`./hy-CZbG8q4J.js`),[]))},{id:`imba`,name:`Imba`,import:(()=>D(()=>import(`./imba-DsUTQ-LC.js`),[]))},{id:`ini`,name:`INI`,aliases:[`properties`],import:(()=>D(()=>import(`./ini-B5eOa1yu.js`),[]))},{id:`java`,name:`Java`,import:(()=>D(()=>import(`./java-DdHNQ9hk.js`).then(e=>e.n),__vite__mapDeps([12,1])))},{id:`javascript`,name:`JavaScript`,aliases:[`js`,`cjs`,`mjs`],import:(()=>D(()=>import(`./javascript-obGGvMPs.js`).then(e=>e.n),__vite__mapDeps([6,1])))},{id:`jinja`,name:`Jinja`,import:(()=>D(()=>import(`./jinja-B-tLrNsM.js`),__vite__mapDeps([63,5,1,6,7])))},{id:`jison`,name:`Jison`,import:(()=>D(()=>import(`./jison-CBjhYtSs.js`),__vite__mapDeps([64,6,1])))},{id:`json`,name:`JSON`,import:(()=>D(()=>import(`./json-DAgxKhMr.js`).then(e=>e.n),__vite__mapDeps([13,1])))},{id:`json5`,name:`JSON5`,import:(()=>D(()=>import(`./json5-BR5RXkoi.js`),[]))},{id:`jsonc`,name:`JSON with Comments`,import:(()=>D(()=>import(`./jsonc-CYpm1nAK.js`),[]))},{id:`jsonl`,name:`JSON Lines`,import:(()=>D(()=>import(`./jsonl-CmCQp5Yx.js`),[]))},{id:`jsonnet`,name:`Jsonnet`,import:(()=>D(()=>import(`./jsonnet-CJTPZ8u_.js`),[]))},{id:`jssm`,name:`JSSM`,aliases:[`fsl`],import:(()=>D(()=>import(`./jssm-DXw9l8Rf.js`),[]))},{id:`jsx`,name:`JSX`,import:(()=>D(()=>import(`./jsx-gTgmArGx.js`).then(e=>e.n),__vite__mapDeps([40,1])))},{id:`julia`,name:`Julia`,aliases:[`jl`],import:(()=>D(()=>import(`./julia-CjHxn3vf.js`),__vite__mapDeps([65,6,1,20,25,28,29,30,23,66])))},{id:`just`,name:`Just`,import:(()=>D(()=>import(`./just-CZ9bduw9.js`),__vite__mapDeps([67,6,1,15,25,32,37,7,5,11,12,20,23,28,29,30,38,39,17,40,41,42,68])))},{id:`kdl`,name:`KDL`,import:(()=>D(()=>import(`./kdl-CsD5j6eV.js`),[]))},{id:`kotlin`,name:`Kotlin`,aliases:[`kt`,`kts`],import:(()=>D(()=>import(`./kotlin-DhhofPvG.js`),[]))},{id:`kusto`,name:`Kusto`,aliases:[`kql`],import:(()=>D(()=>import(`./kusto-C7mF5XQf.js`),[]))},{id:`latex`,name:`LaTeX`,import:(()=>D(()=>import(`./latex-D9bvcAJr.js`),__vite__mapDeps([69,70,66,1])))},{id:`lean`,name:`Lean 4`,aliases:[`lean4`],import:(()=>D(()=>import(`./lean-CewbzKMR.js`),[]))},{id:`less`,name:`Less`,import:(()=>D(()=>import(`./less-DVTAwKKz.js`),[]))},{id:`liquid`,name:`Liquid`,import:(()=>D(()=>import(`./liquid-G0MH4h_m.js`),__vite__mapDeps([71,6,1,7,5,13])))},{id:`llvm`,name:`LLVM IR`,import:(()=>D(()=>import(`./llvm-Cm23YOpf.js`),[]))},{id:`log`,name:`Log file`,import:(()=>D(()=>import(`./log-BNLmms1o.js`),[]))},{id:`logo`,name:`Logo`,import:(()=>D(()=>import(`./logo-Cluzi2Zq.js`),[]))},{id:`lua`,name:`Lua`,import:(()=>D(()=>import(`./lua-FONpmTUP.js`).then(e=>e.n),__vite__mapDeps([41,1,23])))},{id:`luau`,name:`Luau`,import:(()=>D(()=>import(`./luau-CNKltnaQ.js`),[]))},{id:`make`,name:`Makefile`,aliases:[`makefile`],import:(()=>D(()=>import(`./make-Dixweg8N.js`),[]))},{id:`markdown`,name:`Markdown`,aliases:[`md`],import:(()=>D(()=>import(`./markdown-BYOwaDjH.js`),[]))},{id:`marko`,name:`Marko`,import:(()=>D(()=>import(`./marko-DV5GrDmo.js`),__vite__mapDeps([72,7,1,9,15,73])))},{id:`matlab`,name:`MATLAB`,import:(()=>D(()=>import(`./matlab-D7qyCx1q.js`),[]))},{id:`mdc`,name:`MDC`,import:(()=>D(()=>import(`./mdc-cg1lnqpW.js`),__vite__mapDeps([74,19,5,1,6,7,42,44])))},{id:`mdx`,name:`MDX`,import:(()=>D(()=>import(`./mdx-DQZ5AkYe.js`),[]))},{id:`mermaid`,name:`Mermaid`,aliases:[`mmd`],import:(()=>D(()=>import(`./mermaid-Bk4SNUv9.js`),[]))},{id:`mipsasm`,name:`MIPS Assembly`,aliases:[`mips`],import:(()=>D(()=>import(`./mipsasm-BMqwQI7S.js`),[]))},{id:`mojo`,name:`Mojo`,import:(()=>D(()=>import(`./mojo-BgCJLMeH.js`),[]))},{id:`moonbit`,name:`MoonBit`,aliases:[`mbt`,`mbti`],import:(()=>D(()=>import(`./moonbit-CaWjb8XO.js`),[]))},{id:`move`,name:`Move`,import:(()=>D(()=>import(`./move-B1IS1UjX.js`),[]))},{id:`narrat`,name:`Narrat Language`,aliases:[`nar`],import:(()=>D(()=>import(`./narrat-_X_XdTYD.js`),[]))},{id:`nextflow`,name:`Nextflow`,aliases:[`nf`],import:(()=>D(()=>import(`./nextflow-BJtWHP5T.js`),__vite__mapDeps([75,76])))},{id:`nextflow-groovy`,name:`Nextflow Groovy`,import:(()=>D(()=>import(`./nextflow-groovy-DJMQeKeT.js`),[]))},{id:`nginx`,name:`Nginx`,import:(()=>D(()=>import(`./nginx-BTMw9COX.js`),__vite__mapDeps([77,41,1,23])))},{id:`nim`,name:`Nim`,import:(()=>D(()=>import(`./nim-B6yJ_yaC.js`),__vite__mapDeps([78,6,1,7,5,11,12,23,30,44])))},{id:`nix`,name:`Nix`,import:(()=>D(()=>import(`./nix-IvuFDN5E.js`),[]))},{id:`nushell`,name:`nushell`,aliases:[`nu`],import:(()=>D(()=>import(`./nushell-DcLAeLz5.js`),[]))},{id:`objective-c`,name:`Objective-C`,aliases:[`objc`],import:(()=>D(()=>import(`./objective-c-D1A_Heim.js`),[]))},{id:`objective-cpp`,name:`Objective-C++`,import:(()=>D(()=>import(`./objective-cpp-BsSzOQcm.js`),[]))},{id:`ocaml`,name:`OCaml`,import:(()=>D(()=>import(`./ocaml-O90oeIOV.js`),[]))},{id:`odin`,name:`Odin`,import:(()=>D(()=>import(`./odin-B1RWQWA5.js`),[]))},{id:`openscad`,name:`OpenSCAD`,aliases:[`scad`],import:(()=>D(()=>import(`./openscad-BUDT5pXO.js`),[]))},{id:`pascal`,name:`Pascal`,import:(()=>D(()=>import(`./pascal-4ZHwLPI5.js`),[]))},{id:`perl`,name:`Perl`,import:(()=>D(()=>import(`./perl-BAov3eih.js`),__vite__mapDeps([68,6,1,7,5,11,12,20])))},{id:`php`,name:`PHP`,import:(()=>D(()=>import(`./php-Cg76ANFt.js`),__vite__mapDeps([79,6,1,7,5,11,12,13,20])))},{id:`pkl`,name:`Pkl`,import:(()=>D(()=>import(`./pkl-ot-7Btpt.js`),[]))},{id:`plsql`,name:`PL/SQL`,import:(()=>D(()=>import(`./plsql-DGHpHOYJ.js`),[]))},{id:`po`,name:`Gettext PO`,aliases:[`pot`,`potx`],import:(()=>D(()=>import(`./po-BiJDBrnU.js`),[]))},{id:`polar`,name:`Polar`,import:(()=>D(()=>import(`./polar-C7UOKdEL.js`),[]))},{id:`postcss`,name:`PostCSS`,import:(()=>D(()=>import(`./postcss-BXeXVLqQ.js`),[]))},{id:`powerquery`,name:`PowerQuery`,import:(()=>D(()=>import(`./powerquery-DNMTfnFr.js`),[]))},{id:`powershell`,name:`PowerShell`,aliases:[`ps`,`ps1`],import:(()=>D(()=>import(`./powershell-DshXNtvi.js`),[]))},{id:`prisma`,name:`Prisma`,import:(()=>D(()=>import(`./prisma-BsRQq5mF.js`),[]))},{id:`prolog`,name:`Prolog`,import:(()=>D(()=>import(`./prolog-iXnhIJG7.js`),[]))},{id:`proto`,name:`Protocol Buffer 3`,aliases:[`protobuf`],import:(()=>D(()=>import(`./proto-DB4EqR-F.js`),[]))},{id:`pug`,name:`Pug`,aliases:[`jade`],import:(()=>D(()=>import(`./pug-DkgDHZci.js`),__vite__mapDeps([80,6,1,7,5])))},{id:`puppet`,name:`Puppet`,import:(()=>D(()=>import(`./puppet-CDv2pdJW.js`),[]))},{id:`purescript`,name:`PureScript`,import:(()=>D(()=>import(`./purescript-9MfHhQsQ.js`),[]))},{id:`python`,name:`Python`,aliases:[`py`],import:(()=>D(()=>import(`./python-gzcpVVnB.js`),[]))},{id:`qml`,name:`QML`,import:(()=>D(()=>import(`./qml-_a-QhfPD.js`),__vite__mapDeps([81,6,1])))},{id:`qmldir`,name:`QML Directory`,import:(()=>D(()=>import(`./qmldir-DCQb3MpD.js`),[]))},{id:`qss`,name:`Qt Style Sheets`,import:(()=>D(()=>import(`./qss-Fe1Jh2GI.js`),[]))},{id:`r`,name:`R`,import:(()=>D(()=>import(`./r-D6UWEOL2.js`).then(e=>e.n),__vite__mapDeps([66,1])))},{id:`racket`,name:`Racket`,import:(()=>D(()=>import(`./racket-DcIDlBhZ.js`),[]))},{id:`raku`,name:`Raku`,aliases:[`perl6`],import:(()=>D(()=>import(`./raku-B3gFvitq.js`),[]))},{id:`razor`,name:`ASP.NET Razor`,import:(()=>D(()=>import(`./razor-D3EoCAik.js`),__vite__mapDeps([82,5,1,6,7,83])))},{id:`reg`,name:`Windows Registry Script`,import:(()=>D(()=>import(`./reg-CRGYupPL.js`),[]))},{id:`regexp`,name:`RegExp`,aliases:[`regex`],import:(()=>D(()=>import(`./regexp-DR20uMnK.js`).then(e=>e.n),__vite__mapDeps([29,1])))},{id:`rel`,name:`Rel`,import:(()=>D(()=>import(`./rel-BtDbiS_P.js`),[]))},{id:`riscv`,name:`RISC-V`,import:(()=>D(()=>import(`./riscv-Ckw8ddFX.js`),[]))},{id:`ron`,name:`RON`,import:(()=>D(()=>import(`./ron-VUp2lXgN.js`),[]))},{id:`rosmsg`,name:`ROS Interface`,import:(()=>D(()=>import(`./rosmsg-CAekHB0j.js`),[]))},{id:`rst`,name:`reStructuredText`,import:(()=>D(()=>import(`./rst-YTmaoyaq.js`),__vite__mapDeps([84,6,1,19,5,7,25,85,28,20,29,30,23,32,42,37,11,12,38,39,15,17,40,41])))},{id:`ruby`,name:`Ruby`,aliases:[`rb`],import:(()=>D(()=>import(`./ruby-2bd251b9.js`),__vite__mapDeps([37,6,1,7,5,11,12,20,23,28,29,30,32,38,39,15,17,40,41,42])))},{id:`rust`,name:`Rust`,aliases:[`rs`],import:(()=>D(()=>import(`./rust-Cfkwpbl8.js`),[]))},{id:`sas`,name:`SAS`,import:(()=>D(()=>import(`./sas-B6p8-ynO.js`),__vite__mapDeps([86,20,1])))},{id:`sass`,name:`Sass`,import:(()=>D(()=>import(`./sass-DXrisJhu.js`),[]))},{id:`scala`,name:`Scala`,import:(()=>D(()=>import(`./scala-DKOlJaKm.js`),[]))},{id:`scheme`,name:`Scheme`,import:(()=>D(()=>import(`./scheme-DQCgrYNe.js`),[]))},{id:`scss`,name:`SCSS`,import:(()=>D(()=>import(`./scss-YesllqfO.js`).then(e=>e.n),__vite__mapDeps([9,1,7])))},{id:`sdbl`,name:`1C (Query)`,aliases:[`1c-query`],import:(()=>D(()=>import(`./sdbl-bTVj8UrX.js`),[]))},{id:`shaderlab`,name:`ShaderLab`,aliases:[`shader`],import:(()=>D(()=>import(`./shaderlab-TOUzSsQk.js`),__vite__mapDeps([87,88])))},{id:`shellscript`,name:`Shell`,aliases:[`bash`,`sh`,`shell`,`zsh`],import:(()=>D(()=>import(`./shellscript-Da78Ox-3.js`).then(e=>e.n),__vite__mapDeps([32,1])))},{id:`shellsession`,name:`Shell Session`,aliases:[`console`],import:(()=>D(()=>import(`./shellsession-CVsQGYfZ.js`),__vite__mapDeps([89,32,1])))},{id:`smalltalk`,name:`Smalltalk`,import:(()=>D(()=>import(`./smalltalk-B16xEiuN.js`),[]))},{id:`solidity`,name:`Solidity`,import:(()=>D(()=>import(`./solidity-CKzVLygQ.js`),[]))},{id:`soy`,name:`Closure Templates`,aliases:[`closure-templates`],import:(()=>D(()=>import(`./soy-DEd-qcad.js`),__vite__mapDeps([90,5,1,6,7])))},{id:`sparql`,name:`SPARQL`,import:(()=>D(()=>import(`./sparql-D_iOobhT.js`),__vite__mapDeps([91,92])))},{id:`splunk`,name:`Splunk Query Language`,aliases:[`spl`],import:(()=>D(()=>import(`./splunk-BC2Px7Mm.js`),[]))},{id:`sql`,name:`SQL`,import:(()=>D(()=>import(`./sql-ClgswhA6.js`).then(e=>e.n),__vite__mapDeps([20,1])))},{id:`ssh-config`,name:`SSH Config`,import:(()=>D(()=>import(`./ssh-config-BgfXC-Er.js`),[]))},{id:`stata`,name:`Stata`,import:(()=>D(()=>import(`./stata-RoaAgbqU.js`),__vite__mapDeps([93,20,1])))},{id:`stylus`,name:`Stylus`,aliases:[`styl`],import:(()=>D(()=>import(`./stylus-B6D30XZt.js`),[]))},{id:`surrealql`,name:`SurrealQL`,aliases:[`surql`],import:(()=>D(()=>import(`./surrealql-DIn4NJsS.js`),__vite__mapDeps([94,6,1])))},{id:`svelte`,name:`Svelte`,import:(()=>D(()=>import(`./svelte-Bj3Hmc9F.js`),__vite__mapDeps([95,6,1,7,15,16])))},{id:`swift`,name:`Swift`,import:(()=>D(()=>import(`./swift-DonLKvLd.js`),[]))},{id:`system-verilog`,name:`SystemVerilog`,import:(()=>D(()=>import(`./system-verilog-DJ5XKQeo.js`),[]))},{id:`systemd`,name:`Systemd Units`,import:(()=>D(()=>import(`./systemd-BxMlprV5.js`),[]))},{id:`talonscript`,name:`TalonScript`,aliases:[`talon`],import:(()=>D(()=>import(`./talonscript-CohzipZa.js`),[]))},{id:`tasl`,name:`Tasl`,import:(()=>D(()=>import(`./tasl-DMoTqEGO.js`),[]))},{id:`tcl`,name:`Tcl`,import:(()=>D(()=>import(`./tcl-CZd0xW_V.js`),[]))},{id:`templ`,name:`Templ`,import:(()=>D(()=>import(`./templ-TjxbArHn.js`),__vite__mapDeps([96,6,1,7,97])))},{id:`terraform`,name:`Terraform`,aliases:[`tf`,`tfvars`],import:(()=>D(()=>import(`./terraform-DswuEJGm.js`),[]))},{id:`tex`,name:`TeX`,import:(()=>D(()=>import(`./tex-0w6-Dtgt.js`),__vite__mapDeps([70,66,1])))},{id:`toml`,name:`TOML`,import:(()=>D(()=>import(`./toml-CcmNWLt0.js`),[]))},{id:`ts-tags`,name:`TypeScript with Tags`,aliases:[`lit`],import:(()=>D(()=>import(`./ts-tags-DFwAVxhO.js`),__vite__mapDeps([98,6,1,7,5,11,12,15,20,30,23])))},{id:`tsv`,name:`TSV`,import:(()=>D(()=>import(`./tsv-sltzmVWM.js`),[]))},{id:`tsx`,name:`TSX`,import:(()=>D(()=>import(`./tsx-CUOciP0b.js`).then(e=>e.n),__vite__mapDeps([17,1])))},{id:`turtle`,name:`Turtle`,import:(()=>D(()=>import(`./turtle-ByJddavk.js`),[]))},{id:`twig`,name:`Twig`,import:(()=>D(()=>import(`./twig-BbcH-NR0.js`),__vite__mapDeps([99,6,1,7,9,25,37,5,11,12,20,23,28,29,30,32,38,39,15,17,40,41,42,79,13])))},{id:`typescript`,name:`TypeScript`,aliases:[`ts`,`cts`,`mts`],import:(()=>D(()=>import(`./typescript-BydbNFcO.js`).then(e=>e.n),__vite__mapDeps([15,1])))},{id:`typespec`,name:`TypeSpec`,aliases:[`tsp`],import:(()=>D(()=>import(`./typespec-BRdr0IET.js`),[]))},{id:`typst`,name:`Typst`,aliases:[`typ`],import:(()=>D(()=>import(`./typst-DI99ib-x.js`),[]))},{id:`v`,name:`V`,import:(()=>D(()=>import(`./v-DETTlOr0.js`),[]))},{id:`vala`,name:`Vala`,import:(()=>D(()=>import(`./vala-zf12oZj6.js`),[]))},{id:`vb`,name:`Visual Basic`,aliases:[`cmd`],import:(()=>D(()=>import(`./vb-Djn5o6TS.js`),[]))},{id:`verilog`,name:`Verilog`,import:(()=>D(()=>import(`./verilog-CiiDBU1e.js`),[]))},{id:`vhdl`,name:`VHDL`,import:(()=>D(()=>import(`./vhdl-BroJfC0k.js`),[]))},{id:`viml`,name:`Vim Script`,aliases:[`vim`,`vimscript`],import:(()=>D(()=>import(`./viml-DvXPmvsu.js`),[]))},{id:`vue`,name:`Vue`,import:(()=>D(()=>import(`./vue-BNi0qJZP.js`),__vite__mapDeps([100,6,1,7,5,13,15,19])))},{id:`vue-html`,name:`Vue HTML`,import:(()=>D(()=>import(`./vue-html-DkKkQnZL.js`),__vite__mapDeps([101,6,1])))},{id:`vue-vine`,name:`Vue Vine`,import:(()=>D(()=>import(`./vue-vine-DFaKYU4X.js`),__vite__mapDeps([102,6,1,7,9,16,73,103])))},{id:`vyper`,name:`Vyper`,aliases:[`vy`],import:(()=>D(()=>import(`./vyper-CgoNMtux.js`),[]))},{id:`wasm`,name:`WebAssembly`,import:(()=>D(()=>import(`./wasm-ByWQv1Qj.js`),[]))},{id:`wenyan`,name:`Wenyan`,aliases:[`文言`],import:(()=>D(()=>import(`./wenyan-C8pVoKbM.js`),[]))},{id:`wgsl`,name:`WGSL`,import:(()=>D(()=>import(`./wgsl-BsKzXJz4.js`),[]))},{id:`wikitext`,name:`Wikitext`,aliases:[`mediawiki`,`wiki`],import:(()=>D(()=>import(`./wikitext-ClFFjSW2.js`),[]))},{id:`wit`,name:`WebAssembly Interface Types`,import:(()=>D(()=>import(`./wit-DdvCle-K.js`),[]))},{id:`wolfram`,name:`Wolfram`,aliases:[`wl`],import:(()=>D(()=>import(`./wolfram-DLL8P-h_.js`),[]))},{id:`xml`,name:`XML`,import:(()=>D(()=>import(`./xml-BlnrEAEy.js`).then(e=>e.n),__vite__mapDeps([11,1,12])))},{id:`xsl`,name:`XSL`,import:(()=>D(()=>import(`./xsl-BOPS8gLt.js`),__vite__mapDeps([104,11,1,12])))},{id:`yaml`,name:`YAML`,aliases:[`yml`],import:(()=>D(()=>import(`./yaml-Du_6cdrH.js`).then(e=>e.n),__vite__mapDeps([42,1])))},{id:`zenscript`,name:`ZenScript`,import:(()=>D(()=>import(`./zenscript-BnlCZFoB.js`),[]))},{id:`zig`,name:`Zig`,import:(()=>D(()=>import(`./zig-CMLA9XwU.js`),[]))}],lI=Object.fromEntries(cI.map(e=>[e.id,e.import])),uI=Object.fromEntries(cI.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),dI={...lI,...uI},fI=Object.fromEntries([{id:`andromeeda`,displayName:`Andromeeda`,type:`dark`,import:(()=>D(()=>import(`./andromeeda-WkhI09AS.js`),[]))},{id:`aurora-x`,displayName:`Aurora X`,type:`dark`,import:(()=>D(()=>import(`./aurora-x-C7CFqhAd.js`),[]))},{id:`ayu-dark`,displayName:`Ayu Dark`,type:`dark`,import:(()=>D(()=>import(`./ayu-dark-CRu61w6_.js`),[]))},{id:`ayu-light`,displayName:`Ayu Light`,type:`light`,import:(()=>D(()=>import(`./ayu-light-Dn6O_aYR.js`),[]))},{id:`ayu-mirage`,displayName:`Ayu Mirage`,type:`dark`,import:(()=>D(()=>import(`./ayu-mirage-CTjYAbs-.js`),[]))},{id:`catppuccin-frappe`,displayName:`Catppuccin Frappé`,type:`dark`,import:(()=>D(()=>import(`./catppuccin-frappe-DFlFW5gh.js`),[]))},{id:`catppuccin-latte`,displayName:`Catppuccin Latte`,type:`light`,import:(()=>D(()=>import(`./catppuccin-latte-CpxdcXpJ.js`),[]))},{id:`catppuccin-macchiato`,displayName:`Catppuccin Macchiato`,type:`dark`,import:(()=>D(()=>import(`./catppuccin-macchiato-DIdIQ04K.js`),[]))},{id:`catppuccin-mocha`,displayName:`Catppuccin Mocha`,type:`dark`,import:(()=>D(()=>import(`./catppuccin-mocha-Co3Xjl64.js`),[]))},{id:`dark-plus`,displayName:`Dark Plus`,type:`dark`,import:(()=>D(()=>import(`./dark-plus-GAt2ZgX8.js`),[]))},{id:`dracula`,displayName:`Dracula Theme`,type:`dark`,import:(()=>D(()=>import(`./dracula-C2uKkzgK.js`),[]))},{id:`dracula-soft`,displayName:`Dracula Theme Soft`,type:`dark`,import:(()=>D(()=>import(`./dracula-soft-D1bVjxWZ.js`),[]))},{id:`everforest-dark`,displayName:`Everforest Dark`,type:`dark`,import:(()=>D(()=>import(`./everforest-dark-D-DlICQR.js`),[]))},{id:`everforest-light`,displayName:`Everforest Light`,type:`light`,import:(()=>D(()=>import(`./everforest-light-CeVdGHYG.js`),[]))},{id:`github-dark`,displayName:`GitHub Dark`,type:`dark`,import:(()=>D(()=>import(`./github-dark-DwbbXv51.js`),[]))},{id:`github-dark-default`,displayName:`GitHub Dark Default`,type:`dark`,import:(()=>D(()=>import(`./github-dark-default-CxjRwzl6.js`),[]))},{id:`github-dark-dimmed`,displayName:`GitHub Dark Dimmed`,type:`dark`,import:(()=>D(()=>import(`./github-dark-dimmed-Cr1oaoul.js`),[]))},{id:`github-dark-high-contrast`,displayName:`GitHub Dark High Contrast`,type:`dark`,import:(()=>D(()=>import(`./github-dark-high-contrast-B4qJZLZa.js`),[]))},{id:`github-light`,displayName:`GitHub Light`,type:`light`,import:(()=>D(()=>import(`./github-light-CsVXhIlR.js`),[]))},{id:`github-light-default`,displayName:`GitHub Light Default`,type:`light`,import:(()=>D(()=>import(`./github-light-default-DB_IwZa6.js`),[]))},{id:`github-light-high-contrast`,displayName:`GitHub Light High Contrast`,type:`light`,import:(()=>D(()=>import(`./github-light-high-contrast-DLgVeSB-.js`),[]))},{id:`gruvbox-dark-hard`,displayName:`Gruvbox Dark Hard`,type:`dark`,import:(()=>D(()=>import(`./gruvbox-dark-hard-DXm60lX3.js`),[]))},{id:`gruvbox-dark-medium`,displayName:`Gruvbox Dark Medium`,type:`dark`,import:(()=>D(()=>import(`./gruvbox-dark-medium-GE2thSmD.js`),[]))},{id:`gruvbox-dark-soft`,displayName:`Gruvbox Dark Soft`,type:`dark`,import:(()=>D(()=>import(`./gruvbox-dark-soft-04Cj-4VZ.js`),[]))},{id:`gruvbox-light-hard`,displayName:`Gruvbox Light Hard`,type:`light`,import:(()=>D(()=>import(`./gruvbox-light-hard-K6wSn29D.js`),[]))},{id:`gruvbox-light-medium`,displayName:`Gruvbox Light Medium`,type:`light`,import:(()=>D(()=>import(`./gruvbox-light-medium-CVy3aSlc.js`),[]))},{id:`gruvbox-light-soft`,displayName:`Gruvbox Light Soft`,type:`light`,import:(()=>D(()=>import(`./gruvbox-light-soft-DNgJjaY0.js`),[]))},{id:`horizon`,displayName:`Horizon`,type:`dark`,import:(()=>D(()=>import(`./horizon-0-RkHfro.js`),[]))},{id:`horizon-bright`,displayName:`Horizon Bright`,type:`light`,import:(()=>D(()=>import(`./horizon-bright-BgL2X9oq.js`),[]))},{id:`houston`,displayName:`Houston`,type:`dark`,import:(()=>D(()=>import(`./houston-KyjWKfuY.js`),[]))},{id:`kanagawa-dragon`,displayName:`Kanagawa Dragon`,type:`dark`,import:(()=>D(()=>import(`./kanagawa-dragon-7TqgsUPC.js`),[]))},{id:`kanagawa-lotus`,displayName:`Kanagawa Lotus`,type:`light`,import:(()=>D(()=>import(`./kanagawa-lotus-CqxMQulh.js`),[]))},{id:`kanagawa-wave`,displayName:`Kanagawa Wave`,type:`dark`,import:(()=>D(()=>import(`./kanagawa-wave-D8CNn6T_.js`),[]))},{id:`laserwave`,displayName:`LaserWave`,type:`dark`,import:(()=>D(()=>import(`./laserwave-CQkdhozh.js`),[]))},{id:`light-plus`,displayName:`Light Plus`,type:`light`,import:(()=>D(()=>import(`./light-plus-CNQ8_7Y0.js`),[]))},{id:`material-theme`,displayName:`Material Theme`,type:`dark`,import:(()=>D(()=>import(`./material-theme-CAtLaHa3.js`),[]))},{id:`material-theme-darker`,displayName:`Material Theme Darker`,type:`dark`,import:(()=>D(()=>import(`./material-theme-darker-k-s5Bc6K.js`),[]))},{id:`material-theme-lighter`,displayName:`Material Theme Lighter`,type:`light`,import:(()=>D(()=>import(`./material-theme-lighter-CD6a-c4d.js`),[]))},{id:`material-theme-ocean`,displayName:`Material Theme Ocean`,type:`dark`,import:(()=>D(()=>import(`./material-theme-ocean-B3mraInd.js`),[]))},{id:`material-theme-palenight`,displayName:`Material Theme Palenight`,type:`dark`,import:(()=>D(()=>import(`./material-theme-palenight-DEhAARHw.js`),[]))},{id:`min-dark`,displayName:`Min Dark`,type:`dark`,import:(()=>D(()=>import(`./min-dark-BFqTAwCr.js`),[]))},{id:`min-light`,displayName:`Min Light`,type:`light`,import:(()=>D(()=>import(`./min-light-O7UdaaxX.js`),[]))},{id:`monokai`,displayName:`Monokai`,type:`dark`,import:(()=>D(()=>import(`./monokai-C0p7Qecz.js`),[]))},{id:`night-owl`,displayName:`Night Owl`,type:`dark`,import:(()=>D(()=>import(`./night-owl-BsnCLAKc.js`),[]))},{id:`night-owl-light`,displayName:`Night Owl Light`,type:`light`,import:(()=>D(()=>import(`./night-owl-light-BODRhcTU.js`),[]))},{id:`nord`,displayName:`Nord`,type:`dark`,import:(()=>D(()=>import(`./nord-Cd-F4txO.js`),[]))},{id:`one-dark-pro`,displayName:`One Dark Pro`,type:`dark`,import:(()=>D(()=>import(`./one-dark-pro-DUS_IGRK.js`),[]))},{id:`one-light`,displayName:`One Light`,type:`light`,import:(()=>D(()=>import(`./one-light-CVUd7yD5.js`),[]))},{id:`plastic`,displayName:`Plastic`,type:`dark`,import:(()=>D(()=>import(`./plastic-CF8VZTnn.js`),[]))},{id:`poimandres`,displayName:`Poimandres`,type:`dark`,import:(()=>D(()=>import(`./poimandres-BX2TyY6j.js`),[]))},{id:`red`,displayName:`Red`,type:`dark`,import:(()=>D(()=>import(`./red-7ga_dcKu.js`),[]))},{id:`rose-pine`,displayName:`Rosé Pine`,type:`dark`,import:(()=>D(()=>import(`./rose-pine-rh6ipraJ.js`),[]))},{id:`rose-pine-dawn`,displayName:`Rosé Pine Dawn`,type:`light`,import:(()=>D(()=>import(`./rose-pine-dawn-DSuRaP6u.js`),[]))},{id:`rose-pine-moon`,displayName:`Rosé Pine Moon`,type:`dark`,import:(()=>D(()=>import(`./rose-pine-moon-DdHjCvFQ.js`),[]))},{id:`slack-dark`,displayName:`Slack Dark`,type:`dark`,import:(()=>D(()=>import(`./slack-dark-DYvUXyrP.js`),[]))},{id:`slack-ochin`,displayName:`Slack Ochin`,type:`light`,import:(()=>D(()=>import(`./slack-ochin-bqtMVDfH.js`),[]))},{id:`snazzy-light`,displayName:`Snazzy Light`,type:`light`,import:(()=>D(()=>import(`./snazzy-light-D8dzFmq5.js`),[]))},{id:`solarized-dark`,displayName:`Solarized Dark`,type:`dark`,import:(()=>D(()=>import(`./solarized-dark-BQwPDzxK.js`),[]))},{id:`solarized-light`,displayName:`Solarized Light`,type:`light`,import:(()=>D(()=>import(`./solarized-light-BLaijb3X.js`),[]))},{id:`synthwave-84`,displayName:`Synthwave '84`,type:`dark`,import:(()=>D(()=>import(`./synthwave-84-CIknw8y7.js`),[]))},{id:`tokyo-night`,displayName:`Tokyo Night`,type:`dark`,import:(()=>D(()=>import(`./tokyo-night-iIspnLcq.js`),[]))},{id:`vesper`,displayName:`Vesper`,type:`dark`,import:(()=>D(()=>import(`./vesper-D5bVUKB1.js`),[]))},{id:`vitesse-black`,displayName:`Vitesse Black`,type:`dark`,import:(()=>D(()=>import(`./vitesse-black-D082JcaE.js`),[]))},{id:`vitesse-dark`,displayName:`Vitesse Dark`,type:`dark`,import:(()=>D(()=>import(`./vitesse-dark-z-nr_5O8.js`),[]))},{id:`vitesse-light`,displayName:`Vitesse Light`,type:`light`,import:(()=>D(()=>import(`./vitesse-light-ojz42ZLy.js`),[]))}].map(e=>[e.id,e.import])),pI=e({createOnigurumaEngine:()=>zI,getDefaultWasmLoader:()=>RI,loadWasm:()=>MI,setDefaultWasmLoader:()=>LI}),mI=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function hI(){return 2147483648}function gI(){return typeof performance<`u`?performance.now():Date.now()}var _I=(e,t)=>e+(t-e%t)%t;async function vI(e){let t,n,r={};function i(e){n=e,r.HEAPU8=new Uint8Array(e),r.HEAPU32=new Uint32Array(e)}function a(e,t,n){r.HEAPU8.copyWithin(e,t,t+n)}function o(e){try{return t.grow(e-n.byteLength+65535>>>16),i(t.buffer),1}catch{}}function s(e){let t=r.HEAPU8.length;e>>>=0;let n=hI();if(e>n)return!1;for(let r=1;r<=4;r*=2){let i=t*(1+.2/r);if(i=Math.min(i,e+100663296),o(Math.min(n,_I(Math.max(e,i),65536))))return!0}return!1}let c=typeof TextDecoder<`u`?new TextDecoder(`utf8`):void 0;function l(e,t,n=1024){let r=t+n,i=t;for(;e[i]&&!(i>=r);)++i;if(i-t>16&&e.buffer&&c)return c.decode(e.subarray(t,i));let a=``;for(;t<i;){let n=e[t++];if(!(n&128)){a+=String.fromCharCode(n);continue}let r=e[t++]&63;if((n&224)==192){a+=String.fromCharCode((n&31)<<6|r);continue}let i=e[t++]&63;if(n=(n&240)==224?(n&15)<<12|r<<6|i:(n&7)<<18|r<<12|i<<6|e[t++]&63,n<65536)a+=String.fromCharCode(n);else{let e=n-65536;a+=String.fromCharCode(55296|e>>10,56320|e&1023)}}return a}function u(e,t){return e?l(r.HEAPU8,e,t):``}let d={emscripten_get_now:gI,emscripten_memcpy_big:a,emscripten_resize_heap:s,fd_write:()=>0};async function f(){let n=await e({env:d,wasi_snapshot_preview1:d});t=n.memory,i(t.buffer),Object.assign(r,n),r.UTF8ToString=u}return await f(),r}var yI=Object.defineProperty,bI=(e,t,n)=>t in e?yI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,K=(e,t,n)=>bI(e,typeof t==`symbol`?t:t+``,n),q=null;function xI(e){throw new mI(e.UTF8ToString(e.getLastOnigError()))}var SI=class e{constructor(t){K(this,`utf16Length`),K(this,`utf8Length`),K(this,`utf16Value`),K(this,`utf8Value`),K(this,`utf16OffsetToUtf8`),K(this,`utf8OffsetToUtf16`);let n=t.length,r=e._utf8ByteLength(t),i=r!==n,a=i?new Uint32Array(n+1):null;i&&(a[n]=r);let o=i?new Uint32Array(r+1):null;i&&(o[r]=n);let s=new Uint8Array(r),c=0;for(let e=0;e<n;e++){let r=t.charCodeAt(e),l=r,u=!1;if(r>=55296&&r<=56319&&e+1<n){let n=t.charCodeAt(e+1);n>=56320&&n<=57343&&(l=(r-55296<<10)+65536|n-56320,u=!0)}i&&(a[e]=c,u&&(a[e+1]=c),l<=127?o[c+0]=e:l<=2047?(o[c+0]=e,o[c+1]=e):l<=65535?(o[c+0]=e,o[c+1]=e,o[c+2]=e):(o[c+0]=e,o[c+1]=e,o[c+2]=e,o[c+3]=e)),l<=127?s[c++]=l:l<=2047?(s[c++]=192|(l&1984)>>>6,s[c++]=128|(l&63)>>>0):l<=65535?(s[c++]=224|(l&61440)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0):(s[c++]=240|(l&1835008)>>>18,s[c++]=128|(l&258048)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0),u&&e++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=s,this.utf16OffsetToUtf8=a,this.utf8OffsetToUtf16=o}static _utf8ByteLength(e){let t=0;for(let n=0,r=e.length;n<r;n++){let i=e.charCodeAt(n),a=i,o=!1;if(i>=55296&&i<=56319&&n+1<r){let t=e.charCodeAt(n+1);t>=56320&&t<=57343&&(a=(i-55296<<10)+65536|t-56320,o=!0)}t+=a<=127?1:a<=2047?2:a<=65535?3:4,o&&n++}return t}createString(e){let t=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,t),t}},CI=class e{constructor(t){if(K(this,`id`,++e.LAST_ID),K(this,`_onigBinding`),K(this,`content`),K(this,`utf16Length`),K(this,`utf8Length`),K(this,`utf16OffsetToUtf8`),K(this,`utf8OffsetToUtf16`),K(this,`ptr`),!q)throw new mI(`Must invoke loadWasm first.`);this._onigBinding=q,this.content=t;let n=new SI(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!e._sharedPtrInUse?(e._sharedPtr||=q.omalloc(1e4),e._sharedPtrInUse=!0,q.HEAPU8.set(n.utf8Value,e._sharedPtr),this.ptr=e._sharedPtr):this.ptr=n.createString(q)}convertUtf8OffsetToUtf16(e){return this.utf8OffsetToUtf16?e<0?0:e>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[e]:e}convertUtf16OffsetToUtf8(e){return this.utf16OffsetToUtf8?e<0?0:e>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[e]:e}dispose(){this.ptr===e._sharedPtr?e._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};K(CI,`LAST_ID`,0),K(CI,`_sharedPtr`,0),K(CI,`_sharedPtrInUse`,!1);var wI=CI,TI=class{constructor(e){if(K(this,`_onigBinding`),K(this,`_ptr`),!q)throw new mI(`Must invoke loadWasm first.`);let t=[],n=[];for(let r=0,i=e.length;r<i;r++){let i=new SI(e[r]);t[r]=i.createString(q),n[r]=i.utf8Length}let r=q.omalloc(4*e.length);q.HEAPU32.set(t,r/4);let i=q.omalloc(4*e.length);q.HEAPU32.set(n,i/4);let a=q.createOnigScanner(r,i,e.length);for(let n=0,r=e.length;n<r;n++)q.ofree(t[n]);q.ofree(i),q.ofree(r),a===0&&xI(q),this._onigBinding=q,this._ptr=a}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,t,n){let r=0;if(typeof n==`number`&&(r=n),typeof e==`string`){e=new wI(e);let n=this._findNextMatchSync(e,t,!1,r);return e.dispose(),n}return this._findNextMatchSync(e,t,!1,r)}_findNextMatchSync(e,t,n,r){let i=this._onigBinding,a=i.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(t),r);if(a===0)return null;let o=i.HEAPU32,s=a/4,c=o[s++],l=o[s++],u=[];for(let t=0;t<l;t++){let n=e.convertUtf8OffsetToUtf16(o[s++]),r=e.convertUtf8OffsetToUtf16(o[s++]);u[t]={start:n,end:r,length:r-n}}return{index:c,captureIndices:u}}};function EI(e){return typeof e.instantiator==`function`}function DI(e){return typeof e.default==`function`}function OI(e){return e.data!==void 0}function kI(e){return typeof Response<`u`&&e instanceof Response}function AI(e){return typeof ArrayBuffer<`u`&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<`u`&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||typeof Uint32Array<`u`&&e instanceof Uint32Array}var jI;function MI(e){if(jI)return jI;async function t(){q=await vI(async t=>{let n=e;return n=await n,typeof n==`function`&&(n=await n(t)),typeof n==`function`&&(n=await n(t)),EI(n)?n=await n.instantiator(t):DI(n)?n=await n.default(t):(OI(n)&&(n=n.data),kI(n)?n=typeof WebAssembly.instantiateStreaming==`function`?await PI(n)(t):await FI(n)(t):AI(n)||n instanceof WebAssembly.Module?n=await NI(n)(t):`default`in n&&n.default instanceof WebAssembly.Module&&(n=await NI(n.default)(t))),`instance`in n&&(n=n.instance),`exports`in n&&(n=n.exports),n})}return jI=t(),jI}function NI(e){return t=>WebAssembly.instantiate(e,t)}function PI(e){return t=>WebAssembly.instantiateStreaming(e,t)}function FI(e){return async t=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var II;function LI(e){II=e}function RI(){return II}async function zI(e){return e&&await MI(e),{createScanner(e){return new TI(e.map(e=>typeof e==`string`?e:e.source))},createString(e){return new wI(e)}}}var BI=aI({});sI(BI,pI);var J=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function VI(e){return HI(e)}function HI(e){return Array.isArray(e)?UI(e):e instanceof RegExp?e:typeof e==`object`?WI(e):e}function UI(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=HI(e[n]);return t}function WI(e){let t={};for(let n in e)t[n]=HI(e[n]);return t}function GI(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function KI(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?KI(e.substring(0,e.length-1)):e.substr(~t+1)}var qI=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,JI=class{static hasCaptures(e){return e!==null&&(qI.lastIndex=0,qI.test(e))}static replaceCaptures(e,t,n){return e.replace(qI,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function YI(e,t){return e<t?-1:+(e>t)}function XI(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=YI(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function ZI(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function QI(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var $I=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},eL=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(aL(e),t)}static createFromParsedTheme(e,t){return sL(e,t)}_cachedMatchRoot=new $I(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>nL(e.parent,t.parentScopes));return n?new iL(n.fontStyle,n.foreground,n.background):null}},tL=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e||this.parent!==null&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function nL(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!rL(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function rL(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var iL=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function aL(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8}}let s=null;typeof i.settings.foreground==`string`&&ZI(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&ZI(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new oL(l,u,e,o,s,c)}}return n}var oL=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}},Y=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(Y||{});function sL(e,t){e.sort((e,t)=>{let n=YI(e.scope,t.scope);return n!==0||(n=XI(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new cL(t),o=new iL(n,a.getId(r),a.getId(i)),s=new dL(new uL(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new eL(a,o,s)}var cL=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},lL=Object.freeze([]),uL=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||lL,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},dL=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),uL.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(XI(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new uL(e,t,n,r,i))}},fL=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return!!(e&1024)}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=mL(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function pL(e){return e}function mL(e){return e}function hL(e,t){let n=[],r=_L(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(gL(i)){let e=[];do e.push(i),i=r.next();while(gL(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function gL(e){return!!e&&!!e.match(/[\w\.:]+/)}function _L(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function vL(e){typeof e.dispose==`function`&&e.dispose()}var yL=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},bL=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},xL=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},SL=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new yL(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new xL;for(let n of e)CL(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof yL){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function CL(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof yL?TL({baseGrammar:a,selfGrammar:i},r):wL(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new yL(e))}function wL(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];EL([r],t,n)}}function TL(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&EL(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&EL(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function EL(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?GI({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&EL(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=ML(i);switch(a.kind){case 0:TL({...t,selfGrammar:t.baseGrammar},n);break;case 1:TL(t,n);break;case 2:wL(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?wL(a.ruleName,i,n):TL(i,n)}else a.kind===4?n.add(new bL(a.scopeName,a.ruleName)):n.add(new yL(a.scopeName))}}}var DL=class{kind=0},OL=class{kind=1},kL=class{constructor(e){this.ruleName=e}kind=2},AL=class{constructor(e){this.scopeName=e}kind=3},jL=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function ML(e){if(e===`$base`)return new DL;if(e===`$self`)return new OL;let t=e.indexOf(`#`);return t===-1?new AL(e):t===0?new kL(e.substring(1)):new jL(e.substring(0,t),e.substring(t+1))}var NL=/\\(\d+)/,PL=/\\(\d+)/g,FL=-1,IL=-2;function LL(e){return e}function RL(e){return e}var zL=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=JI.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=JI.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${KI(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:JI.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:JI.replaceCaptures(this._contentName,e,t)}},BL=class extends zL{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},VL=class extends zL{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new KL(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new qL,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},HL=class extends zL{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new qL,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},UL=class extends zL{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new KL(i,this.id),this.beginCaptures=a,this._end=new KL(o||``,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new qL;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},WL=class extends zL{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new KL(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new KL(o,IL),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new qL;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new qL,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||``),this._cachedCompiledWhilePatterns}},GL=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new BL(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new VL(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=GI({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new HL(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new WL(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new UL(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=ML(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository)}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof HL||e instanceof UL||e instanceof WL)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},KL=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this._anchorCache=this.hasAnchor?this._buildAnchorCache():null,this.ruleId=t,this.hasBackReferences=typeof this.source==`string`&&NL.test(this.source)}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return PL.lastIndex=0,this.source.replace(PL,(e,t)=>QI(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=``,t[i+1]=``,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=``,t[i+1]=`G`,n[i+1]=``,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},qL=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new JL(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new JL(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},JL=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
|
|
42
|
+
`)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},YL=class{constructor(e,t){this.languageId=e,this.tokenType=t}},XL=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new YL(e,8),this._embeddedLanguagesMatcher=new ZL(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new YL(0,0);_getBasicScopeAttributes=new $I(e=>new YL(this._scopeToLanguage(e),this._toStandardTokenType(e)));_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){let n=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case`comment`:return 1;case`string`:return 2;case`regex`:return 3;case`meta.embedded`:return 0}throw Error(`Unexpected match for standard token type!`)}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},ZL=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([e,t])=>QI(e));t.sort(),t.reverse(),this.scopesRegExp=RegExp(`^((${t.join(`)|(`)}))($|\\.)`,``)}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}};typeof process<`u`&&{}.VSCODE_TEXTMATE_DEBUG;var QL=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function $L(e,t,n,r,i,a,o,s){let c=t.content.length,l=!1,u=-1;if(o){let o=eR(e,t,n,r,i,a);i=o.stack,r=o.linePos,n=o.isFirstLine,u=o.anchorPosition}let d=Date.now();for(;!l;){if(s!==0&&Date.now()-d>s)return new QL(i,!0);f()}return new QL(i,!1);function f(){let o=tR(e,t,n,r,i,u);if(!o){a.produce(i,c),l=!0;return}let s=o.captureIndices,d=o.matchedRuleId,f=s&&s.length>0?s[0].end>r:!1;if(d===FL){let o=i.getRule(e);a.produce(i,s[0].start),i=i.withContentNameScopesList(i.nameScopesList),oR(e,t,n,i,a,o.endCaptures,s),a.produce(i,s[0].end);let d=i;if(i=i.parent,u=d.getAnchorPos(),!f&&d.getEnterPos()===r){i=d,a.produce(i,c),l=!0;return}}else{let o=e.getRule(d);a.produce(i,s[0].start);let p=i,m=o.getName(t.content,s),h=i.contentNameScopesList.pushAttributed(m,e);if(i=i.push(d,r,u,s[0].end===c,null,h,h),o instanceof UL){let r=o;oR(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.endHasBackReferences&&(i=i.withEndRule(r.getEndWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(o instanceof WL){let r=o;oR(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.whileHasBackReferences&&(i=i.withEndRule(r.getWhileWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(oR(e,t,n,i,a,o.captures,s),a.produce(i,s[0].end),i=i.pop(),!f){i=i.safePop(),a.produce(i,c),l=!0;return}}s[0].end>r&&(r=s[0].end,n=!1)}}function eR(e,t,n,r,i,a){let o=i.beginRuleCapturedEOL?0:-1,s=[];for(let t=i;t;t=t.pop()){let n=t.getRule(e);n instanceof WL&&s.push({rule:n,stack:t})}for(let c=s.pop();c;c=s.pop()){let{ruleScanner:s,findOptions:l}=aR(c.rule,e,c.stack.endRule,n,r===o),u=s.findNextMatchSync(t,r,l);if(u){if(u.ruleId!==IL){i=c.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(a.produce(c.stack,u.captureIndices[0].start),oR(e,t,n,c.stack,a,c.rule.whileCaptures,u.captureIndices),a.produce(c.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>r&&(r=u.captureIndices[0].end,n=!1))}else{i=c.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:o,isFirstLine:n}}function tR(e,t,n,r,i,a){let o=nR(e,t,n,r,i,a),s=e.getInjections();if(s.length===0)return o;let c=rR(s,e,t,n,r,i,a);if(!c)return o;if(!o)return c;let l=o.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:o}function nR(e,t,n,r,i,a){let{ruleScanner:o,findOptions:s}=iR(i.getRule(e),e,i.endRule,n,r===a),c=o.findNextMatchSync(t,r,s);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function rR(e,t,n,r,i,a,o){let s=Number.MAX_VALUE,c=null,l,u=0,d=a.contentNameScopesList.getScopeNames();for(let a=0,f=e.length;a<f;a++){let f=e[a];if(!f.matcher(d))continue;let{ruleScanner:p,findOptions:m}=iR(t.getRule(f.ruleId),t,null,r,i===o),h=p.findNextMatchSync(n,i,m);if(!h)continue;let g=h.captureIndices[0].start;if(!(g>=s)&&(s=g,c=h.captureIndices,l=h.ruleId,u=f.priority,s===i))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function iR(e,t,n,r,i){return{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function aR(e,t,n,r,i){return{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function oR(e,t,n,r,i,a,o){if(a.length===0)return;let s=t.content,c=Math.min(a.length,o.length),l=[],u=o[0].end;for(let t=0;t<c;t++){let c=a[t];if(c===null)continue;let d=o[t];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?i.produceFromScopes(l[l.length-1].scopes,d.start):i.produce(r,d.start),c.retokenizeCapturedWithRuleId){let t=c.getName(s,o),a=r.contentNameScopesList.pushAttributed(t,e),l=c.getContentName(s,o),u=a.pushAttributed(l,e),f=r.push(c.retokenizeCapturedWithRuleId,d.start,-1,!1,null,a,u),p=e.createOnigString(s.substring(0,d.end));$L(e,p,n&&d.start===0,d.start,f,i,!1,0),vL(p);continue}let f=c.getName(s,o);if(f!==null){let t=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);l.push(new sR(t,d.end))}}for(;l.length>0;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var sR=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function cR(e,t,n,r,i,a,o,s){return new fR(e,t,n,r,i,a,o,s)}function lR(e,t,n,r,i){let a=hL(t,uR),o=GL.getCompiledRuleId(n,r,i.repository);for(let n of a)e.push({debugSelector:t,matcher:n.matcher,ruleId:o,grammar:i,priority:n.priority})}function uR(e,t){if(t.length<e.length)return!1;let n=0;return e.every(e=>{for(let r=n;r<t.length;r++)if(dR(t[r],e))return n=r+1,!0;return!1})}function dR(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]===`.`}var fR=class{constructor(e,t,n,r,i,a,o,s){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=s,this._basicScopeAttributesProvider=new XL(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=pR(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(let e of Object.keys(i)){let t=hL(e,uR);for(let n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:i[e]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),injections:e=>this._grammarRepository.injections(e)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let e=r.injections;if(e)for(let n in e)lR(t,n,e[n],this,r);let i=this._grammarRepository.injections(n);i&&i.forEach(e=>{let n=this.getExternalGrammar(e);if(n){let e=n.injectionSelector;e&&lR(t,e,n,this,n)}})}return t.sort((e,t)=>e.priority-t.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(LL(t));return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[RL(e)]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=pR(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=GL.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===hR.NULL){i=!0;let e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=fL.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),a=this.getRule(this._rootId).getName(null,null),o;o=a?mR.createRootAndLookUpScopeName(a,r,this):mR.createRoot(`unknown`,r),t=new hR(null,this._rootId,-1,-1,!1,null,o,o)}else i=!1,t.reset();e+=`
|
|
43
|
+
`;let a=this.createOnigString(e),o=a.content.length,s=new _R(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=$L(this,a,i,0,t,s,!0,r);return vL(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function pR(e,t){return e=VI(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var mR=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=tL.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new tL(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new tL(null,t),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(n,i,o);return new e(null,a,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),fL.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(t.tokenAttributes,i,o);return new e(t,a,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},hR=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t!==null&&e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?mR.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:RL(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=mR.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,LL(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,mR.fromExtension(r,n.contentNameScopesList))}},gR=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):hL(e,uR).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>hL(e,uR).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},_R=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=fL.set(n,0,pL(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=fL.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},vR=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,cR(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},yR=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new vR(eL.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(eL.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new gR(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new SL(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},bR=hR.NULL;function xR(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function SR(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function CR(e){return Array.isArray(e)?e:[e]}async function wR(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function TR(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function ER(e){return e===`ansi`||TR(e)}function DR(e){return e===`none`}function OR(e){return DR(e)}function kR(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(/(\r?\n)/g),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}var AR={light:`#333333`,dark:`#bbbbbb`},jR={light:`#fffffe`,dark:`#1e1e1e`},MR=`__shiki_resolved`;function NR(e){if(e?.[MR])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?AR.light:AR.dark,n||=t.type===`light`?jR.light:jR.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,MR,{enumerable:!1,writable:!1,value:!0}),t}async function PR(e){return Array.from(new Set((await Promise.all(e.filter(e=>!ER(e)).map(async e=>await wR(e).then(e=>Array.isArray(e)?e:[e])))).flat()))}async function FR(e){return(await Promise.all(e.map(async e=>OR(e)?null:NR(await wR(e))))).filter(e=>!!e)}function IR(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new J(`Circular alias \`${Array.from(n).join(` -> `)} -> ${e}\``);n.add(e)}}return e}var LR=class extends yR{_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=NR(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=eL.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=IR(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null,t.size)for(let e of t)this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(e.scopeName),this._syncRegistry?._grammars?.delete(e.scopeName),this.loadLanguage(this._langMap.get(e.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=Array.from(this._langGraph.entries()),n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new J(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},RR=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}},zR=0;function BR(e){zR+=1,e.warnings!==!1&&zR>=10&&zR%10==0&&console.warn(`[Shiki] ${zR} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new J("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(NR),i=new LR(new RR(e.engine,n),r,n,e.langAlias),a;function o(t){return IR(t,e.langAlias)}function s(e){g();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new J(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};g();let t=i.getTheme(e);if(!t)throw new J(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){g();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return g(),i.getLoadedThemes()}function d(){return g(),i.getLoadedLanguages()}function f(...e){g(),i.loadLanguages(e.flat(1))}async function p(...e){return f(await PR(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await FR(e))}function g(){if(t)throw new J(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--zR)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:o,loadLanguage:p,loadLanguageSync:f,loadTheme:h,loadThemeSync:m,dispose:_,[Symbol.dispose]:_}}async function VR(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([FR(e.themes||[]),PR(e.langs||[]),e.engine]);return BR({...e,themes:t,langs:n,engine:r})}var HR=new WeakMap;function UR(e,t){HR.set(e,t)}function WR(e){return HR.get(e)}var GR=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(CR(n).map(e=>[e,bR])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return KR(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function KR(e){let t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function qR(e,t){if(!(e instanceof GR))throw new J(`Invalid grammar state`);return e.getInternalStack(t)}function JR(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(TR(e.resolveLangAlias(n.lang||`text`))||DR(r))return kR(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new J(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new J(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return XR(t,o,i,a,n)}function YR(...e){if(e.length===2)return WR(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(TR(i)||DR(a))throw new J(`Plain language does not have grammar state`);if(i===`ansi`)throw new J(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new GR(ZR(n,c,o,s,r).stateStack,c.name,o.name)}function XR(e,t,n,r,i){let a=ZR(e,t,n,r,i),o=new GR(a.stateStack,t.name,n.name);return UR(a.tokens,o),a.tokens}function ZR(e,t,n,r,i){let a=xR(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500}=i,c=kR(e),l=i.grammarState?qR(i.grammarState,n.name)??bR:i.grammarContextCode==null?bR:ZR(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,u=[],d=[];for(let e=0,f=c.length;e<f;e++){let[f,p]=c[e];if(f===``){u=[],d.push([]);continue}if(o>0&&f.length>=o){u=[],d.push([{content:f,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;i.includeExplanation&&(m=t.tokenizeLine(f,l,s),h=m.tokens,g=0);let _=t.tokenizeLine2(f,l,s),v=_.tokens.length/2;for(let e=0;e<v;e++){let t=_.tokens[2*e],o=e+1<v?_.tokens[2*e+2]:f.length;if(t===o)continue;let s=_.tokens[2*e+1],c=SR(r[fL.getForeground(s)],a),l=fL.getFontStyle(s),d={content:f.substring(t,o),offset:p+t,color:c,fontStyle:l};if(i.includeExplanation){let e=[];if(i.includeExplanation!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(/,/).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(/ /))})}d.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=f.substring(t.startIndex,t.endIndex);r+=n.length,d.explanation.push({content:n,scopes:i.includeExplanation===`scopeName`?QR(t.scopes):$R(e,t.scopes)}),g+=1}}u.push(d)}d.push(u),u=[],l=_.ruleStack}return{tokens:d,stateStack:l}}function QR(e){return e.map(e=>({scopeName:e}))}function $R(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:nz(e,i,t.slice(0,r))}}return n}function ez(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function tz(e,t,n){if(!ez(e[e.length-1],t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)ez(e[r],n[i])&&--r,--i;return r===-1}function nz(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(tz(e,t,n)){r.push(a);break}return r}function rz(e,t,n,r=JR){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:WR(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=iz(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new GR(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&UR(s,c),s}function iz(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}function az(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class==`string`&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(/\s+/g);for(let t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}function oz(e){let t=kR(e,!0).map(([e])=>e);function n(n){if(n===e.length)return{line:t.length-1,character:t[t.length-1].length};let r=n,i=0;for(let e of t){if(r<e.length)break;r-=e.length,i++}return{line:i,character:r}}function r(e,n){let r=0;for(let n=0;n<e;n++)r+=t[n].length;return r+=n,r}return{lines:t,indexToPos:n,posToIndex:r}}function sz(e,t,n){let r=new Set;for(let t of e.matchAll(/:?lang=["']([^"']+)["']/g)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(/\\begin\{([\w-]+)\}/g)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let e=t[1].toLowerCase().trim(),n=e.includes(`/`)?e.split(`/`).pop():e;n&&r.add(n)}if(!n)return Array.from(r);let i=n.getBundledLanguages();return Array.from(r).filter(e=>e&&i[e])}var cz=`light-dark()`,lz=[`color`,`background-color`];function uz(e,t){let n=0,r=[];for(let i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function dz(e,t){let n=Array.from(t instanceof Set?t:new Set(t)).sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{let t=n.filter(t=>e.offset<t&&t<e.offset+e.content.length).map(t=>t-e.offset).sort((e,t)=>e-t);return t.length?uz(e,t):e})):e}function fz(e,t,n,r,i=`css-vars`){let a={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>pz(e.variants[t])),s=new Set(o.flatMap(e=>Object.keys(e))),c={},l=(e,r)=>{let i=r===`color`?``:r===`background-color`?`-bg`:`-${r}`;return n+t[e]+(r===`color`?``:i)};return o.forEach((e,n)=>{for(let a of s){let s=e[a]||`inherit`;if(n===0&&r&&lz.includes(a))if(r===cz&&o.length>1){let e=t.findIndex(e=>e===`light`),r=t.findIndex(e=>e===`dark`);if(e===-1||r===-1)throw new J('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');c[a]=`light-dark(${o[e][a]||`inherit`}, ${o[r][a]||`inherit`})`,i===`css-vars`&&(c[l(n,a)]=s)}else c[a]=s;else i===`css-vars`&&(c[l(n,a)]=s)}}),a.htmlStyle=c,a}function pz(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t[`background-color`]=e.bgColor),e.fontStyle){e.fontStyle&Y.Italic&&(t[`font-style`]=`italic`),e.fontStyle&Y.Bold&&(t[`font-weight`]=`bold`);let n=[];e.fontStyle&Y.Underline&&n.push(`underline`),e.fontStyle&Y.Strikethrough&&n.push(`line-through`),n.length&&(t[`text-decoration`]=n.join(` `))}return t}function mz(e){return typeof e==`string`?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function hz(){let e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=oz(t.source);function r(e){if(typeof e==`number`){if(e<0||e>t.source.length)throw new J(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...n.indexToPos(e),offset:e}}{let t=n.lines[e.line];if(t===void 0)throw new J(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${n.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new J(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:n.posToIndex(e.line,r)}}}let i=(t.options.decorations||[]).map(e=>({...e,start:r(e.start),end:r(e.end)}));gz(i),e.set(t.meta,{decorations:i,converter:n,source:t.source})}return e.get(t.meta)}return{name:`shiki:decorations`,tokens(e){if(this.options.decorations?.length)return dz(e,t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]))},code(e){if(!this.options.decorations?.length)return;let n=t(this),r=Array.from(e.children).filter(e=>e.type===`element`&&e.tagName===`span`);if(r.length!==n.converter.lines.length)throw new J(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function i(e,t,n,i){let a=r[e],s=``,c=-1,l=-1;if(t===0&&(c=0),n===0&&(l=0),n===1/0&&(l=a.children.length),c===-1||l===-1)for(let e=0;e<a.children.length;e++)s+=_z(a.children[e]),c===-1&&s.length===t&&(c=e+1),l===-1&&s.length===n&&(l=e+1);if(c===-1)throw new J(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(l===-1)throw new J(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let u=a.children.slice(c,l);if(!i.alwaysWrap&&u.length===a.children.length)o(a,i,`line`);else if(!i.alwaysWrap&&u.length===1&&u[0].type===`element`)o(u[0],i,`token`);else{let e={type:`element`,tagName:`span`,properties:{},children:u};o(e,i,`wrapper`),a.children.splice(c,u.length,e)}}function a(e,t){r[e]=o(r[e],t,`line`)}function o(e,t,n){let r=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||`span`,e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&az(e,t.properties.class),e=i(e,n)||e,e}let s=[],c=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(let e of c){let{start:t,end:n}=e;if(t.line===n.line)i(t.line,t.character,n.character,e);else if(t.line<n.line){i(t.line,t.character,1/0,e);for(let r=t.line+1;r<n.line;r++)s.unshift(()=>a(r,e));i(n.line,0,n.character,e)}}s.forEach(e=>e())}}}function gz(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new J(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let t=e[r],i=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,a=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,s=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(i||a||o||s){if(i&&a||o&&s||o&&n.start.offset===n.end.offset||a&&t.start.offset===t.end.offset)continue;throw new J(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}function _z(e){return e.type===`text`?e.value:e.type===`element`?e.children.map(_z).join(``):``}var vz=[hz()];function yz(e){let t=bz(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...vz]}function bz(e){let t=[],n=[],r=[];for(let i of e)switch(i.enforce){case`pre`:t.push(i);break;case`post`:n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var xz=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],Sz={1:`bold`,2:`dim`,3:`italic`,4:`underline`,7:`reverse`,8:`hidden`,9:`strikethrough`};function Cz(e,t){let n=e.indexOf(`\x1B`,t);if(n!==-1&&e[n+1]===`[`){let t=e.indexOf(`m`,n);if(t!==-1)return{sequence:e.substring(n+2,t).split(`;`),startPosition:n,position:t+1}}return{position:e.length}}function wz(e){let t=e.shift();if(t===`2`){let t=e.splice(0,3).map(e=>Number.parseInt(e));return t.length!==3||t.some(e=>Number.isNaN(e))?void 0:{type:`rgb`,rgb:t}}if(t===`5`){let t=e.shift();if(t)return{type:`table`,index:Number(t)}}}function Tz(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:`resetAll`});else if(r<=9)Sz[r]&&t.push({type:`setDecoration`,value:Sz[r]});else if(r<=29){let e=Sz[r-20];e&&(t.push({type:`resetDecoration`,value:e}),e===`dim`&&t.push({type:`resetDecoration`,value:`bold`}))}else if(r<=37)t.push({type:`setForegroundColor`,value:{type:`named`,name:xz[r-30]}});else if(r===38){let n=wz(e);n&&t.push({type:`setForegroundColor`,value:n})}else if(r===39)t.push({type:`resetForegroundColor`});else if(r<=47)t.push({type:`setBackgroundColor`,value:{type:`named`,name:xz[r-40]}});else if(r===48){let n=wz(e);n&&t.push({type:`setBackgroundColor`,value:n})}else r===49?t.push({type:`resetBackgroundColor`}):r===53?t.push({type:`setDecoration`,value:`overline`}):r===55?t.push({type:`resetDecoration`,value:`overline`}):r>=90&&r<=97?t.push({type:`setForegroundColor`,value:{type:`named`,name:xz[r-90+8]}}):r>=100&&r<=107&&t.push({type:`setBackgroundColor`,value:{type:`named`,name:xz[r-100+8]}})}return t}function Ez(){let e=null,t=null,n=new Set;return{parse(r){let i=[],a=0;do{let o=Cz(r,a),s=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(s.length>0&&i.push({value:s,foreground:e,background:t,decorations:new Set(n)}),o.sequence){let r=Tz(o.sequence);for(let i of r)i.type===`resetAll`?(e=null,t=null,n.clear()):i.type===`resetForegroundColor`?e=null:i.type===`resetBackgroundColor`?t=null:i.type===`resetDecoration`&&n.delete(i.value);for(let i of r)i.type===`setForegroundColor`?e=i.value:i.type===`setBackgroundColor`?t=i.value:i.type===`setDecoration`&&n.add(i.value)}a=o.position}while(a<r.length);return i}}}var Dz={black:`#000000`,red:`#bb0000`,green:`#00bb00`,yellow:`#bbbb00`,blue:`#0000bb`,magenta:`#ff00ff`,cyan:`#00bbbb`,white:`#eeeeee`,brightBlack:`#555555`,brightRed:`#ff5555`,brightGreen:`#00ff00`,brightYellow:`#ffff55`,brightBlue:`#5555ff`,brightMagenta:`#ff55ff`,brightCyan:`#55ffff`,brightWhite:`#ffffff`};function Oz(e=Dz){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,`0`)).join(``)}`}let r;function i(){if(r)return r;r=[];for(let e=0;e<xz.length;e++)r.push(t(xz[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)r.push(n([e[t],e[i],e[a]]));let i=8;for(let e=0;e<24;e++,i+=10)r.push(n([i,i,i]));return r}function a(e){return i()[e]}function o(e){switch(e.type){case`named`:return t(e.name);case`rgb`:return n(e.rgb);case`table`:return a(e.index)}}return{value:o}}var kz={black:`#000000`,red:`#cd3131`,green:`#0DBC79`,yellow:`#E5E510`,blue:`#2472C8`,magenta:`#BC3FBC`,cyan:`#11A8CD`,white:`#E5E5E5`,brightBlack:`#666666`,brightRed:`#F14C4C`,brightGreen:`#23D18B`,brightYellow:`#F5F543`,brightBlue:`#3B8EEA`,brightMagenta:`#D670D6`,brightCyan:`#29B8DB`,brightWhite:`#FFFFFF`};function Az(e,t,n){let r=xR(e,n),i=kR(t),a=Oz(Object.fromEntries(xz.map(t=>{let n=`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`;return[t,e.colors?.[n]||kz[t]]}))),o=Ez();return i.map(t=>o.parse(t[0]).map(n=>{let i,o;n.decorations.has(`reverse`)?(i=n.background?a.value(n.background):e.bg,o=n.foreground?a.value(n.foreground):e.fg):(i=n.foreground?a.value(n.foreground):e.fg,o=n.background?a.value(n.background):void 0),i=SR(i,r),o=SR(o,r),n.decorations.has(`dim`)&&(i=jz(i));let s=Y.None;return n.decorations.has(`bold`)&&(s|=Y.Bold),n.decorations.has(`italic`)&&(s|=Y.Italic),n.decorations.has(`underline`)&&(s|=Y.Underline),n.decorations.has(`strikethrough`)&&(s|=Y.Strikethrough),{content:n.value,offset:t[1],color:i,bgColor:o,fontStyle:s}}))}function jz(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let e=t[1];if(e.length===8){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,`0`);return`#${e.slice(0,6)}${t}`}if(e.length===6)return`#${e}80`;if(e.length===4){let t=e[0],n=e[1],r=e[2],i=e[3];return`#${t}${t}${n}${n}${r}${r}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,`0`)}`}if(e.length===3){let t=e[0],n=e[1],r=e[2];return`#${t}${t}${n}${n}${r}${r}80`}}let n=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:e}function Mz(e,t,n={}){let r=e.resolveLangAlias(n.lang||`text`),{theme:i=e.getLoadedThemes()[0]}=n;if(!TR(r)&&!DR(i)&&r===`ansi`){let{theme:r}=e.setTheme(i);return Az(r,t,n)}return JR(e,t,n)}function Nz(e,t,n){let r,i,a,o,s,c;if(`themes`in n){let{defaultColor:l=`light`,cssVariablePrefix:u=`--shiki-`,colorsRendering:d=`css-vars`}=n,f=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===l?-1:+(t.color===l));if(f.length===0)throw new J("`themes` option must not be empty");let p=rz(e,t,n,Mz);if(c=WR(p),l&&cz!==l&&!f.find(e=>e.color===l))throw new J(`\`themes\` option must contain the defaultColor key \`${l}\``);let m=f.map(t=>e.getTheme(t.theme)),h=f.map(e=>e.color);a=p.map(e=>e.map(e=>fz(e,h,u,l,d))),c&&UR(a,c);let g=f.map(e=>xR(e.theme,n));i=Pz(f,m,g,u,l,`fg`,d),r=Pz(f,m,g,u,l,`bg`,d),o=`shiki-themes ${m.map(e=>e.name).join(` `)}`,s=l?void 0:[i,r].join(`;`)}else if(`theme`in n){let s=xR(n.theme,n);a=Mz(e,t,n);let l=e.getTheme(n.theme);r=SR(l.bg,s),i=SR(l.fg,s),o=l.name,c=WR(a)}else throw new J("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:o,rootStyle:s,grammarState:c}}function Pz(e,t,n,r,i,a,o){return e.map((s,c)=>{let l=SR(t[c][a],n[c])||`inherit`,u=`${r+s.color}${a===`bg`?`-bg`:``}:${l}`;if(c===0&&i){if(i===cz&&e.length>1){let r=e.findIndex(e=>e.color===`light`),i=e.findIndex(e=>e.color===`dark`);if(r===-1||i===-1)throw new J('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${SR(t[r][a],n[r])||`inherit`}, ${SR(t[i][a],n[i])||`inherit`});${u}`}return l}return o===`css-vars`?u:null}).filter(e=>!!e).join(`;`)}function Fz(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>Fz(e,t,n),codeToTokens:(t,n)=>Nz(e,t,n)}){let i=t;for(let e of yz(n))i=e.preprocess?.call(r,i,n)||i;let{tokens:a,fg:o,bg:s,themeName:c,rootStyle:l,grammarState:u}=Nz(e,i,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?a=Lz(a):d===`never`&&(a=Rz(a)),f&&(a=zz(a));let p={...r,get source(){return i}};for(let e of yz(n))a=e.tokens?.call(p,a)||a;return Iz(a,{...n,fg:o,bg:s,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},p,u)}function Iz(e,t,n,r=WR(e)){let i=yz(t),a=[],o={type:`root`,children:[]},{structure:s=`classic`,tabindex:c=`0`}=t,l={class:`shiki ${t.themeName||``}`};t.rootStyle!==!1&&(l.style=t.rootStyle==null?`background-color:${t.bg};color:${t.fg}`:t.rootStyle),c!==!1&&c!=null&&(l.tabindex=c.toString());for(let[e,n]of Object.entries(t.meta||{}))e.startsWith(`_`)||(l[e]=n);let u={type:`element`,tagName:`pre`,properties:l,children:[],data:t.data},d={type:`element`,tagName:`code`,properties:{},children:a},f=[],p={...n,structure:s,addClassToHast:az,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return u},get code(){return d},get lines(){return f}};if(e.forEach((e,t)=>{t&&(s===`inline`?o.children.push({type:`element`,tagName:`br`,properties:{},children:[]}):s===`classic`&&a.push({type:`text`,value:`
|
|
44
|
+
`}));let n={type:`element`,tagName:`span`,properties:{class:`line`},children:[]},r=0;for(let a of e){let e={type:`element`,tagName:`span`,properties:{...a.htmlAttrs},children:[{type:`text`,value:a.content}]},c=mz(a.htmlStyle||pz(a));c&&(e.properties.style=c);for(let o of i)e=o?.span?.call(p,e,t+1,r,n,a)||e;s===`inline`?o.children.push(e):s===`classic`&&n.children.push(e),r+=a.content.length}if(s===`classic`){for(let e of i)n=e?.line?.call(p,n,t+1)||n;f.push(n),a.push(n)}else s===`inline`&&f.push(n)}),s===`classic`){for(let e of i)d=e?.code?.call(p,d)||d;u.children.push(d);for(let e of i)u=e?.pre?.call(p,u)||u;o.children.push(u)}else if(s===`inline`){let e=[],t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]};for(let n of o.children)n.type===`element`&&n.tagName===`br`?(e.push(t),t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]}):(n.type===`element`||n.type===`text`)&&t.children.push(n);e.push(t);let n={type:`element`,tagName:`code`,properties:{},children:e};for(let e of i)n=e?.code?.call(p,n)||n;o.children=[];for(let e=0;e<n.children.length;e++){e>0&&o.children.push({type:`element`,tagName:`br`,properties:{},children:[]});let t=n.children[e];t.type===`element`&&o.children.push(...t.children)}}let m=o;for(let e of i)m=e?.root?.call(p,m)||m;return r&&UR(m,r),m}function Lz(e){return e.map(e=>{let t=[],n=``,r;return e.forEach((i,a)=>{let o=!(i.fontStyle&&(i.fontStyle&Y.Underline||i.fontStyle&Y.Strikethrough));o&&i.content.match(/^\s+$/)&&e[a+1]?(r===void 0&&(r=i.offset),n+=i.content):n?(o?t.push({...i,offset:r,content:n+i.content}):t.push({content:n,offset:r},i),r=void 0,n=``):t.push(i)}),t})}function Rz(e){return e.map(e=>e.flatMap(e=>{if(e.content.match(/^\s+$/))return e;let t=e.content.match(/^(\s*)(.*?)(\s*)$/);if(!t)return e;let[,n,r,i]=t;if(!n&&!i)return e;let a=[{...e,offset:e.offset+n.length,content:r}];return n&&a.unshift({content:n,offset:e.offset}),i&&a.push({content:i,offset:e.offset+n.length+r.length}),a}))}function zz(e){return e.map(e=>{let t=[];for(let n of e){if(t.length===0){t.push({...n});continue}let e=t[t.length-1],r=mz(e.htmlStyle||pz(e)),i=mz(n.htmlStyle||pz(n)),a=e.fontStyle&&(e.fontStyle&Y.Underline||e.fontStyle&Y.Strikethrough),o=n.fontStyle&&(n.fontStyle&Y.Underline||n.fontStyle&Y.Strikethrough);!a&&!o&&r===i?e.content+=n.content:t.push({...n})}return t})}var Bz=_F;function Vz(e,t,n){let r={meta:{},options:n,codeToHast:(t,n)=>Fz(e,t,n),codeToTokens:(t,n)=>Nz(e,t,n)},i=Bz(Fz(e,t,n,r));for(let e of yz(n))i=e.postprocess?.call(r,i,n)||i;return i}async function Hz(e){let t=await VR(e);return{getLastGrammarState:(...e)=>YR(t,...e),codeToTokensBase:(e,n)=>Mz(t,e,n),codeToTokensWithThemes:(e,n)=>rz(t,e,n),codeToTokens:(e,n)=>Nz(t,e,n),codeToHast:(e,n)=>Fz(t,e,n),codeToHtml:(e,n)=>Vz(t,e,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function Uz(e){let t=e.langs,n=e.themes,r=e.engine;async function i(e){function i(n){if(typeof n==`string`){if(n=e.langAlias?.[n]||n,ER(n))return[];let r=t[n];if(!r)throw new J(`Language \`${n}\` is not included in this bundle. You may want to load it from external source.`);return r}return n}function a(e){if(OR(e))return`none`;if(typeof e==`string`){let t=n[e];if(!t)throw new J(`Theme \`${e}\` is not included in this bundle. You may want to load it from external source.`);return t}return e}let o=(e.themes??[]).map(e=>a(e)),s=(e.langs??[]).map(e=>i(e)),c=await Hz({engine:e.engine??r(),...e,themes:o,langs:s});return{...c,loadLanguage(...e){return c.loadLanguage(...e.map(i))},loadTheme(...e){return c.loadTheme(...e.map(a))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return i}function Wz(e){let t;async function n(n={}){if(t){let e=await t;return await Promise.all([e.loadTheme(...n.themes||[]),e.loadLanguage(...n.langs||[])]),e}{t=e({...n,themes:[],langs:[]});let r=await t;return await Promise.all([r.loadTheme(...n.themes||[]),r.loadLanguage(...n.langs||[])]),r}}return n}function Gz(e,t){let n=Wz(e);async function r(e,r){let i=await n({langs:[r.lang],themes:`theme`in r?[r.theme]:Object.values(r.themes)}),a=await t?.guessEmbeddedLanguages?.(e,r.lang,i);return a&&await i.loadLanguage(...a),i}return{getSingletonHighlighter(e){return n(e)},async codeToHtml(e,t){return(await r(e,t)).codeToHtml(e,t)},async codeToHast(e,t){return(await r(e,t)).codeToHast(e,t)},async codeToTokens(e,t){return(await r(e,t)).codeToTokens(e,t)},async codeToTokensBase(e,t){return(await r(e,t)).codeToTokensBase(e,t)},async codeToTokensWithThemes(e,t){return(await r(e,t)).codeToTokensWithThemes(e,t)},async getLastGrammarState(e,t){return(await n({langs:[t.lang],themes:[t.theme]})).getLastGrammarState(e,t)}}}var Kz=Uz({langs:dI,themes:fI,engine:()=>(0,BI.createOnigurumaEngine)(D(()=>import(`./wasm-BnjxR4X6.js`),[]))}),{codeToHtml:qz,codeToHast:Jz,codeToTokens:Yz,codeToTokensBase:Xz,codeToTokensWithThemes:Zz,getSingletonHighlighter:Qz,getLastGrammarState:$z}=Gz(Kz,{guessEmbeddedLanguages:sz}),eB=4294967295,tB=class{regexps;constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:i}=t;if(!i)throw Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if(typeof e!=`string`)return e;let t=r?.get(e);if(t){if(t instanceof RegExp)return t;if(n)return null;throw t}try{let t=i(e);return r?.set(e,t),t}catch(t){if(r?.set(e,t),n)return null;throw t}})}findNextMatchSync(e,t,n){let r=typeof e==`string`?e:e.content,i=[];function a(e,t,n=0){return{index:e,captureIndices:t.indices.map(e=>e==null?{start:eB,end:eB,length:0}:{start:e[0]+n,end:e[1]+n,length:e[1]-e[0]})}}for(let e=0;e<this.regexps.length;e++){let n=this.regexps[e];if(n)try{n.lastIndex=t;let o=n.exec(r);if(!o)continue;if(o.index===t)return a(e,o,0);i.push([e,o,0])}catch(e){if(this.options.forgiving)continue;throw e}}if(i.length){let e=Math.min(...i.map(e=>e[1].index));for(let[t,n,r]of i)if(n.index===e)return a(t,n,r)}return null}};function nB(e){if([...e].length!==1)throw Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function rB(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var iB=new Set([`alnum`,`alpha`,`ascii`,`blank`,`cntrl`,`digit`,`graph`,`lower`,`print`,`punct`,`space`,`upper`,`word`,`xdigit`]),X=String.raw;function aB(e,t){if(e==null)throw Error(t??`Value expected`);return e}var oB=X`\[\^?`,sB=`c.? | C(?:-.?)?|${X`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${X`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${X`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${X`o\{[^\}]*\}?`}|${X`\d{1,3}`}`,cB=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,lB=new RegExp(X`
|
|
45
45
|
\\ (?:
|
|
46
|
-
${
|
|
46
|
+
${sB}
|
|
47
47
|
| [gk]<[^>]*>?
|
|
48
48
|
| [gk]'[^']*'?
|
|
49
49
|
| .
|
|
@@ -60,20 +60,20 @@ import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{$ as r,$
|
|
|
60
60
|
)?
|
|
61
61
|
| \*[^\)]*\)?
|
|
62
62
|
)?
|
|
63
|
-
| (?:${
|
|
64
|
-
| ${
|
|
63
|
+
| (?:${cB.source})+
|
|
64
|
+
| ${oB}
|
|
65
65
|
| .
|
|
66
|
-
`.replace(/\s+/g,``),`gsu`),
|
|
66
|
+
`.replace(/\s+/g,``),`gsu`),uB=new RegExp(X`
|
|
67
67
|
\\ (?:
|
|
68
|
-
${
|
|
68
|
+
${sB}
|
|
69
69
|
| .
|
|
70
70
|
)
|
|
71
71
|
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
72
|
-
| ${
|
|
72
|
+
| ${oB}
|
|
73
73
|
| &&
|
|
74
74
|
| .
|
|
75
|
-
`.replace(/\s+/g,``),`gsu`);function
|
|
76
|
-
`,r);return{lastIndex:e===-1?t.length:e}}if(/^\s$/.test(n)){let e=/\s+/y;return e.lastIndex=r,{lastIndex:e.exec(t)?e.lastIndex:r}}}return n===`.`?{token:xB(`dot`,n)}:n===`^`||n===`$`?{token:mB(e.singleline?{"^":X`\A`,$:X`\Z`}[n]:n,n)}:n===`|`?{token:pB(n)}:aB.test(n)?{tokens:VB(n)}:{token:gB($z(n),n)}}function uB(e,t,n){let r=[bB(t[1]===`^`,t)],i=1,a;for(sB.lastIndex=n;a=sB.exec(e);){let e=a[0];if(e[0]===`[`&&e[1]!==`:`)i++,r.push(bB(e[1]===`^`,e));else if(e===`]`){if(r.at(-1).type===`CharacterClassOpen`)r.push(gB(93,e));else if(i--,r.push(_B(e)),!i)break}else{let t=dB(e);Array.isArray(t)?r.push(...t):r.push(t)}}return{tokens:r,lastIndex:sB.lastIndex||e.length}}function dB(e){if(e[0]===`\\`)return fB(e,{inCharClass:!0});if(e[0]===`[`){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!tB.has(t.groups.name))throw Error(`Invalid POSIX class "${e}"`);return xB(`posix`,e,{value:t.groups.name,negate:!!t.groups.negate})}return e===`-`?vB(e):e===`&&`?yB(e):gB($z(e),e)}function fB(e,{inCharClass:t}){let n=e[1];if(n===`c`||n===`C`)return jB(e);if(`dDhHsSwW`.includes(n))return FB(e);if(e.startsWith(X`\o{`))throw Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw Error(`Incomplete or invalid Unicode property "${e}"`);return IB(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let t=e.split(/\\x/).slice(1).map(e=>parseInt(e,16)),n=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(t)),r=new TextEncoder;return[...n].map(e=>{let t=[...r.encode(e)].map(e=>`\\x${e.toString(16)}`).join(``);return gB($z(e),t)})}catch{throw Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n===`u`||n===`x`)return gB(zB(e),e);if(AB.has(n))return gB(AB.get(n),e);if(/\d/.test(n))return CB(t,e);if(e===`\\`)throw Error(X`Incomplete escape "\"`);if(n===`M`)throw Error(`Unsupported meta "${e}"`);if([...e].length===2)return gB(e.codePointAt(1),e);throw Error(`Unexpected escape "${e}"`)}function pB(e){return{type:`Alternator`,raw:e}}function mB(e,t){return{type:`Assertion`,kind:e,raw:t}}function hB(e){return{type:`Backreference`,raw:e}}function gB(e,t){return{type:`Character`,value:e,raw:t}}function _B(e){return{type:`CharacterClassClose`,raw:e}}function vB(e){return{type:`CharacterClassHyphen`,raw:e}}function yB(e){return{type:`CharacterClassIntersector`,raw:e}}function bB(e,t){return{type:`CharacterClassOpen`,negate:e,raw:t}}function xB(e,t,n={}){return{type:`CharacterSet`,kind:e,...n,raw:t}}function SB(e,t,n={}){return e===`keep`?{type:`Directive`,kind:e,raw:t}:{type:`Directive`,kind:e,flags:nB(n.flags),raw:t}}function CB(e,t){return{type:`EscapedNumber`,inCharClass:e,raw:t}}function wB(e){return{type:`GroupClose`,raw:e}}function TB(e,t,n={}){return{type:`GroupOpen`,kind:e,...n,raw:t}}function EB(e,t,n,r){return{type:`NamedCallout`,kind:e,tag:t,arguments:n,raw:r}}function DB(e,t,n,r){return{type:`Quantifier`,kind:e,min:t,max:n,raw:r}}function OB(e){return{type:`Subroutine`,raw:e}}var kB=new Set([`COUNT`,`CMP`,`ERROR`,`FAIL`,`MAX`,`MISMATCH`,`SKIP`,`TOTAL_COUNT`]),AB=new Map([[`a`,7],[`b`,8],[`e`,27],[`f`,12],[`n`,10],[`r`,13],[`t`,9],[`v`,11]]);function jB(e){let t=e[1]===`c`?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw Error(`Unsupported control character "${e}"`);return gB($z(t.toUpperCase())-64,e)}function MB(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??=``;let i=(t.getCurrentModX()||n.includes(`x`))&&!r.includes(`x`),a=LB(n),o=LB(r),s={};if(a&&(s.enable=a),o&&(s.disable=o),e.endsWith(`)`))return t.replaceCurrentModX(i),SB(`flags`,e,{flags:s});if(e.endsWith(`:`))return t.pushModX(i),t.numOpenGroups++,TB(`group`,e,{...(a||o)&&{flags:s}});throw Error(`Unexpected flag modifier "${e}"`)}function NB(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:i}=t.groups;if(!n)throw Error(`Invalid named callout "${e}"`);if(r===``)throw Error(`Named callout tag with empty value not allowed "${e}"`);let a=i?i.split(`,`).filter(e=>e!==``).map(e=>/^[+-]?\d+$/.test(e)?+e:e):[],[o,s,c]=a,l=kB.has(n)?n.toLowerCase():`custom`;switch(l){case`fail`:case`mismatch`:case`skip`:if(a.length>0)throw Error(`Named callout arguments not allowed "${a}"`);break;case`error`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(typeof o==`string`)throw Error(`Named callout argument must be a number "${o}"`);break;case`max`:if(!a.length||a.length>2)throw Error(`Named callout must have one or two arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(a.length===2&&(typeof s==`number`||!/^[<>X]$/.test(s)))throw Error(`Named callout optional argument two must be '<', '>', or 'X' "${s}"`);break;case`count`:case`total_count`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof o==`number`||!/^[<>X]$/.test(o)))throw Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case`cmp`:if(a.length!==3)throw Error(`Named callout must have three arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(typeof s==`number`||!/^(?:[<>!=]=|[<>])$/.test(s))throw Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${s}"`);if(typeof c==`string`&&!/^[A-Za-z_]\w*$/.test(c))throw Error(`Named callout argument three must be a tag or number "${c}"`);break;case`custom`:throw Error(`Undefined callout name "${n}"`);default:throw Error(`Unexpected named callout kind "${l}"`)}return EB(l,r??null,i?.split(`,`)??null,e)}function PB(e){let t=null,n,r;if(e[0]===`{`){let{minStr:i,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+i>o||a&&+a>o)throw Error(`Quantifier value unsupported in Oniguruma`);if(n=+i,r=a===void 0?+i:a===``?1/0:+a,n>r&&(t=`possessive`,[n,r]=[r,n]),e.endsWith(`?`)){if(t===`possessive`)throw Error(`Unsupported possessive interval quantifier chain with "?"`);t=`lazy`}else t||=`greedy`}else n=+(e[0]===`+`),r=e[0]===`?`?1:1/0,t=e[1]===`+`?`possessive`:e[1]===`?`?`lazy`:`greedy`;return DB(t,n,r,e)}function FB(e){let t=e[1].toLowerCase();return xB({d:`digit`,h:`hex`,s:`space`,w:`word`}[t],e,{negate:e[1]!==t})}function IB(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return xB(`property`,e,{value:r,negate:t===`P`&&!n||t===`p`&&!!n})}function LB(e){let t={};return e.includes(`i`)&&(t.ignoreCase=!0),e.includes(`m`)&&(t.dotAll=!0),e.includes(`x`)&&(t.extended=!0),Object.keys(t).length?t:null}function RB(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!`imxDPSWy`.includes(r))throw Error(`Invalid flag "${r}"`);if(r===`y`){if(!/^y{[gw]}/.test(e.slice(n)))throw Error(`Invalid or unspecified flag "y" mode`);t.textSegmentMode=e[n+2]===`g`?`grapheme`:`word`,n+=3;continue}t[{i:`ignoreCase`,m:`dotAll`,x:`extended`,D:`digitIsAscii`,P:`posixIsAscii`,S:`spaceIsAscii`,W:`wordIsAscii`}[r]]=!0}return t}function zB(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw Error(`Incomplete or invalid escape "${e}"`);let t=e[2]===`{`?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function BB(e,t){let{raw:n,inCharClass:r}=e,i=n.slice(1);if(!r&&(i!==`0`&&i.length===1||i[0]!==`0`&&+i<=t))return[hB(n)];let a=[],o=i.match(/^[0-7]+|\d/g);for(let e=0;e<o.length;e++){let t=o[e],r;if(e===0&&t!==`8`&&t!==`9`){if(r=parseInt(t,8),r>127)throw Error(X`Octal encoded byte above 177 unsupported "${n}"`)}else r=$z(t);a.push(gB(r,(e===0?`\\`:``)+t))}return a}function VB(e){let t=[],n=new RegExp(aB,`gy`),r;for(;r=n.exec(e);){let e=r[0];if(e[0]===`{`){let r=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(e);if(r){let{min:i,max:a}=r.groups;if(+i>+a&&e.endsWith(`?`)){n.lastIndex--,t.push(PB(e.slice(0,-1)));continue}}}t.push(PB(e))}return t}function HB(e,t){if(!Array.isArray(e.body))throw Error(`Expected node with body array`);if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(e=>t[e]===n[e])}function UB(e){return WB.has(e.type)}var WB=new Set([`AbsenceFunction`,`Backreference`,`CapturingGroup`,`Character`,`CharacterClass`,`CharacterSet`,`Group`,`Quantifier`,`Subroutine`]);function GB(e,t={}){let n={flags:``,normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=cB(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),i=(e,t)=>{let n=r.tokens[a.nextIndex];switch(a.parent=e,a.nextIndex++,n.type){case`Alternator`:return tV();case`Assertion`:return KB(n);case`Backreference`:return qB(n,a);case`Character`:return aV(n.value,{useLastValid:!!t.isCheckingRangeEnd});case`CharacterClassHyphen`:return JB(n,a,t);case`CharacterClassOpen`:return YB(n,a,t);case`CharacterSet`:return XB(n,a);case`Directive`:return lV(n.kind,{flags:n.flags});case`GroupOpen`:return ZB(n,a,t);case`NamedCallout`:return pV(n.kind,n.tag,n.arguments);case`Quantifier`:return QB(n,a);case`Subroutine`:return $B(n,a);default:throw Error(`Unexpected token type "${n.type}"`)}},a={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:i},o=gV(uV(r.flags)),s=o.body[0];for(;a.nextIndex<r.tokens.length;){let e=i(s,{});e.type===`Alternative`?(o.body.push(e),s=e):s.body.push(e)}let{capturingGroups:c,hasNumberedRef:l,namedGroupsByName:u,subroutines:d}=a;if(l&&u.size&&!n.rules.captureGroup)throw Error(`Numbered backref/subroutine not allowed when using named capture`);for(let{ref:e}of d)if(typeof e==`number`){if(e>c.length)throw Error(`Subroutine uses a group number that's not defined`);e&&(c[e-1].isSubroutined=!0)}else if(u.has(e)){if(u.get(e).length>1)throw Error(X`Subroutine uses a duplicate group name "\g<${e}>"`);u.get(e)[0].isSubroutined=!0}else throw Error(X`Subroutine uses a group name that's not defined "\g<${e}>"`);return o}function KB({kind:e}){return nV(nB({"^":`line_start`,$:`line_end`,"\\A":`string_start`,"\\b":`word_boundary`,"\\B":`word_boundary`,"\\G":`search_start`,"\\y":`text_segment_boundary`,"\\Y":`text_segment_boundary`,"\\z":`string_end`,"\\Z":`string_end_newline`}[e],`Unexpected assertion kind "${e}"`),{negate:e===X`\B`||e===X`\Y`})}function qB({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),i=(n,r=!1)=>{let i=t.capturingGroups.length,a=!1;if(n>i)if(t.skipBackrefValidation)a=!0;else throw Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,rV(r?i+1-n:n,{orphan:a})};if(n){let n=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(n)return i(+n.groups.num,!!n.groups.sign);if(/[-+]/.test(r))throw Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw Error(`Group name not defined to the left "${e}"`);return rV(r)}return i(+r)}function JB(e,t,n){let{tokens:r,walk:i}=t,a=t.parent,o=a.body.at(-1),s=r[t.nextIndex];if(!n.isCheckingRangeEnd&&o&&o.type!==`CharacterClass`&&o.type!==`CharacterClassRange`&&s&&s.type!==`CharacterClassOpen`&&s.type!==`CharacterClassClose`&&s.type!==`CharacterClassIntersector`){let e=i(a,{...n,isCheckingRangeEnd:!0});if(o.type===`Character`&&e.type===`Character`)return a.body.pop(),sV(o,e);throw Error(`Invalid character class range`)}return aV($z(`-`))}function YB({negate:e},t,n){let{tokens:r,walk:i}=t,a=r[t.nextIndex],o=[oV()],s=DV(a);for(;s.type!==`CharacterClassClose`;){if(s.type===`CharacterClassIntersector`)o.push(oV()),t.nextIndex++;else{let e=o.at(-1);e.body.push(i(e,n))}s=DV(r[t.nextIndex],a)}let c=oV({negate:e});return o.length===1?c.body=o[0].body:(c.kind=`intersection`,c.body=o.map(e=>e.body.length===1?e.body[0]:e)),t.nextIndex++,c}function XB({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o}=r;if(e===`property`){let r=EV(n);if(tB.has(r)&&!o?.has(r))e=`posix`,n=r;else return vV(n,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o})}return e===`posix`?mV(n,{negate:t}):cV(e,{negate:t})}function ZB(e,t,n){let{tokens:r,capturingGroups:i,namedGroupsByName:a,skipLookbehindValidation:o,walk:s}=t,c=yV(e),l=c.type===`AbsenceFunction`,u=CV(c),d=u&&c.negate;if(c.type===`CapturingGroup`&&(i.push(c),c.name&&eB(a,c.name,[]).push(c)),l&&n.isInAbsenceFunction)throw Error(`Nested absence function not supported by Oniguruma`);let f=OV(r[t.nextIndex]);for(;f.type!==`GroupClose`;){if(f.type===`Alternator`)c.body.push(tV()),t.nextIndex++;else{let e=c.body.at(-1),t=s(e,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(e.body.push(t),(u||n.isInLookbehind)&&!o){let e=`Lookbehind includes a pattern not allowed by Oniguruma`;if(d||n.isInNegLookbehind){if(SV(t)||t.type===`CapturingGroup`)throw Error(e)}else if(SV(t)||CV(t)&&t.negate)throw Error(e)}}f=OV(r[t.nextIndex])}return t.nextIndex++,c}function QB({kind:e,min:t,max:n},r){let i=r.parent,a=i.body.at(-1);if(!a||!UB(a))throw Error(`Quantifier requires a repeatable token`);let o=hV(e,t,n,a);return i.body.pop(),o}function $B({raw:e},t){let{capturingGroups:n,subroutines:r}=t,i=e.slice(3,-1),a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(a){let e=+a.groups.num,r=n.length;if(t.hasNumberedRef=!0,i={"":e,"+":r+e,"-":r+1-e}[a.groups.sign],i<1)throw Error(`Invalid subroutine number`)}else i===`0`&&(i=0);let o=_V(i);return r.push(o),o}function eV(e,t){if(e!==`repeater`)throw Error(`Unexpected absence function kind "${e}"`);return{type:`AbsenceFunction`,kind:e,body:bV(t?.body)}}function tV(e){return{type:`Alternative`,body:xV(e?.body)}}function nV(e,t){let n={type:`Assertion`,kind:e};return(e===`word_boundary`||e===`text_segment_boundary`)&&(n.negate=!!t?.negate),n}function rV(e,t){let n=!!t?.orphan;return{type:`Backreference`,ref:e,...n&&{orphan:n}}}function iV(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!wV(n.name))throw Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:`CapturingGroup`,number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:bV(t?.body)}}function aV(e,t){let n={useLastValid:!1,...t};if(e>1114111){let t=e.toString(16);if(n.useLastValid)e=1114111;else throw Error(e>1310719?`Invalid code point out of range "\\x{${t}}"`:`Invalid code point out of range in JS "\\x{${t}}"`)}return{type:`Character`,value:e}}function oV(e){let t={kind:`union`,negate:!1,...e};return{type:`CharacterClass`,kind:t.kind,negate:t.negate,body:xV(e?.body)}}function sV(e,t){if(t.value<e.value)throw Error(`Character class range out of order`);return{type:`CharacterClassRange`,min:e,max:t}}function cV(e,t){let n=!!t?.negate,r={type:`CharacterSet`,kind:e};return(e===`digit`||e===`hex`||e===`newline`||e===`space`||e===`word`)&&(r.negate=n),(e===`text_segment`||e===`newline`&&!n)&&(r.variableLength=!0),r}function lV(e,t={}){if(e===`keep`)return{type:`Directive`,kind:e};if(e===`flags`)return{type:`Directive`,kind:e,flags:nB(t.flags)};throw Error(`Unexpected directive kind "${e}"`)}function uV(e){return{type:`Flags`,...e}}function dV(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw Error(`Atomic group cannot have flags`);return{type:`Group`,...t&&{atomic:t},...n&&{flags:n},body:bV(e?.body)}}function fV(e){let t={behind:!1,negate:!1,...e};return{type:`LookaroundAssertion`,kind:t.behind?`lookbehind`:`lookahead`,negate:t.negate,body:bV(e?.body)}}function pV(e,t,n){return{type:`NamedCallout`,kind:e,tag:t,arguments:n}}function mV(e,t){let n=!!t?.negate;if(!tB.has(e))throw Error(`Invalid POSIX class "${e}"`);return{type:`CharacterSet`,kind:`posix`,value:e,negate:n}}function hV(e,t,n,r){if(t>n)throw Error(`Invalid reversed quantifier range`);return{type:`Quantifier`,kind:e,min:t,max:n,body:r}}function gV(e,t){return{type:`Regex`,body:bV(t?.body),flags:e}}function _V(e){return{type:`Subroutine`,ref:e}}function vV(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(EV(e));if(!r){if(n.normalizeUnknownPropertyNames)r=TV(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw Error(X`Invalid Unicode property "\p{${e}}"`)}return{type:`CharacterSet`,kind:`property`,value:r??e,negate:n.negate}}function yV({flags:e,kind:t,name:n,negate:r,number:i}){switch(t){case`absence_repeater`:return eV(`repeater`);case`atomic`:return dV({atomic:!0});case`capturing`:return iV(i,{name:n});case`group`:return dV({flags:e});case`lookahead`:case`lookbehind`:return fV({behind:t===`lookbehind`,negate:r});default:throw Error(`Unexpected group kind "${t}"`)}}function bV(e){if(e===void 0)e=[tV()];else if(!Array.isArray(e)||!e.length||!e.every(e=>e.type===`Alternative`))throw Error(`Invalid body; expected array of one or more Alternative nodes`);return e}function xV(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(e=>!!e.type))throw Error(`Invalid body; expected array of nodes`);return e}function SV(e){return e.type===`LookaroundAssertion`&&e.kind===`lookahead`}function CV(e){return e.type===`LookaroundAssertion`&&e.kind===`lookbehind`}function wV(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function TV(e){return e.trim().replace(/[- _]+/g,`_`).replace(/[A-Z][a-z]+(?=[A-Z])/g,`$&_`).replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function EV(e){return e.replace(/[- _]+/g,``).toLowerCase()}function DV(e,t){return nB(e,`${t?.type===`Character`&&t.value===93?`Empty`:`Unclosed`} character class`)}function OV(e){return nB(e,`Unclosed group`)}function kV(e,t,n=null){function r(e,t){for(let n=0;n<e.length;n++){let r=i(e[n],t,n,e);n=Math.max(-1,n+r)}}function i(a,o=null,s=null,c=null){let l=0,u=!1,d={node:a,parent:o,key:s,container:c,root:e,remove(){AV(c).splice(Math.max(0,jV(s)+l),1),l--,u=!0},removeAllNextSiblings(){return AV(c).splice(jV(s)+1)},removeAllPrevSiblings(){let e=jV(s)+l;return l-=e,AV(c).splice(0,Math.max(0,e))},replaceWith(e,t={}){let n=!!t.traverse;c?c[Math.max(0,jV(s)+l)]=e:nB(o,`Can't replace root node`)[s]=e,n&&i(e,o,s,c),u=!0},replaceWithMultiple(e,t={}){let n=!!t.traverse;if(AV(c).splice(Math.max(0,jV(s)+l),1,...e),l+=e.length-1,n){let t=0;for(let n=0;n<e.length;n++)t+=i(e[n],o,jV(s)+n+t,c)}u=!0},skip(){u=!0}},{type:f}=a,p=t[`*`],m=t[f],h=typeof p==`function`?p:p?.enter,g=typeof m==`function`?m:m?.enter;if(h?.(d,n),g?.(d,n),!u)switch(f){case`AbsenceFunction`:case`CapturingGroup`:case`Group`:r(a.body,a);break;case`Alternative`:case`CharacterClass`:r(a.body,a);break;case`Assertion`:case`Backreference`:case`Character`:case`CharacterSet`:case`Directive`:case`Flags`:case`NamedCallout`:case`Subroutine`:break;case`CharacterClassRange`:i(a.min,a,`min`),i(a.max,a,`max`);break;case`LookaroundAssertion`:r(a.body,a);break;case`Quantifier`:i(a.body,a,`body`);break;case`Regex`:r(a.body,a),i(a.flags,a,`flags`);break;default:throw Error(`Unexpected node type "${f}"`)}return m?.exit?.(d,n),p?.exit?.(d,n),l}return i(e),e}function AV(e){if(!Array.isArray(e))throw Error(`Container expected`);return e}function jV(e){if(typeof e!=`number`)throw Error(`Numeric key expected`);return e}var MV=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function NV(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function PV(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var FV=Object.freeze({DEFAULT:`DEFAULT`,CHAR_CLASS:`CHAR_CLASS`});function IV(e,t,n,r){let i=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,`gsu`),a=[!1],o=0,s=``;for(let t of e.matchAll(i)){let{0:e,groups:{$skip:i}}=t;if(!i&&(!r||r===FV.DEFAULT==!o)){n instanceof Function?s+=n(t,{context:o?FV.CHAR_CLASS:FV.DEFAULT,negated:a[a.length-1]}):s+=n;continue}e[0]===`[`?(o++,a.push(e[1]===`^`)):e===`]`&&o&&(o--,a.pop()),s+=e}return s}function LV(e,t,n,r){IV(e,t,n,r)}function RV(e,t,n=0,r){if(!new RegExp(t,`su`).test(e))return null;let i=RegExp(`${t}|(?<$skip>\\\\?.)`,`gsu`);i.lastIndex=n;let a=0,o;for(;o=i.exec(e);){let{0:e,groups:{$skip:t}}=o;if(!t&&(!r||r===FV.DEFAULT==!a))return o;e===`[`?a++:e===`]`&&a&&a--,i.lastIndex==o.index&&i.lastIndex++}return null}function zV(e,t,n){return!!RV(e,t,0,n)}function BV(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,i=0,a=1,o;for(;o=n.exec(e);){let[e]=o;if(e===`[`)i++;else if(i)e===`]`&&i--;else if(e===`(`)a++;else if(e===`)`&&(a--,!a)){r=o.index;break}}return e.slice(t,r)}var VV=new RegExp(String.raw`(?<noncapturingStart>${MV})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,`gsu`);function HV(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let i=[0],a=[],o=0,s=0,c=NaN,l;do{l=!1;let t=0,u=0,d=!1,f;for(VV.lastIndex=Number.isNaN(c)?0:c+7;f=VV.exec(e);){let{0:p,index:m,groups:{capturingStart:h,noncapturingStart:g}}=f;if(p===`[`)t++;else if(t)p===`]`&&t--;else if(p===`(?>`&&!d)c=m,d=!0;else if(d&&g)u++;else if(h)d?u++:(o++,i.push(o+s));else if(p===`)`&&d){if(!u){s++;let t=o+s;if(e=`${e.slice(0,c)}(?:(?=(${e.slice(c+3,m)}))<$$${t}>)${e.slice(m+1)}`,l=!0,a.push(t),NV(n,t),r.size){let e=new Map;r.forEach((n,r)=>{e.set(r>=t?r+1:r,n.map(e=>e>=t?e+1:e))}),r=e}break}u--}}}while(l);return n.push(...a),e=IV(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:t,wrappedBackrefNum:n}})=>{if(t){let n=+t;if(n>i.length-1)throw Error(`Backref "${e}" greater than number of captures`);return`\\${i[n]}`}return`\\${n}`},FV.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var UV=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,WV=new RegExp(String.raw`
|
|
75
|
+
`.replace(/\s+/g,``),`gsu`);function dB(e,t={}){let n={flags:``,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!=`string`)throw Error(`String expected as pattern`);let r=VB(n.flags),i=[r.extended],a={captureGroup:n.rules.captureGroup,getCurrentModX(){return i.at(-1)},numOpenGroups:0,popModX(){i.pop()},pushModX(e){i.push(e)},replaceCurrentModX(e){i[i.length-1]=e},singleline:n.rules.singleline},o=[],s;for(lB.lastIndex=0;s=lB.exec(e);){let t=fB(a,e,s[0],lB.lastIndex);t.tokens?o.push(...t.tokens):t.token&&o.push(t.token),t.lastIndex!==void 0&&(lB.lastIndex=t.lastIndex)}let c=[],l=0;o.filter(e=>e.type===`GroupOpen`).forEach(e=>{e.kind===`capturing`?e.number=++l:e.raw===`(`&&c.push(e)}),l||c.forEach((e,t)=>{e.kind=`capturing`,e.number=t+1});let u=l||c.length;return{tokens:o.map(e=>e.type===`EscapedNumber`?UB(e,u):e).flat(),flags:r}}function fB(e,t,n,r){let[i,a]=n;if(n===`[`||n===`[^`){let e=pB(t,n,r);return{tokens:e.tokens,lastIndex:e.lastIndex}}if(i===`\\`){if(`AbBGyYzZ`.includes(a))return{token:_B(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:jB(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:vB(n)}}if(a===`K`)return{token:TB(`keep`,n)};if(a===`N`||a===`R`)return{token:wB(`newline`,n,{negate:a===`N`})};if(a===`O`)return{token:wB(`any`,n)};if(a===`X`)return{token:wB(`text_segment`,n)};let e=hB(n,{inCharClass:!1});return Array.isArray(e)?{tokens:e}:{token:e}}if(i===`(`){if(a===`*`)return{token:IB(n)};if(n===`(?{`)throw Error(`Unsupported callout "${n}"`);if(n.startsWith(`(?#`)){if(t[r]!==`)`)throw Error(`Unclosed comment group "(?#"`);return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:FB(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n===`(`&&!e.captureGroup||n===`(?:`)return{token:OB(`group`,n)};if(n===`(?>`)return{token:OB(`atomic`,n)};if(n===`(?=`||n===`(?!`||n===`(?<=`||n===`(?<!`)return{token:OB(n[2]===`<`?`lookbehind`:`lookahead`,n,{negate:n.endsWith(`!`)})};if(n===`(`&&e.captureGroup||n.startsWith(`(?<`)&&n.endsWith(`>`)||n.startsWith(`(?'`)&&n.endsWith(`'`))return{token:OB(`capturing`,n,{...n!==`(`&&{name:n.slice(3,-1)}})};if(n.startsWith(`(?~`)){if(n===`(?~|`)throw Error(`Unsupported absence function kind "${n}"`);return{token:OB(`absence_repeater`,n)}}throw Error(n===`(?(`?`Unsupported conditional "${n}"`:`Invalid or unsupported group option "${n}"`)}if(n===`)`){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw Error(`Unmatched ")"`);return{token:DB(n)}}if(e.getCurrentModX()){if(n===`#`){let e=t.indexOf(`
|
|
76
|
+
`,r);return{lastIndex:e===-1?t.length:e}}if(/^\s$/.test(n)){let e=/\s+/y;return e.lastIndex=r,{lastIndex:e.exec(t)?e.lastIndex:r}}}return n===`.`?{token:wB(`dot`,n)}:n===`^`||n===`$`?{token:_B(e.singleline?{"^":X`\A`,$:X`\Z`}[n]:n,n)}:n===`|`?{token:gB(n)}:cB.test(n)?{tokens:WB(n)}:{token:yB(nB(n),n)}}function pB(e,t,n){let r=[CB(t[1]===`^`,t)],i=1,a;for(uB.lastIndex=n;a=uB.exec(e);){let e=a[0];if(e[0]===`[`&&e[1]!==`:`)i++,r.push(CB(e[1]===`^`,e));else if(e===`]`){if(r.at(-1).type===`CharacterClassOpen`)r.push(yB(93,e));else if(i--,r.push(bB(e)),!i)break}else{let t=mB(e);Array.isArray(t)?r.push(...t):r.push(t)}}return{tokens:r,lastIndex:uB.lastIndex||e.length}}function mB(e){if(e[0]===`\\`)return hB(e,{inCharClass:!0});if(e[0]===`[`){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!iB.has(t.groups.name))throw Error(`Invalid POSIX class "${e}"`);return wB(`posix`,e,{value:t.groups.name,negate:!!t.groups.negate})}return e===`-`?xB(e):e===`&&`?SB(e):yB(nB(e),e)}function hB(e,{inCharClass:t}){let n=e[1];if(n===`c`||n===`C`)return PB(e);if(`dDhHsSwW`.includes(n))return RB(e);if(e.startsWith(X`\o{`))throw Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw Error(`Incomplete or invalid Unicode property "${e}"`);return zB(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let t=e.split(/\\x/).slice(1).map(e=>parseInt(e,16)),n=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(t)),r=new TextEncoder;return[...n].map(e=>{let t=[...r.encode(e)].map(e=>`\\x${e.toString(16)}`).join(``);return yB(nB(e),t)})}catch{throw Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n===`u`||n===`x`)return yB(HB(e),e);if(NB.has(n))return yB(NB.get(n),e);if(/\d/.test(n))return EB(t,e);if(e===`\\`)throw Error(X`Incomplete escape "\"`);if(n===`M`)throw Error(`Unsupported meta "${e}"`);if([...e].length===2)return yB(e.codePointAt(1),e);throw Error(`Unexpected escape "${e}"`)}function gB(e){return{type:`Alternator`,raw:e}}function _B(e,t){return{type:`Assertion`,kind:e,raw:t}}function vB(e){return{type:`Backreference`,raw:e}}function yB(e,t){return{type:`Character`,value:e,raw:t}}function bB(e){return{type:`CharacterClassClose`,raw:e}}function xB(e){return{type:`CharacterClassHyphen`,raw:e}}function SB(e){return{type:`CharacterClassIntersector`,raw:e}}function CB(e,t){return{type:`CharacterClassOpen`,negate:e,raw:t}}function wB(e,t,n={}){return{type:`CharacterSet`,kind:e,...n,raw:t}}function TB(e,t,n={}){return e===`keep`?{type:`Directive`,kind:e,raw:t}:{type:`Directive`,kind:e,flags:aB(n.flags),raw:t}}function EB(e,t){return{type:`EscapedNumber`,inCharClass:e,raw:t}}function DB(e){return{type:`GroupClose`,raw:e}}function OB(e,t,n={}){return{type:`GroupOpen`,kind:e,...n,raw:t}}function kB(e,t,n,r){return{type:`NamedCallout`,kind:e,tag:t,arguments:n,raw:r}}function AB(e,t,n,r){return{type:`Quantifier`,kind:e,min:t,max:n,raw:r}}function jB(e){return{type:`Subroutine`,raw:e}}var MB=new Set([`COUNT`,`CMP`,`ERROR`,`FAIL`,`MAX`,`MISMATCH`,`SKIP`,`TOTAL_COUNT`]),NB=new Map([[`a`,7],[`b`,8],[`e`,27],[`f`,12],[`n`,10],[`r`,13],[`t`,9],[`v`,11]]);function PB(e){let t=e[1]===`c`?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw Error(`Unsupported control character "${e}"`);return yB(nB(t.toUpperCase())-64,e)}function FB(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??=``;let i=(t.getCurrentModX()||n.includes(`x`))&&!r.includes(`x`),a=BB(n),o=BB(r),s={};if(a&&(s.enable=a),o&&(s.disable=o),e.endsWith(`)`))return t.replaceCurrentModX(i),TB(`flags`,e,{flags:s});if(e.endsWith(`:`))return t.pushModX(i),t.numOpenGroups++,OB(`group`,e,{...(a||o)&&{flags:s}});throw Error(`Unexpected flag modifier "${e}"`)}function IB(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:i}=t.groups;if(!n)throw Error(`Invalid named callout "${e}"`);if(r===``)throw Error(`Named callout tag with empty value not allowed "${e}"`);let a=i?i.split(`,`).filter(e=>e!==``).map(e=>/^[+-]?\d+$/.test(e)?+e:e):[],[o,s,c]=a,l=MB.has(n)?n.toLowerCase():`custom`;switch(l){case`fail`:case`mismatch`:case`skip`:if(a.length>0)throw Error(`Named callout arguments not allowed "${a}"`);break;case`error`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(typeof o==`string`)throw Error(`Named callout argument must be a number "${o}"`);break;case`max`:if(!a.length||a.length>2)throw Error(`Named callout must have one or two arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(a.length===2&&(typeof s==`number`||!/^[<>X]$/.test(s)))throw Error(`Named callout optional argument two must be '<', '>', or 'X' "${s}"`);break;case`count`:case`total_count`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof o==`number`||!/^[<>X]$/.test(o)))throw Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case`cmp`:if(a.length!==3)throw Error(`Named callout must have three arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(typeof s==`number`||!/^(?:[<>!=]=|[<>])$/.test(s))throw Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${s}"`);if(typeof c==`string`&&!/^[A-Za-z_]\w*$/.test(c))throw Error(`Named callout argument three must be a tag or number "${c}"`);break;case`custom`:throw Error(`Undefined callout name "${n}"`);default:throw Error(`Unexpected named callout kind "${l}"`)}return kB(l,r??null,i?.split(`,`)??null,e)}function LB(e){let t=null,n,r;if(e[0]===`{`){let{minStr:i,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+i>o||a&&+a>o)throw Error(`Quantifier value unsupported in Oniguruma`);if(n=+i,r=a===void 0?+i:a===``?1/0:+a,n>r&&(t=`possessive`,[n,r]=[r,n]),e.endsWith(`?`)){if(t===`possessive`)throw Error(`Unsupported possessive interval quantifier chain with "?"`);t=`lazy`}else t||=`greedy`}else n=+(e[0]===`+`),r=e[0]===`?`?1:1/0,t=e[1]===`+`?`possessive`:e[1]===`?`?`lazy`:`greedy`;return AB(t,n,r,e)}function RB(e){let t=e[1].toLowerCase();return wB({d:`digit`,h:`hex`,s:`space`,w:`word`}[t],e,{negate:e[1]!==t})}function zB(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return wB(`property`,e,{value:r,negate:t===`P`&&!n||t===`p`&&!!n})}function BB(e){let t={};return e.includes(`i`)&&(t.ignoreCase=!0),e.includes(`m`)&&(t.dotAll=!0),e.includes(`x`)&&(t.extended=!0),Object.keys(t).length?t:null}function VB(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!`imxDPSWy`.includes(r))throw Error(`Invalid flag "${r}"`);if(r===`y`){if(!/^y{[gw]}/.test(e.slice(n)))throw Error(`Invalid or unspecified flag "y" mode`);t.textSegmentMode=e[n+2]===`g`?`grapheme`:`word`,n+=3;continue}t[{i:`ignoreCase`,m:`dotAll`,x:`extended`,D:`digitIsAscii`,P:`posixIsAscii`,S:`spaceIsAscii`,W:`wordIsAscii`}[r]]=!0}return t}function HB(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw Error(`Incomplete or invalid escape "${e}"`);let t=e[2]===`{`?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function UB(e,t){let{raw:n,inCharClass:r}=e,i=n.slice(1);if(!r&&(i!==`0`&&i.length===1||i[0]!==`0`&&+i<=t))return[vB(n)];let a=[],o=i.match(/^[0-7]+|\d/g);for(let e=0;e<o.length;e++){let t=o[e],r;if(e===0&&t!==`8`&&t!==`9`){if(r=parseInt(t,8),r>127)throw Error(X`Octal encoded byte above 177 unsupported "${n}"`)}else r=nB(t);a.push(yB(r,(e===0?`\\`:``)+t))}return a}function WB(e){let t=[],n=new RegExp(cB,`gy`),r;for(;r=n.exec(e);){let e=r[0];if(e[0]===`{`){let r=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(e);if(r){let{min:i,max:a}=r.groups;if(+i>+a&&e.endsWith(`?`)){n.lastIndex--,t.push(LB(e.slice(0,-1)));continue}}}t.push(LB(e))}return t}function GB(e,t){if(!Array.isArray(e.body))throw Error(`Expected node with body array`);if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(e=>t[e]===n[e])}function KB(e){return qB.has(e.type)}var qB=new Set([`AbsenceFunction`,`Backreference`,`CapturingGroup`,`Character`,`CharacterClass`,`CharacterSet`,`Group`,`Quantifier`,`Subroutine`]);function JB(e,t={}){let n={flags:``,normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=dB(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),i=(e,t)=>{let n=r.tokens[a.nextIndex];switch(a.parent=e,a.nextIndex++,n.type){case`Alternator`:return iV();case`Assertion`:return YB(n);case`Backreference`:return XB(n,a);case`Character`:return cV(n.value,{useLastValid:!!t.isCheckingRangeEnd});case`CharacterClassHyphen`:return ZB(n,a,t);case`CharacterClassOpen`:return QB(n,a,t);case`CharacterSet`:return $B(n,a);case`Directive`:return fV(n.kind,{flags:n.flags});case`GroupOpen`:return eV(n,a,t);case`NamedCallout`:return gV(n.kind,n.tag,n.arguments);case`Quantifier`:return tV(n,a);case`Subroutine`:return nV(n,a);default:throw Error(`Unexpected token type "${n.type}"`)}},a={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:i},o=yV(pV(r.flags)),s=o.body[0];for(;a.nextIndex<r.tokens.length;){let e=i(s,{});e.type===`Alternative`?(o.body.push(e),s=e):s.body.push(e)}let{capturingGroups:c,hasNumberedRef:l,namedGroupsByName:u,subroutines:d}=a;if(l&&u.size&&!n.rules.captureGroup)throw Error(`Numbered backref/subroutine not allowed when using named capture`);for(let{ref:e}of d)if(typeof e==`number`){if(e>c.length)throw Error(`Subroutine uses a group number that's not defined`);e&&(c[e-1].isSubroutined=!0)}else if(u.has(e)){if(u.get(e).length>1)throw Error(X`Subroutine uses a duplicate group name "\g<${e}>"`);u.get(e)[0].isSubroutined=!0}else throw Error(X`Subroutine uses a group name that's not defined "\g<${e}>"`);return o}function YB({kind:e}){return aV(aB({"^":`line_start`,$:`line_end`,"\\A":`string_start`,"\\b":`word_boundary`,"\\B":`word_boundary`,"\\G":`search_start`,"\\y":`text_segment_boundary`,"\\Y":`text_segment_boundary`,"\\z":`string_end`,"\\Z":`string_end_newline`}[e],`Unexpected assertion kind "${e}"`),{negate:e===X`\B`||e===X`\Y`})}function XB({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),i=(n,r=!1)=>{let i=t.capturingGroups.length,a=!1;if(n>i)if(t.skipBackrefValidation)a=!0;else throw Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,oV(r?i+1-n:n,{orphan:a})};if(n){let n=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(n)return i(+n.groups.num,!!n.groups.sign);if(/[-+]/.test(r))throw Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw Error(`Group name not defined to the left "${e}"`);return oV(r)}return i(+r)}function ZB(e,t,n){let{tokens:r,walk:i}=t,a=t.parent,o=a.body.at(-1),s=r[t.nextIndex];if(!n.isCheckingRangeEnd&&o&&o.type!==`CharacterClass`&&o.type!==`CharacterClassRange`&&s&&s.type!==`CharacterClassOpen`&&s.type!==`CharacterClassClose`&&s.type!==`CharacterClassIntersector`){let e=i(a,{...n,isCheckingRangeEnd:!0});if(o.type===`Character`&&e.type===`Character`)return a.body.pop(),uV(o,e);throw Error(`Invalid character class range`)}return cV(nB(`-`))}function QB({negate:e},t,n){let{tokens:r,walk:i}=t,a=r[t.nextIndex],o=[lV()],s=AV(a);for(;s.type!==`CharacterClassClose`;){if(s.type===`CharacterClassIntersector`)o.push(lV()),t.nextIndex++;else{let e=o.at(-1);e.body.push(i(e,n))}s=AV(r[t.nextIndex],a)}let c=lV({negate:e});return o.length===1?c.body=o[0].body:(c.kind=`intersection`,c.body=o.map(e=>e.body.length===1?e.body[0]:e)),t.nextIndex++,c}function $B({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o}=r;if(e===`property`){let r=kV(n);if(iB.has(r)&&!o?.has(r))e=`posix`,n=r;else return xV(n,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o})}return e===`posix`?_V(n,{negate:t}):dV(e,{negate:t})}function eV(e,t,n){let{tokens:r,capturingGroups:i,namedGroupsByName:a,skipLookbehindValidation:o,walk:s}=t,c=SV(e),l=c.type===`AbsenceFunction`,u=EV(c),d=u&&c.negate;if(c.type===`CapturingGroup`&&(i.push(c),c.name&&rB(a,c.name,[]).push(c)),l&&n.isInAbsenceFunction)throw Error(`Nested absence function not supported by Oniguruma`);let f=jV(r[t.nextIndex]);for(;f.type!==`GroupClose`;){if(f.type===`Alternator`)c.body.push(iV()),t.nextIndex++;else{let e=c.body.at(-1),t=s(e,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(e.body.push(t),(u||n.isInLookbehind)&&!o){let e=`Lookbehind includes a pattern not allowed by Oniguruma`;if(d||n.isInNegLookbehind){if(TV(t)||t.type===`CapturingGroup`)throw Error(e)}else if(TV(t)||EV(t)&&t.negate)throw Error(e)}}f=jV(r[t.nextIndex])}return t.nextIndex++,c}function tV({kind:e,min:t,max:n},r){let i=r.parent,a=i.body.at(-1);if(!a||!KB(a))throw Error(`Quantifier requires a repeatable token`);let o=vV(e,t,n,a);return i.body.pop(),o}function nV({raw:e},t){let{capturingGroups:n,subroutines:r}=t,i=e.slice(3,-1),a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(a){let e=+a.groups.num,r=n.length;if(t.hasNumberedRef=!0,i={"":e,"+":r+e,"-":r+1-e}[a.groups.sign],i<1)throw Error(`Invalid subroutine number`)}else i===`0`&&(i=0);let o=bV(i);return r.push(o),o}function rV(e,t){if(e!==`repeater`)throw Error(`Unexpected absence function kind "${e}"`);return{type:`AbsenceFunction`,kind:e,body:CV(t?.body)}}function iV(e){return{type:`Alternative`,body:wV(e?.body)}}function aV(e,t){let n={type:`Assertion`,kind:e};return(e===`word_boundary`||e===`text_segment_boundary`)&&(n.negate=!!t?.negate),n}function oV(e,t){let n=!!t?.orphan;return{type:`Backreference`,ref:e,...n&&{orphan:n}}}function sV(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!DV(n.name))throw Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:`CapturingGroup`,number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:CV(t?.body)}}function cV(e,t){let n={useLastValid:!1,...t};if(e>1114111){let t=e.toString(16);if(n.useLastValid)e=1114111;else throw Error(e>1310719?`Invalid code point out of range "\\x{${t}}"`:`Invalid code point out of range in JS "\\x{${t}}"`)}return{type:`Character`,value:e}}function lV(e){let t={kind:`union`,negate:!1,...e};return{type:`CharacterClass`,kind:t.kind,negate:t.negate,body:wV(e?.body)}}function uV(e,t){if(t.value<e.value)throw Error(`Character class range out of order`);return{type:`CharacterClassRange`,min:e,max:t}}function dV(e,t){let n=!!t?.negate,r={type:`CharacterSet`,kind:e};return(e===`digit`||e===`hex`||e===`newline`||e===`space`||e===`word`)&&(r.negate=n),(e===`text_segment`||e===`newline`&&!n)&&(r.variableLength=!0),r}function fV(e,t={}){if(e===`keep`)return{type:`Directive`,kind:e};if(e===`flags`)return{type:`Directive`,kind:e,flags:aB(t.flags)};throw Error(`Unexpected directive kind "${e}"`)}function pV(e){return{type:`Flags`,...e}}function mV(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw Error(`Atomic group cannot have flags`);return{type:`Group`,...t&&{atomic:t},...n&&{flags:n},body:CV(e?.body)}}function hV(e){let t={behind:!1,negate:!1,...e};return{type:`LookaroundAssertion`,kind:t.behind?`lookbehind`:`lookahead`,negate:t.negate,body:CV(e?.body)}}function gV(e,t,n){return{type:`NamedCallout`,kind:e,tag:t,arguments:n}}function _V(e,t){let n=!!t?.negate;if(!iB.has(e))throw Error(`Invalid POSIX class "${e}"`);return{type:`CharacterSet`,kind:`posix`,value:e,negate:n}}function vV(e,t,n,r){if(t>n)throw Error(`Invalid reversed quantifier range`);return{type:`Quantifier`,kind:e,min:t,max:n,body:r}}function yV(e,t){return{type:`Regex`,body:CV(t?.body),flags:e}}function bV(e){return{type:`Subroutine`,ref:e}}function xV(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(kV(e));if(!r){if(n.normalizeUnknownPropertyNames)r=OV(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw Error(X`Invalid Unicode property "\p{${e}}"`)}return{type:`CharacterSet`,kind:`property`,value:r??e,negate:n.negate}}function SV({flags:e,kind:t,name:n,negate:r,number:i}){switch(t){case`absence_repeater`:return rV(`repeater`);case`atomic`:return mV({atomic:!0});case`capturing`:return sV(i,{name:n});case`group`:return mV({flags:e});case`lookahead`:case`lookbehind`:return hV({behind:t===`lookbehind`,negate:r});default:throw Error(`Unexpected group kind "${t}"`)}}function CV(e){if(e===void 0)e=[iV()];else if(!Array.isArray(e)||!e.length||!e.every(e=>e.type===`Alternative`))throw Error(`Invalid body; expected array of one or more Alternative nodes`);return e}function wV(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(e=>!!e.type))throw Error(`Invalid body; expected array of nodes`);return e}function TV(e){return e.type===`LookaroundAssertion`&&e.kind===`lookahead`}function EV(e){return e.type===`LookaroundAssertion`&&e.kind===`lookbehind`}function DV(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function OV(e){return e.trim().replace(/[- _]+/g,`_`).replace(/[A-Z][a-z]+(?=[A-Z])/g,`$&_`).replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function kV(e){return e.replace(/[- _]+/g,``).toLowerCase()}function AV(e,t){return aB(e,`${t?.type===`Character`&&t.value===93?`Empty`:`Unclosed`} character class`)}function jV(e){return aB(e,`Unclosed group`)}function MV(e,t,n=null){function r(e,t){for(let n=0;n<e.length;n++){let r=i(e[n],t,n,e);n=Math.max(-1,n+r)}}function i(a,o=null,s=null,c=null){let l=0,u=!1,d={node:a,parent:o,key:s,container:c,root:e,remove(){NV(c).splice(Math.max(0,PV(s)+l),1),l--,u=!0},removeAllNextSiblings(){return NV(c).splice(PV(s)+1)},removeAllPrevSiblings(){let e=PV(s)+l;return l-=e,NV(c).splice(0,Math.max(0,e))},replaceWith(e,t={}){let n=!!t.traverse;c?c[Math.max(0,PV(s)+l)]=e:aB(o,`Can't replace root node`)[s]=e,n&&i(e,o,s,c),u=!0},replaceWithMultiple(e,t={}){let n=!!t.traverse;if(NV(c).splice(Math.max(0,PV(s)+l),1,...e),l+=e.length-1,n){let t=0;for(let n=0;n<e.length;n++)t+=i(e[n],o,PV(s)+n+t,c)}u=!0},skip(){u=!0}},{type:f}=a,p=t[`*`],m=t[f],h=typeof p==`function`?p:p?.enter,g=typeof m==`function`?m:m?.enter;if(h?.(d,n),g?.(d,n),!u)switch(f){case`AbsenceFunction`:case`CapturingGroup`:case`Group`:r(a.body,a);break;case`Alternative`:case`CharacterClass`:r(a.body,a);break;case`Assertion`:case`Backreference`:case`Character`:case`CharacterSet`:case`Directive`:case`Flags`:case`NamedCallout`:case`Subroutine`:break;case`CharacterClassRange`:i(a.min,a,`min`),i(a.max,a,`max`);break;case`LookaroundAssertion`:r(a.body,a);break;case`Quantifier`:i(a.body,a,`body`);break;case`Regex`:r(a.body,a),i(a.flags,a,`flags`);break;default:throw Error(`Unexpected node type "${f}"`)}return m?.exit?.(d,n),p?.exit?.(d,n),l}return i(e),e}function NV(e){if(!Array.isArray(e))throw Error(`Container expected`);return e}function PV(e){if(typeof e!=`number`)throw Error(`Numeric key expected`);return e}var FV=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function IV(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function LV(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var RV=Object.freeze({DEFAULT:`DEFAULT`,CHAR_CLASS:`CHAR_CLASS`});function zV(e,t,n,r){let i=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,`gsu`),a=[!1],o=0,s=``;for(let t of e.matchAll(i)){let{0:e,groups:{$skip:i}}=t;if(!i&&(!r||r===RV.DEFAULT==!o)){n instanceof Function?s+=n(t,{context:o?RV.CHAR_CLASS:RV.DEFAULT,negated:a[a.length-1]}):s+=n;continue}e[0]===`[`?(o++,a.push(e[1]===`^`)):e===`]`&&o&&(o--,a.pop()),s+=e}return s}function BV(e,t,n,r){zV(e,t,n,r)}function VV(e,t,n=0,r){if(!new RegExp(t,`su`).test(e))return null;let i=RegExp(`${t}|(?<$skip>\\\\?.)`,`gsu`);i.lastIndex=n;let a=0,o;for(;o=i.exec(e);){let{0:e,groups:{$skip:t}}=o;if(!t&&(!r||r===RV.DEFAULT==!a))return o;e===`[`?a++:e===`]`&&a&&a--,i.lastIndex==o.index&&i.lastIndex++}return null}function HV(e,t,n){return!!VV(e,t,0,n)}function UV(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,i=0,a=1,o;for(;o=n.exec(e);){let[e]=o;if(e===`[`)i++;else if(i)e===`]`&&i--;else if(e===`(`)a++;else if(e===`)`&&(a--,!a)){r=o.index;break}}return e.slice(t,r)}var WV=new RegExp(String.raw`(?<noncapturingStart>${FV})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,`gsu`);function GV(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let i=[0],a=[],o=0,s=0,c=NaN,l;do{l=!1;let t=0,u=0,d=!1,f;for(WV.lastIndex=Number.isNaN(c)?0:c+7;f=WV.exec(e);){let{0:p,index:m,groups:{capturingStart:h,noncapturingStart:g}}=f;if(p===`[`)t++;else if(t)p===`]`&&t--;else if(p===`(?>`&&!d)c=m,d=!0;else if(d&&g)u++;else if(h)d?u++:(o++,i.push(o+s));else if(p===`)`&&d){if(!u){s++;let t=o+s;if(e=`${e.slice(0,c)}(?:(?=(${e.slice(c+3,m)}))<$$${t}>)${e.slice(m+1)}`,l=!0,a.push(t),IV(n,t),r.size){let e=new Map;r.forEach((n,r)=>{e.set(r>=t?r+1:r,n.map(e=>e>=t?e+1:e))}),r=e}break}u--}}}while(l);return n.push(...a),e=zV(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:t,wrappedBackrefNum:n}})=>{if(t){let n=+t;if(n>i.length-1)throw Error(`Backref "${e}" greater than number of captures`);return`\\${i[n]}`}return`\\${n}`},RV.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var KV=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,qV=new RegExp(String.raw`
|
|
77
77
|
\\(?: \d+
|
|
78
78
|
| c[A-Za-z]
|
|
79
79
|
| [gk]<[^>]+>
|
|
@@ -86,9 +86,9 @@ import{n as e,r as t,t as n}from"./rolldown-runtime-hePW80VL.js";import{$ as r,$
|
|
|
86
86
|
| [A-Za-z\-]+:
|
|
87
87
|
| \(DEFINE\)
|
|
88
88
|
))?
|
|
89
|
-
| (?<qBase>${
|
|
89
|
+
| (?<qBase>${KV})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
90
90
|
| \\?.
|
|
91
|
-
`.replace(/\s+/g,``),`gsu`);function
|
|
91
|
+
`.replace(/\s+/g,``),`gsu`);function JV(e){if(!RegExp(`${KV}\\+`).test(e))return{pattern:e};let t=[],n=null,r=null,i=``,a=0,o;for(qV.lastIndex=0;o=qV.exec(e);){let{0:s,index:c,groups:{qBase:l,qMod:u,invalidQ:d}}=o;if(s===`[`)a||(r=c),a++;else if(s===`]`)a?a--:r=null;else if(!a)if(u===`+`&&i&&!i.startsWith(`(`)){if(d)throw Error(`Invalid quantifier "${s}"`);let t=-1;if(/^\{\d+\}$/.test(l))e=LV(e,c+l.length,u,``);else{if(i===`)`||i===`]`){let t=i===`)`?n:r;if(t===null)throw Error(`Invalid unmatched "${i}"`);e=`${e.slice(0,t)}(?>${e.slice(t,c)}${l})${e.slice(c+s.length)}`}else e=`${e.slice(0,c-i.length)}(?>${i}${l})${e.slice(c+s.length)}`;t+=4}qV.lastIndex+=t}else s[0]===`(`?t.push(c):s===`)`&&(n=t.length?t.pop():null);i=s}return{pattern:e}}var YV=String.raw,XV=YV`\(\?R=(?<rDepth>[^\)]+)\)|${YV`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`}`,ZV=YV`\(\?<(?![=!])(?<captureName>[^>]+)>`,QV=YV`${ZV}|(?<unnamed>\()(?!\?)`,$V=new RegExp(YV`${ZV}|${XV}|\(\?|\\?.`,`gsu`),eH=`Cannot use multiple overlapping recursions`;function tH(e,t){let{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:`plugin`,...t},i=t?.captureTransfers??new Map;if(!new RegExp(XV,`su`).test(e))return{pattern:e,captureTransfers:i,hiddenCaptures:n};if(r===`plugin`&&HV(e,YV`\(\?\(DEFINE\)`,RV.DEFAULT))throw Error(`DEFINE groups cannot be used with recursion`);let a=[],o=HV(e,YV`\\[1-9]`,RV.DEFAULT),s=new Map,c=[],l=!1,u=0,d=0,f;for($V.lastIndex=0;f=$V.exec(e);){let{0:t,groups:{captureName:p,rDepth:m,gRNameOrNum:h,gRDepth:g}}=f;if(t===`[`)u++;else if(u)t===`]`&&u--;else{if(m){if(nH(m),l)throw Error(eH);if(o)throw Error(`${r===`external`?`Backrefs`:`Numbered backrefs`} cannot be used with global recursion`);let t=e.slice(0,f.index),s=e.slice($V.lastIndex);if(HV(s,XV,RV.DEFAULT))throw Error(eH);let c=m-1;e=rH(t,s,c,!1,n,a,d),i=oH(i,t,c,a.length,0,d);break}if(h){nH(g);let u=!1;for(let e of c)if(e.name===h||e.num===+h){if(u=!0,e.hasRecursedWithin)throw Error(eH);break}if(!u)throw Error(YV`Recursive \g cannot be used outside the referenced group "${r===`external`?h:YV`\g<${h}&R=${g}>`}"`);let p=s.get(h),m=UV(e,p);if(o&&HV(m,YV`${ZV}|\((?!\?)`,RV.DEFAULT))throw Error(`${r===`external`?`Backrefs`:`Numbered backrefs`} cannot be used with recursion of capturing groups`);let _=e.slice(p,f.index),v=m.slice(_.length+t.length),y=a.length,b=g-1,x=rH(_,v,b,!0,n,a,d);i=oH(i,_,b,a.length-y,y,d),e=`${e.slice(0,p)}${x}${e.slice(p+m.length)}`,$V.lastIndex+=x.length-t.length-_.length-v.length,c.forEach(e=>e.hasRecursedWithin=!0),l=!0}else if(p)d++,s.set(String(d),$V.lastIndex),s.set(p,$V.lastIndex),c.push({num:d,name:p});else if(t[0]===`(`){let e=t===`(`;e&&(d++,s.set(String(d),$V.lastIndex)),c.push(e?{num:d}:{})}else t===`)`&&c.pop()}}return n.push(...a),{pattern:e,captureTransfers:i,hiddenCaptures:n}}function nH(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e)||(e=+e,e<2||e>100))throw Error(t)}function rH(e,t,n,r,i,a,o){let s=new Set;r&&BV(e+t,ZV,({groups:{captureName:e}})=>{s.add(e)},RV.DEFAULT);let c=[n,r?s:null,i,a,o];return`${e}${iH(`(?:${e}`,`forward`,...c)}(?:)${iH(`${t})`,`backward`,...c)}${t}`}function iH(e,t,n,r,i,a,o){let s=e=>t===`forward`?e+2:n-e+2-1,c=``;for(let t=0;t<n;t++){let n=s(t);c+=zV(e,YV`${QV}|\\k<(?<backref>[^>]+)>`,({0:e,groups:{captureName:t,unnamed:s,backref:c}})=>{if(c&&r&&!r.has(c))return e;let l=`_$${n}`;if(s||t){let n=o+a.length+1;return a.push(n),aH(i,n),s?e:`(?<${t}${l}>`}return YV`\k<${c}${l}>`},RV.DEFAULT)}return c}function aH(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function oH(e,t,n,r,i,a){if(e.size&&r){let o=0;BV(t,QV,()=>o++,RV.DEFAULT);let s=a-o+i,c=new Map;return e.forEach((e,t)=>{let i=(r-o*n)/n,a=o*n,l=t>s+o?t+r:t,u=[];for(let t of e)if(t<=s)u.push(t);else if(t>s+o+i)u.push(t+r);else if(t<=s+o)for(let e=0;e<=n;e++)u.push(t+o*e);else for(let e=0;e<=n;e++)u.push(t+a+i*e);c.set(l,u)}),c}return e}var Z=String.fromCodePoint,Q=String.raw,sH={},cH=globalThis.RegExp;sH.flagGroups=(()=>{try{new cH(`(?i:)`)}catch{return!1}return!0})(),sH.unicodeSets=(()=>{try{new cH(`[[]]`,`v`)}catch{return!1}return!0})(),sH.bugFlagVLiteralHyphenIsRange=sH.unicodeSets?(()=>{try{new cH(Q`[\d\-a]`,`v`)}catch{return!0}return!1})():!1,sH.bugNestedClassIgnoresNegation=sH.unicodeSets&&new cH(`[[^a]]`,`v`).test(`a`);function lH(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function uH(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function dH(e,t){return pH[e]>=pH[t]}function fH(e,t){if(e==null)throw Error(t??`Value expected`);return e}var pH={ES2025:2025,ES2024:2024,ES2018:2018},mH={auto:`auto`,ES2025:`ES2025`,ES2024:`ES2024`,ES2018:`ES2018`};function hH(e={}){if({}.toString.call(e)!==`[object Object]`)throw Error(`Unexpected options`);if(e.target!==void 0&&!mH[e.target])throw Error(`Unexpected target "${e.target}"`);let t={accuracy:`default`,avoidSubclass:!1,flags:``,global:!1,hasIndices:!1,lazyCompileLength:1/0,target:`auto`,verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target===`auto`&&(t.target=sH.flagGroups?`ES2025`:sH.unicodeSets?`ES2024`:`ES2018`),t}var gH=`[ -\r ]`,_H=new Set([Z(304),Z(305)]),vH=Q`[\p{L}\p{M}\p{N}\p{Pc}]`;function yH(e){if(_H.has(e))return[e];let t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),i=CH.get(n),a=xH.get(n),o=SH.get(n);return[...r].length===1&&t.add(r),o&&t.add(o),i&&t.add(i),t.add(n),a&&t.add(a),[...t]}var bH=new Map(`C Other
|
|
92
92
|
Cc Control cntrl
|
|
93
93
|
Cf Format
|
|
94
94
|
Cn Unassigned
|
|
@@ -178,18 +178,18 @@ Uppercase Upper
|
|
|
178
178
|
Variation_Selector VS
|
|
179
179
|
White_Space space
|
|
180
180
|
XID_Continue XIDC
|
|
181
|
-
XID_Start XIDS`.split(/\s/).map(e=>[
|
|
181
|
+
XID_Start XIDS`.split(/\s/).map(e=>[kV(e),e])),xH=new Map([[`s`,Z(383)],[Z(383),`s`]]),SH=new Map([[Z(223),Z(7838)],[Z(107),Z(8490)],[Z(229),Z(8491)],[Z(969),Z(8486)]]),CH=new Map([EH(453),EH(456),EH(459),EH(498),...DH(8072,8079),...DH(8088,8095),...DH(8104,8111),EH(8124),EH(8140),EH(8188)]),wH=new Map([[`alnum`,Q`[\p{Alpha}\p{Nd}]`],[`alpha`,Q`\p{Alpha}`],[`ascii`,Q`\p{ASCII}`],[`blank`,Q`[\p{Zs}\t]`],[`cntrl`,Q`\p{Cc}`],[`digit`,Q`\p{Nd}`],[`graph`,Q`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],[`lower`,Q`\p{Lower}`],[`print`,Q`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],[`punct`,Q`[\p{P}\p{S}]`],[`space`,Q`\p{space}`],[`upper`,Q`\p{Upper}`],[`word`,Q`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],[`xdigit`,Q`\p{AHex}`]]);function TH(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function EH(e){let t=Z(e);return[t.toLowerCase(),t]}function DH(e,t){return TH(e,t).map(e=>EH(e))}var OH=new Set([`Lower`,`Lowercase`,`Upper`,`Uppercase`,`Ll`,`Lowercase_Letter`,`Lt`,`Titlecase_Letter`,`Lu`,`Uppercase_Letter`]);function kH(e,t){let n={accuracy:`default`,asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:`ES2025`,...t};NH(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:dH(n.bestEffortTarget,`ES2024`),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};MV(e,AH,r);let i={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},a={currentFlags:i,prevFlags:null,globalFlags:i,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};return MV(e,jH,a),MV(e,MH,{groupsByName:a.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:a.reffedNodesByReferencer}),e._originMap=a.groupOriginByCopy,e._strategy=r.strategy,e}var AH={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:i}=e;if(i===`repeater`){let e=mV();e.body[0].body.push(hV({negate:!0,body:r}),xV(`Any`));let i=mV();i.body[0].body.push(vV(`greedy`,0,1/0,e)),n($(i,t),{traverse:!0})}else throw Error(`Unsupported absence function "(?~|"`)},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){let i=e.body.filter(e=>e.kind===`flags`);for(let e=n+1;e<t.body.length;e++){let n=t.body[e];uH(r,n,[]).push(...i)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=BH(t.get(e));if(n){let t=mV({flags:n});t.body[0].body=e.body,e.body=[$(t,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:i,remove:a,replaceWith:o},s){let{kind:c,negate:l}=e,{asciiWordBoundaries:u,avoidSubclass:d,supportedGNodes:f,wordIsAscii:p}=s;if(c===`text_segment_boundary`)throw Error(`Unsupported text segment boundary "\\${l?`Y`:`y`}"`);if(c===`line_end`)o($(hV({body:[iV({body:[aV(`string_end`)]}),iV({body:[cV(10)]})]}),t));else if(c===`line_start`)o($(YH(Q`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(c===`search_start`)if(f.has(e))i.flags.sticky=!0,a();else{let e=r[n-1];if(e&&KH(e))o($(hV({negate:!0}),t));else if(d)throw Error(Q`Uses "\G" in a way that requires a subclass`);else o(ZH(aV(`string_start`),t)),s.strategy=`clip_search`}else if(c!==`string_end`&&c!==`string_start`)if(c===`string_end_newline`)o($(YH(Q`(?=\n?\z)`),t));else if(c===`word_boundary`){if(!p&&!u){let e=`(?:(?<=${vH})(?!${vH})|(?<!${vH})(?=${vH}))`,n=`(?:(?<=${vH})(?=${vH})|(?<!${vH})(?!${vH}))`;o($(YH(l?n:e),t))}}else throw Error(`Unexpected assertion kind "${c}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!JH(n)&&(n=zH(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!JH(r)&&(r=zH(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){t.kind===`intersection`&&n($(lV({body:[e]}),t),{traverse:!0})},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:i,digitIsAscii:a,spaceIsAscii:o,wordIsAscii:s}){let{kind:c,negate:l,value:u}=e;if(a&&(c===`digit`||u===`digit`)){n(ZH(dV(`digit`,{negate:l}),t));return}if(o&&(c===`space`||u===`space`)){n($(XH(YH(gH),l),t));return}if(s&&(c===`word`||u===`word`)){n(ZH(dV(`word`,{negate:l}),t));return}if(c===`any`)n(ZH(xV(`Any`),t));else if(c===`digit`)n(ZH(xV(`Nd`,{negate:l}),t));else if(c!==`dot`)if(c===`text_segment`){if(r===`strict`)throw Error(Q`Use of "\X" requires non-strict accuracy`);let e=`\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?`,a=Q`\p{RI}{2}|${e}(?:\u200D${e})*`;n($(YH(Q`(?>\r\n|${i?Q`\p{RGI_Emoji}`:a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(c===`hex`)n(ZH(xV(`AHex`,{negate:l}),t));else if(c===`newline`)n($(YH(l?`[^
|
|
182
182
|
]`:`(?>\r
|
|
183
183
|
?|[
|
|
184
|
-
\v\f
\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${Z(e.codePointAt(0)-1)}${Z(e.codePointAt(2)+1)}-\u{10FFFF}`),n($(KH(`[${e}]`),t))}else n($(qH(KH(xH.get(u)),l),t));else if(c===`property`)_H.has(EV(u))||(e.key=`sc`);else if(c===`space`)n(JH(vV(`space`,{negate:l}),t));else if(c===`word`)n($(qH(KH(hH),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=dV({flags:c});e.body[0].body=o(),i($(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&HB(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error(Q`Uses "\K" in a way that's unsupported`);let o=fV({behind:!0});o.body[0].body=a(),i($(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n($(fV({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=dV();t.body[0].body.push(e.body),e.body=$(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=BH(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error(Q`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!GH(n)&&(n=IH(n,t),e.ref=n)}},OH={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=JH(PH(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&sH(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=sH(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=oH(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&(n.type!==`CapturingGroup`||n.name!==a&&n.number!==a););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?PH(0):NH(o,r.groupOriginByCopy,null),l=c;if(!s){let e=LH(FH(o,e=>e.type===`Group`&&!!e.flags)),t=e?oH(r.globalFlags,e):r.globalFlags;jH(t,r.currentFlags)||(l=dV({flags:RH(t)}),l.body[0].body.push(c))}n($(l,t),{traverse:!s})}},kH={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>MH(t,e));i.length?i.length>1?n($(dV({atomic:!0,body:i.reverse().map(e=>tV({body:[rV(e.number)]}))}),t)):e.ref=i[0].number:n($(fV({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=iV();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function AH(e){kV(e,{"*"({node:e,parent:t}){e.parent=t}})}function jH(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function MH(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=zH(n.parent);for(let r of t){if(r===n)break;if(r===e||VH(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function NH(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=NH(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function PH(e){let t=_V(e);return t.isRecursive=!0,t}function FH(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function IH(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function LH(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function RH({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function zH(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function BH(e){let t=e.find(e=>e.kind===`search_start`||WH(e,{negate:!1})||!HH(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=BH(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function VH(e,t){let n=zH(e)??[];for(let e of n)if(e===t||VH(e,t))return!0;return!1}function HH({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function UH(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function WH(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&HB(e.body[0],{type:`Assertion`,kind:`search_start`})}function GH(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function KH(e,t){let n=GB(e,{...t,unicodePropertyMap:_H}).body;return n.length>1||n[0].body.length>1?dV({body:n}):n[0].body[0]}function qH(e,t){return e.negate=t,e}function JH(e,t){return e.parent=t,e}function $(e,t){return AH(e),e.parent=t,e}function YH(e,t){let n=fH(t),r=cH(n.target,`ES2024`),i=cH(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];kV(e,XH,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,lH(ZH[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&sH(f._captureTransfers,e.transferTo,[]).push(t)}),f}var XH={"*":{enter({node:e},t){if(lU(e)){let n=t.getCurrentModI();t.pushModI(e.flags?oH({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){lU(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){rU(Z(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),iU(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&TH.has(e.value)&&t.setHasCasedChar()}},ZH={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?Q`\B`:Q`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=Z(e),r=aU(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&rU(n)){let e=gH(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);iH.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(dU)&&(o=[aV(45),...o.filter(e=>!dU(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||iH.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=dV(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=tV({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(iH.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=aU(n,i),o=aU(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&oU(iU(e)).forEach(e=>{s.add(Array.isArray(e)?`${aU(e[0],i)}-${aU(e[1],i)}`:aU(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:Q`[^\n]`;if(e===`digit`)return t?Q`\D`:Q`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&TH.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?Q`\P`:Q`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?Q`\W`:Q`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=oH(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${sU(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+cU(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:Q`\g<${t}&R=${r}>`}},QH=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),$H=new Set([`-`,`\\`,`]`,`^`,`[`]),eU=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),tU=new Map([[9,Q`\t`],[10,Q`\n`],[11,Q`\v`],[12,Q`\f`],[13,Q`\r`],[8232,Q`\u2028`],[8233,Q`\u2029`],[65279,Q`\uFEFF`]]),nU=/^\p{Cased}$/u;function rU(e){return nU.test(e)}function iU(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=Z(e);if(!rU(t))continue;let o=gH(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function aU(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(tU.has(e))return tU.get(e);if(e<32||e>126&&e<160||e>262143||t&&uU(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?eU:$H:QH,a=Z(e);return(i.has(a)?`\\`:``)+a}function oU(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function sU(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function cU({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function lU({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function uU(e){return e>47&&e<58}function dU({type:e,value:t}){return e===`Character`&&t===45}var fU=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=mU(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(pU(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=hU(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function pU(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function mU(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)sH(n,t,{}).transferTo=e;return n}function hU(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function gU(e,t){let n=_U(e,t);return n.options?new fU(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function _U(e,t){let n=fH(t),r=EH(GB(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:_H}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=YH(r,n),a=QV(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=HV(GV(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}function vU(e,t){return gU(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function yU(e={}){let t=Object.assign({target:`auto`,cache:new Map},e);return t.regexConstructor||=e=>vU(e,{target:t.target}),{createScanner(e){return new Qz(e,t)},createString(e){return{content:e}}}}async function bU(e){if(ZF())throw Error(`resolveLanguage("${e}") cannot be called from a worker context. Languages must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);let t=KF.get(e);if(t!=null)return t;try{let t=qF.get(e);if(t==null&&Object.prototype.hasOwnProperty.call(cI,e)&&(t=cI[e]),t==null)throw Error(`resolveLanguage: "${e}" not found in bundled or custom languages`);let n=t().then(({default:t})=>{let n={name:e,data:t};return GF.has(e)||GF.set(e,n),n});return KF.set(e,n),await n}finally{KF.delete(e)}}function xU(e){return GF.get(e)??bU(e)}var SU=new Set;function CU(e){let t=[],n=new Set;for(let r of wU(e.themes)){let e=DU(r)?r.getThemes():[r];for(let r of e){if(n.has(r.name))throw Error(`Theme collection already contains theme "${r.name}"`);n.add(r.name),t.push(r)}}let r=Object.freeze([...t]),i=Object.freeze(r.filter(e=>e.colorScheme===`light`)),a=Object.freeze(r.filter(e=>e.colorScheme===`dark`)),o=new Map(r.map(e=>[e.name,e])),s=Object.freeze(r.map(e=>e.name)),c=Object.freeze(i.map(e=>e.name)),l=Object.freeze(a.map(e=>e.name));function u(e){if(e==null)return r;let{colorScheme:t,collection:n}=e;return n==null?t===`light`?i:t===`dark`?a:r:r.filter(e=>e.collection===n?t==null||e.colorScheme===t:!1)}return{getTheme(e){return o.get(e)},getThemes(e){return u(e)},getThemeNames(e){return e?.collection==null?e?.colorScheme===`light`?c:e?.colorScheme===`dark`?l:s:u(e).map(e=>e.name)},hasTheme(e){return o.has(e)},orderBy(e){return CU({themes:r.map((e,t)=>({descriptor:e,index:t})).sort((t,n)=>{let r=e(t.descriptor,n.descriptor);return r===0?t.index-n.index:r}).map(e=>e.descriptor)})},pick(e){let t=[],n=new Set;for(let r of e){if(n.has(r))throw Error(`Theme collection pick already includes theme "${r}"`);n.add(r);let e=o.get(r);if(e==null)throw Error(`Theme collection does not contain theme "${r}"`);t.push(e)}return CU({themes:t})},registerInto(e){for(let t of r)e.registerThemeIfAbsent(t.name,t.load)}}}function wU(e){return TU(e)?[e]:e}function TU(e){return DU(e)||EU(e)}function EU(e){return typeof e.name==`string`&&typeof e.load==`function`}function DU(e){return typeof e.getThemes==`function`}function OU(e){return typeof e==`object`&&e&&`default`in e?e.default:e}var kU=class extends Error{constructor(e){super(`Theme "${e}" is already registered`),this.name=`DuplicateThemeError`}},AU=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`),this.name=`UnregisteredThemeError`}},jU=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`),this.name=`UnresolvedThemeError`}};function MU(){let e=new Map,t=new Map,n=new Map,r=0;function i(t,n){if(e.has(t))throw new kU(t);e.set(t,n)}function a(t,n){return!e.has(t)&&(e.set(t,n),!0)}function o(t){return e.has(t)}function s(i){let a=t.get(i);if(a!==void 0)return Promise.resolve(a);let o=n.get(i);if(o!==void 0)return o;let s=e.get(i);if(s===void 0)return Promise.reject(new AU(i));let c=r,l=s().then(e=>{let a=OU(e);return c===r&&t.set(i,a),n.get(i)===l&&n.delete(i),a}).catch(e=>{throw n.get(i)===l&&n.delete(i),e});return n.set(i,l),l}function c(e){return Promise.all(e.map(e=>s(e)))}function l(e,n){t.set(e,n)}function u(e){for(let[t,n]of e)l(t,n)}function d(e){return t.get(e)}function f(e){let n=[];for(let r of e){let e=t.get(r);if(e===void 0)throw new jU(r);n.push(e)}return n}function p(e){return t.has(e)}function m(e){for(let n of e)if(!t.has(n))return!1;return!0}function h(e){let n=t.get(e);return n===void 0?s(e):n}function g(){r++,t.clear(),n.clear()}return{clearResolvedThemes:g,getResolvedOrResolveTheme:h,getResolvedTheme:d,getResolvedThemes:f,hasRegisteredTheme:o,hasResolvedTheme:p,hasResolvedThemes:m,registerTheme:i,registerThemeIfAbsent:a,resolveTheme:s,resolveThemes:c,seedResolvedTheme:l,seedResolvedThemes:u}}var NU=MU();function PU(e,t){e=Array.isArray(e)?e:[e];for(let n of e){let e;if(typeof n==`string`){if(e=NU.getResolvedTheme(n),e==null)throw Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else e=n,n=n.name,NU.getResolvedTheme(n)??NU.seedResolvedTheme(n,e);SU.has(n)||(SU.add(n),t.loadThemeSync(e))}}function FU({name:e,load:t,colorScheme:n,collection:r,displayName:i}){return{name:e,colorScheme:n,collection:r,displayName:i,load:IU(t)}}function IU(e){return async()=>AR(OU(await e()))}var LU=`pierre`,RU=[`pierre-dark`,`pierre-dark-soft`,`pierre-dark-vibrant`,`pierre-dark-protanopia-deuteranopia`,`pierre-dark-tritanopia`],zU=[`pierre-light`,`pierre-light-soft`,`pierre-light-vibrant`,`pierre-light-protanopia-deuteranopia`,`pierre-light-tritanopia`],BU=[...zU,...RU],VU=new Set(zU);function HU(e){return VU.has(e)?`light`:`dark`}var UU={"pierre-dark":`Pierre Dark`,"pierre-dark-soft":`Pierre Dark Soft`,"pierre-dark-vibrant":`Pierre Dark Vibrant`,"pierre-dark-protanopia-deuteranopia":`Pierre Dark Protanopia & Deuteranopia`,"pierre-dark-tritanopia":`Pierre Dark Tritanopia`,"pierre-light":`Pierre Light`,"pierre-light-soft":`Pierre Light Soft`,"pierre-light-vibrant":`Pierre Light Vibrant`,"pierre-light-protanopia-deuteranopia":`Pierre Light Protanopia & Deuteranopia`,"pierre-light-tritanopia":`Pierre Light Tritanopia`},WU={"pierre-dark":()=>D(()=>import(`./pierre-dark-CpLgRqie.js`),[]),"pierre-dark-soft":()=>D(()=>import(`./pierre-dark-soft-kZQmAZld.js`),[]),"pierre-dark-vibrant":()=>D(()=>import(`./pierre-dark-vibrant-CpQYzh95.js`),[]),"pierre-dark-protanopia-deuteranopia":()=>D(()=>import(`./pierre-dark-protanopia-deuteranopia-B35FxJx-.js`),[]),"pierre-dark-tritanopia":()=>D(()=>import(`./pierre-dark-tritanopia-CpjhbsIL.js`),[]),"pierre-light":()=>D(()=>import(`./pierre-light-CoaEpmwp.js`),[]),"pierre-light-soft":()=>D(()=>import(`./pierre-light-soft-lWLdNTOI.js`),[]),"pierre-light-vibrant":()=>D(()=>import(`./pierre-light-vibrant-D80Fkn33.js`),[]),"pierre-light-protanopia-deuteranopia":()=>D(()=>import(`./pierre-light-protanopia-deuteranopia-0fSaH845.js`),[]),"pierre-light-tritanopia":()=>D(()=>import(`./pierre-light-tritanopia-CEbqgOJL.js`),[])};function GU(e){return FU({name:e,collection:LU,colorScheme:HU(e),displayName:UU[e],load:WU[e]})}var KU=CU({themes:BU.map(e=>GU(e))}),qU=`shiki`,JU=[`ayu-light`,`catppuccin-latte`,`everforest-light`,`github-light`,`github-light-default`,`github-light-high-contrast`,`gruvbox-light-hard`,`gruvbox-light-medium`,`gruvbox-light-soft`,`horizon-bright`,`kanagawa-lotus`,`light-plus`,`material-theme-lighter`,`min-light`,`night-owl-light`,`one-light`,`rose-pine-dawn`,`slack-ochin`,`snazzy-light`,`solarized-light`,`vitesse-light`],YU=`andromeeda.aurora-x.ayu-dark.ayu-mirage.catppuccin-frappe.catppuccin-macchiato.catppuccin-mocha.dark-plus.dracula.dracula-soft.everforest-dark.github-dark.github-dark-default.github-dark-dimmed.github-dark-high-contrast.gruvbox-dark-hard.gruvbox-dark-medium.gruvbox-dark-soft.horizon.houston.kanagawa-dragon.kanagawa-wave.laserwave.material-theme.material-theme-darker.material-theme-ocean.material-theme-palenight.min-dark.monokai.night-owl.nord.one-dark-pro.plastic.poimandres.red.rose-pine.rose-pine-moon.slack-dark.solarized-dark.synthwave-84.tokyo-night.vesper.vitesse-black.vitesse-dark`.split(`.`),XU=new Set(JU);function ZU(e){return XU.has(e)?`light`:`dark`}var QU={andromeeda:()=>D(()=>import(`./andromeeda-vGVdxbeo.js`),[]),"aurora-x":()=>D(()=>import(`./aurora-x-CDeNXAV0.js`),[]),"ayu-dark":()=>D(()=>import(`./ayu-dark-DluEY0Gj.js`),[]),"ayu-light":()=>D(()=>import(`./ayu-light-C3h-C4tm.js`),[]),"ayu-mirage":()=>D(()=>import(`./ayu-mirage-Bqwy1Gya.js`),[]),"catppuccin-frappe":()=>D(()=>import(`./catppuccin-frappe-3VR1Za6u.js`),[]),"catppuccin-latte":()=>D(()=>import(`./catppuccin-latte-DwIHMF0Q.js`),[]),"catppuccin-macchiato":()=>D(()=>import(`./catppuccin-macchiato-DYnBP6_5.js`),[]),"catppuccin-mocha":()=>D(()=>import(`./catppuccin-mocha-DYhrFGRu.js`),[]),"dark-plus":()=>D(()=>import(`./dark-plus-Cs2F2srj.js`),[]),dracula:()=>D(()=>import(`./dracula-BHWKrbxM.js`),[]),"dracula-soft":()=>D(()=>import(`./dracula-soft-5eyTD99u.js`),[]),"everforest-dark":()=>D(()=>import(`./everforest-dark-sB-x3p7T.js`),[]),"everforest-light":()=>D(()=>import(`./everforest-light-Df2xbC6M.js`),[]),"github-dark":()=>D(()=>import(`./github-dark-C-LZuMrd.js`),[]),"github-dark-default":()=>D(()=>import(`./github-dark-default-DXG-b-1a.js`),[]),"github-dark-dimmed":()=>D(()=>import(`./github-dark-dimmed-Bx1FflLF.js`),[]),"github-dark-high-contrast":()=>D(()=>import(`./github-dark-high-contrast-B_tTalzw.js`),[]),"github-light":()=>D(()=>import(`./github-light-EUqPIrTm.js`),[]),"github-light-default":()=>D(()=>import(`./github-light-default-BXViO-2h.js`),[]),"github-light-high-contrast":()=>D(()=>import(`./github-light-high-contrast-B68TUdTA.js`),[]),"gruvbox-dark-hard":()=>D(()=>import(`./gruvbox-dark-hard-C820rvS2.js`),[]),"gruvbox-dark-medium":()=>D(()=>import(`./gruvbox-dark-medium-BPjhmG05.js`),[]),"gruvbox-dark-soft":()=>D(()=>import(`./gruvbox-dark-soft-MrdJrrXF.js`),[]),"gruvbox-light-hard":()=>D(()=>import(`./gruvbox-light-hard-BC_s9l72.js`),[]),"gruvbox-light-medium":()=>D(()=>import(`./gruvbox-light-medium-BAWPOn9u.js`),[]),"gruvbox-light-soft":()=>D(()=>import(`./gruvbox-light-soft-BSMLrYjP.js`),[]),horizon:()=>D(()=>import(`./horizon-CE9ld1lL.js`),[]),"horizon-bright":()=>D(()=>import(`./horizon-bright-DSNQnXHK.js`),[]),houston:()=>D(()=>import(`./houston-CsvMBhTu.js`),[]),"kanagawa-dragon":()=>D(()=>import(`./kanagawa-dragon-CXtmUGW6.js`),[]),"kanagawa-lotus":()=>D(()=>import(`./kanagawa-lotus-BN08jTvb.js`),[]),"kanagawa-wave":()=>D(()=>import(`./kanagawa-wave-CTweb8Dz.js`),[]),laserwave:()=>D(()=>import(`./laserwave-C_8bwKvT.js`),[]),"light-plus":()=>D(()=>import(`./light-plus-DVQuIRkW.js`),[]),"material-theme":()=>D(()=>import(`./material-theme-Bm3Qr25_.js`),[]),"material-theme-darker":()=>D(()=>import(`./material-theme-darker-2IIEA8gg.js`),[]),"material-theme-lighter":()=>D(()=>import(`./material-theme-lighter-uhdI0v04.js`),[]),"material-theme-ocean":()=>D(()=>import(`./material-theme-ocean-CHQ94UKr.js`),[]),"material-theme-palenight":()=>D(()=>import(`./material-theme-palenight-B5W6OYN7.js`),[]),"min-dark":()=>D(()=>import(`./min-dark-BSWPekZh.js`),[]),"min-light":()=>D(()=>import(`./min-light-DDpmG2fV.js`),[]),monokai:()=>D(()=>import(`./monokai-CdkpiU2Y.js`),[]),"night-owl":()=>D(()=>import(`./night-owl-DhmEMT88.js`),[]),"night-owl-light":()=>D(()=>import(`./night-owl-light-eJ-hLW7d.js`),[]),nord:()=>D(()=>import(`./nord-Cb4Vim4T.js`),[]),"one-dark-pro":()=>D(()=>import(`./one-dark-pro-CLwyXe_n.js`),[]),"one-light":()=>D(()=>import(`./one-light-D7Lr4KcI.js`),[]),plastic:()=>D(()=>import(`./plastic-DQwYfKfQ.js`),[]),poimandres:()=>D(()=>import(`./poimandres-DRFjx7u4.js`),[]),red:()=>D(()=>import(`./red-CJ3rzSJv.js`),[]),"rose-pine":()=>D(()=>import(`./rose-pine-BthvhNj6.js`),[]),"rose-pine-dawn":()=>D(()=>import(`./rose-pine-dawn-Dg85fqjY.js`),[]),"rose-pine-moon":()=>D(()=>import(`./rose-pine-moon-hon4tzzS.js`),[]),"slack-dark":()=>D(()=>import(`./slack-dark-DnToyrRv.js`),[]),"slack-ochin":()=>D(()=>import(`./slack-ochin-B2OO5cIa.js`),[]),"snazzy-light":()=>D(()=>import(`./snazzy-light-4G7pJPwS.js`),[]),"solarized-dark":()=>D(()=>import(`./solarized-dark-DV17i1UV.js`),[]),"solarized-light":()=>D(()=>import(`./solarized-light-DSh2HLQt.js`),[]),"synthwave-84":()=>D(()=>import(`./synthwave-84-nFMaYfgc.js`),[]),"tokyo-night":()=>D(()=>import(`./tokyo-night-oM2G3aXe.js`),[]),vesper:()=>D(()=>import(`./vesper-DdrHHSXu.js`),[]),"vitesse-black":()=>D(()=>import(`./vitesse-black-fwtXNY1n.js`),[]),"vitesse-dark":()=>D(()=>import(`./vitesse-dark-BZCL-v6S.js`),[]),"vitesse-light":()=>D(()=>import(`./vitesse-light-VbXTXTou.js`),[])};function $U(e){return FU({name:e,collection:qU,colorScheme:ZU(e),load:QU[e]})}var eW=CU({themes:Object.freeze([...JU.map(e=>$U(e)),...YU.map(e=>$U(e))])});function tW(e){if(ZF())throw Error(`Theme "${e}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);if(NU.hasRegisteredTheme(e))return;let t=eW.getTheme(e);if(t!=null){NU.registerThemeIfAbsent(t.name,t.load);return}throw Error(`No valid theme loader registered for "${e}"`)}function nW(e,t){if(t.name!==e)throw Error(`resolvedTheme: themeName: ${e} does not match theme.name: ${t.name}`)}async function rW(e){tW(e);let t=await NU.resolveTheme(e);return nW(e,t),t}function iW(e){return NU.getResolvedTheme(e)??rW(e)}var aW;async function oW({themes:e,langs:t,preferredHighlighter:n=`shiki-js`}){aW??=Uz({themes:[],langs:[`text`],engine:n===`shiki-wasm`?II(D(()=>import(`./wasm-BnjxR4X6.js`),[])):yU()});let r=cW(aW)?await aW:aW;aW=r;let i=[];for(let e of t){if(e===`text`||e===`ansi`)continue;let t=xU(e);`then`in t?i.push(t):XF(t,r)}let a=[];for(let t of e){let e=iW(t);`then`in e?a.push(e):PU(e,aW)}return(i.length>0||a.length>0)&&await Promise.all([Promise.all(i).then(e=>{XF(e,r)}),Promise.all(a).then(e=>{PU(e,r)})]),r}function sW(){if(aW!=null&&!(`then`in aW))return aW}function cW(e=aW){return e!=null&&`then`in e}for(let e of KU.getThemes())NU.registerThemeIfAbsent(e.name,e.load);function lW(e=Xj){let t=[];return typeof e==`string`?t.push(e):(t.push(e.dark),t.push(e.light)),t}function uW(e){for(let t of lW(e))if(!SU.has(t))return!1;return!0}function dW(e){return NU.hasResolvedThemes(e)}function fW(e,t){return _M(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function pW(e,t){return e==null||t==null?e===t:e.startingLine===t.startingLine&&e.totalLines===t.totalLines&&e.bufferBefore===t.bufferBefore&&e.bufferAfter===t.bufferAfter}function mW(e){return B({tagName:`div`,children:[B({tagName:`div`,children:e.annotations?.map(e=>B({tagName:`slot`,properties:{name:e}})),properties:{"data-annotation-content":``}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function hW(e){switch(e){case`file`:return`diffs-icon-file-code`;case`change`:return`diffs-icon-symbol-modified`;case`new`:return`diffs-icon-symbol-added`;case`deleted`:return`diffs-icon-symbol-deleted`;case`rename-pure`:case`rename-changed`:return`diffs-icon-symbol-moved`}}function gW({fileOrDiff:e,mode:t,stickyHeader:n}){let r=`type`in e?e:void 0,i={"data-diffs-header":t,"data-change-type":r?.type,"data-sticky":n?``:void 0};return B({tagName:`div`,children:[t===`custom`?B({tagName:`slot`,properties:{name:Yj}}):_W({name:e.name,prevName:`prevName`in e?e.prevName:void 0,iconType:r?.type??`file`}),...t===`custom`?[]:[vW(r)]],properties:i})}function _W({name:e,prevName:t,iconType:n}){let r=[B({tagName:`slot`,properties:{name:Kj}}),aN({name:hW(n),properties:{"data-change-icon":n}})];return t!=null&&(r.push(B({tagName:`div`,children:[B({tagName:`bdi`,children:[iN(t)]})],properties:{"data-prev-name":``}})),r.push(aN({name:`diffs-icon-arrow-right-short`,properties:{"data-rename-icon":``}}))),r.push(B({tagName:`div`,children:[B({tagName:`bdi`,children:[iN(e)]})],properties:{"data-title":``}})),r.push(B({tagName:`slot`,properties:{name:qj}})),B({tagName:`div`,children:r,properties:{"data-header-content":``}})}function vW(e){let t=[];if(e!=null){let n=0,r=0;for(let t of e.hunks)n+=t.additionLines,r+=t.deletionLines;(r>0||n===0)&&t.push(B({tagName:`span`,children:[iN(`-${r}`)],properties:{"data-deletions-count":``}})),(n>0||r===0)&&t.push(B({tagName:`span`,children:[iN(`+${n}`)],properties:{"data-additions-count":``}}))}return t.push(B({tagName:`slot`,properties:{name:Jj}})),B({tagName:`div`,children:t,properties:{"data-metadata":``}})}function yW(e){return B({tagName:`pre`,properties:bW(e)})}function bW({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:r,split:i,totalLines:a,type:o,customProperties:s}){return{...s,"data-diff":o===`diff`?``:void 0,"data-file":o===`file`?``:void 0,"data-diff-type":o===`diff`?i?`split`:`single`:void 0,"data-overflow":r,"data-disable-line-numbers":n?``:void 0,"data-background":t?void 0:``,"data-indicators":e===`bars`||e===`classic`?e:void 0,style:`--diffs-min-number-column-width-default:${`${a}`.length}ch;`}}var xW=new Map,SW=0,CW={"1c":`1c`,abap:`abap`,as:`actionscript-3`,ada:`ada`,adb:`ada`,ads:`ada`,adoc:`asciidoc`,asciidoc:`asciidoc`,"component.html":`angular-html`,"component.ts":`angular-ts`,conf:`nginx`,htaccess:`apache`,cls:`tex`,trigger:`apex`,apl:`apl`,applescript:`applescript`,scpt:`applescript`,ara:`ara`,asm:`asm`,s:`riscv`,astro:`astro`,awk:`awk`,bal:`ballerina`,sh:`zsh`,bash:`zsh`,bat:`cmd`,cmd:`cmd`,be:`berry`,beancount:`beancount`,bib:`bibtex`,bicep:`bicep`,"blade.php":`blade`,bsl:`bsl`,c:`c`,h:`objective-cpp`,cs:`csharp`,cpp:`cpp`,hpp:`cpp`,cc:`cpp`,cxx:`cpp`,hh:`cpp`,cdc:`cdc`,cairo:`cairo`,clar:`clarity`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,soy:`soy`,cmake:`cmake`,"CMakeLists.txt":`cmake`,cob:`cobol`,cbl:`cobol`,cobol:`cobol`,CODEOWNERS:`codeowners`,ql:`ql`,coffee:`coffeescript`,lisp:`lisp`,cl:`lisp`,lsp:`lisp`,log:`log`,v:`verilog`,cql:`cql`,cr:`crystal`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cypher`,cyp:`cypher`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,patch:`diff`,Dockerfile:`dockerfile`,dockerfile:`dockerfile`,env:`dotenv`,dm:`dream-maker`,edge:`edge`,el:`emacs-lisp`,ex:`elixir`,exs:`elixir`,elm:`elm`,erb:`erb`,erl:`erlang`,hrl:`erlang`,f:`fortran-fixed-form`,for:`fortran-fixed-form`,fs:`fsharp`,fsi:`fsharp`,fsx:`fsharp`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`fortran-free-form`,f95:`fortran-free-form`,fnl:`fennel`,fish:`fish`,ftl:`ftl`,tres:`gdresource`,res:`gdresource`,gd:`gdscript`,gdshader:`gdshader`,gs:`genie`,feature:`gherkin`,COMMIT_EDITMSG:`git-commit`,"git-rebase-todo":`git-rebase`,gjs:`glimmer-js`,gleam:`gleam`,gts:`glimmer-ts`,glsl:`glsl`,vert:`glsl`,frag:`glsl`,shader:`shaderlab`,gp:`gnuplot`,plt:`gnuplot`,gnuplot:`gnuplot`,go:`go`,graphql:`graphql`,gql:`graphql`,groovy:`groovy`,gvy:`groovy`,hack:`hack`,haml:`haml`,hbs:`handlebars`,handlebars:`handlebars`,hs:`haskell`,lhs:`haskell`,hx:`haxe`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,fx:`hlsl`,html:`html`,htm:`html`,http:`http`,rest:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,cfg:`ini`,jade:`pug`,pug:`pug`,java:`java`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jinja:`jinja`,jinja2:`jinja`,j2:`jinja`,jison:`jison`,jl:`julia`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,libsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,kt:`kotlin`,kts:`kts`,kql:`kusto`,tex:`tex`,ltx:`tex`,lean:`lean4`,less:`less`,liquid:`liquid`,lit:`lit`,ll:`llvm`,logo:`logo`,lua:`lua`,luau:`luau`,Makefile:`makefile`,mk:`makefile`,makefile:`makefile`,md:`markdown`,markdown:`markdown`,marko:`marko`,m:`wolfram`,mat:`matlab`,mdc:`mdc`,mdx:`mdx`,wiki:`wikitext`,mediawiki:`wikitext`,mmd:`mermaid`,mermaid:`mermaid`,mips:`mipsasm`,mojo:`mojo`,"🔥":`mojo`,move:`move`,nar:`narrat`,nf:`nextflow`,nim:`nim`,nims:`nim`,nimble:`nim`,nix:`nix`,nu:`nushell`,mm:`objective-cpp`,ml:`ocaml`,mli:`ocaml`,mll:`ocaml`,mly:`ocaml`,pas:`pascal`,p:`pascal`,pl:`prolog`,pm:`perl`,t:`perl`,raku:`raku`,p6:`raku`,pl6:`raku`,php:`php`,phtml:`php`,pls:`plsql`,sql:`sql`,po:`po`,polar:`polar`,pcss:`postcss`,pot:`pot`,potx:`potx`,pq:`powerquery`,pqm:`powerquery`,ps1:`powershell`,psm1:`powershell`,psd1:`powershell`,prisma:`prisma`,pro:`prolog`,P:`prolog`,properties:`properties`,proto:`protobuf`,pp:`puppet`,purs:`purescript`,py:`python`,pyw:`python`,pyi:`python`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,R:`r`,rkt:`racket`,rktl:`racket`,razor:`razor`,cshtml:`razor`,rb:`ruby`,rbw:`ruby`,reg:`reg`,regex:`regexp`,rel:`rel`,rs:`rust`,rst:`rst`,rake:`ruby`,gemspec:`ruby`,jbuilder:`ruby`,builder:`ruby`,rabl:`ruby`,arb:`ruby`,ru:`ruby`,podspec:`ruby`,Gemfile:`ruby`,Rakefile:`ruby`,Guardfile:`ruby`,Capfile:`ruby`,Berksfile:`ruby`,Brewfile:`ruby`,Vagrantfile:`ruby`,Thorfile:`ruby`,Appraisals:`ruby`,Dangerfile:`ruby`,sas:`sas`,sass:`sass`,scala:`scala`,sc:`scala`,scm:`scheme`,ss:`scheme`,sld:`scheme`,scss:`scss`,sdbl:`sdbl`,shadergraph:`shader`,st:`smalltalk`,sol:`solidity`,sparql:`sparql`,rq:`sparql`,spl:`splunk`,config:`ssh-config`,do:`stata`,ado:`stata`,dta:`stata`,styl:`stylus`,stylus:`stylus`,svelte:`svelte`,swift:`swift`,sv:`system-verilog`,svh:`system-verilog`,service:`systemd`,socket:`systemd`,device:`systemd`,timer:`systemd`,talon:`talonscript`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`typescript`,mts:`typescript`,cts:`typescript`,tsp:`typespec`,tsv:`tsv`,tsx:`tsx`,ttl:`turtle`,twig:`twig`,typ:`typst`,vv:`v`,vala:`vala`,vapi:`vala`,vb:`vb`,vbs:`vb`,bas:`vb`,vh:`verilog`,vhd:`vhdl`,vhdl:`vhdl`,vim:`vimscript`,vue:`vue`,"vine.ts":`vue-vine`,vy:`vyper`,wasm:`wasm`,wat:`wasm`,wy:`文言`,wgsl:`wgsl`,wit:`wit`,wl:`wolfram`,nb:`wolfram`,xml:`xml`,xsl:`xsl`,xslt:`xsl`,yaml:`yaml`,yml:`yml`,zs:`zenscript`,zig:`zig`,zsh:`zsh`,sty:`tex`};function wW(e){if(xW.has(e))return xW.get(e)??`text`;if(CW[e]!=null)return CW[e];let t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(t!=null){if(xW.has(t[1]))return xW.get(t[1])??`text`;if(CW[t[1]]!=null)return CW[t[1]]??`text`}let n=e.match(/\.([^.]+)$/)?.[1]??``;return xW.has(n)?xW.get(n)??`text`:CW[n]??`text`}function TW(){return SW}function EW(){return Object.fromEntries(xW)}function DW(e,{theme:t,preferredHighlighter:n=`shiki-js`}){return{langs:[e??`text`],themes:lW(t),preferredHighlighter:n}}function OW(e){return`annotation-${`side`in e?`${e.side}-`:``}${e.lineNumber}`}function kW(e,t,n){let r=typeof n.lineInfo==`function`?n.lineInfo(t):n.lineInfo[t-1];if(r==null){let r=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(r,{node:e,line:t,state:n}),Error(r)}return e.tagName=`div`,e.properties[`data-line`]=r.lineNumber,e.properties[`data-alt-line`]=r.altLineNumber,e.properties[`data-line-type`]=r.type,e.properties[`data-line-index`]=r.lineIndex,e.children.length===0&&e.children.push(iN(`
|
|
185
|
-
`)),e}var
|
|
184
|
+
\v\f
\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${Z(e.codePointAt(0)-1)}${Z(e.codePointAt(2)+1)}-\u{10FFFF}`),n($(YH(`[${e}]`),t))}else n($(XH(YH(wH.get(u)),l),t));else if(c===`property`)bH.has(kV(u))||(e.key=`sc`);else if(c===`space`)n(ZH(xV(`space`,{negate:l}),t));else if(c===`word`)n($(XH(YH(vH),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=mV({flags:c});e.body[0].body=o(),i($(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&GB(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error(Q`Uses "\K" in a way that's unsupported`);let o=hV({behind:!0});o.body[0].body=a(),i($(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n($(hV({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=mV();t.body[0].body.push(e.body),e.body=$(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=UH(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error(Q`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!JH(n)&&(n=zH(n,t),e.ref=n)}},jH={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=ZH(LH(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&uH(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=uH(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=lH(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&(n.type!==`CapturingGroup`||n.name!==a&&n.number!==a););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?LH(0):IH(o,r.groupOriginByCopy,null),l=c;if(!s){let e=BH(RH(o,e=>e.type===`Group`&&!!e.flags)),t=e?lH(r.globalFlags,e):r.globalFlags;PH(t,r.currentFlags)||(l=mV({flags:VH(t)}),l.body[0].body.push(c))}n($(l,t),{traverse:!s})}},MH={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>FH(t,e));i.length?i.length>1?n($(mV({atomic:!0,body:i.reverse().map(e=>iV({body:[oV(e.number)]}))}),t)):e.ref=i[0].number:n($(hV({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=sV();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function NH(e){MV(e,{"*"({node:e,parent:t}){e.parent=t}})}function PH(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function FH(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=HH(n.parent);for(let r of t){if(r===n)break;if(r===e||WH(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function IH(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=IH(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function LH(e){let t=bV(e);return t.isRecursive=!0,t}function RH(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function zH(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function BH(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function VH({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function HH(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function UH(e){let t=e.find(e=>e.kind===`search_start`||qH(e,{negate:!1})||!GH(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=UH(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function WH(e,t){let n=HH(e)??[];for(let e of n)if(e===t||WH(e,t))return!0;return!1}function GH({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function KH(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function qH(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&GB(e.body[0],{type:`Assertion`,kind:`search_start`})}function JH(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function YH(e,t){let n=JB(e,{...t,unicodePropertyMap:bH}).body;return n.length>1||n[0].body.length>1?mV({body:n}):n[0].body[0]}function XH(e,t){return e.negate=t,e}function ZH(e,t){return e.parent=t,e}function $(e,t){return NH(e),e.parent=t,e}function QH(e,t){let n=hH(t),r=dH(n.target,`ES2024`),i=dH(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];MV(e,$H,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,fH(eU[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&uH(f._captureTransfers,e.transferTo,[]).push(t)}),f}var $H={"*":{enter({node:e},t){if(fU(e)){let n=t.getCurrentModI();t.pushModI(e.flags?lH({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){fU(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){oU(Z(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),sU(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&OH.has(e.value)&&t.setHasCasedChar()}},eU={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?Q`\B`:Q`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=Z(e),r=cU(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&oU(n)){let e=yH(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);sH.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(mU)&&(o=[cV(45),...o.filter(e=>!mU(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||sH.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=mV(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=iV({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(sH.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=cU(n,i),o=cU(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&lU(sU(e)).forEach(e=>{s.add(Array.isArray(e)?`${cU(e[0],i)}-${cU(e[1],i)}`:cU(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:Q`[^\n]`;if(e===`digit`)return t?Q`\D`:Q`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&OH.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?Q`\P`:Q`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?Q`\W`:Q`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=lH(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${uU(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+dU(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:Q`\g<${t}&R=${r}>`}},tU=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),nU=new Set([`-`,`\\`,`]`,`^`,`[`]),rU=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),iU=new Map([[9,Q`\t`],[10,Q`\n`],[11,Q`\v`],[12,Q`\f`],[13,Q`\r`],[8232,Q`\u2028`],[8233,Q`\u2029`],[65279,Q`\uFEFF`]]),aU=/^\p{Cased}$/u;function oU(e){return aU.test(e)}function sU(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=Z(e);if(!oU(t))continue;let o=yH(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function cU(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(iU.has(e))return iU.get(e);if(e<32||e>126&&e<160||e>262143||t&&pU(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?rU:nU:tU,a=Z(e);return(i.has(a)?`\\`:``)+a}function lU(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function uU(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function dU({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function fU({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function pU(e){return e>47&&e<58}function mU({type:e,value:t}){return e===`Character`&&t===45}var hU=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=_U(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(gU(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=vU(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function gU(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function _U(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)uH(n,t,{}).transferTo=e;return n}function vU(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function yU(e,t){let n=bU(e,t);return n.options?new hU(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function bU(e,t){let n=hH(t),r=kH(JB(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:bH}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=QH(r,n),a=tH(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=GV(JV(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}function xU(e,t){return yU(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function SU(e={}){let t=Object.assign({target:`auto`,cache:new Map},e);return t.regexConstructor||=e=>xU(e,{target:t.target}),{createScanner(e){return new tB(e,t)},createString(e){return{content:e}}}}async function CU(e){if(eI())throw Error(`resolveLanguage("${e}") cannot be called from a worker context. Languages must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);let t=YF.get(e);if(t!=null)return t;try{let t=XF.get(e);if(t==null&&Object.prototype.hasOwnProperty.call(dI,e)&&(t=dI[e]),t==null)throw Error(`resolveLanguage: "${e}" not found in bundled or custom languages`);let n=t().then(({default:t})=>{let n={name:e,data:t};return JF.has(e)||JF.set(e,n),n});return YF.set(e,n),await n}finally{YF.delete(e)}}function wU(e){return JF.get(e)??CU(e)}var TU=new Set;function EU(e){let t=[],n=new Set;for(let r of DU(e.themes)){let e=AU(r)?r.getThemes():[r];for(let r of e){if(n.has(r.name))throw Error(`Theme collection already contains theme "${r.name}"`);n.add(r.name),t.push(r)}}let r=Object.freeze([...t]),i=Object.freeze(r.filter(e=>e.colorScheme===`light`)),a=Object.freeze(r.filter(e=>e.colorScheme===`dark`)),o=new Map(r.map(e=>[e.name,e])),s=Object.freeze(r.map(e=>e.name)),c=Object.freeze(i.map(e=>e.name)),l=Object.freeze(a.map(e=>e.name));function u(e){if(e==null)return r;let{colorScheme:t,collection:n}=e;return n==null?t===`light`?i:t===`dark`?a:r:r.filter(e=>e.collection===n?t==null||e.colorScheme===t:!1)}return{getTheme(e){return o.get(e)},getThemes(e){return u(e)},getThemeNames(e){return e?.collection==null?e?.colorScheme===`light`?c:e?.colorScheme===`dark`?l:s:u(e).map(e=>e.name)},hasTheme(e){return o.has(e)},orderBy(e){return EU({themes:r.map((e,t)=>({descriptor:e,index:t})).sort((t,n)=>{let r=e(t.descriptor,n.descriptor);return r===0?t.index-n.index:r}).map(e=>e.descriptor)})},pick(e){let t=[],n=new Set;for(let r of e){if(n.has(r))throw Error(`Theme collection pick already includes theme "${r}"`);n.add(r);let e=o.get(r);if(e==null)throw Error(`Theme collection does not contain theme "${r}"`);t.push(e)}return EU({themes:t})},registerInto(e){for(let t of r)e.registerThemeIfAbsent(t.name,t.load)}}}function DU(e){return OU(e)?[e]:e}function OU(e){return AU(e)||kU(e)}function kU(e){return typeof e.name==`string`&&typeof e.load==`function`}function AU(e){return typeof e.getThemes==`function`}function jU(e){return typeof e==`object`&&e&&`default`in e?e.default:e}var MU=class extends Error{constructor(e){super(`Theme "${e}" is already registered`),this.name=`DuplicateThemeError`}},NU=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`),this.name=`UnregisteredThemeError`}},PU=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`),this.name=`UnresolvedThemeError`}};function FU(){let e=new Map,t=new Map,n=new Map,r=0;function i(t,n){if(e.has(t))throw new MU(t);e.set(t,n)}function a(t,n){return!e.has(t)&&(e.set(t,n),!0)}function o(t){return e.has(t)}function s(i){let a=t.get(i);if(a!==void 0)return Promise.resolve(a);let o=n.get(i);if(o!==void 0)return o;let s=e.get(i);if(s===void 0)return Promise.reject(new NU(i));let c=r,l=s().then(e=>{let a=jU(e);return c===r&&t.set(i,a),n.get(i)===l&&n.delete(i),a}).catch(e=>{throw n.get(i)===l&&n.delete(i),e});return n.set(i,l),l}function c(e){return Promise.all(e.map(e=>s(e)))}function l(e,n){t.set(e,n)}function u(e){for(let[t,n]of e)l(t,n)}function d(e){return t.get(e)}function f(e){let n=[];for(let r of e){let e=t.get(r);if(e===void 0)throw new PU(r);n.push(e)}return n}function p(e){return t.has(e)}function m(e){for(let n of e)if(!t.has(n))return!1;return!0}function h(e){let n=t.get(e);return n===void 0?s(e):n}function g(){r++,t.clear(),n.clear()}return{clearResolvedThemes:g,getResolvedOrResolveTheme:h,getResolvedTheme:d,getResolvedThemes:f,hasRegisteredTheme:o,hasResolvedTheme:p,hasResolvedThemes:m,registerTheme:i,registerThemeIfAbsent:a,resolveTheme:s,resolveThemes:c,seedResolvedTheme:l,seedResolvedThemes:u}}var IU=FU();function LU(e,t){e=Array.isArray(e)?e:[e];for(let n of e){let e;if(typeof n==`string`){if(e=IU.getResolvedTheme(n),e==null)throw Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else e=n,n=n.name,IU.getResolvedTheme(n)??IU.seedResolvedTheme(n,e);TU.has(n)||(TU.add(n),t.loadThemeSync(e))}}function RU({name:e,load:t,colorScheme:n,collection:r,displayName:i}){return{name:e,colorScheme:n,collection:r,displayName:i,load:zU(t)}}function zU(e){return async()=>NR(jU(await e()))}var BU=`pierre`,VU=[`pierre-dark`,`pierre-dark-soft`,`pierre-dark-vibrant`,`pierre-dark-protanopia-deuteranopia`,`pierre-dark-tritanopia`],HU=[`pierre-light`,`pierre-light-soft`,`pierre-light-vibrant`,`pierre-light-protanopia-deuteranopia`,`pierre-light-tritanopia`],UU=[...HU,...VU],WU=new Set(HU);function GU(e){return WU.has(e)?`light`:`dark`}var KU={"pierre-dark":`Pierre Dark`,"pierre-dark-soft":`Pierre Dark Soft`,"pierre-dark-vibrant":`Pierre Dark Vibrant`,"pierre-dark-protanopia-deuteranopia":`Pierre Dark Protanopia & Deuteranopia`,"pierre-dark-tritanopia":`Pierre Dark Tritanopia`,"pierre-light":`Pierre Light`,"pierre-light-soft":`Pierre Light Soft`,"pierre-light-vibrant":`Pierre Light Vibrant`,"pierre-light-protanopia-deuteranopia":`Pierre Light Protanopia & Deuteranopia`,"pierre-light-tritanopia":`Pierre Light Tritanopia`},qU={"pierre-dark":()=>D(()=>import(`./pierre-dark-CpLgRqie.js`),[]),"pierre-dark-soft":()=>D(()=>import(`./pierre-dark-soft-kZQmAZld.js`),[]),"pierre-dark-vibrant":()=>D(()=>import(`./pierre-dark-vibrant-CpQYzh95.js`),[]),"pierre-dark-protanopia-deuteranopia":()=>D(()=>import(`./pierre-dark-protanopia-deuteranopia-B35FxJx-.js`),[]),"pierre-dark-tritanopia":()=>D(()=>import(`./pierre-dark-tritanopia-CpjhbsIL.js`),[]),"pierre-light":()=>D(()=>import(`./pierre-light-CoaEpmwp.js`),[]),"pierre-light-soft":()=>D(()=>import(`./pierre-light-soft-lWLdNTOI.js`),[]),"pierre-light-vibrant":()=>D(()=>import(`./pierre-light-vibrant-D80Fkn33.js`),[]),"pierre-light-protanopia-deuteranopia":()=>D(()=>import(`./pierre-light-protanopia-deuteranopia-0fSaH845.js`),[]),"pierre-light-tritanopia":()=>D(()=>import(`./pierre-light-tritanopia-CEbqgOJL.js`),[])};function JU(e){return RU({name:e,collection:BU,colorScheme:GU(e),displayName:KU[e],load:qU[e]})}var YU=EU({themes:UU.map(e=>JU(e))}),XU=`shiki`,ZU=[`ayu-light`,`catppuccin-latte`,`everforest-light`,`github-light`,`github-light-default`,`github-light-high-contrast`,`gruvbox-light-hard`,`gruvbox-light-medium`,`gruvbox-light-soft`,`horizon-bright`,`kanagawa-lotus`,`light-plus`,`material-theme-lighter`,`min-light`,`night-owl-light`,`one-light`,`rose-pine-dawn`,`slack-ochin`,`snazzy-light`,`solarized-light`,`vitesse-light`],QU=`andromeeda.aurora-x.ayu-dark.ayu-mirage.catppuccin-frappe.catppuccin-macchiato.catppuccin-mocha.dark-plus.dracula.dracula-soft.everforest-dark.github-dark.github-dark-default.github-dark-dimmed.github-dark-high-contrast.gruvbox-dark-hard.gruvbox-dark-medium.gruvbox-dark-soft.horizon.houston.kanagawa-dragon.kanagawa-wave.laserwave.material-theme.material-theme-darker.material-theme-ocean.material-theme-palenight.min-dark.monokai.night-owl.nord.one-dark-pro.plastic.poimandres.red.rose-pine.rose-pine-moon.slack-dark.solarized-dark.synthwave-84.tokyo-night.vesper.vitesse-black.vitesse-dark`.split(`.`),$U=new Set(ZU);function eW(e){return $U.has(e)?`light`:`dark`}var tW={andromeeda:()=>D(()=>import(`./andromeeda-vGVdxbeo.js`),[]),"aurora-x":()=>D(()=>import(`./aurora-x-CDeNXAV0.js`),[]),"ayu-dark":()=>D(()=>import(`./ayu-dark-DluEY0Gj.js`),[]),"ayu-light":()=>D(()=>import(`./ayu-light-C3h-C4tm.js`),[]),"ayu-mirage":()=>D(()=>import(`./ayu-mirage-Bqwy1Gya.js`),[]),"catppuccin-frappe":()=>D(()=>import(`./catppuccin-frappe-3VR1Za6u.js`),[]),"catppuccin-latte":()=>D(()=>import(`./catppuccin-latte-DwIHMF0Q.js`),[]),"catppuccin-macchiato":()=>D(()=>import(`./catppuccin-macchiato-DYnBP6_5.js`),[]),"catppuccin-mocha":()=>D(()=>import(`./catppuccin-mocha-DYhrFGRu.js`),[]),"dark-plus":()=>D(()=>import(`./dark-plus-Cs2F2srj.js`),[]),dracula:()=>D(()=>import(`./dracula-BHWKrbxM.js`),[]),"dracula-soft":()=>D(()=>import(`./dracula-soft-5eyTD99u.js`),[]),"everforest-dark":()=>D(()=>import(`./everforest-dark-sB-x3p7T.js`),[]),"everforest-light":()=>D(()=>import(`./everforest-light-Df2xbC6M.js`),[]),"github-dark":()=>D(()=>import(`./github-dark-C-LZuMrd.js`),[]),"github-dark-default":()=>D(()=>import(`./github-dark-default-DXG-b-1a.js`),[]),"github-dark-dimmed":()=>D(()=>import(`./github-dark-dimmed-Bx1FflLF.js`),[]),"github-dark-high-contrast":()=>D(()=>import(`./github-dark-high-contrast-B_tTalzw.js`),[]),"github-light":()=>D(()=>import(`./github-light-EUqPIrTm.js`),[]),"github-light-default":()=>D(()=>import(`./github-light-default-BXViO-2h.js`),[]),"github-light-high-contrast":()=>D(()=>import(`./github-light-high-contrast-B68TUdTA.js`),[]),"gruvbox-dark-hard":()=>D(()=>import(`./gruvbox-dark-hard-C820rvS2.js`),[]),"gruvbox-dark-medium":()=>D(()=>import(`./gruvbox-dark-medium-BPjhmG05.js`),[]),"gruvbox-dark-soft":()=>D(()=>import(`./gruvbox-dark-soft-MrdJrrXF.js`),[]),"gruvbox-light-hard":()=>D(()=>import(`./gruvbox-light-hard-BC_s9l72.js`),[]),"gruvbox-light-medium":()=>D(()=>import(`./gruvbox-light-medium-BAWPOn9u.js`),[]),"gruvbox-light-soft":()=>D(()=>import(`./gruvbox-light-soft-BSMLrYjP.js`),[]),horizon:()=>D(()=>import(`./horizon-CE9ld1lL.js`),[]),"horizon-bright":()=>D(()=>import(`./horizon-bright-DSNQnXHK.js`),[]),houston:()=>D(()=>import(`./houston-CsvMBhTu.js`),[]),"kanagawa-dragon":()=>D(()=>import(`./kanagawa-dragon-CXtmUGW6.js`),[]),"kanagawa-lotus":()=>D(()=>import(`./kanagawa-lotus-BN08jTvb.js`),[]),"kanagawa-wave":()=>D(()=>import(`./kanagawa-wave-CTweb8Dz.js`),[]),laserwave:()=>D(()=>import(`./laserwave-C_8bwKvT.js`),[]),"light-plus":()=>D(()=>import(`./light-plus-DVQuIRkW.js`),[]),"material-theme":()=>D(()=>import(`./material-theme-Bm3Qr25_.js`),[]),"material-theme-darker":()=>D(()=>import(`./material-theme-darker-2IIEA8gg.js`),[]),"material-theme-lighter":()=>D(()=>import(`./material-theme-lighter-uhdI0v04.js`),[]),"material-theme-ocean":()=>D(()=>import(`./material-theme-ocean-CHQ94UKr.js`),[]),"material-theme-palenight":()=>D(()=>import(`./material-theme-palenight-B5W6OYN7.js`),[]),"min-dark":()=>D(()=>import(`./min-dark-BSWPekZh.js`),[]),"min-light":()=>D(()=>import(`./min-light-DDpmG2fV.js`),[]),monokai:()=>D(()=>import(`./monokai-CdkpiU2Y.js`),[]),"night-owl":()=>D(()=>import(`./night-owl-DhmEMT88.js`),[]),"night-owl-light":()=>D(()=>import(`./night-owl-light-eJ-hLW7d.js`),[]),nord:()=>D(()=>import(`./nord-Cb4Vim4T.js`),[]),"one-dark-pro":()=>D(()=>import(`./one-dark-pro-CLwyXe_n.js`),[]),"one-light":()=>D(()=>import(`./one-light-D7Lr4KcI.js`),[]),plastic:()=>D(()=>import(`./plastic-DQwYfKfQ.js`),[]),poimandres:()=>D(()=>import(`./poimandres-DRFjx7u4.js`),[]),red:()=>D(()=>import(`./red-CJ3rzSJv.js`),[]),"rose-pine":()=>D(()=>import(`./rose-pine-BthvhNj6.js`),[]),"rose-pine-dawn":()=>D(()=>import(`./rose-pine-dawn-Dg85fqjY.js`),[]),"rose-pine-moon":()=>D(()=>import(`./rose-pine-moon-hon4tzzS.js`),[]),"slack-dark":()=>D(()=>import(`./slack-dark-DnToyrRv.js`),[]),"slack-ochin":()=>D(()=>import(`./slack-ochin-B2OO5cIa.js`),[]),"snazzy-light":()=>D(()=>import(`./snazzy-light-4G7pJPwS.js`),[]),"solarized-dark":()=>D(()=>import(`./solarized-dark-DV17i1UV.js`),[]),"solarized-light":()=>D(()=>import(`./solarized-light-DSh2HLQt.js`),[]),"synthwave-84":()=>D(()=>import(`./synthwave-84-nFMaYfgc.js`),[]),"tokyo-night":()=>D(()=>import(`./tokyo-night-oM2G3aXe.js`),[]),vesper:()=>D(()=>import(`./vesper-DdrHHSXu.js`),[]),"vitesse-black":()=>D(()=>import(`./vitesse-black-fwtXNY1n.js`),[]),"vitesse-dark":()=>D(()=>import(`./vitesse-dark-BZCL-v6S.js`),[]),"vitesse-light":()=>D(()=>import(`./vitesse-light-VbXTXTou.js`),[])};function nW(e){return RU({name:e,collection:XU,colorScheme:eW(e),load:tW[e]})}var rW=EU({themes:Object.freeze([...ZU.map(e=>nW(e)),...QU.map(e=>nW(e))])});function iW(e){if(eI())throw Error(`Theme "${e}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);if(IU.hasRegisteredTheme(e))return;let t=rW.getTheme(e);if(t!=null){IU.registerThemeIfAbsent(t.name,t.load);return}throw Error(`No valid theme loader registered for "${e}"`)}function aW(e,t){if(t.name!==e)throw Error(`resolvedTheme: themeName: ${e} does not match theme.name: ${t.name}`)}async function oW(e){iW(e);let t=await IU.resolveTheme(e);return aW(e,t),t}function sW(e){return IU.getResolvedTheme(e)??oW(e)}var cW;async function lW({themes:e,langs:t,preferredHighlighter:n=`shiki-js`}){cW??=Kz({themes:[],langs:[`text`],engine:n===`shiki-wasm`?zI(D(()=>import(`./wasm-BnjxR4X6.js`),[])):SU()});let r=dW(cW)?await cW:cW;cW=r;let i=[];for(let e of t){if(e===`text`||e===`ansi`)continue;let t=wU(e);`then`in t?i.push(t):$F(t,r)}let a=[];for(let t of e){let e=sW(t);`then`in e?a.push(e):LU(e,cW)}return(i.length>0||a.length>0)&&await Promise.all([Promise.all(i).then(e=>{$F(e,r)}),Promise.all(a).then(e=>{LU(e,r)})]),r}function uW(){if(cW!=null&&!(`then`in cW))return cW}function dW(e=cW){return e!=null&&`then`in e}for(let e of YU.getThemes())IU.registerThemeIfAbsent(e.name,e.load);function fW(e=$j){let t=[];return typeof e==`string`?t.push(e):(t.push(e.dark),t.push(e.light)),t}function pW(e){for(let t of fW(e))if(!TU.has(t))return!1;return!0}function mW(e){return IU.hasResolvedThemes(e)}function hW(e,t){return bM(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function gW(e,t){return e==null||t==null?e===t:e.startingLine===t.startingLine&&e.totalLines===t.totalLines&&e.bufferBefore===t.bufferBefore&&e.bufferAfter===t.bufferAfter}function _W(e){return B({tagName:`div`,children:[B({tagName:`div`,children:e.annotations?.map(e=>B({tagName:`slot`,properties:{name:e}})),properties:{"data-annotation-content":``}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function vW(e){switch(e){case`file`:return`diffs-icon-file-code`;case`change`:return`diffs-icon-symbol-modified`;case`new`:return`diffs-icon-symbol-added`;case`deleted`:return`diffs-icon-symbol-deleted`;case`rename-pure`:case`rename-changed`:return`diffs-icon-symbol-moved`}}function yW({fileOrDiff:e,mode:t,stickyHeader:n}){let r=`type`in e?e:void 0,i={"data-diffs-header":t,"data-change-type":r?.type,"data-sticky":n?``:void 0};return B({tagName:`div`,children:[t===`custom`?B({tagName:`slot`,properties:{name:Qj}}):bW({name:e.name,prevName:`prevName`in e?e.prevName:void 0,iconType:r?.type??`file`}),...t===`custom`?[]:[xW(r)]],properties:i})}function bW({name:e,prevName:t,iconType:n}){let r=[B({tagName:`slot`,properties:{name:Yj}}),cN({name:vW(n),properties:{"data-change-icon":n}})];return t!=null&&(r.push(B({tagName:`div`,children:[B({tagName:`bdi`,children:[sN(t)]})],properties:{"data-prev-name":``}})),r.push(cN({name:`diffs-icon-arrow-right-short`,properties:{"data-rename-icon":``}}))),r.push(B({tagName:`div`,children:[B({tagName:`bdi`,children:[sN(e)]})],properties:{"data-title":``}})),r.push(B({tagName:`slot`,properties:{name:Xj}})),B({tagName:`div`,children:r,properties:{"data-header-content":``}})}function xW(e){let t=[];if(e!=null){let n=0,r=0;for(let t of e.hunks)n+=t.additionLines,r+=t.deletionLines;(r>0||n===0)&&t.push(B({tagName:`span`,children:[sN(`-${r}`)],properties:{"data-deletions-count":``}})),(n>0||r===0)&&t.push(B({tagName:`span`,children:[sN(`+${n}`)],properties:{"data-additions-count":``}}))}return t.push(B({tagName:`slot`,properties:{name:Zj}})),B({tagName:`div`,children:t,properties:{"data-metadata":``}})}function SW(e){return B({tagName:`pre`,properties:CW(e)})}function CW({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:r,split:i,totalLines:a,type:o,customProperties:s}){return{...s,"data-diff":o===`diff`?``:void 0,"data-file":o===`file`?``:void 0,"data-diff-type":o===`diff`?i?`split`:`single`:void 0,"data-overflow":r,"data-disable-line-numbers":n?``:void 0,"data-background":t?void 0:``,"data-indicators":e===`bars`||e===`classic`?e:void 0,style:`--diffs-min-number-column-width-default:${`${a}`.length}ch;`}}var wW=new Map,TW=0,EW={"1c":`1c`,abap:`abap`,as:`actionscript-3`,ada:`ada`,adb:`ada`,ads:`ada`,adoc:`asciidoc`,asciidoc:`asciidoc`,"component.html":`angular-html`,"component.ts":`angular-ts`,conf:`nginx`,htaccess:`apache`,cls:`tex`,trigger:`apex`,apl:`apl`,applescript:`applescript`,scpt:`applescript`,ara:`ara`,asm:`asm`,s:`riscv`,astro:`astro`,awk:`awk`,bal:`ballerina`,sh:`zsh`,bash:`zsh`,bat:`cmd`,cmd:`cmd`,be:`berry`,beancount:`beancount`,bib:`bibtex`,bicep:`bicep`,"blade.php":`blade`,bsl:`bsl`,c:`c`,h:`objective-cpp`,cs:`csharp`,cpp:`cpp`,hpp:`cpp`,cc:`cpp`,cxx:`cpp`,hh:`cpp`,cdc:`cdc`,cairo:`cairo`,clar:`clarity`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,soy:`soy`,cmake:`cmake`,"CMakeLists.txt":`cmake`,cob:`cobol`,cbl:`cobol`,cobol:`cobol`,CODEOWNERS:`codeowners`,ql:`ql`,coffee:`coffeescript`,lisp:`lisp`,cl:`lisp`,lsp:`lisp`,log:`log`,v:`verilog`,cql:`cql`,cr:`crystal`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cypher`,cyp:`cypher`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,patch:`diff`,Dockerfile:`dockerfile`,dockerfile:`dockerfile`,env:`dotenv`,dm:`dream-maker`,edge:`edge`,el:`emacs-lisp`,ex:`elixir`,exs:`elixir`,elm:`elm`,erb:`erb`,erl:`erlang`,hrl:`erlang`,f:`fortran-fixed-form`,for:`fortran-fixed-form`,fs:`fsharp`,fsi:`fsharp`,fsx:`fsharp`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`fortran-free-form`,f95:`fortran-free-form`,fnl:`fennel`,fish:`fish`,ftl:`ftl`,tres:`gdresource`,res:`gdresource`,gd:`gdscript`,gdshader:`gdshader`,gs:`genie`,feature:`gherkin`,COMMIT_EDITMSG:`git-commit`,"git-rebase-todo":`git-rebase`,gjs:`glimmer-js`,gleam:`gleam`,gts:`glimmer-ts`,glsl:`glsl`,vert:`glsl`,frag:`glsl`,shader:`shaderlab`,gp:`gnuplot`,plt:`gnuplot`,gnuplot:`gnuplot`,go:`go`,graphql:`graphql`,gql:`graphql`,groovy:`groovy`,gvy:`groovy`,hack:`hack`,haml:`haml`,hbs:`handlebars`,handlebars:`handlebars`,hs:`haskell`,lhs:`haskell`,hx:`haxe`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,fx:`hlsl`,html:`html`,htm:`html`,http:`http`,rest:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,cfg:`ini`,jade:`pug`,pug:`pug`,java:`java`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jinja:`jinja`,jinja2:`jinja`,j2:`jinja`,jison:`jison`,jl:`julia`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,libsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,kt:`kotlin`,kts:`kts`,kql:`kusto`,tex:`tex`,ltx:`tex`,lean:`lean4`,less:`less`,liquid:`liquid`,lit:`lit`,ll:`llvm`,logo:`logo`,lua:`lua`,luau:`luau`,Makefile:`makefile`,mk:`makefile`,makefile:`makefile`,md:`markdown`,markdown:`markdown`,marko:`marko`,m:`wolfram`,mat:`matlab`,mdc:`mdc`,mdx:`mdx`,wiki:`wikitext`,mediawiki:`wikitext`,mmd:`mermaid`,mermaid:`mermaid`,mips:`mipsasm`,mojo:`mojo`,"🔥":`mojo`,move:`move`,nar:`narrat`,nf:`nextflow`,nim:`nim`,nims:`nim`,nimble:`nim`,nix:`nix`,nu:`nushell`,mm:`objective-cpp`,ml:`ocaml`,mli:`ocaml`,mll:`ocaml`,mly:`ocaml`,pas:`pascal`,p:`pascal`,pl:`prolog`,pm:`perl`,t:`perl`,raku:`raku`,p6:`raku`,pl6:`raku`,php:`php`,phtml:`php`,pls:`plsql`,sql:`sql`,po:`po`,polar:`polar`,pcss:`postcss`,pot:`pot`,potx:`potx`,pq:`powerquery`,pqm:`powerquery`,ps1:`powershell`,psm1:`powershell`,psd1:`powershell`,prisma:`prisma`,pro:`prolog`,P:`prolog`,properties:`properties`,proto:`protobuf`,pp:`puppet`,purs:`purescript`,py:`python`,pyw:`python`,pyi:`python`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,R:`r`,rkt:`racket`,rktl:`racket`,razor:`razor`,cshtml:`razor`,rb:`ruby`,rbw:`ruby`,reg:`reg`,regex:`regexp`,rel:`rel`,rs:`rust`,rst:`rst`,rake:`ruby`,gemspec:`ruby`,jbuilder:`ruby`,builder:`ruby`,rabl:`ruby`,arb:`ruby`,ru:`ruby`,podspec:`ruby`,Gemfile:`ruby`,Rakefile:`ruby`,Guardfile:`ruby`,Capfile:`ruby`,Berksfile:`ruby`,Brewfile:`ruby`,Vagrantfile:`ruby`,Thorfile:`ruby`,Appraisals:`ruby`,Dangerfile:`ruby`,sas:`sas`,sass:`sass`,scala:`scala`,sc:`scala`,scm:`scheme`,ss:`scheme`,sld:`scheme`,scss:`scss`,sdbl:`sdbl`,shadergraph:`shader`,st:`smalltalk`,sol:`solidity`,sparql:`sparql`,rq:`sparql`,spl:`splunk`,config:`ssh-config`,do:`stata`,ado:`stata`,dta:`stata`,styl:`stylus`,stylus:`stylus`,svelte:`svelte`,swift:`swift`,sv:`system-verilog`,svh:`system-verilog`,service:`systemd`,socket:`systemd`,device:`systemd`,timer:`systemd`,talon:`talonscript`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`typescript`,mts:`typescript`,cts:`typescript`,tsp:`typespec`,tsv:`tsv`,tsx:`tsx`,ttl:`turtle`,twig:`twig`,typ:`typst`,vv:`v`,vala:`vala`,vapi:`vala`,vb:`vb`,vbs:`vb`,bas:`vb`,vh:`verilog`,vhd:`vhdl`,vhdl:`vhdl`,vim:`vimscript`,vue:`vue`,"vine.ts":`vue-vine`,vy:`vyper`,wasm:`wasm`,wat:`wasm`,wy:`文言`,wgsl:`wgsl`,wit:`wit`,wl:`wolfram`,nb:`wolfram`,xml:`xml`,xsl:`xsl`,xslt:`xsl`,yaml:`yaml`,yml:`yml`,zs:`zenscript`,zig:`zig`,zsh:`zsh`,sty:`tex`};function DW(e){if(wW.has(e))return wW.get(e)??`text`;if(EW[e]!=null)return EW[e];let t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(t!=null){if(wW.has(t[1]))return wW.get(t[1])??`text`;if(EW[t[1]]!=null)return EW[t[1]]??`text`}let n=e.match(/\.([^.]+)$/)?.[1]??``;return wW.has(n)?wW.get(n)??`text`:EW[n]??`text`}function OW(){return TW}function kW(){return Object.fromEntries(wW)}function AW(e,{theme:t,preferredHighlighter:n=`shiki-js`}){return{langs:[e??`text`],themes:fW(t),preferredHighlighter:n}}function jW(e){return`annotation-${`side`in e?`${e.side}-`:``}${e.lineNumber}`}function MW(e,t,n){let r=typeof n.lineInfo==`function`?n.lineInfo(t):n.lineInfo[t-1];if(r==null){let r=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(r,{node:e,line:t,state:n}),Error(r)}return e.tagName=`div`,e.properties[`data-line`]=r.lineNumber,e.properties[`data-alt-line`]=r.altLineNumber,e.properties[`data-line-type`]=r.type,e.properties[`data-line-index`]=r.lineIndex,e.children.length===0&&e.children.push(sN(`
|
|
185
|
+
`)),e}var NW=Symbol(`no-token`),PW=Symbol(`multiple-tokens`);function FW(e){let t=IW(e);if(t!=null)return t;let n=NW,r=[],i=[],a,o=()=>{if(i.length===0||a==null){i=[],a=void 0;return}if(i.length===1){let e=i[0];if(e?.type===`element`){RW(e,a);for(let t of e.children)LW(t)}else LW(e);r.push(e),i=[],a=void 0;return}for(let e of i)LW(e);r.push(B({tagName:`span`,properties:{"data-char":a},children:i})),i=[],a=void 0},s=e=>{if(e!==NW){if(e===PW){n=PW;return}if(n===NW){n=e;return}n!==e&&(n=PW)}};for(let t of e.children){let e=t.type===`element`?FW(t):NW;if(s(e),typeof e!=`number`){o(),r.push(t);continue}a!=null&&a!==e&&o(),a??=e,i.push(t)}return o(),e.children=r,n}function IW(e){let t=e.properties[`data-char`];if(typeof t==`number`)return t}function LW(e){if(e.type===`element`){e.properties[`data-char`]=void 0;for(let t of e.children)LW(t)}}function RW(e,t){e.properties[`data-char`]=t}function zW(e={}){let{classPrefix:t=`__shiki_`,classSuffix:n=``,classReplacer:r=e=>e}=e,i=new Map;function a(e){return Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function o(e){let o=typeof e==`string`?e:a(e),s=t+BW(o)+n;return s=r(s),i.has(s)||i.set(s,typeof e==`string`?e:{...e}),s}return{name:`@shikijs/transformers:style-to-class`,pre(e){if(!e.properties.style)return;let t=o(e.properties.style);delete e.properties.style,this.addClassToHast(e,t)},tokens(e){for(let t of e)for(let e of t){if(!e.htmlStyle)continue;let t=o(e.htmlStyle);e.htmlStyle={},e.htmlAttrs||={},e.htmlAttrs.class?e.htmlAttrs.class+=` ${t}`:e.htmlAttrs.class=t}},getClassRegistry(){return i},getCSS(){let e=``;for(let[t,n]of i.entries())e+=`.${t}{${typeof n==`string`?n:a(n)}}`;return e},clearRegistry(){i.clear()}}}function BW(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&r)+(n>>>0)).toString(36).slice(0,6)}function VW(e=!1,t=!1){let n={lineInfo:[]},r=[{line(e){return delete e.properties.class,e},pre(t){let r=lN(t),i=[];if(r!=null){let t=1;for(let a of r.children)a.type===`element`&&(e&&FW(a),i.push(MW(a,t,n)),t++);r.children=i}return t},...e?{tokens(e){for(let t of e){let e=0;for(let n of t){let t=n;t.__lineChar??=e,e+=n.content.length}}},preprocess(e,t){t.mergeWhitespaces=`never`},span(e,t,n,r,i){if(i?.offset!=null&&i.content!=null){let t=i.__lineChar;return t!=null&&(e.properties[`data-char`]=t),e}return e}}:null}];return t&&r.push(UW,HW),e&&r.push({line:e=>(e.type===`element`&&e.children.length===0&&e.children.push({type:`element`,tagName:`br`,properties:{},children:[]}),e)}),{state:n,transformers:r,toClass:HW}}var HW=zW({classPrefix:`hl-`}),UW={name:`token-style-normalizer`,tokens(e){for(let t of e)for(let e of t){if(e.htmlStyle!=null)continue;let t={};e.color!=null&&(t.color=e.color),e.bgColor!=null&&(t[`background-color`]=e.bgColor),e.fontStyle!=null&&e.fontStyle!==0&&(e.fontStyle&1&&(t[`font-style`]=`italic`),e.fontStyle&2&&(t[`font-weight`]=`bold`),e.fontStyle&4&&(t[`text-decoration`]=`underline`)),Object.keys(t).length>0&&(e.htmlStyle=t)}}};function WW(e){return`--${e===`token`?`diffs-token`:`diffs`}-`}var GW=/^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i,KW=/^0(?:\.0+)?%?$/;function qW(e){let t=e.indexOf(`(`);if(t<=0||!e.endsWith(`)`))return;let n=e.slice(0,t).trim();if(!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(n))return;let r=e.slice(t+1,-1).trim();if(r.length===0)return;let i=r.lastIndexOf(`/`);if(i!==-1)return r.slice(i+1).trim();if(/^(?:rgba|hsla)$/i.test(n)){let e=r.split(`,`);if(e.length===4)return e[3]?.trim()}}function JW(e){let t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(e.trim());if(t==null)return null;let n=t[1],r,i=1;return n.length===3?r=n.split(``).map(e=>e+e).join(``):n.length===6?r=n:(r=n.slice(0,6),i=parseInt(n.slice(6,8),16)/255),[parseInt(r.slice(0,2),16),parseInt(r.slice(2,4),16),parseInt(r.slice(4,6),16),i]}function YW(e){if(e==null)return null;let t=JW(e);if(t==null)return null;let n=t[0]/255,r=t[1]/255,i=t[2]/255,a=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return .2126*a(n)+.7152*a(r)+.0722*a(i)}function XW(e){if(e==null)return!1;let t=e.trim().toLowerCase();if(t===`transparent`||GW.test(t))return!0;let n=qW(t);return n!=null&&KW.test(n)}function ZW(e,t,n){if(t==null||n==null)return!1;let r=YW(e),i=YW(t),a=YW(n);return r==null||i==null||a==null?!1:Math.abs(r-a)<Math.abs(r-i)}var QW=new WeakMap;function $W(e){let t=QW.get(e);if(t!=null)return t;let n=e.colors??{},r={...n},i=n[`editor.background`]??e.bg,a=n[`editor.foreground`]??e.fg,o=n[`sideBar.background`]??i,s=n[`sideBar.foreground`]??a;eG(r,`editor.background`,i),eG(r,`editor.foreground`,a),eG(r,`sideBar.background`,o),eG(r,`sideBar.foreground`,s),eG(r,`input.background`,n[`input.background`]??o),eG(r,`sideBarSectionHeader.foreground`,n[`sideBarSectionHeader.foreground`]??s),eG(r,`list.activeSelectionForeground`,n[`list.activeSelectionForeground`]??s),eG(r,`gitDecoration.addedResourceForeground`,tG(n[`gitDecoration.addedResourceForeground`],n[`terminal.ansiGreen`],n[`editorGutter.addedBackground`])),eG(r,`gitDecoration.modifiedResourceForeground`,tG(n[`gitDecoration.modifiedResourceForeground`],n[`terminal.ansiBlue`],n[`editorGutter.modifiedBackground`])),eG(r,`gitDecoration.deletedResourceForeground`,tG(n[`gitDecoration.deletedResourceForeground`],n[`terminal.ansiRed`],n[`editorGutter.deletedBackground`]));let c=(XW(n[`list.focusOutline`])?void 0:n[`list.focusOutline`])??(XW(n.focusBorder)?void 0:n.focusBorder);c==null?delete r[`list.focusOutline`]:r[`list.focusOutline`]=c;let l=n[`list.hoverBackground`];l!=null&&(nG(l,o)||ZW(l,o,s))&&delete r[`list.hoverBackground`];let u=Object.freeze({...e,colors:Object.freeze(r)});return QW.set(e,u),u}function eG(e,t,n){n!=null&&n!==``&&(e[t]=n)}function tG(...e){for(let t of e)if(t!=null&&t!==``)return t}function nG(e,t){return t!=null&&e.toLowerCase()===t.toLowerCase()}function rG({theme:e=$j,highlighter:t,prefix:n}){let r=``;if(typeof e==`string`){let i=t.getTheme(e),a=$W(i);r+=`color:${a.fg};`,r+=`background-color:${a.bg};`,r+=`${WW(`global`)}fg:${a.fg};`,r+=`${WW(`global`)}bg:${a.bg};`,r+=iG(i,n)}else{let n=t.getTheme(e.dark),i=$W(n);r+=`${WW(`global`)}dark:${i.fg};`,r+=`${WW(`global`)}dark-bg:${i.bg};`,r+=iG(n,`dark`),n=t.getTheme(e.light),i=$W(n),r+=`${WW(`global`)}light:${i.fg};`,r+=`${WW(`global`)}light-bg:${i.bg};`,r+=iG(n,`light`)}return r}function iG(e,t){t=t==null?``:`${t}-`;let n=``,r=e.colors?.[`gitDecoration.addedResourceForeground`]??e.colors?.[`terminal.ansiGreen`];r!=null&&(n+=`${WW(`global`)}${t}addition-color:${r};`);let i=e.colors?.[`gitDecoration.deletedResourceForeground`]??e.colors?.[`terminal.ansiRed`];i!=null&&(n+=`${WW(`global`)}${t}deletion-color:${i};`);let a=e.colors?.[`gitDecoration.modifiedResourceForeground`]??e.colors?.[`terminal.ansiBlue`];return a!=null&&(n+=`${WW(`global`)}${t}modified-color:${a};`),n}function aG(e){let t=e.children[0];for(;t!=null;){if(t.type===`element`&&t.tagName===`code`)return t.children;t=`children`in t?t.children[0]:null}throw console.error(e),Error(`getLineNodes: Unable to find children`)}var oG=10,sG=13,cG=4,lG=40;function uG(e){let t=[0],n=e.indexOf(`\r`),r=e.indexOf(`
|
|
186
186
|
`),i=0,a=0;for(;n!==-1||r!==-1;){let o;if(n!==-1&&(r===-1||n<r)?r===n+1?(o=r+1,n=e.indexOf(`\r`,o),r=e.indexOf(`
|
|
187
187
|
`,o)):(o=n+1,n=e.indexOf(`\r`,o)):(o=r+1,r=e.indexOf(`
|
|
188
|
-
`,o)),t.push(o),++a===
|
|
188
|
+
`,o)),t.push(o),++a===cG){if(o-i<=lG){for(let n=o;n<e.length;n++){let r=e.charCodeAt(n);(r===oG||r===sG)&&(r===sG&&n+1<e.length&&e.charCodeAt(n+1)===oG&&n++,t.push(n+1))}return t}i=o,a=0}}return t}function dG(e){let t=uG(e);return Array.from({length:t.length},(n,r)=>{let i=t[r],a=t[r+1]??e.length;return e.slice(i,a)})}var fG={forcePlainText:!1};function pG(e,t,{theme:n=$j,tokenizeMaxLineLength:r,useTokenTransformer:i},{forcePlainText:a,startingLine:o,totalLines:s,lines:c}=fG){a?(o??=0,s??=1/0):(o=0,s=1/0);let l=o>0||s<1/0,{state:u,transformers:d}=VW(i),f=a?`text`:e.lang??DW(e.name),p=typeof n==`string`?t.getTheme(n).type:void 0,m=rG({theme:n,highlighter:t});u.lineInfo=e=>({type:`context`,lineIndex:e-1+o,lineNumber:e+o});let h=typeof n==`string`?{lang:f,theme:n,transformers:d,defaultColor:!1,cssVariablePrefix:WW(`token`),tokenizeMaxLineLength:r,tokenizeTimeLimit:0}:{lang:f,themes:n,transformers:d,defaultColor:!1,cssVariablePrefix:WW(`token`),tokenizeMaxLineLength:r,tokenizeTimeLimit:0},g=aG(t.codeToHast(l?mG(c??dG(e.contents),o,s):e.contents,h)),_=l?Array(o):g;return l&&_.push(...g),{code:_,themeStyles:m,baseThemeType:p}}function mG(e,t,n){if(e.length===0)return``;let r=Math.min(t+n,e.length);return e.slice(t,r).join(``)}var hG=`-1,-1`;function gG(e){return e?.some(e=>e.lineNumber===0)??!1}function _G(e){let t=e[0];return t!=null&&t.length>0?t:void 0}function vG(e){return e.startingLine===0&&e.totalLines>0}function yG(e,t){return e.endsWith(`\r
|
|
189
189
|
`)?t+`\r
|
|
190
190
|
`:e.endsWith(`\r`)?t+`\r`:e.endsWith(`
|
|
191
191
|
`)?t+`
|
|
192
|
-
`:t}function
|
|
192
|
+
`:t}function bG(e,t){return B({tagName:`div`,children:e,properties:{"data-content":``,style:`grid-row: span ${t}`}})}function xG(e){return(e.lang??DW(e.name))===`text`}var SG=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
193
193
|
<symbol id="diffs-icon-arrow-right-short" viewBox="0 0 16 16">
|
|
194
194
|
<path d="M8.47 4.22a.75.75 0 0 0 0 1.06l1.97 1.97H3.75a.75.75 0 0 0 0 1.5h6.69l-1.97 1.97a.75.75 0 1 0 1.06 1.06l3.25-3.25a.75.75 0 0 0 0-1.06L9.53 4.22a.75.75 0 0 0-1.06 0"/>
|
|
195
195
|
</symbol>
|
|
@@ -241,7 +241,7 @@ XID_Start XIDS`.split(/\s/).map(e=>[EV(e),e])),vH=new Map([[`s`,Z(383)],[Z(383),
|
|
|
241
241
|
<symbol id="diffs-icon-symbol-ref" viewBox="0 0 16 16">
|
|
242
242
|
<path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706.286.286.71.54 1.41.73V1.86c-.7.19-1.124.444-1.41.73-.324.325-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8m4 6.397c.697.07 1.522.103 2.5.103 1.613 0 2.806-.088 3.704-.288.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5c-.978 0-1.803.033-2.5.103zM0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m7-2a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z"/>
|
|
243
243
|
</symbol>
|
|
244
|
-
</svg>`;function
|
|
244
|
+
</svg>`;function CG(e,t){return e==null||t==null?e===t:TG(e.customProperties,t.customProperties)&&e.type===t.type&&e.diffIndicators===t.diffIndicators&&e.disableBackground===t.disableBackground&&e.disableLineNumbers===t.disableLineNumbers&&e.overflow===t.overflow&&e.split===t.split&&e.totalLines===t.totalLines}var wG={};function TG(e=wG,t=wG){if(e===t)return!0;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}function EG(e){let t=document.createElement(`div`);return t.dataset.annotationSlot=``,t.slot=e,t.style.whiteSpace=`normal`,t}function DG(){let e=document.createElement(`div`);return e.slot=`gutter-utility-slot`,e.style.position=`absolute`,e.style.top=`0`,e.style.bottom=`0`,e.style.textAlign=`center`,e.style.whiteSpace=`normal`,e.style.touchAction=`none`,e}function OG(){let e=document.createElement(`style`);return e.setAttribute(tM,``),e}var kG=`@layer base {
|
|
245
245
|
:host {
|
|
246
246
|
--diffs-font-fallback: "SF Mono", Monaco, Consolas, "Ubuntu Mono", "Liberation Mono",
|
|
247
247
|
"Courier New", monospace;
|
|
@@ -1519,15 +1519,15 @@ XID_Start XIDS`.split(/\s/).map(e=>[EV(e),e])),vH=new Map([[`s`,Z(383)],[Z(383),
|
|
|
1519
1519
|
}
|
|
1520
1520
|
|
|
1521
1521
|
@layer theme, rendered, unsafe;
|
|
1522
|
-
`,
|
|
1522
|
+
`,AG;function jG(e){if(AG!=null)return AG;let t=e.host;if(typeof HTMLElement<`u`&&t instanceof HTMLElement&&!t.isConnected)return;let n=document.createElement(`div`);n.setAttribute(`data-code`,``),n.setAttribute(nM,`true`);let r=document.createElement(`div`);return r.style.position=`relative`,r.style.width=`200%`,r.style.height=`200%`,n.appendChild(r),e.appendChild(n),AG=Math.max(n.offsetHeight-n.clientHeight,0),n.remove(),AG}function MG(e){return`${aM}: ${e==null?`var(--diffs-scrollbar-gutter-fallback)`:`${e}px`};`}var NG=`@layer base, theme, rendered, unsafe;`,PG=RegExp(`${RG(aM)}\\s*:\\s*[^;]+;`);function FG(e){return`${NG}
|
|
1523
1523
|
@layer unsafe {
|
|
1524
1524
|
${e}
|
|
1525
|
-
}`}function
|
|
1525
|
+
}`}function IG(e,t=`system`,n){return`${NG}
|
|
1526
1526
|
@layer rendered {
|
|
1527
1527
|
:host {${t===`system`?``:`
|
|
1528
1528
|
color-scheme: ${t};`}
|
|
1529
|
-
${
|
|
1529
|
+
${MG(n)}
|
|
1530
1530
|
${e}
|
|
1531
1531
|
}
|
|
1532
|
-
}`}function PG(e,t){let n=kG(t);return e.replace(jG,n)}function FG(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function IG({code:e,pre:t,columnType:n,rowSpan:r,containerSize:i=!1}={}){return e??(e=document.createElement(`code`),e.setAttribute(`data-code`,``),n!=null&&e.setAttribute(`data-${n}`,``),t?.appendChild(e)),r==null?e.style.removeProperty(`grid-row`):e.style.setProperty(`grid-row`,`span ${r}`),i?e.setAttribute(`data-container-size`,``):e.removeAttribute(`data-container-size`),e}function LG(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function RG(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:a,split:o,totalLines:s,customProperties:c}){if(c!=null)for(let t in c){let n=c[t];n!=null&&e.setAttribute(t,`${n}`)}switch(t===`diff`?(e.setAttribute(`data-diff`,``),e.removeAttribute(`data-file`)):(e.setAttribute(`data-file`,``),e.removeAttribute(`data-diff`)),n){case`bars`:case`classic`:e.setAttribute(`data-indicators`,n);break;case`none`:e.removeAttribute(`data-indicators`)}return i?e.setAttribute(`data-disable-line-numbers`,``):e.removeAttribute(`data-disable-line-numbers`),r?e.removeAttribute(`data-background`):e.setAttribute(`data-background`,``),t===`diff`?e.setAttribute(`data-diff-type`,o?`split`:`single`):e.removeAttribute(`data-diff-type`),e.setAttribute(`data-overflow`,a),e.style.setProperty(`--diffs-min-number-column-width-default`,`${`${s}`.length}ch`),e}function zG(e){if(typeof HTMLStyleElement<`u`&&e instanceof HTMLStyleElement)return!0;let t=e.tagName??e.nodeName;return typeof t==`string`&&t.toLowerCase()===`style`}function BG(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function VG(e,t){let n=e?.offsetHeight??0;if(e==null||n===0){t();return}e.style.minHeight=`${n}px`;try{t(),e.offsetHeight}finally{e.style.minHeight=``}}function HG({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===``){t?.remove();return}return t??=UG(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function UG(){let e=document.createElement(`style`);return e.setAttribute(Zj,``),e}var WG=void 0;function GG(){return WG??=`safari`in window&&`pushNotification`in window.safari||/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}if(typeof HTMLElement<`u`&&customElements.get(`diffs-container`)==null){let e;class t extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;let t=this.attachShadow({mode:`open`});e??(e=new CSSStyleSheet,e.replaceSync(EG)),t.adoptedStyleSheets=[e]}connectedCallback(){OG(this.shadowRoot??this.attachShadow({mode:`open`}))}}customElements.define(Lj,t)}function KG(e){return{...iM,...e}}function qG(e,t){let n=JG(e,t);return t?n:e.diffHeaderHeight+n}function JG(e,t){return e.paddingTop??(t?e.spacing:0)}function YG(e){return e.paddingBottom??e.spacing}function XG(e){switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}function ZG(e,t){return e===t||e?.cacheKey!=null&&e.cacheKey===t?.cacheKey}function QG(e,t){return _M(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function $G({line:e,spanStart:t,spanLength:n}){return{start:{line:e,character:t},end:{line:e,character:t+n},properties:{"data-diff-span":``},alwaysWrap:!0}}function eK({item:e,arr:t,enableJoin:n,isNeutral:r=!1,isLastItem:i=!1}){let a=t[t.length-1];if(a==null||i||!n){t.push([+!r,e.value]);return}let o=a[0]===0;if(r===o||r&&e.value.length===1&&!o){a[1]+=e.value;return}t.push([+!r,e.value])}function tK(e){return[CM(e.additionStart,e.additionCount)+1,wM(e.additionStart,e.additionCount)+1]}function nK({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:r,collapsedContextThreshold:i}){let a=Math.max(t,0);if(a===0||e)return{fromStart:0,fromEnd:0,rangeSize:a,collapsedLines:a,renderAll:!1};if(n===!0||a<=i)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(r),s=Math.min(Math.max(o?.fromStart??0,0),a),c=Math.min(Math.max(o?.fromEnd??0,0),a),l=s+c,u=l>=a;return{fromStart:u?a:s,fromEnd:u?0:c,rangeSize:a,collapsedLines:Math.max(a-l,0),renderAll:u}}function rK(e){let t=e.hunks[e.hunks.length-1];if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return!1;let n=e.additionLines.length-wM(t.additionStart,t.additionCount),r=e.deletionLines.length-wM(t.deletionStart,t.deletionCount);return n<=0&&r<=0?!1:n!==r}function iK({fileDiff:e,errorPrefix:t}){let n=e.hunks[e.hunks.length-1];if(n==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;let r=e.additionLines.length-wM(n.additionStart,n.additionCount),i=e.deletionLines.length-wM(n.deletionStart,n.deletionCount);if(r<=0&&i<=0)return 0;if(r!==i)throw Error(`${t}: trailing context mismatch (additions=${r}, deletions=${i}) for ${e.name}`);return Math.min(r,i)}function aK({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let a=iK({fileDiff:e,errorPrefix:i});if(a<=0)return;if(n===!0||a<=r)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(e.hunks.length),s=Math.min(Math.max(o?.fromStart??0,0),a);return{fromStart:s,fromEnd:0,rangeSize:a,collapsedLines:a-s,renderAll:s>=a}}function oK({fileDiff:e,lineNumber:t,expandedHunks:n,collapsedContextThreshold:r}){if(n===!0||e.isPartial)return!0;for(let[i,a]of e.hunks.entries()){let[o,s]=tK(a);if(t<o){let s=nK({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:n,hunkIndex:i,collapsedContextThreshold:r}),c=o-s.rangeSize;return s.renderAll||t<c+s.fromStart||t>=o-s.fromEnd}if(t<s)return!0}let i=aK({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:`isAdditionLineRenderable`});if(i==null||i.renderAll)return!0;let a=e.hunks[e.hunks.length-1],[,o]=tK(a);return t<o+i.fromStart||t>=o+i.rangeSize}function sK({fileDiff:e,lineNumber:t,direction:n,expandedHunks:r,collapsedContextThreshold:i}){if(r===!0||e.isPartial)return t;let a=[],o=1;for(let[t,n]of e.hunks.entries()){let[s,c]=tK(n),l=nK({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:r,hunkIndex:t,collapsedContextThreshold:i}),u=s-l.rangeSize;l.renderAll?a.push([u,s]):(l.fromStart>0&&a.push([u,u+l.fromStart]),l.fromEnd>0&&a.push([s-l.fromEnd,s])),a.push([s,c]),o=c}let s=aK({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:i,errorPrefix:`getNearestRenderableAdditionLine`});if(s!=null){let e=o;o=e+s.rangeSize,s.renderAll?a.push([e,o]):s.fromStart>0&&a.push([e,e+s.fromStart])}if(t>=o)return t;if(n===`down`){for(let[e,n]of a)if(n>t)return Math.max(e,t);return}for(let e=a.length-1;e>=0;e--){let[n,r]=a[e];if(n<=t)return Math.min(r-1,t)}}function cK({type:e,metrics:t}){return t.hunkSeparatorHeight??XG(e)}function lK({type:e,metrics:t}){return e===`simple`||e===`metadata`||e===`line-info-basic`?0:t.spacing}function uK({type:e,hunkIndex:t,hunkSpecs:n}){switch(e){case`simple`:return t>0;case`metadata`:return n!=null;case`line-info`:case`line-info-basic`:case`custom`:return!0}}function dK(e){return e!==`simple`&&e!==`metadata`}function fK({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!uK({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=cK({type:e,metrics:t}),a=lK({type:e,metrics:t}),o=n>0?a:0,s=a;return{height:i,gapBefore:o,gapAfter:s,totalHeight:o+i+s}}function pK({type:e,metrics:t}){if(!dK(e))return;let n=cK({type:e,metrics:t}),r=lK({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function mK({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:a=1,callback:o}){let s=hK({diff:e,diffStyle:t,startingLine:n,expandedHunks:i,collapsedContextThreshold:a}),c={viewportStart:n,viewportEnd:n+r,isWindowedHighlight:n>0||r<1/0,splitCount:s.splitCount,unifiedCount:s.unifiedCount,finalHunkIndex:e.hunks.length-1,shouldBreak(){if(!c.isWindowedHighlight)return!1;let e=c.unifiedCount>=n+r,i=c.splitCount>=n+r;return t===`unified`?e:(t===`split`||e)&&i},shouldSkip(e,r){if(!c.isWindowedHighlight)return!1;let i=e>0&&c.unifiedCount+e<=n,a=r>0&&c.splitCount+r<=n;return t===`unified`?i:(t===`split`||i)&&a},incrementCounts(e,n){(t===`unified`||t===`both`)&&(c.unifiedCount+=e),(t===`split`||t===`both`)&&(c.splitCount+=n)},isInWindow(e,n){if(!c.isWindowedHighlight)return!0;let r=c.isInUnifiedWindow(e),i=c.isInSplitWindow(n);return t===`unified`?r:t===`split`?i:r||i},isInUnifiedWindow(e){return!c.isWindowedHighlight||c.unifiedCount>=n-e&&c.unifiedCount<n+r},isInSplitWindow(e){return!c.isWindowedHighlight||c.splitCount>=n-e&&c.splitCount<n+r},emit(e,n=!1){return n||(t===`unified`?c.incrementCounts(1,0):t===`split`?c.incrementCounts(0,1):c.incrementCounts(1,1)),o(e)??!1}};hunkIterator:for(let n=s.hunkIndex;n<e.hunks.length;n++){let r=e.hunks[n];if(r==null)throw Error(`iterateOverDiff: invalid hunk index`);if(c.shouldBreak())break;let o=CM(r.deletionStart,r.deletionCount),s=CM(r.additionStart,r.additionCount),l=!e.isPartial&&r.deletionCount===0?o:r.deletionLineIndex,u=!e.isPartial&&r.additionCount===0?s:r.additionLineIndex,d=nK({isPartial:e.isPartial,rangeSize:r.collapsedBefore,expandedHunks:i,hunkIndex:n,collapsedContextThreshold:a}),f=n===c.finalHunkIndex?aK({fileDiff:e,hunkIndex:n,expandedHunks:i,collapsedContextThreshold:a,errorPrefix:`iterateOverDiff`}):void 0,p=d.fromStart+d.fromEnd;function m(e,n){return f==null||f.collapsedLines<=0||f.fromStart+f.fromEnd>0?0:t===`unified`?e===r.unifiedLineStart+r.unifiedLineCount-1?f.collapsedLines:0:n===r.splitLineStart+r.splitLineCount-1?f.collapsedLines:0}let h=d.collapsedLines===0;function g(){return h?0:(h=!0,d.collapsedLines)}if(c.shouldSkip(p,p))c.incrementCounts(p,p),g();else{let e=r.unifiedLineStart-d.rangeSize,i=r.splitLineStart-d.rangeSize,a=l-d.rangeSize,f=u-d.rangeSize,p=o+1-d.rangeSize,m=s+1-d.rangeSize;if(vK(c,d.fromStart,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:0,collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}))||(e=r.unifiedLineStart-d.fromEnd,i=r.splitLineStart-d.fromEnd,a=l-d.fromEnd,f=u-d.fromEnd,p=o+1-d.fromEnd,m=s+1-d.fromEnd,vK(c,d.fromEnd,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}),()=>{g()})))break hunkIterator}let _=r.unifiedLineStart,v=r.splitLineStart,y=l,b=u,x=o+1,ee=s+1,te=r.hunkContent.at(-1);for(let e of r.hunkContent){if(c.shouldBreak())break hunkIterator;let i=e===te;if(e.type===`context`){if(c.shouldSkip(e.lines,e.lines))c.incrementCounts(e.lines,e.lines),g();else if(vK(c,e.lines,t,t=>{let a=i&&t===e.lines-1,o=_+t,s=v+t;return c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:m(o,s),type:`context`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:a&&r.noEOFCRDeletions,unifiedLineIndex:o,splitLineIndex:s},additionLine:{unifiedLineIndex:o,splitLineIndex:s,lineIndex:b+t,lineNumber:ee+t,noEOFCR:a&&r.noEOFCRAdditions}})},()=>{g()}))break hunkIterator;_+=e.lines,v+=e.lines,y+=e.lines,b+=e.lines,x+=e.lines,ee+=e.lines}else{let a=Math.max(e.deletions,e.additions),o=e.deletions+e.additions;if(!c.shouldSkip(o,a)){let s=yK(c,e,t);(s[0]?.[0]??0)>0&&g();for(let[l,u]of s)for(let s=l;s<u;s++){let l=m(_+s,t===`unified`?v+(s<e.deletions?s:s-e.deletions):v+s);if(c.emit(bK({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:l,diffStyle:t,index:s,unifiedLineIndex:_,splitLineIndex:v,additionLineIndex:b,deletionLineIndex:y,additionLineNumber:ee,deletionLineNumber:x,content:e,isLastContent:i,unifiedCount:o,splitCount:a}),!0))break hunkIterator}}g(),c.incrementCounts(o,a),_+=o,v+=a,y+=e.deletions,b+=e.additions,x+=e.deletions,ee+=e.additions}}if(f!=null){let{collapsedLines:n,fromStart:r,fromEnd:i}=f,a=r+i;if(vK(c,a,t,t=>{let r=t===a-1;return c.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:r?n:0,type:`context-expanded`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:!1,unifiedLineIndex:_+t,splitLineIndex:v+t},additionLine:{unifiedLineIndex:_+t,splitLineIndex:v+t,lineIndex:b+t,lineNumber:ee+t,noEOFCR:!1}})},void 0,()=>c.shouldBreak()))break hunkIterator}}}function hK({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t===`both`)return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=gK({diff:e,expandedHunks:r,collapsedContextThreshold:i}),o=0,s=e.hunks.length-1,c=e.hunks.length;for(;o<=s;){let e=o+s>>1,r=a[e+1];if(r==null)throw Error(`iterateOverDiff: invalid hunk prefix index`);(t===`unified`?r.unifiedCount:r.splitCount)>n?(c=e,s=e-1):o=e+1}if(c>=e.hunks.length){let t=a[e.hunks.length];if(t==null)throw Error(`iterateOverDiff: invalid terminal hunk prefix index`);return{hunkIndex:e.hunks.length,splitCount:t.splitCount,unifiedCount:t.unifiedCount}}let l=a[c];if(l==null)throw Error(`iterateOverDiff: invalid selected hunk prefix index`);return{hunkIndex:c,splitCount:l.splitCount,unifiedCount:l.unifiedCount}}function gK({diff:e,expandedHunks:t,collapsedContextThreshold:n}){let r=0,i=0,a=e.hunks.length-1,o=[{splitCount:0,unifiedCount:0}];for(let s=0;s<e.hunks.length;s++){let c=e.hunks[s];if(c==null)throw Error(`iterateOverDiff: invalid hunk summary index`);let l=nK({isPartial:e.isPartial,rangeSize:c.collapsedBefore,expandedHunks:t,hunkIndex:s,collapsedContextThreshold:n}),u=l.fromStart+l.fromEnd;r+=u+c.splitLineCount,i+=u+c.unifiedLineCount;let d=s===a?aK({fileDiff:e,hunkIndex:s,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`iterateOverDiff`}):void 0;if(d!=null){let e=d.fromStart+d.fromEnd;r+=e,i+=e}o.push({splitCount:r,unifiedCount:i})}return o}function _K(e,t,n){if(!e.isWindowedHighlight||t<=0)return[0,t];let r=[];function i(n){let i=Math.max(0,e.viewportStart-n),a=Math.min(t,e.viewportEnd-n);a>i&&r.push([i,a])}if(n!==`split`&&i(e.unifiedCount),n!==`unified`&&i(e.splitCount),r.length===0)return[0,0];let a=r[0][0],o=r[0][1];for(let e=1;e<r.length;e++){let t=r[e];a=Math.min(a,t[0]),o=Math.max(o,t[1])}return[a,o]}function vK(e,t,n,r,i,a){let[o,s]=_K(e,t,n);o>0&&(e.incrementCounts(o,o),i?.());let c=o;for(;c<t;){if(a?.()===!0)return!0;if(c>=s){e.incrementCounts(t-c,t-c);break}if(e.isInWindow(0,0)){if(r(c)===!0)return!0}else e.incrementCounts(1,1);c++}return!1}function yK(e,t,n){if(!e.isWindowedHighlight)return[[0,n===`unified`?t.deletions+t.additions:Math.max(t.deletions,t.additions)]];let r=n!==`split`,i=n!==`unified`,a=n===`unified`?`unified`:`split`,o=[];function s(t,n){if(t+n<=e.viewportStart||t>=e.viewportEnd)return;let r=Math.max(0,e.viewportStart-t),i=Math.min(n,e.viewportEnd-t);return i>r?[r,i]:void 0}function c(e,n){return a===`split`?e:n===`additions`?[e[0]+t.deletions,e[1]+t.deletions]:e}function l(e,t){if(e==null)return;let[n,r]=c(e,t);r>n&&o.push([n,r])}if(r&&(l(s(e.unifiedCount,t.deletions),`deletions`),l(s(e.unifiedCount+t.deletions,t.additions),`additions`)),i&&(l(s(e.splitCount,t.deletions),`deletions`),l(s(e.splitCount,t.additions),`additions`)),o.length===0)return o;o.sort((e,t)=>e[0]-t[0]);let u=[o[0]];for(let[e,t]of o.slice(1)){let n=u[u.length-1];e<=n[1]?n[1]=Math.max(n[1],t):u.push([e,t])}return u}function bK({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,diffStyle:i,index:a,unifiedLineIndex:o,splitLineIndex:s,additionLineIndex:c,deletionLineIndex:l,additionLineNumber:u,deletionLineNumber:d,content:f,isLastContent:p,unifiedCount:m,splitCount:h}){let g=a<f.deletions?o+a:void 0,_=i===`unified`?a>=f.deletions?o+a:void 0:a<f.additions?o+f.deletions+a:void 0,v=i===`unified`?s+(a<f.deletions?a:a-f.deletions):s+a,y=a<f.deletions?l+a:void 0,b=a<f.deletions?d+a:void 0,x=i===`unified`?a>=f.deletions?c+(a-f.deletions):void 0:a<f.additions?c+a:void 0,ee=i===`unified`?a>=f.deletions?u+(a-f.deletions):void 0:a<f.additions?u+a:void 0,te=i===`unified`?p&&a===f.deletions-1&&t.noEOFCRDeletions:p&&a===h-1&&t.noEOFCRDeletions,ne=i===`unified`?p&&a===m-1&&t.noEOFCRAdditions:p&&a===h-1&&t.noEOFCRAdditions,re=y!=null&&b!=null&&g!=null?{lineNumber:b,lineIndex:y,noEOFCR:te,unifiedLineIndex:g,splitLineIndex:v}:void 0,ie=x!=null&&ee!=null&&_!=null?{unifiedLineIndex:_,splitLineIndex:v,lineIndex:x,lineNumber:ee,noEOFCR:ne}:void 0;if(re==null&&ie!=null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:ie};if(re!=null&&ie==null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:re,additionLine:void 0};if(re==null||ie==null)throw Error(`iterateOverDiff: missing change line data`);return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:re,additionLine:ie}}var xK={forcePlainText:!1};function SK(e,t,n,{forcePlainText:r,startingLine:i,totalLines:a,expandedHunks:o,collapsedContextThreshold:s=1}=xK){r?(i??=0,a??=1/0):(i=0,a=1/0);let c=i>0||a<1/0,l=typeof n.theme==`string`?t.getTheme(n.theme).type:void 0,u=eG({theme:n.theme,highlighter:t}),d=r&&!c&&(e.unifiedLineCount>1e3||e.splitLineCount>1e3)?`none`:n.lineDiffType,f={deletionLines:[],additionLines:[]},{maxLineDiffLength:p}=n,m=!r&&!e.isPartial,h=r?o:void 0,g=new Map;function _(e){let t=m?0:e,n=g.get(t)??wK();return g.set(t,n),n}function v(e,t,n,r){if(c){let e=n.at(-1);(e==null||e.targetIndex+e.count!==t)&&(e={targetIndex:t,originalOffset:r.length,count:0},n.push(e)),e.count++}r.push(e)}mK({diff:e,diffStyle:`both`,startingLine:i,totalLines:a,expandedHunks:!c||h,collapsedContextThreshold:s,callback:({hunkIndex:t,additionLine:n,deletionLine:r,type:i})=>{let a=_(t),o=n==null?r.splitLineIndex:n.splitLineIndex;i===`change`&&n!=null&&r!=null&&CK({additionLine:e.additionLines[n.lineIndex],deletionLine:e.deletionLines[r.lineIndex],deletionLineIndex:a.deletionContent.length,additionLineIndex:a.additionContent.length,deletionDecorations:a.deletionDecorations,additionDecorations:a.additionDecorations,lineDiffType:d,maxLineDiffLength:p}),r!=null&&(v(e.deletionLines[r.lineIndex],r.lineIndex,a.deletionSegments,a.deletionContent),a.deletionInfo.push({type:i===`change`?`change-deletion`:i,lineNumber:r.lineNumber,altLineNumber:i===`change`?void 0:n.lineNumber??void 0,lineIndex:`${r.unifiedLineIndex},${o}`})),n!=null&&(v(e.additionLines[n.lineIndex],n.lineIndex,a.additionSegments,a.additionContent),a.additionInfo.push({type:i===`change`?`change-addition`:i,lineNumber:n.lineNumber,altLineNumber:i===`change`?void 0:r.lineNumber??void 0,lineIndex:`${n.unifiedLineIndex},${o}`}))}});for(let i of g.values()){if(i.deletionContent.length===0&&i.additionContent.length===0)continue;let a={name:e.prevName??e.name,contents:i.deletionContent.value},o={name:e.name,contents:i.additionContent.value},{deletionLines:s,additionLines:c}=TK({deletionFile:a,deletionInfo:i.deletionInfo,deletionDecorations:i.deletionDecorations,additionFile:o,additionInfo:i.additionInfo,additionDecorations:i.additionDecorations,highlighter:t,options:n,languageOverride:r?`text`:e.lang});if(m){f.deletionLines=s,f.additionLines=c;continue}if(i.deletionSegments.length>0)for(let e of i.deletionSegments)for(let t=0;t<e.count;t++)f.deletionLines[e.targetIndex+t]=s[e.originalOffset+t];else f.deletionLines.push(...s);if(i.additionSegments.length>0)for(let e of i.additionSegments)for(let t=0;t<e.count;t++)f.additionLines[e.targetIndex+t]=c[e.originalOffset+t];else f.additionLines.push(...c)}return{code:f,themeStyles:u,baseThemeType:l}}function CK({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a,lineDiffType:o,maxLineDiffLength:s}){if(e==null||t==null||o===`none`||(e=SM(e),t=SM(t),e.length>s||t.length>s))return;let c=o===`char`?DM(e,t):WM(e,t),l=[],u=[],d=o===`word-alt`,f=c.at(-1);for(let e of c){let t=e===f;!e.added&&!e.removed?(eK({item:e,arr:l,enableJoin:d,isNeutral:!0,isLastItem:t}),eK({item:e,arr:u,enableJoin:d,isNeutral:!0,isLastItem:t})):e.removed?eK({item:e,arr:l,enableJoin:d,isLastItem:t}):eK({item:e,arr:u,enableJoin:d,isLastItem:t})}let p=0;for(let e of l)e[0]===1&&i.push($G({line:n,spanStart:p,spanLength:e[1].length})),p+=e[1].length;p=0;for(let e of u)e[0]===1&&a.push($G({line:r,spanStart:p,spanLength:e[1].length})),p+=e[1].length}function wK(){return{deletionContent:{push(e){this.value+=e,this.length++},value:``,length:0},additionContent:{push(e){this.value+=e,this.length++},value:``,length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function TK({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:a,additionDecorations:o,languageOverride:s,options:{theme:c=Xj,...l}}){let u=s??wW(e.name),d=s??wW(t.name),{state:f,transformers:p}=RW(l.useTokenTransformer),m=typeof c==`string`?{...l,lang:`text`,theme:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:VW(`token`),tokenizeTimeLimit:0}:{...l,lang:`text`,themes:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:VW(`token`),tokenizeTimeLimit:0};return{deletionLines:e.contents===``?[]:(m.lang=u,f.lineInfo=n,m.decorations=a,nG(i.codeToHast(SM(e.contents),m))),additionLines:t.contents===``?[]:(m.lang=d,m.decorations=o,f.lineInfo=r,nG(i.codeToHast(SM(t.contents),m)))}}function EK(e){let t=e.lang??wW(e.name),n=e.lang??(e.prevName==null?`text`:wW(e.prevName));return t===`text`&&n===`text`}function DK(e){let t=[];for(let n of e){let e=GF.get(n);if(e==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(e)}return t}function OK(e){for(let t of Array.isArray(e)?e:[e])if(!GF.has(t))return!1;return!0}async function kK(e){let t=[],n=[];for(let r of e){if(r===`text`||r===`ansi`)continue;let e=xU(r)??bU(r);`then`in e?n.push(e):t.push(e)}return n.length>0&&await Promise.all(n).then(e=>{for(let n of e){if(n==null)throw Error(`resolvedLanguages: unable to resolve language`);t.push(n)}}),t}function AK(e){return NU.getResolvedThemes(e)}async function jK(e){for(let t of e)tW(t);let t=await NU.resolveThemes(e);for(let n=0;n<e.length;n++)nW(e[n],t[n]);return t}var MK={light:`pierre-light`,dark:`pierre-dark`};function NK(e){return e===`dark`?MK.dark:MK.light}var PK=2166136261,FK=16777619,IK=2654435769,LK=2246822507;function RK(e,t=PK,n=FK){let r=t>>>0;for(let t=0;t<e.length;t+=1)r^=e.charCodeAt(t),r=Math.imul(r,n)>>>0;return r>>>0}function zK(e,t=`diff-panel`){let n=e.trim(),r=RK(n,PK,FK).toString(36),i=RK(n,IK,LK).toString(36);return`${t}:${n.length}:${r}:${i}`}function BK(e){return wa(`flex items-center justify-between gap-2 px-4 wco:pr-[calc(100vw-env(titlebar-area-width)-env(titlebar-area-x)+1em)]`,xn&&e!==`sheet`?`h-[52px] border-b border-border wco:h-[env(titlebar-area-height)]`:`h-12 wco:max-h-[env(titlebar-area-height)]`)}function VK(e){let t=(0,A.c)(10),n=xn&&e.mode!==`sheet`,r=e.mode===`inline`?`w-[42vw] min-w-[360px] max-w-[560px] shrink-0 border-l border-border`:`w-full`,i;t[0]===r?i=t[1]:(i=wa(`flex h-full min-w-0 flex-col bg-background`,r),t[0]=r,t[1]=i);let a;t[2]!==e.header||t[3]!==e.mode||t[4]!==n?(a=n?(0,k.jsx)(`div`,{className:BK(e.mode),children:e.header}):(0,k.jsx)(`div`,{className:`border-b border-border`,children:(0,k.jsx)(`div`,{className:BK(e.mode),children:e.header})}),t[2]=e.header,t[3]=e.mode,t[4]=n,t[5]=a):a=t[5];let o;return t[6]!==e.children||t[7]!==i||t[8]!==a?(o=(0,k.jsxs)(`div`,{className:i,children:[a,e.children]}),t[6]=e.children,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function HK(){let e=(0,A.c)(4),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,k.jsx)(I,{className:`absolute left-0 top-1/2 size-6 -translate-y-1/2 rounded-md border border-border/50`}),n=(0,k.jsx)(I,{className:`absolute right-0 top-1/2 size-6 -translate-y-1/2 rounded-md border border-border/50`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,k.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[t,n,(0,k.jsxs)(`div`,{className:`flex gap-1 overflow-hidden px-8 py-0.5`,children:[(0,k.jsx)(I,{className:`h-6 w-16 shrink-0 rounded-md`}),(0,k.jsx)(I,{className:`h-6 w-24 shrink-0 rounded-md`}),(0,k.jsx)(I,{className:`h-6 w-24 shrink-0 rounded-md max-sm:hidden`})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,k.jsxs)(k.Fragment,{children:[r,(0,k.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,k.jsx)(I,{className:`size-7 rounded-md`}),(0,k.jsx)(I,{className:`size-7 rounded-md`})]})]}),e[3]=i):i=e[3],i}function UK(e){let t=(0,A.c)(7),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,k.jsx)(I,{className:`h-4 w-32 rounded-full`}),(0,k.jsx)(I,{className:`ml-auto h-4 w-20 rounded-full`})]}),t[0]=n):n=t[0];let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(I,{className:`h-3 w-full rounded-full`}),(0,k.jsx)(I,{className:`h-3 w-full rounded-full`}),(0,k.jsx)(I,{className:`h-3 w-10/12 rounded-full`}),(0,k.jsx)(I,{className:`h-3 w-11/12 rounded-full`}),(0,k.jsx)(I,{className:`h-3 w-9/12 rounded-full`})]}),t[1]=r):r=t[1];let i;t[2]===e.label?i=t[3]:(i=(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 px-3 py-4`,children:[r,(0,k.jsx)(`span`,{className:`sr-only`,children:e.label})]}),t[2]=e.label,t[3]=i);let a;return t[4]!==e.label||t[5]!==i?(a=(0,k.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col p-2`,children:(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border border-border/60 bg-card/25`,role:`status`,"aria-live":`polite`,"aria-label":e.label,children:[n,i]})}),t[4]=e.label,t[5]=i,t[6]=a):a=t[6],a}function WK(e){let t=(0,O.useRef)(e);return(0,O.useInsertionEffect)(()=>void(t.current=e)),(0,O.useCallback)((...e)=>t.current(...e),[])}var GK=(0,O.createContext)(void 0);function KK(){return(0,O.useContext)(GK)}var qK={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},JK={display:`contents`};function YK(){return null}var XK=t(n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):r((n||=self).lru_map=n.lru_map||{})})(e,function(e){let t=Symbol(`newer`),n=Symbol(`older`);class r{constructor(e,t){typeof e!=`number`&&(t=e,e=0),this.size=0,this.limit=e,this.oldest=this.newest=void 0,this._keymap=new Map,t&&(this.assign(t),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[t]&&(e===this.oldest&&(this.oldest=e[t]),e[t][n]=e[n]),e[n]&&(e[n][t]=e[t]),e[t]=void 0,e[n]=this.newest,this.newest&&(this.newest[t]=e),this.newest=e)}assign(e){let r,a=this.limit||Number.MAX_VALUE;this._keymap.clear();let o=e[Symbol.iterator]();for(let e=o.next();!e.done;e=o.next()){let o=new i(e.value[0],e.value[1]);if(this._keymap.set(o.key,o),r?(r[t]=o,o[n]=r):this.oldest=o,r=o,a--==0)throw Error(`overflow`)}this.newest=r,this.size=this._keymap.size}get(e){var t=this._keymap.get(e);return t?(this._markEntryAsUsed(t),t.value):void 0}set(e,r){var a=this._keymap.get(e);return a?(a.value=r,this._markEntryAsUsed(a),this):(this._keymap.set(e,a=new i(e,r)),this.newest?(this.newest[t]=a,a[n]=this.newest):this.oldest=a,this.newest=a,++this.size,this.size>this.limit&&this.shift(),this)}shift(){var e=this.oldest;if(e)return this.oldest[t]?(this.oldest=this.oldest[t],this.oldest[n]=void 0):(this.oldest=void 0,this.newest=void 0),e[t]=e[n]=void 0,this._keymap.delete(e.key),--this.size,[e.key,e.value]}find(e){let t=this._keymap.get(e);return t?t.value:void 0}has(e){return this._keymap.has(e)}delete(e){var r=this._keymap.get(e);return r?(this._keymap.delete(r.key),r[t]&&r[n]?(r[n][t]=r[t],r[t][n]=r[n]):r[t]?(r[t][n]=void 0,this.oldest=r[t]):r[n]?(r[n][t]=void 0,this.newest=r[n]):this.oldest=this.newest=void 0,this.size--,r.value):void 0}clear(){this.oldest=this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new o(this.oldest)}values(){return new s(this.oldest)}entries(){return this}[Symbol.iterator](){return new a(this.oldest)}forEach(e,n){typeof n!=`object`&&(n=this);let r=this.oldest;for(;r;)e.call(n,r.value,r.key,this),r=r[t]}toJSON(){for(var e=Array(this.size),n=0,r=this.oldest;r;)e[n++]={key:r.key,value:r.value},r=r[t];return e}toString(){for(var e=``,n=this.oldest;n;)e+=String(n.key)+`:`+n.value,n=n[t],n&&(e+=` < `);return e}}e.LRUMap=r;function i(e,r){this.key=e,this.value=r,this[t]=void 0,this[n]=void 0}function a(e){this.entry=e}a.prototype[Symbol.iterator]=function(){return this},a.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}};function o(e){this.entry=e}o.prototype[Symbol.iterator]=function(){return this},o.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:e.key}):{done:!0,value:void 0}};function s(e){this.entry=e}s.prototype[Symbol.iterator]=function(){return this},s.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:e.value}):{done:!0,value:void 0}}})}))(),1),ZK=Symbol(`IGNORE_RESPONSE`),QK=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled because the pool terminated`)}},$K=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled before the task completed`)}},eq=class{options;highlighter;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialized=!1;workers=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;workersFailed=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:n=Xj,useTokenTransformer:r=!1,lineDiffType:i=`word-alt`,maxLineDiffLength:a=1e3,tokenizeMaxLineLength:o=1e3,preferredHighlighter:s=`shiki-js`}){this.options=e,this.preferredHighlighter=s,this.renderOptions={theme:n,useTokenTransformer:r,lineDiffType:i,maxLineDiffLength:a,tokenizeMaxLineLength:o},this.fileCache=new XK.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new XK.default.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed}getFileResultCache(e){return e.cacheKey==null?void 0:this.fileCache.get(e.cacheKey)}getDiffResultCache(e){return e.cacheKey==null?void 0:this.diffCache.get(e.cacheKey)}inspectCaches(){let{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??Xj,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:n=this.renderOptions.lineDiffType??`word-alt`,maxLineDiffLength:r=this.renderOptions.maxLineDiffLength??1e3,tokenizeMaxLineLength:i=this.renderOptions.tokenizeMaxLineLength??1e3}){let{lifecycleGeneration:a}=this,o=++this.renderOptionsRequestVersion,s=()=>this.isCurrentLifecycle(a)&&this.renderOptionsRequestVersion===o;try{let a={theme:e,useTokenTransformer:t,lineDiffType:n,maxLineDiffLength:r,tokenizeMaxLineLength:i};if(this.isInitialized()||await this.initialize(),!s()||QG(a,this.renderOptions))return;let o=lW(e),c=[];if(_M(a.theme,this.renderOptions.theme)||(c=dW(o)?AK(o):await jK(o)),!s())return;if(this.highlighter!=null)PU(c,this.highlighter);else{let e=await oW({themes:o,langs:[`text`],preferredHighlighter:this.preferredHighlighter});if(!s())return;this.highlighter=e}let l=this.setRenderOptionsOnWorkers(a,c);this.renderOptions=a,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(let e of this.themeSubscribers)e.onThemeChange();await l}catch(e){if(e instanceof QK||!s())return;throw e}}getPreferredHighlighter(){return this.preferredHighlighter}getFileRenderOptions(){let{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:n}=this.renderOptions;return{theme:t,useTokenTransformer:n,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e,t){if(this.workersFailed)return;this.isInitialized()||await this.initialize();let n=[];for(let r of this.workers){if(!r.initialized)throw console.log({managedWorker:r}),Error(`setRenderOptionsOnWorkers: Somehow we have an uninitialized worker`);n.push(new Promise((n,i)=>{let a=this.generateRequestId(),o={type:`set-render-options`,id:a,request:{type:`set-render-options`,id:a,renderOptions:e,resolvedThemes:t},resolve:n,reject:i,requestStart:Date.now()};this.activeTaskById.set(a,o),r.pendingSetupRequestId=a,r.worker.postMessage(o.request)}))}await Promise.all(n)}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){this._queuedBroadcast??=requestAnimationFrame(this._broadcastStateChanges)}_broadcastStateChanges=()=>{this._queuedBroadcast!=null&&(cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0);let e=this.getStats();for(let t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);let t=this.activeRequestByInstance.get(e);if(t!=null){let n=this.activeTaskById.get(t);rq(n)?(this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0&&this.removeActiveTask(n)):this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialized===!0}async initialize(e=[]){if(this.initialized!==!0)if(this.initialized===!1){let{lifecycleGeneration:t}=this;this.initialized=new Promise((n,r)=>{(async()=>{try{let r=lW(this.renderOptions.theme),i=[];if(i=dW(r)?AK(r):await jK(r),!this.isCurrentLifecycle(t)){n();return}let a=[];if(a=OK(e)?DK(e):await kK(e),!this.isCurrentLifecycle(t)){n();return}let[o]=await Promise.all([oW({themes:r,langs:[`text`,...e],preferredHighlighter:this.preferredHighlighter}),this.initializeWorkers(i,a)]);if(!this.isCurrentLifecycle(t)){this.terminateWorkers(),n();return}this.highlighter=o,this.initialized=!0,this.diffCache.clear(),this.fileCache.clear(),this.drainQueue(),this.queueBroadcastStateChanges(),n()}catch(e){if(e instanceof QK||!this.isCurrentLifecycle(t)){n();return}this.initialized=!1,this.workersFailed=!0;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,aq(e));this.queueBroadcastStateChanges(),r(e)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=TW(),i=r>0?EW():void 0;this.workers.length>0&&this.terminateWorkers();for(let a=0;a<(this.options.poolSize??8);a++){let a=this.options.workerFactory(),o={worker:a,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set([`text`,...t.map(({name:e})=>e)]),customExtensionsVersion:0};a.addEventListener(`message`,e=>{this.handleWorkerMessage(o,e.data)}),a.addEventListener(`error`,e=>console.error(`Worker error:`,e,o)),this.workers.push(o),n.push(new Promise((n,a)=>{let s=this.generateRequestId(),c={type:`initialize`,id:s,request:{type:`initialize`,id:s,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:i==null?void 0:r,customExtensionMap:i},resolve(){o.initialized=!0,n()},reject:a,requestStart:Date.now()};this.activeTaskById.set(s,c),this.executeTask(o,c)}))}await Promise.all(n)}drainQueue=()=>{if(this._queuedDrain=void 0,this.initialized===!0&&this.queuedTasks.length!==0){for(let e=0;e<this.queuedTasks.length;){let t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}let n=nq(t),r=this.getAvailableWorker(n);if(r==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,r),this.resolveLanguagesAndExecuteTask(r,t,n)}this.queueBroadcastStateChanges()}};highlightFileAST(e,t){let n=this.getFileResultCache(t);vG(t)||n!=null&&fW(n.options,this.getFileRenderOptions())||this.hasMatchingFileInstanceTask(e,t)||this.submitTask(e,{type:`file`,file:t})}primeFileHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error(`WorkerPoolManager.primeFileHighlightCache: worker pool is not working`));let t=this.getOrCreateFileHighlightCacheTask(e);return t==null?Promise.resolve():this.createRenderTaskCallbacks(t)}getOrCreateFileHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`);return}let t=this.getFileResultCache(e),n=this.getFileHighlightKey(e);if(n==null||vG(e)||t!=null&&fW(t.options,this.getFileRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type===`file`?r:void 0;{let t=this.submitCacheTask({type:`file`,file:e},n);return t.type===`file`?t:void 0}}getPlainFileAST(e,t,n,r){if(this.highlighter==null){this.queueInitialization();return}return uG(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);EK(t)||n!=null&&QG(n.options,this.getDiffRenderOptions())||this.hasMatchingDiffInstanceTask(e,t)||this.submitTask(e,{type:`diff`,diff:t})}primeDiffHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error(`WorkerPoolManager.primeDiffHighlightCache: worker pool is not working`));let t=this.getOrCreateDiffHighlightCacheTask(e);return t==null?Promise.resolve():this.createRenderTaskCallbacks(t)}getOrCreateDiffHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`);return}let t=this.getDiffResultCache(e),n=this.getDiffHighlightKey(e);if(n==null||EK(e)||t!=null&&QG(t.options,this.getDiffRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type===`diff`?r:void 0;{let t=this.submitCacheTask({type:`diff`,diff:e},n);return t.type===`diff`?t:void 0}}getPlainDiffAST(e,t,n,r,i){return this.highlighter==null?void 0:SK(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,expandedHunks:r,collapsedContextThreshold:i})}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers();let e=new QK;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,e);this.fileCache.clear(),this.diffCache.clear(),this.activeRequestByInstance.clear(),this.queuedTasks.length=0,this.queuedTaskByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.highlighter=void 0,this.initialized=!1,this.workersFailed=!1,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch(e=>{console.error(e)})}cancelActiveWorkerTasks(){let e=new QK;for(let t of this.activeTaskById.values())`reject`in t?t.reject(e):rq(t)&&this.rejectRenderTaskCallbacks(t,e)}terminateWorkers(){for(let e of this.workers)e.worker.terminate();this.workers.length=0}getStats(){return{managerState:this.initialized===!1?`waiting`:this.initialized===!0?`initialized`:`initializing`,totalWorkers:this.workers.length,workersFailed:this.workersFailed,busyWorkers:this.workers.filter(e=>e.requestId!=null||e.pendingSetupRequestId!=null).length,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){this.initialized===!1&&this.queueInitialization();let n=this.getHighlightKeyForRequest(t),r=n==null?void 0:this.getTaskByHighlightKey(n);if(r!=null){this.detachInstanceFromQueuedTasks(e,r),this.addInstanceToTask(r,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);let i=this.generateRequestId(),a=Date.now(),{renderOptionsVersion:o}=this,s=(()=>{switch(t.type){case`file`:return{type:`file`,id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:o,requestStart:a};case`diff`:return{type:`diff`,id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:o,requestStart:a}}})();this.enqueueRenderTask(s,e)}submitCacheTask(e,t){this.initialized===!1&&this.queueInitialization();let n=this.generateRequestId(),r=Date.now(),{renderOptionsVersion:i}=this,a=(()=>{switch(e.type){case`file`:return{type:`file`,id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r};case`diff`:return{type:`diff`,id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r}}})();return this.enqueueRenderTask(a),a}enqueueRenderTask(e,t){this.queuedTasks.push(e),t!=null&&this.queuedTaskByInstance.set(t,e),e.highlightKey!=null&&this.taskByHighlightKey.set(e.highlightKey,e),this.queueDrain()}async resolveLanguagesAndExecuteTask(e,t,n){try{let r=n.filter(t=>!e.langs.has(t));if(r.length>0&&(OK(r)?t.request.resolvedLanguages=DK(r):t.request.resolvedLanguages=await kK(r)),!this.activeTaskById.has(t.id)){e.requestId===t.id&&(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain());return}this.executeTask(e,t)}catch(n){this.rejectRenderTaskCallbacks(t,aq(n)),this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}}handleWorkerMessage(e,t){let n=this.activeTaskById.get(t.id);try{if(n==null)throw ZK;if(t.type===`error`){let e=Error(t.error);if(t.stack&&(e.stack=t.stack),`reject`in n)n.reject(e);else if(rq(n))this.notifyHighlightError(n,e),this.rejectRenderTaskCallbacks(n,e);else throw Error(`handleWorkerMessage: unknown task type`);throw e}switch(t.requestType){case`initialize`:if(n.type!==`initialize`)throw Error(`handleWorkerMessage: task/response dont match`);this.syncCustomExtensionVersion(e,n.request),n.resolve();break;case`set-render-options`:if(n.type!==`set-render-options`)throw Error(`handleWorkerMessage: task/response dont match`);n.resolve();break;case`file`:{if(n.type!==`file`)throw Error(`handleWorkerMessage: task/response dont match`);let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!fW(i,this.getFileRenderOptions()))throw ZK;let{request:a}=n;this.syncCustomExtensionVersion(e,a),n.cacheKeyAtDispatch!=null&&this.fileCache.set(n.cacheKeyAtDispatch,{result:r,options:i}),this.resolveRenderTaskCallbacks(n),this.notifyFileInstances(n,r,i);break}case`diff`:{if(n.type!==`diff`)throw Error(`handleWorkerMessage: task/response dont match`);let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!QG(i,this.getDiffRenderOptions()))throw ZK;let{request:a}=n;this.syncCustomExtensionVersion(e,a),n.cacheKeyAtDispatch!=null&&this.diffCache.set(n.cacheKeyAtDispatch,{result:r,options:i}),this.resolveRenderTaskCallbacks(n),this.notifyDiffInstances(n,r,i);break}}}catch(e){e!==ZK&&console.error(e,n,t)}this.cleanWorkerAndTask(e,n,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}_queuedDrain;queueDrain(){this._queuedDrain??(this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges())}assignWorkerToTask(e,t){t.requestId=e.id,rq(e)&&(this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e)),this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,n=t?.id){e.requestId===n&&(e.requestId=void 0),e.pendingSetupRequestId===n&&(e.pendingSetupRequestId=void 0),t!=null&&(rq(t)&&(this.rejectRenderTaskCallbacks(t,new $K),this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){tq(t.request)&&this.maybeAttachCustomExtensions(e,t.request),this.activeTaskById.has(t.id)||this.assignWorkerToTask(t,e);for(let n of nq(t))e.langs.add(n);try{t.type===`file`?t.cacheKeyAtDispatch=t.request.file.cacheKey:t.type===`diff`&&(t.cacheKeyAtDispatch=t.request.diff.cacheKey),e.worker.postMessage(t.request)}catch(n){console.error(`Failed to post message to worker:`,n),rq(t)?(this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,aq(n))):`reject`in t&&t.reject(n),this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0&&this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;let n=TW();e.customExtensionsVersion>=n||(t.customExtensionsVersion=n,t.customExtensionMap=EW())}syncCustomExtensionVersion(e,t){t.customExtensionsVersion!=null&&(e.customExtensionsVersion=t.customExtensionsVersion)}getAvailableWorker(e){let t;for(let n of this.workers){if(n.requestId!=null||n.pendingSetupRequestId!=null||!n.initialized)continue;if(t=n,e.length===0)break;let r=!0;for(let t of e)if(!n.langs.has(t)){r=!1;break}if(r)break}return t}getFileHighlightKey(e){if(e.cacheKey!=null)return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey!=null)return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case`file`:return this.getFileHighlightKey(e.file);case`diff`:return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(let t of iq(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){e.type,e.instances.add(t),this.activeTaskById.has(e.id)?this.activeRequestByInstance.set(t,e.id):this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){let n=this.queuedTaskByInstance.get(e);n!=null&&n!==t&&(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0&&this.removeQueuedTask(n))}detachInstanceFromRenderTask(e,t){e.type,e.instances.delete(t)}removeQueuedTask(e){let t=this.queuedTasks.indexOf(e);t!==-1&&this.queuedTasks.splice(t,1),this.rejectRenderTaskCallbacks(e,new $K),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new $K),this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}createRenderTaskCallbacks(e){return new Promise((t,n)=>{e.callbacks.add({resolve:t,reject:n})})}resolveRenderTaskCallbacks(e){for(let t of e.callbacks)t.resolve();e.callbacks.clear()}rejectRenderTaskCallbacks(e,t){for(let n of e.callbacks)n.reject(t);e.callbacks.clear()}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){let t=this.queuedTasks[e];t.renderOptionsVersion!==this.renderOptionsVersion&&this.removeQueuedTask(t)}for(let e of Array.from(this.activeTaskById.values()))rq(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of iq(e))this.queuedTaskByInstance.get(t)===e&&this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e&&this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(let t of iq(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of iq(e))this.activeRequestByInstance.get(t)===e.id&&this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,n){for(let r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.file,t,n)}notifyDiffInstances(e,t,n){for(let r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.diff,t,n)}notifyHighlightError(e,t){for(let n of iq(e))this.activeRequestByInstance.get(n)===e.id&&n.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type===`file`&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&rN(t,n.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type===`diff`&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&ZG(n.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){let t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(let e of this.queuedTasks)yield e;for(let e of this.activeTaskById.values())rq(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function tq(e){return e.type===`initialize`||e.type===`file`||e.type===`diff`}function nq(e){let t=new Set;if(e.type===`initialize`||e.type===`set-render-options`)return[];switch(e.type){case`file`:t.add(e.request.file.lang??wW(e.request.file.name));break;case`diff`:t.add(e.request.diff.lang??wW(e.request.diff.name)),t.add(e.request.diff.lang??wW(e.request.diff.prevName??`-`))}return t.delete(`text`),Array.from(t)}function rq(e){return e?.type===`file`||e?.type===`diff`}function iq(e){return e.instances}function aq(e){return e instanceof Error?e:Error(String(e))}var oq;function sq({poolOptions:e,highlighterOptions:t}){return oq??=new eq(e,t),oq}function cq(){oq!=null&&(oq.terminate(),oq=void 0)}var lq=(0,O.createContext)(void 0),uq=0;function dq({children:e,poolOptions:t,highlighterOptions:n}){let[r]=(0,O.useState)(()=>{if(!(typeof window>`u`))return sq({poolOptions:t,highlighterOptions:n})});return(0,O.useInsertionEffect)(()=>{if(r!=null)return uq++,()=>{uq--}},[r]),(0,O.useEffect)(()=>()=>{uq===0&&cq()},[]),(0,k.jsx)(lq.Provider,{value:r,children:e})}function fq(){return(0,O.useContext)(lq)}export{mG as $,Sh as $a,Cb as $i,gk as $n,sl as $o,UT as $r,Ba as $s,tM as $t,qG as A,c_ as Aa,sC as Ai,gj as An,Bf as Ao,uD as Ar,Ao as As,UN as At,PG as B,Cg as Ba,$S as Bi,$k as Bn,Cd as Bo,OD as Br,uo as Bs,rN as Bt,aK as C,__ as Ca,dw as Ci,Aj as Cn,Xf as Co,PD as Cr,Po as Cs,SP as Ct,QG as D,i_ as Da,SC as Di,kj as Dn,Yf as Do,AD as Dr,Eo as Ds,yP as Dt,oK as E,u_ as Ea,tw as Ei,Nj as En,$f as Eo,pD as Er,Mo as Es,xP as Et,BG as F,Wg as Fa,nC as Fi,gA as Fn,pf as Fo,gD as Fr,bo as Fs,cN as Ft,wG as G,hg as Ga,wS as Gi,Pk as Gn,Wu as Go,jE as Gr,oo as Gs,xM as Gt,MG as H,Tg as Ha,US as Hi,Ik as Hn,nd as Ho,tD as Hr,co as Hs,wM as Ht,zG as I,Zg as Ia,aC as Ii,dA as In,ff as Io,aD as Ir,yo as Is,sN as It,yG as J,_h as Ja,uS as Ji,Ek as Jn,Al as Jo,oE as Jr,ao as Js,_M as Jt,CG as K,ng as Ka,CS as Ki,wk as Kn,Tu as Ko,aE as Kr,io as Ks,bM as Kt,RG as L,Rg as La,tC as Li,hA as Ln,af as Lo,oD as Lr,vo as Ls,B as Lt,GG as M,o_ as Ma,cC as Mi,ij as Mn,Rf as Mo,kD as Mr,Xo as Ms,gN as Mt,HG as N,Yg as Na,ZS as Ni,$A as Nn,Ff as No,xD as Nr,Jo as Ns,pN as Nt,ZG as O,r_ as Oa,mC as Oi,Pj as On,Hf as Oo,mD as Or,Io as Os,GN as Ot,VG as P,Jg as Pa,eC as Pi,BA as Pn,Pf as Po,hD as Pr,xo as Ps,lN as Pt,fG as Q,Ch as Qa,dx as Qi,vk as Qn,j as Qo,HT as Qr,ro as Qs,Wj as Qt,LG as R,Hg as Ra,QS as Ri,uA as Rn,Sd as Ro,_D as Rr,_o as Rs,aN as Rt,iK as S,m_ as Sa,lw as Si,jj as Sn,rp as So,MD as Sr,Fo as Ss,TP as St,rK as T,d_ as Ta,gw as Ti,Ij as Tn,ip as To,iD as Tr,No as Ts,bP as Tt,OG as U,xg as Ua,HS as Ui,Lk as Un,ud as Uo,UE as Ur,so as Us,CM as Ut,NG as V,Lg as Va,qS as Vi,eA as Vn,Td as Vo,sD as Vr,lo as Vs,tN as Vt,TG as W,kg as Wa,VS as Wi,Fk as Wn,zu as Wo,PE as Wr,no as Ws,SM as Wt,_G as X,Eh as Xa,Xx as Xi,Ok as Xn,Tl as Xo,mE as Xr,Wa as Xs,mM as Xt,vG as Y,xh as Ya,Kx as Yi,Dk as Yn,kl as Yo,pE as Yr,Va as Ys,gM as Yt,gG as Z,Dh as Za,Yx as Zi,pk as Zn,fl as Zo,lE as Zr,Ha as Zs,pM as Zt,mK as _,C_ as _a,mw as _i,qj as _n,rm as _o,ZO as _r,cs as _s,YF as _t,JK as a,Ay as aa,Ew as ai,cM as an,Vm as ao,DO as ar,Rs as as,DW as at,fK as b,x_ as ba,aw as bi,Gj as bn,op as bo,uO as br,ns as bs,vF as bt,WK as c,Ov as ca,I as ci,Xj as cn,Nm as co,IO as cr,Ps as cs,gW as ct,VK as d,gy as da,bw as di,Rj as dn,Jm as do,QO as dr,Ds as ds,fW as dt,wb as ea,Ka as ec,kT as ei,eM as en,hh as eo,_k as er,Hs as es,pG as et,zK as f,_y as fa,xw as fi,Lj as fn,qm as fo,KO as fr,Es as fs,dW as ft,SK as g,q_ as ga,ow as gi,Bj as gn,sm as go,WO as gr,ps as gs,oW as gt,EK as h,ev as ha,fw as hi,Uj as hn,cm as ho,GO as hr,fs as hs,sW as ht,qK as i,Oy as ia,OT as ii,oM as in,Rm as io,MO as ir,zs as is,OW as it,YG as j,s_ as ja,oC as ji,hj as jn,Vf as jo,fD as jr,zo as js,zN as jt,KG as k,l_ as ka,fC as ki,_j as kn,Wf as ko,cD as kr,Ro as ks,HN as kt,HK as l,Dv as la,yw as li,rM as ln,Km as lo,qO as lr,Ms as ls,mW as lt,NK as m,J_ as ma,uw as mi,Hj as mn,om as mo,YO as mr,ms,lW as mt,dq as n,_b as na,TT as ni,Yj as nn,eh as no,bk as nr,Bs as ns,uG as nt,YK as o,mv as oa,Cw as oi,lM as on,Am as oo,OO as or,Ns as os,wW as ot,RK as p,tv as pa,_w as pi,uM as pn,am as po,JO as pr,vs as ps,uW as pt,bG as q,ig as qa,pS as qi,Ak as qn,zl as qo,tE as qr,Qa as qs,vM as qt,fq as r,gb as ra,DT as ri,aM as rn,$m as ro,jO as rr,Is as rs,cG as rt,KK as s,xy as sa,ww as si,sM as sn,Pm as so,FO as sr,Fs as ss,yW as st,lq as t,Tb as ta,qa as tc,AT as ti,zj as tn,ph as to,yk as tr,Vs as ts,hG as tt,UK as u,vy as ua,vw as ui,iM as un,km as uo,UO as ur,ks as us,pW as ut,nK as v,S_ as va,hw as vi,Jj as vn,lm as vo,XO as vr,ss as vs,LF as vt,pK as w,f_ as wa,iw as wi,Fj as wn,Zf as wo,LD as wr,Go as ws,CP as wt,sK as x,g_ as xa,nw as xi,Vj as xn,cp as xo,ND as xr,Do as xs,mF as xt,tK as y,w_ as ya,rw as yi,Kj as yn,sp as yo,aO as yr,rs as ys,_F as yt,IG as z,Ug as za,iC as zi,mA as zn,Md as zo,vD as zr,ho as zs,iN as zt};
|
|
1533
|
-
//# sourceMappingURL=WorkerPoolContext-
|
|
1532
|
+
}`}function LG(e,t){let n=MG(t);return e.replace(PG,n)}function RG(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function zG({code:e,pre:t,columnType:n,rowSpan:r,containerSize:i=!1}={}){return e??(e=document.createElement(`code`),e.setAttribute(`data-code`,``),n!=null&&e.setAttribute(`data-${n}`,``),t?.appendChild(e)),r==null?e.style.removeProperty(`grid-row`):e.style.setProperty(`grid-row`,`span ${r}`),i?e.setAttribute(`data-container-size`,``):e.removeAttribute(`data-container-size`),e}function BG(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function VG(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:a,split:o,totalLines:s,customProperties:c}){if(c!=null)for(let t in c){let n=c[t];n!=null&&e.setAttribute(t,`${n}`)}switch(t===`diff`?(e.setAttribute(`data-diff`,``),e.removeAttribute(`data-file`)):(e.setAttribute(`data-file`,``),e.removeAttribute(`data-diff`)),n){case`bars`:case`classic`:e.setAttribute(`data-indicators`,n);break;case`none`:e.removeAttribute(`data-indicators`)}return i?e.setAttribute(`data-disable-line-numbers`,``):e.removeAttribute(`data-disable-line-numbers`),r?e.removeAttribute(`data-background`):e.setAttribute(`data-background`,``),t===`diff`?e.setAttribute(`data-diff-type`,o?`split`:`single`):e.removeAttribute(`data-diff-type`),e.setAttribute(`data-overflow`,a),e.style.setProperty(`--diffs-min-number-column-width-default`,`${`${s}`.length}ch`),e}function HG(e){if(typeof HTMLStyleElement<`u`&&e instanceof HTMLStyleElement)return!0;let t=e.tagName??e.nodeName;return typeof t==`string`&&t.toLowerCase()===`style`}function UG(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function WG(e,t){let n=e?.offsetHeight??0;if(e==null||n===0){t();return}e.style.minHeight=`${n}px`;try{t(),e.offsetHeight}finally{e.style.minHeight=``}}function GG({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===``){t?.remove();return}return t??=KG(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function KG(){let e=document.createElement(`style`);return e.setAttribute(eM,``),e}var qG=void 0;function JG(){return qG??=`safari`in window&&`pushNotification`in window.safari||/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}if(typeof HTMLElement<`u`&&customElements.get(`diffs-container`)==null){let e;class t extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;let t=this.attachShadow({mode:`open`});e??(e=new CSSStyleSheet,e.replaceSync(kG)),t.adoptedStyleSheets=[e]}connectedCallback(){jG(this.shadowRoot??this.attachShadow({mode:`open`}))}}customElements.define(Bj,t)}function YG(e){return{...sM,...e}}function XG(e,t){let n=ZG(e,t);return t?n:e.diffHeaderHeight+n}function ZG(e,t){return e.paddingTop??(t?e.spacing:0)}function QG(e){return e.paddingBottom??e.spacing}function $G(e){switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}function eK(e,t){return e===t||e?.cacheKey!=null&&e.cacheKey===t?.cacheKey}function tK(e,t){return bM(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function nK({line:e,spanStart:t,spanLength:n}){return{start:{line:e,character:t},end:{line:e,character:t+n},properties:{"data-diff-span":``},alwaysWrap:!0}}function rK({item:e,arr:t,enableJoin:n,isNeutral:r=!1,isLastItem:i=!1}){let a=t[t.length-1];if(a==null||i||!n){t.push([+!r,e.value]);return}let o=a[0]===0;if(r===o||r&&e.value.length===1&&!o){a[1]+=e.value;return}t.push([+!r,e.value])}function iK(e){return[EM(e.additionStart,e.additionCount)+1,DM(e.additionStart,e.additionCount)+1]}function aK({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:r,collapsedContextThreshold:i}){let a=Math.max(t,0);if(a===0||e)return{fromStart:0,fromEnd:0,rangeSize:a,collapsedLines:a,renderAll:!1};if(n===!0||a<=i)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(r),s=Math.min(Math.max(o?.fromStart??0,0),a),c=Math.min(Math.max(o?.fromEnd??0,0),a),l=s+c,u=l>=a;return{fromStart:u?a:s,fromEnd:u?0:c,rangeSize:a,collapsedLines:Math.max(a-l,0),renderAll:u}}function oK(e){let t=e.hunks[e.hunks.length-1];if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return!1;let n=e.additionLines.length-DM(t.additionStart,t.additionCount),r=e.deletionLines.length-DM(t.deletionStart,t.deletionCount);return n<=0&&r<=0?!1:n!==r}function sK({fileDiff:e,errorPrefix:t}){let n=e.hunks[e.hunks.length-1];if(n==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;let r=e.additionLines.length-DM(n.additionStart,n.additionCount),i=e.deletionLines.length-DM(n.deletionStart,n.deletionCount);if(r<=0&&i<=0)return 0;if(r!==i)throw Error(`${t}: trailing context mismatch (additions=${r}, deletions=${i}) for ${e.name}`);return Math.min(r,i)}function cK({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let a=sK({fileDiff:e,errorPrefix:i});if(a<=0)return;if(n===!0||a<=r)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(e.hunks.length),s=Math.min(Math.max(o?.fromStart??0,0),a);return{fromStart:s,fromEnd:0,rangeSize:a,collapsedLines:a-s,renderAll:s>=a}}function lK({fileDiff:e,lineNumber:t,expandedHunks:n,collapsedContextThreshold:r}){if(n===!0||e.isPartial)return!0;for(let[i,a]of e.hunks.entries()){let[o,s]=iK(a);if(t<o){let s=aK({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:n,hunkIndex:i,collapsedContextThreshold:r}),c=o-s.rangeSize;return s.renderAll||t<c+s.fromStart||t>=o-s.fromEnd}if(t<s)return!0}let i=cK({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:`isAdditionLineRenderable`});if(i==null||i.renderAll)return!0;let a=e.hunks[e.hunks.length-1],[,o]=iK(a);return t<o+i.fromStart||t>=o+i.rangeSize}function uK({fileDiff:e,lineNumber:t,direction:n,expandedHunks:r,collapsedContextThreshold:i}){if(r===!0||e.isPartial)return t;let a=[],o=1;for(let[t,n]of e.hunks.entries()){let[s,c]=iK(n),l=aK({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:r,hunkIndex:t,collapsedContextThreshold:i}),u=s-l.rangeSize;l.renderAll?a.push([u,s]):(l.fromStart>0&&a.push([u,u+l.fromStart]),l.fromEnd>0&&a.push([s-l.fromEnd,s])),a.push([s,c]),o=c}let s=cK({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:i,errorPrefix:`getNearestRenderableAdditionLine`});if(s!=null){let e=o;o=e+s.rangeSize,s.renderAll?a.push([e,o]):s.fromStart>0&&a.push([e,e+s.fromStart])}if(t>=o)return t;if(n===`down`){for(let[e,n]of a)if(n>t)return Math.max(e,t);return}for(let e=a.length-1;e>=0;e--){let[n,r]=a[e];if(n<=t)return Math.min(r-1,t)}}function dK({type:e,metrics:t}){return t.hunkSeparatorHeight??$G(e)}function fK({type:e,metrics:t}){return e===`simple`||e===`metadata`||e===`line-info-basic`?0:t.spacing}function pK({type:e,hunkIndex:t,hunkSpecs:n}){switch(e){case`simple`:return t>0;case`metadata`:return n!=null;case`line-info`:case`line-info-basic`:case`custom`:return!0}}function mK(e){return e!==`simple`&&e!==`metadata`}function hK({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!pK({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=dK({type:e,metrics:t}),a=fK({type:e,metrics:t}),o=n>0?a:0,s=a;return{height:i,gapBefore:o,gapAfter:s,totalHeight:o+i+s}}function gK({type:e,metrics:t}){if(!mK(e))return;let n=dK({type:e,metrics:t}),r=fK({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function _K({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:a=1,callback:o}){let s=vK({diff:e,diffStyle:t,startingLine:n,expandedHunks:i,collapsedContextThreshold:a}),c={viewportStart:n,viewportEnd:n+r,isWindowedHighlight:n>0||r<1/0,splitCount:s.splitCount,unifiedCount:s.unifiedCount,finalHunkIndex:e.hunks.length-1,shouldBreak(){if(!c.isWindowedHighlight)return!1;let e=c.unifiedCount>=n+r,i=c.splitCount>=n+r;return t===`unified`?e:(t===`split`||e)&&i},shouldSkip(e,r){if(!c.isWindowedHighlight)return!1;let i=e>0&&c.unifiedCount+e<=n,a=r>0&&c.splitCount+r<=n;return t===`unified`?i:(t===`split`||i)&&a},incrementCounts(e,n){(t===`unified`||t===`both`)&&(c.unifiedCount+=e),(t===`split`||t===`both`)&&(c.splitCount+=n)},isInWindow(e,n){if(!c.isWindowedHighlight)return!0;let r=c.isInUnifiedWindow(e),i=c.isInSplitWindow(n);return t===`unified`?r:t===`split`?i:r||i},isInUnifiedWindow(e){return!c.isWindowedHighlight||c.unifiedCount>=n-e&&c.unifiedCount<n+r},isInSplitWindow(e){return!c.isWindowedHighlight||c.splitCount>=n-e&&c.splitCount<n+r},emit(e,n=!1){return n||(t===`unified`?c.incrementCounts(1,0):t===`split`?c.incrementCounts(0,1):c.incrementCounts(1,1)),o(e)??!1}};hunkIterator:for(let n=s.hunkIndex;n<e.hunks.length;n++){let r=e.hunks[n];if(r==null)throw Error(`iterateOverDiff: invalid hunk index`);if(c.shouldBreak())break;let o=EM(r.deletionStart,r.deletionCount),s=EM(r.additionStart,r.additionCount),l=!e.isPartial&&r.deletionCount===0?o:r.deletionLineIndex,u=!e.isPartial&&r.additionCount===0?s:r.additionLineIndex,d=aK({isPartial:e.isPartial,rangeSize:r.collapsedBefore,expandedHunks:i,hunkIndex:n,collapsedContextThreshold:a}),f=n===c.finalHunkIndex?cK({fileDiff:e,hunkIndex:n,expandedHunks:i,collapsedContextThreshold:a,errorPrefix:`iterateOverDiff`}):void 0,p=d.fromStart+d.fromEnd;function m(e,n){return f==null||f.collapsedLines<=0||f.fromStart+f.fromEnd>0?0:t===`unified`?e===r.unifiedLineStart+r.unifiedLineCount-1?f.collapsedLines:0:n===r.splitLineStart+r.splitLineCount-1?f.collapsedLines:0}let h=d.collapsedLines===0;function g(){return h?0:(h=!0,d.collapsedLines)}if(c.shouldSkip(p,p))c.incrementCounts(p,p),g();else{let e=r.unifiedLineStart-d.rangeSize,i=r.splitLineStart-d.rangeSize,a=l-d.rangeSize,f=u-d.rangeSize,p=o+1-d.rangeSize,m=s+1-d.rangeSize;if(xK(c,d.fromStart,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:0,collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}))||(e=r.unifiedLineStart-d.fromEnd,i=r.splitLineStart-d.fromEnd,a=l-d.fromEnd,f=u-d.fromEnd,p=o+1-d.fromEnd,m=s+1-d.fromEnd,xK(c,d.fromEnd,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}),()=>{g()})))break hunkIterator}let _=r.unifiedLineStart,v=r.splitLineStart,y=l,b=u,x=o+1,ee=s+1,te=r.hunkContent.at(-1);for(let e of r.hunkContent){if(c.shouldBreak())break hunkIterator;let i=e===te;if(e.type===`context`){if(c.shouldSkip(e.lines,e.lines))c.incrementCounts(e.lines,e.lines),g();else if(xK(c,e.lines,t,t=>{let a=i&&t===e.lines-1,o=_+t,s=v+t;return c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:m(o,s),type:`context`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:a&&r.noEOFCRDeletions,unifiedLineIndex:o,splitLineIndex:s},additionLine:{unifiedLineIndex:o,splitLineIndex:s,lineIndex:b+t,lineNumber:ee+t,noEOFCR:a&&r.noEOFCRAdditions}})},()=>{g()}))break hunkIterator;_+=e.lines,v+=e.lines,y+=e.lines,b+=e.lines,x+=e.lines,ee+=e.lines}else{let a=Math.max(e.deletions,e.additions),o=e.deletions+e.additions;if(!c.shouldSkip(o,a)){let s=SK(c,e,t);(s[0]?.[0]??0)>0&&g();for(let[l,u]of s)for(let s=l;s<u;s++){let l=m(_+s,t===`unified`?v+(s<e.deletions?s:s-e.deletions):v+s);if(c.emit(CK({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:l,diffStyle:t,index:s,unifiedLineIndex:_,splitLineIndex:v,additionLineIndex:b,deletionLineIndex:y,additionLineNumber:ee,deletionLineNumber:x,content:e,isLastContent:i,unifiedCount:o,splitCount:a}),!0))break hunkIterator}}g(),c.incrementCounts(o,a),_+=o,v+=a,y+=e.deletions,b+=e.additions,x+=e.deletions,ee+=e.additions}}if(f!=null){let{collapsedLines:n,fromStart:r,fromEnd:i}=f,a=r+i;if(xK(c,a,t,t=>{let r=t===a-1;return c.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:r?n:0,type:`context-expanded`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:!1,unifiedLineIndex:_+t,splitLineIndex:v+t},additionLine:{unifiedLineIndex:_+t,splitLineIndex:v+t,lineIndex:b+t,lineNumber:ee+t,noEOFCR:!1}})},void 0,()=>c.shouldBreak()))break hunkIterator}}}function vK({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t===`both`)return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=yK({diff:e,expandedHunks:r,collapsedContextThreshold:i}),o=0,s=e.hunks.length-1,c=e.hunks.length;for(;o<=s;){let e=o+s>>1,r=a[e+1];if(r==null)throw Error(`iterateOverDiff: invalid hunk prefix index`);(t===`unified`?r.unifiedCount:r.splitCount)>n?(c=e,s=e-1):o=e+1}if(c>=e.hunks.length){let t=a[e.hunks.length];if(t==null)throw Error(`iterateOverDiff: invalid terminal hunk prefix index`);return{hunkIndex:e.hunks.length,splitCount:t.splitCount,unifiedCount:t.unifiedCount}}let l=a[c];if(l==null)throw Error(`iterateOverDiff: invalid selected hunk prefix index`);return{hunkIndex:c,splitCount:l.splitCount,unifiedCount:l.unifiedCount}}function yK({diff:e,expandedHunks:t,collapsedContextThreshold:n}){let r=0,i=0,a=e.hunks.length-1,o=[{splitCount:0,unifiedCount:0}];for(let s=0;s<e.hunks.length;s++){let c=e.hunks[s];if(c==null)throw Error(`iterateOverDiff: invalid hunk summary index`);let l=aK({isPartial:e.isPartial,rangeSize:c.collapsedBefore,expandedHunks:t,hunkIndex:s,collapsedContextThreshold:n}),u=l.fromStart+l.fromEnd;r+=u+c.splitLineCount,i+=u+c.unifiedLineCount;let d=s===a?cK({fileDiff:e,hunkIndex:s,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`iterateOverDiff`}):void 0;if(d!=null){let e=d.fromStart+d.fromEnd;r+=e,i+=e}o.push({splitCount:r,unifiedCount:i})}return o}function bK(e,t,n){if(!e.isWindowedHighlight||t<=0)return[0,t];let r=[];function i(n){let i=Math.max(0,e.viewportStart-n),a=Math.min(t,e.viewportEnd-n);a>i&&r.push([i,a])}if(n!==`split`&&i(e.unifiedCount),n!==`unified`&&i(e.splitCount),r.length===0)return[0,0];let a=r[0][0],o=r[0][1];for(let e=1;e<r.length;e++){let t=r[e];a=Math.min(a,t[0]),o=Math.max(o,t[1])}return[a,o]}function xK(e,t,n,r,i,a){let[o,s]=bK(e,t,n);o>0&&(e.incrementCounts(o,o),i?.());let c=o;for(;c<t;){if(a?.()===!0)return!0;if(c>=s){e.incrementCounts(t-c,t-c);break}if(e.isInWindow(0,0)){if(r(c)===!0)return!0}else e.incrementCounts(1,1);c++}return!1}function SK(e,t,n){if(!e.isWindowedHighlight)return[[0,n===`unified`?t.deletions+t.additions:Math.max(t.deletions,t.additions)]];let r=n!==`split`,i=n!==`unified`,a=n===`unified`?`unified`:`split`,o=[];function s(t,n){if(t+n<=e.viewportStart||t>=e.viewportEnd)return;let r=Math.max(0,e.viewportStart-t),i=Math.min(n,e.viewportEnd-t);return i>r?[r,i]:void 0}function c(e,n){return a===`split`?e:n===`additions`?[e[0]+t.deletions,e[1]+t.deletions]:e}function l(e,t){if(e==null)return;let[n,r]=c(e,t);r>n&&o.push([n,r])}if(r&&(l(s(e.unifiedCount,t.deletions),`deletions`),l(s(e.unifiedCount+t.deletions,t.additions),`additions`)),i&&(l(s(e.splitCount,t.deletions),`deletions`),l(s(e.splitCount,t.additions),`additions`)),o.length===0)return o;o.sort((e,t)=>e[0]-t[0]);let u=[o[0]];for(let[e,t]of o.slice(1)){let n=u[u.length-1];e<=n[1]?n[1]=Math.max(n[1],t):u.push([e,t])}return u}function CK({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,diffStyle:i,index:a,unifiedLineIndex:o,splitLineIndex:s,additionLineIndex:c,deletionLineIndex:l,additionLineNumber:u,deletionLineNumber:d,content:f,isLastContent:p,unifiedCount:m,splitCount:h}){let g=a<f.deletions?o+a:void 0,_=i===`unified`?a>=f.deletions?o+a:void 0:a<f.additions?o+f.deletions+a:void 0,v=i===`unified`?s+(a<f.deletions?a:a-f.deletions):s+a,y=a<f.deletions?l+a:void 0,b=a<f.deletions?d+a:void 0,x=i===`unified`?a>=f.deletions?c+(a-f.deletions):void 0:a<f.additions?c+a:void 0,ee=i===`unified`?a>=f.deletions?u+(a-f.deletions):void 0:a<f.additions?u+a:void 0,te=i===`unified`?p&&a===f.deletions-1&&t.noEOFCRDeletions:p&&a===h-1&&t.noEOFCRDeletions,ne=i===`unified`?p&&a===m-1&&t.noEOFCRAdditions:p&&a===h-1&&t.noEOFCRAdditions,re=y!=null&&b!=null&&g!=null?{lineNumber:b,lineIndex:y,noEOFCR:te,unifiedLineIndex:g,splitLineIndex:v}:void 0,ie=x!=null&&ee!=null&&_!=null?{unifiedLineIndex:_,splitLineIndex:v,lineIndex:x,lineNumber:ee,noEOFCR:ne}:void 0;if(re==null&&ie!=null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:ie};if(re!=null&&ie==null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:re,additionLine:void 0};if(re==null||ie==null)throw Error(`iterateOverDiff: missing change line data`);return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:re,additionLine:ie}}var wK={forcePlainText:!1};function TK(e,t,n,{forcePlainText:r,startingLine:i,totalLines:a,expandedHunks:o,collapsedContextThreshold:s=1}=wK){r?(i??=0,a??=1/0):(i=0,a=1/0);let c=i>0||a<1/0,l=typeof n.theme==`string`?t.getTheme(n.theme).type:void 0,u=rG({theme:n.theme,highlighter:t}),d=r&&!c&&(e.unifiedLineCount>1e3||e.splitLineCount>1e3)?`none`:n.lineDiffType,f={deletionLines:[],additionLines:[]},{maxLineDiffLength:p}=n,m=!r&&!e.isPartial,h=r?o:void 0,g=new Map;function _(e){let t=m?0:e,n=g.get(t)??DK();return g.set(t,n),n}function v(e,t,n,r){if(c){let e=n.at(-1);(e==null||e.targetIndex+e.count!==t)&&(e={targetIndex:t,originalOffset:r.length,count:0},n.push(e)),e.count++}r.push(e)}_K({diff:e,diffStyle:`both`,startingLine:i,totalLines:a,expandedHunks:!c||h,collapsedContextThreshold:s,callback:({hunkIndex:t,additionLine:n,deletionLine:r,type:i})=>{let a=_(t),o=n==null?r.splitLineIndex:n.splitLineIndex;i===`change`&&n!=null&&r!=null&&EK({additionLine:e.additionLines[n.lineIndex],deletionLine:e.deletionLines[r.lineIndex],deletionLineIndex:a.deletionContent.length,additionLineIndex:a.additionContent.length,deletionDecorations:a.deletionDecorations,additionDecorations:a.additionDecorations,lineDiffType:d,maxLineDiffLength:p}),r!=null&&(v(e.deletionLines[r.lineIndex],r.lineIndex,a.deletionSegments,a.deletionContent),a.deletionInfo.push({type:i===`change`?`change-deletion`:i,lineNumber:r.lineNumber,altLineNumber:i===`change`?void 0:n.lineNumber??void 0,lineIndex:`${r.unifiedLineIndex},${o}`})),n!=null&&(v(e.additionLines[n.lineIndex],n.lineIndex,a.additionSegments,a.additionContent),a.additionInfo.push({type:i===`change`?`change-addition`:i,lineNumber:n.lineNumber,altLineNumber:i===`change`?void 0:r.lineNumber??void 0,lineIndex:`${n.unifiedLineIndex},${o}`}))}});for(let i of g.values()){if(i.deletionContent.length===0&&i.additionContent.length===0)continue;let a={name:e.prevName??e.name,contents:i.deletionContent.value},o={name:e.name,contents:i.additionContent.value},{deletionLines:s,additionLines:c}=OK({deletionFile:a,deletionInfo:i.deletionInfo,deletionDecorations:i.deletionDecorations,additionFile:o,additionInfo:i.additionInfo,additionDecorations:i.additionDecorations,highlighter:t,options:n,languageOverride:r?`text`:e.lang});if(m){f.deletionLines=s,f.additionLines=c;continue}if(i.deletionSegments.length>0)for(let e of i.deletionSegments)for(let t=0;t<e.count;t++)f.deletionLines[e.targetIndex+t]=s[e.originalOffset+t];else f.deletionLines.push(...s);if(i.additionSegments.length>0)for(let e of i.additionSegments)for(let t=0;t<e.count;t++)f.additionLines[e.targetIndex+t]=c[e.originalOffset+t];else f.additionLines.push(...c)}return{code:f,themeStyles:u,baseThemeType:l}}function EK({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a,lineDiffType:o,maxLineDiffLength:s}){if(e==null||t==null||o===`none`||(e=TM(e),t=TM(t),e.length>s||t.length>s))return;let c=o===`char`?AM(e,t):qM(e,t),l=[],u=[],d=o===`word-alt`,f=c.at(-1);for(let e of c){let t=e===f;!e.added&&!e.removed?(rK({item:e,arr:l,enableJoin:d,isNeutral:!0,isLastItem:t}),rK({item:e,arr:u,enableJoin:d,isNeutral:!0,isLastItem:t})):e.removed?rK({item:e,arr:l,enableJoin:d,isLastItem:t}):rK({item:e,arr:u,enableJoin:d,isLastItem:t})}let p=0;for(let e of l)e[0]===1&&i.push(nK({line:n,spanStart:p,spanLength:e[1].length})),p+=e[1].length;p=0;for(let e of u)e[0]===1&&a.push(nK({line:r,spanStart:p,spanLength:e[1].length})),p+=e[1].length}function DK(){return{deletionContent:{push(e){this.value+=e,this.length++},value:``,length:0},additionContent:{push(e){this.value+=e,this.length++},value:``,length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function OK({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:a,additionDecorations:o,languageOverride:s,options:{theme:c=$j,...l}}){let u=s??DW(e.name),d=s??DW(t.name),{state:f,transformers:p}=VW(l.useTokenTransformer),m=typeof c==`string`?{...l,lang:`text`,theme:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:WW(`token`),tokenizeTimeLimit:0}:{...l,lang:`text`,themes:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:WW(`token`),tokenizeTimeLimit:0};return{deletionLines:e.contents===``?[]:(m.lang=u,f.lineInfo=n,m.decorations=a,aG(i.codeToHast(TM(e.contents),m))),additionLines:t.contents===``?[]:(m.lang=d,m.decorations=o,f.lineInfo=r,aG(i.codeToHast(TM(t.contents),m)))}}function kK(e){let t=e.lang??DW(e.name),n=e.lang??(e.prevName==null?`text`:DW(e.prevName));return t===`text`&&n===`text`}function AK(e){let t=[];for(let n of e){let e=JF.get(n);if(e==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(e)}return t}function jK(e){for(let t of Array.isArray(e)?e:[e])if(!JF.has(t))return!1;return!0}async function MK(e){let t=[],n=[];for(let r of e){if(r===`text`||r===`ansi`)continue;let e=wU(r)??CU(r);`then`in e?n.push(e):t.push(e)}return n.length>0&&await Promise.all(n).then(e=>{for(let n of e){if(n==null)throw Error(`resolvedLanguages: unable to resolve language`);t.push(n)}}),t}function NK(e){return IU.getResolvedThemes(e)}async function PK(e){for(let t of e)iW(t);let t=await IU.resolveThemes(e);for(let n=0;n<e.length;n++)aW(e[n],t[n]);return t}var FK={light:`pierre-light`,dark:`pierre-dark`};function IK(e){return e===`dark`?FK.dark:FK.light}var LK=2166136261,RK=16777619,zK=2654435769,BK=2246822507;function VK(e,t=LK,n=RK){let r=t>>>0;for(let t=0;t<e.length;t+=1)r^=e.charCodeAt(t),r=Math.imul(r,n)>>>0;return r>>>0}function HK(e,t=`diff-panel`){let n=e.trim(),r=VK(n,LK,RK).toString(36),i=VK(n,zK,BK).toString(36);return`${t}:${n.length}:${r}:${i}`}function UK(e){return wa(`flex items-center justify-between gap-2 px-4 wco:pr-[calc(100vw-env(titlebar-area-width)-env(titlebar-area-x)+1em)]`,xn&&e!==`sheet`?`h-[52px] border-b border-border wco:h-[env(titlebar-area-height)]`:`h-12 wco:max-h-[env(titlebar-area-height)]`)}function WK(e){let t=(0,A.c)(10),n=xn&&e.mode!==`sheet`,r=e.mode===`inline`?`w-[42vw] min-w-[360px] max-w-[560px] shrink-0 border-l border-border`:`w-full`,i;t[0]===r?i=t[1]:(i=wa(`flex h-full min-w-0 flex-col bg-background`,r),t[0]=r,t[1]=i);let a;t[2]!==e.header||t[3]!==e.mode||t[4]!==n?(a=n?(0,k.jsx)(`div`,{className:UK(e.mode),children:e.header}):(0,k.jsx)(`div`,{className:`border-b border-border`,children:(0,k.jsx)(`div`,{className:UK(e.mode),children:e.header})}),t[2]=e.header,t[3]=e.mode,t[4]=n,t[5]=a):a=t[5];let o;return t[6]!==e.children||t[7]!==i||t[8]!==a?(o=(0,k.jsxs)(`div`,{className:i,children:[a,e.children]}),t[6]=e.children,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function GK(){let e=(0,A.c)(4),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,k.jsx)(xw,{className:`absolute left-0 top-1/2 size-6 -translate-y-1/2 rounded-md border border-border/50`}),n=(0,k.jsx)(xw,{className:`absolute right-0 top-1/2 size-6 -translate-y-1/2 rounded-md border border-border/50`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,k.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[t,n,(0,k.jsxs)(`div`,{className:`flex gap-1 overflow-hidden px-8 py-0.5`,children:[(0,k.jsx)(xw,{className:`h-6 w-16 shrink-0 rounded-md`}),(0,k.jsx)(xw,{className:`h-6 w-24 shrink-0 rounded-md`}),(0,k.jsx)(xw,{className:`h-6 w-24 shrink-0 rounded-md max-sm:hidden`})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,k.jsxs)(k.Fragment,{children:[r,(0,k.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,k.jsx)(xw,{className:`size-7 rounded-md`}),(0,k.jsx)(xw,{className:`size-7 rounded-md`})]})]}),e[3]=i):i=e[3],i}function KK(e){let t=(0,A.c)(7),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,k.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,k.jsx)(xw,{className:`h-4 w-32 rounded-full`}),(0,k.jsx)(xw,{className:`ml-auto h-4 w-20 rounded-full`})]}),t[0]=n):n=t[0];let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(xw,{className:`h-3 w-full rounded-full`}),(0,k.jsx)(xw,{className:`h-3 w-full rounded-full`}),(0,k.jsx)(xw,{className:`h-3 w-10/12 rounded-full`}),(0,k.jsx)(xw,{className:`h-3 w-11/12 rounded-full`}),(0,k.jsx)(xw,{className:`h-3 w-9/12 rounded-full`})]}),t[1]=r):r=t[1];let i;t[2]===e.label?i=t[3]:(i=(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 px-3 py-4`,children:[r,(0,k.jsx)(`span`,{className:`sr-only`,children:e.label})]}),t[2]=e.label,t[3]=i);let a;return t[4]!==e.label||t[5]!==i?(a=(0,k.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col p-2`,children:(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border border-border/60 bg-card/25`,role:`status`,"aria-live":`polite`,"aria-label":e.label,children:[n,i]})}),t[4]=e.label,t[5]=i,t[6]=a):a=t[6],a}function qK(e){let t=(0,O.useRef)(e);return(0,O.useInsertionEffect)(()=>void(t.current=e)),(0,O.useCallback)((...e)=>t.current(...e),[])}var JK=(0,O.createContext)(void 0);function YK(){return(0,O.useContext)(JK)}var XK={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},ZK={display:`contents`};function QK(){return null}var $K=t(n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):r((n||=self).lru_map=n.lru_map||{})})(e,function(e){let t=Symbol(`newer`),n=Symbol(`older`);class r{constructor(e,t){typeof e!=`number`&&(t=e,e=0),this.size=0,this.limit=e,this.oldest=this.newest=void 0,this._keymap=new Map,t&&(this.assign(t),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[t]&&(e===this.oldest&&(this.oldest=e[t]),e[t][n]=e[n]),e[n]&&(e[n][t]=e[t]),e[t]=void 0,e[n]=this.newest,this.newest&&(this.newest[t]=e),this.newest=e)}assign(e){let r,a=this.limit||Number.MAX_VALUE;this._keymap.clear();let o=e[Symbol.iterator]();for(let e=o.next();!e.done;e=o.next()){let o=new i(e.value[0],e.value[1]);if(this._keymap.set(o.key,o),r?(r[t]=o,o[n]=r):this.oldest=o,r=o,a--==0)throw Error(`overflow`)}this.newest=r,this.size=this._keymap.size}get(e){var t=this._keymap.get(e);return t?(this._markEntryAsUsed(t),t.value):void 0}set(e,r){var a=this._keymap.get(e);return a?(a.value=r,this._markEntryAsUsed(a),this):(this._keymap.set(e,a=new i(e,r)),this.newest?(this.newest[t]=a,a[n]=this.newest):this.oldest=a,this.newest=a,++this.size,this.size>this.limit&&this.shift(),this)}shift(){var e=this.oldest;if(e)return this.oldest[t]?(this.oldest=this.oldest[t],this.oldest[n]=void 0):(this.oldest=void 0,this.newest=void 0),e[t]=e[n]=void 0,this._keymap.delete(e.key),--this.size,[e.key,e.value]}find(e){let t=this._keymap.get(e);return t?t.value:void 0}has(e){return this._keymap.has(e)}delete(e){var r=this._keymap.get(e);return r?(this._keymap.delete(r.key),r[t]&&r[n]?(r[n][t]=r[t],r[t][n]=r[n]):r[t]?(r[t][n]=void 0,this.oldest=r[t]):r[n]?(r[n][t]=void 0,this.newest=r[n]):this.oldest=this.newest=void 0,this.size--,r.value):void 0}clear(){this.oldest=this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new o(this.oldest)}values(){return new s(this.oldest)}entries(){return this}[Symbol.iterator](){return new a(this.oldest)}forEach(e,n){typeof n!=`object`&&(n=this);let r=this.oldest;for(;r;)e.call(n,r.value,r.key,this),r=r[t]}toJSON(){for(var e=Array(this.size),n=0,r=this.oldest;r;)e[n++]={key:r.key,value:r.value},r=r[t];return e}toString(){for(var e=``,n=this.oldest;n;)e+=String(n.key)+`:`+n.value,n=n[t],n&&(e+=` < `);return e}}e.LRUMap=r;function i(e,r){this.key=e,this.value=r,this[t]=void 0,this[n]=void 0}function a(e){this.entry=e}a.prototype[Symbol.iterator]=function(){return this},a.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}};function o(e){this.entry=e}o.prototype[Symbol.iterator]=function(){return this},o.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:e.key}):{done:!0,value:void 0}};function s(e){this.entry=e}s.prototype[Symbol.iterator]=function(){return this},s.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:e.value}):{done:!0,value:void 0}}})}))(),1),eq=Symbol(`IGNORE_RESPONSE`),tq=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled because the pool terminated`)}},nq=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled before the task completed`)}},rq=class{options;highlighter;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialized=!1;workers=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;workersFailed=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:n=$j,useTokenTransformer:r=!1,lineDiffType:i=`word-alt`,maxLineDiffLength:a=1e3,tokenizeMaxLineLength:o=1e3,preferredHighlighter:s=`shiki-js`}){this.options=e,this.preferredHighlighter=s,this.renderOptions={theme:n,useTokenTransformer:r,lineDiffType:i,maxLineDiffLength:a,tokenizeMaxLineLength:o},this.fileCache=new $K.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new $K.default.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed}getFileResultCache(e){return e.cacheKey==null?void 0:this.fileCache.get(e.cacheKey)}getDiffResultCache(e){return e.cacheKey==null?void 0:this.diffCache.get(e.cacheKey)}inspectCaches(){let{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??$j,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:n=this.renderOptions.lineDiffType??`word-alt`,maxLineDiffLength:r=this.renderOptions.maxLineDiffLength??1e3,tokenizeMaxLineLength:i=this.renderOptions.tokenizeMaxLineLength??1e3}){let{lifecycleGeneration:a}=this,o=++this.renderOptionsRequestVersion,s=()=>this.isCurrentLifecycle(a)&&this.renderOptionsRequestVersion===o;try{let a={theme:e,useTokenTransformer:t,lineDiffType:n,maxLineDiffLength:r,tokenizeMaxLineLength:i};if(this.isInitialized()||await this.initialize(),!s()||tK(a,this.renderOptions))return;let o=fW(e),c=[];if(bM(a.theme,this.renderOptions.theme)||(c=mW(o)?NK(o):await PK(o)),!s())return;if(this.highlighter!=null)LU(c,this.highlighter);else{let e=await lW({themes:o,langs:[`text`],preferredHighlighter:this.preferredHighlighter});if(!s())return;this.highlighter=e}let l=this.setRenderOptionsOnWorkers(a,c);this.renderOptions=a,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(let e of this.themeSubscribers)e.onThemeChange();await l}catch(e){if(e instanceof tq||!s())return;throw e}}getPreferredHighlighter(){return this.preferredHighlighter}getFileRenderOptions(){let{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:n}=this.renderOptions;return{theme:t,useTokenTransformer:n,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e,t){if(this.workersFailed)return;this.isInitialized()||await this.initialize();let n=[];for(let r of this.workers){if(!r.initialized)throw console.log({managedWorker:r}),Error(`setRenderOptionsOnWorkers: Somehow we have an uninitialized worker`);n.push(new Promise((n,i)=>{let a=this.generateRequestId(),o={type:`set-render-options`,id:a,request:{type:`set-render-options`,id:a,renderOptions:e,resolvedThemes:t},resolve:n,reject:i,requestStart:Date.now()};this.activeTaskById.set(a,o),r.pendingSetupRequestId=a,r.worker.postMessage(o.request)}))}await Promise.all(n)}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){this._queuedBroadcast??=requestAnimationFrame(this._broadcastStateChanges)}_broadcastStateChanges=()=>{this._queuedBroadcast!=null&&(cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0);let e=this.getStats();for(let t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);let t=this.activeRequestByInstance.get(e);if(t!=null){let n=this.activeTaskById.get(t);oq(n)?(this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0&&this.removeActiveTask(n)):this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialized===!0}async initialize(e=[]){if(this.initialized!==!0)if(this.initialized===!1){let{lifecycleGeneration:t}=this;this.initialized=new Promise((n,r)=>{(async()=>{try{let r=fW(this.renderOptions.theme),i=[];if(i=mW(r)?NK(r):await PK(r),!this.isCurrentLifecycle(t)){n();return}let a=[];if(a=jK(e)?AK(e):await MK(e),!this.isCurrentLifecycle(t)){n();return}let[o]=await Promise.all([lW({themes:r,langs:[`text`,...e],preferredHighlighter:this.preferredHighlighter}),this.initializeWorkers(i,a)]);if(!this.isCurrentLifecycle(t)){this.terminateWorkers(),n();return}this.highlighter=o,this.initialized=!0,this.diffCache.clear(),this.fileCache.clear(),this.drainQueue(),this.queueBroadcastStateChanges(),n()}catch(e){if(e instanceof tq||!this.isCurrentLifecycle(t)){n();return}this.initialized=!1,this.workersFailed=!0;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,cq(e));this.queueBroadcastStateChanges(),r(e)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=OW(),i=r>0?kW():void 0;this.workers.length>0&&this.terminateWorkers();for(let a=0;a<(this.options.poolSize??8);a++){let a=this.options.workerFactory(),o={worker:a,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set([`text`,...t.map(({name:e})=>e)]),customExtensionsVersion:0};a.addEventListener(`message`,e=>{this.handleWorkerMessage(o,e.data)}),a.addEventListener(`error`,e=>console.error(`Worker error:`,e,o)),this.workers.push(o),n.push(new Promise((n,a)=>{let s=this.generateRequestId(),c={type:`initialize`,id:s,request:{type:`initialize`,id:s,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:i==null?void 0:r,customExtensionMap:i},resolve(){o.initialized=!0,n()},reject:a,requestStart:Date.now()};this.activeTaskById.set(s,c),this.executeTask(o,c)}))}await Promise.all(n)}drainQueue=()=>{if(this._queuedDrain=void 0,this.initialized===!0&&this.queuedTasks.length!==0){for(let e=0;e<this.queuedTasks.length;){let t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}let n=aq(t),r=this.getAvailableWorker(n);if(r==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,r),this.resolveLanguagesAndExecuteTask(r,t,n)}this.queueBroadcastStateChanges()}};highlightFileAST(e,t){let n=this.getFileResultCache(t);xG(t)||n!=null&&hW(n.options,this.getFileRenderOptions())||this.hasMatchingFileInstanceTask(e,t)||this.submitTask(e,{type:`file`,file:t})}primeFileHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error(`WorkerPoolManager.primeFileHighlightCache: worker pool is not working`));let t=this.getOrCreateFileHighlightCacheTask(e);return t==null?Promise.resolve():this.createRenderTaskCallbacks(t)}getOrCreateFileHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`);return}let t=this.getFileResultCache(e),n=this.getFileHighlightKey(e);if(n==null||xG(e)||t!=null&&hW(t.options,this.getFileRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type===`file`?r:void 0;{let t=this.submitCacheTask({type:`file`,file:e},n);return t.type===`file`?t:void 0}}getPlainFileAST(e,t,n,r){if(this.highlighter==null){this.queueInitialization();return}return pG(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);kK(t)||n!=null&&tK(n.options,this.getDiffRenderOptions())||this.hasMatchingDiffInstanceTask(e,t)||this.submitTask(e,{type:`diff`,diff:t})}primeDiffHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error(`WorkerPoolManager.primeDiffHighlightCache: worker pool is not working`));let t=this.getOrCreateDiffHighlightCacheTask(e);return t==null?Promise.resolve():this.createRenderTaskCallbacks(t)}getOrCreateDiffHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`);return}let t=this.getDiffResultCache(e),n=this.getDiffHighlightKey(e);if(n==null||kK(e)||t!=null&&tK(t.options,this.getDiffRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type===`diff`?r:void 0;{let t=this.submitCacheTask({type:`diff`,diff:e},n);return t.type===`diff`?t:void 0}}getPlainDiffAST(e,t,n,r,i){return this.highlighter==null?void 0:TK(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,expandedHunks:r,collapsedContextThreshold:i})}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers();let e=new tq;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,e);this.fileCache.clear(),this.diffCache.clear(),this.activeRequestByInstance.clear(),this.queuedTasks.length=0,this.queuedTaskByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.highlighter=void 0,this.initialized=!1,this.workersFailed=!1,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch(e=>{console.error(e)})}cancelActiveWorkerTasks(){let e=new tq;for(let t of this.activeTaskById.values())`reject`in t?t.reject(e):oq(t)&&this.rejectRenderTaskCallbacks(t,e)}terminateWorkers(){for(let e of this.workers)e.worker.terminate();this.workers.length=0}getStats(){return{managerState:this.initialized===!1?`waiting`:this.initialized===!0?`initialized`:`initializing`,totalWorkers:this.workers.length,workersFailed:this.workersFailed,busyWorkers:this.workers.filter(e=>e.requestId!=null||e.pendingSetupRequestId!=null).length,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){this.initialized===!1&&this.queueInitialization();let n=this.getHighlightKeyForRequest(t),r=n==null?void 0:this.getTaskByHighlightKey(n);if(r!=null){this.detachInstanceFromQueuedTasks(e,r),this.addInstanceToTask(r,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);let i=this.generateRequestId(),a=Date.now(),{renderOptionsVersion:o}=this,s=(()=>{switch(t.type){case`file`:return{type:`file`,id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:o,requestStart:a};case`diff`:return{type:`diff`,id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:o,requestStart:a}}})();this.enqueueRenderTask(s,e)}submitCacheTask(e,t){this.initialized===!1&&this.queueInitialization();let n=this.generateRequestId(),r=Date.now(),{renderOptionsVersion:i}=this,a=(()=>{switch(e.type){case`file`:return{type:`file`,id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r};case`diff`:return{type:`diff`,id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r}}})();return this.enqueueRenderTask(a),a}enqueueRenderTask(e,t){this.queuedTasks.push(e),t!=null&&this.queuedTaskByInstance.set(t,e),e.highlightKey!=null&&this.taskByHighlightKey.set(e.highlightKey,e),this.queueDrain()}async resolveLanguagesAndExecuteTask(e,t,n){try{let r=n.filter(t=>!e.langs.has(t));if(r.length>0&&(jK(r)?t.request.resolvedLanguages=AK(r):t.request.resolvedLanguages=await MK(r)),!this.activeTaskById.has(t.id)){e.requestId===t.id&&(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain());return}this.executeTask(e,t)}catch(n){this.rejectRenderTaskCallbacks(t,cq(n)),this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}}handleWorkerMessage(e,t){let n=this.activeTaskById.get(t.id);try{if(n==null)throw eq;if(t.type===`error`){let e=Error(t.error);if(t.stack&&(e.stack=t.stack),`reject`in n)n.reject(e);else if(oq(n))this.notifyHighlightError(n,e),this.rejectRenderTaskCallbacks(n,e);else throw Error(`handleWorkerMessage: unknown task type`);throw e}switch(t.requestType){case`initialize`:if(n.type!==`initialize`)throw Error(`handleWorkerMessage: task/response dont match`);this.syncCustomExtensionVersion(e,n.request),n.resolve();break;case`set-render-options`:if(n.type!==`set-render-options`)throw Error(`handleWorkerMessage: task/response dont match`);n.resolve();break;case`file`:{if(n.type!==`file`)throw Error(`handleWorkerMessage: task/response dont match`);let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!hW(i,this.getFileRenderOptions()))throw eq;let{request:a}=n;this.syncCustomExtensionVersion(e,a),n.cacheKeyAtDispatch!=null&&this.fileCache.set(n.cacheKeyAtDispatch,{result:r,options:i}),this.resolveRenderTaskCallbacks(n),this.notifyFileInstances(n,r,i);break}case`diff`:{if(n.type!==`diff`)throw Error(`handleWorkerMessage: task/response dont match`);let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!tK(i,this.getDiffRenderOptions()))throw eq;let{request:a}=n;this.syncCustomExtensionVersion(e,a),n.cacheKeyAtDispatch!=null&&this.diffCache.set(n.cacheKeyAtDispatch,{result:r,options:i}),this.resolveRenderTaskCallbacks(n),this.notifyDiffInstances(n,r,i);break}}}catch(e){e!==eq&&console.error(e,n,t)}this.cleanWorkerAndTask(e,n,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}_queuedDrain;queueDrain(){this._queuedDrain??(this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges())}assignWorkerToTask(e,t){t.requestId=e.id,oq(e)&&(this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e)),this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,n=t?.id){e.requestId===n&&(e.requestId=void 0),e.pendingSetupRequestId===n&&(e.pendingSetupRequestId=void 0),t!=null&&(oq(t)&&(this.rejectRenderTaskCallbacks(t,new nq),this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){iq(t.request)&&this.maybeAttachCustomExtensions(e,t.request),this.activeTaskById.has(t.id)||this.assignWorkerToTask(t,e);for(let n of aq(t))e.langs.add(n);try{t.type===`file`?t.cacheKeyAtDispatch=t.request.file.cacheKey:t.type===`diff`&&(t.cacheKeyAtDispatch=t.request.diff.cacheKey),e.worker.postMessage(t.request)}catch(n){console.error(`Failed to post message to worker:`,n),oq(t)?(this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,cq(n))):`reject`in t&&t.reject(n),this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0&&this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;let n=OW();e.customExtensionsVersion>=n||(t.customExtensionsVersion=n,t.customExtensionMap=kW())}syncCustomExtensionVersion(e,t){t.customExtensionsVersion!=null&&(e.customExtensionsVersion=t.customExtensionsVersion)}getAvailableWorker(e){let t;for(let n of this.workers){if(n.requestId!=null||n.pendingSetupRequestId!=null||!n.initialized)continue;if(t=n,e.length===0)break;let r=!0;for(let t of e)if(!n.langs.has(t)){r=!1;break}if(r)break}return t}getFileHighlightKey(e){if(e.cacheKey!=null)return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey!=null)return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case`file`:return this.getFileHighlightKey(e.file);case`diff`:return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(let t of sq(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){e.type,e.instances.add(t),this.activeTaskById.has(e.id)?this.activeRequestByInstance.set(t,e.id):this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){let n=this.queuedTaskByInstance.get(e);n!=null&&n!==t&&(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0&&this.removeQueuedTask(n))}detachInstanceFromRenderTask(e,t){e.type,e.instances.delete(t)}removeQueuedTask(e){let t=this.queuedTasks.indexOf(e);t!==-1&&this.queuedTasks.splice(t,1),this.rejectRenderTaskCallbacks(e,new nq),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new nq),this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}createRenderTaskCallbacks(e){return new Promise((t,n)=>{e.callbacks.add({resolve:t,reject:n})})}resolveRenderTaskCallbacks(e){for(let t of e.callbacks)t.resolve();e.callbacks.clear()}rejectRenderTaskCallbacks(e,t){for(let n of e.callbacks)n.reject(t);e.callbacks.clear()}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){let t=this.queuedTasks[e];t.renderOptionsVersion!==this.renderOptionsVersion&&this.removeQueuedTask(t)}for(let e of Array.from(this.activeTaskById.values()))oq(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of sq(e))this.queuedTaskByInstance.get(t)===e&&this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e&&this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(let t of sq(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of sq(e))this.activeRequestByInstance.get(t)===e.id&&this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,n){for(let r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.file,t,n)}notifyDiffInstances(e,t,n){for(let r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.diff,t,n)}notifyHighlightError(e,t){for(let n of sq(e))this.activeRequestByInstance.get(n)===e.id&&n.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type===`file`&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&oN(t,n.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type===`diff`&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&eK(n.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){let t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(let e of this.queuedTasks)yield e;for(let e of this.activeTaskById.values())oq(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function iq(e){return e.type===`initialize`||e.type===`file`||e.type===`diff`}function aq(e){let t=new Set;if(e.type===`initialize`||e.type===`set-render-options`)return[];switch(e.type){case`file`:t.add(e.request.file.lang??DW(e.request.file.name));break;case`diff`:t.add(e.request.diff.lang??DW(e.request.diff.name)),t.add(e.request.diff.lang??DW(e.request.diff.prevName??`-`))}return t.delete(`text`),Array.from(t)}function oq(e){return e?.type===`file`||e?.type===`diff`}function sq(e){return e.instances}function cq(e){return e instanceof Error?e:Error(String(e))}var lq;function uq({poolOptions:e,highlighterOptions:t}){return lq??=new rq(e,t),lq}function dq(){lq!=null&&(lq.terminate(),lq=void 0)}var fq=(0,O.createContext)(void 0),pq=0;function mq({children:e,poolOptions:t,highlighterOptions:n}){let[r]=(0,O.useState)(()=>{if(!(typeof window>`u`))return uq({poolOptions:t,highlighterOptions:n})});return(0,O.useInsertionEffect)(()=>{if(r!=null)return pq++,()=>{pq--}},[r]),(0,O.useEffect)(()=>()=>{pq===0&&dq()},[]),(0,k.jsx)(fq.Provider,{value:r,children:e})}function hq(){return(0,O.useContext)(fq)}export{_G as $,Ch as $a,ux as $i,ZO as $n,j as $o,iT as $r,ro as $s,iM as $t,XG as A,l_ as Aa,dC as Ai,yj as An,Wf as Ao,qE as Ar,Ro as As,KN as At,LG as B,Ug as Ba,rC as Bi,nA as Bn,Md as Bo,zT as Br,ho as Bs,oN as Bt,cK as C,m_ as Ca,cw as Ci,Nj as Cn,rp as Co,yD as Cr,Fo as Cs,TP as Ct,tK as D,u_ as Da,ew as Di,Mj as Dn,$f as Do,DD as Dr,Mo as Ds,SP as Dt,lK as E,d_ as Ea,hw as Ei,Ij as En,ip as Eo,MD as Er,No as Es,wP as Et,UG as F,Jg as Fa,$S as Fi,yA as Fn,Pf as Fo,FT as Fr,xo as Fs,dN as Ft,DG as G,kg as Ga,BS as Gi,Lk as Gn,zu as Go,AT as Gr,no as Gs,wM as Gt,FG as H,Lg as Ha,KS as Hi,zk as Hn,Td as Ho,kT as Hr,lo as Hs,DM as Ht,HG as I,Wg as Ia,tC as Ii,mA as In,pf as Io,VT as Ir,bo as Is,uN as It,SG as J,ig as Ja,fS as Ji,nk as Jn,zl as Jo,Uw as Jr,Qa as Js,bM as Jt,EG as K,hg as Ka,CS as Ki,Ok as Kn,Wu as Ko,jT as Kr,oo as Ks,CM as Kt,VG as L,Zg as La,iC as Li,vA as Ln,ff as Lo,LT as Lr,yo as Ls,B as Lt,JG as M,s_ as Ma,aC as Mi,sj as Mn,Vf as Mo,UE as Mr,zo as Ms,yN as Mt,GG as N,o_ as Na,sC as Ni,nj as Nn,Rf as No,GE as Nr,Xo as Ns,gN as Nt,eK as O,i_ as Oa,xC as Oi,Lj as On,Yf as Oo,oD as Or,Eo as Os,JN as Ot,WG as P,Yg as Pa,XS as Pi,UA as Pn,Ff as Po,KE as Pr,Jo as Ps,fN as Pt,hG as Q,Dh as Qa,Jx as Qi,ek as Qn,fl as Qo,qw as Qr,Ha as Qs,qj as Qt,BG as R,Rg as Ra,eC as Ri,pA as Rn,af as Ro,RT as Rr,vo as Rs,cN as Rt,sK as S,g_ as Sa,tw as Si,Pj as Sn,cp as So,CD as Sr,Do as Ss,OP as St,oK as T,f_ as Ta,rw as Ti,zj as Tn,Zf as To,jD as Tr,Go as Ts,CP as Tt,jG as U,Tg as Ua,HS as Ui,Bk as Un,nd as Uo,DT as Ur,co as Us,EM as Ut,IG as V,Cg as Va,QS as Vi,rA as Vn,Cd as Vo,wT as Vr,uo as Vs,iN as Vt,OG as W,xg as Wa,VS as Wi,Rk as Wn,ud as Wo,OT as Wr,so as Ws,TM as Wt,bG as X,xh as Xa,Gx as Xi,rk as Xn,kl as Xo,zw as Xr,Va as Xs,_M as Xt,xG as Y,_h as Ya,lS as Yi,tk as Yn,Al as Yo,Rw as Yr,ao as Ys,yM as Yt,yG as Z,Eh as Za,Yx as Zi,ok as Zn,Tl as Zo,Kw as Zr,Wa as Zs,gM as Zt,_K as _,q_ as _a,aw as _i,Xj as _n,sm as _o,TO as _r,ps as _s,QF as _t,ZK as a,Dy as aa,nT as ai,dM as an,Rm as ao,EO as ar,zs as as,AW as at,hK as b,w_ as ba,nw as bi,Jj as bn,sp as bo,QD as br,rs as bs,xF as bt,qK as c,by as ca,sT as ci,$j as cn,Pm as co,qO as cr,Fs as cs,yW as ct,WK as d,_y as da,_w as di,Vj as dn,km as do,PO as dr,ks as ds,hW as dt,Sb as ea,Ba as ec,eT as ei,rM as en,Sh as eo,QO as er,sl as es,gG as et,HK as f,hy as fa,yw as fi,Bj as fn,Jm as fo,CO as fr,Ds as fs,mW as ft,TK as g,ev as ga,dw as gi,Uj as gn,cm as go,KO as gr,fs as gs,lW as gt,kK as h,J_ as ha,lw as hi,Kj as hn,om as ho,IO as hr,ms as hs,uW as ht,XK as i,hb as ia,oT as ii,lM as in,$m as io,MO as ir,Is as is,jW as it,QG as j,c_ as ja,oC as ji,vj as jn,Bf as jo,JE as jr,Ao as js,HN as jt,YG as k,r_ as ka,pC as ki,bj as kn,Hf as ko,sD as kr,Io as ks,GN as kt,GK as l,Ov as la,xw as li,oM as ln,Nm as lo,zO as lr,Ps as ls,_W as lt,IK as m,tv as ma,gw as mi,Gj as mn,am as mo,FO as mr,vs as ms,fW as mt,mq as n,wb as na,qa as nc,rT as ni,Qj as nn,ph as no,jO as nr,Vs as ns,pG as nt,QK as o,ky as oa,tT as oi,fM as on,Vm as oo,OO as or,Rs as os,DW as ot,VK as p,gy as pa,bw as pi,pM as pn,qm as po,wO as pr,Es as ps,pW as pt,CG as q,ng as qa,SS as qi,Nk as qn,Tu as qo,Hw as qr,io as qs,xM as qt,hq as r,gb as ra,aT as ri,cM as rn,eh as ro,JO as rr,Bs as rs,dG as rt,YK as s,mv as sa,cT as si,uM as sn,Am as so,AO as sr,Ns as ss,SW as st,fq as t,Cb as ta,Ka as tc,lT as ti,Hj as tn,hh as to,SO as tr,Hs as ts,vG as tt,KK as u,Dv as ua,vw as ui,sM as un,Km as uo,NO as ur,Ms as us,gW as ut,aK as v,C_ as va,pw as vi,Zj as vn,rm as vo,yO as vr,cs as vs,BF as vt,gK as w,__ as wa,uw as wi,Rj as wn,Xf as wo,wD as wr,Po as ws,EP as wt,uK as x,x_ as xa,iw as xi,Wj as xn,op as xo,YD as xr,ns as xs,_F as xt,iK as y,S_ as ya,mw as yi,Yj as yn,lm as yo,sO as yr,ss as ys,bF as yt,zG as z,Hg as za,ZS as zi,_A as zn,Sd as zo,WT as zr,_o as zs,sN as zt};
|
|
1533
|
+
//# sourceMappingURL=WorkerPoolContext-DE6P0yOd.js.map
|