@hyperpuncher/pi-ui 0.47.0 → 0.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -17
- package/dist/npm/server-main.js +1 -1
- package/package.json +1 -1
- package/static/build/chunks/{code-theme-h8xf95gx.js → code-theme-pvx0m83p.js} +1 -1
- package/static/build/chunks/{index-tj848246.js → index-vtmc6jvm.js} +1 -1
- package/static/build/chunks/{main-f40c0hm2.js → main-6b6epn84.js} +5 -5
- package/static/build/chunks/{main-hq8q8mc5.js → main-scnj6yst.js} +46 -46
- package/static/build/chunks/{workspace-review-pme5emmj.js → workspace-review-51kesnmm.js} +12 -12
- package/static/build/main.js +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as xI,Ca as id,Da as sS,Ea as ld,I as Tg,J as Bt,K as Dl,L as kg,M as Hl,N as nd,O as CS,P as Px,Q as Af,R as TI,S as $x,T as Mx,U as Ox,V as Fx,W as zo,X as Ko,Y as Vo,Z as Wo,_ as Oe,aa as pI,ba as hI,ca as jx,da as qx,ea as zu,fa as ZI,ga as bu,ha as rs,ia as ES,ja as vS,ka as QI,la as Xo,ma as rd,na as Go,oa as di,pa as ia,qa as tt,ta as dn,wa as Ji,xa as Fu,za as Xu}from"./main-f40c0hm2.js";import{qc as Ut,rc as g}from"./main-kt1z40p6.js";function Fl(e){return e!==null&&typeof e==="object"&&"default"in e?e.default:e}var pg=class extends Error{constructor(e){super(`Theme "${e}" is already registered`);this.name="DuplicateThemeError"}},hg=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`);this.name="UnregisteredThemeError"}},gg=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`);this.name="UnresolvedThemeError"}};function vm(){let e=new Map,t=new Map,n=new Map,r=0;function i(S,b){if(e.has(S))throw new pg(S);e.set(S,b)}function o(S,b){if(e.has(S))return!1;return e.set(S,b),!0}function s(S){return e.has(S)}function a(S){let b=t.get(S);if(b!==void 0)return Promise.resolve(b);let E=n.get(S);if(E!==void 0)return E;let w=e.get(S);if(w===void 0)return Promise.reject(new hg(S));let k=r,L=w().then((R)=>{let A=Fl(R);if(k===r)t.set(S,A);if(n.get(S)===L)n.delete(S);return A}).catch((R)=>{if(n.get(S)===L)n.delete(S);throw R});return n.set(S,L),L}function l(S){return Promise.all(S.map((b)=>a(b)))}function d(S,b){t.set(S,b)}function c(S){for(let[b,E]of S)d(b,E)}function m(S){return t.get(S)}function p(S){let b=[];for(let E of S){let w=t.get(E);if(w===void 0)throw new gg(E);b.push(w)}return b}function h(S){return t.has(S)}function x(S){for(let b of S)if(!t.has(b))return!1;return!0}function I(S){let b=t.get(S);if(b!==void 0)return b;return a(S)}function v(){r++,t.clear(),n.clear()}return{clearResolvedThemes:v,getResolvedOrResolveTheme:I,getResolvedTheme:m,getResolvedThemes:p,hasRegisteredTheme:s,hasResolvedTheme:h,hasResolvedThemes:x,registerTheme:i,registerThemeIfAbsent:o,resolveTheme:a,resolveThemes:l,seedResolvedTheme:d,seedResolvedThemes:c}}var Zt=vm();function Nl(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}function Qr(e){let t=[],n=new Set;for(let m of rP(e.themes)){let p=yg(m)?m.getThemes():[m];for(let h of p){if(n.has(h.name))throw Error(`Theme collection already contains theme "${h.name}"`);n.add(h.name),t.push(h)}}let r=Object.freeze([...t]),i=Object.freeze(r.filter((m)=>m.colorScheme==="light")),o=Object.freeze(r.filter((m)=>m.colorScheme==="dark")),s=new Map(r.map((m)=>[m.name,m])),a=Object.freeze(r.map((m)=>m.name)),l=Object.freeze(i.map((m)=>m.name)),d=Object.freeze(o.map((m)=>m.name));function c(m){if(m==null)return r;let{colorScheme:p,collection:h}=m;if(h==null){if(p==="light")return i;if(p==="dark")return o;return r}return r.filter((x)=>{if(x.collection!==h)return!1;return p==null||x.colorScheme===p})}return{getTheme(m){return s.get(m)},getThemes(m){return c(m)},getThemeNames(m){if(m?.collection==null){if(m?.colorScheme==="light")return l;if(m?.colorScheme==="dark")return d;return a}return c(m).map((p)=>p.name)},hasTheme(m){return s.has(m)},orderBy(m){return Qr({themes:r.map((p,h)=>({descriptor:p,index:h})).sort((p,h)=>{let x=m(p.descriptor,h.descriptor);if(x!==0)return x;return p.index-h.index}).map((p)=>p.descriptor)})},pick(m){let p=[],h=new Set;for(let x of m){if(h.has(x))throw Error(`Theme collection pick already includes theme "${x}"`);h.add(x);let I=s.get(x);if(I==null)throw Error(`Theme collection does not contain theme "${x}"`);p.push(I)}return Qr({themes:p})},registerInto(m){for(let p of r)m.registerThemeIfAbsent(p.name,p.load)}}}function rP(e){if(iP(e))return[e];return e}function iP(e){return yg(e)||oP(e)}function oP(e){return typeof e.name==="string"&&typeof e.load==="function"}function yg(e){return typeof e.getThemes==="function"}var{defineProperty:Tm,getOwnPropertyDescriptor:sP,getOwnPropertyNames:aP}=Object,lP=Object.prototype.hasOwnProperty,Ig=(e,t)=>{let n={};for(var r in e)Tm(n,r,{get:e[r],enumerable:!0});if(!t)Tm(n,Symbol.toStringTag,{value:"Module"});return n},xg=(e,t,n,r)=>{if(t&&typeof t==="object"||typeof t==="function"){for(var i=aP(t),o=0,s=i.length,a;o<s;o++)if(a=i[o],!lP.call(e,a)&&a!==n)Tm(e,a,{get:((l)=>t[l]).bind(null,a),enumerable:!(r=sP(t,a))||r.enumerable})}return e},Sg=(e,t,n)=>(xg(e,t,"default"),n&&xg(n,t,"default"));var we=class extends Error{constructor(e){super(e);this.name="ShikiError"}};function Us(e,t){let n=typeof e==="string"?{}:{...e.colorReplacements},r=typeof e==="string"?e:e.name;for(let[i,o]of Object.entries(t?.colorReplacements||{}))if(typeof o==="string")n[i]=o;else if(i===r)Object.assign(n,o);return n}function Lr(e,t){if(!e)return e;return t?.[e?.toLowerCase()]||e}function wg(e){return Array.isArray(e)?e:[e]}async function km(e){return Promise.resolve(typeof e==="function"?e():e).then((t)=>t.default||t)}function Bs(e){return!e||["plaintext","txt","text","plain"].includes(e)}function wm(e){return e==="ansi"||Bs(e)}function Gs(e){return e==="none"}function Lm(e){return Gs(e)}var uP=/(\r?\n)/g;function Lo(e,t=!1){if(e.length===0)return[["",0]];let n=e.split(uP),r=0,i=[];for(let o=0;o<n.length;o+=2){let s=t?n[o]+(n[o+1]||""):n[o];i.push([s,r]),r+=n[o].length,r+=n[o+1]?.length||0}return i}var bg={light:"#333333",dark:"#bbbbbb"},Cg={light:"#fffffe",dark:"#1e1e1e"},Eg="__shiki_resolved";function Ro(e){if(e?.[Eg])return e;let t={...e};if(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 a=t.settings?t.settings.find((l)=>!l.name&&!l.scope):void 0;if(a?.settings?.foreground)r=a.settings.foreground;if(a?.settings?.background)n=a.settings.background;if(!r&&t?.colors?.["editor.foreground"])r=t.colors["editor.foreground"];if(!n&&t?.colors?.["editor.background"])n=t.colors["editor.background"];if(!r)r=t.type==="light"?bg.light:bg.dark;if(!n)n=t.type==="light"?Cg.light:Cg.dark;t.fg=r,t.bg=n}if(!(t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope))t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,o=new Map;function s(a){if(o.has(a))return o.get(a);i+=1;let l=`#${i.toString(16).padStart(8,"0").toLowerCase()}`;if(t.colorReplacements?.[`#${l}`])return s(a);return o.set(a,l),l}t.settings=t.settings.map((a)=>{let l=a.settings?.foreground&&!a.settings.foreground.startsWith("#"),d=a.settings?.background&&!a.settings.background.startsWith("#");if(!l&&!d)return a;let c={...a,settings:{...a.settings}};if(l){let m=s(a.settings.foreground);t.colorReplacements[m]=a.settings.foreground,c.settings.foreground=m}if(d){let m=s(a.settings.background);t.colorReplacements[m]=a.settings.background,c.settings.background=m}return c});for(let a of Object.keys(t.colors||{}))if(a==="editor.foreground"||a==="editor.background"||a.startsWith("terminal.ansi")){if(!t.colors[a]?.startsWith("#")){let l=s(t.colors[a]);t.colorReplacements[l]=t.colors[a],t.colors[a]=l}}return Object.defineProperty(t,Eg,{enumerable:!1,writable:!1,value:!0}),t}async function Lg(e){return[...new Set((await Promise.all(e.filter((t)=>!wm(t)).map(async(t)=>await km(t).then((n)=>Array.isArray(n)?n:[n])))).flat())]}async function Rg(e){return(await Promise.all(e.map(async(t)=>Lm(t)?null:Ro(await km(t))))).filter((t)=>!!t)}function Ag(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);while(t[e]){if(e=t[e],n.has(e))throw new we(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var dP=class extends kg{_resolver;_themes;_langs;_alias;_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((i)=>this.loadTheme(i)),this.loadLanguages(this._langs)}getTheme(e){if(typeof e==="string")return this._resolvedThemes.get(e);else return this.loadTheme(e)}loadTheme(e){let t=Ro(e);if(t.name)this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null;return t}getLoadedThemes(){if(!this._loadedThemesCache)this._loadedThemesCache=[...this._resolvedThemes.keys()];return this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);if(!t)t=Tg.createFromRawTheme(e),this._textmateThemeCache.set(e,t);this._syncRegistry.setTheme(t)}getGrammar(e){return e=Ag(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter((i)=>i.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((i)=>{this._alias[i]=e.name});if(this._loadedLanguagesCache=null,t.size)for(let i of t)this._resolvedGrammars.delete(i.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(i.scopeName),this._syncRegistry?._grammars?.delete(i.scopeName),this.loadLanguage(this._langMap.get(i.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let r of e)this.resolveEmbeddedLanguages(r);let t=[...this._langGraph.entries()],n=t.filter(([r,i])=>!i);if(n.length){let r=t.filter(([i,o])=>{if(!o)return!1;return(o.embeddedLanguages||o.embeddedLangs)?.some((s)=>n.map(([a])=>a).includes(s))}).filter((i)=>!n.includes(i));throw new we(`Missing languages ${n.map(([i])=>`\`${i}\``).join(", ")}, required by ${r.map(([i])=>`\`${i}\``).join(", ")}`)}for(let[r,i]of t)this._resolver.addLanguage(i);for(let[r,i]of t)this.loadLanguage(i)}getLoadedLanguages(){if(!this._loadedLanguagesCache)this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])];return 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 n of t)this._langGraph.set(n,this._langMap.get(n))}},cP=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:(n)=>e.createScanner(n),createOnigString:(n)=>e.createString(n)},t.forEach((n)=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){if(this._langs.set(e.name,e),e.aliases)e.aliases.forEach((t)=>{this._langs.set(t,e)});if(this._scopeToLang.set(e.scopeName,e),e.injectTo)e.injectTo.forEach((t)=>{if(!this._injections.get(t))this._injections.set(t,[]);this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split("."),n=[];for(let r=1;r<=t.length;r++){let i=t.slice(0,r).join(".");n=[...n,...this._injections.get(i)||[]]}return n}},_s=0;function Rm(e){if(_s+=1,e.warnings!==!1&&_s>=10&&_s%10===0)console.warn(`[Shiki] ${_s} 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 we("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Ro),i=new dP(new cP(e.engine,n),r,n,e.langAlias),o;function s(b){return Ag(b,e.langAlias)}function a(b){v();let E=i.getGrammar(typeof b==="string"?b:b.name);if(!E)throw new we(`Language \`${b}\` not found, you may need to load it first`);return E}function l(b){if(b==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};v();let E=i.getTheme(b);if(!E)throw new we(`Theme \`${b}\` not found, you may need to load it first`);return E}function d(b){v();let E=l(b);if(o!==b)i.setTheme(E),o=b;return{theme:E,colorMap:i.getColorMap()}}function c(){return v(),i.getLoadedThemes()}function m(){return v(),i.getLoadedLanguages()}function p(...b){v(),i.loadLanguages(b.flat(1))}async function h(...b){return p(await Lg(b))}function x(...b){v();for(let E of b.flat(1))i.loadTheme(E)}async function I(...b){return v(),x(await Rg(b))}function v(){if(t)throw new we("Shiki instance has been disposed")}function S(){if(t)return;t=!0,i.dispose(),_s-=1}return{setTheme:d,getTheme:l,getLanguage:a,getLoadedThemes:c,getLoadedLanguages:m,resolveLangAlias:s,loadLanguage:h,loadLanguageSync:p,loadTheme:I,loadThemeSync:x,dispose:S,[Symbol.dispose]:S}}async function Am(e){if(!e.engine)console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([Rg(e.themes||[]),Lg(e.langs||[]),e.engine]);return Rm({...e,themes:t,langs:n,engine:r})}var Pg=new WeakMap;function js(e,t){Pg.set(e,t)}function Ao(e){return Pg.get(e)}var _l=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(wg(n).map((r)=>[r,Hl])),t)}constructor(...t){if(t.length===2){let[n,r]=t;this.lang=r,this._stacks=n}else{let[n,r,i]=t;this.lang=r,this._stacks={[i]:n}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return mP(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function mP(e){let t=[],n=new Set;function r(i){if(n.has(i))return;n.add(i);let o=i?.nameScopesList?.scopeName;if(o)t.push(o);if(i.parent)r(i.parent)}return r(e),t}function fP(e,t){if(!(e instanceof _l))throw new we("Invalid grammar state");return e.getInternalStack(t)}var pP=/,/,hP=/ /;function Pm(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(Bs(e.resolveLangAlias(n.lang||"text"))||Gs(r))return Lo(t).map((a)=>[{content:a[0],offset:a[1]}]);let{theme:i,colorMap:o}=e.setTheme(r),s=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==s.name)throw new we(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${s.name}"`);if(!n.grammarState.themes.includes(i.name))throw new we(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return Mg(t,s,i,o,n)}function $g(...e){if(e.length===2)return Ao(e[1]);let[t,n,r={}]=e,{lang:i="text",theme:o=t.getLoadedThemes()[0]}=r;if(Bs(i)||Gs(o))throw new we("Plain language does not have grammar state");if(i==="ansi")throw new we("ANSI language does not have grammar state");let{theme:s,colorMap:a}=t.setTheme(o),l=t.getLanguage(i);return new _l($m(n,l,s,a,r).stateStack,l.name,s.name)}function Mg(e,t,n,r,i){let o=$m(e,t,n,r,i),s=new _l(o.stateStack,t.name,n.name);return js(o.tokens,s),o.tokens}function $m(e,t,n,r,i){let o=Us(n,i),{tokenizeMaxLineLength:s=0,tokenizeTimeLimit:a=500,includeExplanation:l=!1}=i,d=Lo(e),c=i.grammarState?fP(i.grammarState,n.name)??Hl:i.grammarContextCode!=null?$m(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack:Hl,m=[],p=[];for(let h=0,x=d.length;h<x;h++){let[I,v]=d[h];if(I===""){m=[],p.push([]);continue}if(s>0&&I.length>=s){m=[],p.push([{content:I,offset:v,color:"",fontStyle:0}]);continue}let S,b,E;if(l&&l!=="tokenType")S=t.tokenizeLine(I,c,a),b=S.tokens,E=0;let w=t.tokenizeLine2(I,c,a),k=w.tokens.length/2;for(let L=0;L<k;L++){let R=w.tokens[2*L],A=L+1<k?w.tokens[2*L+2]:I.length;if(R===A)continue;let O=w.tokens[2*L+1],D=Lr(r[Dl.getForeground(O)],o),X=Dl.getFontStyle(O),N={content:I.substring(R,A),offset:v+R,color:D,fontStyle:X};if(l==="tokenType")N.type=Dl.getTokenType(O);else if(l){let B=[];if(l!=="scopeName")for(let ye of n.settings){let j;switch(typeof ye.scope){case"string":j=ye.scope.split(pP).map((ie)=>ie.trim());break;case"object":j=ye.scope;break;default:continue}B.push({settings:ye,selectors:j.map((ie)=>ie.split(hP))})}N.explanation=[];let pe=0;while(R+pe<A){let ye=b[E],j=I.substring(ye.startIndex,ye.endIndex);pe+=j.length,N.explanation.push({content:j,scopes:l==="scopeName"?gP(ye.scopes):yP(B,ye.scopes)}),E+=1}}m.push(N)}p.push(m),m=[],c=w.ruleStack}return{tokens:p,stateStack:c}}function gP(e){return e.map((t)=>({scopeName:t}))}function yP(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let o=t[r];n[r]={scopeName:o,themeMatches:IP(e,o,t.slice(0,r))}}return n}function vg(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function xP(e,t,n){if(!vg(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;while(r>=0&&i>=0){if(vg(e[r],n[i]))r-=1;i-=1}if(r===-1)return!0;return!1}function IP(e,t,n){let r=[];for(let{selectors:i,settings:o}of e)for(let s of i)if(xP(s,t,n)){r.push(o);break}return r}function Ul(e,t,n,r=Pm){let i=Object.entries(n.themes).filter((d)=>d[1]).map((d)=>({color:d[0],theme:d[1]})),o=i.map((d,c)=>{let m=r(e,t,{...n,includeExplanation:c===0||n.includeExplanation==="tokenType"?n.includeExplanation:!1,theme:d.theme});return{tokens:m,state:Ao(m),theme:typeof d.theme==="string"?d.theme:d.theme.name}}),s=SP(...o.map((d)=>d.tokens)),a=s[0].map((d,c)=>d.map((m,p)=>{let h={content:m.content,variants:{},offset:m.offset};if("includeExplanation"in n&&n.includeExplanation)h.explanation=m.explanation;return s.forEach((x,I)=>{let{content:v,explanation:S,offset:b,...E}=x[c][p];h.variants[i[I].color]=E}),h})),l=o[0].state?new _l(Object.fromEntries(o.map((d)=>[d.theme,d.state?.getInternalStack(d.theme)])),o[0].state.lang):void 0;if(l)js(a,l);return a}function SP(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map((l)=>l[r]),o=t.map(()=>[]);t.forEach((l,d)=>l.push(o[d]));let s=i.map(()=>0),a=i.map((l)=>l[0]);while(a.every((l)=>l)){let l=Math.min(...a.map((d)=>d.content.length));for(let d=0;d<n;d++){let c=a[d];if(c.content.length===l)o[d].push(c),s[d]+=1,a[d]=i[d][s[d]];else o[d].push({...c,content:c.content.slice(0,l)}),a[d]={...c,content:c.content.slice(l),offset:c.offset+l}}}}return t}var Og=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class ei{constructor(e,t,n){if(this.normal=t,this.property=e,n)this.space=n}}ei.prototype.normal={};ei.prototype.property={};ei.prototype.space=void 0;function Mm(e,t){let n={},r={};for(let i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new ei(n,r,t)}function qs(e){return e.toLowerCase()}class Ot{constructor(e,t){this.attribute=t,this.property=e}}Ot.prototype.attribute="";Ot.prototype.booleanish=!1;Ot.prototype.boolean=!1;Ot.prototype.commaOrSpaceSeparated=!1;Ot.prototype.commaSeparated=!1;Ot.prototype.defined=!1;Ot.prototype.mustUseProperty=!1;Ot.prototype.number=!1;Ot.prototype.overloadedBoolean=!1;Ot.prototype.property="";Ot.prototype.spaceSeparated=!1;Ot.prototype.space=void 0;var zs={};Ut(zs,{boolean:()=>Q,booleanish:()=>lt,commaOrSpaceSeparated:()=>an,commaSeparated:()=>Rr,number:()=>P,overloadedBoolean:()=>Bl,spaceSeparated:()=>Te});var bP=0,Q=Ui(),lt=Ui(),Bl=Ui(),P=Ui(),Te=Ui(),Rr=Ui(),an=Ui();function Ui(){return 2**++bP}var Om=Object.keys(zs);class Po extends Ot{constructor(e,t,n,r){let i=-1;super(e,t);if(Fg(this,"space",r),typeof n==="number")while(++i<Om.length){let o=Om[i];Fg(this,Om[i],(n&zs[o])===zs[o])}}}Po.prototype.defined=!0;function Fg(e,t,n){if(n)e[t]=n}function $n(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let o=new Po(r,e.transform(e.attributes||{},r),i,e.space);if(e.mustUseProperty&&e.mustUseProperty.includes(r))o.mustUseProperty=!0;t[r]=o,n[qs(r)]=r,n[qs(o.attribute)]=r}return new ei(t,n,e.space)}var Fm=$n({properties:{ariaActiveDescendant:null,ariaAtomic:lt,ariaAutoComplete:null,ariaBusy:lt,ariaChecked:lt,ariaColCount:P,ariaColIndex:P,ariaColSpan:P,ariaControls:Te,ariaCurrent:null,ariaDescribedBy:Te,ariaDetails:null,ariaDisabled:lt,ariaDropEffect:Te,ariaErrorMessage:null,ariaExpanded:lt,ariaFlowTo:Te,ariaGrabbed:lt,ariaHasPopup:null,ariaHidden:lt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Te,ariaLevel:P,ariaLive:null,ariaModal:lt,ariaMultiLine:lt,ariaMultiSelectable:lt,ariaOrientation:null,ariaOwns:Te,ariaPlaceholder:null,ariaPosInSet:P,ariaPressed:lt,ariaReadOnly:lt,ariaRelevant:null,ariaRequired:lt,ariaRoleDescription:Te,ariaRowCount:P,ariaRowIndex:P,ariaRowSpan:P,ariaSelected:lt,ariaSetSize:P,ariaSort:null,ariaValueMax:P,ariaValueMin:P,ariaValueNow:P,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Gl(e,t){return t in e?e[t]:t}function jl(e,t){return Gl(e,t.toLowerCase())}var Ng=$n({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Rr,acceptCharset:Te,accessKey:Te,action:null,allow:null,allowFullScreen:Q,allowPaymentRequest:Q,allowUserMedia:Q,alpha:Q,alt:null,as:null,async:Q,autoCapitalize:null,autoComplete:Te,autoFocus:Q,autoPlay:Q,blocking:Te,capture:null,charSet:null,checked:Q,cite:null,className:Te,closedBy:null,colorSpace:null,cols:P,colSpan:P,command:null,commandFor:null,content:null,contentEditable:lt,controls:Q,controlsList:Te,coords:P|Rr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Q,defer:Q,dir:null,dirName:null,disabled:Q,download:Bl,draggable:lt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Q,formTarget:null,headers:Te,height:P,hidden:Bl,high:P,href:null,hrefLang:null,htmlFor:Te,httpEquiv:Te,id:null,imageSizes:null,imageSrcSet:null,inert:Q,inputMode:null,integrity:null,is:null,isMap:Q,itemId:null,itemProp:Te,itemRef:Te,itemScope:Q,itemType:Te,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Q,low:P,manifest:null,max:null,maxLength:P,media:null,method:null,min:null,minLength:P,multiple:Q,muted:Q,name:null,nonce:null,noModule:Q,noValidate:Q,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:Q,optimum:P,pattern:null,ping:Te,placeholder:null,playsInline:Q,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Q,referrerPolicy:null,rel:Te,required:Q,reversed:Q,rows:P,rowSpan:P,sandbox:Te,scope:null,scoped:Q,seamless:Q,selected:Q,shadowRootClonable:Q,shadowRootCustomElementRegistry:Q,shadowRootDelegatesFocus:Q,shadowRootMode:null,shadowRootSerializable:Q,shape:null,size:P,sizes:null,slot:null,span:P,spellCheck:lt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:P,step:null,style:null,tabIndex:P,target:null,title:null,translate:null,type:null,typeMustMatch:Q,useMap:null,value:lt,width:P,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Te,axis:null,background:null,bgColor:null,border:P,borderColor:null,bottomMargin:P,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Q,declare:Q,event:null,face:null,frame:null,frameBorder:null,hSpace:P,leftMargin:P,link:null,longDesc:null,lowSrc:null,marginHeight:P,marginWidth:P,noResize:Q,noHref:Q,noShade:Q,noWrap:Q,object:null,profile:null,prompt:null,rev:null,rightMargin:P,rules:null,scheme:null,scrolling:lt,standby:null,summary:null,text:null,topMargin:P,valueType:null,version:null,vAlign:null,vLink:null,vSpace:P,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Q,disablePictureInPicture:Q,disableRemotePlayback:Q,exportParts:Rr,part:Te,prefix:null,property:null,results:P,security:null,unselectable:null},space:"html",transform:jl});var Dg=$n({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:an,accentHeight:P,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:P,amplitude:P,arabicForm:null,ascent:P,attributeName:null,attributeType:null,azimuth:P,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:P,by:null,calcMode:null,capHeight:P,className:Te,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:P,diffuseConstant:P,direction:null,display:null,dur:null,divisor:P,dominantBaseline:null,download:Q,dx:null,dy:null,edgeMode:null,editable:null,elevation:P,enableBackground:null,end:null,event:null,exponent:P,externalResourcesRequired:null,fill:null,fillOpacity:P,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:Rr,g2:Rr,glyphName:Rr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:P,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:P,horizOriginX:P,horizOriginY:P,id:null,ideographic:P,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:P,k:P,k1:P,k2:P,k3:P,k4:P,kernelMatrix:an,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:P,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:P,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:P,overlineThickness:P,paintOrder:null,panose1:null,path:null,pathLength:P,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Te,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:P,pointsAtY:P,pointsAtZ:P,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:an,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:an,rev:an,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:an,requiredFeatures:an,requiredFonts:an,requiredFormats:an,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:P,specularExponent:P,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:P,strikethroughThickness:P,string:null,stroke:null,strokeDashArray:an,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:P,strokeOpacity:P,strokeWidth:null,style:null,surfaceScale:P,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:an,tabIndex:P,tableValues:null,target:null,targetX:P,targetY:P,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:an,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:P,underlineThickness:P,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:P,values:null,vAlphabetic:P,vMathematical:P,vectorEffect:null,vHanging:P,vIdeographic:P,version:null,vertAdvY:P,vertOriginX:P,vertOriginY:P,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:P,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Gl});var Nm=$n({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()}});var Dm=$n({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:jl});var Hm=$n({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var CP=/[A-Z]/g,Hg=/-[a-z]/g,EP=/^data[-\w.:]+$/i;function _m(e,t){let n=qs(t),r=t,i=Ot;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&EP.test(t)){if(t.charAt(4)==="-"){let o=t.slice(5).replace(Hg,TP);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{let o=t.slice(4);if(!Hg.test(o)){let s=o.replace(CP,vP);if(s.charAt(0)!=="-")s="-"+s;t="data"+s}}i=Po}return new i(r,t)}function vP(e){return"-"+e.toLowerCase()}function TP(e){return e.charAt(1).toUpperCase()}var _g=Mm([Fm,Ng,Nm,Dm,Hm],"html"),ql=Mm([Fm,Dg,Nm,Dm,Hm],"svg");var Ug={}.hasOwnProperty;function Bg(e,t){let n=t||{};function r(i,...o){let{invalid:s,handlers:a}=r;if(i&&Ug.call(i,e)){let l=String(i[e]);s=Ug.call(a,l)?a[l]:r.unknown}if(s)return s.call(this,i,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var kP=/["&'<>`]/g,wP=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,LP=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,RP=/[|\\{}()[\]^$+*?.]/g,Gg=new WeakMap;function jg(e,t){if(e=e.replace(t.subset?AP(t.subset):kP,r),t.subset||t.escapeOnly)return e;return e.replace(wP,n).replace(LP,r);function n(i,o,s){return t.format((i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)-56320+65536,s.charCodeAt(o+2),t)}function r(i,o,s){return t.format(i.charCodeAt(0),s.charCodeAt(o+1),t)}}function AP(e){let t=Gg.get(e);if(!t)t=PP(e),Gg.set(e,t);return t}function PP(e){let t=[],n=-1;while(++n<e.length)t.push(e[n].replace(RP,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}var $P=/[\dA-Fa-f]/;function qg(e,t,n){let r="&#x"+e.toString(16).toUpperCase();return n&&t&&!$P.test(String.fromCharCode(t))?r:r+";"}var MP=/\d/;function zg(e,t,n){let r="&#"+String(e);return n&&t&&!MP.test(String.fromCharCode(t))?r:r+";"}var Kg=["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"];var zl={nbsp:" ",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:"€"};var Vg=["cent","copy","divide","gt","lt","not","para","times"];var Wg={}.hasOwnProperty,Um={},Kl;for(Kl in zl)if(Wg.call(zl,Kl))Um[zl[Kl]]=Kl;var OP=/[^\dA-Za-z]/;function Xg(e,t,n,r){let i=String.fromCharCode(e);if(Wg.call(Um,i)){let o=Um[i],s="&"+o;if(n&&Kg.includes(o)&&!Vg.includes(o)&&(!r||t&&t!==61&&OP.test(String.fromCharCode(t))))return s;return s+";"}return""}function Yg(e,t,n){let r=qg(e,t,n.omitOptionalSemicolons),i;if(n.useNamedReferences||n.useShortestReferences)i=Xg(e,t,n.omitOptionalSemicolons,n.attribute);if((n.useShortestReferences||!i)&&n.useShortestReferences){let o=zg(e,t,n.omitOptionalSemicolons);if(o.length<r.length)r=o}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function Ar(e,t){return jg(e,Object.assign({format:Yg},t))}var FP=/^>|^->|<!--|-->|--!>|<!-$/g,NP=[">"],DP=["<",">"];function Jg(e,t,n,r){return r.settings.bogusComments?"<?"+Ar(e.value,Object.assign({},r.settings.characterReferences,{subset:NP}))+">":"<!--"+e.value.replace(FP,i)+"-->";function i(o){return Ar(o,Object.assign({},r.settings.characterReferences,{subset:DP}))}}function Zg(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function Bm(e,t){let n=String(e);if(typeof t!=="string")throw TypeError("Expected character");let r=0,i=n.indexOf(t);while(i!==-1)r++,i=n.indexOf(t,i+t.length);return r}function Qg(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function ey(e){return e.join(" ").trim()}var HP=/[ \t\n\f\r]/g;function Bi(e){return typeof e==="object"?e.type==="text"?ty(e.value):!1:ty(e)}function ty(e){return e.replace(HP,"")===""}var mt=ny(1),Gm=ny(-1),_P=[];function ny(e){return t;function t(n,r,i){let o=n?n.children:_P,s=(r||0)+e,a=o[s];if(!i)while(a&&Bi(a))s+=e,a=o[s];return a}}var UP={}.hasOwnProperty;function Vl(e){return t;function t(n,r,i){return UP.call(e,n.tagName)&&e[n.tagName](n,r,i)}}var Ks=Vl({body:GP,caption:jm,colgroup:jm,dd:KP,dt:zP,head:jm,html:BP,li:qP,optgroup:VP,option:WP,p:jP,rp:ry,rt:ry,tbody:YP,td:iy,tfoot:JP,th:iy,thead:XP,tr:ZP});function jm(e,t,n){let r=mt(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&Bi(r.value.charAt(0)))}function BP(e,t,n){let r=mt(n,t);return!r||r.type!=="comment"}function GP(e,t,n){let r=mt(n,t);return!r||r.type!=="comment"}function jP(e,t,n){let r=mt(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 qP(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&r.tagName==="li"}function zP(e,t,n){let r=mt(n,t);return Boolean(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function KP(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function ry(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function VP(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function WP(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function XP(e,t,n){let r=mt(n,t);return Boolean(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function YP(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function JP(e,t,n){return!mt(n,t)}function ZP(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function iy(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}var oy=Vl({body:t$,colgroup:n$,head:e$,html:QP,tbody:r$});function QP(e){let t=mt(e,-1);return!t||t.type!=="comment"}function e$(e){let t=new Set;for(let r of e.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(t.has(r.tagName))return!1;t.add(r.tagName)}let n=e.children[0];return!n||n.type==="element"}function t$(e){let t=mt(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Bi(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function n$(e,t,n){let r=Gm(n,t),i=mt(e,-1,!0);if(n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Ks(r,n.children.indexOf(r),n))return!1;return Boolean(i&&i.type==="element"&&i.tagName==="col")}function r$(e,t,n){let r=Gm(n,t),i=mt(e,-1);if(n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Ks(r,n.children.indexOf(r),n))return!1;return Boolean(i&&i.type==="element"&&i.tagName==="tr")}var Wl={name:[[`
|
|
1
|
+
import{$ as bI,Ca as od,Da as uS,Ea as ud,I as Tg,J as Gt,K as Hl,L as wg,M as _l,N as rd,O as kS,P as Fx,Q as Af,R as LI,S as Nx,T as Dx,U as Hx,V as _x,W as Wo,X as Xo,Y as Yo,Z as Jo,_ as Oe,aa as xI,ba as II,ca as Vx,da as Wx,ea as Ku,fa as tS,ga as Cu,ha as ss,ia as TS,ja as wS,ka as nS,la as Zo,ma as id,na as zo,oa as di,pa as oa,qa as tt,ta as dn,wa as Ji,xa as Nu,za as Yu}from"./main-6b6epn84.js";import{qc as Bt,rc as g}from"./main-kt1z40p6.js";function Nl(e){return e!==null&&typeof e==="object"&&"default"in e?e.default:e}var hg=class extends Error{constructor(e){super(`Theme "${e}" is already registered`);this.name="DuplicateThemeError"}},gg=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`);this.name="UnregisteredThemeError"}},yg=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`);this.name="UnresolvedThemeError"}};function km(){let e=new Map,t=new Map,n=new Map,r=0;function i(S,b){if(e.has(S))throw new hg(S);e.set(S,b)}function o(S,b){if(e.has(S))return!1;return e.set(S,b),!0}function s(S){return e.has(S)}function a(S){let b=t.get(S);if(b!==void 0)return Promise.resolve(b);let E=n.get(S);if(E!==void 0)return E;let w=e.get(S);if(w===void 0)return Promise.reject(new gg(S));let T=r,L=w().then((R)=>{let A=Nl(R);if(T===r)t.set(S,A);if(n.get(S)===L)n.delete(S);return A}).catch((R)=>{if(n.get(S)===L)n.delete(S);throw R});return n.set(S,L),L}function l(S){return Promise.all(S.map((b)=>a(b)))}function d(S,b){t.set(S,b)}function c(S){for(let[b,E]of S)d(b,E)}function m(S){return t.get(S)}function p(S){let b=[];for(let E of S){let w=t.get(E);if(w===void 0)throw new yg(E);b.push(w)}return b}function h(S){return t.has(S)}function x(S){for(let b of S)if(!t.has(b))return!1;return!0}function I(S){let b=t.get(S);if(b!==void 0)return b;return a(S)}function v(){r++,t.clear(),n.clear()}return{clearResolvedThemes:v,getResolvedOrResolveTheme:I,getResolvedTheme:m,getResolvedThemes:p,hasRegisteredTheme:s,hasResolvedTheme:h,hasResolvedThemes:x,registerTheme:i,registerThemeIfAbsent:o,resolveTheme:a,resolveThemes:l,seedResolvedTheme:d,seedResolvedThemes:c}}var Ut=km();function Dl(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}function ei(e){let t=[],n=new Set;for(let m of sP(e.themes)){let p=xg(m)?m.getThemes():[m];for(let h of p){if(n.has(h.name))throw Error(`Theme collection already contains theme "${h.name}"`);n.add(h.name),t.push(h)}}let r=Object.freeze([...t]),i=Object.freeze(r.filter((m)=>m.colorScheme==="light")),o=Object.freeze(r.filter((m)=>m.colorScheme==="dark")),s=new Map(r.map((m)=>[m.name,m])),a=Object.freeze(r.map((m)=>m.name)),l=Object.freeze(i.map((m)=>m.name)),d=Object.freeze(o.map((m)=>m.name));function c(m){if(m==null)return r;let{colorScheme:p,collection:h}=m;if(h==null){if(p==="light")return i;if(p==="dark")return o;return r}return r.filter((x)=>{if(x.collection!==h)return!1;return p==null||x.colorScheme===p})}return{getTheme(m){return s.get(m)},getThemes(m){return c(m)},getThemeNames(m){if(m?.collection==null){if(m?.colorScheme==="light")return l;if(m?.colorScheme==="dark")return d;return a}return c(m).map((p)=>p.name)},hasTheme(m){return s.has(m)},orderBy(m){return ei({themes:r.map((p,h)=>({descriptor:p,index:h})).sort((p,h)=>{let x=m(p.descriptor,h.descriptor);if(x!==0)return x;return p.index-h.index}).map((p)=>p.descriptor)})},pick(m){let p=[],h=new Set;for(let x of m){if(h.has(x))throw Error(`Theme collection pick already includes theme "${x}"`);h.add(x);let I=s.get(x);if(I==null)throw Error(`Theme collection does not contain theme "${x}"`);p.push(I)}return ei({themes:p})},registerInto(m){for(let p of r)m.registerThemeIfAbsent(p.name,p.load)}}}function sP(e){if(aP(e))return[e];return e}function aP(e){return xg(e)||lP(e)}function lP(e){return typeof e.name==="string"&&typeof e.load==="function"}function xg(e){return typeof e.getThemes==="function"}var{defineProperty:Tm,getOwnPropertyDescriptor:uP,getOwnPropertyNames:dP}=Object,cP=Object.prototype.hasOwnProperty,Sg=(e,t)=>{let n={};for(var r in e)Tm(n,r,{get:e[r],enumerable:!0});if(!t)Tm(n,Symbol.toStringTag,{value:"Module"});return n},Ig=(e,t,n,r)=>{if(t&&typeof t==="object"||typeof t==="function"){for(var i=dP(t),o=0,s=i.length,a;o<s;o++)if(a=i[o],!cP.call(e,a)&&a!==n)Tm(e,a,{get:((l)=>t[l]).bind(null,a),enumerable:!(r=uP(t,a))||r.enumerable})}return e},bg=(e,t,n)=>(Ig(e,t,"default"),n&&Ig(n,t,"default"));var we=class extends Error{constructor(e){super(e);this.name="ShikiError"}};function js(e,t){let n=typeof e==="string"?{}:{...e.colorReplacements},r=typeof e==="string"?e:e.name;for(let[i,o]of Object.entries(t?.colorReplacements||{}))if(typeof o==="string")n[i]=o;else if(i===r)Object.assign(n,o);return n}function Lr(e,t){if(!e)return e;return t?.[e?.toLowerCase()]||e}function Lg(e){return Array.isArray(e)?e:[e]}async function wm(e){return Promise.resolve(typeof e==="function"?e():e).then((t)=>t.default||t)}function qs(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Lm(e){return e==="ansi"||qs(e)}function zs(e){return e==="none"}function Rm(e){return zs(e)}var mP=/(\r?\n)/g;function Lo(e,t=!1){if(e.length===0)return[["",0]];let n=e.split(mP),r=0,i=[];for(let o=0;o<n.length;o+=2){let s=t?n[o]+(n[o+1]||""):n[o];i.push([s,r]),r+=n[o].length,r+=n[o+1]?.length||0}return i}var Cg={light:"#333333",dark:"#bbbbbb"},Eg={light:"#fffffe",dark:"#1e1e1e"},vg="__shiki_resolved";function Ro(e){if(e?.[vg])return e;let t={...e};if(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 a=t.settings?t.settings.find((l)=>!l.name&&!l.scope):void 0;if(a?.settings?.foreground)r=a.settings.foreground;if(a?.settings?.background)n=a.settings.background;if(!r&&t?.colors?.["editor.foreground"])r=t.colors["editor.foreground"];if(!n&&t?.colors?.["editor.background"])n=t.colors["editor.background"];if(!r)r=t.type==="light"?Cg.light:Cg.dark;if(!n)n=t.type==="light"?Eg.light:Eg.dark;t.fg=r,t.bg=n}if(!(t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope))t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,o=new Map;function s(a){if(o.has(a))return o.get(a);i+=1;let l=`#${i.toString(16).padStart(8,"0").toLowerCase()}`;if(t.colorReplacements?.[`#${l}`])return s(a);return o.set(a,l),l}t.settings=t.settings.map((a)=>{let l=a.settings?.foreground&&!a.settings.foreground.startsWith("#"),d=a.settings?.background&&!a.settings.background.startsWith("#");if(!l&&!d)return a;let c={...a,settings:{...a.settings}};if(l){let m=s(a.settings.foreground);t.colorReplacements[m]=a.settings.foreground,c.settings.foreground=m}if(d){let m=s(a.settings.background);t.colorReplacements[m]=a.settings.background,c.settings.background=m}return c});for(let a of Object.keys(t.colors||{}))if(a==="editor.foreground"||a==="editor.background"||a.startsWith("terminal.ansi")){if(!t.colors[a]?.startsWith("#")){let l=s(t.colors[a]);t.colorReplacements[l]=t.colors[a],t.colors[a]=l}}return Object.defineProperty(t,vg,{enumerable:!1,writable:!1,value:!0}),t}async function Rg(e){return[...new Set((await Promise.all(e.filter((t)=>!Lm(t)).map(async(t)=>await wm(t).then((n)=>Array.isArray(n)?n:[n])))).flat())]}async function Ag(e){return(await Promise.all(e.map(async(t)=>Rm(t)?null:Ro(await wm(t))))).filter((t)=>!!t)}function Pg(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);while(t[e]){if(e=t[e],n.has(e))throw new we(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var fP=class extends wg{_resolver;_themes;_langs;_alias;_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((i)=>this.loadTheme(i)),this.loadLanguages(this._langs)}getTheme(e){if(typeof e==="string")return this._resolvedThemes.get(e);else return this.loadTheme(e)}loadTheme(e){let t=Ro(e);if(t.name)this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null;return t}getLoadedThemes(){if(!this._loadedThemesCache)this._loadedThemesCache=[...this._resolvedThemes.keys()];return this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);if(!t)t=Tg.createFromRawTheme(e),this._textmateThemeCache.set(e,t);this._syncRegistry.setTheme(t)}getGrammar(e){return e=Pg(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter((i)=>i.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((i)=>{this._alias[i]=e.name});if(this._loadedLanguagesCache=null,t.size)for(let i of t)this._resolvedGrammars.delete(i.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(i.scopeName),this._syncRegistry?._grammars?.delete(i.scopeName),this.loadLanguage(this._langMap.get(i.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let r of e)this.resolveEmbeddedLanguages(r);let t=[...this._langGraph.entries()],n=t.filter(([r,i])=>!i);if(n.length){let r=t.filter(([i,o])=>{if(!o)return!1;return(o.embeddedLanguages||o.embeddedLangs)?.some((s)=>n.map(([a])=>a).includes(s))}).filter((i)=>!n.includes(i));throw new we(`Missing languages ${n.map(([i])=>`\`${i}\``).join(", ")}, required by ${r.map(([i])=>`\`${i}\``).join(", ")}`)}for(let[r,i]of t)this._resolver.addLanguage(i);for(let[r,i]of t)this.loadLanguage(i)}getLoadedLanguages(){if(!this._loadedLanguagesCache)this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])];return 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 n of t)this._langGraph.set(n,this._langMap.get(n))}},pP=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:(n)=>e.createScanner(n),createOnigString:(n)=>e.createString(n)},t.forEach((n)=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){if(this._langs.set(e.name,e),e.aliases)e.aliases.forEach((t)=>{this._langs.set(t,e)});if(this._scopeToLang.set(e.scopeName,e),e.injectTo)e.injectTo.forEach((t)=>{if(!this._injections.get(t))this._injections.set(t,[]);this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split("."),n=[];for(let r=1;r<=t.length;r++){let i=t.slice(0,r).join(".");n=[...n,...this._injections.get(i)||[]]}return n}},Gs=0;function Am(e){if(Gs+=1,e.warnings!==!1&&Gs>=10&&Gs%10===0)console.warn(`[Shiki] ${Gs} 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 we("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Ro),i=new fP(new pP(e.engine,n),r,n,e.langAlias),o;function s(b){return Pg(b,e.langAlias)}function a(b){v();let E=i.getGrammar(typeof b==="string"?b:b.name);if(!E)throw new we(`Language \`${b}\` not found, you may need to load it first`);return E}function l(b){if(b==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};v();let E=i.getTheme(b);if(!E)throw new we(`Theme \`${b}\` not found, you may need to load it first`);return E}function d(b){v();let E=l(b);if(o!==b)i.setTheme(E),o=b;return{theme:E,colorMap:i.getColorMap()}}function c(){return v(),i.getLoadedThemes()}function m(){return v(),i.getLoadedLanguages()}function p(...b){v(),i.loadLanguages(b.flat(1))}async function h(...b){return p(await Rg(b))}function x(...b){v();for(let E of b.flat(1))i.loadTheme(E)}async function I(...b){return v(),x(await Ag(b))}function v(){if(t)throw new we("Shiki instance has been disposed")}function S(){if(t)return;t=!0,i.dispose(),Gs-=1}return{setTheme:d,getTheme:l,getLanguage:a,getLoadedThemes:c,getLoadedLanguages:m,resolveLangAlias:s,loadLanguage:h,loadLanguageSync:p,loadTheme:I,loadThemeSync:x,dispose:S,[Symbol.dispose]:S}}async function Pm(e){if(!e.engine)console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([Ag(e.themes||[]),Rg(e.langs||[]),e.engine]);return Am({...e,themes:t,langs:n,engine:r})}var $g=new WeakMap;function Ks(e,t){$g.set(e,t)}function Ao(e){return $g.get(e)}var Ul=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(Lg(n).map((r)=>[r,_l])),t)}constructor(...t){if(t.length===2){let[n,r]=t;this.lang=r,this._stacks=n}else{let[n,r,i]=t;this.lang=r,this._stacks={[i]:n}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return hP(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function hP(e){let t=[],n=new Set;function r(i){if(n.has(i))return;n.add(i);let o=i?.nameScopesList?.scopeName;if(o)t.push(o);if(i.parent)r(i.parent)}return r(e),t}function gP(e,t){if(!(e instanceof Ul))throw new we("Invalid grammar state");return e.getInternalStack(t)}var yP=/,/,xP=/ /;function $m(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(qs(e.resolveLangAlias(n.lang||"text"))||zs(r))return Lo(t).map((a)=>[{content:a[0],offset:a[1]}]);let{theme:i,colorMap:o}=e.setTheme(r),s=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==s.name)throw new we(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${s.name}"`);if(!n.grammarState.themes.includes(i.name))throw new we(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return Og(t,s,i,o,n)}function Mg(...e){if(e.length===2)return Ao(e[1]);let[t,n,r={}]=e,{lang:i="text",theme:o=t.getLoadedThemes()[0]}=r;if(qs(i)||zs(o))throw new we("Plain language does not have grammar state");if(i==="ansi")throw new we("ANSI language does not have grammar state");let{theme:s,colorMap:a}=t.setTheme(o),l=t.getLanguage(i);return new Ul(Mm(n,l,s,a,r).stateStack,l.name,s.name)}function Og(e,t,n,r,i){let o=Mm(e,t,n,r,i),s=new Ul(o.stateStack,t.name,n.name);return Ks(o.tokens,s),o.tokens}function Mm(e,t,n,r,i){let o=js(n,i),{tokenizeMaxLineLength:s=0,tokenizeTimeLimit:a=500,includeExplanation:l=!1}=i,d=Lo(e),c=i.grammarState?gP(i.grammarState,n.name)??_l:i.grammarContextCode!=null?Mm(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack:_l,m=[],p=[];for(let h=0,x=d.length;h<x;h++){let[I,v]=d[h];if(I===""){m=[],p.push([]);continue}if(s>0&&I.length>=s){m=[],p.push([{content:I,offset:v,color:"",fontStyle:0}]);continue}let S,b,E;if(l&&l!=="tokenType")S=t.tokenizeLine(I,c,a),b=S.tokens,E=0;let w=t.tokenizeLine2(I,c,a),T=w.tokens.length/2;for(let L=0;L<T;L++){let R=w.tokens[2*L],A=L+1<T?w.tokens[2*L+2]:I.length;if(R===A)continue;let O=w.tokens[2*L+1],D=Lr(r[Hl.getForeground(O)],o),X=Hl.getFontStyle(O),N={content:I.substring(R,A),offset:v+R,color:D,fontStyle:X};if(l==="tokenType")N.type=Hl.getTokenType(O);else if(l){let B=[];if(l!=="scopeName")for(let ye of n.settings){let j;switch(typeof ye.scope){case"string":j=ye.scope.split(yP).map((ie)=>ie.trim());break;case"object":j=ye.scope;break;default:continue}B.push({settings:ye,selectors:j.map((ie)=>ie.split(xP))})}N.explanation=[];let pe=0;while(R+pe<A){let ye=b[E],j=I.substring(ye.startIndex,ye.endIndex);pe+=j.length,N.explanation.push({content:j,scopes:l==="scopeName"?IP(ye.scopes):SP(B,ye.scopes)}),E+=1}}m.push(N)}p.push(m),m=[],c=w.ruleStack}return{tokens:p,stateStack:c}}function IP(e){return e.map((t)=>({scopeName:t}))}function SP(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let o=t[r];n[r]={scopeName:o,themeMatches:CP(e,o,t.slice(0,r))}}return n}function kg(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function bP(e,t,n){if(!kg(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;while(r>=0&&i>=0){if(kg(e[r],n[i]))r-=1;i-=1}if(r===-1)return!0;return!1}function CP(e,t,n){let r=[];for(let{selectors:i,settings:o}of e)for(let s of i)if(bP(s,t,n)){r.push(o);break}return r}function Bl(e,t,n,r=$m){let i=Object.entries(n.themes).filter((d)=>d[1]).map((d)=>({color:d[0],theme:d[1]})),o=i.map((d,c)=>{let m=r(e,t,{...n,includeExplanation:c===0||n.includeExplanation==="tokenType"?n.includeExplanation:!1,theme:d.theme});return{tokens:m,state:Ao(m),theme:typeof d.theme==="string"?d.theme:d.theme.name}}),s=EP(...o.map((d)=>d.tokens)),a=s[0].map((d,c)=>d.map((m,p)=>{let h={content:m.content,variants:{},offset:m.offset};if("includeExplanation"in n&&n.includeExplanation)h.explanation=m.explanation;return s.forEach((x,I)=>{let{content:v,explanation:S,offset:b,...E}=x[c][p];h.variants[i[I].color]=E}),h})),l=o[0].state?new Ul(Object.fromEntries(o.map((d)=>[d.theme,d.state?.getInternalStack(d.theme)])),o[0].state.lang):void 0;if(l)Ks(a,l);return a}function EP(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map((l)=>l[r]),o=t.map(()=>[]);t.forEach((l,d)=>l.push(o[d]));let s=i.map(()=>0),a=i.map((l)=>l[0]);while(a.every((l)=>l)){let l=Math.min(...a.map((d)=>d.content.length));for(let d=0;d<n;d++){let c=a[d];if(c.content.length===l)o[d].push(c),s[d]+=1,a[d]=i[d][s[d]];else o[d].push({...c,content:c.content.slice(0,l)}),a[d]={...c,content:c.content.slice(l),offset:c.offset+l}}}}return t}var Fg=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class ti{constructor(e,t,n){if(this.normal=t,this.property=e,n)this.space=n}}ti.prototype.normal={};ti.prototype.property={};ti.prototype.space=void 0;function Om(e,t){let n={},r={};for(let i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new ti(n,r,t)}function Po(e){return e.toLowerCase()}class Ot{constructor(e,t){this.attribute=t,this.property=e}}Ot.prototype.attribute="";Ot.prototype.booleanish=!1;Ot.prototype.boolean=!1;Ot.prototype.commaOrSpaceSeparated=!1;Ot.prototype.commaSeparated=!1;Ot.prototype.defined=!1;Ot.prototype.mustUseProperty=!1;Ot.prototype.number=!1;Ot.prototype.overloadedBoolean=!1;Ot.prototype.property="";Ot.prototype.spaceSeparated=!1;Ot.prototype.space=void 0;var Vs={};Bt(Vs,{boolean:()=>Q,booleanish:()=>lt,commaOrSpaceSeparated:()=>an,commaSeparated:()=>Rr,number:()=>P,overloadedBoolean:()=>Gl,spaceSeparated:()=>ke});var vP=0,Q=Ui(),lt=Ui(),Gl=Ui(),P=Ui(),ke=Ui(),Rr=Ui(),an=Ui();function Ui(){return 2**++vP}var Fm=Object.keys(Vs);class $o extends Ot{constructor(e,t,n,r){let i=-1;super(e,t);if(Ng(this,"space",r),typeof n==="number")while(++i<Fm.length){let o=Fm[i];Ng(this,Fm[i],(n&Vs[o])===Vs[o])}}}$o.prototype.defined=!0;function Ng(e,t,n){if(n)e[t]=n}function $n(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let o=new $o(r,e.transform(e.attributes||{},r),i,e.space);if(e.mustUseProperty&&e.mustUseProperty.includes(r))o.mustUseProperty=!0;t[r]=o,n[Po(r)]=r,n[Po(o.attribute)]=r}return new ti(t,n,e.space)}var Nm=$n({properties:{ariaActiveDescendant:null,ariaAtomic:lt,ariaAutoComplete:null,ariaBusy:lt,ariaChecked:lt,ariaColCount:P,ariaColIndex:P,ariaColSpan:P,ariaControls:ke,ariaCurrent:null,ariaDescribedBy:ke,ariaDetails:null,ariaDisabled:lt,ariaDropEffect:ke,ariaErrorMessage:null,ariaExpanded:lt,ariaFlowTo:ke,ariaGrabbed:lt,ariaHasPopup:null,ariaHidden:lt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ke,ariaLevel:P,ariaLive:null,ariaModal:lt,ariaMultiLine:lt,ariaMultiSelectable:lt,ariaOrientation:null,ariaOwns:ke,ariaPlaceholder:null,ariaPosInSet:P,ariaPressed:lt,ariaReadOnly:lt,ariaRelevant:null,ariaRequired:lt,ariaRoleDescription:ke,ariaRowCount:P,ariaRowIndex:P,ariaRowSpan:P,ariaSelected:lt,ariaSetSize:P,ariaSort:null,ariaValueMax:P,ariaValueMin:P,ariaValueNow:P,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function jl(e,t){return t in e?e[t]:t}function ql(e,t){return jl(e,t.toLowerCase())}var Dg=$n({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Rr,acceptCharset:ke,accessKey:ke,action:null,allow:null,allowFullScreen:Q,allowPaymentRequest:Q,allowUserMedia:Q,alpha:Q,alt:null,as:null,async:Q,autoCapitalize:null,autoComplete:ke,autoFocus:Q,autoPlay:Q,blocking:ke,capture:null,charSet:null,checked:Q,cite:null,className:ke,closedBy:null,colorSpace:null,cols:P,colSpan:P,command:null,commandFor:null,content:null,contentEditable:lt,controls:Q,controlsList:ke,coords:P|Rr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Q,defer:Q,dir:null,dirName:null,disabled:Q,download:Gl,draggable:lt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Q,formTarget:null,headers:ke,height:P,hidden:Gl,high:P,href:null,hrefLang:null,htmlFor:ke,httpEquiv:ke,id:null,imageSizes:null,imageSrcSet:null,inert:Q,inputMode:null,integrity:null,is:null,isMap:Q,itemId:null,itemProp:ke,itemRef:ke,itemScope:Q,itemType:ke,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Q,low:P,manifest:null,max:null,maxLength:P,media:null,method:null,min:null,minLength:P,multiple:Q,muted:Q,name:null,nonce:null,noModule:Q,noValidate:Q,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:Q,optimum:P,pattern:null,ping:ke,placeholder:null,playsInline:Q,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Q,referrerPolicy:null,rel:ke,required:Q,reversed:Q,rows:P,rowSpan:P,sandbox:ke,scope:null,scoped:Q,seamless:Q,selected:Q,shadowRootClonable:Q,shadowRootCustomElementRegistry:Q,shadowRootDelegatesFocus:Q,shadowRootMode:null,shadowRootSerializable:Q,shape:null,size:P,sizes:null,slot:null,span:P,spellCheck:lt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:P,step:null,style:null,tabIndex:P,target:null,title:null,translate:null,type:null,typeMustMatch:Q,useMap:null,value:lt,width:P,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ke,axis:null,background:null,bgColor:null,border:P,borderColor:null,bottomMargin:P,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Q,declare:Q,event:null,face:null,frame:null,frameBorder:null,hSpace:P,leftMargin:P,link:null,longDesc:null,lowSrc:null,marginHeight:P,marginWidth:P,noResize:Q,noHref:Q,noShade:Q,noWrap:Q,object:null,profile:null,prompt:null,rev:null,rightMargin:P,rules:null,scheme:null,scrolling:lt,standby:null,summary:null,text:null,topMargin:P,valueType:null,version:null,vAlign:null,vLink:null,vSpace:P,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Q,disablePictureInPicture:Q,disableRemotePlayback:Q,exportParts:Rr,part:ke,prefix:null,property:null,results:P,security:null,unselectable:null},space:"html",transform:ql});var Hg=$n({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:an,accentHeight:P,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:P,amplitude:P,arabicForm:null,ascent:P,attributeName:null,attributeType:null,azimuth:P,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:P,by:null,calcMode:null,capHeight:P,className:ke,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:P,diffuseConstant:P,direction:null,display:null,dur:null,divisor:P,dominantBaseline:null,download:Q,dx:null,dy:null,edgeMode:null,editable:null,elevation:P,enableBackground:null,end:null,event:null,exponent:P,externalResourcesRequired:null,fill:null,fillOpacity:P,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:Rr,g2:Rr,glyphName:Rr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:P,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:P,horizOriginX:P,horizOriginY:P,id:null,ideographic:P,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:P,k:P,k1:P,k2:P,k3:P,k4:P,kernelMatrix:an,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:P,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:P,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:P,overlineThickness:P,paintOrder:null,panose1:null,path:null,pathLength:P,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ke,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:P,pointsAtY:P,pointsAtZ:P,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:an,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:an,rev:an,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:an,requiredFeatures:an,requiredFonts:an,requiredFormats:an,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:P,specularExponent:P,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:P,strikethroughThickness:P,string:null,stroke:null,strokeDashArray:an,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:P,strokeOpacity:P,strokeWidth:null,style:null,surfaceScale:P,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:an,tabIndex:P,tableValues:null,target:null,targetX:P,targetY:P,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:an,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:P,underlineThickness:P,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:P,values:null,vAlphabetic:P,vMathematical:P,vectorEffect:null,vHanging:P,vIdeographic:P,version:null,vertAdvY:P,vertOriginX:P,vertOriginY:P,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:P,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:jl});var Dm=$n({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()}});var Hm=$n({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:ql});var _m=$n({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var kP=/[A-Z]/g,_g=/-[a-z]/g,TP=/^data[-\w.:]+$/i;function Um(e,t){let n=Po(t),r=t,i=Ot;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&TP.test(t)){if(t.charAt(4)==="-"){let o=t.slice(5).replace(_g,LP);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{let o=t.slice(4);if(!_g.test(o)){let s=o.replace(kP,wP);if(s.charAt(0)!=="-")s="-"+s;t="data"+s}}i=$o}return new i(r,t)}function wP(e){return"-"+e.toLowerCase()}function LP(e){return e.charAt(1).toUpperCase()}var Ug=Om([Nm,Dg,Dm,Hm,_m],"html"),zl=Om([Nm,Hg,Dm,Hm,_m],"svg");var Bg={}.hasOwnProperty;function Gg(e,t){let n=t||{};function r(i,...o){let{invalid:s,handlers:a}=r;if(i&&Bg.call(i,e)){let l=String(i[e]);s=Bg.call(a,l)?a[l]:r.unknown}if(s)return s.call(this,i,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var RP=/["&'<>`]/g,AP=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,PP=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,$P=/[|\\{}()[\]^$+*?.]/g,jg=new WeakMap;function qg(e,t){if(e=e.replace(t.subset?MP(t.subset):RP,r),t.subset||t.escapeOnly)return e;return e.replace(AP,n).replace(PP,r);function n(i,o,s){return t.format((i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)-56320+65536,s.charCodeAt(o+2),t)}function r(i,o,s){return t.format(i.charCodeAt(0),s.charCodeAt(o+1),t)}}function MP(e){let t=jg.get(e);if(!t)t=OP(e),jg.set(e,t);return t}function OP(e){let t=[],n=-1;while(++n<e.length)t.push(e[n].replace($P,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}var FP=/[\dA-Fa-f]/;function zg(e,t,n){let r="&#x"+e.toString(16).toUpperCase();return n&&t&&!FP.test(String.fromCharCode(t))?r:r+";"}var NP=/\d/;function Kg(e,t,n){let r="&#"+String(e);return n&&t&&!NP.test(String.fromCharCode(t))?r:r+";"}var Vg=["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"];var Kl={nbsp:" ",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:"€"};var Wg=["cent","copy","divide","gt","lt","not","para","times"];var Xg={}.hasOwnProperty,Bm={},Vl;for(Vl in Kl)if(Xg.call(Kl,Vl))Bm[Kl[Vl]]=Vl;var DP=/[^\dA-Za-z]/;function Yg(e,t,n,r){let i=String.fromCharCode(e);if(Xg.call(Bm,i)){let o=Bm[i],s="&"+o;if(n&&Vg.includes(o)&&!Wg.includes(o)&&(!r||t&&t!==61&&DP.test(String.fromCharCode(t))))return s;return s+";"}return""}function Jg(e,t,n){let r=zg(e,t,n.omitOptionalSemicolons),i;if(n.useNamedReferences||n.useShortestReferences)i=Yg(e,t,n.omitOptionalSemicolons,n.attribute);if((n.useShortestReferences||!i)&&n.useShortestReferences){let o=Kg(e,t,n.omitOptionalSemicolons);if(o.length<r.length)r=o}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function Ar(e,t){return qg(e,Object.assign({format:Jg},t))}var HP=/^>|^->|<!--|-->|--!>|<!-$/g,_P=[">"],UP=["<",">"];function Zg(e,t,n,r){return r.settings.bogusComments?"<?"+Ar(e.value,Object.assign({},r.settings.characterReferences,{subset:_P}))+">":"<!--"+e.value.replace(HP,i)+"-->";function i(o){return Ar(o,Object.assign({},r.settings.characterReferences,{subset:UP}))}}function Qg(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function Gm(e,t){let n=String(e);if(typeof t!=="string")throw TypeError("Expected character");let r=0,i=n.indexOf(t);while(i!==-1)r++,i=n.indexOf(t,i+t.length);return r}function ey(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function ty(e){return e.join(" ").trim()}var BP=/[ \t\n\f\r]/g;function Bi(e){return typeof e==="object"?e.type==="text"?ny(e.value):!1:ny(e)}function ny(e){return e.replace(BP,"")===""}var mt=ry(1),jm=ry(-1),GP=[];function ry(e){return t;function t(n,r,i){let o=n?n.children:GP,s=(r||0)+e,a=o[s];if(!i)while(a&&Bi(a))s+=e,a=o[s];return a}}var jP={}.hasOwnProperty;function Wl(e){return t;function t(n,r,i){return jP.call(e,n.tagName)&&e[n.tagName](n,r,i)}}var Ws=Wl({body:zP,caption:qm,colgroup:qm,dd:XP,dt:WP,head:qm,html:qP,li:VP,optgroup:YP,option:JP,p:KP,rp:iy,rt:iy,tbody:QP,td:oy,tfoot:e$,th:oy,thead:ZP,tr:t$});function qm(e,t,n){let r=mt(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&Bi(r.value.charAt(0)))}function qP(e,t,n){let r=mt(n,t);return!r||r.type!=="comment"}function zP(e,t,n){let r=mt(n,t);return!r||r.type!=="comment"}function KP(e,t,n){let r=mt(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 VP(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&r.tagName==="li"}function WP(e,t,n){let r=mt(n,t);return Boolean(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function XP(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function iy(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function YP(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function JP(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function ZP(e,t,n){let r=mt(n,t);return Boolean(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function QP(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function e$(e,t,n){return!mt(n,t)}function t$(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function oy(e,t,n){let r=mt(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}var sy=Wl({body:i$,colgroup:o$,head:r$,html:n$,tbody:s$});function n$(e){let t=mt(e,-1);return!t||t.type!=="comment"}function r$(e){let t=new Set;for(let r of e.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(t.has(r.tagName))return!1;t.add(r.tagName)}let n=e.children[0];return!n||n.type==="element"}function i$(e){let t=mt(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Bi(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function o$(e,t,n){let r=jm(n,t),i=mt(e,-1,!0);if(n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Ws(r,n.children.indexOf(r),n))return!1;return Boolean(i&&i.type==="element"&&i.tagName==="col")}function s$(e,t,n){let r=jm(n,t),i=mt(e,-1);if(n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Ws(r,n.children.indexOf(r),n))return!1;return Boolean(i&&i.type==="element"&&i.tagName==="tr")}var Xl={name:[[`
|
|
2
2
|
\f\r &/=>`.split(""),`
|
|
3
3
|
\f\r "&'/=>\``.split("")],[`\x00
|
|
4
4
|
\f\r "&'/<=>`.split(""),`\x00
|
|
@@ -6,10 +6,10 @@ import{$ as xI,Ca as id,Da as sS,Ea as ld,I as Tg,J as Bt,K as Dl,L as kg,M as H
|
|
|
6
6
|
\f\r &>`.split(""),`\x00
|
|
7
7
|
\f\r "&'<=>\``.split("")],[`\x00
|
|
8
8
|
\f\r "&'<=>\``.split(""),`\x00
|
|
9
|
-
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\x00&'".split(""),"\x00\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\x00"&'.split(""),"\x00\"&'`".split("")]]};function sy(e,t,n,r){let i=r.schema,o=i.space==="svg"?!1:r.settings.omitOptionalTags,s=i.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),a=[],l;if(i.space==="html"&&e.tagName==="svg")r.schema=ql;let d=i$(r,e.properties),c=r.all(i.space==="html"&&e.tagName==="template"?e.content:e);if(r.schema=i,c)s=!1;if(d||!o||!oy(e,t,n)){if(a.push("<",e.tagName,d?" "+d:""),s&&(i.space==="svg"||r.settings.closeSelfClosing)){if(l=d.charAt(d.length-1),!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")a.push(" ");a.push("/")}a.push(">")}if(a.push(c),!s&&(!o||!Ks(e,t,n)))a.push("</"+e.tagName+">");return a.join("")}function i$(e,t){let n=[],r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){let o=o$(e,i,t[i]);if(o)n.push(o)}}while(++r<n.length){let o=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;if(r!==n.length-1&&o!=='"'&&o!=="'")n[r]+=" "}return n.join("")}function o$(e,t,n){let r=_m(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,o=e.settings.allowDangerousCharacters?0:1,s=e.quote,a;if(r.overloadedBoolean&&(n===r.attribute||n===""))n=!0;else if((r.boolean||r.overloadedBoolean)&&(typeof n!=="string"||n===r.attribute||n===""))n=Boolean(n);if(n===null||n===void 0||n===!1||typeof n==="number"&&Number.isNaN(n))return"";let l=Ar(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Wl.name[i][o]}));if(n===!0)return l;if(n=Array.isArray(n)?(r.commaSeparated?Qg:ey)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)return l;if(e.settings.preferUnquoted)a=Ar(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Wl.unquoted[i][o]}));if(a!==n){if(e.settings.quoteSmart&&Bm(n,s)>Bm(n,e.alternative))s=e.alternative;a=s+Ar(n,Object.assign({},e.settings.characterReferences,{subset:(s==="'"?Wl.single:Wl.double)[i][o],attribute:!0}))+s}return l+(a?"="+a:a)}var s$=["<","&"];function Xl(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Ar(e.value,Object.assign({},r.settings.characterReferences,{subset:s$}))}function ay(e,t,n,r){return r.settings.allowDangerousHtml?e.value:Xl(e,t,n,r)}function ly(e,t,n,r){return r.all(e)}var uy=Bg("type",{invalid:a$,unknown:l$,handlers:{comment:Jg,doctype:Zg,element:sy,raw:ay,root:ly,text:Xl}});function a$(e){throw Error("Expected node, not `"+e+"`")}function l$(e){throw Error("Cannot compile unknown node `"+e.type+"`")}var u$={},d$={},c$=[];function ut(e,t){let n=t||u$,r=n.quote||'"',i=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:m$,all:f$,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||Og,characterReferences:n.characterReferences||d$,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?ql:_g,quote:r,alternative:i}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function m$(e,t,n){return uy(e,t,n,this)}function f$(e){let t=[],n=e&&e.children||c$,r=-1;while(++r<n.length)t[r]=this.one(n[r],r,e);return t.join("")}var dy=/\s+/g;function fy(e,t){if(!t)return e;if(e.properties||={},e.properties.class||=[],typeof e.properties.class==="string")e.properties.class=e.properties.class.split(dy);if(!Array.isArray(e.properties.class))e.properties.class=[];let n=Array.isArray(t)?t:t.split(dy);for(let r of n)if(r&&!e.properties.class.includes(r))e.properties.class.push(r);return e}function p$(e){let t=Lo(e,!0).map(([i])=>i);function n(i){if(i===e.length)return{line:t.length-1,character:t.at(-1).length};let o=i,s=0;for(let a of t){if(o<a.length)break;o-=a.length,s++}return{line:s,character:o}}function r(i,o){let s=0;for(let a=0;a<i;a++)s+=t[a].length;return s+=o,s}return{lines:t,indexToPos:n,posToIndex:r}}var h$=["color","background-color"];function g$(e,t){let n=0,r=[];for(let i of t){if(i>n)r.push({...e,content:e.content.slice(n,i),offset:e.offset+n});n=i}if(n<e.content.length)r.push({...e,content:e.content.slice(n),offset:e.offset+n});return r}function y$(e,t){let n=0,r=e.length;while(n<r){let i=n+(r-n>>1);if(e[i]<=t)n=i+1;else r=i}return n}function x$(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((r,i)=>r-i);if(!n.length)return e;return e.map((r)=>r.flatMap((i)=>{let o=i.offset+i.content.length,s=y$(n,i.offset),a=s;while(a<n.length&&n[a]<o)a++;if(s===a)return i;let l=n.slice(s,a);for(let d=0;d<l.length;d++)l[d]-=i.offset;return g$(i,l)}))}function I$(e,t,n,r,i="css-vars"){let o={content:e.content,explanation:e.explanation,offset:e.offset},s=t.map((c)=>Yl(e.variants[c])),a=new Set(s.flatMap((c)=>Object.keys(c))),l={},d=(c,m)=>{let p=m==="color"?"":m==="background-color"?"-bg":`-${m}`;return n+t[c]+(m==="color"?"":p)};return s.forEach((c,m)=>{for(let p of a){let h=c[p]||"inherit";if(m===0&&r&&h$.includes(p))if(r==="light-dark()"&&s.length>1){let x=t.findIndex((b)=>b==="light"),I=t.findIndex((b)=>b==="dark");if(x===-1||I===-1)throw new we('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let v=s[x][p]||"inherit",S=s[I][p]||"inherit";if(l[p]=`light-dark(${v}, ${S})`,i==="css-vars")l[d(m,p)]=h}else l[p]=h;else if(i==="css-vars")l[d(m,p)]=h}}),o.htmlStyle=l,o}function Yl(e){let t={};if(e.color)t.color=e.color;if(e.bgColor)t["background-color"]=e.bgColor;if(e.fontStyle){if(e.fontStyle&Bt.Italic)t["font-style"]="italic";if(e.fontStyle&Bt.Bold)t["font-weight"]="bold";let n=[];if(e.fontStyle&Bt.Underline)n.push("underline");if(e.fontStyle&Bt.Strikethrough)n.push("line-through");if(n.length)t["text-decoration"]=n.join(" ")}return t}function zm(e){if(typeof e==="string")return e;return Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function S$(){let e=new WeakMap;function t(n){if(!e.has(n.meta)){let i=function(s){if(typeof s==="number"){if(s<0||s>n.source.length)throw new we(`Invalid decoration offset: ${s}. Code length: ${n.source.length}`);return{...r.indexToPos(s),offset:s}}else{let a=r.lines[s.line];if(a===void 0)throw new we(`Invalid decoration position ${JSON.stringify(s)}. Lines length: ${r.lines.length}`);let l=s.character;if(l<0)l=a.length+l;if(l<0||l>a.length)throw new we(`Invalid decoration position ${JSON.stringify(s)}. Line ${s.line} length: ${a.length}`);return{...s,character:l,offset:r.posToIndex(s.line,l)}}},r=p$(n.source),o=(n.options.decorations||[]).map((s)=>({...s,start:i(s.start),end:i(s.end)}));b$(o),e.set(n.meta,{decorations:o,converter:r,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(!this.options.decorations?.length)return;return x$(n,t(this).decorations.flatMap((r)=>[r.start.offset,r.end.offset]))},code(n){if(!this.options.decorations?.length)return;let r=t(this),i=[...n.children].filter((c)=>c.type==="element"&&c.tagName==="span");if(i.length!==r.converter.lines.length)throw new we(`Number of lines in code element (${i.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function o(c,m,p,h){let x=i[c],I="",v=-1,S=-1;if(m===0)v=0;if(p===0)S=0;if(p===Number.POSITIVE_INFINITY)S=x.children.length;if(v===-1||S===-1)for(let E=0;E<x.children.length;E++){if(I+=py(x.children[E]),v===-1&&I.length===m)v=E+1;if(S===-1&&I.length===p)S=E+1}if(v===-1)throw new we(`Failed to find start index for decoration ${JSON.stringify(h.start)}`);if(S===-1)throw new we(`Failed to find end index for decoration ${JSON.stringify(h.end)}`);let b=x.children.slice(v,S);if(!h.alwaysWrap&&b.length===x.children.length)a(x,h,"line");else if(!h.alwaysWrap&&b.length===1&&b[0].type==="element")a(b[0],h,"token");else{let E={type:"element",tagName:"span",properties:{},children:b};a(E,h,"wrapper"),x.children.splice(v,b.length,E)}}function s(c,m){i[c]=a(i[c],m,"line")}function a(c,m,p){let h=m.properties||{},x=m.transform||((I)=>I);if(c.tagName=m.tagName||"span",c.properties={...c.properties,...h,class:c.properties.class},m.properties?.class)fy(c,m.properties.class);return c=x(c,p)||c,c}let l=[],d=r.decorations.sort((c,m)=>m.start.offset-c.start.offset||c.end.offset-m.end.offset);for(let c of d){let{start:m,end:p}=c;if(m.line===p.line)o(m.line,m.character,p.character,c);else if(m.line<p.line){o(m.line,m.character,Number.POSITIVE_INFINITY,c);for(let h=m.line+1;h<p.line;h++)l.unshift(()=>s(h,c));o(p.line,0,p.character,c)}}l.forEach((c)=>c())}}}function b$(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new we(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let i=e[r],o=n.start.offset<=i.start.offset&&i.start.offset<n.end.offset,s=n.start.offset<i.end.offset&&i.end.offset<=n.end.offset,a=i.start.offset<=n.start.offset&&n.start.offset<i.end.offset,l=i.start.offset<n.end.offset&&n.end.offset<=i.end.offset;if(o||s||a||l){if(o&&s)continue;if(a&&l)continue;if(a&&n.start.offset===n.end.offset)continue;if(s&&i.start.offset===i.end.offset)continue;throw new we(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(i.start)} intersect.`)}}}}function py(e){if(e.type==="text")return e.value;if(e.type==="element")return e.children.map(py).join("");return""}var C$=[S$()];function Jl(e){let t=E$(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...C$]}function E$(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 Gi=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],qm={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function v$(e,t){let n=e.indexOf("\x1B",t);if(n!==-1){if(e[n+1]==="["){let r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}}return{position:e.length}}function cy(e){let t=e.shift();if(t==="2"){let n=e.splice(0,3).map((r)=>Number.parseInt(r));if(n.length!==3||n.some((r)=>Number.isNaN(r)))return;return{type:"rgb",rgb:n}}else if(t==="5"){let n=e.shift();if(n)return{type:"table",index:Number(n)}}}function T$(e){let t=[];while(e.length>0){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(Number.isNaN(r))continue;if(r===0)t.push({type:"resetAll"});else if(r<=9){if(qm[r])t.push({type:"setDecoration",value:qm[r]})}else if(r<=29){let i=qm[r-20];if(i){if(t.push({type:"resetDecoration",value:i}),i==="dim")t.push({type:"resetDecoration",value:"bold"})}}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:Gi[r-30]}});else if(r===38){let i=cy(e);if(i)t.push({type:"setForegroundColor",value:i})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:Gi[r-40]}});else if(r===48){let i=cy(e);if(i)t.push({type:"setBackgroundColor",value:i})}else if(r===49)t.push({type:"resetBackgroundColor"});else if(r===53)t.push({type:"setDecoration",value:"overline"});else if(r===55)t.push({type:"resetDecoration",value:"overline"});else if(r>=90&&r<=97)t.push({type:"setForegroundColor",value:{type:"named",name:Gi[r-90+8]}});else if(r>=100&&r<=107)t.push({type:"setBackgroundColor",value:{type:"named",name:Gi[r-100+8]}})}return t}function k$(){let e=null,t=null,n=new Set;return{parse(r){let i=[],o=0;do{let s=v$(r,o),a=s.sequence?r.substring(o,s.startPosition):r.substring(o);if(a.length>0)i.push({value:a,foreground:e,background:t,decorations:new Set(n)});if(s.sequence){let l=T$(s.sequence);for(let d of l)if(d.type==="resetAll")e=null,t=null,n.clear();else if(d.type==="resetForegroundColor")e=null;else if(d.type==="resetBackgroundColor")t=null;else if(d.type==="resetDecoration")n.delete(d.value);for(let d of l)if(d.type==="setForegroundColor")e=d.value;else if(d.type==="setBackgroundColor")t=d.value;else if(d.type==="setDecoration")n.add(d.value)}o=s.position}while(o<r.length);return i}}}var w$={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 L$(e=w$){function t(a){return e[a]}function n(a){return`#${a.map((l)=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function i(){if(r)return r;r=[];for(let d=0;d<Gi.length;d++)r.push(t(Gi[d]));let a=[0,95,135,175,215,255];for(let d=0;d<6;d++)for(let c=0;c<6;c++)for(let m=0;m<6;m++)r.push(n([a[d],a[c],a[m]]));let l=8;for(let d=0;d<24;d++,l+=10)r.push(n([l,l,l]));return r}function o(a){return i()[a]}function s(a){switch(a.type){case"named":return t(a.name);case"rgb":return n(a.rgb);case"table":return o(a.index)}}return{value:s}}var R$=/#([0-9a-f]{3,8})/i,A$=/var\((--[\w-]+-ansi-[\w-]+)\)/,P$={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 $$(e,t,n){let r=Us(e,n),i=Lo(t),o=L$(Object.fromEntries(Gi.map((a)=>{let l=`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`;return[a,e.colors?.[l]||P$[a]]}))),s=k$();return i.map((a)=>s.parse(a[0]).map((l)=>{let d,c;if(l.decorations.has("reverse"))d=l.background?o.value(l.background):e.bg,c=l.foreground?o.value(l.foreground):e.fg;else d=l.foreground?o.value(l.foreground):e.fg,c=l.background?o.value(l.background):void 0;if(d=Lr(d,r),c=Lr(c,r),l.decorations.has("dim"))d=M$(d);let m=Bt.None;if(l.decorations.has("bold"))m|=Bt.Bold;if(l.decorations.has("italic"))m|=Bt.Italic;if(l.decorations.has("underline"))m|=Bt.Underline;if(l.decorations.has("strikethrough"))m|=Bt.Strikethrough;return{content:l.value,offset:a[1],color:d,bgColor:c,fontStyle:m}}))}function M$(e){let t=e.match(R$);if(t){let r=t[1];if(r.length===8){let i=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${i}`}else if(r.length===6)return`#${r}80`;else if(r.length===4){let i=r[0],o=r[1],s=r[2],a=r[3];return`#${i}${i}${o}${o}${s}${s}${Math.round(Number.parseInt(`${a}${a}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){let i=r[0],o=r[1],s=r[2];return`#${i}${i}${o}${o}${s}${s}80`}}let n=e.match(A$);if(n)return`var(${n[1]}-dim)`;return e}function Km(e,t,n={}){let r=e.resolveLangAlias(n.lang||"text"),{theme:i=e.getLoadedThemes()[0]}=n;if(!Bs(r)&&!Gs(i)&&r==="ansi"){let{theme:o}=e.setTheme(i);return $$(o,t,n)}return Pm(e,t,n)}function Zl(e,t,n){let r,i,o,s,a,l;if("themes"in n){let{defaultColor:d="light",cssVariablePrefix:c="--shiki-",colorsRendering:m="css-vars"}=n,p=Object.entries(n.themes).filter((S)=>S[1]).map((S)=>({color:S[0],theme:S[1]})).sort((S,b)=>S.color===d?-1:b.color===d?1:0);if(p.length===0)throw new we("`themes` option must not be empty");let h=Ul(e,t,n,Km);if(l=Ao(h),d&&d!=="light-dark()"&&!p.some((S)=>S.color===d))throw new we(`\`themes\` option must contain the defaultColor key \`${d}\``);let x=p.map((S)=>e.getTheme(S.theme)),I=p.map((S)=>S.color);if(o=h.map((S)=>S.map((b)=>I$(b,I,c,d,m))),l)js(o,l);let v=p.map((S)=>Us(S.theme,n));i=my(p,x,v,c,d,"fg",m),r=my(p,x,v,c,d,"bg",m),s=`shiki-themes ${x.map((S)=>S.name).join(" ")}`,a=d?void 0:[i,r].join(";")}else if("theme"in n){let d=Us(n.theme,n);o=Km(e,t,n);let c=e.getTheme(n.theme);r=Lr(c.bg,d),i=Lr(c.fg,d),s=c.name,l=Ao(o)}else throw new we("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:i,bg:r,themeName:s,rootStyle:a,grammarState:l}}function my(e,t,n,r,i,o,s){return e.map((a,l)=>{let d=Lr(t[l][o],n[l])||"inherit",c=`${r+a.color}${o==="bg"?"-bg":""}:${d}`;if(l===0&&i){if(i==="light-dark()"&&e.length>1){let m=e.findIndex((h)=>h.color==="light"),p=e.findIndex((h)=>h.color==="dark");if(m===-1||p===-1)throw new we('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Lr(t[m][o],n[m])||"inherit"}, ${Lr(t[p][o],n[p])||"inherit"});${c}`}return d}if(s==="css-vars")return c;return null}).filter((a)=>!!a).join(";")}var hy=/^\s+$/,O$=/^(\s*)(.*?)(\s*)$/;function Ql(e,t,n,r={meta:{},options:n,codeToHast:(i,o)=>Ql(e,i,o),codeToTokens:(i,o)=>Zl(e,i,o)}){let i=t;for(let x of Jl(n))i=x.preprocess?.call(r,i,n)||i;let{tokens:o,fg:s,bg:a,themeName:l,rootStyle:d,grammarState:c}=Zl(e,i,n),{mergeWhitespaces:m=!0,mergeSameStyleTokens:p=!1}=n;if(m===!0)o=N$(o);else if(m==="never")o=D$(o);if(p)o=H$(o);let h={...r,get source(){return i}};for(let x of Jl(n))o=x.tokens?.call(h,o)||o;return F$(o,{...n,fg:s,bg:a,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??d},h,c)}function F$(e,t,n,r=Ao(e)){let i=Jl(t),o=[],s={type:"root",children:[]},{structure:a="classic",tabindex:l="0"}=t,d={class:`shiki ${t.themeName||""}`};if(t.rootStyle!==!1)if(t.rootStyle!=null)d.style=t.rootStyle;else d.style=`background-color:${t.bg};color:${t.fg}`;if(l!==!1&&l!=null)d.tabindex=l.toString();for(let[I,v]of Object.entries(t.meta||{}))if(!I.startsWith("_"))d[I]=v;let c={type:"element",tagName:"pre",properties:d,children:[],data:t.data},m={type:"element",tagName:"code",properties:{},children:o},p=[],h={...n,structure:a,addClassToHast:fy,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return s},get pre(){return c},get code(){return m},get lines(){return p}};if(e.forEach((I,v)=>{if(v){if(a==="inline")s.children.push({type:"element",tagName:"br",properties:{},children:[]});else if(a==="classic")o.push({type:"text",value:`
|
|
10
|
-
`})}let S={type:"element",tagName:"span",properties:{class:"line"},children:[]},b=0;for(let E of I){let w={type:"element",tagName:"span",properties:{...E.htmlAttrs},children:[{type:"text",value:E.content}]},k=zm(E.htmlStyle||Yl(E));if(k)w.properties.style=k;for(let L of i)w=L?.span?.call(h,w,v+1,b,S,E)||w;if(a==="inline")s.children.push(w);else if(a==="classic")S.children.push(w);b+=E.content.length}if(a==="classic"){for(let E of i)S=E?.line?.call(h,S,v+1)||S;p.push(S),o.push(S)}else if(a==="inline")p.push(S)}),a==="classic"){for(let I of i)m=I?.code?.call(h,m)||m;c.children.push(m);for(let I of i)c=I?.pre?.call(h,c)||c;s.children.push(c)}else if(a==="inline"){let I=[],v={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let b of s.children)if(b.type==="element"&&b.tagName==="br")I.push(v),v={type:"element",tagName:"span",properties:{class:"line"},children:[]};else if(b.type==="element"||b.type==="text")v.children.push(b);I.push(v);let S={type:"element",tagName:"code",properties:{},children:I};for(let b of i)S=b?.code?.call(h,S)||S;s.children=[];for(let b=0;b<S.children.length;b++){if(b>0)s.children.push({type:"element",tagName:"br",properties:{},children:[]});let E=S.children[b];if(E.type==="element")s.children.push(...E.children)}}let x=s;for(let I of i)x=I?.root?.call(h,x)||x;if(r)js(x,r);return x}function N$(e){return e.map((t)=>{let n=[],r="",i;return t.forEach((o,s)=>{let a=!(o.fontStyle&&(o.fontStyle&Bt.Underline||o.fontStyle&Bt.Strikethrough));if(a&&hy.test(o.content)&&t[s+1]){if(i===void 0)i=o.offset;r+=o.content}else if(r){if(a)n.push({...o,offset:i,content:r+o.content});else n.push({content:r,offset:i},o);i=void 0,r=""}else n.push(o)}),n})}function D$(e){return e.map((t)=>t.flatMap((n)=>{if(hy.test(n.content))return n;let r=n.content.match(O$);if(!r)return n;let[,i,o,s]=r;if(!i&&!s)return n;let a=[{...n,offset:n.offset+i.length,content:o}];if(i)a.unshift({content:i,offset:n.offset});if(s)a.push({content:s,offset:n.offset+i.length+o.length});return a}))}function H$(e){return e.map((t)=>{let n=[];for(let r of t){if(n.length===0){n.push({...r});continue}let i=n.at(-1),o=zm(i.htmlStyle||Yl(i)),s=zm(r.htmlStyle||Yl(r)),a=i.fontStyle&&(i.fontStyle&Bt.Underline||i.fontStyle&Bt.Strikethrough),l=r.fontStyle&&(r.fontStyle&Bt.Underline||r.fontStyle&Bt.Strikethrough);if(!a&&!l&&o===s)i.content+=r.content;else n.push({...r})}return n})}var _$=ut;function U$(e,t,n){let r={meta:{},options:n,codeToHast:(o,s)=>Ql(e,o,s),codeToTokens:(o,s)=>Zl(e,o,s)},i=_$(Ql(e,t,n,r));for(let o of Jl(n))i=o.postprocess?.call(r,i,n)||i;return i}async function B$(e){let t=await Am(e);return{getLastGrammarState:(...n)=>$g(t,...n),codeToTokensBase:(n,r)=>Km(t,n,r),codeToTokensWithThemes:(n,r)=>Ul(t,n,r),codeToTokens:(n,r)=>Zl(t,n,r),codeToHast:(n,r)=>Ql(t,n,r),codeToHtml:(n,r)=>U$(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function gy(e){let{langs:t,themes:n,engine:r}=e;async function i(o){function s(m){if(typeof m==="string"){if(m=o.langAlias?.[m]||m,wm(m))return[];let p=t[m];if(!p)throw new we(`Language \`${m}\` is not included in this bundle. You may want to load it from external source.`);return p}return m}function a(m){if(Lm(m))return"none";if(typeof m==="string"){let p=n[m];if(!p)throw new we(`Theme \`${m}\` is not included in this bundle. You may want to load it from external source.`);return p}return m}let l=(o.themes??[]).map((m)=>a(m)),d=(o.langs??[]).map((m)=>s(m)),c=await B$({engine:o.engine??r(),...o,themes:l,langs:d});return{...c,loadLanguage(...m){return c.loadLanguage(...m.map(s))},loadTheme(...m){return c.loadTheme(...m.map(a))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return i}function eu({name:e,load:t,colorScheme:n,collection:r,displayName:i}){return{name:e,colorScheme:n,collection:r,displayName:i,load:G$(t)}}function G$(e){return async()=>Ro(Fl(await e()))}var j$="pierre",q$=["pierre-dark","pierre-dark-soft","pierre-dark-vibrant","pierre-dark-protanopia-deuteranopia","pierre-dark-tritanopia"],yy=["pierre-light","pierre-light-soft","pierre-light-vibrant","pierre-light-protanopia-deuteranopia","pierre-light-tritanopia"],z$=[...yy,...q$],K$=new Set(yy);function V$(e){if(K$.has(e))return"light";return"dark"}var W$={"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"},X$={"pierre-dark":()=>import("./pierre-dark-dbehbn5b.js"),"pierre-dark-soft":()=>import("./pierre-dark-soft-svbt475t.js"),"pierre-dark-vibrant":()=>import("./pierre-dark-vibrant-3st3mhhn.js"),"pierre-dark-protanopia-deuteranopia":()=>import("./pierre-dark-protanopia-deuteranopia-p24qgk7j.js"),"pierre-dark-tritanopia":()=>import("./pierre-dark-tritanopia-f5fgf7t0.js"),"pierre-light":()=>import("./pierre-light-sr6jfjng.js"),"pierre-light-soft":()=>import("./pierre-light-soft-rcep508k.js"),"pierre-light-vibrant":()=>import("./pierre-light-vibrant-mv2fa7xw.js"),"pierre-light-protanopia-deuteranopia":()=>import("./pierre-light-protanopia-deuteranopia-rfszgf8k.js"),"pierre-light-tritanopia":()=>import("./pierre-light-tritanopia-d8z7gv4x.js")};function Y$(e){return eu({name:e,collection:j$,colorScheme:V$(e),displayName:W$[e],load:X$[e]})}var tu=Qr({themes:z$.map((e)=>Y$(e))});var J$="shiki",Iy=["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"],Z$=["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"],Q$=new Set(Iy);function eM(e){if(Q$.has(e))return"light";return"dark"}var tM={andromeeda:()=>import("./andromeeda-tsp924my.js"),"aurora-x":()=>import("./aurora-x-ba9r2etj.js"),"ayu-dark":()=>import("./ayu-dark-1vqjtzry.js"),"ayu-light":()=>import("./ayu-light-hyc4fc7y.js"),"ayu-mirage":()=>import("./ayu-mirage-exvkv8da.js"),"catppuccin-frappe":()=>import("./catppuccin-frappe-0rvsggsb.js"),"catppuccin-latte":()=>import("./catppuccin-latte-av89afca.js"),"catppuccin-macchiato":()=>import("./catppuccin-macchiato-dqe3mbw1.js"),"catppuccin-mocha":()=>import("./catppuccin-mocha-2w1wgn9v.js"),"dark-plus":()=>import("./dark-plus-0be7zfjq.js"),dracula:()=>import("./dracula-kyzb58xf.js"),"dracula-soft":()=>import("./dracula-soft-4ah05qcy.js"),"everforest-dark":()=>import("./everforest-dark-x2sxpmaz.js"),"everforest-light":()=>import("./everforest-light-9xkh4gqx.js"),"github-dark":()=>import("./github-dark-xzmxhvr4.js"),"github-dark-default":()=>import("./github-dark-default-sa857k56.js"),"github-dark-dimmed":()=>import("./github-dark-dimmed-ekh4tbqg.js"),"github-dark-high-contrast":()=>import("./github-dark-high-contrast-5xp9g18c.js"),"github-light":()=>import("./github-light-2q28m6c1.js"),"github-light-default":()=>import("./github-light-default-ywc9b32r.js"),"github-light-high-contrast":()=>import("./github-light-high-contrast-9hy4thhf.js"),"gruvbox-dark-hard":()=>import("./gruvbox-dark-hard-h6rfjf9q.js"),"gruvbox-dark-medium":()=>import("./gruvbox-dark-medium-gdwaw20e.js"),"gruvbox-dark-soft":()=>import("./gruvbox-dark-soft-sq5yvaag.js"),"gruvbox-light-hard":()=>import("./gruvbox-light-hard-nym0hnh4.js"),"gruvbox-light-medium":()=>import("./gruvbox-light-medium-9kgrswjt.js"),"gruvbox-light-soft":()=>import("./gruvbox-light-soft-618vpmvg.js"),horizon:()=>import("./horizon-5e2be4sx.js"),"horizon-bright":()=>import("./horizon-bright-0hrqkmhs.js"),houston:()=>import("./houston-wzd0npbc.js"),"kanagawa-dragon":()=>import("./kanagawa-dragon-hec3nmvm.js"),"kanagawa-lotus":()=>import("./kanagawa-lotus-eg9aja7s.js"),"kanagawa-wave":()=>import("./kanagawa-wave-314f45f0.js"),laserwave:()=>import("./laserwave-wz1f76zd.js"),"light-plus":()=>import("./light-plus-43gmczhw.js"),"material-theme":()=>import("./material-theme-bqcfs89x.js"),"material-theme-darker":()=>import("./material-theme-darker-gger3t82.js"),"material-theme-lighter":()=>import("./material-theme-lighter-evaye4z3.js"),"material-theme-ocean":()=>import("./material-theme-ocean-h7m9f34k.js"),"material-theme-palenight":()=>import("./material-theme-palenight-tyeannba.js"),"min-dark":()=>import("./min-dark-kcpraaxv.js"),"min-light":()=>import("./min-light-w5gbrkp8.js"),monokai:()=>import("./monokai-nbvd076q.js"),"night-owl":()=>import("./night-owl-kk2p0vc0.js"),"night-owl-light":()=>import("./night-owl-light-hq9zzwqt.js"),nord:()=>import("./nord-c0ea2g04.js"),"one-dark-pro":()=>import("./one-dark-pro-t9a3593x.js"),"one-light":()=>import("./one-light-aar5vy7j.js"),plastic:()=>import("./plastic-0tmrj0c8.js"),poimandres:()=>import("./poimandres-hmgg59te.js"),red:()=>import("./red-0knjvcyd.js"),"rose-pine":()=>import("./rose-pine-v63jc1jc.js"),"rose-pine-dawn":()=>import("./rose-pine-dawn-a079aeh5.js"),"rose-pine-moon":()=>import("./rose-pine-moon-axp18ha5.js"),"slack-dark":()=>import("./slack-dark-n2f4xt4t.js"),"slack-ochin":()=>import("./slack-ochin-ag40mqdq.js"),"snazzy-light":()=>import("./snazzy-light-g9qtd34v.js"),"solarized-dark":()=>import("./solarized-dark-cpesrcas.js"),"solarized-light":()=>import("./solarized-light-ar205sc0.js"),"synthwave-84":()=>import("./synthwave-84-n8bwkyqe.js"),"tokyo-night":()=>import("./tokyo-night-rcm4pka3.js"),vesper:()=>import("./vesper-dctcmpqx.js"),"vitesse-black":()=>import("./vitesse-black-jpzvzek5.js"),"vitesse-dark":()=>import("./vitesse-dark-6067ajvh.js"),"vitesse-light":()=>import("./vitesse-light-tz4hqyp9.js")};function xy(e){return eu({name:e,collection:J$,colorScheme:eM(e),load:tM[e]})}var nu=Qr({themes:Object.freeze([...Iy.map((e)=>xy(e)),...Z$.map((e)=>xy(e))])});var B4=Qr({themes:[tu,nu]});function Sy(e){if(Nl())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(Zt.hasRegisteredTheme(e))return;let t=nu.getTheme(e);if(t!=null){Zt.registerThemeIfAbsent(t.name,t.load);return}throw Error(`No valid theme loader registered for "${e}"`)}function by(e,t){if(t.name!==e)throw Error(`resolvedTheme: themeName: ${e} does not match theme.name: ${t.name}`)}async function Vm(e){Sy(e);let t=await Zt.resolveTheme(e);return by(e,t),t}var ti=new Map,ru=new Map,Cy=new Map,Vs=new Set;function ni(e){for(let t of Array.isArray(e)?e:[e]){if(t==="text"||t==="ansi")continue;if(!Vs.has(t))return!1}return!0}function Wm(e,t){e=Array.isArray(e)?e:[e];for(let n of e){if(Vs.has(n.name))continue;let r=ti.get(n.name);if(r==null)r=n,ti.set(n.name,r);Vs.add(r.name),t.loadLanguageSync(r.data)}}var iu=[{id:"abap",name:"ABAP",import:()=>import("./abap-37m8k1ec.js")},{id:"actionscript-3",name:"ActionScript",aliases:["actionscript","as3"],import:()=>import("./actionscript-3-n586vqk1.js")},{id:"ada",name:"Ada",import:()=>import("./ada-v0kw2293.js")},{id:"ahk",name:"AutoHotkey",aliases:["ahk1"],import:()=>import("./ahk-9r99qttb.js")},{id:"ahk2",name:"AutoHotkey2",import:()=>import("./ahk2-zf55ztys.js")},{id:"angular-html",name:"Angular HTML",import:()=>import("./angular-html-kv9gdfx2.js")},{id:"angular-ts",name:"Angular TypeScript",import:()=>import("./angular-ts-keppeh1h.js")},{id:"apache",name:"Apache Conf",import:()=>import("./apache-4v6bayjm.js")},{id:"apex",name:"Apex",import:()=>import("./apex-e7qd8eak.js")},{id:"apl",name:"APL",import:()=>import("./apl-gx9k013t.js")},{id:"applescript",name:"AppleScript",import:()=>import("./applescript-5c6hhda4.js")},{id:"ara",name:"Ara",import:()=>import("./ara-yz6s07xr.js")},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:()=>import("./asciidoc-g34hsq0b.js")},{id:"asm",name:"Assembly",import:()=>import("./asm-d0xrkzc6.js")},{id:"astro",name:"Astro",import:()=>import("./astro-axfx2dwc.js")},{id:"awk",name:"AWK",import:()=>import("./awk-hr43qkge.js")},{id:"ballerina",name:"Ballerina",import:()=>import("./ballerina-qf8n2afr.js")},{id:"bat",name:"Batch File",aliases:["batch","cmd"],import:()=>import("./bat-tvqjs4qg.js")},{id:"beancount",name:"Beancount",import:()=>import("./beancount-rjbxrtqa.js")},{id:"berry",name:"Berry",aliases:["be"],import:()=>import("./berry-mne8afdm.js")},{id:"bibtex",name:"BibTeX",import:()=>import("./bibtex-1a8tpckh.js")},{id:"bicep",name:"Bicep",import:()=>import("./bicep-evx2z4e8.js")},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:()=>import("./bird2-92vp70tt.js")},{id:"blade",name:"Blade",import:()=>import("./blade-8ztgkb7f.js")},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:()=>import("./bsl-6zj38j1e.js")},{id:"c",name:"C",import:()=>import("./c-8xqp48d5.js")},{id:"c3",name:"C3",import:()=>import("./c3-c92e602v.js")},{id:"cadence",name:"Cadence",aliases:["cdc"],import:()=>import("./cadence-a36vzekc.js")},{id:"cairo",name:"Cairo",import:()=>import("./cairo-eb6safc8.js")},{id:"chapel",name:"Chapel",aliases:["chpl"],import:()=>import("./chapel-ar2268s7.js")},{id:"clarity",name:"Clarity",import:()=>import("./clarity-zf60e2j2.js")},{id:"clojure",name:"Clojure",aliases:["clj"],import:()=>import("./clojure-887d1e1x.js")},{id:"cmake",name:"CMake",import:()=>import("./cmake-57kpn13k.js")},{id:"cobol",name:"COBOL",import:()=>import("./cobol-sa1635qf.js")},{id:"codeowners",name:"CODEOWNERS",import:()=>import("./codeowners-fh934x1t.js")},{id:"codeql",name:"CodeQL",aliases:["ql"],import:()=>import("./codeql-va3jby28.js")},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:()=>import("./coffee-8136cr62.js")},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:()=>import("./common-lisp-00wv3fh8.js")},{id:"coq",name:"Rocq",import:()=>import("./coq-b3a6w5bc.js")},{id:"cpp",name:"C++",aliases:["c++"],import:()=>import("./cpp-a43bjfgc.js")},{id:"crystal",name:"Crystal",import:()=>import("./crystal-s9vexq9g.js")},{id:"csharp",name:"C#",aliases:["c#","cs"],import:()=>import("./csharp-hdxbv9a9.js")},{id:"css",name:"CSS",import:()=>import("./css-yqycp94s.js")},{id:"csv",name:"CSV",import:()=>import("./csv-vyt11en5.js")},{id:"cue",name:"CUE",import:()=>import("./cue-08m83p37.js")},{id:"cypher",name:"Cypher",aliases:["cql"],import:()=>import("./cypher-v1jcw5fh.js")},{id:"d",name:"D",import:()=>import("./d-e529x4sm.js")},{id:"dart",name:"Dart",import:()=>import("./dart-hk8rmm39.js")},{id:"dax",name:"DAX",import:()=>import("./dax-qz31wras.js")},{id:"desktop",name:"Desktop",import:()=>import("./desktop-b4y70ke9.js")},{id:"diff",name:"Diff",import:()=>import("./diff-ep27k8fw.js")},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:()=>import("./docker-rcmk5ma2.js")},{id:"dotenv",name:"dotEnv",import:()=>import("./dotenv-vec5mamj.js")},{id:"dream-maker",name:"Dream Maker",import:()=>import("./dream-maker-6vr9fy8n.js")},{id:"edge",name:"Edge",import:()=>import("./edge-gc4817bf.js")},{id:"elixir",name:"Elixir",import:()=>import("./elixir-gq7mpq9w.js")},{id:"elm",name:"Elm",import:()=>import("./elm-1j0csrmm.js")},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:()=>import("./emacs-lisp-eg0jfvw2.js")},{id:"erb",name:"ERB",import:()=>import("./erb-x3fzkywy.js")},{id:"erlang",name:"Erlang",aliases:["erl"],import:()=>import("./erlang-jmc1stgg.js")},{id:"fennel",name:"Fennel",import:()=>import("./fennel-s8wmfc8s.js")},{id:"fish",name:"Fish",import:()=>import("./fish-dfn8bm4m.js")},{id:"fluent",name:"Fluent",aliases:["ftl"],import:()=>import("./fluent-r16tj7sx.js")},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:()=>import("./fortran-fixed-form-sv8wqvzh.js")},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:()=>import("./fortran-free-form-3hgcgxwg.js")},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:()=>import("./fsharp-zw1bjtaf.js")},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:()=>import("./gdresource-vdfqv4hv.js")},{id:"gdscript",name:"GDScript",aliases:["gd"],import:()=>import("./gdscript-wx8h0589.js")},{id:"gdshader",name:"GDShader",import:()=>import("./gdshader-68h3wsc3.js")},{id:"genie",name:"Genie",import:()=>import("./genie-ks4dnr15.js")},{id:"gherkin",name:"Gherkin",import:()=>import("./gherkin-ha552g2d.js")},{id:"git-commit",name:"Git Commit Message",import:()=>import("./git-commit-s1t474nk.js")},{id:"git-rebase",name:"Git Rebase Message",import:()=>import("./git-rebase-2x9tcy50.js")},{id:"gleam",name:"Gleam",import:()=>import("./gleam-775tda2q.js")},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:()=>import("./glimmer-js-82d7ga5f.js")},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:()=>import("./glimmer-ts-x63pcyb9.js")},{id:"glsl",name:"GLSL",import:()=>import("./glsl-dd0ny3vj.js")},{id:"gn",name:"GN",import:()=>import("./gn-drgd8tqk.js")},{id:"gnuplot",name:"Gnuplot",import:()=>import("./gnuplot-0rhp27c5.js")},{id:"go",name:"Go",import:()=>import("./go-d36pkndb.js")},{id:"graphql",name:"GraphQL",aliases:["gql"],import:()=>import("./graphql-af70d7rf.js")},{id:"groovy",name:"Groovy",import:()=>import("./groovy-1btmbca0.js")},{id:"hack",name:"Hack",import:()=>import("./hack-fg23bx96.js")},{id:"haml",name:"Ruby Haml",import:()=>import("./haml-k0j6f2e1.js")},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:()=>import("./handlebars-88ngzyjf.js")},{id:"haskell",name:"Haskell",aliases:["hs"],import:()=>import("./haskell-q53cwazc.js")},{id:"haxe",name:"Haxe",import:()=>import("./haxe-yayte2fd.js")},{id:"hcl",name:"HashiCorp HCL",import:()=>import("./hcl-hnh4hm4w.js")},{id:"hjson",name:"Hjson",import:()=>import("./hjson-8aw9mzqe.js")},{id:"hlsl",name:"HLSL",import:()=>import("./hlsl-cdkxcw4v.js")},{id:"html",name:"HTML",import:()=>import("./html-xwjgwct9.js")},{id:"html-derivative",name:"HTML (Derivative)",import:()=>import("./html-derivative-jzw9h4sb.js")},{id:"http",name:"HTTP",import:()=>import("./http-jmywyq30.js")},{id:"hurl",name:"Hurl",import:()=>import("./hurl-84djmb3v.js")},{id:"hxml",name:"HXML",import:()=>import("./hxml-7vd5wkqb.js")},{id:"hy",name:"Hy",import:()=>import("./hy-s26y0h11.js")},{id:"imba",name:"Imba",import:()=>import("./imba-7x38tp3g.js")},{id:"ini",name:"INI",aliases:["properties"],import:()=>import("./ini-wwj497bd.js")},{id:"java",name:"Java",import:()=>import("./java-qhn9cnec.js")},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:()=>import("./javascript-nnj4psw2.js")},{id:"jinja",name:"Jinja",import:()=>import("./jinja-czj082f2.js")},{id:"jison",name:"Jison",import:()=>import("./jison-kv24rt0q.js")},{id:"json",name:"JSON",import:()=>import("./json-0rje0de7.js")},{id:"json5",name:"JSON5",import:()=>import("./json5-ev0pv4wp.js")},{id:"jsonc",name:"JSON with Comments",import:()=>import("./jsonc-c4370yyr.js")},{id:"jsonl",name:"JSON Lines",import:()=>import("./jsonl-m9zc20xa.js")},{id:"jsonnet",name:"Jsonnet",import:()=>import("./jsonnet-e15qnnm2.js")},{id:"jssm",name:"JSSM",aliases:["fsl"],import:()=>import("./jssm-jmddbjy9.js")},{id:"jsx",name:"JSX",import:()=>import("./jsx-w8d0cm0a.js")},{id:"julia",name:"Julia",aliases:["jl"],import:()=>import("./julia-pfs2n4wr.js")},{id:"just",name:"Just",aliases:["justfile"],import:()=>import("./just-3qxt7w30.js")},{id:"kdl",name:"KDL",import:()=>import("./kdl-rytfnhc2.js")},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:()=>import("./kotlin-5bm8qh36.js")},{id:"kusto",name:"Kusto",aliases:["kql"],import:()=>import("./kusto-1jvn4kfn.js")},{id:"latex",name:"LaTeX",import:()=>import("./latex-25xjj37d.js")},{id:"lean",name:"Lean 4",aliases:["lean4"],import:()=>import("./lean-yey9ct91.js")},{id:"less",name:"Less",import:()=>import("./less-hmpk8q7h.js")},{id:"liquid",name:"Liquid",import:()=>import("./liquid-68rn6mg0.js")},{id:"llvm",name:"LLVM IR",import:()=>import("./llvm-aytmzfxk.js")},{id:"log",name:"Log file",import:()=>import("./log-x9fxkda3.js")},{id:"logo",name:"Logo",import:()=>import("./logo-954dz0fv.js")},{id:"lua",name:"Lua",import:()=>import("./lua-5mg6z41k.js")},{id:"luau",name:"Luau",import:()=>import("./luau-a2f57ery.js")},{id:"make",name:"Makefile",aliases:["makefile"],import:()=>import("./make-n47q2r30.js")},{id:"markdown",name:"Markdown",aliases:["md"],import:()=>import("./markdown-pdjapk97.js")},{id:"marko",name:"Marko",import:()=>import("./marko-avh3r0r7.js")},{id:"matlab",name:"MATLAB",import:()=>import("./matlab-grf517hb.js")},{id:"mdc",name:"MDC",import:()=>import("./mdc-w2xeah7f.js")},{id:"mdx",name:"MDX",import:()=>import("./mdx-jthgmdc9.js")},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:()=>import("./mermaid-gjwxzxws.js")},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:()=>import("./mipsasm-vjz9dmbq.js")},{id:"mojo",name:"Mojo",import:()=>import("./mojo-x773m0x3.js")},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:()=>import("./moonbit-n86a5d99.js")},{id:"move",name:"Move",import:()=>import("./move-75v0pk38.js")},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:()=>import("./narrat-yaw9xjvk.js")},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:()=>import("./nextflow-k452sqhf.js")},{id:"nextflow-groovy",name:"Nextflow Groovy",import:()=>import("./nextflow-groovy-srx6sxt8.js")},{id:"nginx",name:"Nginx",import:()=>import("./nginx-65m3tsxt.js")},{id:"nim",name:"Nim",import:()=>import("./nim-3kvk1gm5.js")},{id:"nix",name:"Nix",import:()=>import("./nix-bwp0ftjx.js")},{id:"nsis",name:"NSIS",import:()=>import("./nsis-pf2p1pqq.js")},{id:"nushell",name:"nushell",aliases:["nu"],import:()=>import("./nushell-2ga7e2rp.js")},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:()=>import("./objective-c-df116c38.js")},{id:"objective-cpp",name:"Objective-C++",import:()=>import("./objective-cpp-8m99samw.js")},{id:"ocaml",name:"OCaml",import:()=>import("./ocaml-2tmrnxx8.js")},{id:"odin",name:"Odin",import:()=>import("./odin-8ew89sbm.js")},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:()=>import("./openscad-0qpp8tms.js")},{id:"org",name:"Org Markup",import:()=>import("./org-3jkbxnxe.js")},{id:"pascal",name:"Pascal",import:()=>import("./pascal-t9tmw6mg.js")},{id:"perl",name:"Perl",import:()=>import("./perl-bhkhyh5d.js")},{id:"php",name:"PHP",import:()=>import("./php-9rfj74fc.js")},{id:"pkl",name:"Pkl",import:()=>import("./pkl-1165dchs.js")},{id:"plsql",name:"PL/SQL",import:()=>import("./plsql-naj0n4k8.js")},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:()=>import("./po-fepdn90s.js")},{id:"polar",name:"Polar",import:()=>import("./polar-csz6j8sz.js")},{id:"postcss",name:"PostCSS",import:()=>import("./postcss-zk8djd5p.js")},{id:"powerquery",name:"PowerQuery",import:()=>import("./powerquery-dty2ym0j.js")},{id:"powershell",name:"PowerShell",aliases:["ps","ps1","pwsh"],import:()=>import("./powershell-s2zm86px.js")},{id:"prisma",name:"Prisma",import:()=>import("./prisma-1xsywwsm.js")},{id:"prolog",name:"Prolog",import:()=>import("./prolog-9wxf6gzq.js")},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:()=>import("./proto-kb1st3s4.js")},{id:"pug",name:"Pug",aliases:["jade"],import:()=>import("./pug-rez2g9md.js")},{id:"puppet",name:"Puppet",import:()=>import("./puppet-51d61ef3.js")},{id:"purescript",name:"PureScript",import:()=>import("./purescript-ent5fqsh.js")},{id:"python",name:"Python",aliases:["py"],import:()=>import("./python-xba33008.js")},{id:"qml",name:"QML",import:()=>import("./qml-ecfac92p.js")},{id:"qmldir",name:"QML Directory",import:()=>import("./qmldir-z4dnf3er.js")},{id:"qss",name:"Qt Style Sheets",import:()=>import("./qss-5x7cdqde.js")},{id:"r",name:"R",import:()=>import("./r-dhavk838.js")},{id:"racket",name:"Racket",import:()=>import("./racket-m0rr2sr2.js")},{id:"raku",name:"Raku",aliases:["perl6"],import:()=>import("./raku-qsb9ddmk.js")},{id:"razor",name:"ASP.NET Razor",import:()=>import("./razor-kvnxas87.js")},{id:"rbs",name:"RBS",aliases:["ruby-signature"],import:()=>import("./rbs-rhjg3txf.js")},{id:"reg",name:"Windows Registry Script",import:()=>import("./reg-a0bppknm.js")},{id:"regexp",name:"RegExp",aliases:["regex"],import:()=>import("./regexp-fmz67gn4.js")},{id:"rel",name:"Rel",import:()=>import("./rel-26b830vk.js")},{id:"riscv",name:"RISC-V",import:()=>import("./riscv-vyzz3zzw.js")},{id:"ron",name:"RON",import:()=>import("./ron-359ky2kq.js")},{id:"rosmsg",name:"ROS Interface",import:()=>import("./rosmsg-w65k1nbk.js")},{id:"rst",name:"reStructuredText",import:()=>import("./rst-5bdn1c1j.js")},{id:"ruby",name:"Ruby",aliases:["rb"],import:()=>import("./ruby-gftcg1pk.js")},{id:"rust",name:"Rust",aliases:["rs"],import:()=>import("./rust-sq4f6g9y.js")},{id:"sas",name:"SAS",import:()=>import("./sas-qd9nq299.js")},{id:"sass",name:"Sass",import:()=>import("./sass-2tnh8wwx.js")},{id:"scala",name:"Scala",import:()=>import("./scala-j16eytps.js")},{id:"scheme",name:"Scheme",import:()=>import("./scheme-85ydnecj.js")},{id:"scss",name:"SCSS",import:()=>import("./scss-214pb2ev.js")},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:()=>import("./sdbl-yjgr9s0t.js")},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:()=>import("./shaderlab-9f34hb54.js")},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:()=>import("./shellscript-zsv4e5j0.js")},{id:"shellsession",name:"Shell Session",aliases:["console"],import:()=>import("./shellsession-vw3z7saq.js")},{id:"smalltalk",name:"GNU Smalltalk",import:()=>import("./smalltalk-ykje8je7.js")},{id:"smithy",name:"Smithy",import:()=>import("./smithy-n6n07hva.js")},{id:"solidity",name:"Solidity",import:()=>import("./solidity-cpw98fq4.js")},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:()=>import("./soy-jxsncnd7.js")},{id:"sparql",name:"SPARQL",import:()=>import("./sparql-7rsbch4s.js")},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:()=>import("./splunk-ahrhnqde.js")},{id:"sql",name:"SQL",import:()=>import("./sql-651bw7e4.js")},{id:"ssh-config",name:"SSH Config",import:()=>import("./ssh-config-jqqshx5y.js")},{id:"stata",name:"Stata",import:()=>import("./stata-3j5zc4en.js")},{id:"stylus",name:"Stylus",aliases:["styl"],import:()=>import("./stylus-4hacczez.js")},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:()=>import("./surrealql-bpwpv6hg.js")},{id:"svelte",name:"Svelte",import:()=>import("./svelte-3dbkq6j1.js")},{id:"swift",name:"Swift",import:()=>import("./swift-pq21fbt6.js")},{id:"system-verilog",name:"SystemVerilog",import:()=>import("./system-verilog-bjx146s2.js")},{id:"systemd",name:"Systemd Units",import:()=>import("./systemd-r44qzr4g.js")},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:()=>import("./talonscript-y3x48301.js")},{id:"tasl",name:"Tasl",import:()=>import("./tasl-3nnxpar2.js")},{id:"tcl",name:"Tcl",import:()=>import("./tcl-fmhzgxjx.js")},{id:"templ",name:"Templ",import:()=>import("./templ-x6vt4p4p.js")},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:()=>import("./terraform-v7zcbaqa.js")},{id:"tex",name:"TeX",import:()=>import("./tex-nmj16m3q.js")},{id:"toml",name:"TOML",import:()=>import("./toml-a6gg4eqj.js")},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:()=>import("./ts-tags-s8df9nd9.js")},{id:"tsv",name:"TSV",import:()=>import("./tsv-98armktx.js")},{id:"tsx",name:"TSX",import:()=>import("./tsx-6e9nwp76.js")},{id:"turtle",name:"Turtle",import:()=>import("./turtle-w9cxrxmc.js")},{id:"twig",name:"Twig",import:()=>import("./twig-9zpbpfbc.js")},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:()=>import("./typescript-r25bn51c.js")},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:()=>import("./typespec-8twhvsj0.js")},{id:"typst",name:"Typst",aliases:["typ"],import:()=>import("./typst-tewdnmsd.js")},{id:"v",name:"V",import:()=>import("./v-8950s4xp.js")},{id:"vala",name:"Vala",import:()=>import("./vala-jm0v1b80.js")},{id:"vb",name:"Visual Basic",import:()=>import("./vb-ystyawbc.js")},{id:"verilog",name:"Verilog",import:()=>import("./verilog-gymxq45g.js")},{id:"vhdl",name:"VHDL",import:()=>import("./vhdl-eqvvaqjg.js")},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:()=>import("./viml-nbft5xr9.js")},{id:"vue",name:"Vue",import:()=>import("./vue-42gn5vkg.js")},{id:"vue-html",name:"Vue HTML",import:()=>import("./vue-html-2004vfpd.js")},{id:"vue-vine",name:"Vue Vine",import:()=>import("./vue-vine-ae1x9v8h.js")},{id:"vyper",name:"Vyper",aliases:["vy"],import:()=>import("./vyper-1nkezv4x.js")},{id:"wasm",name:"WebAssembly",import:()=>import("./wasm-t2esg905.js")},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:()=>import("./wenyan-4sm4vf06.js")},{id:"wgsl",name:"WGSL",import:()=>import("./wgsl-tfyxmx9d.js")},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:()=>import("./wikitext-7qxke4yx.js")},{id:"wit",name:"WebAssembly Interface Types",import:()=>import("./wit-cp0rj4jh.js")},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:()=>import("./wolfram-mqv28qsr.js")},{id:"xml",name:"XML",import:()=>import("./xml-5jnb6sqj.js")},{id:"xsl",name:"XSL",import:()=>import("./xsl-hde8are0.js")},{id:"yaml",name:"YAML",aliases:["yml"],import:()=>import("./yaml-4j71mjzp.js")},{id:"zenscript",name:"ZenScript",import:()=>import("./zenscript-83k18fya.js")},{id:"zig",name:"Zig",import:()=>import("./zig-te4p6btc.js")}],Xm=Object.fromEntries(iu.map((e)=>[e.id,e.import])),Ym=Object.fromEntries(iu.flatMap((e)=>e.aliases?.map((t)=>[t,e.import])||[])),$o={...Xm,...Ym};var ef={};Ut(ef,{createOnigurumaEngine:()=>lu,getDefaultWasmLoader:()=>yM,loadWasm:()=>Qm,setDefaultWasmLoader:()=>gM});var Zm=class extends Error{constructor(e){super(e);this.name="ShikiError"}};function nM(){return 2147483648}function rM(){return typeof performance<"u"?performance.now():Date.now()}var iM=(e,t)=>e+(t-e%t)%t;async function oM(e){let t,n,r={};function i(h){n=h,r.HEAPU8=new Uint8Array(h),r.HEAPU32=new Uint32Array(h)}function o(h,x,I){r.HEAPU8.copyWithin(h,x,x+I)}function s(h){try{return t.grow(h-n.byteLength+65535>>>16),i(t.buffer),1}catch{}}function a(h){let x=r.HEAPU8.length;h=h>>>0;let I=nM();if(h>I)return!1;for(let v=1;v<=4;v*=2){let S=x*(1+0.2/v);S=Math.min(S,h+100663296);let b=Math.min(I,iM(Math.max(h,S),65536));if(s(b))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function d(h,x,I=1024){let v=x+I,S=x;while(h[S]&&!(S>=v))++S;if(S-x>16&&h.buffer&&l)return l.decode(h.subarray(x,S));let b="";while(x<S){let E=h[x++];if(!(E&128)){b+=String.fromCharCode(E);continue}let w=h[x++]&63;if((E&224)===192){b+=String.fromCharCode((E&31)<<6|w);continue}let k=h[x++]&63;if((E&240)===224)E=(E&15)<<12|w<<6|k;else E=(E&7)<<18|w<<12|k<<6|h[x++]&63;if(E<65536)b+=String.fromCharCode(E);else{let L=E-65536;b+=String.fromCharCode(55296|L>>10,56320|L&1023)}}return b}function c(h,x){return h?d(r.HEAPU8,h,x):""}let m={emscripten_get_now:rM,emscripten_memcpy_big:o,emscripten_resize_heap:a,fd_write:()=>0};async function p(){let x=await e({env:m,wasi_snapshot_preview1:m});t=x.memory,i(t.buffer),Object.assign(r,x),r.UTF8ToString=c}return await p(),r}var sM=Object.defineProperty,aM=(e,t,n)=>(t in e)?sM(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Et=(e,t,n)=>aM(e,typeof t!=="symbol"?t+"":t,n),At=null;function lM(e){throw new Zm(e.UTF8ToString(e.getLastOnigError()))}class su{constructor(e){Et(this,"utf16Length"),Et(this,"utf8Length"),Et(this,"utf16Value"),Et(this,"utf8Value"),Et(this,"utf16OffsetToUtf8"),Et(this,"utf8OffsetToUtf16");let t=e.length,n=su._utf8ByteLength(e),r=n!==t,i=r?new Uint32Array(t+1):null;if(r)i[t]=n;let o=r?new Uint32Array(n+1):null;if(r)o[n]=t;let s=new Uint8Array(n),a=0;for(let l=0;l<t;l++){let d=e.charCodeAt(l),c=d,m=!1;if(d>=55296&&d<=56319){if(l+1<t){let p=e.charCodeAt(l+1);if(p>=56320&&p<=57343)c=(d-55296<<10)+65536|p-56320,m=!0}}if(r){if(i[l]=a,m)i[l+1]=a;if(c<=127)o[a+0]=l;else if(c<=2047)o[a+0]=l,o[a+1]=l;else if(c<=65535)o[a+0]=l,o[a+1]=l,o[a+2]=l;else o[a+0]=l,o[a+1]=l,o[a+2]=l,o[a+3]=l}if(c<=127)s[a++]=c;else if(c<=2047)s[a++]=192|(c&1984)>>>6,s[a++]=128|(c&63)>>>0;else if(c<=65535)s[a++]=224|(c&61440)>>>12,s[a++]=128|(c&4032)>>>6,s[a++]=128|(c&63)>>>0;else s[a++]=240|(c&1835008)>>>18,s[a++]=128|(c&258048)>>>12,s[a++]=128|(c&4032)>>>6,s[a++]=128|(c&63)>>>0;if(m)l++}this.utf16Length=t,this.utf8Length=n,this.utf16Value=e,this.utf8Value=s,this.utf16OffsetToUtf8=i,this.utf8OffsetToUtf16=o}static _utf8ByteLength(e){let t=0;for(let n=0,r=e.length;n<r;n++){let i=e.charCodeAt(n),o=i,s=!1;if(i>=55296&&i<=56319){if(n+1<r){let a=e.charCodeAt(n+1);if(a>=56320&&a<=57343)o=(i-55296<<10)+65536|a-56320,s=!0}}if(o<=127)t+=1;else if(o<=2047)t+=2;else if(o<=65535)t+=3;else t+=4;if(s)n++}return t}createString(e){let t=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,t),t}}var au=class e{constructor(t){if(Et(this,"id",++e.LAST_ID),Et(this,"_onigBinding"),Et(this,"content"),Et(this,"utf16Length"),Et(this,"utf8Length"),Et(this,"utf16OffsetToUtf8"),Et(this,"utf8OffsetToUtf16"),Et(this,"ptr"),!At)throw new Zm("Must invoke loadWasm first.");this._onigBinding=At,this.content=t;let n=new su(t);if(this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!e._sharedPtrInUse){if(!e._sharedPtr)e._sharedPtr=At.omalloc(1e4);e._sharedPtrInUse=!0,At.HEAPU8.set(n.utf8Value,e._sharedPtr),this.ptr=e._sharedPtr}else this.ptr=n.createString(At)}convertUtf8OffsetToUtf16(t){if(this.utf8OffsetToUtf16){if(t<0)return 0;if(t>this.utf8Length)return this.utf16Length;return this.utf8OffsetToUtf16[t]}return t}convertUtf16OffsetToUtf8(t){if(this.utf16OffsetToUtf8){if(t<0)return 0;if(t>this.utf16Length)return this.utf8Length;return this.utf16OffsetToUtf8[t]}return t}dispose(){if(this.ptr===e._sharedPtr)e._sharedPtrInUse=!1;else this._onigBinding.ofree(this.ptr)}};Et(au,"LAST_ID",0);Et(au,"_sharedPtr",0);Et(au,"_sharedPtrInUse",!1);var Ey=au;class vy{constructor(e){if(Et(this,"_onigBinding"),Et(this,"_ptr"),!At)throw new Zm("Must invoke loadWasm first.");let t=[],n=[];for(let s=0,a=e.length;s<a;s++){let l=new su(e[s]);t[s]=l.createString(At),n[s]=l.utf8Length}let r=At.omalloc(4*e.length);At.HEAPU32.set(t,r/4);let i=At.omalloc(4*e.length);At.HEAPU32.set(n,i/4);let o=At.createOnigScanner(r,i,e.length);for(let s=0,a=e.length;s<a;s++)At.ofree(t[s]);if(At.ofree(i),At.ofree(r),o===0)lM(At);this._onigBinding=At,this._ptr=o}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,t,n){let r=0;if(typeof n==="number")r=n;if(typeof e==="string"){e=new Ey(e);let i=this._findNextMatchSync(e,t,!1,r);return e.dispose(),i}return this._findNextMatchSync(e,t,!1,r)}_findNextMatchSync(e,t,n,r){let i=this._onigBinding,o=i.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(t),r);if(o===0)return null;let s=i.HEAPU32,a=o/4,l=s[a++],d=s[a++],c=[];for(let m=0;m<d;m++){let p=e.convertUtf8OffsetToUtf16(s[a++]),h=e.convertUtf8OffsetToUtf16(s[a++]);c[m]={start:p,end:h,length:h-p}}return{index:l,captureIndices:c}}}function uM(e){return typeof e.instantiator==="function"}function dM(e){return typeof e.default==="function"}function cM(e){return typeof e.data<"u"}function mM(e){return typeof Response<"u"&&e instanceof Response}function fM(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 ou;function Qm(e){if(ou)return ou;async function t(){At=await oM(async(n)=>{let r=e;if(r=await r,typeof r==="function")r=await r(n);if(typeof r==="function")r=await r(n);if(uM(r))r=await r.instantiator(n);else if(dM(r))r=await r.default(n);else{if(cM(r))r=r.data;if(mM(r))if(typeof WebAssembly.instantiateStreaming==="function")r=await pM(r)(n);else r=await hM(r)(n);else if(fM(r))r=await Jm(r)(n);else if(r instanceof WebAssembly.Module)r=await Jm(r)(n);else if("default"in r&&r.default instanceof WebAssembly.Module)r=await Jm(r.default)(n)}if("instance"in r)r=r.instance;if("exports"in r)r=r.exports;return r})}return ou=t(),ou}function Jm(e){return(t)=>WebAssembly.instantiate(e,t)}function pM(e){return(t)=>WebAssembly.instantiateStreaming(e,t)}function hM(e){return async(t)=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var Ty;function gM(e){Ty=e}function yM(){return Ty}async function lu(e){if(e)await Qm(e);return{createScanner(t){return new vy(t.map((n)=>typeof n==="string"?n:n.source))},createString(t){return new Ey(t)}}}var tf=Ig({});Sg(tf,ef);var ky=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:()=>import("./andromeeda-tsp924my.js")},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:()=>import("./aurora-x-ba9r2etj.js")},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:()=>import("./ayu-dark-1vqjtzry.js")},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:()=>import("./ayu-light-hyc4fc7y.js")},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:()=>import("./ayu-mirage-exvkv8da.js")},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:()=>import("./catppuccin-frappe-0rvsggsb.js")},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:()=>import("./catppuccin-latte-av89afca.js")},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:()=>import("./catppuccin-macchiato-dqe3mbw1.js")},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:()=>import("./catppuccin-mocha-2w1wgn9v.js")},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:()=>import("./dark-plus-0be7zfjq.js")},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:()=>import("./dracula-kyzb58xf.js")},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:()=>import("./dracula-soft-4ah05qcy.js")},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:()=>import("./everforest-dark-x2sxpmaz.js")},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:()=>import("./everforest-light-9xkh4gqx.js")},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:()=>import("./github-dark-xzmxhvr4.js")},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:()=>import("./github-dark-default-sa857k56.js")},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:()=>import("./github-dark-dimmed-ekh4tbqg.js")},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:()=>import("./github-dark-high-contrast-5xp9g18c.js")},{id:"github-light",displayName:"GitHub Light",type:"light",import:()=>import("./github-light-2q28m6c1.js")},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:()=>import("./github-light-default-ywc9b32r.js")},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:()=>import("./github-light-high-contrast-9hy4thhf.js")},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:()=>import("./gruvbox-dark-hard-h6rfjf9q.js")},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:()=>import("./gruvbox-dark-medium-gdwaw20e.js")},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:()=>import("./gruvbox-dark-soft-sq5yvaag.js")},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:()=>import("./gruvbox-light-hard-nym0hnh4.js")},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:()=>import("./gruvbox-light-medium-9kgrswjt.js")},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:()=>import("./gruvbox-light-soft-618vpmvg.js")},{id:"horizon",displayName:"Horizon",type:"dark",import:()=>import("./horizon-5e2be4sx.js")},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:()=>import("./horizon-bright-0hrqkmhs.js")},{id:"houston",displayName:"Houston",type:"dark",import:()=>import("./houston-wzd0npbc.js")},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:()=>import("./kanagawa-dragon-hec3nmvm.js")},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:()=>import("./kanagawa-lotus-eg9aja7s.js")},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:()=>import("./kanagawa-wave-314f45f0.js")},{id:"laserwave",displayName:"LaserWave",type:"dark",import:()=>import("./laserwave-wz1f76zd.js")},{id:"light-plus",displayName:"Light Plus",type:"light",import:()=>import("./light-plus-43gmczhw.js")},{id:"material-theme",displayName:"Material Theme",type:"dark",import:()=>import("./material-theme-bqcfs89x.js")},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:()=>import("./material-theme-darker-gger3t82.js")},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:()=>import("./material-theme-lighter-evaye4z3.js")},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:()=>import("./material-theme-ocean-h7m9f34k.js")},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:()=>import("./material-theme-palenight-tyeannba.js")},{id:"min-dark",displayName:"Min Dark",type:"dark",import:()=>import("./min-dark-kcpraaxv.js")},{id:"min-light",displayName:"Min Light",type:"light",import:()=>import("./min-light-w5gbrkp8.js")},{id:"monokai",displayName:"Monokai",type:"dark",import:()=>import("./monokai-nbvd076q.js")},{id:"night-owl",displayName:"Night Owl",type:"dark",import:()=>import("./night-owl-kk2p0vc0.js")},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:()=>import("./night-owl-light-hq9zzwqt.js")},{id:"nord",displayName:"Nord",type:"dark",import:()=>import("./nord-c0ea2g04.js")},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:()=>import("./one-dark-pro-t9a3593x.js")},{id:"one-light",displayName:"One Light",type:"light",import:()=>import("./one-light-aar5vy7j.js")},{id:"plastic",displayName:"Plastic",type:"dark",import:()=>import("./plastic-0tmrj0c8.js")},{id:"poimandres",displayName:"Poimandres",type:"dark",import:()=>import("./poimandres-hmgg59te.js")},{id:"red",displayName:"Red",type:"dark",import:()=>import("./red-0knjvcyd.js")},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:()=>import("./rose-pine-v63jc1jc.js")},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:()=>import("./rose-pine-dawn-a079aeh5.js")},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:()=>import("./rose-pine-moon-axp18ha5.js")},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:()=>import("./slack-dark-n2f4xt4t.js")},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:()=>import("./slack-ochin-ag40mqdq.js")},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:()=>import("./snazzy-light-g9qtd34v.js")},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:()=>import("./solarized-dark-cpesrcas.js")},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:()=>import("./solarized-light-ar205sc0.js")},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:()=>import("./synthwave-84-n8bwkyqe.js")},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:()=>import("./tokyo-night-rcm4pka3.js")},{id:"vesper",displayName:"Vesper",type:"dark",import:()=>import("./vesper-dctcmpqx.js")},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:()=>import("./vitesse-black-jpzvzek5.js")},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:()=>import("./vitesse-dark-6067ajvh.js")},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:()=>import("./vitesse-light-tz4hqyp9.js")}],wy=Object.fromEntries(ky.map((e)=>[e.id,e.import]));var nf=gy({langs:$o,themes:wy,engine:()=>(0,tf.createOnigurumaEngine)(import("./wasm-8yvsdhkk.js"))});var Ly=class{patterns;options;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((o)=>{if(typeof o!=="string")return o;let s=r?.get(o);if(s){if(s instanceof RegExp)return s;if(n)return null;throw s}try{let a=i(o);return r?.set(o,a),a}catch(a){if(r?.set(o,a),n)return null;throw a}})}findNextMatchSync(e,t,n){let r=typeof e==="string"?e:e.content,i=[];function o(s,a,l=0){return{index:s,captureIndices:a.indices.map((d)=>{if(d==null)return{start:4294967295,end:4294967295,length:0};return{start:d[0]+l,end:d[1]+l,length:d[1]-d[0]}})}}for(let s=0;s<this.regexps.length;s++){let a=this.regexps[s];if(!a)continue;try{a.lastIndex=t;let l=a.exec(r);if(!l)continue;if(l.index===t)return o(s,l,0);i.push([s,l,0])}catch(l){if(this.options.forgiving)continue;throw l}}if(i.length){let s=Math.min(...i.map((a)=>a[1].index));for(let[a,l,d]of i)if(l.index===s)return o(a,l,d)}return null}};function ri(e){if([...e].length!==1)throw Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function Ry(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var Ws=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),yt=String.raw;function Pr(e,t){if(e==null)throw Error(t??"Value expected");return e}var Fy=yt`\[\^?`,Ny=`c.? | C(?:-.?)?|${yt`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${yt`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${yt`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${yt`o\{[^\}]*\}?`}|${yt`\d{1,3}`}`,of=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,uu=new RegExp(yt`
|
|
9
|
+
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\x00&'".split(""),"\x00\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\x00"&'.split(""),"\x00\"&'`".split("")]]};function ay(e,t,n,r){let i=r.schema,o=i.space==="svg"?!1:r.settings.omitOptionalTags,s=i.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),a=[],l;if(i.space==="html"&&e.tagName==="svg")r.schema=zl;let d=a$(r,e.properties),c=r.all(i.space==="html"&&e.tagName==="template"?e.content:e);if(r.schema=i,c)s=!1;if(d||!o||!sy(e,t,n)){if(a.push("<",e.tagName,d?" "+d:""),s&&(i.space==="svg"||r.settings.closeSelfClosing)){if(l=d.charAt(d.length-1),!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")a.push(" ");a.push("/")}a.push(">")}if(a.push(c),!s&&(!o||!Ws(e,t,n)))a.push("</"+e.tagName+">");return a.join("")}function a$(e,t){let n=[],r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){let o=l$(e,i,t[i]);if(o)n.push(o)}}while(++r<n.length){let o=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;if(r!==n.length-1&&o!=='"'&&o!=="'")n[r]+=" "}return n.join("")}function l$(e,t,n){let r=Um(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,o=e.settings.allowDangerousCharacters?0:1,s=e.quote,a;if(r.overloadedBoolean&&(n===r.attribute||n===""))n=!0;else if((r.boolean||r.overloadedBoolean)&&(typeof n!=="string"||n===r.attribute||n===""))n=Boolean(n);if(n===null||n===void 0||n===!1||typeof n==="number"&&Number.isNaN(n))return"";let l=Ar(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Xl.name[i][o]}));if(n===!0)return l;if(n=Array.isArray(n)?(r.commaSeparated?ey:ty)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)return l;if(e.settings.preferUnquoted)a=Ar(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Xl.unquoted[i][o]}));if(a!==n){if(e.settings.quoteSmart&&Gm(n,s)>Gm(n,e.alternative))s=e.alternative;a=s+Ar(n,Object.assign({},e.settings.characterReferences,{subset:(s==="'"?Xl.single:Xl.double)[i][o],attribute:!0}))+s}return l+(a?"="+a:a)}var u$=["<","&"];function Yl(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Ar(e.value,Object.assign({},r.settings.characterReferences,{subset:u$}))}function ly(e,t,n,r){return r.settings.allowDangerousHtml?e.value:Yl(e,t,n,r)}function uy(e,t,n,r){return r.all(e)}var dy=Gg("type",{invalid:d$,unknown:c$,handlers:{comment:Zg,doctype:Qg,element:ay,raw:ly,root:uy,text:Yl}});function d$(e){throw Error("Expected node, not `"+e+"`")}function c$(e){throw Error("Cannot compile unknown node `"+e.type+"`")}var m$={},f$={},p$=[];function ut(e,t){let n=t||m$,r=n.quote||'"',i=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:h$,all:g$,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||Fg,characterReferences:n.characterReferences||f$,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?zl:Ug,quote:r,alternative:i}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function h$(e,t,n){return dy(e,t,n,this)}function g$(e){let t=[],n=e&&e.children||p$,r=-1;while(++r<n.length)t[r]=this.one(n[r],r,e);return t.join("")}var cy=/\s+/g;function py(e,t){if(!t)return e;if(e.properties||={},e.properties.class||=[],typeof e.properties.class==="string")e.properties.class=e.properties.class.split(cy);if(!Array.isArray(e.properties.class))e.properties.class=[];let n=Array.isArray(t)?t:t.split(cy);for(let r of n)if(r&&!e.properties.class.includes(r))e.properties.class.push(r);return e}var y$=/:?lang=["']([^"']+)["']/g,x$=/(?:```|~~~)([\w-]+)/g,I$=/\\begin\{([\w-]+)\}/g,S$=/<script\s+(?:type|lang)=["']([^"']+)["']/gi,b$=/^\s*---\r?\n[\s\S]*?\r?\n---(?:\r?\n|\s*$)/;function C$(e){let t=Lo(e,!0).map(([i])=>i);function n(i){if(i===e.length)return{line:t.length-1,character:t.at(-1).length};let o=i,s=0;for(let a of t){if(o<a.length)break;o-=a.length,s++}return{line:s,character:o}}function r(i,o){let s=0;for(let a=0;a<i;a++)s+=t[a].length;return s+=o,s}return{lines:t,indexToPos:n,posToIndex:r}}function hy(e,t,n){let r=new Set;for(let o of e.matchAll(y$)){let s=o[1].toLowerCase().trim();if(s)r.add(s)}for(let o of e.matchAll(x$)){let s=o[1].toLowerCase().trim();if(s)r.add(s)}for(let o of e.matchAll(I$)){let s=o[1].toLowerCase().trim();if(s)r.add(s)}for(let o of e.matchAll(S$)){let s=o[1].toLowerCase().trim(),a=s.includes("/")?s.split("/").pop():s;if(a)r.add(a)}if(b$.test(e))r.add("yaml");if(!n)return[...r];let i=n.getBundledLanguages();return[...r].filter((o)=>o&&i[o])}var E$=["color","background-color"];function v$(e,t){let n=0,r=[];for(let i of t){if(i>n)r.push({...e,content:e.content.slice(n,i),offset:e.offset+n});n=i}if(n<e.content.length)r.push({...e,content:e.content.slice(n),offset:e.offset+n});return r}function k$(e,t){let n=0,r=e.length;while(n<r){let i=n+(r-n>>1);if(e[i]<=t)n=i+1;else r=i}return n}function T$(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((r,i)=>r-i);if(!n.length)return e;return e.map((r)=>r.flatMap((i)=>{let o=i.offset+i.content.length,s=k$(n,i.offset),a=s;while(a<n.length&&n[a]<o)a++;if(s===a)return i;let l=n.slice(s,a);for(let d=0;d<l.length;d++)l[d]-=i.offset;return v$(i,l)}))}function w$(e,t,n,r,i="css-vars"){let o={content:e.content,explanation:e.explanation,offset:e.offset},s=t.map((c)=>Jl(e.variants[c])),a=new Set(s.flatMap((c)=>Object.keys(c))),l={},d=(c,m)=>{let p=m==="color"?"":m==="background-color"?"-bg":`-${m}`;return n+t[c]+(m==="color"?"":p)};return s.forEach((c,m)=>{for(let p of a){let h=c[p]||"inherit";if(m===0&&r&&E$.includes(p))if(r==="light-dark()"&&s.length>1){let x=t.findIndex((b)=>b==="light"),I=t.findIndex((b)=>b==="dark");if(x===-1||I===-1)throw new we('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let v=s[x][p]||"inherit",S=s[I][p]||"inherit";if(l[p]=`light-dark(${v}, ${S})`,i==="css-vars")l[d(m,p)]=h}else l[p]=h;else if(i==="css-vars")l[d(m,p)]=h}}),o.htmlStyle=l,o}function Jl(e){let t={};if(e.color)t.color=e.color;if(e.bgColor)t["background-color"]=e.bgColor;if(e.fontStyle){if(e.fontStyle&Gt.Italic)t["font-style"]="italic";if(e.fontStyle&Gt.Bold)t["font-weight"]="bold";let n=[];if(e.fontStyle&Gt.Underline)n.push("underline");if(e.fontStyle&Gt.Strikethrough)n.push("line-through");if(n.length)t["text-decoration"]=n.join(" ")}return t}function Km(e){if(typeof e==="string")return e;return Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function L$(){let e=new WeakMap;function t(n){if(!e.has(n.meta)){let i=function(s){if(typeof s==="number"){if(s<0||s>n.source.length)throw new we(`Invalid decoration offset: ${s}. Code length: ${n.source.length}`);return{...r.indexToPos(s),offset:s}}else{let a=r.lines[s.line];if(a===void 0)throw new we(`Invalid decoration position ${JSON.stringify(s)}. Lines length: ${r.lines.length}`);let l=s.character;if(l<0)l=a.length+l;if(l<0||l>a.length)throw new we(`Invalid decoration position ${JSON.stringify(s)}. Line ${s.line} length: ${a.length}`);return{...s,character:l,offset:r.posToIndex(s.line,l)}}},r=C$(n.source),o=(n.options.decorations||[]).map((s)=>({...s,start:i(s.start),end:i(s.end)}));R$(o),e.set(n.meta,{decorations:o,converter:r,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(!this.options.decorations?.length)return;return T$(n,t(this).decorations.flatMap((r)=>[r.start.offset,r.end.offset]))},code(n){if(!this.options.decorations?.length)return;let r=t(this),i=[...n.children].filter((c)=>c.type==="element"&&c.tagName==="span");if(i.length!==r.converter.lines.length)throw new we(`Number of lines in code element (${i.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function o(c,m,p,h){let x=i[c],I="",v=-1,S=-1;if(m===0)v=0;if(p===0)S=0;if(p===Number.POSITIVE_INFINITY)S=x.children.length;if(v===-1||S===-1)for(let E=0;E<x.children.length;E++){if(I+=gy(x.children[E]),v===-1&&I.length===m)v=E+1;if(S===-1&&I.length===p)S=E+1}if(v===-1)throw new we(`Failed to find start index for decoration ${JSON.stringify(h.start)}`);if(S===-1)throw new we(`Failed to find end index for decoration ${JSON.stringify(h.end)}`);let b=x.children.slice(v,S);if(!h.alwaysWrap&&b.length===x.children.length)a(x,h,"line");else if(!h.alwaysWrap&&b.length===1&&b[0].type==="element")a(b[0],h,"token");else{let E={type:"element",tagName:"span",properties:{},children:b};a(E,h,"wrapper"),x.children.splice(v,b.length,E)}}function s(c,m){i[c]=a(i[c],m,"line")}function a(c,m,p){let h=m.properties||{},x=m.transform||((I)=>I);if(c.tagName=m.tagName||"span",c.properties={...c.properties,...h,class:c.properties.class},m.properties?.class)py(c,m.properties.class);return c=x(c,p)||c,c}let l=[],d=r.decorations.sort((c,m)=>m.start.offset-c.start.offset||c.end.offset-m.end.offset);for(let c of d){let{start:m,end:p}=c;if(m.line===p.line)o(m.line,m.character,p.character,c);else if(m.line<p.line){o(m.line,m.character,Number.POSITIVE_INFINITY,c);for(let h=m.line+1;h<p.line;h++)l.unshift(()=>s(h,c));o(p.line,0,p.character,c)}}l.forEach((c)=>c())}}}function R$(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new we(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let i=e[r],o=n.start.offset<=i.start.offset&&i.start.offset<n.end.offset,s=n.start.offset<i.end.offset&&i.end.offset<=n.end.offset,a=i.start.offset<=n.start.offset&&n.start.offset<i.end.offset,l=i.start.offset<n.end.offset&&n.end.offset<=i.end.offset;if(o||s||a||l){if(o&&s)continue;if(a&&l)continue;if(a&&n.start.offset===n.end.offset)continue;if(s&&i.start.offset===i.end.offset)continue;throw new we(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(i.start)} intersect.`)}}}}function gy(e){if(e.type==="text")return e.value;if(e.type==="element")return e.children.map(gy).join("");return""}var A$=[L$()];function Zl(e){let t=P$(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...A$]}function P$(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 Gi=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],zm={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function $$(e,t){let n=e.indexOf("\x1B",t);if(n!==-1){if(e[n+1]==="["){let r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}}return{position:e.length}}function my(e){let t=e.shift();if(t==="2"){let n=e.splice(0,3).map((r)=>Number.parseInt(r));if(n.length!==3||n.some((r)=>Number.isNaN(r)))return;return{type:"rgb",rgb:n}}else if(t==="5"){let n=e.shift();if(n)return{type:"table",index:Number(n)}}}function M$(e){let t=[];while(e.length>0){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(Number.isNaN(r))continue;if(r===0)t.push({type:"resetAll"});else if(r<=9){if(zm[r])t.push({type:"setDecoration",value:zm[r]})}else if(r<=29){let i=zm[r-20];if(i){if(t.push({type:"resetDecoration",value:i}),i==="dim")t.push({type:"resetDecoration",value:"bold"})}}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:Gi[r-30]}});else if(r===38){let i=my(e);if(i)t.push({type:"setForegroundColor",value:i})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:Gi[r-40]}});else if(r===48){let i=my(e);if(i)t.push({type:"setBackgroundColor",value:i})}else if(r===49)t.push({type:"resetBackgroundColor"});else if(r===53)t.push({type:"setDecoration",value:"overline"});else if(r===55)t.push({type:"resetDecoration",value:"overline"});else if(r>=90&&r<=97)t.push({type:"setForegroundColor",value:{type:"named",name:Gi[r-90+8]}});else if(r>=100&&r<=107)t.push({type:"setBackgroundColor",value:{type:"named",name:Gi[r-100+8]}})}return t}function O$(){let e=null,t=null,n=new Set;return{parse(r){let i=[],o=0;do{let s=$$(r,o),a=s.sequence?r.substring(o,s.startPosition):r.substring(o);if(a.length>0)i.push({value:a,foreground:e,background:t,decorations:new Set(n)});if(s.sequence){let l=M$(s.sequence);for(let d of l)if(d.type==="resetAll")e=null,t=null,n.clear();else if(d.type==="resetForegroundColor")e=null;else if(d.type==="resetBackgroundColor")t=null;else if(d.type==="resetDecoration")n.delete(d.value);for(let d of l)if(d.type==="setForegroundColor")e=d.value;else if(d.type==="setBackgroundColor")t=d.value;else if(d.type==="setDecoration")n.add(d.value)}o=s.position}while(o<r.length);return i}}}var F$={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 N$(e=F$){function t(a){return e[a]}function n(a){return`#${a.map((l)=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function i(){if(r)return r;r=[];for(let d=0;d<Gi.length;d++)r.push(t(Gi[d]));let a=[0,95,135,175,215,255];for(let d=0;d<6;d++)for(let c=0;c<6;c++)for(let m=0;m<6;m++)r.push(n([a[d],a[c],a[m]]));let l=8;for(let d=0;d<24;d++,l+=10)r.push(n([l,l,l]));return r}function o(a){return i()[a]}function s(a){switch(a.type){case"named":return t(a.name);case"rgb":return n(a.rgb);case"table":return o(a.index)}}return{value:s}}var D$=/#([0-9a-f]{3,8})/i,H$=/var\((--[\w-]+-ansi-[\w-]+)\)/,_$={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 U$(e,t,n){let r=js(e,n),i=Lo(t),o=N$(Object.fromEntries(Gi.map((a)=>{let l=`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`;return[a,e.colors?.[l]||_$[a]]}))),s=O$();return i.map((a)=>s.parse(a[0]).map((l)=>{let d,c;if(l.decorations.has("reverse"))d=l.background?o.value(l.background):e.bg,c=l.foreground?o.value(l.foreground):e.fg;else d=l.foreground?o.value(l.foreground):e.fg,c=l.background?o.value(l.background):void 0;if(d=Lr(d,r),c=Lr(c,r),l.decorations.has("dim"))d=B$(d);let m=Gt.None;if(l.decorations.has("bold"))m|=Gt.Bold;if(l.decorations.has("italic"))m|=Gt.Italic;if(l.decorations.has("underline"))m|=Gt.Underline;if(l.decorations.has("strikethrough"))m|=Gt.Strikethrough;return{content:l.value,offset:a[1],color:d,bgColor:c,fontStyle:m}}))}function B$(e){let t=e.match(D$);if(t){let r=t[1];if(r.length===8){let i=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${i}`}else if(r.length===6)return`#${r}80`;else if(r.length===4){let i=r[0],o=r[1],s=r[2],a=r[3];return`#${i}${i}${o}${o}${s}${s}${Math.round(Number.parseInt(`${a}${a}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){let i=r[0],o=r[1],s=r[2];return`#${i}${i}${o}${o}${s}${s}80`}}let n=e.match(H$);if(n)return`var(${n[1]}-dim)`;return e}function Vm(e,t,n={}){let r=e.resolveLangAlias(n.lang||"text"),{theme:i=e.getLoadedThemes()[0]}=n;if(!qs(r)&&!zs(i)&&r==="ansi"){let{theme:o}=e.setTheme(i);return U$(o,t,n)}return $m(e,t,n)}function Ql(e,t,n){let r,i,o,s,a,l;if("themes"in n){let{defaultColor:d="light",cssVariablePrefix:c="--shiki-",colorsRendering:m="css-vars"}=n,p=Object.entries(n.themes).filter((S)=>S[1]).map((S)=>({color:S[0],theme:S[1]})).sort((S,b)=>S.color===d?-1:b.color===d?1:0);if(p.length===0)throw new we("`themes` option must not be empty");let h=Bl(e,t,n,Vm);if(l=Ao(h),d&&d!=="light-dark()"&&!p.some((S)=>S.color===d))throw new we(`\`themes\` option must contain the defaultColor key \`${d}\``);let x=p.map((S)=>e.getTheme(S.theme)),I=p.map((S)=>S.color);if(o=h.map((S)=>S.map((b)=>w$(b,I,c,d,m))),l)Ks(o,l);let v=p.map((S)=>js(S.theme,n));i=fy(p,x,v,c,d,"fg",m),r=fy(p,x,v,c,d,"bg",m),s=`shiki-themes ${x.map((S)=>S.name).join(" ")}`,a=d?void 0:[i,r].join(";")}else if("theme"in n){let d=js(n.theme,n);o=Vm(e,t,n);let c=e.getTheme(n.theme);r=Lr(c.bg,d),i=Lr(c.fg,d),s=c.name,l=Ao(o)}else throw new we("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:i,bg:r,themeName:s,rootStyle:a,grammarState:l}}function fy(e,t,n,r,i,o,s){return e.map((a,l)=>{let d=Lr(t[l][o],n[l])||"inherit",c=`${r+a.color}${o==="bg"?"-bg":""}:${d}`;if(l===0&&i){if(i==="light-dark()"&&e.length>1){let m=e.findIndex((h)=>h.color==="light"),p=e.findIndex((h)=>h.color==="dark");if(m===-1||p===-1)throw new we('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Lr(t[m][o],n[m])||"inherit"}, ${Lr(t[p][o],n[p])||"inherit"});${c}`}return d}if(s==="css-vars")return c;return null}).filter((a)=>!!a).join(";")}var yy=/^\s+$/,G$=/^(\s*)(.*?)(\s*)$/;function eu(e,t,n,r={meta:{},options:n,codeToHast:(i,o)=>eu(e,i,o),codeToTokens:(i,o)=>Ql(e,i,o)}){let i=t;for(let x of Zl(n))i=x.preprocess?.call(r,i,n)||i;let{tokens:o,fg:s,bg:a,themeName:l,rootStyle:d,grammarState:c}=Ql(e,i,n),{mergeWhitespaces:m=!0,mergeSameStyleTokens:p=!1}=n;if(m===!0)o=q$(o);else if(m==="never")o=z$(o);if(p)o=K$(o);let h={...r,get source(){return i}};for(let x of Zl(n))o=x.tokens?.call(h,o)||o;return j$(o,{...n,fg:s,bg:a,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??d},h,c)}function j$(e,t,n,r=Ao(e)){let i=Zl(t),o=[],s={type:"root",children:[]},{structure:a="classic",tabindex:l="0"}=t,d={class:`shiki ${t.themeName||""}`};if(t.rootStyle!==!1)if(t.rootStyle!=null)d.style=t.rootStyle;else d.style=`background-color:${t.bg};color:${t.fg}`;if(l!==!1&&l!=null)d.tabindex=l.toString();for(let[I,v]of Object.entries(t.meta||{}))if(!I.startsWith("_"))d[I]=v;let c={type:"element",tagName:"pre",properties:d,children:[],data:t.data},m={type:"element",tagName:"code",properties:{},children:o},p=[],h={...n,structure:a,addClassToHast:py,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return s},get pre(){return c},get code(){return m},get lines(){return p}};if(e.forEach((I,v)=>{if(v){if(a==="inline")s.children.push({type:"element",tagName:"br",properties:{},children:[]});else if(a==="classic")o.push({type:"text",value:`
|
|
10
|
+
`})}let S={type:"element",tagName:"span",properties:{class:"line"},children:[]},b=0;for(let E of I){let w={type:"element",tagName:"span",properties:{...E.htmlAttrs},children:[{type:"text",value:E.content}]},T=Km(E.htmlStyle||Jl(E));if(T)w.properties.style=T;for(let L of i)w=L?.span?.call(h,w,v+1,b,S,E)||w;if(a==="inline")s.children.push(w);else if(a==="classic")S.children.push(w);b+=E.content.length}if(a==="classic"){for(let E of i)S=E?.line?.call(h,S,v+1)||S;p.push(S),o.push(S)}else if(a==="inline")p.push(S)}),a==="classic"){for(let I of i)m=I?.code?.call(h,m)||m;c.children.push(m);for(let I of i)c=I?.pre?.call(h,c)||c;s.children.push(c)}else if(a==="inline"){let I=[],v={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let b of s.children)if(b.type==="element"&&b.tagName==="br")I.push(v),v={type:"element",tagName:"span",properties:{class:"line"},children:[]};else if(b.type==="element"||b.type==="text")v.children.push(b);I.push(v);let S={type:"element",tagName:"code",properties:{},children:I};for(let b of i)S=b?.code?.call(h,S)||S;s.children=[];for(let b=0;b<S.children.length;b++){if(b>0)s.children.push({type:"element",tagName:"br",properties:{},children:[]});let E=S.children[b];if(E.type==="element")s.children.push(...E.children)}}let x=s;for(let I of i)x=I?.root?.call(h,x)||x;if(r)Ks(x,r);return x}function q$(e){return e.map((t)=>{let n=[],r="",i;return t.forEach((o,s)=>{let a=!(o.fontStyle&&(o.fontStyle&Gt.Underline||o.fontStyle&Gt.Strikethrough));if(a&&yy.test(o.content)&&t[s+1]){if(i===void 0)i=o.offset;r+=o.content}else if(r){if(a)n.push({...o,offset:i,content:r+o.content});else n.push({content:r,offset:i},o);i=void 0,r=""}else n.push(o)}),n})}function z$(e){return e.map((t)=>t.flatMap((n)=>{if(yy.test(n.content))return n;let r=n.content.match(G$);if(!r)return n;let[,i,o,s]=r;if(!i&&!s)return n;let a=[{...n,offset:n.offset+i.length,content:o}];if(i)a.unshift({content:i,offset:n.offset});if(s)a.push({content:s,offset:n.offset+i.length+o.length});return a}))}function K$(e){return e.map((t)=>{let n=[];for(let r of t){if(n.length===0){n.push({...r});continue}let i=n.at(-1),o=Km(i.htmlStyle||Jl(i)),s=Km(r.htmlStyle||Jl(r)),a=i.fontStyle&&(i.fontStyle&Gt.Underline||i.fontStyle&Gt.Strikethrough),l=r.fontStyle&&(r.fontStyle&Gt.Underline||r.fontStyle&Gt.Strikethrough);if(!a&&!l&&o===s)i.content+=r.content;else n.push({...r})}return n})}var V$=ut;function W$(e,t,n){let r={meta:{},options:n,codeToHast:(o,s)=>eu(e,o,s),codeToTokens:(o,s)=>Ql(e,o,s)},i=V$(eu(e,t,n,r));for(let o of Zl(n))i=o.postprocess?.call(r,i,n)||i;return i}async function xy(e){let t=await Pm(e);return{getLastGrammarState:(...n)=>Mg(t,...n),codeToTokensBase:(n,r)=>Vm(t,n,r),codeToTokensWithThemes:(n,r)=>Bl(t,n,r),codeToTokens:(n,r)=>Ql(t,n,r),codeToHast:(n,r)=>eu(t,n,r),codeToHtml:(n,r)=>W$(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function X$(e){let t;async function n(r){if(!t)return t=e({...r,themes:r.themes||[],langs:r.langs||[]}),t;else{let i=await t;return await Promise.all([i.loadTheme(...r.themes||[]),i.loadLanguage(...r.langs||[])]),i}}return n}var Z4=X$(xy);function Iy(e){let{langs:t,themes:n,engine:r}=e;async function i(o){function s(m){if(typeof m==="string"){if(m=o.langAlias?.[m]||m,Lm(m))return[];let p=t[m];if(!p)throw new we(`Language \`${m}\` is not included in this bundle. You may want to load it from external source.`);return p}return m}function a(m){if(Rm(m))return"none";if(typeof m==="string"){let p=n[m];if(!p)throw new we(`Theme \`${m}\` is not included in this bundle. You may want to load it from external source.`);return p}return m}let l=(o.themes??[]).map((m)=>a(m)),d=(o.langs??[]).map((m)=>s(m)),c=await xy({engine:o.engine??r(),...o,themes:l,langs:d});return{...c,loadLanguage(...m){return c.loadLanguage(...m.map(s))},loadTheme(...m){return c.loadTheme(...m.map(a))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return i}function Y$(e){let t;async function n(r={}){if(!t){t=e({...r,themes:[],langs:[]});let i=await t;return await Promise.all([i.loadTheme(...r.themes||[]),i.loadLanguage(...r.langs||[])]),i}else{let i=await t;return await Promise.all([i.loadTheme(...r.themes||[]),i.loadLanguage(...r.langs||[])]),i}}return n}function Sy(e,t){let n=Y$(e);async function r(i,o){let s=await n({langs:[o.lang],themes:"theme"in o?[o.theme]:Object.values(o.themes)}),a=await t?.guessEmbeddedLanguages?.(i,o.lang,s);if(a)await s.loadLanguage(...a);return s}return{getSingletonHighlighter(i){return n(i)},async codeToHtml(i,o){return(await r(i,o)).codeToHtml(i,o)},async codeToHast(i,o){return(await r(i,o)).codeToHast(i,o)},async codeToTokens(i,o){return(await r(i,o)).codeToTokens(i,o)},async codeToTokensBase(i,o){return(await r(i,o)).codeToTokensBase(i,o)},async codeToTokensWithThemes(i,o){return(await r(i,o)).codeToTokensWithThemes(i,o)},async getLastGrammarState(i,o){return(await n({langs:[o.lang],themes:[o.theme]})).getLastGrammarState(i,o)}}}function Xs({name:e,load:t,colorScheme:n,collection:r,displayName:i}){return{name:e,colorScheme:n,collection:r,displayName:i,load:J$(t)}}function J$(e){return async()=>Ro(Nl(await e()))}var Z$="pierre",Q$=["pierre-dark","pierre-dark-soft","pierre-dark-vibrant","pierre-dark-protanopia-deuteranopia","pierre-dark-tritanopia"],by=["pierre-light","pierre-light-soft","pierre-light-vibrant","pierre-light-protanopia-deuteranopia","pierre-light-tritanopia"],eM=[...by,...Q$],tM=new Set(by);function nM(e){if(tM.has(e))return"light";return"dark"}var rM={"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"},iM={"pierre-dark":()=>import("./pierre-dark-dbehbn5b.js"),"pierre-dark-soft":()=>import("./pierre-dark-soft-svbt475t.js"),"pierre-dark-vibrant":()=>import("./pierre-dark-vibrant-3st3mhhn.js"),"pierre-dark-protanopia-deuteranopia":()=>import("./pierre-dark-protanopia-deuteranopia-p24qgk7j.js"),"pierre-dark-tritanopia":()=>import("./pierre-dark-tritanopia-f5fgf7t0.js"),"pierre-light":()=>import("./pierre-light-sr6jfjng.js"),"pierre-light-soft":()=>import("./pierre-light-soft-rcep508k.js"),"pierre-light-vibrant":()=>import("./pierre-light-vibrant-mv2fa7xw.js"),"pierre-light-protanopia-deuteranopia":()=>import("./pierre-light-protanopia-deuteranopia-rfszgf8k.js"),"pierre-light-tritanopia":()=>import("./pierre-light-tritanopia-d8z7gv4x.js")};function oM(e){return Xs({name:e,collection:Z$,colorScheme:nM(e),displayName:rM[e],load:iM[e]})}var tu=ei({themes:eM.map((e)=>oM(e))});var sM="shiki",Ey=["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"],aM=["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"],lM=new Set(Ey);function uM(e){if(lM.has(e))return"light";return"dark"}var dM={andromeeda:()=>import("./andromeeda-tsp924my.js"),"aurora-x":()=>import("./aurora-x-ba9r2etj.js"),"ayu-dark":()=>import("./ayu-dark-1vqjtzry.js"),"ayu-light":()=>import("./ayu-light-hyc4fc7y.js"),"ayu-mirage":()=>import("./ayu-mirage-exvkv8da.js"),"catppuccin-frappe":()=>import("./catppuccin-frappe-0rvsggsb.js"),"catppuccin-latte":()=>import("./catppuccin-latte-av89afca.js"),"catppuccin-macchiato":()=>import("./catppuccin-macchiato-dqe3mbw1.js"),"catppuccin-mocha":()=>import("./catppuccin-mocha-2w1wgn9v.js"),"dark-plus":()=>import("./dark-plus-0be7zfjq.js"),dracula:()=>import("./dracula-kyzb58xf.js"),"dracula-soft":()=>import("./dracula-soft-4ah05qcy.js"),"everforest-dark":()=>import("./everforest-dark-x2sxpmaz.js"),"everforest-light":()=>import("./everforest-light-9xkh4gqx.js"),"github-dark":()=>import("./github-dark-xzmxhvr4.js"),"github-dark-default":()=>import("./github-dark-default-sa857k56.js"),"github-dark-dimmed":()=>import("./github-dark-dimmed-ekh4tbqg.js"),"github-dark-high-contrast":()=>import("./github-dark-high-contrast-5xp9g18c.js"),"github-light":()=>import("./github-light-2q28m6c1.js"),"github-light-default":()=>import("./github-light-default-ywc9b32r.js"),"github-light-high-contrast":()=>import("./github-light-high-contrast-9hy4thhf.js"),"gruvbox-dark-hard":()=>import("./gruvbox-dark-hard-h6rfjf9q.js"),"gruvbox-dark-medium":()=>import("./gruvbox-dark-medium-gdwaw20e.js"),"gruvbox-dark-soft":()=>import("./gruvbox-dark-soft-sq5yvaag.js"),"gruvbox-light-hard":()=>import("./gruvbox-light-hard-nym0hnh4.js"),"gruvbox-light-medium":()=>import("./gruvbox-light-medium-9kgrswjt.js"),"gruvbox-light-soft":()=>import("./gruvbox-light-soft-618vpmvg.js"),horizon:()=>import("./horizon-5e2be4sx.js"),"horizon-bright":()=>import("./horizon-bright-0hrqkmhs.js"),houston:()=>import("./houston-wzd0npbc.js"),"kanagawa-dragon":()=>import("./kanagawa-dragon-hec3nmvm.js"),"kanagawa-lotus":()=>import("./kanagawa-lotus-eg9aja7s.js"),"kanagawa-wave":()=>import("./kanagawa-wave-314f45f0.js"),laserwave:()=>import("./laserwave-wz1f76zd.js"),"light-plus":()=>import("./light-plus-43gmczhw.js"),"material-theme":()=>import("./material-theme-bqcfs89x.js"),"material-theme-darker":()=>import("./material-theme-darker-gger3t82.js"),"material-theme-lighter":()=>import("./material-theme-lighter-evaye4z3.js"),"material-theme-ocean":()=>import("./material-theme-ocean-h7m9f34k.js"),"material-theme-palenight":()=>import("./material-theme-palenight-tyeannba.js"),"min-dark":()=>import("./min-dark-kcpraaxv.js"),"min-light":()=>import("./min-light-w5gbrkp8.js"),monokai:()=>import("./monokai-nbvd076q.js"),"night-owl":()=>import("./night-owl-kk2p0vc0.js"),"night-owl-light":()=>import("./night-owl-light-hq9zzwqt.js"),nord:()=>import("./nord-c0ea2g04.js"),"one-dark-pro":()=>import("./one-dark-pro-t9a3593x.js"),"one-light":()=>import("./one-light-aar5vy7j.js"),plastic:()=>import("./plastic-0tmrj0c8.js"),poimandres:()=>import("./poimandres-hmgg59te.js"),red:()=>import("./red-0knjvcyd.js"),"rose-pine":()=>import("./rose-pine-v63jc1jc.js"),"rose-pine-dawn":()=>import("./rose-pine-dawn-a079aeh5.js"),"rose-pine-moon":()=>import("./rose-pine-moon-axp18ha5.js"),"slack-dark":()=>import("./slack-dark-n2f4xt4t.js"),"slack-ochin":()=>import("./slack-ochin-ag40mqdq.js"),"snazzy-light":()=>import("./snazzy-light-g9qtd34v.js"),"solarized-dark":()=>import("./solarized-dark-cpesrcas.js"),"solarized-light":()=>import("./solarized-light-ar205sc0.js"),"synthwave-84":()=>import("./synthwave-84-n8bwkyqe.js"),"tokyo-night":()=>import("./tokyo-night-rcm4pka3.js"),vesper:()=>import("./vesper-dctcmpqx.js"),"vitesse-black":()=>import("./vitesse-black-jpzvzek5.js"),"vitesse-dark":()=>import("./vitesse-dark-6067ajvh.js"),"vitesse-light":()=>import("./vitesse-light-tz4hqyp9.js")};function Cy(e){return Xs({name:e,collection:sM,colorScheme:uM(e),load:dM[e]})}var nu=ei({themes:Object.freeze([...Ey.map((e)=>Cy(e)),...aM.map((e)=>Cy(e))])});var yV=ei({themes:[tu,nu]});function vy(e){if(Dl())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(Ut.hasRegisteredTheme(e))return;let t=nu.getTheme(e);if(t!=null){Ut.registerThemeIfAbsent(t.name,t.load);return}throw Error(`No valid theme loader registered for "${e}"`)}function ky(e,t){if(t.name!==e)throw Error(`resolvedTheme: themeName: ${e} does not match theme.name: ${t.name}`)}async function Wm(e){vy(e);let t=await Ut.resolveTheme(e);return ky(e,t),t}var Pr=new Map,ru=new Map,Ty=new Map,Mo=new Set;function ni(e){for(let t of Array.isArray(e)?e:[e]){if(t==="text"||t==="ansi")continue;if(!Mo.has(t))return!1}return!0}function Xm(e,t){e=Array.isArray(e)?e:[e];for(let n of e){if(Mo.has(n.name))continue;let r=Pr.get(n.name);if(r==null)r=n,Pr.set(n.name,r);Mo.add(r.name),t.loadLanguageSync(r.data)}}var iu=[{id:"abap",name:"ABAP",import:()=>import("./abap-37m8k1ec.js")},{id:"actionscript-3",name:"ActionScript",aliases:["actionscript","as3"],import:()=>import("./actionscript-3-n586vqk1.js")},{id:"ada",name:"Ada",import:()=>import("./ada-v0kw2293.js")},{id:"ahk",name:"AutoHotkey",aliases:["ahk1"],import:()=>import("./ahk-9r99qttb.js")},{id:"ahk2",name:"AutoHotkey2",import:()=>import("./ahk2-zf55ztys.js")},{id:"angular-html",name:"Angular HTML",import:()=>import("./angular-html-kv9gdfx2.js")},{id:"angular-ts",name:"Angular TypeScript",import:()=>import("./angular-ts-keppeh1h.js")},{id:"apache",name:"Apache Conf",import:()=>import("./apache-4v6bayjm.js")},{id:"apex",name:"Apex",import:()=>import("./apex-e7qd8eak.js")},{id:"apl",name:"APL",import:()=>import("./apl-gx9k013t.js")},{id:"applescript",name:"AppleScript",import:()=>import("./applescript-5c6hhda4.js")},{id:"ara",name:"Ara",import:()=>import("./ara-yz6s07xr.js")},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:()=>import("./asciidoc-g34hsq0b.js")},{id:"asm",name:"Assembly",import:()=>import("./asm-d0xrkzc6.js")},{id:"astro",name:"Astro",import:()=>import("./astro-axfx2dwc.js")},{id:"awk",name:"AWK",import:()=>import("./awk-hr43qkge.js")},{id:"ballerina",name:"Ballerina",import:()=>import("./ballerina-qf8n2afr.js")},{id:"bat",name:"Batch File",aliases:["batch","cmd"],import:()=>import("./bat-tvqjs4qg.js")},{id:"beancount",name:"Beancount",import:()=>import("./beancount-rjbxrtqa.js")},{id:"berry",name:"Berry",aliases:["be"],import:()=>import("./berry-mne8afdm.js")},{id:"bibtex",name:"BibTeX",import:()=>import("./bibtex-1a8tpckh.js")},{id:"bicep",name:"Bicep",import:()=>import("./bicep-evx2z4e8.js")},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:()=>import("./bird2-92vp70tt.js")},{id:"blade",name:"Blade",import:()=>import("./blade-8ztgkb7f.js")},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:()=>import("./bsl-6zj38j1e.js")},{id:"c",name:"C",import:()=>import("./c-8xqp48d5.js")},{id:"c3",name:"C3",import:()=>import("./c3-c92e602v.js")},{id:"cadence",name:"Cadence",aliases:["cdc"],import:()=>import("./cadence-a36vzekc.js")},{id:"cairo",name:"Cairo",import:()=>import("./cairo-eb6safc8.js")},{id:"chapel",name:"Chapel",aliases:["chpl"],import:()=>import("./chapel-ar2268s7.js")},{id:"clarity",name:"Clarity",import:()=>import("./clarity-zf60e2j2.js")},{id:"clojure",name:"Clojure",aliases:["clj"],import:()=>import("./clojure-887d1e1x.js")},{id:"cmake",name:"CMake",import:()=>import("./cmake-57kpn13k.js")},{id:"cobol",name:"COBOL",import:()=>import("./cobol-sa1635qf.js")},{id:"codeowners",name:"CODEOWNERS",import:()=>import("./codeowners-fh934x1t.js")},{id:"codeql",name:"CodeQL",aliases:["ql"],import:()=>import("./codeql-va3jby28.js")},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:()=>import("./coffee-8136cr62.js")},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:()=>import("./common-lisp-00wv3fh8.js")},{id:"coq",name:"Rocq",import:()=>import("./coq-b3a6w5bc.js")},{id:"cpp",name:"C++",aliases:["c++"],import:()=>import("./cpp-a43bjfgc.js")},{id:"crystal",name:"Crystal",import:()=>import("./crystal-s9vexq9g.js")},{id:"csharp",name:"C#",aliases:["c#","cs"],import:()=>import("./csharp-hdxbv9a9.js")},{id:"css",name:"CSS",import:()=>import("./css-yqycp94s.js")},{id:"csv",name:"CSV",import:()=>import("./csv-vyt11en5.js")},{id:"cue",name:"CUE",import:()=>import("./cue-08m83p37.js")},{id:"cypher",name:"Cypher",aliases:["cql"],import:()=>import("./cypher-v1jcw5fh.js")},{id:"d",name:"D",import:()=>import("./d-e529x4sm.js")},{id:"dart",name:"Dart",import:()=>import("./dart-hk8rmm39.js")},{id:"dax",name:"DAX",import:()=>import("./dax-qz31wras.js")},{id:"desktop",name:"Desktop",import:()=>import("./desktop-b4y70ke9.js")},{id:"diff",name:"Diff",import:()=>import("./diff-ep27k8fw.js")},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:()=>import("./docker-rcmk5ma2.js")},{id:"dotenv",name:"dotEnv",import:()=>import("./dotenv-vec5mamj.js")},{id:"dream-maker",name:"Dream Maker",import:()=>import("./dream-maker-6vr9fy8n.js")},{id:"edge",name:"Edge",import:()=>import("./edge-gc4817bf.js")},{id:"elixir",name:"Elixir",import:()=>import("./elixir-gq7mpq9w.js")},{id:"elm",name:"Elm",import:()=>import("./elm-1j0csrmm.js")},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:()=>import("./emacs-lisp-eg0jfvw2.js")},{id:"erb",name:"ERB",import:()=>import("./erb-x3fzkywy.js")},{id:"erlang",name:"Erlang",aliases:["erl"],import:()=>import("./erlang-jmc1stgg.js")},{id:"fennel",name:"Fennel",import:()=>import("./fennel-s8wmfc8s.js")},{id:"fish",name:"Fish",import:()=>import("./fish-dfn8bm4m.js")},{id:"fluent",name:"Fluent",aliases:["ftl"],import:()=>import("./fluent-r16tj7sx.js")},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:()=>import("./fortran-fixed-form-sv8wqvzh.js")},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:()=>import("./fortran-free-form-3hgcgxwg.js")},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:()=>import("./fsharp-zw1bjtaf.js")},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:()=>import("./gdresource-vdfqv4hv.js")},{id:"gdscript",name:"GDScript",aliases:["gd"],import:()=>import("./gdscript-wx8h0589.js")},{id:"gdshader",name:"GDShader",import:()=>import("./gdshader-68h3wsc3.js")},{id:"genie",name:"Genie",import:()=>import("./genie-ks4dnr15.js")},{id:"gherkin",name:"Gherkin",import:()=>import("./gherkin-ha552g2d.js")},{id:"git-commit",name:"Git Commit Message",import:()=>import("./git-commit-s1t474nk.js")},{id:"git-rebase",name:"Git Rebase Message",import:()=>import("./git-rebase-2x9tcy50.js")},{id:"gleam",name:"Gleam",import:()=>import("./gleam-775tda2q.js")},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:()=>import("./glimmer-js-82d7ga5f.js")},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:()=>import("./glimmer-ts-x63pcyb9.js")},{id:"glsl",name:"GLSL",import:()=>import("./glsl-dd0ny3vj.js")},{id:"gn",name:"GN",import:()=>import("./gn-drgd8tqk.js")},{id:"gnuplot",name:"Gnuplot",import:()=>import("./gnuplot-0rhp27c5.js")},{id:"go",name:"Go",import:()=>import("./go-d36pkndb.js")},{id:"graphql",name:"GraphQL",aliases:["gql"],import:()=>import("./graphql-af70d7rf.js")},{id:"groovy",name:"Groovy",import:()=>import("./groovy-1btmbca0.js")},{id:"hack",name:"Hack",import:()=>import("./hack-fg23bx96.js")},{id:"haml",name:"Ruby Haml",import:()=>import("./haml-k0j6f2e1.js")},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:()=>import("./handlebars-88ngzyjf.js")},{id:"haskell",name:"Haskell",aliases:["hs"],import:()=>import("./haskell-q53cwazc.js")},{id:"haxe",name:"Haxe",import:()=>import("./haxe-yayte2fd.js")},{id:"hcl",name:"HashiCorp HCL",import:()=>import("./hcl-hnh4hm4w.js")},{id:"hjson",name:"Hjson",import:()=>import("./hjson-8aw9mzqe.js")},{id:"hlsl",name:"HLSL",import:()=>import("./hlsl-cdkxcw4v.js")},{id:"html",name:"HTML",import:()=>import("./html-xwjgwct9.js")},{id:"html-derivative",name:"HTML (Derivative)",import:()=>import("./html-derivative-jzw9h4sb.js")},{id:"http",name:"HTTP",import:()=>import("./http-jmywyq30.js")},{id:"hurl",name:"Hurl",import:()=>import("./hurl-84djmb3v.js")},{id:"hxml",name:"HXML",import:()=>import("./hxml-7vd5wkqb.js")},{id:"hy",name:"Hy",import:()=>import("./hy-s26y0h11.js")},{id:"imba",name:"Imba",import:()=>import("./imba-7x38tp3g.js")},{id:"ini",name:"INI",aliases:["properties"],import:()=>import("./ini-wwj497bd.js")},{id:"java",name:"Java",import:()=>import("./java-qhn9cnec.js")},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:()=>import("./javascript-nnj4psw2.js")},{id:"jinja",name:"Jinja",import:()=>import("./jinja-czj082f2.js")},{id:"jison",name:"Jison",import:()=>import("./jison-kv24rt0q.js")},{id:"json",name:"JSON",import:()=>import("./json-0rje0de7.js")},{id:"json5",name:"JSON5",import:()=>import("./json5-ev0pv4wp.js")},{id:"jsonc",name:"JSON with Comments",import:()=>import("./jsonc-c4370yyr.js")},{id:"jsonl",name:"JSON Lines",import:()=>import("./jsonl-m9zc20xa.js")},{id:"jsonnet",name:"Jsonnet",import:()=>import("./jsonnet-e15qnnm2.js")},{id:"jssm",name:"JSSM",aliases:["fsl"],import:()=>import("./jssm-jmddbjy9.js")},{id:"jsx",name:"JSX",import:()=>import("./jsx-w8d0cm0a.js")},{id:"julia",name:"Julia",aliases:["jl"],import:()=>import("./julia-pfs2n4wr.js")},{id:"just",name:"Just",aliases:["justfile"],import:()=>import("./just-3qxt7w30.js")},{id:"kdl",name:"KDL",import:()=>import("./kdl-rytfnhc2.js")},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:()=>import("./kotlin-5bm8qh36.js")},{id:"kusto",name:"Kusto",aliases:["kql"],import:()=>import("./kusto-1jvn4kfn.js")},{id:"latex",name:"LaTeX",import:()=>import("./latex-25xjj37d.js")},{id:"lean",name:"Lean 4",aliases:["lean4"],import:()=>import("./lean-yey9ct91.js")},{id:"less",name:"Less",import:()=>import("./less-hmpk8q7h.js")},{id:"liquid",name:"Liquid",import:()=>import("./liquid-68rn6mg0.js")},{id:"llvm",name:"LLVM IR",import:()=>import("./llvm-aytmzfxk.js")},{id:"log",name:"Log file",import:()=>import("./log-x9fxkda3.js")},{id:"logo",name:"Logo",import:()=>import("./logo-954dz0fv.js")},{id:"lua",name:"Lua",import:()=>import("./lua-5mg6z41k.js")},{id:"luau",name:"Luau",import:()=>import("./luau-a2f57ery.js")},{id:"make",name:"Makefile",aliases:["makefile"],import:()=>import("./make-n47q2r30.js")},{id:"markdown",name:"Markdown",aliases:["md"],import:()=>import("./markdown-pdjapk97.js")},{id:"marko",name:"Marko",import:()=>import("./marko-avh3r0r7.js")},{id:"matlab",name:"MATLAB",import:()=>import("./matlab-grf517hb.js")},{id:"mdc",name:"MDC",import:()=>import("./mdc-w2xeah7f.js")},{id:"mdx",name:"MDX",import:()=>import("./mdx-jthgmdc9.js")},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:()=>import("./mermaid-gjwxzxws.js")},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:()=>import("./mipsasm-vjz9dmbq.js")},{id:"mojo",name:"Mojo",import:()=>import("./mojo-x773m0x3.js")},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:()=>import("./moonbit-n86a5d99.js")},{id:"move",name:"Move",import:()=>import("./move-75v0pk38.js")},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:()=>import("./narrat-yaw9xjvk.js")},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:()=>import("./nextflow-k452sqhf.js")},{id:"nextflow-groovy",name:"Nextflow Groovy",import:()=>import("./nextflow-groovy-srx6sxt8.js")},{id:"nginx",name:"Nginx",import:()=>import("./nginx-65m3tsxt.js")},{id:"nim",name:"Nim",import:()=>import("./nim-3kvk1gm5.js")},{id:"nix",name:"Nix",import:()=>import("./nix-bwp0ftjx.js")},{id:"nsis",name:"NSIS",import:()=>import("./nsis-pf2p1pqq.js")},{id:"nushell",name:"nushell",aliases:["nu"],import:()=>import("./nushell-2ga7e2rp.js")},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:()=>import("./objective-c-df116c38.js")},{id:"objective-cpp",name:"Objective-C++",import:()=>import("./objective-cpp-8m99samw.js")},{id:"ocaml",name:"OCaml",import:()=>import("./ocaml-2tmrnxx8.js")},{id:"odin",name:"Odin",import:()=>import("./odin-8ew89sbm.js")},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:()=>import("./openscad-0qpp8tms.js")},{id:"org",name:"Org Markup",import:()=>import("./org-3jkbxnxe.js")},{id:"pascal",name:"Pascal",import:()=>import("./pascal-t9tmw6mg.js")},{id:"perl",name:"Perl",import:()=>import("./perl-bhkhyh5d.js")},{id:"php",name:"PHP",import:()=>import("./php-9rfj74fc.js")},{id:"pkl",name:"Pkl",import:()=>import("./pkl-1165dchs.js")},{id:"plsql",name:"PL/SQL",import:()=>import("./plsql-naj0n4k8.js")},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:()=>import("./po-fepdn90s.js")},{id:"polar",name:"Polar",import:()=>import("./polar-csz6j8sz.js")},{id:"postcss",name:"PostCSS",import:()=>import("./postcss-zk8djd5p.js")},{id:"powerquery",name:"PowerQuery",import:()=>import("./powerquery-dty2ym0j.js")},{id:"powershell",name:"PowerShell",aliases:["ps","ps1","pwsh"],import:()=>import("./powershell-s2zm86px.js")},{id:"prisma",name:"Prisma",import:()=>import("./prisma-1xsywwsm.js")},{id:"prolog",name:"Prolog",import:()=>import("./prolog-9wxf6gzq.js")},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:()=>import("./proto-kb1st3s4.js")},{id:"pug",name:"Pug",aliases:["jade"],import:()=>import("./pug-rez2g9md.js")},{id:"puppet",name:"Puppet",import:()=>import("./puppet-51d61ef3.js")},{id:"purescript",name:"PureScript",import:()=>import("./purescript-ent5fqsh.js")},{id:"python",name:"Python",aliases:["py"],import:()=>import("./python-xba33008.js")},{id:"qml",name:"QML",import:()=>import("./qml-ecfac92p.js")},{id:"qmldir",name:"QML Directory",import:()=>import("./qmldir-z4dnf3er.js")},{id:"qss",name:"Qt Style Sheets",import:()=>import("./qss-5x7cdqde.js")},{id:"r",name:"R",import:()=>import("./r-dhavk838.js")},{id:"racket",name:"Racket",import:()=>import("./racket-m0rr2sr2.js")},{id:"raku",name:"Raku",aliases:["perl6"],import:()=>import("./raku-qsb9ddmk.js")},{id:"razor",name:"ASP.NET Razor",import:()=>import("./razor-kvnxas87.js")},{id:"rbs",name:"RBS",aliases:["ruby-signature"],import:()=>import("./rbs-rhjg3txf.js")},{id:"reg",name:"Windows Registry Script",import:()=>import("./reg-a0bppknm.js")},{id:"regexp",name:"RegExp",aliases:["regex"],import:()=>import("./regexp-fmz67gn4.js")},{id:"rel",name:"Rel",import:()=>import("./rel-26b830vk.js")},{id:"riscv",name:"RISC-V",import:()=>import("./riscv-vyzz3zzw.js")},{id:"ron",name:"RON",import:()=>import("./ron-359ky2kq.js")},{id:"rosmsg",name:"ROS Interface",import:()=>import("./rosmsg-w65k1nbk.js")},{id:"rst",name:"reStructuredText",import:()=>import("./rst-5bdn1c1j.js")},{id:"ruby",name:"Ruby",aliases:["rb"],import:()=>import("./ruby-gftcg1pk.js")},{id:"rust",name:"Rust",aliases:["rs"],import:()=>import("./rust-sq4f6g9y.js")},{id:"sas",name:"SAS",import:()=>import("./sas-qd9nq299.js")},{id:"sass",name:"Sass",import:()=>import("./sass-2tnh8wwx.js")},{id:"scala",name:"Scala",import:()=>import("./scala-j16eytps.js")},{id:"scheme",name:"Scheme",import:()=>import("./scheme-85ydnecj.js")},{id:"scss",name:"SCSS",import:()=>import("./scss-214pb2ev.js")},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:()=>import("./sdbl-yjgr9s0t.js")},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:()=>import("./shaderlab-9f34hb54.js")},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:()=>import("./shellscript-zsv4e5j0.js")},{id:"shellsession",name:"Shell Session",aliases:["console"],import:()=>import("./shellsession-vw3z7saq.js")},{id:"smalltalk",name:"GNU Smalltalk",import:()=>import("./smalltalk-ykje8je7.js")},{id:"smithy",name:"Smithy",import:()=>import("./smithy-n6n07hva.js")},{id:"solidity",name:"Solidity",import:()=>import("./solidity-cpw98fq4.js")},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:()=>import("./soy-jxsncnd7.js")},{id:"sparql",name:"SPARQL",import:()=>import("./sparql-7rsbch4s.js")},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:()=>import("./splunk-ahrhnqde.js")},{id:"sql",name:"SQL",import:()=>import("./sql-651bw7e4.js")},{id:"ssh-config",name:"SSH Config",import:()=>import("./ssh-config-jqqshx5y.js")},{id:"stata",name:"Stata",import:()=>import("./stata-3j5zc4en.js")},{id:"stylus",name:"Stylus",aliases:["styl"],import:()=>import("./stylus-4hacczez.js")},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:()=>import("./surrealql-bpwpv6hg.js")},{id:"svelte",name:"Svelte",import:()=>import("./svelte-3dbkq6j1.js")},{id:"swift",name:"Swift",import:()=>import("./swift-pq21fbt6.js")},{id:"system-verilog",name:"SystemVerilog",import:()=>import("./system-verilog-bjx146s2.js")},{id:"systemd",name:"Systemd Units",import:()=>import("./systemd-r44qzr4g.js")},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:()=>import("./talonscript-y3x48301.js")},{id:"tasl",name:"Tasl",import:()=>import("./tasl-3nnxpar2.js")},{id:"tcl",name:"Tcl",import:()=>import("./tcl-fmhzgxjx.js")},{id:"templ",name:"Templ",import:()=>import("./templ-x6vt4p4p.js")},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:()=>import("./terraform-v7zcbaqa.js")},{id:"tex",name:"TeX",import:()=>import("./tex-nmj16m3q.js")},{id:"toml",name:"TOML",import:()=>import("./toml-a6gg4eqj.js")},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:()=>import("./ts-tags-s8df9nd9.js")},{id:"tsv",name:"TSV",import:()=>import("./tsv-98armktx.js")},{id:"tsx",name:"TSX",import:()=>import("./tsx-6e9nwp76.js")},{id:"turtle",name:"Turtle",import:()=>import("./turtle-w9cxrxmc.js")},{id:"twig",name:"Twig",import:()=>import("./twig-9zpbpfbc.js")},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:()=>import("./typescript-r25bn51c.js")},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:()=>import("./typespec-8twhvsj0.js")},{id:"typst",name:"Typst",aliases:["typ"],import:()=>import("./typst-tewdnmsd.js")},{id:"v",name:"V",import:()=>import("./v-8950s4xp.js")},{id:"vala",name:"Vala",import:()=>import("./vala-jm0v1b80.js")},{id:"vb",name:"Visual Basic",import:()=>import("./vb-ystyawbc.js")},{id:"verilog",name:"Verilog",import:()=>import("./verilog-gymxq45g.js")},{id:"vhdl",name:"VHDL",import:()=>import("./vhdl-eqvvaqjg.js")},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:()=>import("./viml-nbft5xr9.js")},{id:"vue",name:"Vue",import:()=>import("./vue-42gn5vkg.js")},{id:"vue-html",name:"Vue HTML",import:()=>import("./vue-html-2004vfpd.js")},{id:"vue-vine",name:"Vue Vine",import:()=>import("./vue-vine-ae1x9v8h.js")},{id:"vyper",name:"Vyper",aliases:["vy"],import:()=>import("./vyper-1nkezv4x.js")},{id:"wasm",name:"WebAssembly",import:()=>import("./wasm-t2esg905.js")},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:()=>import("./wenyan-4sm4vf06.js")},{id:"wgsl",name:"WGSL",import:()=>import("./wgsl-tfyxmx9d.js")},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:()=>import("./wikitext-7qxke4yx.js")},{id:"wit",name:"WebAssembly Interface Types",import:()=>import("./wit-cp0rj4jh.js")},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:()=>import("./wolfram-mqv28qsr.js")},{id:"xml",name:"XML",import:()=>import("./xml-5jnb6sqj.js")},{id:"xsl",name:"XSL",import:()=>import("./xsl-hde8are0.js")},{id:"yaml",name:"YAML",aliases:["yml"],import:()=>import("./yaml-4j71mjzp.js")},{id:"zenscript",name:"ZenScript",import:()=>import("./zenscript-83k18fya.js")},{id:"zig",name:"Zig",import:()=>import("./zig-te4p6btc.js")}],Ym=Object.fromEntries(iu.map((e)=>[e.id,e.import])),Jm=Object.fromEntries(iu.flatMap((e)=>e.aliases?.map((t)=>[t,e.import])||[])),Oo={...Ym,...Jm};var tf={};Bt(tf,{createOnigurumaEngine:()=>lu,getDefaultWasmLoader:()=>TM,loadWasm:()=>ef,setDefaultWasmLoader:()=>kM});var Qm=class extends Error{constructor(e){super(e);this.name="ShikiError"}};function cM(){return 2147483648}function mM(){return typeof performance<"u"?performance.now():Date.now()}var fM=(e,t)=>e+(t-e%t)%t;async function pM(e){let t,n,r={};function i(h){n=h,r.HEAPU8=new Uint8Array(h),r.HEAPU32=new Uint32Array(h)}function o(h,x,I){r.HEAPU8.copyWithin(h,x,x+I)}function s(h){try{return t.grow(h-n.byteLength+65535>>>16),i(t.buffer),1}catch{}}function a(h){let x=r.HEAPU8.length;h=h>>>0;let I=cM();if(h>I)return!1;for(let v=1;v<=4;v*=2){let S=x*(1+0.2/v);S=Math.min(S,h+100663296);let b=Math.min(I,fM(Math.max(h,S),65536));if(s(b))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function d(h,x,I=1024){let v=x+I,S=x;while(h[S]&&!(S>=v))++S;if(S-x>16&&h.buffer&&l)return l.decode(h.subarray(x,S));let b="";while(x<S){let E=h[x++];if(!(E&128)){b+=String.fromCharCode(E);continue}let w=h[x++]&63;if((E&224)===192){b+=String.fromCharCode((E&31)<<6|w);continue}let T=h[x++]&63;if((E&240)===224)E=(E&15)<<12|w<<6|T;else E=(E&7)<<18|w<<12|T<<6|h[x++]&63;if(E<65536)b+=String.fromCharCode(E);else{let L=E-65536;b+=String.fromCharCode(55296|L>>10,56320|L&1023)}}return b}function c(h,x){return h?d(r.HEAPU8,h,x):""}let m={emscripten_get_now:mM,emscripten_memcpy_big:o,emscripten_resize_heap:a,fd_write:()=>0};async function p(){let x=await e({env:m,wasi_snapshot_preview1:m});t=x.memory,i(t.buffer),Object.assign(r,x),r.UTF8ToString=c}return await p(),r}var hM=Object.defineProperty,gM=(e,t,n)=>(t in e)?hM(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Et=(e,t,n)=>gM(e,typeof t!=="symbol"?t+"":t,n),At=null;function yM(e){throw new Qm(e.UTF8ToString(e.getLastOnigError()))}class su{constructor(e){Et(this,"utf16Length"),Et(this,"utf8Length"),Et(this,"utf16Value"),Et(this,"utf8Value"),Et(this,"utf16OffsetToUtf8"),Et(this,"utf8OffsetToUtf16");let t=e.length,n=su._utf8ByteLength(e),r=n!==t,i=r?new Uint32Array(t+1):null;if(r)i[t]=n;let o=r?new Uint32Array(n+1):null;if(r)o[n]=t;let s=new Uint8Array(n),a=0;for(let l=0;l<t;l++){let d=e.charCodeAt(l),c=d,m=!1;if(d>=55296&&d<=56319){if(l+1<t){let p=e.charCodeAt(l+1);if(p>=56320&&p<=57343)c=(d-55296<<10)+65536|p-56320,m=!0}}if(r){if(i[l]=a,m)i[l+1]=a;if(c<=127)o[a+0]=l;else if(c<=2047)o[a+0]=l,o[a+1]=l;else if(c<=65535)o[a+0]=l,o[a+1]=l,o[a+2]=l;else o[a+0]=l,o[a+1]=l,o[a+2]=l,o[a+3]=l}if(c<=127)s[a++]=c;else if(c<=2047)s[a++]=192|(c&1984)>>>6,s[a++]=128|(c&63)>>>0;else if(c<=65535)s[a++]=224|(c&61440)>>>12,s[a++]=128|(c&4032)>>>6,s[a++]=128|(c&63)>>>0;else s[a++]=240|(c&1835008)>>>18,s[a++]=128|(c&258048)>>>12,s[a++]=128|(c&4032)>>>6,s[a++]=128|(c&63)>>>0;if(m)l++}this.utf16Length=t,this.utf8Length=n,this.utf16Value=e,this.utf8Value=s,this.utf16OffsetToUtf8=i,this.utf8OffsetToUtf16=o}static _utf8ByteLength(e){let t=0;for(let n=0,r=e.length;n<r;n++){let i=e.charCodeAt(n),o=i,s=!1;if(i>=55296&&i<=56319){if(n+1<r){let a=e.charCodeAt(n+1);if(a>=56320&&a<=57343)o=(i-55296<<10)+65536|a-56320,s=!0}}if(o<=127)t+=1;else if(o<=2047)t+=2;else if(o<=65535)t+=3;else t+=4;if(s)n++}return t}createString(e){let t=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,t),t}}var au=class e{constructor(t){if(Et(this,"id",++e.LAST_ID),Et(this,"_onigBinding"),Et(this,"content"),Et(this,"utf16Length"),Et(this,"utf8Length"),Et(this,"utf16OffsetToUtf8"),Et(this,"utf8OffsetToUtf16"),Et(this,"ptr"),!At)throw new Qm("Must invoke loadWasm first.");this._onigBinding=At,this.content=t;let n=new su(t);if(this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!e._sharedPtrInUse){if(!e._sharedPtr)e._sharedPtr=At.omalloc(1e4);e._sharedPtrInUse=!0,At.HEAPU8.set(n.utf8Value,e._sharedPtr),this.ptr=e._sharedPtr}else this.ptr=n.createString(At)}convertUtf8OffsetToUtf16(t){if(this.utf8OffsetToUtf16){if(t<0)return 0;if(t>this.utf8Length)return this.utf16Length;return this.utf8OffsetToUtf16[t]}return t}convertUtf16OffsetToUtf8(t){if(this.utf16OffsetToUtf8){if(t<0)return 0;if(t>this.utf16Length)return this.utf8Length;return this.utf16OffsetToUtf8[t]}return t}dispose(){if(this.ptr===e._sharedPtr)e._sharedPtrInUse=!1;else this._onigBinding.ofree(this.ptr)}};Et(au,"LAST_ID",0);Et(au,"_sharedPtr",0);Et(au,"_sharedPtrInUse",!1);var wy=au;class Ly{constructor(e){if(Et(this,"_onigBinding"),Et(this,"_ptr"),!At)throw new Qm("Must invoke loadWasm first.");let t=[],n=[];for(let s=0,a=e.length;s<a;s++){let l=new su(e[s]);t[s]=l.createString(At),n[s]=l.utf8Length}let r=At.omalloc(4*e.length);At.HEAPU32.set(t,r/4);let i=At.omalloc(4*e.length);At.HEAPU32.set(n,i/4);let o=At.createOnigScanner(r,i,e.length);for(let s=0,a=e.length;s<a;s++)At.ofree(t[s]);if(At.ofree(i),At.ofree(r),o===0)yM(At);this._onigBinding=At,this._ptr=o}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,t,n){let r=0;if(typeof n==="number")r=n;if(typeof e==="string"){e=new wy(e);let i=this._findNextMatchSync(e,t,!1,r);return e.dispose(),i}return this._findNextMatchSync(e,t,!1,r)}_findNextMatchSync(e,t,n,r){let i=this._onigBinding,o=i.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(t),r);if(o===0)return null;let s=i.HEAPU32,a=o/4,l=s[a++],d=s[a++],c=[];for(let m=0;m<d;m++){let p=e.convertUtf8OffsetToUtf16(s[a++]),h=e.convertUtf8OffsetToUtf16(s[a++]);c[m]={start:p,end:h,length:h-p}}return{index:l,captureIndices:c}}}function xM(e){return typeof e.instantiator==="function"}function IM(e){return typeof e.default==="function"}function SM(e){return typeof e.data<"u"}function bM(e){return typeof Response<"u"&&e instanceof Response}function CM(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 ou;function ef(e){if(ou)return ou;async function t(){At=await pM(async(n)=>{let r=e;if(r=await r,typeof r==="function")r=await r(n);if(typeof r==="function")r=await r(n);if(xM(r))r=await r.instantiator(n);else if(IM(r))r=await r.default(n);else{if(SM(r))r=r.data;if(bM(r))if(typeof WebAssembly.instantiateStreaming==="function")r=await EM(r)(n);else r=await vM(r)(n);else if(CM(r))r=await Zm(r)(n);else if(r instanceof WebAssembly.Module)r=await Zm(r)(n);else if("default"in r&&r.default instanceof WebAssembly.Module)r=await Zm(r.default)(n)}if("instance"in r)r=r.instance;if("exports"in r)r=r.exports;return r})}return ou=t(),ou}function Zm(e){return(t)=>WebAssembly.instantiate(e,t)}function EM(e){return(t)=>WebAssembly.instantiateStreaming(e,t)}function vM(e){return async(t)=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var Ry;function kM(e){Ry=e}function TM(){return Ry}async function lu(e){if(e)await ef(e);return{createScanner(t){return new Ly(t.map((n)=>typeof n==="string"?n:n.source))},createString(t){return new wy(t)}}}var nf=Sg({});bg(nf,tf);var Ay=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:()=>import("./andromeeda-tsp924my.js")},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:()=>import("./aurora-x-ba9r2etj.js")},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:()=>import("./ayu-dark-1vqjtzry.js")},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:()=>import("./ayu-light-hyc4fc7y.js")},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:()=>import("./ayu-mirage-exvkv8da.js")},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:()=>import("./catppuccin-frappe-0rvsggsb.js")},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:()=>import("./catppuccin-latte-av89afca.js")},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:()=>import("./catppuccin-macchiato-dqe3mbw1.js")},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:()=>import("./catppuccin-mocha-2w1wgn9v.js")},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:()=>import("./dark-plus-0be7zfjq.js")},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:()=>import("./dracula-kyzb58xf.js")},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:()=>import("./dracula-soft-4ah05qcy.js")},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:()=>import("./everforest-dark-x2sxpmaz.js")},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:()=>import("./everforest-light-9xkh4gqx.js")},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:()=>import("./github-dark-xzmxhvr4.js")},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:()=>import("./github-dark-default-sa857k56.js")},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:()=>import("./github-dark-dimmed-ekh4tbqg.js")},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:()=>import("./github-dark-high-contrast-5xp9g18c.js")},{id:"github-light",displayName:"GitHub Light",type:"light",import:()=>import("./github-light-2q28m6c1.js")},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:()=>import("./github-light-default-ywc9b32r.js")},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:()=>import("./github-light-high-contrast-9hy4thhf.js")},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:()=>import("./gruvbox-dark-hard-h6rfjf9q.js")},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:()=>import("./gruvbox-dark-medium-gdwaw20e.js")},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:()=>import("./gruvbox-dark-soft-sq5yvaag.js")},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:()=>import("./gruvbox-light-hard-nym0hnh4.js")},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:()=>import("./gruvbox-light-medium-9kgrswjt.js")},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:()=>import("./gruvbox-light-soft-618vpmvg.js")},{id:"horizon",displayName:"Horizon",type:"dark",import:()=>import("./horizon-5e2be4sx.js")},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:()=>import("./horizon-bright-0hrqkmhs.js")},{id:"houston",displayName:"Houston",type:"dark",import:()=>import("./houston-wzd0npbc.js")},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:()=>import("./kanagawa-dragon-hec3nmvm.js")},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:()=>import("./kanagawa-lotus-eg9aja7s.js")},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:()=>import("./kanagawa-wave-314f45f0.js")},{id:"laserwave",displayName:"LaserWave",type:"dark",import:()=>import("./laserwave-wz1f76zd.js")},{id:"light-plus",displayName:"Light Plus",type:"light",import:()=>import("./light-plus-43gmczhw.js")},{id:"material-theme",displayName:"Material Theme",type:"dark",import:()=>import("./material-theme-bqcfs89x.js")},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:()=>import("./material-theme-darker-gger3t82.js")},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:()=>import("./material-theme-lighter-evaye4z3.js")},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:()=>import("./material-theme-ocean-h7m9f34k.js")},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:()=>import("./material-theme-palenight-tyeannba.js")},{id:"min-dark",displayName:"Min Dark",type:"dark",import:()=>import("./min-dark-kcpraaxv.js")},{id:"min-light",displayName:"Min Light",type:"light",import:()=>import("./min-light-w5gbrkp8.js")},{id:"monokai",displayName:"Monokai",type:"dark",import:()=>import("./monokai-nbvd076q.js")},{id:"night-owl",displayName:"Night Owl",type:"dark",import:()=>import("./night-owl-kk2p0vc0.js")},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:()=>import("./night-owl-light-hq9zzwqt.js")},{id:"nord",displayName:"Nord",type:"dark",import:()=>import("./nord-c0ea2g04.js")},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:()=>import("./one-dark-pro-t9a3593x.js")},{id:"one-light",displayName:"One Light",type:"light",import:()=>import("./one-light-aar5vy7j.js")},{id:"plastic",displayName:"Plastic",type:"dark",import:()=>import("./plastic-0tmrj0c8.js")},{id:"poimandres",displayName:"Poimandres",type:"dark",import:()=>import("./poimandres-hmgg59te.js")},{id:"red",displayName:"Red",type:"dark",import:()=>import("./red-0knjvcyd.js")},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:()=>import("./rose-pine-v63jc1jc.js")},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:()=>import("./rose-pine-dawn-a079aeh5.js")},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:()=>import("./rose-pine-moon-axp18ha5.js")},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:()=>import("./slack-dark-n2f4xt4t.js")},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:()=>import("./slack-ochin-ag40mqdq.js")},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:()=>import("./snazzy-light-g9qtd34v.js")},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:()=>import("./solarized-dark-cpesrcas.js")},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:()=>import("./solarized-light-ar205sc0.js")},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:()=>import("./synthwave-84-n8bwkyqe.js")},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:()=>import("./tokyo-night-rcm4pka3.js")},{id:"vesper",displayName:"Vesper",type:"dark",import:()=>import("./vesper-dctcmpqx.js")},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:()=>import("./vitesse-black-jpzvzek5.js")},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:()=>import("./vitesse-dark-6067ajvh.js")},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:()=>import("./vitesse-light-tz4hqyp9.js")}],Py=Object.fromEntries(Ay.map((e)=>[e.id,e.import]));var uu=Iy({langs:Oo,themes:Py,engine:()=>(0,nf.createOnigurumaEngine)(import("./wasm-8yvsdhkk.js"))}),{codeToHtml:wM,codeToHast:LM,codeToTokens:RM,codeToTokensBase:AM,codeToTokensWithThemes:PM,getSingletonHighlighter:$M,getLastGrammarState:MM}=Sy(uu,{guessEmbeddedLanguages:hy});var $y=class{patterns;options;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((o)=>{if(typeof o!=="string")return o;let s=r?.get(o);if(s){if(s instanceof RegExp)return s;if(n)return null;throw s}try{let a=i(o);return r?.set(o,a),a}catch(a){if(r?.set(o,a),n)return null;throw a}})}findNextMatchSync(e,t,n){let r=typeof e==="string"?e:e.content,i=[];function o(s,a,l=0){return{index:s,captureIndices:a.indices.map((d)=>{if(d==null)return{start:4294967295,end:4294967295,length:0};return{start:d[0]+l,end:d[1]+l,length:d[1]-d[0]}})}}for(let s=0;s<this.regexps.length;s++){let a=this.regexps[s];if(!a)continue;try{a.lastIndex=t;let l=a.exec(r);if(!l)continue;if(l.index===t)return o(s,l,0);i.push([s,l,0])}catch(l){if(this.options.forgiving)continue;throw l}}if(i.length){let s=Math.min(...i.map((a)=>a[1].index));for(let[a,l,d]of i)if(l.index===s)return o(a,l,d)}return null}};function ri(e){if([...e].length!==1)throw Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function My(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var Ys=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),yt=String.raw;function $r(e,t){if(e==null)throw Error(t??"Value expected");return e}var _y=yt`\[\^?`,Uy=`c.? | C(?:-.?)?|${yt`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${yt`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${yt`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${yt`o\{[^\}]*\}?`}|${yt`\d{1,3}`}`,of=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,du=new RegExp(yt`
|
|
11
11
|
\\ (?:
|
|
12
|
-
${
|
|
12
|
+
${Uy}
|
|
13
13
|
| [gk]<[^>]*>?
|
|
14
14
|
| [gk]'[^']*'?
|
|
15
15
|
| .
|
|
@@ -27,19 +27,19 @@ import{$ as xI,Ca as id,Da as sS,Ea as ld,I as Tg,J as Bt,K as Dl,L as kg,M as H
|
|
|
27
27
|
| \*[^\)]*\)?
|
|
28
28
|
)?
|
|
29
29
|
| (?:${of.source})+
|
|
30
|
-
| ${
|
|
30
|
+
| ${_y}
|
|
31
31
|
| .
|
|
32
32
|
`.replace(/\s+/g,""),"gsu"),rf=new RegExp(yt`
|
|
33
33
|
\\ (?:
|
|
34
|
-
${
|
|
34
|
+
${Uy}
|
|
35
35
|
| .
|
|
36
36
|
)
|
|
37
37
|
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
38
|
-
| ${
|
|
38
|
+
| ${_y}
|
|
39
39
|
| &&
|
|
40
40
|
| .
|
|
41
|
-
`.replace(/\s+/g,""),"gsu");function
|
|
42
|
-
`,r);return{lastIndex:s===-1?t.length:s}}if(/^\s$/.test(n)){let s=/\s+/y;return s.lastIndex=r,{lastIndex:s.exec(t)?s.lastIndex:r}}}if(n===".")return{token:ji("dot",n)};if(n==="^"||n==="$"){let s=e.singleline?{"^":yt`\A`,$:yt`\Z`}[n]:n;return{token:Ay(s,n)}}return n==="|"?{token:bM(n)}:of.test(n)?{tokens:_M(n)}:{token:$r(ri(n),n)}}function IM(e,t,n){let r=[Py(t[1]==="^",t)],i=1,o;for(rf.lastIndex=n;o=rf.exec(e);){let s=o[0];if(s[0]==="["&&s[1]!==":")i++,r.push(Py(s[1]==="^",s));else if(s==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push($r(93,s));else if(i--,r.push(CM(s)),!i)break}else{let a=SM(s);Array.isArray(a)?r.push(...a):r.push(a)}}return{tokens:r,lastIndex:rf.lastIndex||e.length}}function SM(e){if(e[0]==="\\")return Hy(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Ws.has(t.groups.name))throw Error(`Invalid POSIX class "${e}"`);return ji("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?EM(e):e==="&&"?vM(e):$r(ri(e),e)}function Hy(e,{inCharClass:t}){let n=e[1];if(n==="c"||n==="C")return PM(e);if("dDhHsSwW".includes(n))return OM(e);if(e.startsWith(yt`\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 FM(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let r=e.split(/\\x/).slice(1).map((s)=>parseInt(s,16)),i=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),o=new TextEncoder;return[...i].map((s)=>{let a=[...o.encode(s)].map((l)=>`\\x${l.toString(16)}`).join("");return $r(ri(s),a)})}catch{throw Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return $r(DM(e),e);if($y.has(n))return $r($y.get(n),e);if(/\d/.test(n))return TM(t,e);if(e==="\\")throw Error(yt`Incomplete escape "\"`);if(n==="M")throw Error(`Unsupported meta "${e}"`);if([...e].length===2)return $r(e.codePointAt(1),e);throw Error(`Unexpected escape "${e}"`)}function bM(e){return{type:"Alternator",raw:e}}function Ay(e,t){return{type:"Assertion",kind:e,raw:t}}function _y(e){return{type:"Backreference",raw:e}}function $r(e,t){return{type:"Character",value:e,raw:t}}function CM(e){return{type:"CharacterClassClose",raw:e}}function EM(e){return{type:"CharacterClassHyphen",raw:e}}function vM(e){return{type:"CharacterClassIntersector",raw:e}}function Py(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function ji(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function Uy(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Pr(n.flags),raw:t}}function TM(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function kM(e){return{type:"GroupClose",raw:e}}function Mo(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function wM(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function LM(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function RM(e){return{type:"Subroutine",raw:e}}var AM=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),$y=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function PM(e){let t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw Error(`Unsupported control character "${e}"`);return $r(ri(t.toUpperCase())-64,e)}function $M(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"),o=Oy(n),s=Oy(r),a={};if(o&&(a.enable=o),s&&(a.disable=s),e.endsWith(")"))return t.replaceCurrentModX(i),Uy("flags",e,{flags:a});if(e.endsWith(":"))return t.pushModX(i),t.numOpenGroups++,Mo("group",e,{...(o||s)&&{flags:a}});throw Error(`Unexpected flag modifier "${e}"`)}function MM(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 o=i?i.split(",").filter((c)=>c!=="").map((c)=>/^[+-]?\d+$/.test(c)?+c:c):[],[s,a,l]=o,d=AM.has(n)?n.toLowerCase():"custom";switch(d){case"fail":case"mismatch":case"skip":if(o.length>0)throw Error(`Named callout arguments not allowed "${o}"`);break;case"error":if(o.length>1)throw Error(`Named callout allows only one argument "${o}"`);if(typeof s=="string")throw Error(`Named callout argument must be a number "${s}"`);break;case"max":if(!o.length||o.length>2)throw Error(`Named callout must have one or two arguments "${o}"`);if(typeof s=="string"&&!/^[A-Za-z_]\w*$/.test(s))throw Error(`Named callout argument one must be a tag or number "${s}"`);if(o.length===2&&(typeof a=="number"||!/^[<>X]$/.test(a)))throw Error(`Named callout optional argument two must be '<', '>', or 'X' "${a}"`);break;case"count":case"total_count":if(o.length>1)throw Error(`Named callout allows only one argument "${o}"`);if(o.length===1&&(typeof s=="number"||!/^[<>X]$/.test(s)))throw Error(`Named callout optional argument must be '<', '>', or 'X' "${s}"`);break;case"cmp":if(o.length!==3)throw Error(`Named callout must have three arguments "${o}"`);if(typeof s=="string"&&!/^[A-Za-z_]\w*$/.test(s))throw Error(`Named callout argument one must be a tag or number "${s}"`);if(typeof a=="number"||!/^(?:[<>!=]=|[<>])$/.test(a))throw Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${a}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw Error(`Undefined callout name "${n}"`);default:throw Error(`Unexpected named callout kind "${d}"`)}return wM(d,r??null,i?.split(",")??null,e)}function My(e){let t=null,n,r;if(e[0]==="{"){let{minStr:i,maxStr:o}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups;if(+i>1e5||o&&+o>1e5)throw Error("Quantifier value unsupported in Oniguruma");if(n=+i,r=o===void 0?+i:o===""?1/0:+o,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||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return LM(t,n,r,e)}function OM(e){let t=e[1].toLowerCase();return ji({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function FM(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return ji("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function Oy(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 NM(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 DM(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 HM(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[_y(n)];let o=[],s=i.match(/^[0-7]+|\d/g);for(let a=0;a<s.length;a++){let l=s[a],d;if(a===0&&l!=="8"&&l!=="9"){if(d=parseInt(l,8),d>127)throw Error(yt`Octal encoded byte above 177 unsupported "${n}"`)}else d=ri(l);o.push($r(d,(a===0?"\\":"")+l))}return o}function _M(e){let t=[],n=new RegExp(of,"gy"),r;for(;r=n.exec(e);){let i=r[0];if(i[0]==="{"){let o=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(i);if(o){let{min:s,max:a}=o.groups;if(+s>+a&&i.endsWith("?")){n.lastIndex--,t.push(My(i.slice(0,-1)));continue}}}t.push(My(i))}return t}function du(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((r)=>t[r]===n[r])}function By(e){return UM.has(e.type)}var UM=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function mu(e,t={}){let n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=Dy(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),i=(p,h)=>{let x=r.tokens[o.nextIndex];switch(o.parent=p,o.nextIndex++,x.type){case"Alternator":return Mr();case"Assertion":return BM(x);case"Backreference":return GM(x,o);case"Character":return Oo(x.value,{useLastValid:!!h.isCheckingRangeEnd});case"CharacterClassHyphen":return jM(x,o,h);case"CharacterClassOpen":return qM(x,o,h);case"CharacterSet":return zM(x,o);case"Directive":return JM(x.kind,{flags:x.flags});case"GroupOpen":return KM(x,o,h);case"NamedCallout":return QM(x.kind,x.tag,x.arguments);case"Quantifier":return VM(x,o);case"Subroutine":return WM(x,o);default:throw Error(`Unexpected token type "${x.type}"`)}},o={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},s=tO(ZM(r.flags)),a=s.body[0];for(;o.nextIndex<r.tokens.length;){let p=i(a,{});p.type==="Alternative"?(s.body.push(p),a=p):a.body.push(p)}let{capturingGroups:l,hasNumberedRef:d,namedGroupsByName:c,subroutines:m}=o;if(d&&c.size&&!n.rules.captureGroup)throw Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:p}of m)if(typeof p=="number"){if(p>l.length)throw Error("Subroutine uses a group number that's not defined");p&&(l[p-1].isSubroutined=!0)}else if(c.has(p)){if(c.get(p).length>1)throw Error(yt`Subroutine uses a duplicate group name "\g<${p}>"`);c.get(p)[0].isSubroutined=!0}else throw Error(yt`Subroutine uses a group name that's not defined "\g<${p}>"`);return s}function BM({kind:e}){return fu(Pr({"^":"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===yt`\B`||e===yt`\Y`})}function GM({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),i=(o,s=!1)=>{let a=t.capturingGroups.length,l=!1;if(o>a)if(t.skipBackrefValidation)l=!0;else throw Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,cu(s?a+1-o:o,{orphan:l})};if(n){let o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(o)return i(+o.groups.num,!!o.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 cu(r)}return i(+r)}function jM(e,t,n){let{tokens:r,walk:i}=t,o=t.parent,s=o.body.at(-1),a=r[t.nextIndex];if(!n.isCheckingRangeEnd&&s&&s.type!=="CharacterClass"&&s.type!=="CharacterClassRange"&&a&&a.type!=="CharacterClassOpen"&&a.type!=="CharacterClassClose"&&a.type!=="CharacterClassIntersector"){let l=i(o,{...n,isCheckingRangeEnd:!0});if(s.type==="Character"&&l.type==="Character")return o.body.pop(),YM(s,l);throw Error("Invalid character class range")}return Oo(ri("-"))}function qM({negate:e},t,n){let{tokens:r,walk:i}=t,o=[Xs()],s=r[t.nextIndex],a=qy(s);for(;a.type!=="CharacterClassClose";){if(a.type==="CharacterClassIntersector")o.push(Xs()),t.nextIndex++;else{let d=o.at(-1);d.body.push(i(d,n))}a=qy(r[t.nextIndex],s)}let l=Xs({negate:e});return o.length===1?l.body=o[0].body:(l.kind="intersection",l.body=o.map((d)=>d.body.length===1?d.body[0]:d)),t.nextIndex++,l}function zM({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:o,unicodePropertyMap:s}=r;if(e==="property"){let a=Fo(n);if(Ws.has(a)&&!s?.has(a))e="posix",n=a;else return qi(n,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:o,unicodePropertyMap:s})}return e==="posix"?eO(n,{negate:t}):pu(e,{negate:t})}function KM(e,t,n){let{tokens:r,capturingGroups:i,namedGroupsByName:o,skipLookbehindValidation:s,walk:a}=t,l=nO(e),d=l.type==="AbsenceFunction",c=jy(l),m=c&&l.negate;if(l.type==="CapturingGroup"&&(i.push(l),l.name&&Ry(o,l.name,[]).push(l)),d&&n.isInAbsenceFunction)throw Error("Nested absence function not supported by Oniguruma");let p=zy(r[t.nextIndex]);for(;p.type!=="GroupClose";){if(p.type==="Alternator")l.body.push(Mr()),t.nextIndex++;else{let h=l.body.at(-1),x=a(h,{...n,isInAbsenceFunction:n.isInAbsenceFunction||d,isInLookbehind:n.isInLookbehind||c,isInNegLookbehind:n.isInNegLookbehind||m});if(h.body.push(x),(c||n.isInLookbehind)&&!s){if(m||n.isInNegLookbehind){if(Gy(x)||x.type==="CapturingGroup")throw Error("Lookbehind includes a pattern not allowed by Oniguruma")}else if(Gy(x)||jy(x)&&x.negate)throw Error("Lookbehind includes a pattern not allowed by Oniguruma")}}p=zy(r[t.nextIndex])}return t.nextIndex++,l}function VM({kind:e,min:t,max:n},r){let i=r.parent,o=i.body.at(-1);if(!o||!By(o))throw Error("Quantifier requires a repeatable token");let s=af(e,t,n,o);return i.body.pop(),s}function WM({raw:e},t){let{capturingGroups:n,subroutines:r}=t,i=e.slice(3,-1),o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(o){let a=+o.groups.num,l=n.length;if(t.hasNumberedRef=!0,i={"":a,"+":l+a,"-":l+1-a}[o.groups.sign],i<1)throw Error("Invalid subroutine number")}else i==="0"&&(i=0);let s=lf(i);return r.push(s),s}function XM(e,t){if(e!=="repeater")throw Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:Ys(t?.body)}}function Mr(e){return{type:"Alternative",body:Ky(e?.body)}}function fu(e,t){let n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!t?.negate),n}function cu(e,t){let n=!!t?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function sf(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!rO(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:Ys(t?.body)}}function Oo(e,t){let n={useLastValid:!1,...t};if(e>1114111){let r=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?Error(`Invalid code point out of range "\\x{${r}}"`):Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:"Character",value:e}}function Xs(e){let t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:Ky(e?.body)}}function YM(e,t){if(t.value<e.value)throw Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function pu(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 JM(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Pr(t.flags)};throw Error(`Unexpected directive kind "${e}"`)}function ZM(e){return{type:"Flags",...e}}function Sn(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:Ys(e?.body)}}function ii(e){let t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:Ys(e?.body)}}function QM(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function eO(e,t){let n=!!t?.negate;if(!Ws.has(e))throw Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function af(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 tO(e,t){return{type:"Regex",body:Ys(t?.body),flags:e}}function lf(e){return{type:"Subroutine",ref:e}}function qi(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(Fo(e));if(!r){if(n.normalizeUnknownPropertyNames)r=iO(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw Error(yt`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function nO({flags:e,kind:t,name:n,negate:r,number:i}){switch(t){case"absence_repeater":return XM("repeater");case"atomic":return Sn({atomic:!0});case"capturing":return sf(i,{name:n});case"group":return Sn({flags:e});case"lookahead":case"lookbehind":return ii({behind:t==="lookbehind",negate:r});default:throw Error(`Unexpected group kind "${t}"`)}}function Ys(e){if(e===void 0)e=[Mr()];else if(!Array.isArray(e)||!e.length||!e.every((t)=>t.type==="Alternative"))throw Error("Invalid body; expected array of one or more Alternative nodes");return e}function Ky(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every((t)=>!!t.type))throw Error("Invalid body; expected array of nodes");return e}function Gy(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function jy(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function rO(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function iO(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,(t)=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function Fo(e){return e.replace(/[- _]+/g,"").toLowerCase()}function qy(e,t){let n=t;return Pr(e,`Unclosed character class${n?.type==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function zy(e){return Pr(e,"Unclosed group")}function zi(e,t,n=null){function r(o,s){for(let a=0;a<o.length;a++){let l=i(o[a],s,a,o);a=Math.max(-1,a+l)}}function i(o,s=null,a=null,l=null){let d=0,c=!1,m={node:o,parent:s,key:a,container:l,root:e,remove(){hu(l).splice(Math.max(0,No(a)+d),1),d--,c=!0},removeAllNextSiblings(){return hu(l).splice(No(a)+1)},removeAllPrevSiblings(){let S=No(a)+d;return d-=S,hu(l).splice(0,Math.max(0,S))},replaceWith(S,b={}){let E=!!b.traverse;l?l[Math.max(0,No(a)+d)]=S:Pr(s,"Can't replace root node")[a]=S,E&&i(S,s,a,l),c=!0},replaceWithMultiple(S,b={}){let E=!!b.traverse;if(hu(l).splice(Math.max(0,No(a)+d),1,...S),d+=S.length-1,E){let w=0;for(let k=0;k<S.length;k++)w+=i(S[k],s,No(a)+k+w,l)}c=!0},skip(){c=!0}},{type:p}=o,h=t["*"],x=t[p],I=typeof h=="function"?h:h?.enter,v=typeof x=="function"?x:x?.enter;if(I?.(m,n),v?.(m,n),!c)switch(p){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(o.body,o);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":i(o.min,o,"min"),i(o.max,o,"max");break;case"Quantifier":i(o.body,o,"body");break;case"Regex":r(o.body,o),i(o.flags,o,"flags");break;default:throw Error(`Unexpected node type "${p}"`)}return x?.exit?.(m,n),h?.exit?.(m,n),d}return i(e),e}function hu(e){if(!Array.isArray(e))throw Error("Container expected");return e}function No(e){if(typeof e!="number")throw Error("Numeric key expected");return e}var Vy=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Wy(e,t){for(let n=0;n<e.length;n++)if(e[n]>=t)e[n]++}function Xy(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var ln=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Js(e,t,n,r){let i=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),o=[!1],s=0,a="";for(let l of e.matchAll(i)){let{0:d,groups:{$skip:c}}=l;if(!c&&(!r||r===ln.DEFAULT===!s)){if(n instanceof Function)a+=n(l,{context:s?ln.CHAR_CLASS:ln.DEFAULT,negated:o[o.length-1]});else a+=n;continue}if(d[0]==="[")s++,o.push(d[1]==="^");else if(d==="]"&&s)s--,o.pop();a+=d}return a}function uf(e,t,n,r){Js(e,t,n,r)}function oO(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;let i=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");i.lastIndex=n;let o=0,s;while(s=i.exec(e)){let{0:a,groups:{$skip:l}}=s;if(!l&&(!r||r===ln.DEFAULT===!o))return s;if(a==="[")o++;else if(a==="]"&&o)o--;if(i.lastIndex==s.index)i.lastIndex++}return null}function Zs(e,t,n){return!!oO(e,t,0,n)}function Yy(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,i=0,o=1,s;while(s=n.exec(e)){let[a]=s;if(a==="[")i++;else if(!i){if(a==="(")o++;else if(a===")"){if(o--,!o){r=s.index;break}}}else if(a==="]")i--}return e.slice(t,r)}var Jy=new RegExp(String.raw`(?<noncapturingStart>${Vy})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function cf(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let i="(?>",o="(?:(?=(",s=[0],a=[],l=0,d=0,c=NaN,m;do{m=!1;let p=0,h=0,x=!1,I;Jy.lastIndex=Number.isNaN(c)?0:c+o.length;while(I=Jy.exec(e)){let{0:v,index:S,groups:{capturingStart:b,noncapturingStart:E}}=I;if(v==="[")p++;else if(!p){if(v===i&&!x)c=S,x=!0;else if(x&&E)h++;else if(b)if(x)h++;else l++,s.push(l+d);else if(v===")"&&x){if(!h){d++;let w=l+d;if(e=`${e.slice(0,c)}${o}${e.slice(c+i.length,S)}))<$$${w}>)${e.slice(S+1)}`,m=!0,a.push(w),Wy(n,w),r.size){let k=new Map;r.forEach((L,R)=>{k.set(R>=w?R+1:R,L.map((A)=>A>=w?A+1:A))}),r=k}break}h--}}else if(v==="]")p--}}while(m);return n.push(...a),e=Js(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:p,groups:{backrefNum:h,wrappedBackrefNum:x}})=>{if(h){let I=+h;if(I>s.length-1)throw Error(`Backref "${p}" greater than number of captures`);return`\\${s[I]}`}return`\\${x}`},ln.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var Zy=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,df=new RegExp(String.raw`
|
|
41
|
+
`.replace(/\s+/g,""),"gsu");function By(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=ZM(n.flags),i=[r.extended],o={captureGroup:n.rules.captureGroup,getCurrentModX(){return i.at(-1)},numOpenGroups:0,popModX(){i.pop()},pushModX(m){i.push(m)},replaceCurrentModX(m){i[i.length-1]=m},singleline:n.rules.singleline},s=[],a;for(du.lastIndex=0;a=du.exec(e);){let m=OM(o,e,a[0],du.lastIndex);m.tokens?s.push(...m.tokens):m.token&&s.push(m.token),m.lastIndex!==void 0&&(du.lastIndex=m.lastIndex)}let l=[],d=0;s.filter((m)=>m.type==="GroupOpen").forEach((m)=>{m.kind==="capturing"?m.number=++d:m.raw==="("&&l.push(m)}),d||l.forEach((m,p)=>{m.kind="capturing",m.number=p+1});let c=d||l.length;return{tokens:s.map((m)=>m.type==="EscapedNumber"?eO(m,c):m).flat(),flags:r}}function OM(e,t,n,r){let[i,o]=n;if(n==="["||n==="[^"){let s=FM(t,n,r);return{tokens:s.tokens,lastIndex:s.lastIndex}}if(i==="\\"){if("AbBGyYzZ".includes(o))return{token:Oy(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:zM(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:jy(n)}}if(o==="K")return{token:qy("keep",n)};if(o==="N"||o==="R")return{token:ji("newline",n,{negate:o==="N"})};if(o==="O")return{token:ji("any",n)};if(o==="X")return{token:ji("text_segment",n)};let s=Gy(n,{inCharClass:!1});return Array.isArray(s)?{tokens:s}:{token:s}}if(i==="("){if(o==="*")return{token:XM(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:WM(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Fo("group",n)};if(n==="(?>")return{token:Fo("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Fo(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Fo("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw Error(`Unsupported absence function kind "${n}"`);return{token:Fo("absence_repeater",n)}}throw n==="(?("?Error(`Unsupported conditional "${n}"`):Error(`Invalid or unsupported group option "${n}"`)}if(n===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw Error('Unmatched ")"');return{token:GM(n)}}if(e.getCurrentModX()){if(n==="#"){let s=t.indexOf(`
|
|
42
|
+
`,r);return{lastIndex:s===-1?t.length:s}}if(/^\s$/.test(n)){let s=/\s+/y;return s.lastIndex=r,{lastIndex:s.exec(t)?s.lastIndex:r}}}if(n===".")return{token:ji("dot",n)};if(n==="^"||n==="$"){let s=e.singleline?{"^":yt`\A`,$:yt`\Z`}[n]:n;return{token:Oy(s,n)}}return n==="|"?{token:DM(n)}:of.test(n)?{tokens:tO(n)}:{token:Mr(ri(n),n)}}function FM(e,t,n){let r=[Fy(t[1]==="^",t)],i=1,o;for(rf.lastIndex=n;o=rf.exec(e);){let s=o[0];if(s[0]==="["&&s[1]!==":")i++,r.push(Fy(s[1]==="^",s));else if(s==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(Mr(93,s));else if(i--,r.push(HM(s)),!i)break}else{let a=NM(s);Array.isArray(a)?r.push(...a):r.push(a)}}return{tokens:r,lastIndex:rf.lastIndex||e.length}}function NM(e){if(e[0]==="\\")return Gy(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Ys.has(t.groups.name))throw Error(`Invalid POSIX class "${e}"`);return ji("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?_M(e):e==="&&"?UM(e):Mr(ri(e),e)}function Gy(e,{inCharClass:t}){let n=e[1];if(n==="c"||n==="C")return VM(e);if("dDhHsSwW".includes(n))return YM(e);if(e.startsWith(yt`\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 JM(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let r=e.split(/\\x/).slice(1).map((s)=>parseInt(s,16)),i=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),o=new TextEncoder;return[...i].map((s)=>{let a=[...o.encode(s)].map((l)=>`\\x${l.toString(16)}`).join("");return Mr(ri(s),a)})}catch{throw Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return Mr(QM(e),e);if(Ny.has(n))return Mr(Ny.get(n),e);if(/\d/.test(n))return BM(t,e);if(e==="\\")throw Error(yt`Incomplete escape "\"`);if(n==="M")throw Error(`Unsupported meta "${e}"`);if([...e].length===2)return Mr(e.codePointAt(1),e);throw Error(`Unexpected escape "${e}"`)}function DM(e){return{type:"Alternator",raw:e}}function Oy(e,t){return{type:"Assertion",kind:e,raw:t}}function jy(e){return{type:"Backreference",raw:e}}function Mr(e,t){return{type:"Character",value:e,raw:t}}function HM(e){return{type:"CharacterClassClose",raw:e}}function _M(e){return{type:"CharacterClassHyphen",raw:e}}function UM(e){return{type:"CharacterClassIntersector",raw:e}}function Fy(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function ji(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function qy(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:$r(n.flags),raw:t}}function BM(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function GM(e){return{type:"GroupClose",raw:e}}function Fo(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function jM(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function qM(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function zM(e){return{type:"Subroutine",raw:e}}var KM=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),Ny=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function VM(e){let t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw Error(`Unsupported control character "${e}"`);return Mr(ri(t.toUpperCase())-64,e)}function WM(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"),o=Hy(n),s=Hy(r),a={};if(o&&(a.enable=o),s&&(a.disable=s),e.endsWith(")"))return t.replaceCurrentModX(i),qy("flags",e,{flags:a});if(e.endsWith(":"))return t.pushModX(i),t.numOpenGroups++,Fo("group",e,{...(o||s)&&{flags:a}});throw Error(`Unexpected flag modifier "${e}"`)}function XM(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 o=i?i.split(",").filter((c)=>c!=="").map((c)=>/^[+-]?\d+$/.test(c)?+c:c):[],[s,a,l]=o,d=KM.has(n)?n.toLowerCase():"custom";switch(d){case"fail":case"mismatch":case"skip":if(o.length>0)throw Error(`Named callout arguments not allowed "${o}"`);break;case"error":if(o.length>1)throw Error(`Named callout allows only one argument "${o}"`);if(typeof s=="string")throw Error(`Named callout argument must be a number "${s}"`);break;case"max":if(!o.length||o.length>2)throw Error(`Named callout must have one or two arguments "${o}"`);if(typeof s=="string"&&!/^[A-Za-z_]\w*$/.test(s))throw Error(`Named callout argument one must be a tag or number "${s}"`);if(o.length===2&&(typeof a=="number"||!/^[<>X]$/.test(a)))throw Error(`Named callout optional argument two must be '<', '>', or 'X' "${a}"`);break;case"count":case"total_count":if(o.length>1)throw Error(`Named callout allows only one argument "${o}"`);if(o.length===1&&(typeof s=="number"||!/^[<>X]$/.test(s)))throw Error(`Named callout optional argument must be '<', '>', or 'X' "${s}"`);break;case"cmp":if(o.length!==3)throw Error(`Named callout must have three arguments "${o}"`);if(typeof s=="string"&&!/^[A-Za-z_]\w*$/.test(s))throw Error(`Named callout argument one must be a tag or number "${s}"`);if(typeof a=="number"||!/^(?:[<>!=]=|[<>])$/.test(a))throw Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${a}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw Error(`Undefined callout name "${n}"`);default:throw Error(`Unexpected named callout kind "${d}"`)}return jM(d,r??null,i?.split(",")??null,e)}function Dy(e){let t=null,n,r;if(e[0]==="{"){let{minStr:i,maxStr:o}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups;if(+i>1e5||o&&+o>1e5)throw Error("Quantifier value unsupported in Oniguruma");if(n=+i,r=o===void 0?+i:o===""?1/0:+o,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||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return qM(t,n,r,e)}function YM(e){let t=e[1].toLowerCase();return ji({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function JM(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return ji("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function Hy(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 ZM(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 QM(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 eO(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[jy(n)];let o=[],s=i.match(/^[0-7]+|\d/g);for(let a=0;a<s.length;a++){let l=s[a],d;if(a===0&&l!=="8"&&l!=="9"){if(d=parseInt(l,8),d>127)throw Error(yt`Octal encoded byte above 177 unsupported "${n}"`)}else d=ri(l);o.push(Mr(d,(a===0?"\\":"")+l))}return o}function tO(e){let t=[],n=new RegExp(of,"gy"),r;for(;r=n.exec(e);){let i=r[0];if(i[0]==="{"){let o=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(i);if(o){let{min:s,max:a}=o.groups;if(+s>+a&&i.endsWith("?")){n.lastIndex--,t.push(Dy(i.slice(0,-1)));continue}}}t.push(Dy(i))}return t}function cu(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((r)=>t[r]===n[r])}function zy(e){return nO.has(e.type)}var nO=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function fu(e,t={}){let n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=By(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),i=(p,h)=>{let x=r.tokens[o.nextIndex];switch(o.parent=p,o.nextIndex++,x.type){case"Alternator":return Or();case"Assertion":return rO(x);case"Backreference":return iO(x,o);case"Character":return No(x.value,{useLastValid:!!h.isCheckingRangeEnd});case"CharacterClassHyphen":return oO(x,o,h);case"CharacterClassOpen":return sO(x,o,h);case"CharacterSet":return aO(x,o);case"Directive":return fO(x.kind,{flags:x.flags});case"GroupOpen":return lO(x,o,h);case"NamedCallout":return hO(x.kind,x.tag,x.arguments);case"Quantifier":return uO(x,o);case"Subroutine":return dO(x,o);default:throw Error(`Unexpected token type "${x.type}"`)}},o={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},s=yO(pO(r.flags)),a=s.body[0];for(;o.nextIndex<r.tokens.length;){let p=i(a,{});p.type==="Alternative"?(s.body.push(p),a=p):a.body.push(p)}let{capturingGroups:l,hasNumberedRef:d,namedGroupsByName:c,subroutines:m}=o;if(d&&c.size&&!n.rules.captureGroup)throw Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:p}of m)if(typeof p=="number"){if(p>l.length)throw Error("Subroutine uses a group number that's not defined");p&&(l[p-1].isSubroutined=!0)}else if(c.has(p)){if(c.get(p).length>1)throw Error(yt`Subroutine uses a duplicate group name "\g<${p}>"`);c.get(p)[0].isSubroutined=!0}else throw Error(yt`Subroutine uses a group name that's not defined "\g<${p}>"`);return s}function rO({kind:e}){return pu($r({"^":"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===yt`\B`||e===yt`\Y`})}function iO({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),i=(o,s=!1)=>{let a=t.capturingGroups.length,l=!1;if(o>a)if(t.skipBackrefValidation)l=!0;else throw Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,mu(s?a+1-o:o,{orphan:l})};if(n){let o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(o)return i(+o.groups.num,!!o.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 mu(r)}return i(+r)}function oO(e,t,n){let{tokens:r,walk:i}=t,o=t.parent,s=o.body.at(-1),a=r[t.nextIndex];if(!n.isCheckingRangeEnd&&s&&s.type!=="CharacterClass"&&s.type!=="CharacterClassRange"&&a&&a.type!=="CharacterClassOpen"&&a.type!=="CharacterClassClose"&&a.type!=="CharacterClassIntersector"){let l=i(o,{...n,isCheckingRangeEnd:!0});if(s.type==="Character"&&l.type==="Character")return o.body.pop(),mO(s,l);throw Error("Invalid character class range")}return No(ri("-"))}function sO({negate:e},t,n){let{tokens:r,walk:i}=t,o=[Js()],s=r[t.nextIndex],a=Wy(s);for(;a.type!=="CharacterClassClose";){if(a.type==="CharacterClassIntersector")o.push(Js()),t.nextIndex++;else{let d=o.at(-1);d.body.push(i(d,n))}a=Wy(r[t.nextIndex],s)}let l=Js({negate:e});return o.length===1?l.body=o[0].body:(l.kind="intersection",l.body=o.map((d)=>d.body.length===1?d.body[0]:d)),t.nextIndex++,l}function aO({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:o,unicodePropertyMap:s}=r;if(e==="property"){let a=Do(n);if(Ys.has(a)&&!s?.has(a))e="posix",n=a;else return qi(n,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:o,unicodePropertyMap:s})}return e==="posix"?gO(n,{negate:t}):hu(e,{negate:t})}function lO(e,t,n){let{tokens:r,capturingGroups:i,namedGroupsByName:o,skipLookbehindValidation:s,walk:a}=t,l=xO(e),d=l.type==="AbsenceFunction",c=Vy(l),m=c&&l.negate;if(l.type==="CapturingGroup"&&(i.push(l),l.name&&My(o,l.name,[]).push(l)),d&&n.isInAbsenceFunction)throw Error("Nested absence function not supported by Oniguruma");let p=Xy(r[t.nextIndex]);for(;p.type!=="GroupClose";){if(p.type==="Alternator")l.body.push(Or()),t.nextIndex++;else{let h=l.body.at(-1),x=a(h,{...n,isInAbsenceFunction:n.isInAbsenceFunction||d,isInLookbehind:n.isInLookbehind||c,isInNegLookbehind:n.isInNegLookbehind||m});if(h.body.push(x),(c||n.isInLookbehind)&&!s){if(m||n.isInNegLookbehind){if(Ky(x)||x.type==="CapturingGroup")throw Error("Lookbehind includes a pattern not allowed by Oniguruma")}else if(Ky(x)||Vy(x)&&x.negate)throw Error("Lookbehind includes a pattern not allowed by Oniguruma")}}p=Xy(r[t.nextIndex])}return t.nextIndex++,l}function uO({kind:e,min:t,max:n},r){let i=r.parent,o=i.body.at(-1);if(!o||!zy(o))throw Error("Quantifier requires a repeatable token");let s=af(e,t,n,o);return i.body.pop(),s}function dO({raw:e},t){let{capturingGroups:n,subroutines:r}=t,i=e.slice(3,-1),o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(o){let a=+o.groups.num,l=n.length;if(t.hasNumberedRef=!0,i={"":a,"+":l+a,"-":l+1-a}[o.groups.sign],i<1)throw Error("Invalid subroutine number")}else i==="0"&&(i=0);let s=lf(i);return r.push(s),s}function cO(e,t){if(e!=="repeater")throw Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:Zs(t?.body)}}function Or(e){return{type:"Alternative",body:Yy(e?.body)}}function pu(e,t){let n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!t?.negate),n}function mu(e,t){let n=!!t?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function sf(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!IO(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:Zs(t?.body)}}function No(e,t){let n={useLastValid:!1,...t};if(e>1114111){let r=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?Error(`Invalid code point out of range "\\x{${r}}"`):Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:"Character",value:e}}function Js(e){let t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:Yy(e?.body)}}function mO(e,t){if(t.value<e.value)throw Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function hu(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 fO(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:$r(t.flags)};throw Error(`Unexpected directive kind "${e}"`)}function pO(e){return{type:"Flags",...e}}function Sn(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:Zs(e?.body)}}function ii(e){let t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:Zs(e?.body)}}function hO(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function gO(e,t){let n=!!t?.negate;if(!Ys.has(e))throw Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function af(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 yO(e,t){return{type:"Regex",body:Zs(t?.body),flags:e}}function lf(e){return{type:"Subroutine",ref:e}}function qi(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(Do(e));if(!r){if(n.normalizeUnknownPropertyNames)r=SO(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw Error(yt`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function xO({flags:e,kind:t,name:n,negate:r,number:i}){switch(t){case"absence_repeater":return cO("repeater");case"atomic":return Sn({atomic:!0});case"capturing":return sf(i,{name:n});case"group":return Sn({flags:e});case"lookahead":case"lookbehind":return ii({behind:t==="lookbehind",negate:r});default:throw Error(`Unexpected group kind "${t}"`)}}function Zs(e){if(e===void 0)e=[Or()];else if(!Array.isArray(e)||!e.length||!e.every((t)=>t.type==="Alternative"))throw Error("Invalid body; expected array of one or more Alternative nodes");return e}function Yy(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every((t)=>!!t.type))throw Error("Invalid body; expected array of nodes");return e}function Ky(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function Vy(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function IO(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function SO(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,(t)=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function Do(e){return e.replace(/[- _]+/g,"").toLowerCase()}function Wy(e,t){let n=t;return $r(e,`Unclosed character class${n?.type==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function Xy(e){return $r(e,"Unclosed group")}function zi(e,t,n=null){function r(o,s){for(let a=0;a<o.length;a++){let l=i(o[a],s,a,o);a=Math.max(-1,a+l)}}function i(o,s=null,a=null,l=null){let d=0,c=!1,m={node:o,parent:s,key:a,container:l,root:e,remove(){gu(l).splice(Math.max(0,Ho(a)+d),1),d--,c=!0},removeAllNextSiblings(){return gu(l).splice(Ho(a)+1)},removeAllPrevSiblings(){let S=Ho(a)+d;return d-=S,gu(l).splice(0,Math.max(0,S))},replaceWith(S,b={}){let E=!!b.traverse;l?l[Math.max(0,Ho(a)+d)]=S:$r(s,"Can't replace root node")[a]=S,E&&i(S,s,a,l),c=!0},replaceWithMultiple(S,b={}){let E=!!b.traverse;if(gu(l).splice(Math.max(0,Ho(a)+d),1,...S),d+=S.length-1,E){let w=0;for(let T=0;T<S.length;T++)w+=i(S[T],s,Ho(a)+T+w,l)}c=!0},skip(){c=!0}},{type:p}=o,h=t["*"],x=t[p],I=typeof h=="function"?h:h?.enter,v=typeof x=="function"?x:x?.enter;if(I?.(m,n),v?.(m,n),!c)switch(p){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(o.body,o);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":i(o.min,o,"min"),i(o.max,o,"max");break;case"Quantifier":i(o.body,o,"body");break;case"Regex":r(o.body,o),i(o.flags,o,"flags");break;default:throw Error(`Unexpected node type "${p}"`)}return x?.exit?.(m,n),h?.exit?.(m,n),d}return i(e),e}function gu(e){if(!Array.isArray(e))throw Error("Container expected");return e}function Ho(e){if(typeof e!="number")throw Error("Numeric key expected");return e}var Jy=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Zy(e,t){for(let n=0;n<e.length;n++)if(e[n]>=t)e[n]++}function Qy(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var ln=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Qs(e,t,n,r){let i=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),o=[!1],s=0,a="";for(let l of e.matchAll(i)){let{0:d,groups:{$skip:c}}=l;if(!c&&(!r||r===ln.DEFAULT===!s)){if(n instanceof Function)a+=n(l,{context:s?ln.CHAR_CLASS:ln.DEFAULT,negated:o[o.length-1]});else a+=n;continue}if(d[0]==="[")s++,o.push(d[1]==="^");else if(d==="]"&&s)s--,o.pop();a+=d}return a}function uf(e,t,n,r){Qs(e,t,n,r)}function bO(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;let i=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");i.lastIndex=n;let o=0,s;while(s=i.exec(e)){let{0:a,groups:{$skip:l}}=s;if(!l&&(!r||r===ln.DEFAULT===!o))return s;if(a==="[")o++;else if(a==="]"&&o)o--;if(i.lastIndex==s.index)i.lastIndex++}return null}function ea(e,t,n){return!!bO(e,t,0,n)}function ex(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,i=0,o=1,s;while(s=n.exec(e)){let[a]=s;if(a==="[")i++;else if(!i){if(a==="(")o++;else if(a===")"){if(o--,!o){r=s.index;break}}}else if(a==="]")i--}return e.slice(t,r)}var tx=new RegExp(String.raw`(?<noncapturingStart>${Jy})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function cf(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let i="(?>",o="(?:(?=(",s=[0],a=[],l=0,d=0,c=NaN,m;do{m=!1;let p=0,h=0,x=!1,I;tx.lastIndex=Number.isNaN(c)?0:c+o.length;while(I=tx.exec(e)){let{0:v,index:S,groups:{capturingStart:b,noncapturingStart:E}}=I;if(v==="[")p++;else if(!p){if(v===i&&!x)c=S,x=!0;else if(x&&E)h++;else if(b)if(x)h++;else l++,s.push(l+d);else if(v===")"&&x){if(!h){d++;let w=l+d;if(e=`${e.slice(0,c)}${o}${e.slice(c+i.length,S)}))<$$${w}>)${e.slice(S+1)}`,m=!0,a.push(w),Zy(n,w),r.size){let T=new Map;r.forEach((L,R)=>{T.set(R>=w?R+1:R,L.map((A)=>A>=w?A+1:A))}),r=T}break}h--}}else if(v==="]")p--}}while(m);return n.push(...a),e=Qs(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:p,groups:{backrefNum:h,wrappedBackrefNum:x}})=>{if(h){let I=+h;if(I>s.length-1)throw Error(`Backref "${p}" greater than number of captures`);return`\\${s[I]}`}return`\\${x}`},ln.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var nx=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,df=new RegExp(String.raw`
|
|
43
43
|
\\(?: \d+
|
|
44
44
|
| c[A-Za-z]
|
|
45
45
|
| [gk]<[^>]+>
|
|
@@ -52,9 +52,9 @@ import{$ as xI,Ca as id,Da as sS,Ea as ld,I as Tg,J as Bt,K as Dl,L as kg,M as H
|
|
|
52
52
|
| [A-Za-z\-]+:
|
|
53
53
|
| \(DEFINE\)
|
|
54
54
|
))?
|
|
55
|
-
| (?<qBase>${
|
|
55
|
+
| (?<qBase>${nx})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
56
56
|
| \\?.
|
|
57
|
-
`.replace(/\s+/g,""),"gsu");function mf(e){if(!new RegExp(`${
|
|
57
|
+
`.replace(/\s+/g,""),"gsu");function mf(e){if(!new RegExp(`${nx}\\+`).test(e))return{pattern:e};let t=[],n=null,r=null,i="",o=0,s;df.lastIndex=0;while(s=df.exec(e)){let{0:a,index:l,groups:{qBase:d,qMod:c,invalidQ:m}}=s;if(a==="["){if(!o)r=l;o++}else if(a==="]")if(o)o--;else r=null;else if(!o){if(c==="+"&&i&&!i.startsWith("(")){if(m)throw Error(`Invalid quantifier "${a}"`);let p=-1;if(/^\{\d+\}$/.test(d))e=Qy(e,l+d.length,c,"");else{if(i===")"||i==="]"){let h=i===")"?n:r;if(h===null)throw Error(`Invalid unmatched "${i}"`);e=`${e.slice(0,h)}(?>${e.slice(h,l)}${d})${e.slice(l+a.length)}`}else e=`${e.slice(0,l-i.length)}(?>${i}${d})${e.slice(l+a.length)}`;p+=4}df.lastIndex+=p}else if(a[0]==="(")t.push(l);else if(a===")")n=t.length?t.pop():null}i=a}return{pattern:e}}var Mn=String.raw,CO=Mn`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,pf=Mn`\(\?R=(?<rDepth>[^\)]+)\)|${CO}`,yu=Mn`\(\?<(?![=!])(?<captureName>[^>]+)>`,ax=Mn`${yu}|(?<unnamed>\()(?!\?)`,Ki=new RegExp(Mn`${yu}|${pf}|\(\?|\\?.`,"gsu"),ff="Cannot use multiple overlapping recursions";function lx(e,t){let{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t},i=t?.captureTransfers??new Map;if(!new RegExp(pf,"su").test(e))return{pattern:e,captureTransfers:i,hiddenCaptures:n};if(r==="plugin"&&ea(e,Mn`\(\?\(DEFINE\)`,ln.DEFAULT))throw Error("DEFINE groups cannot be used with recursion");let o=[],s=ea(e,Mn`\\[1-9]`,ln.DEFAULT),a=new Map,l=[],d=!1,c=0,m=0,p;Ki.lastIndex=0;while(p=Ki.exec(e)){let{0:h,groups:{captureName:x,rDepth:I,gRNameOrNum:v,gRDepth:S}}=p;if(h==="[")c++;else if(!c){if(I){if(rx(I),d)throw Error(ff);if(s)throw Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);let b=e.slice(0,p.index),E=e.slice(Ki.lastIndex);if(ea(E,pf,ln.DEFAULT))throw Error(ff);let w=+I-1;e=ix(b,E,w,!1,n,o,m),i=sx(i,b,w,o.length,0,m);break}else if(v){rx(S);let b=!1;for(let N of l)if(N.name===v||N.num===+v){if(b=!0,N.hasRecursedWithin)throw Error(ff);break}if(!b)throw Error(Mn`Recursive \g cannot be used outside the referenced group "${r==="external"?v:Mn`\g<${v}&R=${S}>`}"`);let E=a.get(v),w=ex(e,E);if(s&&ea(w,Mn`${yu}|\((?!\?)`,ln.DEFAULT))throw Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);let T=e.slice(E,p.index),L=w.slice(T.length+h.length),R=o.length,A=+S-1,O=ix(T,L,A,!0,n,o,m);i=sx(i,T,A,o.length-R,R,m);let D=e.slice(0,E),X=e.slice(E+w.length);e=`${D}${O}${X}`,Ki.lastIndex+=O.length-h.length-T.length-L.length,l.forEach((N)=>N.hasRecursedWithin=!0),d=!0}else if(x)m++,a.set(String(m),Ki.lastIndex),a.set(x,Ki.lastIndex),l.push({num:m,name:x});else if(h[0]==="("){let b=h==="(";if(b)m++,a.set(String(m),Ki.lastIndex);l.push(b?{num:m}:{})}else if(h===")")l.pop()}else if(h==="]")c--}return n.push(...o),{pattern:e,captureTransfers:i,hiddenCaptures:n}}function rx(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw Error(t);if(e=+e,e<2||e>100)throw Error(t)}function ix(e,t,n,r,i,o,s){let a=new Set;if(r)uf(e+t,yu,({groups:{captureName:d}})=>{a.add(d)},ln.DEFAULT);let l=[n,r?a:null,i,o,s];return`${e}${ox(`(?:${e}`,"forward",...l)}(?:)${ox(`${t})`,"backward",...l)}${t}`}function ox(e,t,n,r,i,o,s){let l=(c)=>t==="forward"?c+2:n-c+2-1,d="";for(let c=0;c<n;c++){let m=l(c);d+=Qs(e,Mn`${ax}|\\k<(?<backref>[^>]+)>`,({0:p,groups:{captureName:h,unnamed:x,backref:I}})=>{if(I&&r&&!r.has(I))return p;let v=`_$${m}`;if(x||h){let S=s+o.length+1;return o.push(S),EO(i,S),x?p:`(?<${h}${v}>`}return Mn`\k<${I}${v}>`},ln.DEFAULT)}return d}function EO(e,t){for(let n=0;n<e.length;n++)if(e[n]>=t)e[n]++}function sx(e,t,n,r,i,o){if(e.size&&r){let s=0;uf(t,ax,()=>s++,ln.DEFAULT);let a=o-s+i,l=new Map;return e.forEach((d,c)=>{let m=(r-s*n)/n,p=s*n,h=c>a+s?c+r:c,x=[];for(let I of d)if(I<=a)x.push(I);else if(I>a+s+m)x.push(I+r);else if(I<=a+s)for(let v=0;v<=n;v++)x.push(I+s*v);else for(let v=0;v<=n;v++)x.push(I+p+m*v);l.set(h,x)}),l}return e}var{fromCodePoint:vt,raw:oe}=String,Bn={},Iu=globalThis.RegExp;Bn.flagGroups=(()=>{try{new Iu("(?i:)")}catch{return!1}return!0})();Bn.unicodeSets=(()=>{try{new Iu("[[]]","v")}catch{return!1}return!0})();Bn.bugFlagVLiteralHyphenIsRange=Bn.unicodeSets?(()=>{try{new Iu(oe`[\d\-a]`,"v")}catch{return!0}return!1})():!1;Bn.bugNestedClassIgnoresNegation=Bn.unicodeSets&&new Iu("[[^a]]","v").test("a");function xu(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function ta(e,t,n){if(!e.has(t))e.set(t,n);return e.get(t)}function If(e,t){return ux[e]>=ux[t]}function vO(e,t){if(e==null)throw Error(t??"Value expected");return e}var ux={ES2025:2025,ES2024:2024,ES2018:2018},kO={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function px(e={}){if({}.toString.call(e)!=="[object Object]")throw Error("Unexpected options");if(e.target!==void 0&&!kO[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}};if(t.target==="auto")t.target=Bn.flagGroups?"ES2025":Bn.unicodeSets?"ES2024":"ES2018";return t}var TO="[\t-\r ]",wO=new Set([vt(304),vt(305)]),Fr=oe`[\p{L}\p{M}\p{N}\p{Pc}]`;function hx(e){if(wO.has(e))return[e];let t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),i=AO.get(n),o=LO.get(n),s=RO.get(n);if([...r].length===1)t.add(r);return s&&t.add(s),i&&t.add(i),t.add(n),o&&t.add(o),[...t]}var Sf=new Map(`C Other
|
|
58
58
|
Cc Control cntrl
|
|
59
59
|
Cf Format
|
|
60
60
|
Cn Unassigned
|
|
@@ -144,28 +144,28 @@ Uppercase Upper
|
|
|
144
144
|
Variation_Selector VS
|
|
145
145
|
White_Space space
|
|
146
146
|
XID_Continue XIDC
|
|
147
|
-
XID_Start XIDS`.split(/\s/).map((e)=>[
|
|
147
|
+
XID_Start XIDS`.split(/\s/).map((e)=>[Do(e),e])),LO=new Map([["s",vt(383)],[vt(383),"s"]]),RO=new Map([[vt(223),vt(7838)],[vt(107),vt(8490)],[vt(229),vt(8491)],[vt(969),vt(8486)]]),AO=new Map([oi(453),oi(456),oi(459),oi(498),...hf(8072,8079),...hf(8088,8095),...hf(8104,8111),oi(8124),oi(8140),oi(8188)]),PO=new Map([["alnum",oe`[\p{Alpha}\p{Nd}]`],["alpha",oe`\p{Alpha}`],["ascii",oe`\p{ASCII}`],["blank",oe`[\p{Zs}\t]`],["cntrl",oe`\p{Cc}`],["digit",oe`\p{Nd}`],["graph",oe`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",oe`\p{Lower}`],["print",oe`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",oe`[\p{P}\p{S}]`],["space",oe`\p{space}`],["upper",oe`\p{Upper}`],["word",oe`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",oe`\p{AHex}`]]);function $O(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function oi(e){let t=vt(e);return[t.toLowerCase(),t]}function hf(e,t){return $O(e,t).map((n)=>oi(n))}var gx=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function MO(e,t){let n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};yx(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:If(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};zi(e,OO,r);let i={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},o={currentFlags:i,prevFlags:null,globalFlags:i,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};zi(e,FO,o);let s={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return zi(e,NO,s),e._originMap=o.groupOriginByCopy,e._strategy=r.strategy,e}var OO={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:i}=e;if(i==="repeater"){let o=Sn();o.body[0].body.push(ii({negate:!0,body:r}),qi("Any"));let s=Sn();s.body[0].body.push(af("greedy",0,1/0,o)),n(ft(s,t),{traverse:!0})}else throw Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){let i=e.body.filter((o)=>o.kind==="flags");for(let o=n+1;o<t.body.length;o++){let s=t.body[o];ta(r,s,[]).push(...i)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=Ix(t.get(e));if(n){let r=Sn({flags:n});r.body[0].body=e.body,e.body=[ft(r,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:i,remove:o,replaceWith:s},a){let{kind:l,negate:d}=e,{asciiWordBoundaries:c,avoidSubclass:m,supportedGNodes:p,wordIsAscii:h}=a;if(l==="text_segment_boundary")throw Error(`Unsupported text segment boundary "\\${d?"Y":"y"}"`);else if(l==="line_end")s(ft(ii({body:[Or({body:[pu("string_end")]}),Or({body:[No(10)]})]}),t));else if(l==="line_start")s(ft(Nr(oe`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(l==="search_start")if(p.has(e))i.flags.sticky=!0,o();else{let x=r[n-1];if(x&&GO(x))s(ft(ii({negate:!0}),t));else if(m)throw Error(oe`Uses "\G" in a way that requires a subclass`);else s(si(pu("string_start"),t)),a.strategy="clip_search"}else if(l==="string_end"||l==="string_start");else if(l==="string_end_newline")s(ft(Nr(oe`(?=\n?\z)`),t));else if(l==="word_boundary"){if(!h&&!c){let x=`(?:(?<=${Fr})(?!${Fr})|(?<!${Fr})(?=${Fr}))`,I=`(?:(?<=${Fr})(?=${Fr})|(?<!${Fr})(?!${Fr}))`;s(ft(Nr(d?I:x),t))}}else throw Error(`Unexpected assertion kind "${l}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;if(typeof n==="string"&&!yf(n))n=gf(n,t),e.ref=n},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;if(r&&!yf(r))r=gf(r,t),e.name=r;if(n.set(e.number,e),r)n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if(t.kind==="intersection"){let r=Js({body:[e]});n(ft(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:i,digitIsAscii:o,spaceIsAscii:s,wordIsAscii:a}){let{kind:l,negate:d,value:c}=e;if(o&&(l==="digit"||c==="digit")){n(si(hu("digit",{negate:d}),t));return}if(s&&(l==="space"||c==="space")){n(ft(xf(Nr(TO),d),t));return}if(a&&(l==="word"||c==="word")){n(si(hu("word",{negate:d}),t));return}if(l==="any")n(si(qi("Any"),t));else if(l==="digit")n(si(qi("Nd",{negate:d}),t));else if(l==="dot");else if(l==="text_segment"){if(r==="strict")throw Error(oe`Use of "\X" requires non-strict accuracy`);let m="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",p=oe`\p{RI}{2}|${m}(?:\u200D${m})*`;n(ft(Nr(oe`(?>\r\n|${i?oe`\p{RGI_Emoji}`:p}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(l==="hex")n(si(qi("AHex",{negate:d}),t));else if(l==="newline")n(ft(Nr(d?`[^
|
|
148
148
|
]`:`(?>\r
|
|
149
149
|
?|[
|
|
150
|
-
\v\f
\u2028\u2029])`),t));else if(l==="posix")if(!i&&(c==="graph"||c==="print")){if(r==="strict")throw Error(`POSIX class "${c}" requires min target ES2024 or non-strict accuracy`);let m={graph:"!-~",print:" -~"}[c];if(d)m=`\x00-${vt(m.codePointAt(0)-1)}${vt(m.codePointAt(2)+1)}-\uDBFF\uDFFF`;n(ft(Fr(`[${m}]`),t))}else n(ft(xf(Fr(hO.get(c)),d),t));else if(l==="property"){if(!Sf.has(Fo(c)))e.key="sc"}else if(l==="space")n(si(qi("space",{negate:d}),t));else if(l==="word")n(ft(xf(Fr(Or),d),t));else throw Error(`Unexpected character set kind "${l}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:o,removeAllNextSiblings:s}){let{kind:a,flags:l}=e;if(a==="flags")if(!l.enable&&!l.disable)r();else{let d=Sn({flags:l});d.body[0].body=s(),i(ft(d,t),{traverse:!0})}else if(a==="keep"){let d=n.body[0],m=n.body.length===1&&du(d,{type:"Group"})&&d.body[0].body.length===1?d.body[0]:n;if(t.parent!==m||m.body.length>1)throw Error(oe`Uses "\K" in a way that's unsupported`);let p=ii({behind:!0});p.body[0].body=o(),i(ft(p,t))}else throw Error(`Unexpected directive kind "${a}"`)},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((n)=>delete e[n]),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;if(n==="lookbehind")t.passedLookbehind=!0},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r==="fail")n(ft(ii({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){let t=Sn();t.body[0].body.push(e.body),e.body=ft(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let o of e.body)if(o.body.length===1&&o.body[0].kind==="search_start")o.body.pop();else{let s=yx(o.body);if(s)r=!0,Array.isArray(s)?n.push(...s):n.push(s);else i=!0}if(r&&!i)n.forEach((o)=>t.add(o))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw Error(oe`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;if(typeof n==="string"&&!yf(n))n=gf(n,t),e.ref=n}},IO={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;if(!r)n.set(e,[...t.get(i).map(({node:o})=>o)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:o,multiplexCapturesToLeftByRef:s,openRefs:a,reffedNodesByReferencer:l}){let d=i.get(e);if(d&&a.has(e.number)){let m=si(sx(e.number),t);l.set(m,a.get(e.number)),n(m);return}if(a.set(e.number,e),s.set(e.number,[]),e.name)Qs(s,e.name,[]);let c=s.get(e.name??e.number);for(let m=0;m<c.length;m++){let p=c[m];if(d===p.node||d&&d===p.origin||e===p.origin){c.splice(m,1);break}}if(s.get(e.number).push({node:e,origin:d}),e.name)s.get(e.name).push({node:e,origin:d});if(e.name){let m=Qs(o,e.name,new Map),p=!1;if(d)p=!0;else for(let h of m.values())if(!h.hasDuplicateNameToRemove){p=!0;break}o.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:p})}},exit({node:e},{openRefs:t}){if(t.get(e.number)===e)t.delete(e.number)}},Group:{enter({node:e},t){if(t.prevFlags=t.currentFlags,e.flags)t.currentFlags=yu(t.currentFlags,e.flags)},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:o}=e;if(i){let c=t;while(c=c.parent)if(c.type==="CapturingGroup"&&(c.name===o||c.number===o))break;r.reffedNodesByReferencer.set(e,c);return}let s=r.subroutineRefMap.get(o),a=o===0,l=a?sx(0):px(s,r.groupOriginByCopy,null),d=l;if(!a){let c=hx(EO(s,(p)=>p.type==="Group"&&!!p.flags)),m=c?yu(r.globalFlags,c):r.globalFlags;if(!bO(m,r.currentFlags))d=Sn({flags:vO(m)}),d.body[0].body.push(l)}n(ft(d,t),{traverse:!a})}},SO={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let o=r.reffedNodesByReferencer.get(e).filter((s)=>CO(s,e));if(!o.length)n(ft(ii({negate:!0}),t));else if(o.length>1){let s=Sn({atomic:!0,body:o.reverse().map((a)=>Mr({body:[cu(a.number)]}))});n(ft(s,t))}else e.ref=o[0].number},CapturingGroup({node:e},t){if(e.number=++t.numCapturesToLeft,e.name){if(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 r=0;r<n;r++){let i=sf();e.body.at(-1).body.push(i)}}},Subroutine({node:e},t){if(!e.isRecursive||e.ref===0)return;e.ref=t.reffedNodesByReferencer.get(e).number}};function fx(e){zi(e,{"*"({node:t,parent:n}){t.parent=n}})}function bO(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function CO(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;let r=gx(n.parent);for(let i of r){if(i===n)break;if(i===e||xx(i,e))return!0}}while(n=n.parent);throw Error("Unexpected path")}function px(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[o,s]of Object.entries(e))if(o==="parent")i.parent=Array.isArray(n)?r:n;else if(s&&typeof s==="object")i[o]=px(s,t,i,n);else{if(o==="type"&&s==="CapturingGroup")t.set(i,t.get(e)??e);i[o]=s}return i}function sx(e){let t=lf(e);return t.isRecursive=!0,t}function EO(e,t){let n=[];while(e=e.parent)if(!t||t(e))n.push(e);return n}function gf(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function hx(e){let t=["dotAll","ignoreCase"],n={enable:{},disable:{}};if(e.forEach(({flags:r})=>{t.forEach((i)=>{if(r.enable?.[i])delete n.disable[i],n.enable[i]=!0;if(r.disable?.[i])n.disable[i]=!0})}),!Object.keys(n.enable).length)delete n.enable;if(!Object.keys(n.disable).length)delete n.disable;if(n.enable||n.disable)return n;return null}function vO({dotAll:e,ignoreCase:t}){let n={};if(e||t)n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0);if(!e||!t)n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0);return n}function gx(e){if(!e)throw Error("Node expected");let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function yx(e){let t=e.find((n)=>n.kind==="search_start"||wO(n,{negate:!1})||!TO(n));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 n=[];for(let r of t.body){let i=yx(r.body);if(!i)return null;Array.isArray(i)?n.push(...i):n.push(i)}return n}return null}function xx(e,t){let n=gx(e)??[];for(let r of n)if(r===t||xx(r,t))return!0;return!1}function TO({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function kO(e){let t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function wO(e,t){let n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&du(e.body[0],{type:"Assertion",kind:"search_start"})}function yf(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Fr(e,t){let r=mu(e,{...t,unicodePropertyMap:Sf}).body;if(r.length>1||r[0].body.length>1)return Sn({body:r});return r[0].body[0]}function xf(e,t){return e.negate=t,e}function si(e,t){return e.parent=t,e}function ft(e,t){return fx(e),e.parent=t,e}function LO(e,t){let n=dx(t),r=If(n.target,"ES2024"),i=If(n.target,"ES2025"),o=n.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw Error("Invalid recursionLimit; use 2-20");let s=null,a=null;if(!i){let h=[e.flags.ignoreCase];zi(e,RO,{getCurrentModI:()=>h.at(-1),popModI(){h.pop()},pushModI(x){h.push(x)},setHasCasedChar(){if(h.at(-1))s=!0;else a=!0}})}let l={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||s)&&!a)},d=e,c={accuracy:n.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:d,originMap:e._originMap,recursionLimit:o,useAppliedIgnoreCase:!!(!i&&s&&a),useFlagMods:i,useFlagV:r,verbose:n.verbose};function m(h){return c.lastNode=d,d=h,lO(AO[h.type],`Unexpected node type "${h.type}"`)(h,c,m)}let p={pattern:e.body.map(m).join("|"),flags:m(e.flags),options:{...e.options}};if(!r)delete p.options.force.v,p.options.disable.v=!0,p.options.unicodeSetsPlugin=null;return p._captureTransfers=new Map,p._hiddenCaptures=[],c.captureMap.forEach((h,x)=>{if(h.hidden)p._hiddenCaptures.push(x);if(h.transferTo)Qs(p._captureTransfers,h.transferTo,[]).push(x)}),p}var RO={"*":{enter({node:e},t){if(lx(e)){let n=t.getCurrentModI();t.pushModI(e.flags?yu({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){if(lx(e))t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){if(bf(vt(e.value)))t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){if(t(),Ix(e,{firstOnly:!0}).length)n.setHasCasedChar()},CharacterSet({node:e},t){if(e.kind==="property"&&mx.has(e.value))t.setHasCasedChar()}},AO={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?oe`\B`:oe`\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:o}=e,s={ignoreCase:t.currentFlags.ignoreCase},a=t.originMap.get(e);if(a){if(s.hidden=!0,o>a.number)s.transferTo=a.number}return t.captureMap.set(o,s),`(${i?`?<${i}>`:""}${r.map(n).join("|")})`},Character({value:e},t){let n=vt(e),r=Do(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&bf(n)){let i=cx(n);return t.inCharClass?i.join(""):i.length>1?`[${i.join("")}]`:i[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:o}=e,{body:s}=e;if(r==="intersection"&&!t.useFlagV)throw Error("Use of character class intersection requires min target ES2024");if(Bn.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&s.some(ux))s=[Oo(45),...s.filter((d)=>!ux(d))];let a=()=>`[${i?"^":""}${s.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||Bn.bugNestedClassIgnoresNegation)&&!i){let c=s.filter((m)=>m.type==="CharacterClass"&&m.kind==="union"&&m.negate);if(c.length){let m=Sn(),p=m.body[0];if(m.parent=o,p.parent=m,s=s.filter((h)=>!c.includes(h)),e.body=s,s.length)e.parent=p,p.body.push(e);else m.body.pop();return c.forEach((h)=>{let x=Mr({body:[h]});h.parent=x,x.parent=m,m.body.push(x)}),n(m)}}t.inCharClass=!0;let d=a();return t.inCharClass=!1,d}let l=s[0];if(r==="union"&&!i&&l&&((!t.useFlagV||!t.verbose)&&o.kind==="union"&&!(Bn.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&o.kind==="intersection"&&s.length===1&&l.type!=="CharacterClassRange"))return s.map(n).join("");if(!t.useFlagV&&o.type==="CharacterClass")throw Error("Uses nested character class in a way that requires min target ES2024");return a()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},o=Do(n,i),s=Do(r,i),a=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let l=Ix(e);FO(l).forEach((c)=>{a.add(Array.isArray(c)?`${Do(c[0],i)}-${Do(c[1],i)}`:Do(c,i))})}return`${o}-${s}${[...a].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e==="dot")return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?".":"[^]":oe`[^\n]`;if(e==="digit")return t?oe`\D`:oe`\d`;if(e==="property"){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&mx.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?oe`\P`:oe`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?oe`\W`:oe`\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,o){let s=i.currentFlags;if(n)i.currentFlags=yu(s,n);let a=t.map(o).join("|"),l=!i.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!i.useFlagMods||!n)?a:`(?${NO(e,n,i.useFlagMods)}${a})`;return i.currentFlags=s,l},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)+DO(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})`:oe`\g<${t}&R=${r}>`}},PO=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),$O=new Set(["-","\\","]","^","["]),MO=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),ax=new Map([[9,oe`\t`],[10,oe`\n`],[11,oe`\v`],[12,oe`\f`],[13,oe`\r`],[8232,oe`\u2028`],[8233,oe`\u2029`],[65279,oe`\uFEFF`]]),OO=/^\p{Cased}$/u;function bf(e){return OO.test(e)}function Ix(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,o=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return o;for(let s=r;s<=i;s++){let a=vt(s);if(!bf(a))continue;let l=cx(a).filter((d)=>{let c=d.codePointAt(0);return c<r||c>i});if(l.length){if(o.push(...l),n)break}}return o}function Do(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(ax.has(e))return ax.get(e);if(e<32||e>126&&e<160||e>262143||t&&HO(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let i=n?r?MO:$O:PO,o=vt(e);return(i.has(o)?"\\":"")+o}function FO(e){let t=e.map((i)=>i.codePointAt(0)).sort((i,o)=>i-o),n=[],r=null;for(let i=0;i<t.length;i++)if(t[i+1]===t[i]+1)r??=t[i];else if(r===null)n.push(t[i]);else n.push([r,t[i]]),r=null;return n}function NO(e,t,n){if(e)return">";let r="";if(t&&n){let{enable:i,disable:o}=t;r=(i?.ignoreCase?"i":"")+(i?.dotAll?"s":"")+(o?"-":"")+(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")}return`${r}:`}function DO({kind:e,max:t,min:n}){let r;if(!n&&t===1)r="?";else if(!n&&t===1/0)r="*";else if(n===1&&t===1/0)r="+";else if(n===t)r=`{${n}}`;else r=`{${n},${t===1/0?"":t}}`;return r+{greedy:"",lazy:"?",possessive:"+"}[e]}function lx({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function HO(e){return e>47&&e<58}function ux({type:e,value:t}){return e==="Character"&&t===45}var _O=class e extends RegExp{#t=new Map;#e=null;#r;#n=null;#i=null;rawOptions={};get source(){return this.#r||"(?:)"}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error("Cannot provide options when copying a regexp");let o=t;super(o,n);if(this.#r=o.source,o instanceof e)this.#t=o.#t,this.#n=o.#n,this.#i=o.#i,this.rawOptions=o.rawOptions}else{let o={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?"":t,n);this.#r=t,this.#t=BO(o.hiddenCaptures,o.transfers),this.#i=o.strategy,this.rawOptions=r??{}}if(!i)this.#e=this}exec(t){if(!this.#e){let{lazyCompile:i,...o}=this.rawOptions;this.#e=new e(this.#r,this.flags,o)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i==="clip_search"&&n&&r){this.lastIndex=0;let i=this.#o(t.slice(r));if(i)UO(i,r,t,this.hasIndices),this.lastIndex+=r;return i}return this.#o(t)}#o(t){this.#e.lastIndex=this.lastIndex;let n=super.exec.call(this.#e,t);if(this.lastIndex=this.#e.lastIndex,!n||!this.#t.size)return n;let r=[...n];n.length=1;let i;if(this.hasIndices)i=[...n.indices],n.indices.length=1;let o=[0];for(let s=1;s<r.length;s++){let{hidden:a,transferTo:l}=this.#t.get(s)??{};if(a)o.push(null);else if(o.push(n.length),n.push(r[s]),this.hasIndices)n.indices.push(i[s]);if(l&&r[s]!==void 0){let d=o[l];if(!d)throw Error(`Invalid capture transfer to "${d}"`);if(n[d]=r[s],this.hasIndices)n.indices[d]=i[s];if(n.groups){if(!this.#n)this.#n=GO(this.source);let c=this.#n.get(l);if(c){if(n.groups[c]=r[s],this.hasIndices)n.indices.groups[c]=i[s]}}}}return n}};function UO(e,t,n,r){if(e.index+=t,e.input=n,r){let i=e.indices;for(let s=0;s<i.length;s++){let a=i[s];if(a)i[s]=[a[0]+t,a[1]+t]}let o=i.groups;if(o)Object.keys(o).forEach((s)=>{let a=o[s];if(a)o[s]=[a[0]+t,a[1]+t]})}}function BO(e,t){let n=new Map;for(let r of e)n.set(r,{hidden:!0});for(let[r,i]of t)for(let o of i)Qs(n,o,{}).transferTo=r;return n}function GO(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,o;while(o=t.exec(e)){let{0:s,groups:{capture:a,name:l}}=o;if(s==="[")r++;else if(!r){if(a){if(i++,l)n.set(i,l)}}else if(s==="]")r--}return n}function Sx(e,t){let n=jO(e,t);if(n.options)return new _O(n.pattern,n.flags,n.options);return new RegExp(n.pattern,n.flags)}function jO(e,t){let n=dx(t),r=mu(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Sf}),i=yO(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=LO(i,n),s=ix(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),a=mf(s.pattern),l=cf(a.pattern,{captureTransfers:s.captureTransfers,hiddenCaptures:s.hiddenCaptures}),d={pattern:l.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error("Lazy compilation requires subclass")}else{let c=l.hiddenCaptures.sort((x,I)=>x-I),m=Array.from(l.captureTransfers),p=i._strategy,h=d.pattern.length>=n.lazyCompileLength;if(c.length||m.length||p||h)d.options={...c.length&&{hiddenCaptures:c},...m.length&&{transfers:m},...p&&{strategy:p},...h&&{lazyCompile:h}}}return d}function Cf(e,t){return Sx(e,{global:!0,hasIndices:!0,lazyCompileLength:3000,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function Iu(e={}){let t={target:"auto",cache:new Map,...e};return t.regexConstructor||=(n)=>Cf(n,{target:t.target}),{createScanner(n){return new Ly(n,t)},createString(n){return{content:n}}}}async function bx(e){if(Nl())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=ru.get(e);if(t!=null)return t;try{let n=Cy.get(e);if(n==null&&Object.prototype.hasOwnProperty.call($o,e))n=$o[e];if(n==null)throw Error(`resolveLanguage: "${e}" not found in bundled or custom languages`);let r=n().then(({default:i})=>{let o={name:e,data:i};if(!ti.has(e))ti.set(e,o);return o});return ru.set(e,r),await r}finally{ru.delete(e)}}function Cx(e){return ti.get(e)??bx(e)}function On(e=Oe){let t=[];if(typeof e==="string")t.push(e);else t.push(e.dark),t.push(e.light);return t}var ea=new Set;function Qt(e){for(let t of On(e))if(!ea.has(t))return!1;return!0}function Ef(e,t){e=Array.isArray(e)?e:[e];for(let n of e){let r;if(typeof n==="string"){if(r=Zt.getResolvedTheme(n),r==null)throw Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else if(r=n,n=n.name,Zt.getResolvedTheme(n)==null)Zt.seedResolvedTheme(n,r);if(ea.has(n))continue;ea.add(n),t.loadThemeSync(r)}}function Ex(e){return Zt.getResolvedTheme(e)??Vm(e)}var Gn;async function sr({themes:e,langs:t,preferredHighlighter:n="shiki-js"}){Gn??=nf({themes:[],langs:["text"],engine:n==="shiki-wasm"?lu(import("./wasm-8yvsdhkk.js")):Iu()});let r=vx(Gn)?await Gn:Gn;Gn=r;let i=[];for(let s of Array.from(new Set(t))){if(s==="text"||s==="ansi")continue;let a=Cx(s);if("then"in a)i.push(a);else Wm(a,r)}let o=[];for(let s of e){let a=Ex(s);if("then"in a)o.push(a);else Ef(a,Gn)}if(i.length>0||o.length>0)await Promise.all([Promise.all(i).then((s)=>{Wm(s,r)}),Promise.all(o).then((s)=>{Ef(s,r)})]);return r}function vf(e=Gn){return e!=null&&!("then"in e)}function jn(e){if(Gn==null||"then"in Gn)return;if(e!=null&&(!Qt(e.theme)||!ni(e.lang)))return;return Gn}function vx(e=Gn){return e!=null&&"then"in e}async function Tf(e){await sr(e)}for(let e of tu.getThemes())Zt.registerThemeIfAbsent(e.name,e.load);function Tt(e,t){return e-(t===0?0:1)}function kt(e,t){return Tt(e,t)+t}function Vi(e,...t){return`ck1:${JSON.stringify([e,...t])}`}function bn(e){let t=e.length;if(e.charCodeAt(t-1)===10){if(t--,e.charCodeAt(t-1)===13)t--}return e.slice(0,t)}var qO=new TextEncoder,zO=new TextDecoder("utf-8",{ignoreBOM:!0}),KO=/[\uD800-\uDFFF]/;var Ho=new Uint8Array(1024);function kf(){if(Ho.length!==1024)Ho=new Uint8Array(1024)}function xt(e){if(e.length===0)return e;if(KO.test(e))return JSON.parse(JSON.stringify(e));let t=e.length*3;if(Ho.length<t)Ho=new Uint8Array(t);let{written:n}=qO.encodeInto(e,Ho);return zO.decode(Ho.subarray(0,n))}function kx(e){for(let t of e.hunks){for(let n=0;n<t.hunkContent.length;n++){let r=t.hunkContent[n];if(r.type!=="change")continue;let i=WO(e,r);if(i!=null)t.hunkContent.splice(n,1,...i),n+=i.length-1}VO(t,e)}}function VO(e,t){let{hunkContent:n}=e;for(let r=1;r<n.length;r++){let i=n[r],o=n[r-1];if(i.type!=="change"||i.additions>0&&i.deletions>0||o.type!=="context")continue;let s=i.additions>0,a=s?t.additionLines:t.deletionLines,l=s?i.additionLineIndex:i.deletionLineIndex,d=s?i.additions:i.deletions,c=a[l]??"";if(c.trim()!=="")continue;let m=!0;for(let v=1;v<d;v++)if(a[l+v]!==c){m=!1;break}if(!m)continue;let p=0;while(p<o.lines&&t.additionLines[o.additionLineIndex+o.lines-1-p]===c)p++;if(p===0)continue;if(r===1&&p===o.lines)continue;i.additionLineIndex-=p,i.deletionLineIndex-=p;let h=i.additionLineIndex+i.additions,x=i.deletionLineIndex+i.deletions,I=n[r+1];if(I?.type==="context")I.lines+=p,I.additionLineIndex=h,I.deletionLineIndex=x;else n.splice(r+1,0,{type:"context",lines:p,additionLineIndex:h,deletionLineIndex:x});if(o.lines-=p,o.lines===0)n.splice(r-1,1),r--}}function WO(e,t){let{deletions:n,additions:r,deletionLineIndex:i,additionLineIndex:o}=t,s=Math.min(n,r),a=Math.abs(r-n);if(s===0||a===0||s*(a+1)>4096)return null;let l=[];for(let I=0;I<n;I++)l.push(Tx(e.deletionLines[i+I]??""));let d=[];for(let I=0;I<r;I++)d.push(Tx(e.additionLines[o+I]??""));let c=r>n,m=0,p=-1;for(let I=0;I<=a;I++){let v=0;for(let S=0;S<s;S++)v+=YO(l[S+(c?0:I)],d[S+(c?I:0)]);if(I===0)p=v+s*0.5;else if(v>p)p=v,m=I}if(m===0)return null;let h=[],x=(I,v,S,b)=>{if(I>0||v>0)h.push({type:"change",deletions:I,additions:v,deletionLineIndex:S,additionLineIndex:b})};if(c)x(0,m,i,o),x(s,s,i,o+m),x(0,r-s-m,i+s,o+m+s);else x(m,0,i,o),x(s,s,i+m,o),x(n-s-m,0,i+m+s,o+s);return h}var XO=/\s+/g;function Tx(e){return e.replace(XO,"")}function YO(e,t){if(e===t)return 1;let n=Math.max(e.length,t.length),r=Math.min(e.length,t.length);if(r===0)return 0;let i=0;while(i<r&&e[i]===t[i])i++;let o=0;while(o<r-i&&e[e.length-1-o]===t[t.length-1-o])o++;return(i+o)/n}function JO(e,t,n=!1,r){let i=sF(e),o=i?eF(e):tF(e),s,a=[];for(let l of o){if(i&&!Af.test(l)){if(s==null)s=xt(l);else if(n)throw Error("parsePatchContent: unknown file blob");else console.error("parsePatchContent: unknown file blob:",l);continue}else if(!i&&!nF(l)){if(s==null)s=xt(l);else if(n)throw Error("parsePatchContent: unknown file blob");else console.error("parsePatchContent: unknown file blob:",l);continue}let d=Nx(l,{cacheKey:t!=null?r==null?Vi("patch-file",t,String(a.length)):Vi("patch-file",t,String(r),String(a.length)):void 0,isGitDiff:i,throwOnError:n});if(d!=null)a.push(d)}return{patchMetadata:s,files:a}}function Pf(e,t){try{return Nx(e,t)}finally{kf()}}function Nx(e,{cacheKey:t,isGitDiff:n=Af.test(e),oldFile:r,newFile:i,throwOnError:o=!1}={}){let s=0,a=Ux(e,"@@ "),l,d=r==null||i==null,c=0,m=0;for(let p of a){let h=Dx(p),x=h[0];if(x==null){if(o)throw Error("parsePatchContent: invalid hunk");else console.error("parsePatchContent: invalid hunk",p);continue}let I=_x(x),v=0,S=0;if(I==null||l==null){if(l!=null){if(o)throw Error("parsePatchContent: Invalid hunk");else console.error("parsePatchContent: Invalid hunk",p);continue}if(l={name:"",type:"change",hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:d,additionLines:!d&&r!=null&&i!=null?wx(i.contents):[],deletionLines:!d&&r!=null&&i!=null?wx(r.contents):[],cacheKey:Ax(t)},l.additionLines.length===1&&i?.contents==="")l.additionLines.length=0;if(l.deletionLines.length===1&&r?.contents==="")l.deletionLines.length=0;for(let O of h){if(O.startsWith("diff --git")){let X=O.trim().match(Ox),N=X?.[1]??X?.[2],B=X?.[3]??X?.[4];if(N==null||B==null){if(o)throw Error("parsePatchContent: invalid git diff header");else console.error("parsePatchContent: invalid git diff header",O);continue}if(l.name=xt(B.trim()),N!==B)l.prevName=xt(N.trim());continue}let D=O.startsWith("---")||O.startsWith("+++")?O.match(n?Mx:$x):null;if(D!=null){let[,X,N]=D;if(X==="---"&&N!=="/dev/null"){let B=xt(N.trim());l.prevName=B,l.name=B}else if(X==="+++"&&N!=="/dev/null")l.name=xt(N.trim())}else if(n){if(O.startsWith("new mode "))l.mode=xt(O.slice(8).trim());if(O.startsWith("old mode "))l.prevMode=xt(O.slice(8).trim());if(O.startsWith("new file mode"))l.type="new",l.mode=xt(O.slice(13).trim());if(O.startsWith("deleted file mode"))l.type="deleted",l.mode=xt(O.slice(17).trim());if(O.startsWith("similarity index"))if(O.startsWith("similarity index 100%"))l.type="rename-pure";else l.type="rename-changed";if(O.startsWith("index ")){let[,X,N,B]=O.trim().match(Fx)??[];if(X!=null)l.prevObjectId=xt(X);if(N!=null)l.newObjectId=xt(N);if(B!=null)l.mode=xt(B)}if(O.startsWith("rename from "))l.prevName=xt(O.slice(12).trim());if(O.startsWith("rename to "))l.name=xt(O.slice(10).trim())}}continue}let b,E;while(h.length>0&&(h[h.length-1]===`
|
|
150
|
+
\v\f
\u2028\u2029])`),t));else if(l==="posix")if(!i&&(c==="graph"||c==="print")){if(r==="strict")throw Error(`POSIX class "${c}" requires min target ES2024 or non-strict accuracy`);let m={graph:"!-~",print:" -~"}[c];if(d)m=`\x00-${vt(m.codePointAt(0)-1)}${vt(m.codePointAt(2)+1)}-\uDBFF\uDFFF`;n(ft(Nr(`[${m}]`),t))}else n(ft(xf(Nr(PO.get(c)),d),t));else if(l==="property"){if(!Sf.has(Do(c)))e.key="sc"}else if(l==="space")n(si(qi("space",{negate:d}),t));else if(l==="word")n(ft(xf(Nr(Fr),d),t));else throw Error(`Unexpected character set kind "${l}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:o,removeAllNextSiblings:s}){let{kind:a,flags:l}=e;if(a==="flags")if(!l.enable&&!l.disable)r();else{let d=Sn({flags:l});d.body[0].body=s(),i(ft(d,t),{traverse:!0})}else if(a==="keep"){let d=n.body[0],m=n.body.length===1&&cu(d,{type:"Group"})&&d.body[0].body.length===1?d.body[0]:n;if(t.parent!==m||m.body.length>1)throw Error(oe`Uses "\K" in a way that's unsupported`);let p=ii({behind:!0});p.body[0].body=o(),i(ft(p,t))}else throw Error(`Unexpected directive kind "${a}"`)},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((n)=>delete e[n]),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;if(n==="lookbehind")t.passedLookbehind=!0},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r==="fail")n(ft(ii({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){let t=Sn();t.body[0].body.push(e.body),e.body=ft(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let o of e.body)if(o.body.length===1&&o.body[0].kind==="search_start")o.body.pop();else{let s=bx(o.body);if(s)r=!0,Array.isArray(s)?n.push(...s):n.push(s);else i=!0}if(r&&!i)n.forEach((o)=>t.add(o))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw Error(oe`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;if(typeof n==="string"&&!yf(n))n=gf(n,t),e.ref=n}},FO={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;if(!r)n.set(e,[...t.get(i).map(({node:o})=>o)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:o,multiplexCapturesToLeftByRef:s,openRefs:a,reffedNodesByReferencer:l}){let d=i.get(e);if(d&&a.has(e.number)){let m=si(dx(e.number),t);l.set(m,a.get(e.number)),n(m);return}if(a.set(e.number,e),s.set(e.number,[]),e.name)ta(s,e.name,[]);let c=s.get(e.name??e.number);for(let m=0;m<c.length;m++){let p=c[m];if(d===p.node||d&&d===p.origin||e===p.origin){c.splice(m,1);break}}if(s.get(e.number).push({node:e,origin:d}),e.name)s.get(e.name).push({node:e,origin:d});if(e.name){let m=ta(o,e.name,new Map),p=!1;if(d)p=!0;else for(let h of m.values())if(!h.hasDuplicateNameToRemove){p=!0;break}o.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:p})}},exit({node:e},{openRefs:t}){if(t.get(e.number)===e)t.delete(e.number)}},Group:{enter({node:e},t){if(t.prevFlags=t.currentFlags,e.flags)t.currentFlags=xu(t.currentFlags,e.flags)},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:o}=e;if(i){let c=t;while(c=c.parent)if(c.type==="CapturingGroup"&&(c.name===o||c.number===o))break;r.reffedNodesByReferencer.set(e,c);return}let s=r.subroutineRefMap.get(o),a=o===0,l=a?dx(0):xx(s,r.groupOriginByCopy,null),d=l;if(!a){let c=Ix(_O(s,(p)=>p.type==="Group"&&!!p.flags)),m=c?xu(r.globalFlags,c):r.globalFlags;if(!DO(m,r.currentFlags))d=Sn({flags:UO(m)}),d.body[0].body.push(l)}n(ft(d,t),{traverse:!a})}},NO={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let o=r.reffedNodesByReferencer.get(e).filter((s)=>HO(s,e));if(!o.length)n(ft(ii({negate:!0}),t));else if(o.length>1){let s=Sn({atomic:!0,body:o.reverse().map((a)=>Or({body:[mu(a.number)]}))});n(ft(s,t))}else e.ref=o[0].number},CapturingGroup({node:e},t){if(e.number=++t.numCapturesToLeft,e.name){if(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 r=0;r<n;r++){let i=sf();e.body.at(-1).body.push(i)}}},Subroutine({node:e},t){if(!e.isRecursive||e.ref===0)return;e.ref=t.reffedNodesByReferencer.get(e).number}};function yx(e){zi(e,{"*"({node:t,parent:n}){t.parent=n}})}function DO(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function HO(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;let r=Sx(n.parent);for(let i of r){if(i===n)break;if(i===e||Cx(i,e))return!0}}while(n=n.parent);throw Error("Unexpected path")}function xx(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[o,s]of Object.entries(e))if(o==="parent")i.parent=Array.isArray(n)?r:n;else if(s&&typeof s==="object")i[o]=xx(s,t,i,n);else{if(o==="type"&&s==="CapturingGroup")t.set(i,t.get(e)??e);i[o]=s}return i}function dx(e){let t=lf(e);return t.isRecursive=!0,t}function _O(e,t){let n=[];while(e=e.parent)if(!t||t(e))n.push(e);return n}function gf(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function Ix(e){let t=["dotAll","ignoreCase"],n={enable:{},disable:{}};if(e.forEach(({flags:r})=>{t.forEach((i)=>{if(r.enable?.[i])delete n.disable[i],n.enable[i]=!0;if(r.disable?.[i])n.disable[i]=!0})}),!Object.keys(n.enable).length)delete n.enable;if(!Object.keys(n.disable).length)delete n.disable;if(n.enable||n.disable)return n;return null}function UO({dotAll:e,ignoreCase:t}){let n={};if(e||t)n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0);if(!e||!t)n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0);return n}function Sx(e){if(!e)throw Error("Node expected");let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function bx(e){let t=e.find((n)=>n.kind==="search_start"||jO(n,{negate:!1})||!BO(n));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 n=[];for(let r of t.body){let i=bx(r.body);if(!i)return null;Array.isArray(i)?n.push(...i):n.push(i)}return n}return null}function Cx(e,t){let n=Sx(e)??[];for(let r of n)if(r===t||Cx(r,t))return!0;return!1}function BO({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function GO(e){let t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function jO(e,t){let n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&cu(e.body[0],{type:"Assertion",kind:"search_start"})}function yf(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Nr(e,t){let r=fu(e,{...t,unicodePropertyMap:Sf}).body;if(r.length>1||r[0].body.length>1)return Sn({body:r});return r[0].body[0]}function xf(e,t){return e.negate=t,e}function si(e,t){return e.parent=t,e}function ft(e,t){return yx(e),e.parent=t,e}function qO(e,t){let n=px(t),r=If(n.target,"ES2024"),i=If(n.target,"ES2025"),o=n.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw Error("Invalid recursionLimit; use 2-20");let s=null,a=null;if(!i){let h=[e.flags.ignoreCase];zi(e,zO,{getCurrentModI:()=>h.at(-1),popModI(){h.pop()},pushModI(x){h.push(x)},setHasCasedChar(){if(h.at(-1))s=!0;else a=!0}})}let l={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||s)&&!a)},d=e,c={accuracy:n.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:d,originMap:e._originMap,recursionLimit:o,useAppliedIgnoreCase:!!(!i&&s&&a),useFlagMods:i,useFlagV:r,verbose:n.verbose};function m(h){return c.lastNode=d,d=h,vO(KO[h.type],`Unexpected node type "${h.type}"`)(h,c,m)}let p={pattern:e.body.map(m).join("|"),flags:m(e.flags),options:{...e.options}};if(!r)delete p.options.force.v,p.options.disable.v=!0,p.options.unicodeSetsPlugin=null;return p._captureTransfers=new Map,p._hiddenCaptures=[],c.captureMap.forEach((h,x)=>{if(h.hidden)p._hiddenCaptures.push(x);if(h.transferTo)ta(p._captureTransfers,h.transferTo,[]).push(x)}),p}var zO={"*":{enter({node:e},t){if(mx(e)){let n=t.getCurrentModI();t.pushModI(e.flags?xu({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){if(mx(e))t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){if(bf(vt(e.value)))t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){if(t(),Ex(e,{firstOnly:!0}).length)n.setHasCasedChar()},CharacterSet({node:e},t){if(e.kind==="property"&&gx.has(e.value))t.setHasCasedChar()}},KO={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?oe`\B`:oe`\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:o}=e,s={ignoreCase:t.currentFlags.ignoreCase},a=t.originMap.get(e);if(a){if(s.hidden=!0,o>a.number)s.transferTo=a.number}return t.captureMap.set(o,s),`(${i?`?<${i}>`:""}${r.map(n).join("|")})`},Character({value:e},t){let n=vt(e),r=_o(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&bf(n)){let i=hx(n);return t.inCharClass?i.join(""):i.length>1?`[${i.join("")}]`:i[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:o}=e,{body:s}=e;if(r==="intersection"&&!t.useFlagV)throw Error("Use of character class intersection requires min target ES2024");if(Bn.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&s.some(fx))s=[No(45),...s.filter((d)=>!fx(d))];let a=()=>`[${i?"^":""}${s.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||Bn.bugNestedClassIgnoresNegation)&&!i){let c=s.filter((m)=>m.type==="CharacterClass"&&m.kind==="union"&&m.negate);if(c.length){let m=Sn(),p=m.body[0];if(m.parent=o,p.parent=m,s=s.filter((h)=>!c.includes(h)),e.body=s,s.length)e.parent=p,p.body.push(e);else m.body.pop();return c.forEach((h)=>{let x=Or({body:[h]});h.parent=x,x.parent=m,m.body.push(x)}),n(m)}}t.inCharClass=!0;let d=a();return t.inCharClass=!1,d}let l=s[0];if(r==="union"&&!i&&l&&((!t.useFlagV||!t.verbose)&&o.kind==="union"&&!(Bn.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&o.kind==="intersection"&&s.length===1&&l.type!=="CharacterClassRange"))return s.map(n).join("");if(!t.useFlagV&&o.type==="CharacterClass")throw Error("Uses nested character class in a way that requires min target ES2024");return a()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},o=_o(n,i),s=_o(r,i),a=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let l=Ex(e);JO(l).forEach((c)=>{a.add(Array.isArray(c)?`${_o(c[0],i)}-${_o(c[1],i)}`:_o(c,i))})}return`${o}-${s}${[...a].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e==="dot")return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?".":"[^]":oe`[^\n]`;if(e==="digit")return t?oe`\D`:oe`\d`;if(e==="property"){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&gx.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?oe`\P`:oe`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?oe`\W`:oe`\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,o){let s=i.currentFlags;if(n)i.currentFlags=xu(s,n);let a=t.map(o).join("|"),l=!i.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!i.useFlagMods||!n)?a:`(?${ZO(e,n,i.useFlagMods)}${a})`;return i.currentFlags=s,l},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)+QO(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})`:oe`\g<${t}&R=${r}>`}},VO=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),WO=new Set(["-","\\","]","^","["]),XO=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),cx=new Map([[9,oe`\t`],[10,oe`\n`],[11,oe`\v`],[12,oe`\f`],[13,oe`\r`],[8232,oe`\u2028`],[8233,oe`\u2029`],[65279,oe`\uFEFF`]]),YO=/^\p{Cased}$/u;function bf(e){return YO.test(e)}function Ex(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,o=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return o;for(let s=r;s<=i;s++){let a=vt(s);if(!bf(a))continue;let l=hx(a).filter((d)=>{let c=d.codePointAt(0);return c<r||c>i});if(l.length){if(o.push(...l),n)break}}return o}function _o(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(cx.has(e))return cx.get(e);if(e<32||e>126&&e<160||e>262143||t&&eF(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let i=n?r?XO:WO:VO,o=vt(e);return(i.has(o)?"\\":"")+o}function JO(e){let t=e.map((i)=>i.codePointAt(0)).sort((i,o)=>i-o),n=[],r=null;for(let i=0;i<t.length;i++)if(t[i+1]===t[i]+1)r??=t[i];else if(r===null)n.push(t[i]);else n.push([r,t[i]]),r=null;return n}function ZO(e,t,n){if(e)return">";let r="";if(t&&n){let{enable:i,disable:o}=t;r=(i?.ignoreCase?"i":"")+(i?.dotAll?"s":"")+(o?"-":"")+(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")}return`${r}:`}function QO({kind:e,max:t,min:n}){let r;if(!n&&t===1)r="?";else if(!n&&t===1/0)r="*";else if(n===1&&t===1/0)r="+";else if(n===t)r=`{${n}}`;else r=`{${n},${t===1/0?"":t}}`;return r+{greedy:"",lazy:"?",possessive:"+"}[e]}function mx({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function eF(e){return e>47&&e<58}function fx({type:e,value:t}){return e==="Character"&&t===45}var tF=class e extends RegExp{#t=new Map;#e=null;#r;#n=null;#i=null;rawOptions={};get source(){return this.#r||"(?:)"}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error("Cannot provide options when copying a regexp");let o=t;super(o,n);if(this.#r=o.source,o instanceof e)this.#t=o.#t,this.#n=o.#n,this.#i=o.#i,this.rawOptions=o.rawOptions}else{let o={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?"":t,n);this.#r=t,this.#t=rF(o.hiddenCaptures,o.transfers),this.#i=o.strategy,this.rawOptions=r??{}}if(!i)this.#e=this}exec(t){if(!this.#e){let{lazyCompile:i,...o}=this.rawOptions;this.#e=new e(this.#r,this.flags,o)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i==="clip_search"&&n&&r){this.lastIndex=0;let i=this.#o(t.slice(r));if(i)nF(i,r,t,this.hasIndices),this.lastIndex+=r;return i}return this.#o(t)}#o(t){this.#e.lastIndex=this.lastIndex;let n=super.exec.call(this.#e,t);if(this.lastIndex=this.#e.lastIndex,!n||!this.#t.size)return n;let r=[...n];n.length=1;let i;if(this.hasIndices)i=[...n.indices],n.indices.length=1;let o=[0];for(let s=1;s<r.length;s++){let{hidden:a,transferTo:l}=this.#t.get(s)??{};if(a)o.push(null);else if(o.push(n.length),n.push(r[s]),this.hasIndices)n.indices.push(i[s]);if(l&&r[s]!==void 0){let d=o[l];if(!d)throw Error(`Invalid capture transfer to "${d}"`);if(n[d]=r[s],this.hasIndices)n.indices[d]=i[s];if(n.groups){if(!this.#n)this.#n=iF(this.source);let c=this.#n.get(l);if(c){if(n.groups[c]=r[s],this.hasIndices)n.indices.groups[c]=i[s]}}}}return n}};function nF(e,t,n,r){if(e.index+=t,e.input=n,r){let i=e.indices;for(let s=0;s<i.length;s++){let a=i[s];if(a)i[s]=[a[0]+t,a[1]+t]}let o=i.groups;if(o)Object.keys(o).forEach((s)=>{let a=o[s];if(a)o[s]=[a[0]+t,a[1]+t]})}}function rF(e,t){let n=new Map;for(let r of e)n.set(r,{hidden:!0});for(let[r,i]of t)for(let o of i)ta(n,o,{}).transferTo=r;return n}function iF(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,o;while(o=t.exec(e)){let{0:s,groups:{capture:a,name:l}}=o;if(s==="[")r++;else if(!r){if(a){if(i++,l)n.set(i,l)}}else if(s==="]")r--}return n}function vx(e,t){let n=oF(e,t);if(n.options)return new tF(n.pattern,n.flags,n.options);return new RegExp(n.pattern,n.flags)}function oF(e,t){let n=px(t),r=fu(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Sf}),i=MO(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=qO(i,n),s=lx(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),a=mf(s.pattern),l=cf(a.pattern,{captureTransfers:s.captureTransfers,hiddenCaptures:s.hiddenCaptures}),d={pattern:l.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error("Lazy compilation requires subclass")}else{let c=l.hiddenCaptures.sort((x,I)=>x-I),m=Array.from(l.captureTransfers),p=i._strategy,h=d.pattern.length>=n.lazyCompileLength;if(c.length||m.length||p||h)d.options={...c.length&&{hiddenCaptures:c},...m.length&&{transfers:m},...p&&{strategy:p},...h&&{lazyCompile:h}}}return d}function Cf(e,t){return vx(e,{global:!0,hasIndices:!0,lazyCompileLength:3000,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function Su(e={}){let t={target:"auto",cache:new Map,...e};return t.regexConstructor||=(n)=>Cf(n,{target:t.target}),{createScanner(n){return new $y(n,t)},createString(n){return{content:n}}}}async function kx(e){if(Dl())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=ru.get(e);if(t!=null)return t;try{let n=Ty.get(e);if(n==null&&Object.prototype.hasOwnProperty.call(Oo,e))n=Oo[e];if(n==null)throw Error(`resolveLanguage: "${e}" not found in bundled or custom languages`);let r=n().then(({default:i})=>{let o={name:e,data:i};if(!Pr.has(e))Pr.set(e,o);return o});return ru.set(e,r),await r}finally{ru.delete(e)}}function Tx(e){return Pr.get(e)??kx(e)}function On(e=Oe){let t=[];if(typeof e==="string")t.push(e);else t.push(e.dark),t.push(e.light);return t}var Uo=new Set;function Qt(e){for(let t of On(e))if(!Uo.has(t))return!1;return!0}function Ef(e,t){e=Array.isArray(e)?e:[e];for(let n of e){let r;if(typeof n==="string"){if(r=Ut.getResolvedTheme(n),r==null)throw Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else if(r=n,n=n.name,Ut.getResolvedTheme(n)==null)Ut.seedResolvedTheme(n,r);if(Uo.has(n))continue;Uo.add(n),t.loadThemeSync(r)}}function wx(e){return Ut.getResolvedTheme(e)??Wm(e)}var Gn;async function sr({themes:e,langs:t,preferredHighlighter:n="shiki-js"}){Gn??=uu({themes:[],langs:["text"],engine:n==="shiki-wasm"?lu(import("./wasm-8yvsdhkk.js")):Su()});let r=Lx(Gn)?await Gn:Gn;Gn=r;let i=[];for(let s of Array.from(new Set(t))){if(s==="text"||s==="ansi")continue;let a=Tx(s);if("then"in a)i.push(a);else Xm(a,r)}let o=[];for(let s of e){let a=wx(s);if("then"in a)o.push(a);else Ef(a,Gn)}if(i.length>0||o.length>0)await Promise.all([Promise.all(i).then((s)=>{Xm(s,r)}),Promise.all(o).then((s)=>{Ef(s,r)})]);return r}function vf(e=Gn){return e!=null&&!("then"in e)}function jn(e){if(Gn==null||"then"in Gn)return;if(e!=null&&(!Qt(e.theme)||!ni(e.lang)))return;return Gn}function Lx(e=Gn){return e!=null&&"then"in e}async function kf(e){await sr(e)}for(let e of tu.getThemes())Ut.registerThemeIfAbsent(e.name,e.load);function kt(e,t){return e-(t===0?0:1)}function Tt(e,t){return kt(e,t)+t}function Vi(e,...t){return`ck1:${JSON.stringify([e,...t])}`}function bn(e){let t=e.length;if(e.charCodeAt(t-1)===10){if(t--,e.charCodeAt(t-1)===13)t--}return e.slice(0,t)}var sF=new TextEncoder,aF=new TextDecoder("utf-8",{ignoreBOM:!0}),lF=/[\uD800-\uDFFF]/;var Bo=new Uint8Array(1024);function Tf(){if(Bo.length!==1024)Bo=new Uint8Array(1024)}function xt(e){if(e.length===0)return e;if(lF.test(e))return JSON.parse(JSON.stringify(e));let t=e.length*3;if(Bo.length<t)Bo=new Uint8Array(t);let{written:n}=sF.encodeInto(e,Bo);return aF.decode(Bo.subarray(0,n))}function Ax(e){for(let t of e.hunks){for(let n=0;n<t.hunkContent.length;n++){let r=t.hunkContent[n];if(r.type!=="change")continue;let i=dF(e,r);if(i!=null)t.hunkContent.splice(n,1,...i),n+=i.length-1}uF(t,e)}}function uF(e,t){let{hunkContent:n}=e;for(let r=1;r<n.length;r++){let i=n[r],o=n[r-1];if(i.type!=="change"||i.additions>0&&i.deletions>0||o.type!=="context")continue;let s=i.additions>0,a=s?t.additionLines:t.deletionLines,l=s?i.additionLineIndex:i.deletionLineIndex,d=s?i.additions:i.deletions,c=a[l]??"";if(c.trim()!=="")continue;let m=!0;for(let v=1;v<d;v++)if(a[l+v]!==c){m=!1;break}if(!m)continue;let p=0;while(p<o.lines&&t.additionLines[o.additionLineIndex+o.lines-1-p]===c)p++;if(p===0)continue;if(r===1&&p===o.lines)continue;i.additionLineIndex-=p,i.deletionLineIndex-=p;let h=i.additionLineIndex+i.additions,x=i.deletionLineIndex+i.deletions,I=n[r+1];if(I?.type==="context")I.lines+=p,I.additionLineIndex=h,I.deletionLineIndex=x;else n.splice(r+1,0,{type:"context",lines:p,additionLineIndex:h,deletionLineIndex:x});if(o.lines-=p,o.lines===0)n.splice(r-1,1),r--}}function dF(e,t){let{deletions:n,additions:r,deletionLineIndex:i,additionLineIndex:o}=t,s=Math.min(n,r),a=Math.abs(r-n);if(s===0||a===0||s*(a+1)>4096)return null;let l=[];for(let I=0;I<n;I++)l.push(Rx(e.deletionLines[i+I]??""));let d=[];for(let I=0;I<r;I++)d.push(Rx(e.additionLines[o+I]??""));let c=r>n,m=0,p=-1;for(let I=0;I<=a;I++){let v=0;for(let S=0;S<s;S++)v+=mF(l[S+(c?0:I)],d[S+(c?I:0)]);if(I===0)p=v+s*0.5;else if(v>p)p=v,m=I}if(m===0)return null;let h=[],x=(I,v,S,b)=>{if(I>0||v>0)h.push({type:"change",deletions:I,additions:v,deletionLineIndex:S,additionLineIndex:b})};if(c)x(0,m,i,o),x(s,s,i,o+m),x(0,r-s-m,i+s,o+m+s);else x(m,0,i,o),x(s,s,i+m,o),x(n-s-m,0,i+m+s,o+s);return h}var cF=/\s+/g;function Rx(e){return e.replace(cF,"")}function mF(e,t){if(e===t)return 1;let n=Math.max(e.length,t.length),r=Math.min(e.length,t.length);if(r===0)return 0;let i=0;while(i<r&&e[i]===t[i])i++;let o=0;while(o<r-i&&e[e.length-1-o]===t[t.length-1-o])o++;return(i+o)/n}function fF(e,t,n=!1,r){let i=CF(e),o=i?gF(e):yF(e),s,a=[];for(let l of o){if(i&&!Af.test(l)){if(s==null)s=xt(l);else if(n)throw Error("parsePatchContent: unknown file blob");else console.error("parsePatchContent: unknown file blob:",l);continue}else if(!i&&!xF(l)){if(s==null)s=xt(l);else if(n)throw Error("parsePatchContent: unknown file blob");else console.error("parsePatchContent: unknown file blob:",l);continue}let d=Ux(l,{cacheKey:t!=null?r==null?Vi("patch-file",t,String(a.length)):Vi("patch-file",t,String(r),String(a.length)):void 0,isGitDiff:i,throwOnError:n});if(d!=null)a.push(d)}return{patchMetadata:s,files:a}}function Pf(e,t){try{return Ux(e,t)}finally{Tf()}}function Ux(e,{cacheKey:t,isGitDiff:n=Af.test(e),oldFile:r,newFile:i,throwOnError:o=!1}={}){let s=0,a=qx(e,"@@ "),l,d=r==null||i==null,c=0,m=0;for(let p of a){let h=Bx(p),x=h[0];if(x==null){if(o)throw Error("parsePatchContent: invalid hunk");else console.error("parsePatchContent: invalid hunk",p);continue}let I=jx(x),v=0,S=0;if(I==null||l==null){if(l!=null){if(o)throw Error("parsePatchContent: Invalid hunk");else console.error("parsePatchContent: Invalid hunk",p);continue}if(l={name:"",type:"change",hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:d,additionLines:!d&&r!=null&&i!=null?Px(i.contents):[],deletionLines:!d&&r!=null&&i!=null?Px(r.contents):[],cacheKey:Ox(t)},l.additionLines.length===1&&i?.contents==="")l.additionLines.length=0;if(l.deletionLines.length===1&&r?.contents==="")l.deletionLines.length=0;for(let O of h){if(O.startsWith("diff --git")){let X=O.trim().match(Hx),N=X?.[1]??X?.[2],B=X?.[3]??X?.[4];if(N==null||B==null){if(o)throw Error("parsePatchContent: invalid git diff header");else console.error("parsePatchContent: invalid git diff header",O);continue}if(l.name=xt(B.trim()),N!==B)l.prevName=xt(N.trim());continue}let D=O.startsWith("---")||O.startsWith("+++")?O.match(n?Dx:Nx):null;if(D!=null){let[,X,N]=D;if(X==="---"&&N!=="/dev/null"){let B=xt(N.trim());l.prevName=B,l.name=B}else if(X==="+++"&&N!=="/dev/null")l.name=xt(N.trim())}else if(n){if(O.startsWith("new mode "))l.mode=xt(O.slice(8).trim());if(O.startsWith("old mode "))l.prevMode=xt(O.slice(8).trim());if(O.startsWith("new file mode"))l.type="new",l.mode=xt(O.slice(13).trim());if(O.startsWith("deleted file mode"))l.type="deleted",l.mode=xt(O.slice(17).trim());if(O.startsWith("similarity index"))if(O.startsWith("similarity index 100%"))l.type="rename-pure";else l.type="rename-changed";if(O.startsWith("index ")){let[,X,N,B]=O.trim().match(_x)??[];if(X!=null)l.prevObjectId=xt(X);if(N!=null)l.newObjectId=xt(N);if(B!=null)l.mode=xt(B)}if(O.startsWith("rename from "))l.prevName=xt(O.slice(12).trim());if(O.startsWith("rename to "))l.name=xt(O.slice(10).trim())}}continue}let b,E;while(h.length>0&&(h[h.length-1]===`
|
|
151
151
|
`||h[h.length-1]==="\r"||h[h.length-1]===`\r
|
|
152
|
-
`||h[h.length-1]===""))h.pop();let{additionStart:w,deletionStart:
|
|
153
|
-
From `)}function
|
|
154
|
-
`,n);if(r===-1)break;t.push(e.slice(n,r+1)),n=r+1}if(n<e.length)t.push(e.slice(n));return t}function
|
|
152
|
+
`||h[h.length-1]===""))h.pop();let{additionStart:w,deletionStart:T}=I;c=d?c:T-1,m=d?m:w-1;let L={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:I.additionCount,additionStart:w,additionLines:v,deletionCount:I.deletionCount,deletionStart:T,deletionLines:S,deletionLineIndex:c,additionLineIndex:m,hunkContent:[],hunkContext:Ox(I.hunkContext),hunkSpecs:xt(x),noEOFCRAdditions:!1,noEOFCRDeletions:!1},R=0,A=0;for(let O=1;O<h.length;O++){let D=h[O];if(R>=L.additionCount&&A>=L.deletionCount&&!D.startsWith("\\")){if(!(IF(D)&&!SF(D)))break;if(o)throw Error("parsePatchContent: hunk has more lines than expected")}let X=D[0];if(X!=="+"&&X!=="-"&&X!==" "&&X!=="\\"){if(o)throw Error("parsePatchContent: invalid hunk line");console.error(`parseLineType: Invalid firstChar: "${X}", full line: "${D}"`),console.error("processFile: invalid rawLine:",D);continue}let N=EF(X);if(N==="addition"){if(o&&R>=L.additionCount)throw Error("parsePatchContent: hunk has too many addition lines");let B=wf(D);if(b==null||b.type!=="change")b=Lf("change",c,m),L.hunkContent.push(b);if(m++,R++,d)l.additionLines.push(B);b.additions++,v++,E="addition"}else if(N==="deletion"){if(o&&A>=L.deletionCount)throw Error("parsePatchContent: hunk has too many deletion lines");let B=wf(D);if(b==null||b.type!=="change")b=Lf("change",c,m),L.hunkContent.push(b);if(c++,A++,d)l.deletionLines.push(B);b.deletions++,S++,E="deletion"}else if(N==="context"){if(o&&(A>=L.deletionCount||R>=L.additionCount))throw Error("parsePatchContent: hunk has too many context lines");let B=wf(D);if(b==null||b.type!=="context")b=Lf("context",c,m),L.hunkContent.push(b);if(m++,c++,R++,A++,d)l.deletionLines.push(B),l.additionLines.push(B);b.lines++,E="context"}else if(N==="metadata"&&b!=null){if(b.type==="context")L.noEOFCRAdditions=!0,L.noEOFCRDeletions=!0;else if(E==="deletion")L.noEOFCRDeletions=!0;else if(E==="addition")L.noEOFCRAdditions=!0;if(d&&(E==="addition"||E==="context")){let B=l.additionLines.length-1;if(B>=0)l.additionLines[B]=bn(l.additionLines[B])}if(d&&(E==="deletion"||E==="context")){let B=l.deletionLines.length-1;if(B>=0)l.deletionLines[B]=bn(l.deletionLines[B])}}}if(R!==L.additionCount||A!==L.deletionCount){if(o)throw Error("parsePatchContent: hunk line count mismatch");console.error(`parsePatchContent: hunk line count mismatch: "${x.trimEnd()}", declared old/new ${L.deletionCount}/${L.additionCount}, parsed old/new ${A}/${R}`);let O=kt(L.additionStart,L.additionCount)+(R===0?0:1),D=kt(L.deletionStart,L.deletionCount)+(A===0?0:1);if(!d){let X=O-L.additionStart,N=D-L.deletionStart;L.additionLineIndex+=X,L.deletionLineIndex+=N;for(let B of L.hunkContent)B.additionLineIndex+=X,B.deletionLineIndex+=N}L.additionStart=O,L.deletionStart=D,L.additionCount=R,L.deletionCount=A}L.additionLines=v,L.deletionLines=S,L.collapsedBefore=Math.max(kt(L.additionStart,L.additionCount)-s,0),l.hunks.push(L),s=Tt(L.additionStart,L.additionCount);for(let O of L.hunkContent)if(O.type==="context")L.splitLineCount+=O.lines,L.unifiedLineCount+=O.lines;else L.splitLineCount+=Math.max(O.additions,O.deletions),L.unifiedLineCount+=O.deletions+O.additions;L.splitLineStart=l.splitLineCount+L.collapsedBefore,L.unifiedLineStart=l.unifiedLineCount+L.collapsedBefore,l.splitLineCount+=L.collapsedBefore+L.splitLineCount,l.unifiedLineCount+=L.collapsedBefore+L.unifiedLineCount}if(l==null)return;if(o&&d&&!n&&l.hunks.length===0)throw Error("parsePatchContent: unified file has no hunks");if(l.hunks.length>0&&!d&&l.additionLines.length>0&&l.deletionLines.length>0){let p=l.hunks[l.hunks.length-1],h=Tt(p.additionStart,p.additionCount),x=l.additionLines.length,I=Math.max(x-h,0);l.splitLineCount+=I,l.unifiedLineCount+=I}if(!n){if(l.prevName!=null&&l.name!==l.prevName)if(l.hunks.length>0)l.type="rename-changed";else l.type="rename-pure";else if((r==null||r.contents==="")&&i!=null&&i.contents!=="")l.type="new";else if(r!=null&&r.contents!==""&&(i==null||i.contents===""))l.type="deleted"}if(l.type!=="rename-pure"&&l.type!=="rename-changed")l.prevName=void 0;return Ax(l),l}function pF(e,t,n=!1){let r=[],i=hF(e)?e.split(Fx):[e];for(let o of i)try{r.push(fF(o,t,n,t!=null?r.length:void 0))}catch(s){if(n)throw s;else console.error(s)}finally{Tf()}return r}function hF(e){return e.startsWith("From ")||e.includes(`
|
|
153
|
+
From `)}function Px(e){let t=Bx(e);for(let n=0;n<t.length;n++)t[n]=xt(t[n]);return t}function Bx(e){if(e.length===0)return[""];let t=[],n=0;for(;;){let r=e.indexOf(`
|
|
154
|
+
`,n);if(r===-1)break;t.push(e.slice(n,r+1)),n=r+1}if(n<e.length)t.push(e.slice(n));return t}function gF(e){return qx(e,"diff --git")}function yF(e){if(e.length===0)return[""];let t=[],n=0,r=0,i=0,o=0,s=!1;while(r<e.length){let a=Rf(e,r);if(i<=0&&o<=0){if(Gx(e,r)){if(r>n)t.push(e.slice(n,r));n=r,s=!0,r=Rf(e,a);continue}if(s&&e.startsWith("@@ -",r)){let d=jx(e.slice(r,a));if(d!=null)i=d.deletionCount,o=d.additionCount}r=a;continue}let l=e[r];if(l==="\\"){r=a;continue}if(l===" ")i=Math.max(i-1,0),o=Math.max(o-1,0);else if(l==="-")i=Math.max(i-1,0);else if(l==="+")o=Math.max(o-1,0);r=a}return t.push(e.slice(n)),t}function xF(e){return Gx(e,0)}function Gx(e,t){let n=Rf(e,t);return $x(e,t,"---")&&$x(e,n,"+++")}function $x(e,t,n){if(!e.startsWith(n,t))return!1;let r=e[t+n.length];if(r!==" "&&r!=="\t")return!1;for(let i=t+n.length+1;i<e.length;i++){let o=e[i];if(o===`
|
|
155
155
|
`||o==="\r")break;if(o!==" "&&o!=="\t")return!0}return!1}function Rf(e,t){let n=e.indexOf(`
|
|
156
|
-
`,t);return n===-1?e.length:n+1}function
|
|
157
|
-
`&&n!=="\r")return!1}return!0}function
|
|
156
|
+
`,t);return n===-1?e.length:n+1}function IF(e){let t=e[0];return t==="+"||t==="-"||t===" "}function SF(e){if(!e.startsWith("--"))return!1;for(let t=2;t<e.length;t++){let n=e[t];if(n!==" "&&n!=="\t"&&n!==`
|
|
157
|
+
`&&n!=="\r")return!1}return!0}function jx(e){if(!e.startsWith("@@ -"))return;let t=4,n=bu(e,t);if(n==null)return;let r=n.value;t=n.endIndex;let i=1;if(e[t]===","){let c=bu(e,t+1);if(c==null)return;i=c.value,t=c.endIndex}if(e[t]!==" "||e[t+1]!=="+")return;t+=2;let o=bu(e,t);if(o==null)return;let s=o.value;t=o.endIndex;let a=1;if(e[t]===","){let c=bu(e,t+1);if(c==null)return;a=c.value,t=c.endIndex}if(e[t]!==" "||e[t+1]!=="@"||e[t+2]!=="@")return;let l,d=t+3;if(e[d]===" ")l=bF(e.slice(d+1));return{additionCount:a,additionStart:s,deletionCount:i,deletionStart:r,hunkContext:l}}function bu(e,t){let n=t,r=0;for(;n<e.length;n++){let i=e.charCodeAt(n)-48;if(i<0||i>9)break;r=r*10+i}if(n===t)return;return{value:r,endIndex:n}}function bF(e){if(e.endsWith(`\r
|
|
158
158
|
`))return e.slice(0,-2);if(e.endsWith(`
|
|
159
|
-
`))return e.slice(0,-1);return e}function
|
|
160
|
-
diff --git`)}function
|
|
161
|
-
${t}`,r=e.startsWith(t)?0:
|
|
162
|
-
`:t)}function Lf(e,t,n){if(e==="change")return{type:"change",additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:t};return{type:"context",lines:0,additionLineIndex:n,deletionLineIndex:t}}function Bx(e,t){if(e==null||t==null)return e===t;if(e.header!==t.header||e.footer!==t.footer)return!1;return lF(e.items,t.items)}function lF(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r==null||i==null||r.id!==i.id||r.type!==i.type||r.element!==i.element||r.instance!==i.instance||r.version!==i.version)return!1}return!0}function ar(e,t,n){if(e===t||e==null||t==null)return e===t;let r=new Set(n),i=Object.keys(e),o=new Set(Object.keys(t));for(let s of i){if(o.delete(s),r.has(s))continue;if(!(s in t)||e[s]!==t[s])return!1}for(let s of Array.from(o))if(!r.has(s))return!1;return!0}function Cn(e,t){if(e==null||t==null||typeof e==="string"||typeof t==="string")return e===t;return e.dark===t.dark&&e.light===t.light}function _o(e,t){let n=e?.theme??Oe,r=t?.theme??Oe,i=Gx(e),o=Gx(t);return Cn(n,r)&&ar(e,t,["theme","parseDiffOptions"])&&ar(i,o)}function Gx(e){if(e!=null&&"parseDiffOptions"in e)return e.parseDiffOptions}function Uo(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}function zx(e,t,n){let r=document.createElement("div");if(r.style.display="flow-root",e==="header")r.setAttribute(jx,""),t.before(r);else r.setAttribute(qx,""),t.after(r);return n?.observe(r),r}function Kx({scrollTop:e,scrollHeight:t,height:n,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:o}){let s=n+o*2,a=r?n+i*2:s;if(t=Math.max(t,a),s>=t||r){let c=Math.max(e-i,0),m=Math.min(e+a,t);return{top:c,bottom:Math.max(m,c)}}let l=e+n/2-s/2,d=l+s;if(l<0)l=0;if(d>t)d=t;return l=Math.floor(Math.max(l,0)),{top:l,bottom:Math.ceil(Math.max(Math.min(d,t),l))}}function ai(e){if(typeof HTMLStyleElement<"u"&&e instanceof HTMLStyleElement)return!0;let t=e.tagName??e.nodeName;return typeof t==="string"&&t.toLowerCase()==="style"}function Vx(){if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function qn(e){let t=window.devicePixelRatio??1;return Math.round(e*t)/t}function et(e,t){return e?.cacheKey!=null||t?.cacheKey!=null?e?.cacheKey===t?.cacheKey:e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}function Bo(e){return{...bu,...e}}function En(e,t){let n=uF(e,t);return t?n:e.diffHeaderHeight+n}function uF(e,t){return e.paddingTop??(t?e.spacing:0)}function Wi(e){return e.paddingBottom??e.spacing}function Wx(e){switch(e){case"simple":return 4;case"metadata":case"line-info":case"line-info-basic":case"custom":return 32}}var Cu="-1,-1";function ta(e){return e?.some((t)=>t.lineNumber===0)??!1}function na(e){let t=e[0];return t!=null&&t.length>0?t:void 0}function li(e){return e.startingLine===0&&e.totalLines>0}function Xx(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side}function un(e){return{type:"text",value:e}}function K({tagName:e,children:t=[],properties:n={}}){return{type:"element",tagName:e,properties:n,children:t}}function Xi({name:e,width:t=16,height:n=16,properties:r}){return K({tagName:"svg",properties:{width:t,height:n,viewBox:"0 0 16 16",...r},children:[K({tagName:"use",properties:{href:`#${e.replace(/^#/,"")}`}})]})}function Yx(e){let t=e.children[0];while(t!=null){if(t.type==="element"&&t.tagName==="code")return t;if("children"in t)t=t.children[0];else t=null}}function ui(e){return K({tagName:"div",properties:{"data-gutter":""},children:e})}function Eu(e,t,n,r={}){return K({tagName:"div",properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...r},children:t!=null?[K({tagName:"span",properties:{"data-line-number-content":""},children:[un(`${t}`)]})]:void 0})}function en(e,t,n){return K({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 Jx(){return K({tagName:"button",properties:{"data-utility-button":"",type:"button"},children:[Xi({name:"diffs-icon-plus",properties:{"data-icon":""}})]})}var Tu=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(),di(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;if(this.pre!==e)this.cleanUp(),this.pre=e;if(n)this.ensureGutterUtilityNode(t);else if(this.gutterUtilityContainer!=null){if(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||Uo(e??void 0,this.selectedRange??void 0)),r=t?.lineNumberOnly??!1,i=t?.activeLineSide!==this.selectedRangeHighlightSide||r!==this.selectedRangeLineNumberOnly;if(!this.isSelectionDirty()&&!n&&!i)return;if(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;if(!this.isSelectionDirty()&&!r&&!i)return;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:o}=this.options;if(t==null&&n==null&&r==null&&o==null&&i==null)return;if(this.options.onGutterUtilityClick!=null&&ia(e.composedPath()))return;Nr(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:o,enableGutterUtility:s=!1}=this.options;if(t==="disabled"&&!s&&n==null&&r==null&&i==null&&o==null)return;Nr(this.options.__debugPointerEvents,"move","FileDiff.DEBUG.handlePointerMove:",e),this.handlePointerEvent({eventType:"move",event:e})};handlePointerLeave=(e)=>{let{__debugPointerEvents:t}=this.options;if(Nr(t,"move","FileDiff.DEBUG.handlePointerLeave: no event"),this.hoveredLine==null&&this.hoveredToken==null){Nr(t,"move","FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token");return}if(this.hoveredToken!=null)this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken();if(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();Nr(n,e,"FileDiff.DEBUG.handlePointerEvent:",{eventType:e,composedPath:r});let i=this.resolvePointerTarget(r);Nr(n,e,"FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:",i);let{onLineClick:o,onLineNumberClick:s,onLineEnter:a,onLineLeave:l,onTokenClick:d,onTokenEnter:c,onTokenLeave:m,onHunkExpand:p,onMergeConflictActionClick:h}=this.options;switch(e){case"move":{let x=$f(i)&&this.hoveredLine?.lineElement===i.lineElement;if(!(vu(i)&&this.hoveredToken?.tokenElement===i.tokenElement)){if(this.hoveredToken!=null)m?.(this.hoveredToken,t),this.clearHoveredToken();if(vu(i))this.setHoveredToken(this.toTokenEventBaseProps(i)),c?.(this.hoveredToken,t)}if(!x){if(this.hoveredLine!=null)l?.({...this.hoveredLine,event:t}),this.clearHoveredLine();if($f(i))this.setHoveredLine(this.toEventBaseProps(i)),this.placeUtility(),a?.({...this.hoveredLine,event:t});else this.placeUtility()}break}case"click":{if(i==null)break;if(mF(i)&&h!=null){h(i);break}if(cF(i)&&p!=null){p(i.hunkIndex,i.all||t.shiftKey?"both":i.direction,i.all||t.shiftKey?Number.POSITIVE_INFINITY:void 0);break}if(!$f(i))break;if(vu(i)&&d!=null)d(this.toTokenEventBaseProps(i),t);let x=this.toEventBaseProps(i);if(s!=null&&i.numberColumn)s({...x,event:t});else if(o!=null)o({...x,event:t});break}}}syncPointerListeners(e){let{__debugPointerEvents:t,lineHoverHighlight:n="disabled",onLineClick:r,onLineNumberClick:i,onLineEnter:o,onLineLeave:s,onTokenClick:a,onTokenEnter:l,onTokenLeave:d,onHunkExpand:c,onMergeConflictActionClick:m,enableGutterUtility:p=!1,enableLineSelection:h=!1,onGutterUtilityClick:x}=this.options,I=x!=null,v=n!=="disabled"||r!=null||i!=null||o!=null||s!=null||a!=null||l!=null||d!=null||c!=null||m!=null||p||h||I;if(v&&!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,Nr(t,"click","FileDiff.DEBUG.attachEventListeners: Attaching click events for:",(()=>{let E=[];if(t==="both"||t==="click"){if(r!=null)E.push("onLineClick");if(i!=null)E.push("onLineNumberClick");if(c!=null)E.push("expandable hunk separators");if(m!=null)E.push("merge conflict actions")}return E})()),Nr(t,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer move event"),Nr(t,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event");else if(!v&&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 S=this.pointerSession.mode==="selecting"||this.pointerSession.mode==="pendingSingleLineUnselect",b=this.pointerSession.mode==="gutterSelecting";if(!h&&S||!I&&b)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;if(r&&!this.interactiveLinesAttr)this.pre.setAttribute("data-interactive-lines",""),this.interactiveLinesAttr=!0;else if(!r&&this.interactiveLinesAttr)this.pre.removeAttribute("data-interactive-lines"),this.interactiveLinesAttr=!1;if(i&&!this.interactiveLineNumbersAttr)this.pre.setAttribute("data-interactive-line-numbers",""),this.interactiveLineNumbersAttr=!0;else if(!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();if(ia(t)&&this.options.onGutterUtilityClick!=null)this.startGutterSelectionFromPointerDown(e);else{if(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:o,lineIndex:s}=n;if(e.shiftKey&&this.selectedRange!=null){let a=this.getIndexesFromSelection(this.selectedRange,r.getAttribute("data-diff-type")==="split");if(a==null)return;let l=a.start<=a.end?s>=a.start:s<=a.end;this.selectionAnchor={lineNumber:l?this.selectedRange.start:this.selectedRange.end,side:l?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(i,o,!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 a={lineNumber:i,side:o};this.selectionAnchor=a,this.pointerSession={mode:"pendingSingleLineUnselect",pointerId:e.pointerId,anchor:a,pending:a},this.attachDocumentPointerListeners();return}if(this.options.controlledSelection===!0)this.proposedSelectedRange=null;else this.selectedRange=null;this.placeUtility(),this.selectionAnchor={lineNumber:i,side:o},this.updateSelection(i,o,!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;if(r==null||i==null)return;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(Xx(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"});if(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){if(e.pointerId!==this.pointerSession.pointerId)return}this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){if(this.hoveredLine==null)return;this.hoveredLine.lineElement.removeAttribute("data-hovered"),this.hoveredLine.numberElement.removeAttribute("data-hovered"),this.hoveredLine=void 0}setHoveredLine(e){let{lineHoverHighlight:t="disabled"}=this.options;if(this.hoveredLine!=null)this.clearHoveredLine();if(this.hoveredLine=e,t!=="disabled"){if(t==="both"||t==="line")this.hoveredLine.lineElement.setAttribute("data-hovered","");if(t==="both"||t==="number")this.hoveredLine.numberElement.setAttribute("data-hovered","")}}clearHoveredToken(){if(this.hoveredToken==null)return;this.hoveredToken=void 0}setHoveredToken(e){if(this.hoveredToken!=null)this.clearHoveredToken();this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer==null)this.gutterUtilityContainer=document.createElement("div"),this.gutterUtilityContainer.setAttribute("data-gutter-utility-slot","");if(e){if(this.gutterUtilityButton!=null)this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0;if(this.gutterUtilitySlot==null)this.gutterUtilitySlot=document.createElement("slot"),this.gutterUtilitySlot.name="gutter-utility-slot";if(this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer)this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot)}else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){let t=document.createElement("div");t.innerHTML=ut(Jx());let n=t.firstElementChild;if(!(n instanceof HTMLButtonElement))throw Error("InteractionManager.ensureGutterUtilityNode: Node element should be a button");n.remove(),this.gutterUtilityButton=n}if(this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer)this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;let t=this.resolvePointerTarget(e);if(oa(t)&&t.numberColumn)this.showUtilityOnLine(this.toEventBaseProps(t))}placeUtility(){if(this.placeUtilityFromSelection())return;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);if(t==null)this.hideUtility();else this.showUtilityOnLine(this.toEventBaseProps(t));return!0}showUtilityOnLine(e){if(this.gutterUtilityContainer==null)return;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;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;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 i of r){if(!(i instanceof HTMLElement))continue;let o=this.resolvePointerTarget(ra(i));if(!oa(o))continue;if(this.mode==="diff"&&e.side!=null&&o.side!==e.side)continue;return o}}attachDocumentPointerListeners(){if(this.hasDocumentPointerListeners)return;document.addEventListener("pointermove",this.handleDocumentPointerMove),document.addEventListener("pointerup",this.handleDocumentPointerUp),document.addEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!0}detachDocumentPointerListeners(){if(!this.hasDocumentPointerListeners)return;document.removeEventListener("pointermove",this.handleDocumentPointerMove),document.removeEventListener("pointerup",this.handleDocumentPointerUp),document.removeEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!1}clearPointerSession(){this.pointerSession={mode:"idle"}}clearPendingSingleLineState(){if(this.pointerSession.mode==="pendingSingleLineUnselect")this.pointerSession={mode:"idle"}}selectionInfoFromPath(e,t){let n=this.resolvePointerTarget(e);if(!oa(n))return;if(t&&!n.numberColumn)return;if(n.splitLineIndex==null)return;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?this.selectionInfoFromPath(n,t.requireNumberColumn):void 0}selectionPointFromPath(e){let t=this.resolvePointerTarget(e);if(!oa(t))return;return{lineNumber:t.lineNumber,side:this.mode==="diff"?t.side:void 0}}resolveSelectionPoint(e,t){let n=this.resolveSelectionPath(e,t);return n!=null?this.selectionPointFromPath(n):void 0}resolveSelectionPath(e,t){let n=t.excludeUtility!==!1;switch(t.source){case"event-path":return this.pathFromEventPath(e.composedPath(),n);case"coordinates-first":{let r=this.pathFromCoordinates(e,n);if(r!==void 0)return r??void 0;return this.pathFromEventPath(e.composedPath(),n)}}}pathFromCoordinates(e,t){let n=this.hitTest(e);if(n===void 0)return;if(n===null)return null;return this.pathFromElement(n,t)??null}pathFromEventPath(e,t){if(t&&ia(e))return;for(let n of e)if(n instanceof Element)return this.pathFromElement(n,t)}pathFromElement(e,t){let n=ra(e);if(t&&ia(n))return;let r=pF(e);if(r!=null)return ra(r);return this.pathFromAnnotationSlot(e)}pathFromAnnotationSlot(e){let t=hF(e)?.previousElementSibling;if(t instanceof HTMLElement&&(t.hasAttribute("data-line")||t.hasAttribute("data-column-number")))return ra(t);let n=yF(gF(e));if(n==null)return;let r=this.targetForSelectionPoint(n);return r!=null?ra(r.lineElement):void 0}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;let t=this.pre?.getRootNode(),n=Qx(t)?t:Qx(document)?document:void 0;if(n==null)return;return n.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,t){let{getLineIndex:n}=this.options;return n!=null?n(e,t):[e-1,e-1]}getCurrentSelectionRange(){return this.proposedSelectedRange!==void 0?this.proposedSelectedRange:this.selectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,t,n=!0){let r=this.getCurrentSelectionRange(),i;if(e==null)i=null;else{let o=this.selectionAnchor?.side??t,s=this.selectionAnchor?.lineNumber??e;i=this.buildSelectionRange(s,e,o,t)}if(Uo(r??void 0,i??void 0))return;if(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0)this.proposedSelectedRange=i;else this.selectedRange=i,Go(this.renderSelection);if(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 o=[];for(let s of i){let a=s.hasAttribute("data-deletions")?"deletions":s.hasAttribute("data-additions")?"additions":void 0,l=e!=null&&t!=null&&(e.highlightSide==null||a==null||e.highlightSide===a),d=n!=null&&r!=null&&(n.highlightSide==null||a==null||n.highlightSide===a);if(!l&&!d)continue;let[c,m]=s.children;if(!(c instanceof HTMLElement)||!(m instanceof HTMLElement))throw Error("InteractionManager.renderSelection: missing gutter or content element");if(m.children.length!==c.children.length)throw Error("InteractionManager.renderSelection: gutter and content children dont match, something is wrong");o.push({content:m,gutter:c,renderEditorActiveLine:d,renderSelectedLines:l})}return o}renderSelection=()=>{di(this.renderSelection);let e=this.getSelectionRenderState();if(this.pre==null)return;let{editorActiveLine:t,selectedLines:n}=e,r=!eI(this.renderedSelectedLinesState,n),i=!eI(this.renderedEditorActiveLineState,t);if(!r&&!i)return;if(r)this.renderedSelectedLinesState=void 0;if(i)this.renderedEditorActiveLineState=void 0;let o=this.pre.getAttribute("data-diff-type")==="split",s=!r?void 0:this.resolveLineRenderRange(n,o,"selected-lines"),a=!i?void 0:this.resolveLineRenderRange(t,o,"editor-active-line"),l=this.getLineRenderColumns(r?n:void 0,s,i?t:void 0,a),d=n.range==null||l.some((I)=>I.renderSelectedLines),c=t.range==null||l.some((I)=>I.renderEditorActiveLine);if(r)for(let I of this.pre.querySelectorAll("[data-selected-line]"))I.removeAttribute("data-selected-line");if(i)for(let I of this.pre.querySelectorAll("[data-editor-active-line]"))I.removeAttribute("data-editor-active-line");let m=s==null?void 0:Math.min(s.start,s.end),p=s==null?void 0:Math.max(s.start,s.end),h=m===p,x=a?.start;for(let I of l){let{content:v,gutter:S,renderEditorActiveLine:b,renderSelectedLines:E}=I,w=Math.max(E?p??-1/0:-1/0,b?x??-1/0:-1/0),k=v.children.length;for(let L=0;L<k;L++){let R=v.children[L],A=S.children[L];if(!(R instanceof HTMLElement)||!(A instanceof HTMLElement))continue;let O=this.parseLineIndex(R,o);if((O??0)>w)break;if(O==null)continue;if(E&&m!=null&&p!=null&&O>=m&&O<=p){let D=h?"single":O===m?"first":O===p?"last":"";if(A.setAttribute("data-selected-line",D),!n.lineNumberOnly){if(R.setAttribute("data-selected-line",D),A.nextSibling instanceof HTMLElement&&R.nextSibling instanceof HTMLElement&&(R.nextSibling.hasAttribute("data-line-annotation")||R.nextSibling.hasAttribute("data-merge-conflict-actions"))){if(h)D="last",R.setAttribute("data-selected-line","first");else if(O===m)D="";else if(O===p)R.setAttribute("data-selected-line","");R.nextSibling.setAttribute("data-selected-line",D),A.nextSibling.setAttribute("data-selected-line",D)}}}if(b&&O===x){if(A.setAttribute("data-editor-active-line",""),!t.lineNumberOnly)R.setAttribute("data-editor-active-line","")}}}if(r&&d)this.renderedSelectedLinesState=n;if(i&&c)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){if(this.mode==="file")return{type:"line",lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement};return{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:o}){if(this.mode==="file")return{type:"token",lineCharEnd:e,lineCharStart:t,lineNumber:n,tokenElement:i,tokenText:o};return{type:"token",lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:o}}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,o,s,a,l,d,c,m;for(let h of e){if(!(h instanceof HTMLElement))continue;if(m==null&&h.hasAttribute("data-merge-conflict-action")){let S=h.getAttribute("data-merge-conflict-action")??void 0,b=h.getAttribute("data-merge-conflict-conflict-index")??void 0,E=b!=null?Number.parseInt(b,10):NaN;if(fF(S)&&Number.isFinite(E))m={kind:"merge-conflict-action",resolution:S,conflictIndex:E}}if(a==null&&h.hasAttribute("data-char")){a=h;let S=h.getAttribute("data-char");if(S!=null){let b=Number.parseInt(S,10);if(!Number.isNaN(b)){let E=h.textContent??"",w=b+E.length;if(E.trim()!==""||this.options.enableTokenInteractionsOnWhitespace===!0)l={tokenElement:a,lineCharStart:b,lineCharEnd:w,tokenText:E};continue}}}let x=s==null?h.getAttribute("data-column-number")??void 0:void 0;if(x!=null){s=h,c=Number.parseInt(x,10),t=!0,n=nI(h),o=h.getAttribute("data-line-index")??void 0;continue}let I=i==null?h.getAttribute("data-line")??void 0:void 0;if(I!=null){i=h,c=Number.parseInt(I,10),n=nI(h),o=h.getAttribute("data-line-index")??void 0;continue}if(d==null&&(h.hasAttribute("data-expand-button")||h.hasAttribute("data-unmodified-lines"))){d={hunkIndex:void 0,direction:(()=>{if(h.hasAttribute("data-expand-up"))return"up";if(h.hasAttribute("data-expand-down"))return"down";return"both"})(),all:h.hasAttribute("data-expand-all-button")};continue}let v=d!=null?h.getAttribute("data-expand-index")??void 0:void 0;if(d!=null&&v!=null){let S=Number.parseInt(v,10);if(!Number.isNaN(S))d.hunkIndex=S;continue}if(r==null&&h.hasAttribute("data-code")){r=h;break}}if(m!=null)return m;if(d?.hunkIndex!=null)return{type:"line-info",hunkIndex:d.hunkIndex,direction:d.direction,all:d.all};if(i??=o!=null?Zx(r,`[data-line][data-line-index="${o}"]`):void 0,s??=o!=null?Zx(r,`[data-column-number][data-line-index="${o}"]`):void 0,r==null||i==null||s==null||n==null||c==null||Number.isNaN(c))return;let p=this.parseLineIndex(i,this.isSplitDiff());if(l!=null){if(this.mode==="file")return{kind:"token",lineType:n,lineElement:i,lineNumber:c,numberColumn:t,numberElement:s,side:void 0,splitLineIndex:p,...l};return{kind:"token",lineType:n,lineElement:i,lineNumber:c,numberColumn:t,numberElement:s,side:tI(n,r),splitLineIndex:p,...l}}if(this.mode==="file")return{kind:"line",lineType:n,lineElement:i,lineNumber:c,numberColumn:t,numberElement:s,side:void 0,splitLineIndex:p};return{kind:"line",lineType:n,lineElement:i,lineNumber:c,numberColumn:t,numberElement:s,side:tI(n,r),splitLineIndex:p}}isSplitDiff(){return this.pre?.getAttribute("data-diff-type")==="split"}parseLineIndex(e,t){let n=(e.getAttribute("data-line-index")??"").split(",").map((r)=>Number.parseInt(r,10)).filter((r)=>!Number.isNaN(r));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function jo({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:t,lineHoverHighlight:n,onGutterUtilityClick:r,onLineClick:i,onLineEnter:o,onLineLeave:s,onLineNumberClick:a,onTokenClick:l,onTokenEnter:d,onTokenLeave:c,renderGutterUtility:m,__debugPointerEvents:p,enableLineSelection:h,controlledSelection:x,onLineSelected:I,onLineSelectionStart:v,onLineSelectionChange:S,onLineSelectionEnd:b},E,w,k){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:dF({enableGutterUtility:t,renderGutterUtility:m,onGutterUtilityClick:r}),usesCustomGutterUtility:m!=null,lineHoverHighlight:n,onGutterUtilityClick:r,onHunkExpand:E,onMergeConflictActionClick:k,onLineClick:i,onLineEnter:o,onLineLeave:s,onLineNumberClick:a,onTokenClick:l,onTokenEnter:d,onTokenLeave:c,__debugPointerEvents:p,enableLineSelection:h,controlledSelection:x,onLineSelected:I,onLineSelectionStart:v,onLineSelectionChange:S,onLineSelectionEnd:b,getLineIndex:w}}function dF({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 oa(e){return e!=null&&"kind"in e&&e.kind==="line"}function vu(e){return e!=null&&"kind"in e&&e.kind==="token"}function $f(e){return oa(e)||vu(e)}function cF(e){return"type"in e&&e.type==="line-info"}function mF(e){return"kind"in e&&e.kind==="merge-conflict-action"}function fF(e){return e==="current"||e==="incoming"||e==="both"}function Zx(e,t){let n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function ra(e){let t=[],n=e;while(n!=null)t.push(n),n=n.parentNode;return t}function pF(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 hF(e){let t=e.closest('[slot^="annotation-"]'),n=(t instanceof HTMLElement&&t.assignedSlot!=null?t.assignedSlot:e.tagName==="SLOT"?e:void 0)?.closest("[data-line-annotation]");return n instanceof HTMLElement?n:void 0}function gF(e){let t=e.closest('[slot^="annotation-"]');if(t instanceof HTMLElement)return t.getAttribute("slot")??void 0;if(e instanceof HTMLElement){let n=e.getAttribute("name")??void 0;return n!=null&&n.startsWith("annotation-")?n:void 0}}function yF(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;return{lineNumber:n,side:t[1]}}function Qx(e){return e!=null&&typeof e.elementFromPoint==="function"}function xF(e,t){return e===t||Uo(e??void 0,t??void 0)}function eI(e,t){return e?.highlightSide===t.highlightSide&&e?.lineNumberOnly===t.lineNumberOnly&&xF(e?.range??null,t.range)}function tI(e,t){switch(e){case"change-deletion":return"deletions";case"change-addition":return"additions";default:return t.hasAttribute("data-deletions")?"deletions":"additions"}}function nI(e){let t=e.getAttribute("data-line-type");if(t==null)return;switch(t){case"change-deletion":case"change-addition":case"context":case"context-expanded":return t;default:return}}function Nr(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 ku=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 i=e.managersByElement.get(r.target);if(i==null)continue;let o=n.get(i);if(o==null)n.set(i,[r]);else o.push(r)}for(let[r,i]of n)r.handleResizeEntries(i)}observedNodes=new Map;setup(t,{disableAnnotations:n,columnVariables:r="apply"}){let i=new Set,o=r==="apply",s=0,a=new Map(this.observedNodes);this.observedNodes.clear();for(let l of t.children){if(s===2)break;let d=(()=>{if(l instanceof HTMLElement&&l.tagName==="CODE")return l})();if(d==null)continue;s++;let c=a.get(d);if(c!=null&&c.type!=="code")throw Error("ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible");let m=d.firstElementChild;if(!(m instanceof HTMLElement))m=null;if(c!=null){if(this.observedNodes.set(d,c),a.delete(d),c.numberElement!==m){if(c.numberElement!=null)this.unobserve(c.numberElement),a.delete(c.numberElement);if(m!=null)this.observe(m),a.delete(m),this.observedNodes.set(m,c);c.numberElement=m,c.numberWidth=0}else if(c.numberElement!=null)a.delete(c.numberElement),this.observedNodes.set(c.numberElement,c);else c.numberWidth=0;bF(c,o)}else if(c={type:"code",codeElement:d,numberElement:m,codeWidth:"auto",numberWidth:0,applyColumnVariables:o},this.observedNodes.set(d,c),this.observe(d),m!=null)this.observedNodes.set(m,c),this.observe(m)}if(s>1&&!n){let l=t.querySelectorAll('[data-line-annotation*=","]'),d=new Map;for(let c of l){if(!(c instanceof HTMLElement))continue;let m=c.getAttribute("data-line-annotation")??"";if(!/^-?\d+,-?\d+$/.test(m)){console.error("DiffFileRenderer.setupResizeObserver: Invalid element or annotation",{lineAnnotation:m,element:c});continue}let p=d.get(m);if(p==null)p=[],d.set(m,p);p.push(c)}for(let[c,m]of d){if(m.length!==2){console.error("DiffFileRenderer.setupResizeObserver: Bad Pair",c,m);continue}let[p,h]=m,x=p.firstElementChild,I=h.firstElementChild;if(!(p instanceof HTMLElement)||!(h instanceof HTMLElement)||!(x instanceof HTMLElement)||!(I instanceof HTMLElement))continue;let v=a.get(x);if(v!=null){this.observedNodes.set(x,v),this.observedNodes.set(I,v),a.delete(x),a.delete(I);continue}let S=x.getBoundingClientRect().height,b=I.getBoundingClientRect().height;v={type:"annotations",column1:{container:p,child:x,childHeight:S},column2:{container:h,child:I,childHeight:b},currentHeight:"auto"},i.add({child1:x,child2:I,item:v,newHeight:Math.max(S,b)})}for(let c of i)this.applyNewHeight(c.item,c.newHeight),this.observedNodes.set(c.child1,c.item),this.observedNodes.set(c.child2,c.item),this.observe(c.child1),this.observe(c.child2);i.clear()}for(let[l,d]of a)if(this.unobserve(l),d.type==="code")CF(d);else EF(d);a.clear()}cleanUp(){for(let t of this.observedNodes.keys())this.unobserve(t);this.observedNodes.clear()}observe(t){let{managersByElement:n}=e,r=n.get(t);if(r===this)return;else 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)return;else if(i!==this)throw Error("ResizeManager.unobserve: element is owned by another ResizeManager");if(n.delete(t),r?.unobserve(t),r!=null&&n.size===0)r.disconnect(),e.resizeObserver=void 0}handleResizeEntries(t){let n=new Map,r=new Set;for(let i of t){let{target:o,borderBoxSize:s,contentBoxSize:a}=i;if(!(o instanceof HTMLElement)){console.error("ResizeManager.handleResizeEntries: Invalid element for ResizeObserver",i);continue}let l=this.observedNodes.get(o);if(l==null){console.error("ResizeManager.handleResizeEntries: Not a valid observed node",i);continue}if(l.type==="annotations"){let d=(()=>{if(o===l.column1.child)return l.column1;if(o===l.column2.child)return l.column2})();if(d==null){console.error("ResizeManager.handleResizeEntries: Couldn't find a column for",{item:l,target:o});continue}d.childHeight=s[0].blockSize,r.add(l)}else if(l.type==="code"){let d=n.get(l)??{},c=a[0].inlineSize;if(o===l.codeElement)d.codeInlineSize=c;else if(o===l.numberElement)d.numberInlineSize=c;n.set(l,d)}}this.applyAnnotationUpdates(r),r.clear(),this.applyColumnUpdates(n),n.clear()}applyAnnotationUpdates(t){for(let n of t)this.applyNewHeight(n,Math.max(n.column1.childHeight,n.column2.childHeight))}applyColumnUpdates=(t)=>{for(let[n,r]of t){let i=r.codeInlineSize!=null?IF(r.codeInlineSize):n.codeWidth,o=r.numberInlineSize!=null?SF(r.numberInlineSize):n.numberWidth,s=i!==n.codeWidth,a=o!==n.numberWidth;if(!s&&!a)continue;if(n.codeWidth=i,n.numberWidth=o,n.applyColumnVariables)rI(n,{codeWidthChanged:s,numberWidthChanged:a})}};applyNewHeight(t,n){if(n!==t.currentHeight)t.currentHeight=Math.max(n,0),t.column1.container.style.setProperty("--diffs-annotation-min-height",`${t.currentHeight}px`),t.column2.container.style.setProperty("--diffs-annotation-min-height",`${t.currentHeight}px`)}};function IF(e){let t=Math.max(Math.floor(e),0);return t===0?"auto":t}function SF(e){return Math.max(Math.ceil(e),0)}function bF(e,t){if(e.applyColumnVariables===t)return;if(e.applyColumnVariables=t,t)rI(e,{codeWidthChanged:!0,numberWidthChanged:!0});else iI(e)}function rI(e,{codeWidthChanged:t,numberWidthChanged:n}){let{codeElement:r,codeWidth:i,numberWidth:o}=e;if(t)r.style.setProperty("--diffs-column-width",`${typeof i==="number"?`${i}px`:"auto"}`);if(n)r.style.setProperty("--diffs-column-number-width",`${o===0?"auto":`${o}px`}`);if(t||n&&i!=="auto"){let s=typeof i==="number"?Math.max(i-o,0):0;r.style.setProperty("--diffs-column-content-width",`${s>0?`${s}px`:"auto"}`)}}function iI(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 CF(e){if(e.codeElement.isConnected)iI(e)}function EF(e){if(e.column1.container.isConnected)e.column1.container.style.removeProperty("--diffs-annotation-min-height");if(e.column2.container.isConnected)e.column2.container.style.removeProperty("--diffs-annotation-min-height")}function ci(e,t){if(e==null||t==null)return e===t;return e.startingLine===t.startingLine&&e.totalLines===t.totalLines&&e.bufferBefore===t.bufferBefore&&e.bufferAfter===t.bufferAfter}function qo(e){return(e.lang??tt(e.name))==="text"}function oI(e){return Zt.hasResolvedThemes(e)}function wu(e,t){if(e.endsWith(`\r
|
|
159
|
+
`))return e.slice(0,-1);return e}function CF(e){return e.startsWith("diff --git")||e.includes(`
|
|
160
|
+
diff --git`)}function qx(e,t){if(e.length===0)return[""];let n=`
|
|
161
|
+
${t}`,r=e.startsWith(t)?0:Mx(e,n,0);if(r===-1)return[e];let i=[];if(r>0)i.push(e.slice(0,r));let o=r;for(;;){let s=Mx(e,n,o+1);if(s===-1)break;i.push(e.slice(o,s)),o=s}return i.push(e.slice(o)),i}function Mx(e,t,n){let r=e.indexOf(t,n);return r===-1?-1:r+1}function Ox(e){return e==null?e:xt(e)}function EF(e){return e===" "?"context":e==="\\"?"metadata":e==="+"?"addition":"deletion"}function wf(e){let t=e.slice(1);return xt(t===""?`
|
|
162
|
+
`:t)}function Lf(e,t,n){if(e==="change")return{type:"change",additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:t};return{type:"context",lines:0,additionLineIndex:n,deletionLineIndex:t}}function zx(e,t){if(e==null||t==null)return e===t;if(e.header!==t.header||e.footer!==t.footer)return!1;return vF(e.items,t.items)}function vF(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r==null||i==null||r.id!==i.id||r.type!==i.type||r.element!==i.element||r.instance!==i.instance||r.version!==i.version)return!1}return!0}function ar(e,t,n){if(e===t||e==null||t==null)return e===t;let r=new Set(n),i=Object.keys(e),o=new Set(Object.keys(t));for(let s of i){if(o.delete(s),r.has(s))continue;if(!(s in t)||e[s]!==t[s])return!1}for(let s of Array.from(o))if(!r.has(s))return!1;return!0}function Cn(e,t){if(e==null||t==null||typeof e==="string"||typeof t==="string")return e===t;return e.dark===t.dark&&e.light===t.light}function Go(e,t){let n=e?.theme??Oe,r=t?.theme??Oe,i=Kx(e),o=Kx(t);return Cn(n,r)&&ar(e,t,["theme","parseDiffOptions"])&&ar(i,o)}function Kx(e){if(e!=null&&"parseDiffOptions"in e)return e.parseDiffOptions}function jo(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}function Xx(e,t,n){let r=document.createElement("div");if(r.style.display="flow-root",e==="header")r.setAttribute(Vx,""),t.before(r);else r.setAttribute(Wx,""),t.after(r);return n?.observe(r),r}function Yx({scrollTop:e,scrollHeight:t,height:n,fitPerfectly:r=!1,fitPerfectlyOverscroll:i=0,overscrollSize:o}){let s=n+o*2,a=r?n+i*2:s;if(t=Math.max(t,a),s>=t||r){let c=Math.max(e-i,0),m=Math.min(e+a,t);return{top:c,bottom:Math.max(m,c)}}let l=e+n/2-s/2,d=l+s;if(l<0)l=0;if(d>t)d=t;return l=Math.floor(Math.max(l,0)),{top:l,bottom:Math.ceil(Math.max(Math.min(d,t),l))}}function ai(e){if(typeof HTMLStyleElement<"u"&&e instanceof HTMLStyleElement)return!0;let t=e.tagName??e.nodeName;return typeof t==="string"&&t.toLowerCase()==="style"}function Jx(){if(typeof window>"u"||typeof window.matchMedia!=="function")return!1;return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function qn(e){let t=window.devicePixelRatio??1;return Math.round(e*t)/t}function et(e,t){return e?.cacheKey!=null||t?.cacheKey!=null?e?.cacheKey===t?.cacheKey:e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}function qo(e){return{...Cu,...e}}function En(e,t){let n=kF(e,t);return t?n:e.diffHeaderHeight+n}function kF(e,t){return e.paddingTop??(t?e.spacing:0)}function Wi(e){return e.paddingBottom??e.spacing}function Zx(e){switch(e){case"simple":return 4;case"metadata":case"line-info":case"line-info-basic":case"custom":return 32}}var Eu="-1,-1";function na(e){return e?.some((t)=>t.lineNumber===0)??!1}function ra(e){let t=e[0];return t!=null&&t.length>0?t:void 0}function li(e){return e.startingLine===0&&e.totalLines>0}function Qx(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side}function un(e){return{type:"text",value:e}}function K({tagName:e,children:t=[],properties:n={}}){return{type:"element",tagName:e,properties:n,children:t}}function Xi({name:e,width:t=16,height:n=16,properties:r}){return K({tagName:"svg",properties:{width:t,height:n,viewBox:"0 0 16 16",...r},children:[K({tagName:"use",properties:{href:`#${e.replace(/^#/,"")}`}})]})}function eI(e){let t=e.children[0];while(t!=null){if(t.type==="element"&&t.tagName==="code")return t;if("children"in t)t=t.children[0];else t=null}}function ui(e){return K({tagName:"div",properties:{"data-gutter":""},children:e})}function vu(e,t,n,r={}){return K({tagName:"div",properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...r},children:t!=null?[K({tagName:"span",properties:{"data-line-number-content":""},children:[un(`${t}`)]})]:void 0})}function en(e,t,n){return K({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 tI(){return K({tagName:"button",properties:{"data-utility-button":"",type:"button"},children:[Xi({name:"diffs-icon-plus",properties:{"data-icon":""}})]})}var Tu=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(),di(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;if(this.pre!==e)this.cleanUp(),this.pre=e;if(n)this.ensureGutterUtilityNode(t);else if(this.gutterUtilityContainer!=null){if(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||jo(e??void 0,this.selectedRange??void 0)),r=t?.lineNumberOnly??!1,i=t?.activeLineSide!==this.selectedRangeHighlightSide||r!==this.selectedRangeLineNumberOnly;if(!this.isSelectionDirty()&&!n&&!i)return;if(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;if(!this.isSelectionDirty()&&!r&&!i)return;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:o}=this.options;if(t==null&&n==null&&r==null&&o==null&&i==null)return;if(this.options.onGutterUtilityClick!=null&&oa(e.composedPath()))return;Dr(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:o,enableGutterUtility:s=!1}=this.options;if(t==="disabled"&&!s&&n==null&&r==null&&i==null&&o==null)return;Dr(this.options.__debugPointerEvents,"move","FileDiff.DEBUG.handlePointerMove:",e),this.handlePointerEvent({eventType:"move",event:e})};handlePointerLeave=(e)=>{let{__debugPointerEvents:t}=this.options;if(Dr(t,"move","FileDiff.DEBUG.handlePointerLeave: no event"),this.hoveredLine==null&&this.hoveredToken==null){Dr(t,"move","FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token");return}if(this.hoveredToken!=null)this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken();if(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();Dr(n,e,"FileDiff.DEBUG.handlePointerEvent:",{eventType:e,composedPath:r});let i=this.resolvePointerTarget(r);Dr(n,e,"FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:",i);let{onLineClick:o,onLineNumberClick:s,onLineEnter:a,onLineLeave:l,onTokenClick:d,onTokenEnter:c,onTokenLeave:m,onHunkExpand:p,onMergeConflictActionClick:h}=this.options;switch(e){case"move":{let x=$f(i)&&this.hoveredLine?.lineElement===i.lineElement;if(!(ku(i)&&this.hoveredToken?.tokenElement===i.tokenElement)){if(this.hoveredToken!=null)m?.(this.hoveredToken,t),this.clearHoveredToken();if(ku(i))this.setHoveredToken(this.toTokenEventBaseProps(i)),c?.(this.hoveredToken,t)}if(!x){if(this.hoveredLine!=null)l?.({...this.hoveredLine,event:t}),this.clearHoveredLine();if($f(i))this.setHoveredLine(this.toEventBaseProps(i)),this.placeUtility(),a?.({...this.hoveredLine,event:t});else this.placeUtility()}break}case"click":{if(i==null)break;if(LF(i)&&h!=null){h(i);break}if(wF(i)&&p!=null){p(i.hunkIndex,i.all||t.shiftKey?"both":i.direction,i.all||t.shiftKey?Number.POSITIVE_INFINITY:void 0);break}if(!$f(i))break;if(ku(i)&&d!=null)d(this.toTokenEventBaseProps(i),t);let x=this.toEventBaseProps(i);if(s!=null&&i.numberColumn)s({...x,event:t});else if(o!=null)o({...x,event:t});break}}}syncPointerListeners(e){let{__debugPointerEvents:t,lineHoverHighlight:n="disabled",onLineClick:r,onLineNumberClick:i,onLineEnter:o,onLineLeave:s,onTokenClick:a,onTokenEnter:l,onTokenLeave:d,onHunkExpand:c,onMergeConflictActionClick:m,enableGutterUtility:p=!1,enableLineSelection:h=!1,onGutterUtilityClick:x}=this.options,I=x!=null,v=n!=="disabled"||r!=null||i!=null||o!=null||s!=null||a!=null||l!=null||d!=null||c!=null||m!=null||p||h||I;if(v&&!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,Dr(t,"click","FileDiff.DEBUG.attachEventListeners: Attaching click events for:",(()=>{let E=[];if(t==="both"||t==="click"){if(r!=null)E.push("onLineClick");if(i!=null)E.push("onLineNumberClick");if(c!=null)E.push("expandable hunk separators");if(m!=null)E.push("merge conflict actions")}return E})()),Dr(t,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer move event"),Dr(t,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event");else if(!v&&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 S=this.pointerSession.mode==="selecting"||this.pointerSession.mode==="pendingSingleLineUnselect",b=this.pointerSession.mode==="gutterSelecting";if(!h&&S||!I&&b)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;if(r&&!this.interactiveLinesAttr)this.pre.setAttribute("data-interactive-lines",""),this.interactiveLinesAttr=!0;else if(!r&&this.interactiveLinesAttr)this.pre.removeAttribute("data-interactive-lines"),this.interactiveLinesAttr=!1;if(i&&!this.interactiveLineNumbersAttr)this.pre.setAttribute("data-interactive-line-numbers",""),this.interactiveLineNumbersAttr=!0;else if(!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();if(oa(t)&&this.options.onGutterUtilityClick!=null)this.startGutterSelectionFromPointerDown(e);else{if(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:o,lineIndex:s}=n;if(e.shiftKey&&this.selectedRange!=null){let a=this.getIndexesFromSelection(this.selectedRange,r.getAttribute("data-diff-type")==="split");if(a==null)return;let l=a.start<=a.end?s>=a.start:s<=a.end;this.selectionAnchor={lineNumber:l?this.selectedRange.start:this.selectedRange.end,side:l?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(i,o,!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 a={lineNumber:i,side:o};this.selectionAnchor=a,this.pointerSession={mode:"pendingSingleLineUnselect",pointerId:e.pointerId,anchor:a,pending:a},this.attachDocumentPointerListeners();return}if(this.options.controlledSelection===!0)this.proposedSelectedRange=null;else this.selectedRange=null;this.placeUtility(),this.selectionAnchor={lineNumber:i,side:o},this.updateSelection(i,o,!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;if(r==null||i==null)return;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(Qx(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"});if(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){if(e.pointerId!==this.pointerSession.pointerId)return}this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){if(this.hoveredLine==null)return;this.hoveredLine.lineElement.removeAttribute("data-hovered"),this.hoveredLine.numberElement.removeAttribute("data-hovered"),this.hoveredLine=void 0}setHoveredLine(e){let{lineHoverHighlight:t="disabled"}=this.options;if(this.hoveredLine!=null)this.clearHoveredLine();if(this.hoveredLine=e,t!=="disabled"){if(t==="both"||t==="line")this.hoveredLine.lineElement.setAttribute("data-hovered","");if(t==="both"||t==="number")this.hoveredLine.numberElement.setAttribute("data-hovered","")}}clearHoveredToken(){if(this.hoveredToken==null)return;this.hoveredToken=void 0}setHoveredToken(e){if(this.hoveredToken!=null)this.clearHoveredToken();this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer==null)this.gutterUtilityContainer=document.createElement("div"),this.gutterUtilityContainer.setAttribute("data-gutter-utility-slot","");if(e){if(this.gutterUtilityButton!=null)this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0;if(this.gutterUtilitySlot==null)this.gutterUtilitySlot=document.createElement("slot"),this.gutterUtilitySlot.name="gutter-utility-slot";if(this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer)this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot)}else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){let t=document.createElement("div");t.innerHTML=ut(tI());let n=t.firstElementChild;if(!(n instanceof HTMLButtonElement))throw Error("InteractionManager.ensureGutterUtilityNode: Node element should be a button");n.remove(),this.gutterUtilityButton=n}if(this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer)this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;let t=this.resolvePointerTarget(e);if(sa(t)&&t.numberColumn)this.showUtilityOnLine(this.toEventBaseProps(t))}placeUtility(){if(this.placeUtilityFromSelection())return;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);if(t==null)this.hideUtility();else this.showUtilityOnLine(this.toEventBaseProps(t));return!0}showUtilityOnLine(e){if(this.gutterUtilityContainer==null)return;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;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;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 i of r){if(!(i instanceof HTMLElement))continue;let o=this.resolvePointerTarget(ia(i));if(!sa(o))continue;if(this.mode==="diff"&&e.side!=null&&o.side!==e.side)continue;return o}}attachDocumentPointerListeners(){if(this.hasDocumentPointerListeners)return;document.addEventListener("pointermove",this.handleDocumentPointerMove),document.addEventListener("pointerup",this.handleDocumentPointerUp),document.addEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!0}detachDocumentPointerListeners(){if(!this.hasDocumentPointerListeners)return;document.removeEventListener("pointermove",this.handleDocumentPointerMove),document.removeEventListener("pointerup",this.handleDocumentPointerUp),document.removeEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!1}clearPointerSession(){this.pointerSession={mode:"idle"}}clearPendingSingleLineState(){if(this.pointerSession.mode==="pendingSingleLineUnselect")this.pointerSession={mode:"idle"}}selectionInfoFromPath(e,t){let n=this.resolvePointerTarget(e);if(!sa(n))return;if(t&&!n.numberColumn)return;if(n.splitLineIndex==null)return;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?this.selectionInfoFromPath(n,t.requireNumberColumn):void 0}selectionPointFromPath(e){let t=this.resolvePointerTarget(e);if(!sa(t))return;return{lineNumber:t.lineNumber,side:this.mode==="diff"?t.side:void 0}}resolveSelectionPoint(e,t){let n=this.resolveSelectionPath(e,t);return n!=null?this.selectionPointFromPath(n):void 0}resolveSelectionPath(e,t){let n=t.excludeUtility!==!1;switch(t.source){case"event-path":return this.pathFromEventPath(e.composedPath(),n);case"coordinates-first":{let r=this.pathFromCoordinates(e,n);if(r!==void 0)return r??void 0;return this.pathFromEventPath(e.composedPath(),n)}}}pathFromCoordinates(e,t){let n=this.hitTest(e);if(n===void 0)return;if(n===null)return null;return this.pathFromElement(n,t)??null}pathFromEventPath(e,t){if(t&&oa(e))return;for(let n of e)if(n instanceof Element)return this.pathFromElement(n,t)}pathFromElement(e,t){let n=ia(e);if(t&&oa(n))return;let r=AF(e);if(r!=null)return ia(r);return this.pathFromAnnotationSlot(e)}pathFromAnnotationSlot(e){let t=PF(e)?.previousElementSibling;if(t instanceof HTMLElement&&(t.hasAttribute("data-line")||t.hasAttribute("data-column-number")))return ia(t);let n=MF($F(e));if(n==null)return;let r=this.targetForSelectionPoint(n);return r!=null?ia(r.lineElement):void 0}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;let t=this.pre?.getRootNode(),n=rI(t)?t:rI(document)?document:void 0;if(n==null)return;return n.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,t){let{getLineIndex:n}=this.options;return n!=null?n(e,t):[e-1,e-1]}getCurrentSelectionRange(){return this.proposedSelectedRange!==void 0?this.proposedSelectedRange:this.selectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,t,n=!0){let r=this.getCurrentSelectionRange(),i;if(e==null)i=null;else{let o=this.selectionAnchor?.side??t,s=this.selectionAnchor?.lineNumber??e;i=this.buildSelectionRange(s,e,o,t)}if(jo(r??void 0,i??void 0))return;if(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0)this.proposedSelectedRange=i;else this.selectedRange=i,zo(this.renderSelection);if(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 o=[];for(let s of i){let a=s.hasAttribute("data-deletions")?"deletions":s.hasAttribute("data-additions")?"additions":void 0,l=e!=null&&t!=null&&(e.highlightSide==null||a==null||e.highlightSide===a),d=n!=null&&r!=null&&(n.highlightSide==null||a==null||n.highlightSide===a);if(!l&&!d)continue;let[c,m]=s.children;if(!(c instanceof HTMLElement)||!(m instanceof HTMLElement))throw Error("InteractionManager.renderSelection: missing gutter or content element");if(m.children.length!==c.children.length)throw Error("InteractionManager.renderSelection: gutter and content children dont match, something is wrong");o.push({content:m,gutter:c,renderEditorActiveLine:d,renderSelectedLines:l})}return o}renderSelection=()=>{di(this.renderSelection);let e=this.getSelectionRenderState();if(this.pre==null)return;let{editorActiveLine:t,selectedLines:n}=e,r=!iI(this.renderedSelectedLinesState,n),i=!iI(this.renderedEditorActiveLineState,t);if(!r&&!i)return;if(r)this.renderedSelectedLinesState=void 0;if(i)this.renderedEditorActiveLineState=void 0;let o=this.pre.getAttribute("data-diff-type")==="split",s=!r?void 0:this.resolveLineRenderRange(n,o,"selected-lines"),a=!i?void 0:this.resolveLineRenderRange(t,o,"editor-active-line"),l=this.getLineRenderColumns(r?n:void 0,s,i?t:void 0,a),d=n.range==null||l.some((I)=>I.renderSelectedLines),c=t.range==null||l.some((I)=>I.renderEditorActiveLine);if(r)for(let I of this.pre.querySelectorAll("[data-selected-line]"))I.removeAttribute("data-selected-line");if(i)for(let I of this.pre.querySelectorAll("[data-editor-active-line]"))I.removeAttribute("data-editor-active-line");let m=s==null?void 0:Math.min(s.start,s.end),p=s==null?void 0:Math.max(s.start,s.end),h=m===p,x=a?.start;for(let I of l){let{content:v,gutter:S,renderEditorActiveLine:b,renderSelectedLines:E}=I,w=Math.max(E?p??-1/0:-1/0,b?x??-1/0:-1/0),T=v.children.length;for(let L=0;L<T;L++){let R=v.children[L],A=S.children[L];if(!(R instanceof HTMLElement)||!(A instanceof HTMLElement))continue;let O=this.parseLineIndex(R,o);if((O??0)>w)break;if(O==null)continue;if(E&&m!=null&&p!=null&&O>=m&&O<=p){let D=h?"single":O===m?"first":O===p?"last":"";if(A.setAttribute("data-selected-line",D),!n.lineNumberOnly){if(R.setAttribute("data-selected-line",D),A.nextSibling instanceof HTMLElement&&R.nextSibling instanceof HTMLElement&&(R.nextSibling.hasAttribute("data-line-annotation")||R.nextSibling.hasAttribute("data-merge-conflict-actions"))){if(h)D="last",R.setAttribute("data-selected-line","first");else if(O===m)D="";else if(O===p)R.setAttribute("data-selected-line","");R.nextSibling.setAttribute("data-selected-line",D),A.nextSibling.setAttribute("data-selected-line",D)}}}if(b&&O===x){if(A.setAttribute("data-editor-active-line",""),!t.lineNumberOnly)R.setAttribute("data-editor-active-line","")}}}if(r&&d)this.renderedSelectedLinesState=n;if(i&&c)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){if(this.mode==="file")return{type:"line",lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement};return{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:o}){if(this.mode==="file")return{type:"token",lineCharEnd:e,lineCharStart:t,lineNumber:n,tokenElement:i,tokenText:o};return{type:"token",lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:o}}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,o,s,a,l,d,c,m;for(let h of e){if(!(h instanceof HTMLElement))continue;if(m==null&&h.hasAttribute("data-merge-conflict-action")){let S=h.getAttribute("data-merge-conflict-action")??void 0,b=h.getAttribute("data-merge-conflict-conflict-index")??void 0,E=b!=null?Number.parseInt(b,10):NaN;if(RF(S)&&Number.isFinite(E))m={kind:"merge-conflict-action",resolution:S,conflictIndex:E}}if(a==null&&h.hasAttribute("data-char")){a=h;let S=h.getAttribute("data-char");if(S!=null){let b=Number.parseInt(S,10);if(!Number.isNaN(b)){let E=h.textContent??"",w=b+E.length;if(E.trim()!==""||this.options.enableTokenInteractionsOnWhitespace===!0)l={tokenElement:a,lineCharStart:b,lineCharEnd:w,tokenText:E};continue}}}let x=s==null?h.getAttribute("data-column-number")??void 0:void 0;if(x!=null){s=h,c=Number.parseInt(x,10),t=!0,n=sI(h),o=h.getAttribute("data-line-index")??void 0;continue}let I=i==null?h.getAttribute("data-line")??void 0:void 0;if(I!=null){i=h,c=Number.parseInt(I,10),n=sI(h),o=h.getAttribute("data-line-index")??void 0;continue}if(d==null&&(h.hasAttribute("data-expand-button")||h.hasAttribute("data-unmodified-lines"))){d={hunkIndex:void 0,direction:(()=>{if(h.hasAttribute("data-expand-up"))return"up";if(h.hasAttribute("data-expand-down"))return"down";return"both"})(),all:h.hasAttribute("data-expand-all-button")};continue}let v=d!=null?h.getAttribute("data-expand-index")??void 0:void 0;if(d!=null&&v!=null){let S=Number.parseInt(v,10);if(!Number.isNaN(S))d.hunkIndex=S;continue}if(r==null&&h.hasAttribute("data-code")){r=h;break}}if(m!=null)return m;if(d?.hunkIndex!=null)return{type:"line-info",hunkIndex:d.hunkIndex,direction:d.direction,all:d.all};if(i??=o!=null?nI(r,`[data-line][data-line-index="${o}"]`):void 0,s??=o!=null?nI(r,`[data-column-number][data-line-index="${o}"]`):void 0,r==null||i==null||s==null||n==null||c==null||Number.isNaN(c))return;let p=this.parseLineIndex(i,this.isSplitDiff());if(l!=null){if(this.mode==="file")return{kind:"token",lineType:n,lineElement:i,lineNumber:c,numberColumn:t,numberElement:s,side:void 0,splitLineIndex:p,...l};return{kind:"token",lineType:n,lineElement:i,lineNumber:c,numberColumn:t,numberElement:s,side:oI(n,r),splitLineIndex:p,...l}}if(this.mode==="file")return{kind:"line",lineType:n,lineElement:i,lineNumber:c,numberColumn:t,numberElement:s,side:void 0,splitLineIndex:p};return{kind:"line",lineType:n,lineElement:i,lineNumber:c,numberColumn:t,numberElement:s,side:oI(n,r),splitLineIndex:p}}isSplitDiff(){return this.pre?.getAttribute("data-diff-type")==="split"}parseLineIndex(e,t){let n=(e.getAttribute("data-line-index")??"").split(",").map((r)=>Number.parseInt(r,10)).filter((r)=>!Number.isNaN(r));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function Ko({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:t,lineHoverHighlight:n,onGutterUtilityClick:r,onLineClick:i,onLineEnter:o,onLineLeave:s,onLineNumberClick:a,onTokenClick:l,onTokenEnter:d,onTokenLeave:c,renderGutterUtility:m,__debugPointerEvents:p,enableLineSelection:h,controlledSelection:x,onLineSelected:I,onLineSelectionStart:v,onLineSelectionChange:S,onLineSelectionEnd:b},E,w,T){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:TF({enableGutterUtility:t,renderGutterUtility:m,onGutterUtilityClick:r}),usesCustomGutterUtility:m!=null,lineHoverHighlight:n,onGutterUtilityClick:r,onHunkExpand:E,onMergeConflictActionClick:T,onLineClick:i,onLineEnter:o,onLineLeave:s,onLineNumberClick:a,onTokenClick:l,onTokenEnter:d,onTokenLeave:c,__debugPointerEvents:p,enableLineSelection:h,controlledSelection:x,onLineSelected:I,onLineSelectionStart:v,onLineSelectionChange:S,onLineSelectionEnd:b,getLineIndex:w}}function TF({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 sa(e){return e!=null&&"kind"in e&&e.kind==="line"}function ku(e){return e!=null&&"kind"in e&&e.kind==="token"}function $f(e){return sa(e)||ku(e)}function wF(e){return"type"in e&&e.type==="line-info"}function LF(e){return"kind"in e&&e.kind==="merge-conflict-action"}function RF(e){return e==="current"||e==="incoming"||e==="both"}function nI(e,t){let n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function ia(e){let t=[],n=e;while(n!=null)t.push(n),n=n.parentNode;return t}function AF(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 PF(e){let t=e.closest('[slot^="annotation-"]'),n=(t instanceof HTMLElement&&t.assignedSlot!=null?t.assignedSlot:e.tagName==="SLOT"?e:void 0)?.closest("[data-line-annotation]");return n instanceof HTMLElement?n:void 0}function $F(e){let t=e.closest('[slot^="annotation-"]');if(t instanceof HTMLElement)return t.getAttribute("slot")??void 0;if(e instanceof HTMLElement){let n=e.getAttribute("name")??void 0;return n!=null&&n.startsWith("annotation-")?n:void 0}}function MF(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;return{lineNumber:n,side:t[1]}}function rI(e){return e!=null&&typeof e.elementFromPoint==="function"}function OF(e,t){return e===t||jo(e??void 0,t??void 0)}function iI(e,t){return e?.highlightSide===t.highlightSide&&e?.lineNumberOnly===t.lineNumberOnly&&OF(e?.range??null,t.range)}function oI(e,t){switch(e){case"change-deletion":return"deletions";case"change-addition":return"additions";default:return t.hasAttribute("data-deletions")?"deletions":"additions"}}function sI(e){let t=e.getAttribute("data-line-type");if(t==null)return;switch(t){case"change-deletion":case"change-addition":case"context":case"context-expanded":return t;default:return}}function Dr(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 wu=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 i=e.managersByElement.get(r.target);if(i==null)continue;let o=n.get(i);if(o==null)n.set(i,[r]);else o.push(r)}for(let[r,i]of n)r.handleResizeEntries(i)}observedNodes=new Map;setup(t,{disableAnnotations:n,columnVariables:r="apply"}){let i=new Set,o=r==="apply",s=0,a=new Map(this.observedNodes);this.observedNodes.clear();for(let l of t.children){if(s===2)break;let d=(()=>{if(l instanceof HTMLElement&&l.tagName==="CODE")return l})();if(d==null)continue;s++;let c=a.get(d);if(c!=null&&c.type!=="code")throw Error("ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible");let m=d.firstElementChild;if(!(m instanceof HTMLElement))m=null;if(c!=null){if(this.observedNodes.set(d,c),a.delete(d),c.numberElement!==m){if(c.numberElement!=null)this.unobserve(c.numberElement),a.delete(c.numberElement);if(m!=null)this.observe(m),a.delete(m),this.observedNodes.set(m,c);c.numberElement=m,c.numberWidth=0}else if(c.numberElement!=null)a.delete(c.numberElement),this.observedNodes.set(c.numberElement,c);else c.numberWidth=0;DF(c,o)}else if(c={type:"code",codeElement:d,numberElement:m,codeWidth:"auto",numberWidth:0,applyColumnVariables:o},this.observedNodes.set(d,c),this.observe(d),m!=null)this.observedNodes.set(m,c),this.observe(m)}if(s>1&&!n){let l=t.querySelectorAll('[data-line-annotation*=","]'),d=new Map;for(let c of l){if(!(c instanceof HTMLElement))continue;let m=c.getAttribute("data-line-annotation")??"";if(!/^-?\d+,-?\d+$/.test(m)){console.error("DiffFileRenderer.setupResizeObserver: Invalid element or annotation",{lineAnnotation:m,element:c});continue}let p=d.get(m);if(p==null)p=[],d.set(m,p);p.push(c)}for(let[c,m]of d){if(m.length!==2){console.error("DiffFileRenderer.setupResizeObserver: Bad Pair",c,m);continue}let[p,h]=m,x=p.firstElementChild,I=h.firstElementChild;if(!(p instanceof HTMLElement)||!(h instanceof HTMLElement)||!(x instanceof HTMLElement)||!(I instanceof HTMLElement))continue;let v=a.get(x);if(v!=null){this.observedNodes.set(x,v),this.observedNodes.set(I,v),a.delete(x),a.delete(I);continue}let S=x.getBoundingClientRect().height,b=I.getBoundingClientRect().height;v={type:"annotations",column1:{container:p,child:x,childHeight:S},column2:{container:h,child:I,childHeight:b},currentHeight:"auto"},i.add({child1:x,child2:I,item:v,newHeight:Math.max(S,b)})}for(let c of i)this.applyNewHeight(c.item,c.newHeight),this.observedNodes.set(c.child1,c.item),this.observedNodes.set(c.child2,c.item),this.observe(c.child1),this.observe(c.child2);i.clear()}for(let[l,d]of a)if(this.unobserve(l),d.type==="code")HF(d);else _F(d);a.clear()}cleanUp(){for(let t of this.observedNodes.keys())this.unobserve(t);this.observedNodes.clear()}observe(t){let{managersByElement:n}=e,r=n.get(t);if(r===this)return;else 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)return;else if(i!==this)throw Error("ResizeManager.unobserve: element is owned by another ResizeManager");if(n.delete(t),r?.unobserve(t),r!=null&&n.size===0)r.disconnect(),e.resizeObserver=void 0}handleResizeEntries(t){let n=new Map,r=new Set;for(let i of t){let{target:o,borderBoxSize:s,contentBoxSize:a}=i;if(!(o instanceof HTMLElement)){console.error("ResizeManager.handleResizeEntries: Invalid element for ResizeObserver",i);continue}let l=this.observedNodes.get(o);if(l==null){console.error("ResizeManager.handleResizeEntries: Not a valid observed node",i);continue}if(l.type==="annotations"){let d=(()=>{if(o===l.column1.child)return l.column1;if(o===l.column2.child)return l.column2})();if(d==null){console.error("ResizeManager.handleResizeEntries: Couldn't find a column for",{item:l,target:o});continue}d.childHeight=s[0].blockSize,r.add(l)}else if(l.type==="code"){let d=n.get(l)??{},c=a[0].inlineSize;if(o===l.codeElement)d.codeInlineSize=c;else if(o===l.numberElement)d.numberInlineSize=c;n.set(l,d)}}this.applyAnnotationUpdates(r),r.clear(),this.applyColumnUpdates(n),n.clear()}applyAnnotationUpdates(t){for(let n of t)this.applyNewHeight(n,Math.max(n.column1.childHeight,n.column2.childHeight))}applyColumnUpdates=(t)=>{for(let[n,r]of t){let i=r.codeInlineSize!=null?FF(r.codeInlineSize):n.codeWidth,o=r.numberInlineSize!=null?NF(r.numberInlineSize):n.numberWidth,s=i!==n.codeWidth,a=o!==n.numberWidth;if(!s&&!a)continue;if(n.codeWidth=i,n.numberWidth=o,n.applyColumnVariables)aI(n,{codeWidthChanged:s,numberWidthChanged:a})}};applyNewHeight(t,n){if(n!==t.currentHeight)t.currentHeight=Math.max(n,0),t.column1.container.style.setProperty("--diffs-annotation-min-height",`${t.currentHeight}px`),t.column2.container.style.setProperty("--diffs-annotation-min-height",`${t.currentHeight}px`)}};function FF(e){let t=Math.max(Math.floor(e),0);return t===0?"auto":t}function NF(e){return Math.max(Math.ceil(e),0)}function DF(e,t){if(e.applyColumnVariables===t)return;if(e.applyColumnVariables=t,t)aI(e,{codeWidthChanged:!0,numberWidthChanged:!0});else lI(e)}function aI(e,{codeWidthChanged:t,numberWidthChanged:n}){let{codeElement:r,codeWidth:i,numberWidth:o}=e;if(t)r.style.setProperty("--diffs-column-width",`${typeof i==="number"?`${i}px`:"auto"}`);if(n)r.style.setProperty("--diffs-column-number-width",`${o===0?"auto":`${o}px`}`);if(t||n&&i!=="auto"){let s=typeof i==="number"?Math.max(i-o,0):0;r.style.setProperty("--diffs-column-content-width",`${s>0?`${s}px`:"auto"}`)}}function lI(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 HF(e){if(e.codeElement.isConnected)lI(e)}function _F(e){if(e.column1.container.isConnected)e.column1.container.style.removeProperty("--diffs-annotation-min-height");if(e.column2.container.isConnected)e.column2.container.style.removeProperty("--diffs-annotation-min-height")}function ci(e,t){if(e==null||t==null)return e===t;return e.startingLine===t.startingLine&&e.totalLines===t.totalLines&&e.bufferBefore===t.bufferBefore&&e.bufferAfter===t.bufferAfter}function Vo(e){return(e.lang??tt(e.name))==="text"}function uI(e){return Ut.hasResolvedThemes(e)}function Lu(e,t){if(e.endsWith(`\r
|
|
163
163
|
`))return t+`\r
|
|
164
164
|
`;if(e.endsWith("\r"))return t+"\r";if(e.endsWith(`
|
|
165
165
|
`))return t+`
|
|
166
|
-
`;return t}function
|
|
167
|
-
`));return e}var
|
|
168
|
-
`)}function MF(e,t,n){if(e.length===0)return"";let r=Math.min(t+n,e.length);return e.slice(t,r).join("")}function Du(e,t){return t.cacheKey==null?e.file===t&&e.sourceContents===t.contents:e.cacheKey===t.cacheKey}var OF=-1,cI=class{options;annotationSlotName;onRenderUpdate;workerManager;__id=`file-renderer:${++OF}`;highlighter;file;renderCache;pendingHighlightResult;computedLang="text";lineAnnotations={};lineCache;pendingStructuralRows;textDocumentCache=new WeakMap;editSessionActive=!1;get fileCache(){return this.renderCache?.file}constructor(e={theme:Oe},t=dn,n,r){if(this.options=e,this.annotationSlotName=t,this.onRenderUpdate=n,this.workerManager=r,r?.isWorkingPool()!==!0)this.highlighter=Qt(e.theme??Oe)?jn():void 0}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setLineAnnotations(e){this.lineAnnotations={};for(let t of e){let n=this.lineAnnotations[t.lineNumber]??[];this.lineAnnotations[t.lineNumber]=n,n.push(t)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}beginEditSession(e,t){let{editSessionActive:n,renderCache:r}=this;if(this.editSessionActive=!0,!n)this.pendingHighlightResult=void 0;if(this.file=e,r==null)return;if(n&&r.file===e)return;let{options:i}=this.getRenderOptions(e),o=r.file===e,s=t!=null&&et(r.file,t),{result:a}=r;if(!r.highlighted||a==null||!Dr(r.options,i)||!o&&!s){this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap;return}if(o)return;this.renderCache={...r,file:e,result:{...a,code:[...a.code]}};let{lineCache:l}=this;if(l!=null&&t!=null&&Du(l,t))this.lineCache={cacheKey:void 0,file:e,sourceContents:e.contents,lines:l.lines};else this.lineCache=void 0}endEditSession(e){this.editSessionActive=!1,this.pendingHighlightResult=void 0;let{renderCache:t}=this;if(e==null||t==null||t.file===e||!et(t.file,e))return;t.file=e}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0,this.file=void 0,this.endEditSession(),this.textDocumentCache=new WeakMap}clearRenderCache(){this.pendingStructuralRows=void 0,this.renderCache=void 0,this.pendingHighlightResult=void 0}hydrate(e){this.file=e;let{options:t}=this.getRenderOptions(e),n=Hu(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength()),r=this.workerManager?.getFileResultCache(e);if(r!=null&&!Dr(t,r.options))r=void 0;if(this.renderCache??={file:e,hydrated:!0,options:t,highlighted:!n&&!qo(e),result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){if(this.renderCache.result==null&&!n)this.workerManager.highlightFileAST(this,e)}else if(this.highlighter==null)this.computedLang=e.lang??tt(e.name),this.initializeHighlighter()}getLocalHighlightTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??Oe}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getFileRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let i=this.workerManager.getFileRenderOptions();if(this.editSessionActive&&i.useTokenTransformer!==!0)return{...i,useTokenTransformer:!0};return i}let{tokenizeMaxLineLength:r=1000}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:r}})(),{renderCache:n}=this;if(n?.result==null)return{options:t,forceHighlight:!0};if(!et(e,n.file)||!Dr(t,n.options))return{options:t,forceHighlight:!0};return{options:t,forceHighlight:!1}}getFileForNextRender(e){let{options:t}=this.getRenderOptions(e);if(this.getReadyRenderResult(e,t)!=null)return e;let{renderCache:n}=this;if(n==null)return e;if(et(n.file,e))return n.file;let r=Ji(e.contents),i=e.contents.length===0||qo(e)||Hu(r.length,this.getTokenizeMaxLength());return this.canRenderFile(e,t,i)?e:n.file}canRenderFile(e,t,n){let{renderCache:r}=this;if(r==null||et(r.file,e))return!0;if(n)return r.result==null&&r.hydrated!==!0||this.workerManager?.isWorkingPool()===!0||this.highlighter!=null&&Qt(t.theme);if(r.result==null&&r.hydrated!==!0)return!0;if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0)return!r.highlighted;return this.highlighter!=null&&Qt(t.theme)}getOrCreateLineCache(e){let{lineCache:t}=this;if(t==null||!Du(t,e))t={cacheKey:e.cacheKey,file:e,sourceContents:e.contents,lines:Ji(e.contents)};return this.lineCache=t,t.lines}getLineCount(e){let t=this.getOrCreateLineCache(e);return this.textDocumentCache.get(e)?.lineCount??t.length}updateRenderCache(e,t,n=!1){this.pendingStructuralRows=void 0;let{renderCache:r}=this;if(r==null)return;let{file:i,result:o}=r;if(o==null)return;let s=n?new Map:void 0;this.pendingStructuralRows=s;let a=this.lineCache!=null&&Du(this.lineCache,i)?this.lineCache:void 0;for(let[l,d]of e){if(s==null&&a!=null&&l<a.lines.length){let m=d.map((p)=>p[2]).join("");a.lines[l]=wu(a.lines[l]??"",m)}let c={type:"element",tagName:"div",properties:{"data-line":l+1,"data-line-type":"context","data-line-index":l},children:d.map(([m,p,h])=>{if(m===0&&p===""){if(h==="")return{type:"element",tagName:"br",properties:{},children:[]};return{type:"text",value:h}}return{type:"element",tagName:"span",properties:{"data-char":m,style:`color:${p};`},children:[{type:"text",value:h}]}})};if(s!=null)s.set(l,c);else o.code[l]=c}if(o.baseThemeType=t,r.isDirty=!0,s==null&&a!=null)i.contents=a.lines.join(""),a.sourceContents=i.contents}applyDocumentChange(e){let{pendingStructuralRows:t,renderCache:n}=this;if(this.pendingStructuralRows=void 0,n==null)return;let{file:r,result:i}=n;if(i==null)return;let o=this.lineCache!=null&&Du(this.lineCache,r)?this.lineCache.lines:Ji(r.contents),s=Ji(e.getText());if(o.length!==s.length){let a=Math.min(o.length,s.length),l=0;while(l<a&&o[l]===s[l])l++;let d=0;while(d<a-l&&o[o.length-1-d]===s[s.length-1-d])d++;let c=i.code;i.code=Array(s.length);for(let m=0;m<l;m++)i.code[m]=c[m];for(let m=0;m<d;m++)i.code[s.length-1-m]=c[o.length-1-m];if(t!==void 0){for(let[m,p]of t)if(m<s.length)i.code[m]=p}for(let m=l;m<s.length-d;m++)i.code[m]??={type:"element",tagName:"div",properties:{"data-line":m+1,"data-line-type":"context","data-line-index":m},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:e.getLineText(m)}]}]};for(let m=0;m<i.code.length;m++){let p=i.code[m];if(p?.type==="element")p.properties["data-line"]=m+1,p.properties["data-line-index"]=m}n.isDirty=!0}this.lineCache={cacheKey:r.cacheKey,file:r,sourceContents:r.contents,lines:s},this.textDocumentCache.set(r,e),r.contents=e.getText()}renderFile(e=this.file,t=Xo){if(this.file=e,e==null){this.pendingHighlightResult=void 0;return}let{options:n,forceHighlight:r}=this.getRenderOptions(e),i=this.getReadyRenderResult(e,n);if(this.pendingHighlightResult=void 0,i!=null)this.renderCache={...i,file:e,renderRange:void 0},r=!1;this.renderCache??={file:e,highlighted:!1,options:n,result:void 0,renderRange:void 0};let o=this.getOrCreateLineCache(e),s=e.contents.length>0,a=!s||qo(e)||Hu(o.length,this.getTokenizeMaxLength()),l=this.canRenderFile(e,n,a),d=!et(e,this.renderCache.file),c=!ci(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){let m=this.renderCache.result==null&&this.renderCache.highlighted&&!a&&!d&&Yi(t);if(l&&!m&&(a||this.renderCache.result==null||!this.renderCache.highlighted&&(d||c))){if(this.renderCache.file=e,this.renderCache.options=n,this.renderCache.highlighted=!1,this.renderCache.result==null||d||c||r)this.renderCache.result=this.workerManager.getPlainFileAST(e,t.startingLine,t.totalLines,o);this.renderCache.renderRange=t}if(!a&&s&&(!this.renderCache.highlighted||r))this.workerManager.highlightFileAST(this,e)}else{this.computedLang=e.lang??tt(e.name),this.highlighter??=jn();let m=this.highlighter!=null&&Qt(n.theme),p=this.highlighter!=null&&ni(this.computedLang),h=!a&&p;if(l&&this.highlighter!=null&&m&&(r||a||!this.renderCache.highlighted&&h||this.renderCache.result==null)){let{result:x,options:I}=this.renderFileWithHighlighter(e,this.highlighter,a||!p);this.renderCache={file:e,options:I,highlighted:h,result:x,renderRange:void 0}}if(!m||!a&&!p)this.asyncHighlight(e).then(({result:x,options:I})=>{this.applyHighlightResult(e,x,I,!a)})}return this.renderCache.result!=null?this.processFileResult(this.renderCache.file,t,this.renderCache.result):void 0}async asyncRender(e,t=Xo){this.file=e;let{result:n}=await this.asyncHighlight(e);return this.processFileResult(e,t,n)}async asyncHighlight(e){let t=Hu(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength());this.computedLang=t?"text":e.lang??tt(e.name);let n=this.highlighter!=null&&oI(On(this.getLocalHighlightTheme())),r=t||this.highlighter!=null&&ni(this.computedLang);if(this.highlighter==null||!n||!r)this.highlighter=await this.initializeHighlighter();return this.renderFileWithHighlighter(e,this.highlighter,t)}renderFileWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e);return{result:dI(e,t,r,{forcePlainText:n}),options:r}}processFileResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let o=this.getLineCount(e),{disableFileHeader:s=!1}=this.options,a=[],l=ui(),d=Math.min(t.startingLine+t.totalLines,o),c=0,m=li(t)?na(this.lineAnnotations):void 0;if(m!=null)l.children.push(en("context","annotation",1)),a.push(sa({type:"annotation",hunkIndex:-1,lineIndex:-1,annotations:m.map((p)=>this.annotationSlotName(p))})),c++;for(let p=t.startingLine;p<d;p++){let h=p+1,x=n[p];if(x==null)throw console.error("FileRenderer.processFileResult: Line doesnt exist",{name:e.name,lineIndex:p,lineNumber:h}),Error("FileRenderer.processFileResult: Line doesnt exist");l.children.push(Eu("context",h,`${p}`)),a.push(x),c++;let I=this.lineAnnotations[h];if(I!=null)l.children.push(en("context","annotation",1)),a.push(sa({type:"annotation",hunkIndex:0,lineIndex:h,annotations:I.map((v)=>this.annotationSlotName(v))})),c++}return l.properties.style=`grid-row: span ${c}`,{file:e,gutterAST:l.children??[],contentAST:a,preAST:this.createPreElement(o),headerAST:!s?this.renderHeader(e):void 0,totalLines:o,rowCount:c,themeStyles:r,baseThemeType:i,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:""}}renderHeader(e){let{headerRenderMode:t="default",stickyHeader:n=!1}=this.options;return Ru({fileOrDiff:e,mode:t,stickyHeader:n})}renderFullHTML(e){return ut(this.renderFullAST(e))}renderFullAST(e,t=[]){return t.push(K({tagName:"code",children:this.renderCodeAST(e),properties:{"data-code":""}})),{...e.preAST,children:t}}renderCodeAST(e){let t=ui();return t.children=e.gutterAST,t.properties.style=`grid-row: span ${e.rowCount}`,[t,Lu(e.contentAST,e.rowCount)]}renderPartialHTML(e,t=!1){if(!t)return ut(e);return ut(K({tagName:"code",children:e,properties:{"data-code":""}}))}async initializeHighlighter(){return this.highlighter=await sr(Pu(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(e,t,n,r=!0){if(this.editSessionActive)return;this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){let{file:i,renderCache:o}=this;if(i==null||o==null||!et(e,i)||!Dr(n,this.getRenderOptions(i).options))return;if(!(o.result==null||!o.highlighted||!Dr(o.options,n)||!et(o.file,i)))return;this.pendingHighlightResult={file:i,options:n,highlighted:r,result:t},this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getFileResultCache(e);if(n==null||!Dr(t,n.options))return;return n}getReadyRenderResult(e,t){let{pendingHighlightResult:n}=this;if(n!=null&&et(n.file,e)&&Dr(n.options,t))return n;let r=this.getMatchingWorkerResultCache(e,t);if(r==null||this.hasHighlightedRenderCache(e,t))return;return{file:e,highlighted:!0,...r}}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&et(e,n.file)&&Dr(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(e){let{disableLineNumbers:t=!1,overflow:n="scroll"}=this.options;return Au({type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:t,overflow:n,split:!1,totalLines:e})}};function Hu(e,t){return e>t}var _u=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
166
|
+
`;return t}function Hr(e,t){return Cn(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function aa(e){return K({tagName:"div",children:[K({tagName:"div",children:e.annotations?.map((t)=>K({tagName:"slot",properties:{name:t}})),properties:{"data-annotation-content":""}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function Ru(e,t){return K({tagName:"div",children:e,properties:{"data-content":"",style:`grid-row: span ${t}`}})}function dI(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 Au({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 K({tagName:"div",children:[t==="custom"?K({tagName:"slot",properties:{name:Jo}}):UF({name:e.name,prevName:"prevName"in e?e.prevName:void 0,iconType:r?.type??"file"}),...t==="custom"?[]:[BF(r)]],properties:i})}function UF({name:e,prevName:t,iconType:n}){let r=[K({tagName:"slot",properties:{name:Wo}}),Xi({name:dI(n),properties:{"data-change-icon":n}})];if(t!=null)r.push(K({tagName:"div",children:[K({tagName:"bdi",children:[un(t)]})],properties:{"data-prev-name":""}})),r.push(Xi({name:"diffs-icon-arrow-right-short",properties:{"data-rename-icon":""}}));return r.push(K({tagName:"div",children:[K({tagName:"bdi",children:[un(e)]})],properties:{"data-title":""}})),r.push(K({tagName:"slot",properties:{name:Xo}})),K({tagName:"div",children:r,properties:{"data-header-content":""}})}function BF(e){let t=[];if(e!=null){let n=0,r=0;for(let i of e.hunks)n+=i.additionLines,r+=i.deletionLines;if(r>0||n===0)t.push(K({tagName:"span",children:[un(`-${r}`)],properties:{"data-deletions-count":""}}));if(n>0||r===0)t.push(K({tagName:"span",children:[un(`+${n}`)],properties:{"data-additions-count":""}}))}return t.push(K({tagName:"slot",properties:{name:Yo}})),K({tagName:"div",children:t,properties:{"data-metadata":""}})}function Pu(e){return K({tagName:"pre",properties:GF(e)})}function GF({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:r,split:i,totalLines:o,type:s,customProperties:a}){return{...a,"data-diff":s==="diff"?"":void 0,"data-file":s==="file"?"":void 0,"data-diff-type":s==="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:${`${o}`.length}ch;`}}function $u(e,{theme:t,preferredHighlighter:n="shiki-js"}){return{langs:Array.isArray(e)?e:[e??"text"],themes:On(t),preferredHighlighter:n}}function Yi(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}function la(e,t){for(let n of t)e.push(n)}function cI(e,t,n){let r=typeof n.lineInfo==="function"?n.lineInfo(t):n.lineInfo[t-1];if(r==null){let i=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(i,{node:e,line:t,state:n}),Error(i)}if(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(un(`
|
|
167
|
+
`));return e}var Mu=Symbol("no-token"),Mf=Symbol("multiple-tokens");function Of(e){let t=jF(e);if(t!=null)return t;let n=Mu,r=[],i=[],o,s=()=>{if(i.length===0||o==null){i=[],o=void 0;return}if(i.length===1){let l=i[0];if(l?.type==="element"){qF(l,o);for(let d of l.children)Ou(d)}else Ou(l);r.push(l),i=[],o=void 0;return}for(let l of i)Ou(l);r.push(K({tagName:"span",properties:{"data-char":o},children:i})),i=[],o=void 0},a=(l)=>{if(l===Mu)return;if(l===Mf){n=Mf;return}if(n===Mu){n=l;return}if(n!==l)n=Mf};for(let l of e.children){let d=l.type==="element"?Of(l):Mu;if(a(d),typeof d!=="number"){s(),r.push(l);continue}if(o!=null&&o!==d)s();o??=d,i.push(l)}return s(),e.children=r,n}function jF(e){let t=e.properties["data-char"];if(typeof t==="number")return t}function Ou(e){if(e.type!=="element")return;e.properties["data-char"]=void 0;for(let t of e.children)Ou(t)}function qF(e,t){e.properties["data-char"]=t}var j9=Symbol("highlighted-lines");function mI(e={}){let{classPrefix:t="__shiki_",classSuffix:n="",classReplacer:r=(a)=>a}=e,i=new Map;function o(a){return Object.entries(a).map(([l,d])=>`${l}:${d}`).join(";")}function s(a){let l=typeof a==="string"?a:o(a),d=t+zF(l)+n;if(d=r(d),!i.has(d))i.set(d,typeof a==="string"?a:{...a});return d}return{name:"@shikijs/transformers:style-to-class",pre(a){if(!a.properties.style)return;let l=s(a.properties.style);delete a.properties.style,this.addClassToHast(a,l)},tokens(a){for(let l of a)for(let d of l){if(!d.htmlStyle)continue;let c=s(d.htmlStyle);if(d.htmlStyle={},d.htmlAttrs||={},!d.htmlAttrs.class)d.htmlAttrs.class=c;else d.htmlAttrs.class+=` ${c}`}},getClassRegistry(){return i},getCSS(){let a="";for(let[l,d]of i.entries())a+=`.${l}{${typeof d==="string"?d:o(d)}}`;return a},clearRegistry(){i.clear()}}}function zF(e,t=0){let n=3735928559^t,r=1103547991^t;for(let i=0,o;i<e.length;i++)o=e.charCodeAt(i),n=Math.imul(n^o,2654435761),r=Math.imul(r^o,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 Fu(e=!1,t=!1){let n={lineInfo:[]},r=[{line(i){return delete i.properties.class,i},pre(i){let o=eI(i),s=[];if(o!=null){let a=1;for(let l of o.children){if(l.type!=="element")continue;if(e)Of(l);s.push(cI(l,a,n)),a++}o.children=s}return i},...e?{tokens(i){for(let o of i){let s=0;for(let a of o){let l=a;l.__lineChar??=s,s+=a.content.length}}},preprocess(i,o){o.mergeWhitespaces="never"},span(i,o,s,a,l){if(l?.offset!=null&&l.content!=null){let d=l.__lineChar;if(d!=null)i.properties["data-char"]=d;return i}return i}}:null}];if(t)r.push(KF,fI);if(e)r.push({line:(i)=>{if(i.type==="element"&&i.children.length===0)i.children.push({type:"element",tagName:"br",properties:{},children:[]});return i}});return{state:n,transformers:r,toClass:fI}}var fI=mI({classPrefix:"hl-"}),KF={name:"token-style-normalizer",tokens(e){for(let t of e)for(let n of t){if(n.htmlStyle!=null)continue;let r={};if(n.color!=null)r.color=n.color;if(n.bgColor!=null)r["background-color"]=n.bgColor;if(n.fontStyle!=null&&n.fontStyle!==0){if((n.fontStyle&1)!==0)r["font-style"]="italic";if((n.fontStyle&2)!==0)r["font-weight"]="bold";if((n.fontStyle&4)!==0)r["text-decoration"]="underline"}if(Object.keys(r).length>0)n.htmlStyle=r}}};function jt(e){return`--${e==="token"?"diffs-token":"diffs"}-`}function Du({theme:e=Oe,highlighter:t,prefix:n}){let r="";if(typeof e==="string"){let i=t.getTheme(e),o=Nu(i);r+=`color:${o.fg};`,r+=`background-color:${o.bg};`,r+=`${jt("global")}fg:${o.fg};`,r+=`${jt("global")}bg:${o.bg};`,r+=Ff(i,n)}else{let i=t.getTheme(e.dark),o=Nu(i);r+=`${jt("global")}dark:${o.fg};`,r+=`${jt("global")}dark-bg:${o.bg};`,r+=Ff(i,"dark"),i=t.getTheme(e.light),o=Nu(i),r+=`${jt("global")}light:${o.fg};`,r+=`${jt("global")}light-bg:${o.bg};`,r+=Ff(i,"light")}return r}function Ff(e,t){t=t!=null?`${t}-`:"";let n="",r=e.colors?.["gitDecoration.addedResourceForeground"]??e.colors?.["terminal.ansiGreen"];if(r!=null)n+=`${jt("global")}${t}addition-color:${r};`;let i=e.colors?.["gitDecoration.deletedResourceForeground"]??e.colors?.["terminal.ansiRed"];if(i!=null)n+=`${jt("global")}${t}deletion-color:${i};`;let o=e.colors?.["gitDecoration.modifiedResourceForeground"]??e.colors?.["terminal.ansiBlue"];if(o!=null)n+=`${jt("global")}${t}modified-color:${o};`;return n}function ua(e){let t=e.children[0];while(t!=null){if(t.type==="element"&&t.tagName==="code")return t.children;if("children"in t)t=t.children[0];else t=null}throw console.error(e),Error("getLineNodes: Unable to find children")}var VF={forcePlainText:!1};function pI(e,t,{theme:n,tokenizeMaxLineLength:r,useTokenTransformer:i},{forcePlainText:o,startingLine:s,totalLines:a,lines:l}=VF){if(o)s??=0,a??=1/0;else s=0,a=1/0;let d=s>0||a<1/0,{state:c,transformers:m}=Fu(i),p=o?"text":e.lang??tt(e.name),h=typeof n==="string"?t.getTheme(n).type:void 0,x=Du({theme:n,highlighter:t});c.lineInfo=(b)=>({type:"context",lineIndex:b-1+s,lineNumber:b+s});let I=(()=>{if(typeof n==="string")return{lang:p,theme:n,transformers:m,defaultColor:!1,cssVariablePrefix:jt("token"),tokenizeMaxLineLength:r,tokenizeTimeLimit:0};return{lang:p,themes:n,transformers:m,defaultColor:!1,cssVariablePrefix:jt("token"),tokenizeMaxLineLength:r,tokenizeTimeLimit:0}})(),v=ua(t.codeToHast(WF(d?XF(l??Ji(e.contents),s,a):e.contents),I)),S=d?Array(s):v;if(d)la(S,v);return{code:S,themeStyles:x,baseThemeType:h}}function WF(e){return e.replace(/\r(?!\n)/g,`
|
|
168
|
+
`)}function XF(e,t,n){if(e.length===0)return"";let r=Math.min(t+n,e.length);return e.slice(t,r).join("")}function Hu(e,t){return t.cacheKey==null?e.file===t&&e.sourceContents===t.contents:e.cacheKey===t.cacheKey}var YF=-1,hI=class{options;annotationSlotName;onRenderUpdate;workerManager;__id=`file-renderer:${++YF}`;highlighter;file;renderCache;pendingHighlightResult;computedLang="text";lineAnnotations={};lineCache;pendingStructuralRows;textDocumentCache=new WeakMap;editSessionActive=!1;get fileCache(){return this.renderCache?.file}constructor(e={theme:Oe},t=dn,n,r){if(this.options=e,this.annotationSlotName=t,this.onRenderUpdate=n,this.workerManager=r,r?.isWorkingPool()!==!0)this.highlighter=Qt(e.theme??Oe)?jn():void 0}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setLineAnnotations(e){this.lineAnnotations={};for(let t of e){let n=this.lineAnnotations[t.lineNumber]??[];this.lineAnnotations[t.lineNumber]=n,n.push(t)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}beginEditSession(e,t){let{editSessionActive:n,renderCache:r}=this;if(this.editSessionActive=!0,!n)this.pendingHighlightResult=void 0;if(this.file=e,r==null)return;if(n&&r.file===e)return;let{options:i}=this.getRenderOptions(e),o=r.file===e,s=t!=null&&et(r.file,t),{result:a}=r;if(!r.highlighted||a==null||!Hr(r.options,i)||!o&&!s){this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap;return}if(o)return;this.renderCache={...r,file:e,result:{...a,code:[...a.code]}};let{lineCache:l}=this;if(l!=null&&t!=null&&Hu(l,t))this.lineCache={cacheKey:void 0,file:e,sourceContents:e.contents,lines:l.lines};else this.lineCache=void 0}endEditSession(e){this.editSessionActive=!1,this.pendingHighlightResult=void 0;let{renderCache:t}=this;if(e==null||t==null||t.file===e||!et(t.file,e))return;t.file=e}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0,this.file=void 0,this.endEditSession(),this.textDocumentCache=new WeakMap}clearRenderCache(){this.pendingStructuralRows=void 0,this.renderCache=void 0,this.pendingHighlightResult=void 0}hydrate(e){this.file=e;let{options:t}=this.getRenderOptions(e),n=_u(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength()),r=this.workerManager?.getFileResultCache(e);if(r!=null&&!Hr(t,r.options))r=void 0;if(this.renderCache??={file:e,hydrated:!0,options:t,highlighted:!n&&!Vo(e),result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){if(this.renderCache.result==null&&!n)this.workerManager.highlightFileAST(this,e)}else if(this.highlighter==null)this.computedLang=e.lang??tt(e.name),this.initializeHighlighter()}getLocalHighlightTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??Oe}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getFileRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let i=this.workerManager.getFileRenderOptions();if(this.editSessionActive&&i.useTokenTransformer!==!0)return{...i,useTokenTransformer:!0};return i}let{tokenizeMaxLineLength:r=1000}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:r}})(),{renderCache:n}=this;if(n?.result==null)return{options:t,forceHighlight:!0};if(!et(e,n.file)||!Hr(t,n.options))return{options:t,forceHighlight:!0};return{options:t,forceHighlight:!1}}getFileForNextRender(e){let{options:t}=this.getRenderOptions(e);if(this.getReadyRenderResult(e,t)!=null)return e;let{renderCache:n}=this;if(n==null)return e;if(et(n.file,e))return n.file;let r=Ji(e.contents),i=e.contents.length===0||Vo(e)||_u(r.length,this.getTokenizeMaxLength());return this.canRenderFile(e,t,i)?e:n.file}canRenderFile(e,t,n){let{renderCache:r}=this;if(r==null||et(r.file,e))return!0;if(n)return r.result==null&&r.hydrated!==!0||this.workerManager?.isWorkingPool()===!0||this.highlighter!=null&&Qt(t.theme);if(r.result==null&&r.hydrated!==!0)return!0;if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0)return!r.highlighted;return this.highlighter!=null&&Qt(t.theme)}getOrCreateLineCache(e){let{lineCache:t}=this;if(t==null||!Hu(t,e))t={cacheKey:e.cacheKey,file:e,sourceContents:e.contents,lines:Ji(e.contents)};return this.lineCache=t,t.lines}getLineCount(e){let t=this.getOrCreateLineCache(e);return this.textDocumentCache.get(e)?.lineCount??t.length}updateRenderCache(e,t,n=!1){this.pendingStructuralRows=void 0;let{renderCache:r}=this;if(r==null)return;let{file:i,result:o}=r;if(o==null)return;let s=n?new Map:void 0;this.pendingStructuralRows=s;let a=this.lineCache!=null&&Hu(this.lineCache,i)?this.lineCache:void 0;for(let[l,d]of e){if(s==null&&a!=null&&l<a.lines.length){let m=d.map((p)=>p[2]).join("");a.lines[l]=Lu(a.lines[l]??"",m)}let c={type:"element",tagName:"div",properties:{"data-line":l+1,"data-line-type":"context","data-line-index":l},children:d.map(([m,p,h])=>{if(m===0&&p===""){if(h==="")return{type:"element",tagName:"br",properties:{},children:[]};return{type:"text",value:h}}return{type:"element",tagName:"span",properties:{"data-char":m,style:`color:${p};`},children:[{type:"text",value:h}]}})};if(s!=null)s.set(l,c);else o.code[l]=c}if(o.baseThemeType=t,r.isDirty=!0,s==null&&a!=null)i.contents=a.lines.join(""),a.sourceContents=i.contents}applyDocumentChange(e){let{pendingStructuralRows:t,renderCache:n}=this;if(this.pendingStructuralRows=void 0,n==null)return;let{file:r,result:i}=n;if(i==null)return;let o=this.lineCache!=null&&Hu(this.lineCache,r)?this.lineCache.lines:Ji(r.contents),s=Ji(e.getText());if(o.length!==s.length){let a=Math.min(o.length,s.length),l=0;while(l<a&&o[l]===s[l])l++;let d=0;while(d<a-l&&o[o.length-1-d]===s[s.length-1-d])d++;let c=i.code;i.code=Array(s.length);for(let m=0;m<l;m++)i.code[m]=c[m];for(let m=0;m<d;m++)i.code[s.length-1-m]=c[o.length-1-m];if(t!==void 0){for(let[m,p]of t)if(m<s.length)i.code[m]=p}for(let m=l;m<s.length-d;m++)i.code[m]??={type:"element",tagName:"div",properties:{"data-line":m+1,"data-line-type":"context","data-line-index":m},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:e.getLineText(m)}]}]};for(let m=0;m<i.code.length;m++){let p=i.code[m];if(p?.type==="element")p.properties["data-line"]=m+1,p.properties["data-line-index"]=m}n.isDirty=!0}this.lineCache={cacheKey:r.cacheKey,file:r,sourceContents:r.contents,lines:s},this.textDocumentCache.set(r,e),r.contents=e.getText()}renderFile(e=this.file,t=Zo){if(this.file=e,e==null){this.pendingHighlightResult=void 0;return}let{options:n,forceHighlight:r}=this.getRenderOptions(e),i=this.getReadyRenderResult(e,n);if(this.pendingHighlightResult=void 0,i!=null)this.renderCache={...i,file:e,renderRange:void 0},r=!1;this.renderCache??={file:e,highlighted:!1,options:n,result:void 0,renderRange:void 0};let o=this.getOrCreateLineCache(e),s=e.contents.length>0,a=!s||Vo(e)||_u(o.length,this.getTokenizeMaxLength()),l=this.canRenderFile(e,n,a),d=!et(e,this.renderCache.file),c=!ci(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){let m=this.renderCache.result==null&&this.renderCache.highlighted&&!a&&!d&&Yi(t);if(l&&!m&&(a||this.renderCache.result==null||!this.renderCache.highlighted&&(d||c))){if(this.renderCache.file=e,this.renderCache.options=n,this.renderCache.highlighted=!1,this.renderCache.result==null||d||c||r)this.renderCache.result=this.workerManager.getPlainFileAST(e,t.startingLine,t.totalLines,o);this.renderCache.renderRange=t}if(!a&&s&&(!this.renderCache.highlighted||r))this.workerManager.highlightFileAST(this,e)}else{this.computedLang=e.lang??tt(e.name),this.highlighter??=jn();let m=this.highlighter!=null&&Qt(n.theme),p=this.highlighter!=null&&ni(this.computedLang),h=!a&&p;if(l&&this.highlighter!=null&&m&&(r||a||!this.renderCache.highlighted&&h||this.renderCache.result==null)){let{result:x,options:I}=this.renderFileWithHighlighter(e,this.highlighter,a||!p);this.renderCache={file:e,options:I,highlighted:h,result:x,renderRange:void 0}}if(!m||!a&&!p)this.asyncHighlight(e).then(({result:x,options:I})=>{this.applyHighlightResult(e,x,I,!a)})}return this.renderCache.result!=null?this.processFileResult(this.renderCache.file,t,this.renderCache.result):void 0}async asyncRender(e,t=Zo){this.file=e;let{result:n}=await this.asyncHighlight(e);return this.processFileResult(e,t,n)}async asyncHighlight(e){let t=_u(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength());this.computedLang=t?"text":e.lang??tt(e.name);let n=this.highlighter!=null&&uI(On(this.getLocalHighlightTheme())),r=t||this.highlighter!=null&&ni(this.computedLang);if(this.highlighter==null||!n||!r)this.highlighter=await this.initializeHighlighter();return this.renderFileWithHighlighter(e,this.highlighter,t)}renderFileWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e);return{result:pI(e,t,r,{forcePlainText:n}),options:r}}processFileResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let o=this.getLineCount(e),{disableFileHeader:s=!1}=this.options,a=[],l=ui(),d=Math.min(t.startingLine+t.totalLines,o),c=0,m=li(t)?ra(this.lineAnnotations):void 0;if(m!=null)l.children.push(en("context","annotation",1)),a.push(aa({type:"annotation",hunkIndex:-1,lineIndex:-1,annotations:m.map((p)=>this.annotationSlotName(p))})),c++;for(let p=t.startingLine;p<d;p++){let h=p+1,x=n[p];if(x==null)throw console.error("FileRenderer.processFileResult: Line doesnt exist",{name:e.name,lineIndex:p,lineNumber:h}),Error("FileRenderer.processFileResult: Line doesnt exist");l.children.push(vu("context",h,`${p}`)),a.push(x),c++;let I=this.lineAnnotations[h];if(I!=null)l.children.push(en("context","annotation",1)),a.push(aa({type:"annotation",hunkIndex:0,lineIndex:h,annotations:I.map((v)=>this.annotationSlotName(v))})),c++}return l.properties.style=`grid-row: span ${c}`,{file:e,gutterAST:l.children??[],contentAST:a,preAST:this.createPreElement(o),headerAST:!s?this.renderHeader(e):void 0,totalLines:o,rowCount:c,themeStyles:r,baseThemeType:i,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:""}}renderHeader(e){let{headerRenderMode:t="default",stickyHeader:n=!1}=this.options;return Au({fileOrDiff:e,mode:t,stickyHeader:n})}renderFullHTML(e){return ut(this.renderFullAST(e))}renderFullAST(e,t=[]){return t.push(K({tagName:"code",children:this.renderCodeAST(e),properties:{"data-code":""}})),{...e.preAST,children:t}}renderCodeAST(e){let t=ui();return t.children=e.gutterAST,t.properties.style=`grid-row: span ${e.rowCount}`,[t,Ru(e.contentAST,e.rowCount)]}renderPartialHTML(e,t=!1){if(!t)return ut(e);return ut(K({tagName:"code",children:e,properties:{"data-code":""}}))}async initializeHighlighter(){return this.highlighter=await sr($u(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(e,t,n,r=!0){if(this.editSessionActive)return;this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){let{file:i,renderCache:o}=this;if(i==null||o==null||!et(e,i)||!Hr(n,this.getRenderOptions(i).options))return;if(!(o.result==null||!o.highlighted||!Hr(o.options,n)||!et(o.file,i)))return;this.pendingHighlightResult={file:i,options:n,highlighted:r,result:t},this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getFileResultCache(e);if(n==null||!Hr(t,n.options))return;return n}getReadyRenderResult(e,t){let{pendingHighlightResult:n}=this;if(n!=null&&et(n.file,e)&&Hr(n.options,t))return n;let r=this.getMatchingWorkerResultCache(e,t);if(r==null||this.hasHighlightedRenderCache(e,t))return;return{file:e,highlighted:!0,...r}}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&et(e,n.file)&&Hr(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(e){let{disableLineNumbers:t=!1,overflow:n="scroll"}=this.options;return Pu({type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:t,overflow:n,split:!1,totalLines:e})}};function _u(e,t){return e>t}var Uu=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
169
169
|
<symbol id="diffs-icon-arrow-right-short" viewBox="0 0 16 16">
|
|
170
170
|
<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"/>
|
|
171
171
|
</symbol>
|
|
@@ -217,7 +217,7 @@ ${t}`,r=e.startsWith(t)?0:Rx(e,n,0);if(r===-1)return[e];let i=[];if(r>0)i.push(e
|
|
|
217
217
|
<symbol id="diffs-icon-symbol-ref" viewBox="0 0 16 16">
|
|
218
218
|
<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"/>
|
|
219
219
|
</symbol>
|
|
220
|
-
</svg>`;function
|
|
220
|
+
</svg>`;function gI(e,t){return e.lineNumber===t.lineNumber&&e.metadata===t.metadata}function Bu(e,t){if(e==null||t==null)return e===t;return JF(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 yI={};function JF(e=yI,t=yI){if(e===t)return!0;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(e[i]!==t[i])return!1;return!0}function Gu(e){let t=document.createElement("div");return t.dataset.annotationSlot="",t.slot=e,t.style.whiteSpace="normal",t}function ju(){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 qu(){let e=document.createElement("style");return e.setAttribute(xI,""),e}var zu;function mi(e){if(zu!=null)return zu;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(II,"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),zu=Math.max(n.offsetHeight-n.clientHeight,0),n.remove(),zu}function Nf(e){let t=e==null?"var(--diffs-scrollbar-gutter-fallback)":`${e}px`;return`${Ku}: ${t};`}var Df=`@layer base {
|
|
221
221
|
:host {
|
|
222
222
|
--diffs-font-fallback: "SF Mono", Monaco, Consolas, "Ubuntu Mono", "Liberation Mono",
|
|
223
223
|
"Courier New", monospace;
|
|
@@ -1495,38 +1495,38 @@ ${t}`,r=e.startsWith(t)?0:Rx(e,n,0);if(r===-1)return[e];let i=[];if(r>0)i.push(e
|
|
|
1495
1495
|
}
|
|
1496
1496
|
|
|
1497
1497
|
@layer theme, rendered, unsafe;
|
|
1498
|
-
`;var
|
|
1498
|
+
`;var SI="@layer base, theme, rendered, unsafe;",ZF=new RegExp(`${QF(Ku)}\\s*:\\s*[^;]+;`);function Vu(e){return`${SI}
|
|
1499
1499
|
@layer unsafe {
|
|
1500
1500
|
${e}
|
|
1501
|
-
}`}function
|
|
1502
|
-
color-scheme: ${t};`,i=Nf(n);return`${
|
|
1501
|
+
}`}function Wu(e,t="system",n){let r=t==="system"?"":`
|
|
1502
|
+
color-scheme: ${t};`,i=Nf(n);return`${SI}
|
|
1503
1503
|
@layer rendered {
|
|
1504
1504
|
:host {${r}
|
|
1505
1505
|
${i}
|
|
1506
1506
|
${e}
|
|
1507
1507
|
}
|
|
1508
|
-
}`}function Wu(e,t){let n=Nf(t);return e.replace(NF,n)}function DF(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yo(e,t,n){let r=new Map;for(let i of e){let o=Xu(i);r.set(o,n?.slotNames.get(o)??t(i))}return{provided:e,current:e,slotNames:r}}function Yu(e,t,n){for(let r of t){let i=Xu(r);if(!e.slotNames.has(i))e.slotNames.set(i,n(r))}e.provided=t,e.current=t}function Ju(e,t,n){if(e==null)return n(t);let r=Xu(t),i=e.slotNames.get(r);if(i==null)i=n(t),e.slotNames.set(r,i);return i}function Zu(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function Df(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,themeType:e?.themeType,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:Zu(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,unsafeCSS:e?.unsafeCSS,headerRenderMode:e?.renderCustomHeader!=null?"custom":"default"}}function Jo({code:e,pre:t,columnType:n,rowSpan:r,containerSize:i=!1}={}){if(e==null){if(e=document.createElement("code"),e.setAttribute("data-code",""),n!=null)e.setAttribute(`data-${n}`,"");t?.appendChild(e)}if(r!=null)e.style.setProperty("grid-row",`span ${r}`);else e.style.removeProperty("grid-row");if(i)e.setAttribute("data-container-size","");else e.removeAttribute("data-container-size");return e}function ua(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 Qu({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===""){t?.remove();return}if(t??=HF(),t.textContent=n,t.parentNode!==e)e.appendChild(t);return t}function HF(){let e=document.createElement("style");return e.setAttribute(xI,""),e}function ed(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:"open"});if(n.innerHTML==="")n.innerHTML=t}function td(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:o,split:s,totalLines:a,customProperties:l}){if(l!=null)for(let d in l){let c=l[d];if(c!=null)e.setAttribute(d,`${c}`)}if(t==="diff")e.setAttribute("data-diff",""),e.removeAttribute("data-file");else e.setAttribute("data-file",""),e.removeAttribute("data-diff");switch(n){case"bars":case"classic":e.setAttribute("data-indicators",n);break;case"none":e.removeAttribute("data-indicators")}if(i)e.setAttribute("data-disable-line-numbers","");else e.removeAttribute("data-disable-line-numbers");if(r)e.removeAttribute("data-background");else e.setAttribute("data-background","");if(t==="diff")e.setAttribute("data-diff-type",s?"split":"single");else e.removeAttribute("data-diff-type");return e.setAttribute("data-overflow",o),e.style.setProperty("--diffs-min-number-column-width-default",`${`${a}`.length}ch`),e}if(typeof HTMLElement<"u"&&customElements.get("diffs-container")==null){let e;class t extends HTMLElement{constructor(){super();if(this.shadowRoot!=null)return;let n=this.attachShadow({mode:"open"});if(e==null)e=new CSSStyleSheet,e.replaceSync(gI);n.adoptedStyleSheets=[e]}connectedCallback(){let n=this.shadowRoot??this.attachShadow({mode:"open"});mi(n)}}customElements.define(nd,t)}var _F=[""];function UF(e){let t={...e};return delete t.cacheKey,t}var BF=-1,Hf=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++BF}`;type="file";fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;editSession;renderedFile;renderRange;enabled=!0;editor;constructor(e={theme:Oe},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new cI(e,this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager),this.resizeManager=new ku,this.interactionManager=new Tu("file",jo(e)),this.workerManager?.subscribeToThemeChanges(this)}getAnnotationSlotName=(e)=>Ju(this.editSession?.annotations,e,dn);handleHighlightRender=()=>{this.rerender()};rerender(){if(!this.enabled||this.file==null)return;this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}getTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??Oe}getLatestFile(e=this.file){return this.editSession?.file??e}getRenderedFile(){return this.renderedFile}getLatestAnnotations(){return this.editSession?.annotations?.current??this.lineAnnotations}isNewAnnotations(e){let t=this.editSession?.annotations;if(e===this.lineAnnotations)return!1;return t==null||e!==t.provided&&e!==t.current}updateExternalFile(e,t){if(et(this.file,e))return!1;let n=this.editSession!=null;if(this.file=e,n||this.editor!=null)this.installEditSession(e,n?void 0:this.editor?.__getDocumentContents(e),!0);else this.editSession=void 0;if(this.editSession?.annotations!=null&&t!=null)this.lineAnnotations=t,this.editSession.annotations=Yo(t,dn,this.editSession.annotations);return!0}installEditSession(e,t,n=!1){let r=t==null||t.name===e.name&&t.lang===e.lang&&t.contents===e.contents,i=UF(t??e);this.editSession={file:i,externalReplacement:n&&r,annotations:this.editSession?.annotations??Yo(this.lineAnnotations,dn)},this.fileRenderer.beginEditSession(i,r?e:void 0)}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){if(e==null)return;this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions()}syncInteractionOptions(){this.interactionManager.setOptions(jo(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){if((this.options.themeType??"system")===e)return;this.mergeOptions({themeType:e}),this.applyCachedThemeState(e)}applyCachedThemeState(e){if(typeof this.options.theme==="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;if(this.appliedThemeCSS.themeType===t)return!1;return this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Cn(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){let t=this.editSession?.annotations;if(t==null){this.lineAnnotations=e;return}if(!this.isNewAnnotations(e))return;this.lineAnnotations=e,Yu(t,e,dn)}syncEditSessionAnnotationsFromEditor(e){let t=this.editSession?.annotations;if(t==null||e===t.current)return!1;return t.current=e,this.fileRenderer.setLineAnnotations(e),this.renderAnnotations(),!0}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??"additions"})}getCodeScrollLeft(){return this.code?.scrollLeft??0}setCodeScrollLeft(e){if(this.code!=null)this.code.scrollLeft=e}__getEffectiveCodeOptions(){return{...this.options,...this.fileRenderer.getEffectiveCodeOptions()}}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e==="wrap",columnVariables:this.shouldApplyColumnVariables(e)?"apply":"measure"}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e==="scroll"&&this.getLatestAnnotations().length>0}cleanUp(e=!1){let t=this.editor;if(this.emitPostRender(!0),t?.cleanUp(e?"recycle":"discard"),!e)this.editor=void 0;if(this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,!this.isContainerManaged)this.fileContainer?.remove();if(this.fileContainer=void 0,this.mounted=!1,!e)this.lineAnnotations=[];if(this.clearAuxiliaryNodes(),this.pre=void 0,this.code=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,!e)this.cachedHeaderHTML=void 0;if(this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,e)this.fileRenderer.recycle();else this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0,this.editSession=void 0,this.renderedFile=void 0;this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:i,lineAnnotations:o}=e;if(!this.enabled)throw Error("File.hydrate: attempting to call hydrate after cleaned up");if(this.fileContainer!=null)throw Error("File.hydrate: hydrate can only be called before the instance has rendered or hydrated");this.hydrateElements(t,n);let s=this.editor!=null;if(s||GF(this.pre,i,this.options.collapsed)||jF(this.headerElement,i,this.options.disableFileHeader))this.render({...e,forceRender:s||e.forceRender,preventEmit:!0});else this.hydrationSetup({file:i,lineAnnotations:o});if(!r)this.emitPostRender()}hydrateElements(e,t){if(this.fileContainer!==e)this.emitPostRender(!0);ed(e,t);for(let n of Array.from(e.shadowRoot?.children??[])){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(!(n instanceof HTMLElement))continue;if(n instanceof HTMLPreElement){this.pre=n,this.appliedPreAttributes=void 0;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}if("diffsHeader"in n.dataset){this.headerElement=n,this.lastRenderedHeaderHTML=void 0;continue}}if(this.pre!=null)this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute("data-dehydrated");this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){if(this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(Df(this.options)),this.syncInteractionOptions(),this.pre==null)return;this.fileRenderer.hydrate(e),this.renderedFile=e,this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers()}getOrCreateLineCache(e=this.getLatestFile()){return e!=null?this.fileRenderer.getOrCreateLineCache(e):_F}updateBuffers(e){if(this.pre!=null)this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){let{editor:e,fileContainer:t,renderRange:n}=this,r=this.getLatestAnnotations(),i=this.getLatestFile();if(e==null||t==null||i==null)return;let o=(d)=>{if(!this.enabled||this.editor!==e||this.fileContainer!==t||this.getLatestFile()!==i)return;e.__syncRenderView({highlighter:d,fileContainer:t,file:i,lineAnnotations:r,renderRange:n,externalDocument:this.editSession?.externalReplacement===!0})},s=this.getTheme(),a=i.lang??tt(i.name),l=jn({theme:s,lang:a});if(l!=null)o(l);else sr({themes:On(s),langs:Array.from(new Set(["text",a])),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter}).then(o)}__acknowledgeDocumentUpdate(){if(this.editSession!=null)this.editSession.externalReplacement=!1}__acceptEditorChange(e){let{lineAnnotations:t}=e;if(t!=null)this.syncEditSessionAnnotationsFromEditor(t)}emitEditChange(e){let{onEditChange:t}=this.options;t?.(e)}__captureDocumentSessionState(){}__attachEditor(e){if(this.editor!=null)throw Error("File.__attachEditor: an editor is already attached");this.editor=e;let t=()=>{this.editor=void 0,this.fileRenderer.endEditSession()};try{return this.resumeEditorRendering(e),t}catch(n){throw t(),n}}__resumeEditor(e){if(this.editor!==e)throw Error("File.__resumeEditor: editor association changed");this.resumeEditorRendering(e)}resumeEditorRendering(e){if(this.editSession!=null)this.fileRenderer.beginEditSession(this.editSession.file);else if(this.file!=null)this.installEditSession(this.file,e.__getDocumentContents(this.file));let t=this.editSession?.file;if(this.fileRenderer.editorRenderReady()){if(this.fileRenderer.fileCache===t)this.renderedFile=t;this.syncRenderViewToEditor()}else this.rerender()}__completeEditSession(e,t){this.settleEditSession(t==="install",e)}settleEditSession(e,t){let{editSession:n,file:r,lineAnnotations:i}=this;if(n==null||r==null)return;let{file:o,annotations:s}=n;if(this.editor!=null)throw Error("File.__completeEditSession: detach the editor before completing the session");let a=s?.current,l,d=!1,c;if(t==null)throw Error("File.__completeEditSession: editor is required for completion");let m={...o},p={file:m,editor:t,originalFile:r,lineAnnotations:a,originalLineAnnotations:i};Object.freeze(p);try{if(t.__emitEditComplete(p),this.options.onEditComplete?.(p)==="accept"){if(m.cacheKey!=null&&m.cacheKey===r.cacheKey)throw Error("File.__completeEditSession: an accepted file must not reuse the replaced file cacheKey");l=m}}catch(I){d=!0,c=I}if(e&&l!=null){if(this.file=l,a!=null)this.lineAnnotations=a}this.editSession=void 0;let{renderedFile:h,file:x}=this;if(this.fileRenderer.endEditSession(x),h!=null&&x!=null&&h!==x&&et(h,x))this.renderedFile=x;if(e&&this.fileContainer!=null)this.rerender();if(d)throw c}applyDocumentChange(e,t){let n=this.editSession?.file;if(n==null)throw Error("File.applyDocumentChange: requires an active edit session");if(this.fileRenderer.beginEditSession(n),this.fileRenderer.applyDocumentChange(e),t!=null)this.syncEditSessionAnnotationsFromEditor(t)}updateRenderCache(e,t,n){let r=this.editSession?.file;if(r==null)throw Error("File.updateRenderCache: requires an active edit session");this.fileRenderer.beginEditSession(r),this.fileRenderer.updateRenderCache(e,t,n?.lineCountChangeInFlight)}render({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:i,deferManagers:o=!1,lineAnnotations:s,renderRange:a}){if(!this.enabled)throw Error("File.render: attempting to call render after cleaned up");this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:l=!1,themeType:d="system"}=this.options,c=l?void 0:a,m=this.renderRange,p=this.hasThemeChanged(),h=s!=null&&(s.length>0||this.getLatestAnnotations().length>0)?this.isNewAnnotations(s):!1,x=!et(this.file,e);if(x)this.updateExternalFile(e,s);let I=this.getLatestFile(e)??e;if(!l&&!n&&ci(c,this.renderRange)&&!x&&!h&&!p){let b=this.applyCachedThemeState(d);if(b)this.finalizeRender();return b}if(this.renderRange=c,x)this.cachedHeaderHTML=void 0;if(this.fileRenderer.setOptions(Df(this.options)),this.syncInteractionOptions(),s!=null)this.setLineAnnotations(s);this.fileRenderer.setLineAnnotations(this.getLatestAnnotations());let{disableErrorHandling:v=!1,disableFileHeader:S=!1}=this.options;if(S){if(this.headerElement!=null)this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0;this.clearHeaderSlots()}if(t=this.getOrCreateFileContainerNode(t,i),this.applyCachedThemeState(d),l){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let b=this.fileRenderer.renderFile(I,rd);if(b!=null)this.applyThemeState(t,b.themeStyles,d,b.baseThemeType);if(b?.headerAST!=null)this.applyHeaderToDOM(b.headerAST,t,b.file);this.renderedFile=b?.file??I,this.injectUnsafeCSS()}catch(b){if(v)throw b;if(console.error(b),b instanceof Error)this.applyErrorToDOM(b,t)}if(this.finalizeRender(),!r)this.emitPostRender();return!0}try{let b=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,h,x||p||!et(this.renderedFile,I))||!this.applyPartialRender(I,m,c)){let E=this.fileRenderer.renderFile(I,c);if(E==null){if(this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool())this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender());return!1}if(this.applyThemeState(t,E.themeStyles,d,E.baseThemeType),E.headerAST!=null)this.applyHeaderToDOM(E.headerAST,t,E.file);this.applyFullRender(E,b),this.renderedFile=E.file}if(this.applyBuffers(b,c),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,!o)this.flushManagers();if(this.finalizeRender(),this.editor!=null)this.syncRenderViewToEditor()}catch(b){if(v)throw b;if(console.error(b),b instanceof Error)this.applyErrorToDOM(b,t)}if(!r)this.emitPostRender();return!0}finalizeRender(){}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted)return;if(this.mounted=!1,t==null)return;n?.(t,this,"unmount");return}if(t==null)return;let r=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){if(e||t||n)return!1;return!0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}async primeHighlightCache(e=this.file){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||qo(e))return;let n=this.options.tokenizeMaxLength??1e5;if(this.fileRenderer.getOrCreateLineCache(e).length>n)return;await t.primeFileHighlightCache(e).catch((r)=>{console.error(r)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:r}of this.annotationCache.values())r.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options,n=this.getLatestAnnotations();if(t!=null&&n.length>0)for(let[r,i]of n.entries()){let o=this.getAnnotationSlotName(i),s=`${r}-${o}`,a=this.annotationCache.get(s);if(a==null||!mI(i,a.annotation)){a?.element.remove();let l=t(i);if(l==null)continue;a={element:Bu(o),annotation:i},a.element.appendChild(l),this.fileContainer.appendChild(a.element),this.annotationCache.set(s,a)}e.delete(s)}for(let[r,{element:i}]of e.entries())this.annotationCache.delete(r),i.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;else if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=Gu();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t==null)return;if(e==null||e===""){if(this.unsafeCSSStyle!=null)this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0;this.appliedUnsafeCSS=void 0;return}if(this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e)return;if(this.unsafeCSSStyle??=ju(),this.unsafeCSSStyle.parentNode!==t)t.appendChild(this.unsafeCSSStyle);this.unsafeCSSStyle.textContent=Ku(e),this.appliedUnsafeCSS=e}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:"open"}),o=r??n,s=this.getTheme(),a=typeof s==="string"?s:{...s},l=mi(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===o&&this.appliedThemeCSS.scrollbarGutter===l){this.appliedThemeCSS.theme=a;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:a,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:l};return}this.themeCSSStyle=Qu({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:Vu(t,o,l)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:a,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:l}:void 0}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;if(e==null||this.themeCSSStyle==null)return;this.themeCSSStyle.textContent=Wu(this.themeCSSStyle.textContent??"",mi(e))}shouldGuardRebuildScroll(){return this.editor!=null&&id()}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);let n=this.code=Jo({code:this.code}),r=this.fileRenderer.renderCodeAST(e);this.editor?.__captureFocusForDOMReplacement();let i=()=>{if(n.childElementCount>=2)for(let o=0;o<2;o++){let s=n.children[o],a=r[o];s.innerHTML=ut(a.children),s.style.cssText=a.properties.style}else n.innerHTML=ut(r);if(!t.contains(n))t.replaceChildren(n)};if(this.shouldGuardRebuildScroll())ua(t,i);else i();this.lastRowCount=e.rowCount}applyPartialRender(e,t,n){if(t==null||n==null)return!1;let{code:r}=this,i=r!=null?this.getColumns(r):void 0;if(r==null||i==null)return!1;let o=t.startingLine,s=n.startingLine,a=t.totalLines===1/0?Number.POSITIVE_INFINITY:o+t.totalLines,l=n.totalLines===1/0?Number.POSITIVE_INFINITY:s+n.totalLines,d=Math.max(o,s),c=Math.min(a,l);if(c<=d)return!1;if(!this.trimDOMToOverlap(i.gutter,d,c)||!this.trimDOMToOverlap(i.content,d,c))throw Error("File.applyPartialRender: failed to trim to overlap");let{length:m}=i.content.children,p=(v,S)=>{if(S<=0)return;return this.fileRenderer.renderFile(e,{startingLine:v,totalLines:S,bufferBefore:0,bufferAfter:0})},h=s<d?p(s,d-s):void 0;if(h===void 0&&s<d)return!1;let x=l===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(0,l-c),I=l>c?p(c,x):void 0;if(I===void 0&&l>c)return!1;if(this.cleanupErrorWrapper(),h!=null)i.gutter.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(h.gutterAST)),i.content.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(h.contentAST)),m+=h.rowCount;if(I!=null)i.gutter.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(I.gutterAST)),i.content.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(I.contentAST)),m+=I.rowCount;if(this.lastRowCount!==m)i.gutter.style.setProperty("grid-row",`span ${m}`),i.content.style.setProperty("grid-row",`span ${m}`),this.lastRowCount=m;return!0}getColumns(e){let t=e.children[0],n=e.children[1];if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null)return;return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){let r=this.getDOMBoundaryIndices(e,[t,n]),i=r.get(t)??e.children.length,o=r.get(n)??e.children.length;if(i>o)return!1;for(let s=e.children.length-1;s>=o;s-=1)e.children[s]?.remove();for(let s=i-1;s>=0;s-=1)e.children[s]?.remove();return!0}getDOMBoundaryIndices(e,t){let n=[...new Set(t)].sort((a,l)=>a-l),r=new Map;if(n.length===0)return r;let i=0,o=n[i],{children:s}=e;if(o===0)r.set(0,0),i+=1,o=n[i];for(let a=0;a<s.length;a+=1){let l=s[a];if(!(l instanceof HTMLElement))continue;let d=this.getLineIndexFromDOMNode(l);if(d==null)continue;while(o!=null&&d>=o)r.set(o,a),i+=1,o=n[i];if(i>=n.length)break}for(let a of n)if(!r.has(a))r.set(a,s.length);return r}getLineIndexFromDOMNode(e){let t=e.dataset.lineIndex;if(t==null)return;let n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){if(this.bufferBefore!=null)this.bufferBefore.remove(),this.bufferBefore=void 0;if(this.bufferAfter!=null)this.bufferAfter.remove(),this.bufferAfter=void 0;return}if(t.bufferBefore>0){if(this.bufferBefore==null)this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore);this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")}else if(this.bufferBefore!=null)this.bufferBefore.remove(),this.bufferBefore=void 0;if(t.bufferAfter>0){if(this.bufferAfter==null)this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter);this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")}else if(this.bufferAfter!=null)this.bufferAfter.remove(),this.bufferAfter=void 0}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t,n){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let r=this.cachedHeaderHTML??ut(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let l=document.createElement("div");l.innerHTML=r;let d=l.firstElementChild;if(!(d instanceof HTMLElement))return;if(this.headerElement!=null)t.shadowRoot?.replaceChild(d,this.headerElement);else t.shadowRoot?.prepend(d);this.headerElement=d,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;let{renderHeaderPrefix:i,renderHeaderFilenameSuffix:o,renderCustomHeader:s,renderHeaderMetadata:a}=this.options;if(s!=null){let l=s(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Wo,l),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{let l=i?.(n)??void 0,d=o?.(n)??void 0,c=a?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,zo,l),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Ko,d),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,Vo,c),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);if(t==null)e.appendChild(i);return this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){if(e.replaceChildren(),t instanceof Element)e.appendChild(t);else e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement("div");return t.slot=e,t}getOrCreateFileContainerNode(e,t){let{fileContainer:n}=this,r=e??n??document.createElement("diffs-container"),i=n!==r;if(n!=null&&i)this.editor?.__captureFocusForDOMReplacement();if(i)this.emitPostRender(!0);if(this.fileContainer=r,n!=null&&i)this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0;if(t!=null&&this.fileContainer.parentNode!==t)t.appendChild(this.fileContainer);if(i)this.adoptReusableShellElements(this.fileContainer);return this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t==null)return;for(let n of t.children)if(n instanceof SVGElement)this.spriteSVG??=n;else if(ai(n)&&n.hasAttribute("data-theme-css"))this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0;else if(ai(n)&&n.hasAttribute("data-unsafe-css"))this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){let n=document.createElement("div");n.innerHTML=_u;let r=n.firstChild;if(r instanceof SVGElement)this.spriteSVG=r}if(this.spriteSVG!=null&&this.spriteSVG.parentNode!==t)t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.pre==null)this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre);else if(this.pre.parentNode!==t)this.editor?.__captureFocusForDOMReplacement(),e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0;return this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;if(t.hasAttribute("data-code")){this.code=t;return}}}applyPreNodeAttributes(e,{totalLines:t}){let{overflow:n="scroll",disableLineNumbers:r=!1}=this.options,i={type:"file",split:!1,overflow:n,disableLineNumbers:r,diffIndicators:"none",disableBackground:!0,totalLines:t};if(Uu(i,this.appliedPreAttributes))return;td(e,i),this.appliedPreAttributes=i}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);let r=document.createElement("div");r.dataset.errorMessage="",r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement("pre");i.dataset.errorStack="",i.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function GF(e,t,n=!1){return!n&&e==null&&t!=null}function jF(e,t,n=!1){return e==null&&t!=null&&!n}var qF=5000,od=new Map,zF=-1;function KF(e,t){return(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS}var II=class extends Hf{virtualizer;metrics;__id=`virtualized-file:${++zF}`;renderType="virtualized";top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0,ghostTextRows:od};pendingRender;isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n=bu,r,i=!1){super(e,r,i);this.virtualizer=t,this.metrics=n}setMetrics(e,t=!1){let n=Bo(e);if(!t&&ar(this.metrics,n))return;this.metrics=n,this.resetLayoutCache()}setLineAnnotations(e){if(this.syncLineAnnotations(e))this.resetLayoutCache()}syncLineAnnotations(e){if(e==null||!this.isNewAnnotations(e))return!1;if(e.length===0&&this.getLatestAnnotations().length===0)return!1;return super.setLineAnnotations(e),!0}syncEditSessionAnnotationsFromEditor(e){if(super.syncEditSessionAnnotationsFromEditor(e))return this.resetLayoutCache(),!0;return!1}hasLineAnnotations(){return this.getLatestAnnotations().some((e)=>e.lineNumber>0)}hasUniformLineHeights(){let{overflow:e="scroll"}=this.options;return e==="scroll"&&!this.hasLineAnnotations()&&this.cache.heights.size===0}getLineHeight(e,t=!1){let n=this.cache.heights.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(this.isAdvancedMode())throw Error("VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(e==null)return;let{options:t}=this,n=!_o(t,e),r=KF(t,e);if(super.setOptions(e),r)this.resetLayoutCache(!0);if(n)this.forceRenderOverride=!0;if(n)this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error("VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(e)}resetLayoutCache(e=!1,t=!0){if(this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0)this.cache.heights.clear();if(this.cache.checkpoints.length>0)this.cache.checkpoints.length=0;if(this.cache.ghostTextRows=od,this.renderRange!=null&&t)this.renderRange=void 0;if(e&&this.isSimpleMode())this.computeApproximateSize()}applyGhostTextRows(e){let{heights:t,ghostTextRows:n}=this.cache;if(n===e)return!1;let{lineHeight:r}=this.metrics,i=!1;for(let o of new Set([...n.keys(),...e.keys()])){let s=n.get(o)??0,a=e.get(o)??0;if(a===s)continue;let l=(t.get(o)??r)-s*r+a*r;if(l===r)t.delete(o);else t.set(o,l);i=!0}return this.cache.ghostTextRows=e,i}reconcileHeights(){let e=!1;if(this.fileContainer==null||this.getLayoutFile()==null){if(this.height!==0)e=!0;return this.height=0,e}let{overflow:t="scroll"}=this.options;this.top=this.getVirtualizedTop();let n=this.editor?.__getGhostTextRows()??od;if(e=this.applyGhostTextRows(n),t==="scroll"&&this.getLatestAnnotations().length===0&&!this.isResizeDebuggingEnabled()){if(e)this.computeApproximateSize(!0);return e}let{lineHeight:r}=this.metrics;if(this.code==null)return e;let i=this.code.children[1];if(!(i instanceof HTMLElement))return e;let o=ta(this.getLatestAnnotations());if(this.renderRange!=null&&o&&li(this.renderRange)){let s=VF(i)??0;if(s!==this.cache.fileAnnotationHeight)this.cache.fileAnnotationHeight=s,e=!0}else if(!o&&this.cache.fileAnnotationHeight!==0)this.cache.fileAnnotationHeight=0,e=!0;for(let s of i.children){if(!(s instanceof HTMLElement))continue;let a=s.dataset.lineIndex;if(a==null)continue;let l=Number(a),d=s.getBoundingClientRect().height+(n.get(l)??0)*r,c=!1;if(s.nextElementSibling instanceof HTMLElement&&(("lineAnnotation"in s.nextElementSibling.dataset)||("noNewline"in s.nextElementSibling.dataset))){if("noNewline"in s.nextElementSibling.dataset)c=!0;d+=s.nextElementSibling.getBoundingClientRect().height}let m=this.getLineHeight(l,c);if(d===m)continue;if(e=!0,d===this.metrics.lineHeight*(c?2:1))this.cache.heights.delete(l);else this.cache.heights.set(l,d)}if(e||this.isResizeDebuggingEnabled())this.computeApproximateSize(!0);return e}onRender=(e)=>{if(this.fileContainer==null||this.file==null)return!1;if(e)this.top=this.getVirtualizedTop();return this.render({file:this.file})};updateCodeViewLayout(e,t,n,r){let i=!et(this.file,e);if(i)this.updateExternalFile(e,r);let{pendingRenderFile:o,layoutFileChanged:s,renderedFileChanged:a,annotationsChanged:l}=this.updatePendingRender(e,r),d=n?.resetFileLayoutCache===!0||s||l;if(n?.metrics!=null)this.metrics=n.metrics,d=!0;let{collapsed:c=!1}=this.options;if(this.currentCollapsed!==c)this.currentCollapsed=c,d=!0;if(d)this.resetLayoutCache();if(i)this.layoutDirty=!0;if(!this.forceRenderOverride&&(i||a||l))this.forceRenderOverride=!0;return this.top=t,this.computeApproximateSize(!1,o),this.height}getLayoutFile(){return this.pendingRender?.file??this.getRenderedFile()}getLinePosition(e){let t=this.getLayoutFile();if(t==null||e<1)return;let{disableFileHeader:n=!1,collapsed:r=!1}=this.options,i=this.fileRenderer.getLineCount(t)-1,o=En(this.metrics,n);if(r||i<0)return{top:o,height:0};let s=Math.min(Math.max(e-1,0),i),{lineHeight:a}=this.metrics;if(o+=this.cache.fileAnnotationHeight,this.hasUniformLineHeights())return{top:o+s*a,height:a};let l=this.getLayoutCheckpointBeforeLineIndex(s);o=l?.top??o;for(let d=l?.lineIndex??0;d<s;d++)o+=this.getLineHeight(d,!1);return{top:o,height:this.getLineHeight(s,!1)}}getEditorViewport(){return this.virtualizer.type==="simple"?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){let t=this.getLayoutFile();if(t==null||this.renderRange==null)return;let{disableFileHeader:n=!1,collapsed:r=!1}=this.options;if(r||this.renderRange.totalLines<=0)return;let i=this.fileRenderer.getLineCount(t)-1;if(i<0)return;let o=En(this.metrics,n),s=Math.min(this.renderRange.startingLine,i),a=Math.min(s+this.renderRange.totalLines-1,i);if(a<s)return;let{fileAnnotationHeight:l}=this.cache;if(this.hasUniformLineHeights()){let{lineHeight:c}=this.metrics,m=o+(s===0?l:this.renderRange.bufferBefore),p=s+Math.max(Math.ceil((e-m)/c),0);if(p>a)return;return{lineNumber:p+1,top:o+l+p*c}}let d=o+(s===0?l:this.renderRange.bufferBefore);for(let c=s;c<=a;c++){if(d>=e)return{lineNumber:c+1,top:d};d+=this.getLineHeight(c)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){let t=this.getLayoutFile();if(this.top==null||t==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let n=e!=null?this.computeRenderRangeFromWindow(t,this.top,e):this.renderRange;if(n==null)return;let{bufferBefore:r,bufferAfter:i,totalLines:o}=n,s=0;if(o===0){let a=e??this.virtualizer.getWindowSpecs();if(this.top<a.top)s=i}return{topOffset:this.top+r+s,height:this.height-(r+i)}}cleanUp(e=!1){let t=this.cache.ghostTextRows.size>0;if(t)this.layoutDirty=!0;let n=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(t||!et(this.getRenderedFile(),this.getLatestFile()));if(this.fileContainer!=null&&this.isSimpleMode())this.getSimpleVirtualizer()?.disconnect(this.fileContainer);if(!e)this.resetLayoutCache();if(this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),n)this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.getLayoutFile()){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],t==null){this.layoutDirty=!1;return}this.applyGhostTextRows(this.editor?.__getGhostTextRows()??od);let{disableFileHeader:i=!1,collapsed:o=!1}=this.options,{lineHeight:s}=this.metrics,a=this.fileRenderer.getLineCount(t),l=En(this.metrics,i),d=Wi(this.metrics);if(this.height+=l,o){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,this.hasUniformLineHeights())this.height+=a*s;else for(let c=0;c<a;c++)this.addLayoutCheckpoint(c,this.height),this.height+=this.getLineHeight(c,!1);if(a>0)this.height+=d;if(this.fileContainer!=null&&n&&!r){let c=this.fileContainer.getBoundingClientRect();if(c.height!==this.height)console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match",{name:t.name,elementHeight:c.height,computedHeight:this.height});else console.log("VirtualizedFile.computeApproximateSize: computed height IS CORRECT")}this.layoutDirty=!1}setVisibility(e){if(this.isAdvancedMode()||this.fileContainer==null)return;if(this.renderRange=void 0,e&&!this.isVisible)this.top=this.getVirtualizedTop(),this.isVisible=!0;else if(!e&&this.isVisible)this.isVisible=!1,this.rerender()}rerender(){if(!this.enabled||this.file==null)return;let e=this.getLatestFile(),t=e==null?void 0:this.fileRenderer.getFileForNextRender(e);if(this.isSimpleMode())this.pendingRender=void 0;this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!et(this.getRenderedFile(),t))}syncGhostTextRows(){let e=this.getAdvancedVirtualizer();if(e!=null)e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0);else this.getSimpleVirtualizer()?.requestHeightReconcile(this)}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1);let i=this.getRenderedFile();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!=null&&i!=null){let o=this.virtualizer.getWindowSpecs(),s=this.computeRenderRangeFromWindow(i,this.top??0,o);if(s.bufferAfter!==r.bufferAfter)this.updateBuffers(s)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}render({fileContainer:e,file:t,forceRender:n=!1,lineAnnotations:r,...i}){let o=!et(this.file,t);if(o)this.updateExternalFile(t,r),this.cachedHeaderHTML=void 0;let{pendingRenderFile:s,layoutFileChanged:a,renderedFileChanged:l,annotationsChanged:d}=(()=>{if(this.pendingRender!=null&&this.pendingRender.latestFile===(this.getLatestFile(t)??t))return{pendingRenderFile:this.pendingRender.file,layoutFileChanged:!1,renderedFileChanged:!1,annotationsChanged:!1};return this.updatePendingRender(t,r)})(),{forceRenderOverride:c,isSetup:m}=this;if(this.forceRenderOverride=void 0,d||a)this.resetLayoutCache();if(e=this.getOrCreateFileContainerNode(e),!m){this.computeApproximateSize(!1,s);let I=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(I==null)throw Error("VirtualizedFile.render: simple virtualizer is not available");I.connect(e,this),this.isVisible=I.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}else if(this.top??=this.getVirtualizedTop(),a&&this.isSimpleMode())this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!1),this.computeApproximateSize(!1,s);if(!this.isVisible&&this.isSimpleMode()&&(!o||!m))return this.pendingRender=void 0,this.renderPlaceholder(this.height);let p=this.virtualizer.getWindowSpecs(),h=this.top??0,x=this.computeRenderRangeFromWindow(s,h,p);return super.render({file:t,fileContainer:e,renderRange:x,lineAnnotations:r,forceRender:(c??n)||d||l||o,...i})}finalizeRender(){if(this.getRenderedFile()!==this.pendingRender?.file)throw Error("VirtualizedFile.render: rendered a different file than its prepared layout");if(this.pendingRender=void 0,this.isSimpleMode())this.getSimpleVirtualizer()?.requestHeightReconcile(this)}updatePendingRender(e,t){let n=this.getLatestFile(e)??e,r=this.getRenderedFile(),i=this.pendingRender?.file??r,o=this.fileRenderer.getFileForNextRender(n);return this.pendingRender={latestFile:n,file:o},{pendingRenderFile:o,annotationsChanged:this.syncLineAnnotations(t),layoutFileChanged:!et(i,o),renderedFileChanged:!et(r,o)}}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}addLayoutCheckpoint(e,t){if(e%qF!==0)return;this.cache.checkpoints.push({lineIndex:e,top:t})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;while(t<=n){let i=t+n>>1,o=this.cache.checkpoints[i];if(o==null)throw Error("VirtualizedFile: invalid checkpoint index");if(o.lineIndex<=e)r=o,t=i+1;else n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;while(n<=r){let o=n+r>>1,s=this.cache.checkpoints[o];if(s==null)throw Error("VirtualizedFile: invalid checkpoint index");if(s.top<=e)i=o,n=o+1;else r=o-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let o=i;o>=0;o--){let s=this.cache.checkpoints[o];if(s==null)throw Error("VirtualizedFile: invalid checkpoint index");if(s.lineIndex%t===0)return s}}getVirtualizedTop(){if(this.virtualizer.type==="advanced")return this.virtualizer.getLocalTopForInstance(this);return this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type==="advanced"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1}=this.options,{hunkLineCount:o,lineHeight:s}=this.metrics,a=this.fileRenderer.getLineCount(e),l=this.height,d=En(this.metrics,i),c=a>0?Wi(this.metrics):0,{fileAnnotationHeight:m}=this.cache,p=d+m,h=Math.max(0,l-d-m-c),x=ta(this.getLatestAnnotations()),I=t+d,v=m>0&&x&&I<r&&I+m>n;if(t<n-l||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-d-c};if(a<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};let S=Math.ceil(Math.max(r-n,0)/s),b=Math.ceil(S/o)*o+o,E=b/o,w=(n+r)/2;if(this.hasUniformLineHeights()){let gt=t+p,xn=gt+h;if(!v&&!(gt<r&&xn>n))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-d-c};let Rn=Math.floor(v&&w<t+p?0:(w-(t+p))/s),An=Math.floor(Rn/o)-Math.floor(E/2),Hi=Math.ceil(a/o),Jt=Math.max(0,Math.min(An,Hi))*o,wo=An<0?b+An*o:b,Hs=Jt===0?0:m+Jt*s,Tr=Math.min(wo,a-Jt);return{startingLine:Jt,totalLines:wo,bufferBefore:Hs,bufferAfter:Math.max(0,(a-Jt-Tr)*s)}}let k=E,L=[],R=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-b*s*2),o),A=t+(R?.top??p),O=R?.lineIndex??0,D,X,N,B=R?.lineIndex??0;for(let gt=B;gt<a;gt++){let xn=O%o===0,Rn=Math.floor(O/o);if(xn){if(L[Rn]=A-(t+p),N!=null){if(N<=0)break;N--}}let An=this.getLineHeight(gt,!1);if(A>n-An&&A<r)D??=Rn;if(A+An>w)X??=Rn;if(N==null&&A>=r&&xn)N=k;O++,A+=An}if(D==null)if(v)D=0,X=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-d-c};X??=D;let pe=Math.round(X-E/2),ye=Math.max(0,Math.ceil(a/o)-E),j=Math.max(0,Math.min(pe,ye)),ie=j*o,Ee=pe<0?b+pe*o:b,Mt=L[j]??0,Ie=ie===0?0:m+Mt,Me=j+Ee/o,Qe=Me<L.length?h-L[Me]:h-(A-t-p);return{startingLine:ie,totalLines:Ee,bufferBefore:Ie,bufferAfter:Math.max(0,Qe)}}};function VF(e){let t;for(let n of e.children){if(!(n instanceof HTMLElement))continue;if(n.dataset.lineAnnotation!==Cu)continue;t=Math.max(t??0,n.getBoundingClientRect().height)}return t}function ze(e,t){return e?.cacheKey!=null||t?.cacheKey!=null?e?.cacheKey===t?.cacheKey:e===t}function sd(e,t){return e?.cacheKey===t?.cacheKey&&e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}async function da(e,t=300){let n;try{await Promise.race([e(),new Promise((r)=>{n=setTimeout(r,t)})])}finally{if(n!=null)clearTimeout(n)}}function Zo(e){return[Tt(e.additionStart,e.additionCount)+1,kt(e.additionStart,e.additionCount)+1]}function cn({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:r,collapsedContextThreshold:i}){let o=Math.max(t,0);if(o===0||e)return{fromStart:0,fromEnd:0,rangeSize:o,collapsedLines:o,renderAll:!1};if(n===!0||o<=i)return{fromStart:o,fromEnd:0,rangeSize:o,collapsedLines:0,renderAll:!0};let s=n?.get(r),a=Math.min(Math.max(s?.fromStart??0,0),o),l=Math.min(Math.max(s?.fromEnd??0,0),o),d=a+l,c=d>=o;return{fromStart:c?o:a,fromEnd:c?0:l,rangeSize:o,collapsedLines:Math.max(o-d,0),renderAll:c}}function SI(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-kt(t.additionStart,t.additionCount),r=e.deletionLines.length-kt(t.deletionStart,t.deletionCount);if(n<=0&&r<=0)return!1;return n!==r}function _f({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-kt(n.additionStart,n.additionCount),i=e.deletionLines.length-kt(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 mn({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let o=_f({fileDiff:e,errorPrefix:i});if(o<=0)return;if(n===!0||o<=r)return{fromStart:o,fromEnd:0,rangeSize:o,collapsedLines:0,renderAll:!0};let s=n?.get(e.hunks.length),a=Math.min(Math.max(s?.fromStart??0,0),o);return{fromStart:a,fromEnd:0,rangeSize:o,collapsedLines:o-a,renderAll:a>=o}}function ad({fileDiff:e,lineNumber:t,expandedHunks:n,collapsedContextThreshold:r}){if(n===!0||e.isPartial)return!0;for(let[a,l]of e.hunks.entries()){let[d,c]=Zo(l);if(t<d){let m=cn({isPartial:e.isPartial,rangeSize:l.collapsedBefore,expandedHunks:n,hunkIndex:a,collapsedContextThreshold:r}),p=d-m.rangeSize;return m.renderAll||t<p+m.fromStart||t>=d-m.fromEnd}if(t<c)return!0}let i=mn({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:"isAdditionLineRenderable"});if(i==null||i.renderAll)return!0;let o=e.hunks[e.hunks.length-1],[,s]=Zo(o);return t<s+i.fromStart||t>=s+i.rangeSize}function bI({fileDiff:e,lineNumber:t,direction:n,expandedHunks:r,collapsedContextThreshold:i}){if(r===!0||e.isPartial)return t;let o=[],s=1;for(let[l,d]of e.hunks.entries()){let[c,m]=Zo(d),p=cn({isPartial:e.isPartial,rangeSize:d.collapsedBefore,expandedHunks:r,hunkIndex:l,collapsedContextThreshold:i}),h=c-p.rangeSize;if(p.renderAll)o.push([h,c]);else{if(p.fromStart>0)o.push([h,h+p.fromStart]);if(p.fromEnd>0)o.push([c-p.fromEnd,c])}o.push([c,m]),s=m}let a=mn({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:i,errorPrefix:"getNearestRenderableAdditionLine"});if(a!=null){let l=s;if(s=l+a.rangeSize,a.renderAll)o.push([l,s]);else if(a.fromStart>0)o.push([l,l+a.fromStart])}if(t>=s)return t;if(n==="down"){for(let[l,d]of o)if(d>t)return Math.max(l,t);return}for(let l=o.length-1;l>=0;l--){let[d,c]=o[l];if(d<=t)return Math.min(c-1,t)}}function CI({type:e,metrics:t}){return t.hunkSeparatorHeight??Wx(e)}function EI({type:e,metrics:t}){return e==="simple"||e==="metadata"||e==="line-info-basic"?0:t.spacing}function WF({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 XF(e){return e!=="simple"&&e!=="metadata"}function Zi({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!WF({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=CI({type:e,metrics:t}),o=EI({type:e,metrics:t}),s=n>0?o:0,a=o;return{height:i,gapBefore:s,gapAfter:a,totalHeight:s+i+a}}function Hr({type:e,metrics:t}){if(!XF(e))return;let n=CI({type:e,metrics:t}),r=EI({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function vI({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:o,collapsedContextThreshold:s,canHydratePartialDiff:a}){let l=En(t,n),d=l,c=i?!0:o,m=e.hunks.length-1;for(let p=0;p<e.hunks.length;p++){let h=e.hunks[p];if(h==null)throw Error("computeEstimatedDiffHeights: invalid hunk index");let x=cn({isPartial:e.isPartial,rangeSize:h.collapsedBefore,expandedHunks:c,hunkIndex:p,collapsedContextThreshold:s}),I=(x.fromStart+x.fromEnd)*t.lineHeight;if(l+=I,d+=I,x.collapsedLines>0){let b=Zi({type:r,metrics:t,hunkIndex:p,hunkSpecs:h.hunkSpecs})?.totalHeight??0;l+=b,d+=b}l+=h.splitLineCount*t.lineHeight,d+=h.unifiedLineCount*t.lineHeight;let v=YF(h);l+=v.split*t.lineHeight,d+=v.unified*t.lineHeight;let S=p===m?mn({fileDiff:e,hunkIndex:p,expandedHunks:c,collapsedContextThreshold:s,errorPrefix:"computeEstimatedDiffHeights"}):void 0;if(S!=null){let b=(S.fromStart+S.fromEnd)*t.lineHeight;if(l+=b,d+=b,S.collapsedLines>0){let E=Hr({type:r,metrics:t})?.totalHeight??0;l+=E,d+=E}}else if(p===m&&e.isPartial&&a){let b=Hr({type:r,metrics:t})?.totalHeight??0;l+=b,d+=b}}if(e.hunks.length>0){let p=Wi(t);l+=p,d+=p}return{splitHeight:l,unifiedHeight:d}}function YF(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};let t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type==="context"){let n=t.lines>0?1:0;return{split:n,unified:n}}return JF(e,t)}function JF(e,t){let n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),r=t.deletions>0&&e.noEOFCRDeletions,i=t.additions>0&&e.noEOFCRAdditions;return{split:r||i?1:0,unified:n}}function ca({oldFile:e,newFile:t},n){if(e===void 0&&t===void 0)return;if(e===void 0||t===void 0)throw Error(`${n}: Pass null for an intentionally missing oldFile or newFile side`);if(e===null){if(t===null)throw Error(`${n}: You must pass oldFile, newFile, or both`);return{oldFile:e,newFile:t}}if(t===null)return{oldFile:e,newFile:t};return{oldFile:e,newFile:t}}function Qo(e){return e!==""?e.split(TI):[]}function ma(e,t,n){let r=e==="clone"?ld(t):t;if(!r.isPartial)throw Error("hydratePartialDiff: fileDiff must be partial");switch(r.type){case"change":case"rename-changed":return ZF(r,eN(r,n),kI(r,n));case"rename-pure":{let i=kI(r,n);tN(r,n);let o=Qo(i.contents);return r.isPartial=!1,r.deletionLines=o,r.additionLines=o,wI(r,null,i),r}}throw Error(`hydratePartialDiff: ${r.type} diffs cannot be hydrated from loaded files`)}function ZF(e,t,n){let r=Qo(t.contents),i=Qo(n.contents),{hunks:o,splitLineCount:s,unifiedLineCount:a}=QF(e.hunks,i.length);return e.hunks=o,e.splitLineCount=s,e.unifiedLineCount=a,e.isPartial=!1,e.deletionLines=r,e.additionLines=i,wI(e,t,n),e}function QF(e,t){let n=0,r=0,i=0,o=[];for(let s of e){let a=Math.max(s.additionStart-1,0),l=Math.max(s.deletionStart-1,0),d=a,c=l,m=0,p=0,h=0,x=0,I=[];for(let S of s.hunkContent){if(S.type==="context"){I.push({...S,additionLineIndex:d,deletionLineIndex:c}),d+=S.lines,c+=S.lines,h+=S.lines,x+=S.lines;continue}I.push({...S,additionLineIndex:d,deletionLineIndex:c}),d+=S.additions,c+=S.deletions,m+=S.additions,p+=S.deletions,h+=Math.max(S.additions,S.deletions),x+=S.additions+S.deletions}let v=Math.max(Tt(s.additionStart,s.additionCount)-i,0);o.push({...s,collapsedBefore:v,additionLineIndex:a,deletionLineIndex:l,additionLines:m,deletionLines:p,hunkContent:I,splitLineStart:n+v,unifiedLineStart:r+v,splitLineCount:h,unifiedLineCount:x}),n+=v+h,r+=v+x,i=kt(s.additionStart,s.additionCount)}if(o.length>0){let s=o[o.length-1],a=kt(s.additionStart,s.additionCount),l=Math.max(t-a,0);n+=l,r+=l}return{hunks:o,splitLineCount:n,unifiedLineCount:r}}function eN(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function kI(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function tN(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function nN(e,t,n){if(e.cacheKey!=null)return`${e.cacheKey}:hydrated`;return rN(t,n)}function wI(e,t,n){let r=nN(e,t,n);if(r==null){delete e.cacheKey;return}e.cacheKey=r}function rN(e,t){if(e!=null&&t!=null)return e.cacheKey!=null&&t.cacheKey!=null?Vi("hydrated-files",e.cacheKey,t.cacheKey):void 0;return e?.cacheKey??t?.cacheKey}function zn({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:o=1,callback:s}){let a=iN({diff:e,diffStyle:t,startingLine:n,expandedHunks:i,collapsedContextThreshold:o}),l={viewportStart:n,viewportEnd:n+r,isWindowedHighlight:n>0||r<1/0,splitCount:a.splitCount,unifiedCount:a.unifiedCount,finalHunkIndex:e.hunks.length-1,shouldBreak(){if(!l.isWindowedHighlight)return!1;let d=l.unifiedCount>=n+r,c=l.splitCount>=n+r;if(t==="unified")return d;else if(t==="split")return c;else return d&&c},shouldSkip(d,c){if(!l.isWindowedHighlight)return!1;let m=d>0&&l.unifiedCount+d<=n,p=c>0&&l.splitCount+c<=n;if(t==="unified")return m;else if(t==="split")return p;else return m&&p},incrementCounts(d,c){if(t==="unified"||t==="both")l.unifiedCount+=d;if(t==="split"||t==="both")l.splitCount+=c},isInWindow(d,c){if(!l.isWindowedHighlight)return!0;let m=l.isInUnifiedWindow(d),p=l.isInSplitWindow(c);if(t==="unified")return m;else if(t==="split")return p;else return m||p},isInUnifiedWindow(d){return!l.isWindowedHighlight||l.unifiedCount>=n-d&&l.unifiedCount<n+r},isInSplitWindow(d){return!l.isWindowedHighlight||l.splitCount>=n-d&&l.splitCount<n+r},emit(d,c=!1){if(!c)if(t==="unified")l.incrementCounts(1,0);else if(t==="split")l.incrementCounts(0,1);else l.incrementCounts(1,1);return s(d)??!1}};e:for(let d=a.hunkIndex;d<e.hunks.length;d++){let b=function(N,B){if(v==null||v.collapsedLines<=0||v.fromStart+v.fromEnd>0)return 0;if(t==="unified")return N===c.unifiedLineStart+c.unifiedLineCount-1?v.collapsedLines:0;return B===c.splitLineStart+c.splitLineCount-1?v.collapsedLines:0},w=function(){if(E)return 0;return E=!0,I.collapsedLines},c=e.hunks[d];if(c==null)throw Error("iterateOverDiff: invalid hunk index");if(l.shouldBreak())break;let m=Tt(c.deletionStart,c.deletionCount),p=Tt(c.additionStart,c.additionCount),h=!e.isPartial&&c.deletionCount===0?m:c.deletionLineIndex,x=!e.isPartial&&c.additionCount===0?p:c.additionLineIndex,I=cn({isPartial:e.isPartial,rangeSize:c.collapsedBefore,expandedHunks:i,hunkIndex:d,collapsedContextThreshold:o}),v=d===l.finalHunkIndex?mn({fileDiff:e,hunkIndex:d,expandedHunks:i,collapsedContextThreshold:o,errorPrefix:"iterateOverDiff"}):void 0,S=I.fromStart+I.fromEnd,E=I.collapsedLines===0;if(!l.shouldSkip(S,S)){let N=c.unifiedLineStart-I.rangeSize,B=c.splitLineStart-I.rangeSize,pe=h-I.rangeSize,ye=x-I.rangeSize,j=m+1-I.rangeSize,ie=p+1-I.rangeSize;if(ud(l,I.fromStart,t,(Ee)=>l.emit({hunkIndex:d,hunk:c,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:j+Ee,lineIndex:pe+Ee,noEOFCR:!1,unifiedLineIndex:N+Ee,splitLineIndex:B+Ee},additionLine:{unifiedLineIndex:N+Ee,splitLineIndex:B+Ee,lineIndex:ye+Ee,lineNumber:ie+Ee,noEOFCR:!1}})))break e;if(N=c.unifiedLineStart-I.fromEnd,B=c.splitLineStart-I.fromEnd,pe=h-I.fromEnd,ye=x-I.fromEnd,j=m+1-I.fromEnd,ie=p+1-I.fromEnd,ud(l,I.fromEnd,t,(Ee)=>l.emit({hunkIndex:d,hunk:c,collapsedBefore:w(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:j+Ee,lineIndex:pe+Ee,noEOFCR:!1,unifiedLineIndex:N+Ee,splitLineIndex:B+Ee},additionLine:{unifiedLineIndex:N+Ee,splitLineIndex:B+Ee,lineIndex:ye+Ee,lineNumber:ie+Ee,noEOFCR:!1}}),()=>{w()}))break e}else l.incrementCounts(S,S),w();let{unifiedLineStart:k,splitLineStart:L}=c,R=h,A=x,O=m+1,D=p+1,X=c.hunkContent.at(-1);for(let N of c.hunkContent){if(l.shouldBreak())break e;let B=N===X;if(N.type==="context"){if(!l.shouldSkip(N.lines,N.lines)){if(ud(l,N.lines,t,(pe)=>{let ye=B&&pe===N.lines-1,j=k+pe,ie=L+pe;return l.emit({hunkIndex:d,hunk:c,collapsedBefore:w(),collapsedAfter:b(j,ie),type:"context",deletionLine:{lineNumber:O+pe,lineIndex:R+pe,noEOFCR:ye&&c.noEOFCRDeletions,unifiedLineIndex:j,splitLineIndex:ie},additionLine:{unifiedLineIndex:j,splitLineIndex:ie,lineIndex:A+pe,lineNumber:D+pe,noEOFCR:ye&&c.noEOFCRAdditions}})},()=>{w()}))break e}else l.incrementCounts(N.lines,N.lines),w();k+=N.lines,L+=N.lines,R+=N.lines,A+=N.lines,O+=N.lines,D+=N.lines}else{let pe=Math.max(N.deletions,N.additions),ye=N.deletions+N.additions;if(!l.shouldSkip(ye,pe)){let j=aN(l,N,t);if((j[0]?.[0]??0)>0)w();for(let[ie,Ee]of j)for(let Mt=ie;Mt<Ee;Mt++){let Ie=b(k+Mt,t==="unified"?L+(Mt<N.deletions?Mt:Mt-N.deletions):L+Mt);if(l.emit(lN({hunkIndex:d,hunk:c,collapsedBefore:w(),collapsedAfter:Ie,diffStyle:t,index:Mt,unifiedLineIndex:k,splitLineIndex:L,additionLineIndex:A,deletionLineIndex:R,additionLineNumber:D,deletionLineNumber:O,content:N,isLastContent:B,unifiedCount:ye,splitCount:pe}),!0))break e}}w(),l.incrementCounts(ye,pe),k+=ye,L+=pe,R+=N.deletions,A+=N.additions,O+=N.deletions,D+=N.additions}}if(v!=null){let{collapsedLines:N,fromStart:B,fromEnd:pe}=v,ye=B+pe;if(ud(l,ye,t,(j)=>{let ie=j===ye-1;return l.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:ie?N:0,type:"context-expanded",deletionLine:{lineNumber:O+j,lineIndex:R+j,noEOFCR:!1,unifiedLineIndex:k+j,splitLineIndex:L+j},additionLine:{unifiedLineIndex:k+j,splitLineIndex:L+j,lineIndex:A+j,lineNumber:D+j,noEOFCR:!1}})},void 0,()=>l.shouldBreak()))break e}}}function iN({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t==="both")return{hunkIndex:0,splitCount:0,unifiedCount:0};let o=oN({diff:e,expandedHunks:r,collapsedContextThreshold:i}),s=0,a=e.hunks.length-1,l=e.hunks.length;while(s<=a){let c=s+a>>1,m=o[c+1];if(m==null)throw Error("iterateOverDiff: invalid hunk prefix index");if((t==="unified"?m.unifiedCount:m.splitCount)>n)l=c,a=c-1;else s=c+1}if(l>=e.hunks.length){let c=o[e.hunks.length];if(c==null)throw Error("iterateOverDiff: invalid terminal hunk prefix index");return{hunkIndex:e.hunks.length,splitCount:c.splitCount,unifiedCount:c.unifiedCount}}let d=o[l];if(d==null)throw Error("iterateOverDiff: invalid selected hunk prefix index");return{hunkIndex:l,splitCount:d.splitCount,unifiedCount:d.unifiedCount}}function oN({diff:e,expandedHunks:t,collapsedContextThreshold:n}){let r=0,i=0,o=e.hunks.length-1,s=[{splitCount:0,unifiedCount:0}];for(let a=0;a<e.hunks.length;a++){let l=e.hunks[a];if(l==null)throw Error("iterateOverDiff: invalid hunk summary index");let d=cn({isPartial:e.isPartial,rangeSize:l.collapsedBefore,expandedHunks:t,hunkIndex:a,collapsedContextThreshold:n}),c=d.fromStart+d.fromEnd;r+=c+l.splitLineCount,i+=c+l.unifiedLineCount;let m=a===o?mn({fileDiff:e,hunkIndex:a,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:"iterateOverDiff"}):void 0;if(m!=null){let p=m.fromStart+m.fromEnd;r+=p,i+=p}s.push({splitCount:r,unifiedCount:i})}return s}function sN(e,t,n){if(!e.isWindowedHighlight||t<=0)return[0,t];let r=[];function i(a){let l=Math.max(0,e.viewportStart-a),d=Math.min(t,e.viewportEnd-a);if(d>l)r.push([l,d])}if(n!=="split")i(e.unifiedCount);if(n!=="unified")i(e.splitCount);if(r.length===0)return[0,0];let o=r[0][0],s=r[0][1];for(let a=1;a<r.length;a++){let l=r[a];o=Math.min(o,l[0]),s=Math.max(s,l[1])}return[o,s]}function ud(e,t,n,r,i,o){let[s,a]=sN(e,t,n);if(s>0)e.incrementCounts(s,s),i?.();let l=s;while(l<t){if(o?.()===!0)return!0;if(l>=a){e.incrementCounts(t-l,t-l);break}if(e.isInWindow(0,0)){if(r(l)===!0)return!0}else e.incrementCounts(1,1);l++}return!1}function aN(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",o=n==="unified"?"unified":"split",s=[];function a(m,p){if(m+p<=e.viewportStart||m>=e.viewportEnd)return;let h=Math.max(0,e.viewportStart-m),x=Math.min(p,e.viewportEnd-m);return x>h?[h,x]:void 0}function l(m,p){if(o==="split")return m;return p==="additions"?[m[0]+t.deletions,m[1]+t.deletions]:m}function d(m,p){if(m==null)return;let[h,x]=l(m,p);if(x>h)s.push([h,x])}if(r)d(a(e.unifiedCount,t.deletions),"deletions"),d(a(e.unifiedCount+t.deletions,t.additions),"additions");if(i)d(a(e.splitCount,t.deletions),"deletions"),d(a(e.splitCount,t.additions),"additions");if(s.length===0)return s;s.sort((m,p)=>m[0]-p[0]);let c=[s[0]];for(let[m,p]of s.slice(1)){let h=c[c.length-1];if(m<=h[1])h[1]=Math.max(h[1],p);else c.push([m,p])}return c}function lN({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,diffStyle:i,index:o,unifiedLineIndex:s,splitLineIndex:a,additionLineIndex:l,deletionLineIndex:d,additionLineNumber:c,deletionLineNumber:m,content:p,isLastContent:h,unifiedCount:x,splitCount:I}){let v=o<p.deletions?s+o:void 0,S=i==="unified"?o>=p.deletions?s+o:void 0:o<p.additions?s+p.deletions+o:void 0,b=i==="unified"?a+(o<p.deletions?o:o-p.deletions):a+o,E=o<p.deletions?d+o:void 0,w=o<p.deletions?m+o:void 0,k=i==="unified"?o>=p.deletions?l+(o-p.deletions):void 0:o<p.additions?l+o:void 0,L=i==="unified"?o>=p.deletions?c+(o-p.deletions):void 0:o<p.additions?c+o:void 0,R=i==="unified"?h&&o===p.deletions-1&&t.noEOFCRDeletions:h&&o===I-1&&t.noEOFCRDeletions,A=i==="unified"?h&&o===x-1&&t.noEOFCRAdditions:h&&o===I-1&&t.noEOFCRAdditions,O=E!=null&&w!=null&&v!=null?{lineNumber:w,lineIndex:E,noEOFCR:R,unifiedLineIndex:v,splitLineIndex:b}:void 0,D=k!=null&&L!=null&&S!=null?{unifiedLineIndex:S,splitLineIndex:b,lineIndex:k,lineNumber:L,noEOFCR:A}:void 0;if(O==null&&D!=null)return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:D};else if(O!=null&&D==null)return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:O,additionLine:void 0};if(O==null||D==null)throw Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:O,additionLine:D}}class _r{diff(e,t,n={}){let r;if(typeof n==="function")r=n,n={};else if("callback"in n)r=n.callback;let i=this.castInput(e,n),o=this.castInput(t,n),s=this.removeEmpty(this.tokenize(i,n)),a=this.removeEmpty(this.tokenize(o,n));return this.diffWithOptionsObj(s,a,n,r)}diffWithOptionsObj(e,t,n,r){var i;let o=(S)=>{if(S=this.postProcess(S,n),r){setTimeout(function(){r(S)},0);return}else return S},s=t.length,a=e.length,l=1,d=s+a;if(n.maxEditLength!=null)d=Math.min(d,n.maxEditLength);let c=(i=n.timeout)!==null&&i!==void 0?i:1/0,m=Date.now()+c,p=[{oldPos:-1,lastComponent:void 0}],h=this.extractCommon(p[0],t,e,0,n);if(p[0].oldPos+1>=a&&h+1>=s)return o(this.buildValues(p[0].lastComponent,t,e));let x=-1/0,I=1/0,v=()=>{for(let S=Math.max(x,-l);S<=Math.min(I,l);S+=2){let b,E=p[S-1],w=p[S+1];if(E)p[S-1]=void 0;let k=!1;if(w){let R=w.oldPos-S;k=w&&0<=R&&R<s}let L=E&&E.oldPos+1<a;if(!k&&!L){p[S]=void 0;continue}if(!L||k&&E.oldPos<w.oldPos)b=this.addToPath(w,!0,!1,0,n);else b=this.addToPath(E,!1,!0,1,n);if(h=this.extractCommon(b,t,e,S,n),b.oldPos+1>=a&&h+1>=s)return o(this.buildValues(b.lastComponent,t,e))||!0;else{if(p[S]=b,b.oldPos+1>=a)I=Math.min(I,S-1);if(h+1>=s)x=Math.max(x,S+1)}}l++};if(r)(function S(){setTimeout(function(){if(l>d||Date.now()>m)return r(void 0);if(!v())S()},0)})();else while(l<=d&&Date.now()<=m){let S=v();if(S)return S}}addToPath(e,t,n,r,i){let o=e.lastComponent;if(o&&!i.oneChangePerToken&&o.added===t&&o.removed===n)return{oldPos:e.oldPos+r,lastComponent:{count:o.count+1,added:t,removed:n,previousComponent:o.previousComponent}};else return{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:o}}}extractCommon(e,t,n,r,i){let o=t.length,s=n.length,a=e.oldPos,l=a-r,d=0;while(l+1<o&&a+1<s&&this.equals(n[a+1],t[l+1],i))if(l++,a++,d++,i.oneChangePerToken)e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1};if(d&&!i.oneChangePerToken)e.lastComponent={count:d,previousComponent:e.lastComponent,added:!1,removed:!1};return e.oldPos=a,l}equals(e,t,n){if(n.comparator)return n.comparator(e,t);else return e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)if(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;while(e)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let o=r.length,s=0,a=0,l=0;for(;s<o;s++){let d=r[s];if(!d.removed){if(!d.added&&this.useLongestToken){let c=t.slice(a,a+d.count);c=c.map(function(m,p){let h=n[l+p];return h.length>m.length?h:m}),d.value=this.join(c)}else d.value=this.join(t.slice(a,a+d.count));if(a+=d.count,!d.added)l+=d.count}else d.value=this.join(n.slice(l,l+d.count)),l+=d.count}return r}}class LI extends _r{}var RI=new LI;function Uf(e,t,n){return RI.diff(e,t,n)}function Bf(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 Gf(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 dd(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 cd(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 es(e,t){return dd(e,t,"")}function fa(e,t){return cd(e,t,"")}function jf(e,t){return t.slice(0,uN(e,t))}function uN(e,t){let n=0;if(e.length>t.length)n=e.length-t.length;let r=t.length;if(e.length<t.length)r=e.length;let i=Array(r),o=0;i[0]=0;for(let s=1;s<r;s++){if(t[s]==t[o])i[s]=i[o];else i[s]=o;while(o>0&&t[s]!=t[o])o=i[o];if(t[s]==t[o])o++}o=0;for(let s=n;s<e.length;s++){while(o>0&&e[s]!=t[o])o=i[o];if(e[s]==t[o])o++}return o}function qf(e,t){let n=[];for(let r of Array.from(t.segment(e))){let i=r.segment;if(n.length&&/\s/.test(n[n.length-1])&&/\s/.test(i))n[n.length-1]+=i;else n.push(i)}return n}function md(e,t){if(t)return ts(e,t)[1];let n;for(n=e.length-1;n>=0;n--)if(!e[n].match(/\s/))break;return e.substring(n+1)}function Qi(e,t){if(t)return ts(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:""}function ts(e,t){if(!t)return[Qi(e),md(e)];if(t.resolvedOptions().granularity!="word")throw Error('The segmenter passed must have a granularity of "word"');let n=qf(e,t),r=n[0],i=n[n.length-1],o=/\s/.test(r)?r:"",s=/\s/.test(i)?i:"";return[o,s]}var fd="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}",dN=new RegExp(`[${fd}]+|\\s+|[^${fd}]`,"ug");class PI extends _r{equals(e,t,n){if(n.ignoreCase)e=e.toLowerCase(),t=t.toLowerCase();return e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let o=t.intlSegmenter;if(o.resolvedOptions().granularity!="word")throw Error('The segmenter passed must have a granularity of "word"');n=qf(e,o)}else n=e.match(dN)||[];let r=[],i=null;return n.forEach((o)=>{if(/\s/.test(o))if(i==null)r.push(o);else r.push(r.pop()+o);else if(i!=null&&/\s/.test(i))if(r[r.length-1]==i)r.push(r.pop()+o);else r.push(i+o);else r.push(o);i=o}),r}join(e){return e.map((t,n)=>{if(n==0)return t;else return t.replace(/^\s+/,"")}).join("")}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;if(e.forEach((o)=>{if(o.added)r=o;else if(o.removed)i=o;else{if(r||i)AI(n,i,r,o,t.intlSegmenter);n=o,r=null,i=null}}),r||i)AI(n,i,r,null,t.intlSegmenter);return e}}var cN=new PI;function AI(e,t,n,r,i){if(t&&n){let[o,s]=ts(t.value,i),[a,l]=ts(n.value,i);if(e){let d=Bf(o,a);e.value=cd(e.value,a,d),t.value=es(t.value,d),n.value=es(n.value,d)}if(r){let d=Gf(s,l);r.value=dd(r.value,l,d),t.value=fa(t.value,d),n.value=fa(n.value,d)}}else if(n){if(e){let o=Qi(n.value,i);n.value=n.value.substring(o.length)}if(r){let o=Qi(r.value,i);r.value=r.value.substring(o.length)}}else if(e&&r){let o=Qi(r.value,i),[s,a]=ts(t.value,i),l=Bf(o,s);t.value=es(t.value,l);let d=Gf(es(o,l),a);t.value=fa(t.value,d),r.value=dd(r.value,o,d),e.value=cd(e.value,o,o.slice(0,o.length-d.length))}else if(r){let o=Qi(r.value,i),s=md(t.value,i),a=jf(s,o);t.value=fa(t.value,a)}else if(e){let o=md(e.value,i),s=Qi(t.value,i),a=jf(o,s);t.value=es(t.value,a)}}class $I extends _r{tokenize(e){let t=new RegExp(`(\\r?\\n)|[${fd}]+|[^\\S\\n\\r]+|[^${fd}]`,"ug");return e.match(t)||[]}}var MI=new $I;function zf(e,t,n){return MI.diff(e,t,n)}class OI extends _r{constructor(){super(...arguments);this.tokenize=fN}equals(e,t,n){if(n.ignoreWhitespace){if(!n.newlineIsToken||!e.includes(`
|
|
1508
|
+
}`}function Xu(e,t){let n=Nf(t);return e.replace(ZF,n)}function QF(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qo(e,t,n){let r=new Map;for(let i of e){let o=Yu(i);r.set(o,n?.slotNames.get(o)??t(i))}return{provided:e,current:e,slotNames:r}}function Ju(e,t,n){for(let r of t){let i=Yu(r);if(!e.slotNames.has(i))e.slotNames.set(i,n(r))}e.provided=t,e.current=t}function Zu(e,t,n){if(e==null)return n(t);let r=Yu(t),i=e.slotNames.get(r);if(i==null)i=n(t),e.slotNames.set(r,i);return i}function Qu(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function Hf(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,themeType:e?.themeType,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:Qu(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,unsafeCSS:e?.unsafeCSS,headerRenderMode:e?.renderCustomHeader!=null?"custom":"default"}}function es({code:e,pre:t,columnType:n,rowSpan:r,containerSize:i=!1}={}){if(e==null){if(e=document.createElement("code"),e.setAttribute("data-code",""),n!=null)e.setAttribute(`data-${n}`,"");t?.appendChild(e)}if(r!=null)e.style.setProperty("grid-row",`span ${r}`);else e.style.removeProperty("grid-row");if(i)e.setAttribute("data-container-size","");else e.removeAttribute("data-container-size");return e}function da(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 ed({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===""){t?.remove();return}if(t??=eN(),t.textContent=n,t.parentNode!==e)e.appendChild(t);return t}function eN(){let e=document.createElement("style");return e.setAttribute(bI,""),e}function td(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:"open"});if(n.innerHTML==="")n.innerHTML=t}function nd(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:o,split:s,totalLines:a,customProperties:l}){if(l!=null)for(let d in l){let c=l[d];if(c!=null)e.setAttribute(d,`${c}`)}if(t==="diff")e.setAttribute("data-diff",""),e.removeAttribute("data-file");else e.setAttribute("data-file",""),e.removeAttribute("data-diff");switch(n){case"bars":case"classic":e.setAttribute("data-indicators",n);break;case"none":e.removeAttribute("data-indicators")}if(i)e.setAttribute("data-disable-line-numbers","");else e.removeAttribute("data-disable-line-numbers");if(r)e.removeAttribute("data-background");else e.setAttribute("data-background","");if(t==="diff")e.setAttribute("data-diff-type",s?"split":"single");else e.removeAttribute("data-diff-type");return e.setAttribute("data-overflow",o),e.style.setProperty("--diffs-min-number-column-width-default",`${`${a}`.length}ch`),e}if(typeof HTMLElement<"u"&&customElements.get("diffs-container")==null){let e;class t extends HTMLElement{constructor(){super();if(this.shadowRoot!=null)return;let n=this.attachShadow({mode:"open"});if(e==null)e=new CSSStyleSheet,e.replaceSync(Df);n.adoptedStyleSheets=[e]}connectedCallback(){let n=this.shadowRoot??this.attachShadow({mode:"open"});mi(n)}}customElements.define(rd,t)}var tN=[""];function nN(e){let t={...e};return delete t.cacheKey,t}var rN=-1,_f=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++rN}`;type="file";fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;editSession;renderedFile;renderRange;enabled=!0;editor;constructor(e={theme:Oe},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new hI(e,this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager),this.resizeManager=new wu,this.interactionManager=new Tu("file",Ko(e)),this.workerManager?.subscribeToThemeChanges(this)}getAnnotationSlotName=(e)=>Zu(this.editSession?.annotations,e,dn);handleHighlightRender=()=>{this.rerender()};rerender(){if(!this.enabled||this.file==null)return;this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}getTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??Oe}getLatestFile(e=this.file){return this.editSession?.file??e}getRenderedFile(){return this.renderedFile}getLatestAnnotations(){return this.editSession?.annotations?.current??this.lineAnnotations}isNewAnnotations(e){let t=this.editSession?.annotations;if(e===this.lineAnnotations)return!1;return t==null||e!==t.provided&&e!==t.current}updateExternalFile(e,t){if(et(this.file,e))return!1;let n=this.editSession!=null;if(this.file=e,n||this.editor!=null)this.installEditSession(e,n?void 0:this.editor?.__getDocumentContents(e),!0);else this.editSession=void 0;if(this.editSession?.annotations!=null&&t!=null)this.lineAnnotations=t,this.editSession.annotations=Qo(t,dn,this.editSession.annotations);return!0}installEditSession(e,t,n=!1){let r=t==null||t.name===e.name&&t.lang===e.lang&&t.contents===e.contents,i=nN(t??e);this.editSession={file:i,externalReplacement:n&&r,annotations:this.editSession?.annotations??Qo(this.lineAnnotations,dn)},this.fileRenderer.beginEditSession(i,r?e:void 0)}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){if(e==null)return;this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions()}syncInteractionOptions(){this.interactionManager.setOptions(Ko(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){if((this.options.themeType??"system")===e)return;this.mergeOptions({themeType:e}),this.applyCachedThemeState(e)}applyCachedThemeState(e){if(typeof this.options.theme==="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;if(this.appliedThemeCSS.themeType===t)return!1;return this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Cn(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){let t=this.editSession?.annotations;if(t==null){this.lineAnnotations=e;return}if(!this.isNewAnnotations(e))return;this.lineAnnotations=e,Ju(t,e,dn)}syncEditSessionAnnotationsFromEditor(e){let t=this.editSession?.annotations;if(t==null||e===t.current)return!1;return t.current=e,this.fileRenderer.setLineAnnotations(e),this.renderAnnotations(),!0}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??"additions"})}getCodeScrollLeft(){return this.code?.scrollLeft??0}setCodeScrollLeft(e){if(this.code!=null)this.code.scrollLeft=e}__getEffectiveCodeOptions(){return{...this.options,...this.fileRenderer.getEffectiveCodeOptions()}}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e==="wrap",columnVariables:this.shouldApplyColumnVariables(e)?"apply":"measure"}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e==="scroll"&&this.getLatestAnnotations().length>0}cleanUp(e=!1){let t=this.editor;if(this.emitPostRender(!0),t?.cleanUp(e?"recycle":"discard"),!e)this.editor=void 0;if(this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,!this.isContainerManaged)this.fileContainer?.remove();if(this.fileContainer=void 0,this.mounted=!1,!e)this.lineAnnotations=[];if(this.clearAuxiliaryNodes(),this.pre=void 0,this.code=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,!e)this.cachedHeaderHTML=void 0;if(this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,e)this.fileRenderer.recycle();else this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0,this.editSession=void 0,this.renderedFile=void 0;this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:i,lineAnnotations:o}=e;if(!this.enabled)throw Error("File.hydrate: attempting to call hydrate after cleaned up");if(this.fileContainer!=null)throw Error("File.hydrate: hydrate can only be called before the instance has rendered or hydrated");this.hydrateElements(t,n);let s=this.editor!=null;if(s||iN(this.pre,i,this.options.collapsed)||oN(this.headerElement,i,this.options.disableFileHeader))this.render({...e,forceRender:s||e.forceRender,preventEmit:!0});else this.hydrationSetup({file:i,lineAnnotations:o});if(!r)this.emitPostRender()}hydrateElements(e,t){if(this.fileContainer!==e)this.emitPostRender(!0);td(e,t);for(let n of Array.from(e.shadowRoot?.children??[])){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(!(n instanceof HTMLElement))continue;if(n instanceof HTMLPreElement){this.pre=n,this.appliedPreAttributes=void 0;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}if("diffsHeader"in n.dataset){this.headerElement=n,this.lastRenderedHeaderHTML=void 0;continue}}if(this.pre!=null)this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute("data-dehydrated");this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){if(this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(Hf(this.options)),this.syncInteractionOptions(),this.pre==null)return;this.fileRenderer.hydrate(e),this.renderedFile=e,this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers()}getOrCreateLineCache(e=this.getLatestFile()){return e!=null?this.fileRenderer.getOrCreateLineCache(e):tN}updateBuffers(e){if(this.pre!=null)this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){let{editor:e,fileContainer:t,renderRange:n}=this,r=this.getLatestAnnotations(),i=this.getLatestFile();if(e==null||t==null||i==null)return;let o=(d)=>{if(!this.enabled||this.editor!==e||this.fileContainer!==t||this.getLatestFile()!==i)return;e.__syncRenderView({highlighter:d,fileContainer:t,file:i,lineAnnotations:r,renderRange:n,externalDocument:this.editSession?.externalReplacement===!0})},s=this.getTheme(),a=i.lang??tt(i.name),l=jn({theme:s,lang:a});if(l!=null)o(l);else sr({themes:On(s),langs:Array.from(new Set(["text",a])),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter}).then(o)}__acknowledgeDocumentUpdate(){if(this.editSession!=null)this.editSession.externalReplacement=!1}__acceptEditorChange(e){let{lineAnnotations:t}=e;if(t!=null)this.syncEditSessionAnnotationsFromEditor(t)}emitEditChange(e){let{onEditChange:t}=this.options;t?.(e)}__captureDocumentSessionState(){}__attachEditor(e){if(this.editor!=null)throw Error("File.__attachEditor: an editor is already attached");this.editor=e;let t=()=>{this.editor=void 0,this.fileRenderer.endEditSession()};try{return this.resumeEditorRendering(e),t}catch(n){throw t(),n}}__resumeEditor(e){if(this.editor!==e)throw Error("File.__resumeEditor: editor association changed");this.resumeEditorRendering(e)}resumeEditorRendering(e){if(this.editSession!=null)this.fileRenderer.beginEditSession(this.editSession.file);else if(this.file!=null)this.installEditSession(this.file,e.__getDocumentContents(this.file));let t=this.editSession?.file;if(this.fileRenderer.editorRenderReady()){if(this.fileRenderer.fileCache===t)this.renderedFile=t;this.syncRenderViewToEditor()}else this.rerender()}__completeEditSession(e,t){this.settleEditSession(t==="install",e)}settleEditSession(e,t){let{editSession:n,file:r,lineAnnotations:i}=this;if(n==null||r==null)return;let{file:o,annotations:s}=n;if(this.editor!=null)throw Error("File.__completeEditSession: detach the editor before completing the session");let a=s?.current,l,d=!1,c;if(t==null)throw Error("File.__completeEditSession: editor is required for completion");let m={...o},p={file:m,editor:t,originalFile:r,lineAnnotations:a,originalLineAnnotations:i};Object.freeze(p);try{if(t.__emitEditComplete(p),this.options.onEditComplete?.(p)==="accept"){if(m.cacheKey!=null&&m.cacheKey===r.cacheKey)throw Error("File.__completeEditSession: an accepted file must not reuse the replaced file cacheKey");l=m}}catch(I){d=!0,c=I}if(e&&l!=null){if(this.file=l,a!=null)this.lineAnnotations=a}this.editSession=void 0;let{renderedFile:h,file:x}=this;if(this.fileRenderer.endEditSession(x),h!=null&&x!=null&&h!==x&&et(h,x))this.renderedFile=x;if(e&&this.fileContainer!=null)this.rerender();if(d)throw c}applyDocumentChange(e,t){let n=this.editSession?.file;if(n==null)throw Error("File.applyDocumentChange: requires an active edit session");if(this.fileRenderer.beginEditSession(n),this.fileRenderer.applyDocumentChange(e),t!=null)this.syncEditSessionAnnotationsFromEditor(t)}updateRenderCache(e,t,n){let r=this.editSession?.file;if(r==null)throw Error("File.updateRenderCache: requires an active edit session");this.fileRenderer.beginEditSession(r),this.fileRenderer.updateRenderCache(e,t,n?.lineCountChangeInFlight)}render({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:i,deferManagers:o=!1,lineAnnotations:s,renderRange:a}){if(!this.enabled)throw Error("File.render: attempting to call render after cleaned up");this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:l=!1,themeType:d="system"}=this.options,c=l?void 0:a,m=this.renderRange,p=this.hasThemeChanged(),h=s!=null&&(s.length>0||this.getLatestAnnotations().length>0)?this.isNewAnnotations(s):!1,x=!et(this.file,e);if(x)this.updateExternalFile(e,s);let I=this.getLatestFile(e)??e;if(!l&&!n&&ci(c,this.renderRange)&&!x&&!h&&!p){let b=this.applyCachedThemeState(d);if(b)this.finalizeRender();return b}if(this.renderRange=c,x)this.cachedHeaderHTML=void 0;if(this.fileRenderer.setOptions(Hf(this.options)),this.syncInteractionOptions(),s!=null)this.setLineAnnotations(s);this.fileRenderer.setLineAnnotations(this.getLatestAnnotations());let{disableErrorHandling:v=!1,disableFileHeader:S=!1}=this.options;if(S){if(this.headerElement!=null)this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0;this.clearHeaderSlots()}if(t=this.getOrCreateFileContainerNode(t,i),this.applyCachedThemeState(d),l){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let b=this.fileRenderer.renderFile(I,id);if(b!=null)this.applyThemeState(t,b.themeStyles,d,b.baseThemeType);if(b?.headerAST!=null)this.applyHeaderToDOM(b.headerAST,t,b.file);this.renderedFile=b?.file??I,this.injectUnsafeCSS()}catch(b){if(v)throw b;if(console.error(b),b instanceof Error)this.applyErrorToDOM(b,t)}if(this.finalizeRender(),!r)this.emitPostRender();return!0}try{let b=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,h,x||p||!et(this.renderedFile,I))||!this.applyPartialRender(I,m,c)){let E=this.fileRenderer.renderFile(I,c);if(E==null){if(this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool())this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender());return!1}if(this.applyThemeState(t,E.themeStyles,d,E.baseThemeType),E.headerAST!=null)this.applyHeaderToDOM(E.headerAST,t,E.file);this.applyFullRender(E,b),this.renderedFile=E.file}if(this.applyBuffers(b,c),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,!o)this.flushManagers();if(this.finalizeRender(),this.editor!=null)this.syncRenderViewToEditor()}catch(b){if(v)throw b;if(console.error(b),b instanceof Error)this.applyErrorToDOM(b,t)}if(!r)this.emitPostRender();return!0}finalizeRender(){}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted)return;if(this.mounted=!1,t==null)return;n?.(t,this,"unmount");return}if(t==null)return;let r=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){if(e||t||n)return!1;return!0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}async primeHighlightCache(e=this.file){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||Vo(e))return;let n=this.options.tokenizeMaxLength??1e5;if(this.fileRenderer.getOrCreateLineCache(e).length>n)return;await t.primeFileHighlightCache(e).catch((r)=>{console.error(r)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:r}of this.annotationCache.values())r.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options,n=this.getLatestAnnotations();if(t!=null&&n.length>0)for(let[r,i]of n.entries()){let o=this.getAnnotationSlotName(i),s=`${r}-${o}`,a=this.annotationCache.get(s);if(a==null||!gI(i,a.annotation)){a?.element.remove();let l=t(i);if(l==null)continue;a={element:Gu(o),annotation:i},a.element.appendChild(l),this.fileContainer.appendChild(a.element),this.annotationCache.set(s,a)}e.delete(s)}for(let[r,{element:i}]of e.entries())this.annotationCache.delete(r),i.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;else if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=ju();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t==null)return;if(e==null||e===""){if(this.unsafeCSSStyle!=null)this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0;this.appliedUnsafeCSS=void 0;return}if(this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e)return;if(this.unsafeCSSStyle??=qu(),this.unsafeCSSStyle.parentNode!==t)t.appendChild(this.unsafeCSSStyle);this.unsafeCSSStyle.textContent=Vu(e),this.appliedUnsafeCSS=e}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:"open"}),o=r??n,s=this.getTheme(),a=typeof s==="string"?s:{...s},l=mi(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===o&&this.appliedThemeCSS.scrollbarGutter===l){this.appliedThemeCSS.theme=a;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:a,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:l};return}this.themeCSSStyle=ed({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:Wu(t,o,l)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:a,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:l}:void 0}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;if(e==null||this.themeCSSStyle==null)return;this.themeCSSStyle.textContent=Xu(this.themeCSSStyle.textContent??"",mi(e))}shouldGuardRebuildScroll(){return this.editor!=null&&od()}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);let n=this.code=es({code:this.code}),r=this.fileRenderer.renderCodeAST(e);this.editor?.__captureFocusForDOMReplacement();let i=()=>{if(n.childElementCount>=2)for(let o=0;o<2;o++){let s=n.children[o],a=r[o];s.innerHTML=ut(a.children),s.style.cssText=a.properties.style}else n.innerHTML=ut(r);if(!t.contains(n))t.replaceChildren(n)};if(this.shouldGuardRebuildScroll())da(t,i);else i();this.lastRowCount=e.rowCount}applyPartialRender(e,t,n){if(t==null||n==null)return!1;let{code:r}=this,i=r!=null?this.getColumns(r):void 0;if(r==null||i==null)return!1;let o=t.startingLine,s=n.startingLine,a=t.totalLines===1/0?Number.POSITIVE_INFINITY:o+t.totalLines,l=n.totalLines===1/0?Number.POSITIVE_INFINITY:s+n.totalLines,d=Math.max(o,s),c=Math.min(a,l);if(c<=d)return!1;if(!this.trimDOMToOverlap(i.gutter,d,c)||!this.trimDOMToOverlap(i.content,d,c))throw Error("File.applyPartialRender: failed to trim to overlap");let{length:m}=i.content.children,p=(v,S)=>{if(S<=0)return;return this.fileRenderer.renderFile(e,{startingLine:v,totalLines:S,bufferBefore:0,bufferAfter:0})},h=s<d?p(s,d-s):void 0;if(h===void 0&&s<d)return!1;let x=l===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(0,l-c),I=l>c?p(c,x):void 0;if(I===void 0&&l>c)return!1;if(this.cleanupErrorWrapper(),h!=null)i.gutter.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(h.gutterAST)),i.content.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(h.contentAST)),m+=h.rowCount;if(I!=null)i.gutter.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(I.gutterAST)),i.content.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(I.contentAST)),m+=I.rowCount;if(this.lastRowCount!==m)i.gutter.style.setProperty("grid-row",`span ${m}`),i.content.style.setProperty("grid-row",`span ${m}`),this.lastRowCount=m;return!0}getColumns(e){let t=e.children[0],n=e.children[1];if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null)return;return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){let r=this.getDOMBoundaryIndices(e,[t,n]),i=r.get(t)??e.children.length,o=r.get(n)??e.children.length;if(i>o)return!1;for(let s=e.children.length-1;s>=o;s-=1)e.children[s]?.remove();for(let s=i-1;s>=0;s-=1)e.children[s]?.remove();return!0}getDOMBoundaryIndices(e,t){let n=[...new Set(t)].sort((a,l)=>a-l),r=new Map;if(n.length===0)return r;let i=0,o=n[i],{children:s}=e;if(o===0)r.set(0,0),i+=1,o=n[i];for(let a=0;a<s.length;a+=1){let l=s[a];if(!(l instanceof HTMLElement))continue;let d=this.getLineIndexFromDOMNode(l);if(d==null)continue;while(o!=null&&d>=o)r.set(o,a),i+=1,o=n[i];if(i>=n.length)break}for(let a of n)if(!r.has(a))r.set(a,s.length);return r}getLineIndexFromDOMNode(e){let t=e.dataset.lineIndex;if(t==null)return;let n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){if(this.bufferBefore!=null)this.bufferBefore.remove(),this.bufferBefore=void 0;if(this.bufferAfter!=null)this.bufferAfter.remove(),this.bufferAfter=void 0;return}if(t.bufferBefore>0){if(this.bufferBefore==null)this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore);this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")}else if(this.bufferBefore!=null)this.bufferBefore.remove(),this.bufferBefore=void 0;if(t.bufferAfter>0){if(this.bufferAfter==null)this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter);this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")}else if(this.bufferAfter!=null)this.bufferAfter.remove(),this.bufferAfter=void 0}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t,n){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let r=this.cachedHeaderHTML??ut(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let l=document.createElement("div");l.innerHTML=r;let d=l.firstElementChild;if(!(d instanceof HTMLElement))return;if(this.headerElement!=null)t.shadowRoot?.replaceChild(d,this.headerElement);else t.shadowRoot?.prepend(d);this.headerElement=d,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;let{renderHeaderPrefix:i,renderHeaderFilenameSuffix:o,renderCustomHeader:s,renderHeaderMetadata:a}=this.options;if(s!=null){let l=s(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Jo,l),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{let l=i?.(n)??void 0,d=o?.(n)??void 0,c=a?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Wo,l),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Xo,d),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,Yo,c),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);if(t==null)e.appendChild(i);return this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){if(e.replaceChildren(),t instanceof Element)e.appendChild(t);else e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement("div");return t.slot=e,t}getOrCreateFileContainerNode(e,t){let{fileContainer:n}=this,r=e??n??document.createElement("diffs-container"),i=n!==r;if(n!=null&&i)this.editor?.__captureFocusForDOMReplacement();if(i)this.emitPostRender(!0);if(this.fileContainer=r,n!=null&&i)this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0;if(t!=null&&this.fileContainer.parentNode!==t)t.appendChild(this.fileContainer);if(i)this.adoptReusableShellElements(this.fileContainer);return this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t==null)return;for(let n of t.children)if(n instanceof SVGElement)this.spriteSVG??=n;else if(ai(n)&&n.hasAttribute("data-theme-css"))this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0;else if(ai(n)&&n.hasAttribute("data-unsafe-css"))this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){let n=document.createElement("div");n.innerHTML=Uu;let r=n.firstChild;if(r instanceof SVGElement)this.spriteSVG=r}if(this.spriteSVG!=null&&this.spriteSVG.parentNode!==t)t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.pre==null)this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre);else if(this.pre.parentNode!==t)this.editor?.__captureFocusForDOMReplacement(),e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0;return this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;if(t.hasAttribute("data-code")){this.code=t;return}}}applyPreNodeAttributes(e,{totalLines:t}){let{overflow:n="scroll",disableLineNumbers:r=!1}=this.options,i={type:"file",split:!1,overflow:n,disableLineNumbers:r,diffIndicators:"none",disableBackground:!0,totalLines:t};if(Bu(i,this.appliedPreAttributes))return;nd(e,i),this.appliedPreAttributes=i}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);let r=document.createElement("div");r.dataset.errorMessage="",r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement("pre");i.dataset.errorStack="",i.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function iN(e,t,n=!1){return!n&&e==null&&t!=null}function oN(e,t,n=!1){return e==null&&t!=null&&!n}var sN=5000,sd=new Map,aN=-1;function lN(e,t){return(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS}var CI=class extends _f{virtualizer;metrics;__id=`virtualized-file:${++aN}`;renderType="virtualized";top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0,ghostTextRows:sd};pendingRender;isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n=Cu,r,i=!1){super(e,r,i);this.virtualizer=t,this.metrics=n}setMetrics(e,t=!1){let n=qo(e);if(!t&&ar(this.metrics,n))return;this.metrics=n,this.resetLayoutCache()}setLineAnnotations(e){if(this.syncLineAnnotations(e))this.resetLayoutCache()}syncLineAnnotations(e){if(e==null||!this.isNewAnnotations(e))return!1;if(e.length===0&&this.getLatestAnnotations().length===0)return!1;return super.setLineAnnotations(e),!0}syncEditSessionAnnotationsFromEditor(e){if(super.syncEditSessionAnnotationsFromEditor(e))return this.resetLayoutCache(),!0;return!1}hasLineAnnotations(){return this.getLatestAnnotations().some((e)=>e.lineNumber>0)}hasUniformLineHeights(){let{overflow:e="scroll"}=this.options;return e==="scroll"&&!this.hasLineAnnotations()&&this.cache.heights.size===0}getLineHeight(e,t=!1){let n=this.cache.heights.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(this.isAdvancedMode())throw Error("VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(e==null)return;let{options:t}=this,n=!Go(t,e),r=lN(t,e);if(super.setOptions(e),r)this.resetLayoutCache(!0);if(n)this.forceRenderOverride=!0;if(n)this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error("VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(e)}resetLayoutCache(e=!1,t=!0){if(this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0)this.cache.heights.clear();if(this.cache.checkpoints.length>0)this.cache.checkpoints.length=0;if(this.cache.ghostTextRows=sd,this.renderRange!=null&&t)this.renderRange=void 0;if(e&&this.isSimpleMode())this.computeApproximateSize()}applyGhostTextRows(e){let{heights:t,ghostTextRows:n}=this.cache;if(n===e)return!1;let{lineHeight:r}=this.metrics,i=!1;for(let o of new Set([...n.keys(),...e.keys()])){let s=n.get(o)??0,a=e.get(o)??0;if(a===s)continue;let l=(t.get(o)??r)-s*r+a*r;if(l===r)t.delete(o);else t.set(o,l);i=!0}return this.cache.ghostTextRows=e,i}reconcileHeights(){let e=!1;if(this.fileContainer==null||this.getLayoutFile()==null){if(this.height!==0)e=!0;return this.height=0,e}let{overflow:t="scroll"}=this.options;this.top=this.getVirtualizedTop();let n=this.editor?.__getGhostTextRows()??sd;if(e=this.applyGhostTextRows(n),t==="scroll"&&this.getLatestAnnotations().length===0&&!this.isResizeDebuggingEnabled()){if(e)this.computeApproximateSize(!0);return e}let{lineHeight:r}=this.metrics;if(this.code==null)return e;let i=this.code.children[1];if(!(i instanceof HTMLElement))return e;let o=na(this.getLatestAnnotations());if(this.renderRange!=null&&o&&li(this.renderRange)){let s=uN(i)??0;if(s!==this.cache.fileAnnotationHeight)this.cache.fileAnnotationHeight=s,e=!0}else if(!o&&this.cache.fileAnnotationHeight!==0)this.cache.fileAnnotationHeight=0,e=!0;for(let s of i.children){if(!(s instanceof HTMLElement))continue;let a=s.dataset.lineIndex;if(a==null)continue;let l=Number(a),d=s.getBoundingClientRect().height+(n.get(l)??0)*r,c=!1;if(s.nextElementSibling instanceof HTMLElement&&(("lineAnnotation"in s.nextElementSibling.dataset)||("noNewline"in s.nextElementSibling.dataset))){if("noNewline"in s.nextElementSibling.dataset)c=!0;d+=s.nextElementSibling.getBoundingClientRect().height}let m=this.getLineHeight(l,c);if(d===m)continue;if(e=!0,d===this.metrics.lineHeight*(c?2:1))this.cache.heights.delete(l);else this.cache.heights.set(l,d)}if(e||this.isResizeDebuggingEnabled())this.computeApproximateSize(!0);return e}onRender=(e)=>{if(this.fileContainer==null||this.file==null)return!1;if(e)this.top=this.getVirtualizedTop();return this.render({file:this.file})};updateCodeViewLayout(e,t,n,r){let i=!et(this.file,e);if(i)this.updateExternalFile(e,r);let{pendingRenderFile:o,layoutFileChanged:s,renderedFileChanged:a,annotationsChanged:l}=this.updatePendingRender(e,r),d=n?.resetFileLayoutCache===!0||s||l;if(n?.metrics!=null)this.metrics=n.metrics,d=!0;let{collapsed:c=!1}=this.options;if(this.currentCollapsed!==c)this.currentCollapsed=c,d=!0;if(d)this.resetLayoutCache();if(i)this.layoutDirty=!0;if(!this.forceRenderOverride&&(i||a||l))this.forceRenderOverride=!0;return this.top=t,this.computeApproximateSize(!1,o),this.height}getLayoutFile(){return this.pendingRender?.file??this.getRenderedFile()}getLinePosition(e){let t=this.getLayoutFile();if(t==null||e<1)return;let{disableFileHeader:n=!1,collapsed:r=!1}=this.options,i=this.fileRenderer.getLineCount(t)-1,o=En(this.metrics,n);if(r||i<0)return{top:o,height:0};let s=Math.min(Math.max(e-1,0),i),{lineHeight:a}=this.metrics;if(o+=this.cache.fileAnnotationHeight,this.hasUniformLineHeights())return{top:o+s*a,height:a};let l=this.getLayoutCheckpointBeforeLineIndex(s);o=l?.top??o;for(let d=l?.lineIndex??0;d<s;d++)o+=this.getLineHeight(d,!1);return{top:o,height:this.getLineHeight(s,!1)}}getEditorViewport(){return this.virtualizer.type==="simple"?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){let t=this.getLayoutFile();if(t==null||this.renderRange==null)return;let{disableFileHeader:n=!1,collapsed:r=!1}=this.options;if(r||this.renderRange.totalLines<=0)return;let i=this.fileRenderer.getLineCount(t)-1;if(i<0)return;let o=En(this.metrics,n),s=Math.min(this.renderRange.startingLine,i),a=Math.min(s+this.renderRange.totalLines-1,i);if(a<s)return;let{fileAnnotationHeight:l}=this.cache;if(this.hasUniformLineHeights()){let{lineHeight:c}=this.metrics,m=o+(s===0?l:this.renderRange.bufferBefore),p=s+Math.max(Math.ceil((e-m)/c),0);if(p>a)return;return{lineNumber:p+1,top:o+l+p*c}}let d=o+(s===0?l:this.renderRange.bufferBefore);for(let c=s;c<=a;c++){if(d>=e)return{lineNumber:c+1,top:d};d+=this.getLineHeight(c)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){let t=this.getLayoutFile();if(this.top==null||t==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let n=e!=null?this.computeRenderRangeFromWindow(t,this.top,e):this.renderRange;if(n==null)return;let{bufferBefore:r,bufferAfter:i,totalLines:o}=n,s=0;if(o===0){let a=e??this.virtualizer.getWindowSpecs();if(this.top<a.top)s=i}return{topOffset:this.top+r+s,height:this.height-(r+i)}}cleanUp(e=!1){let t=this.cache.ghostTextRows.size>0;if(t)this.layoutDirty=!0;let n=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(t||!et(this.getRenderedFile(),this.getLatestFile()));if(this.fileContainer!=null&&this.isSimpleMode())this.getSimpleVirtualizer()?.disconnect(this.fileContainer);if(!e)this.resetLayoutCache();if(this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),n)this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.getLayoutFile()){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],t==null){this.layoutDirty=!1;return}this.applyGhostTextRows(this.editor?.__getGhostTextRows()??sd);let{disableFileHeader:i=!1,collapsed:o=!1}=this.options,{lineHeight:s}=this.metrics,a=this.fileRenderer.getLineCount(t),l=En(this.metrics,i),d=Wi(this.metrics);if(this.height+=l,o){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,this.hasUniformLineHeights())this.height+=a*s;else for(let c=0;c<a;c++)this.addLayoutCheckpoint(c,this.height),this.height+=this.getLineHeight(c,!1);if(a>0)this.height+=d;if(this.fileContainer!=null&&n&&!r){let c=this.fileContainer.getBoundingClientRect();if(c.height!==this.height)console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match",{name:t.name,elementHeight:c.height,computedHeight:this.height});else console.log("VirtualizedFile.computeApproximateSize: computed height IS CORRECT")}this.layoutDirty=!1}setVisibility(e){if(this.isAdvancedMode()||this.fileContainer==null)return;if(this.renderRange=void 0,e&&!this.isVisible)this.top=this.getVirtualizedTop(),this.isVisible=!0;else if(!e&&this.isVisible)this.isVisible=!1,this.rerender()}rerender(){if(!this.enabled||this.file==null)return;let e=this.getLatestFile(),t=e==null?void 0:this.fileRenderer.getFileForNextRender(e);if(this.isSimpleMode())this.pendingRender=void 0;this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!et(this.getRenderedFile(),t))}syncGhostTextRows(){let e=this.getAdvancedVirtualizer();if(e!=null)e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0);else this.getSimpleVirtualizer()?.requestHeightReconcile(this)}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1);let i=this.getRenderedFile();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!=null&&i!=null){let o=this.virtualizer.getWindowSpecs(),s=this.computeRenderRangeFromWindow(i,this.top??0,o);if(s.bufferAfter!==r.bufferAfter)this.updateBuffers(s)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}render({fileContainer:e,file:t,forceRender:n=!1,lineAnnotations:r,...i}){let o=!et(this.file,t);if(o)this.updateExternalFile(t,r),this.cachedHeaderHTML=void 0;let{pendingRenderFile:s,layoutFileChanged:a,renderedFileChanged:l,annotationsChanged:d}=(()=>{if(this.pendingRender!=null&&this.pendingRender.latestFile===(this.getLatestFile(t)??t))return{pendingRenderFile:this.pendingRender.file,layoutFileChanged:!1,renderedFileChanged:!1,annotationsChanged:!1};return this.updatePendingRender(t,r)})(),{forceRenderOverride:c,isSetup:m}=this;if(this.forceRenderOverride=void 0,d||a)this.resetLayoutCache();if(e=this.getOrCreateFileContainerNode(e),!m){this.computeApproximateSize(!1,s);let I=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(I==null)throw Error("VirtualizedFile.render: simple virtualizer is not available");I.connect(e,this),this.isVisible=I.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}else if(this.top??=this.getVirtualizedTop(),a&&this.isSimpleMode())this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!1),this.computeApproximateSize(!1,s);if(!this.isVisible&&this.isSimpleMode()&&(!o||!m))return this.pendingRender=void 0,this.renderPlaceholder(this.height);let p=this.virtualizer.getWindowSpecs(),h=this.top??0,x=this.computeRenderRangeFromWindow(s,h,p);return super.render({file:t,fileContainer:e,renderRange:x,lineAnnotations:r,forceRender:(c??n)||d||l||o,...i})}finalizeRender(){if(this.getRenderedFile()!==this.pendingRender?.file)throw Error("VirtualizedFile.render: rendered a different file than its prepared layout");if(this.pendingRender=void 0,this.isSimpleMode())this.getSimpleVirtualizer()?.requestHeightReconcile(this)}updatePendingRender(e,t){let n=this.getLatestFile(e)??e,r=this.getRenderedFile(),i=this.pendingRender?.file??r,o=this.fileRenderer.getFileForNextRender(n);return this.pendingRender={latestFile:n,file:o},{pendingRenderFile:o,annotationsChanged:this.syncLineAnnotations(t),layoutFileChanged:!et(i,o),renderedFileChanged:!et(r,o)}}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}addLayoutCheckpoint(e,t){if(e%sN!==0)return;this.cache.checkpoints.push({lineIndex:e,top:t})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;while(t<=n){let i=t+n>>1,o=this.cache.checkpoints[i];if(o==null)throw Error("VirtualizedFile: invalid checkpoint index");if(o.lineIndex<=e)r=o,t=i+1;else n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;while(n<=r){let o=n+r>>1,s=this.cache.checkpoints[o];if(s==null)throw Error("VirtualizedFile: invalid checkpoint index");if(s.top<=e)i=o,n=o+1;else r=o-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let o=i;o>=0;o--){let s=this.cache.checkpoints[o];if(s==null)throw Error("VirtualizedFile: invalid checkpoint index");if(s.lineIndex%t===0)return s}}getVirtualizedTop(){if(this.virtualizer.type==="advanced")return this.virtualizer.getLocalTopForInstance(this);return this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type==="advanced"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1}=this.options,{hunkLineCount:o,lineHeight:s}=this.metrics,a=this.fileRenderer.getLineCount(e),l=this.height,d=En(this.metrics,i),c=a>0?Wi(this.metrics):0,{fileAnnotationHeight:m}=this.cache,p=d+m,h=Math.max(0,l-d-m-c),x=na(this.getLatestAnnotations()),I=t+d,v=m>0&&x&&I<r&&I+m>n;if(t<n-l||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-d-c};if(a<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};let S=Math.ceil(Math.max(r-n,0)/s),b=Math.ceil(S/o)*o+o,E=b/o,w=(n+r)/2;if(this.hasUniformLineHeights()){let gt=t+p,xn=gt+h;if(!v&&!(gt<r&&xn>n))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-d-c};let Rn=Math.floor(v&&w<t+p?0:(w-(t+p))/s),An=Math.floor(Rn/o)-Math.floor(E/2),Hi=Math.ceil(a/o),Zt=Math.max(0,Math.min(An,Hi))*o,wo=An<0?b+An*o:b,Bs=Zt===0?0:m+Zt*s,kr=Math.min(wo,a-Zt);return{startingLine:Zt,totalLines:wo,bufferBefore:Bs,bufferAfter:Math.max(0,(a-Zt-kr)*s)}}let T=E,L=[],R=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-b*s*2),o),A=t+(R?.top??p),O=R?.lineIndex??0,D,X,N,B=R?.lineIndex??0;for(let gt=B;gt<a;gt++){let xn=O%o===0,Rn=Math.floor(O/o);if(xn){if(L[Rn]=A-(t+p),N!=null){if(N<=0)break;N--}}let An=this.getLineHeight(gt,!1);if(A>n-An&&A<r)D??=Rn;if(A+An>w)X??=Rn;if(N==null&&A>=r&&xn)N=T;O++,A+=An}if(D==null)if(v)D=0,X=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-d-c};X??=D;let pe=Math.round(X-E/2),ye=Math.max(0,Math.ceil(a/o)-E),j=Math.max(0,Math.min(pe,ye)),ie=j*o,Ee=pe<0?b+pe*o:b,Mt=L[j]??0,Ie=ie===0?0:m+Mt,Me=j+Ee/o,Qe=Me<L.length?h-L[Me]:h-(A-t-p);return{startingLine:ie,totalLines:Ee,bufferBefore:Ie,bufferAfter:Math.max(0,Qe)}}};function uN(e){let t;for(let n of e.children){if(!(n instanceof HTMLElement))continue;if(n.dataset.lineAnnotation!==Eu)continue;t=Math.max(t??0,n.getBoundingClientRect().height)}return t}function ze(e,t){return e?.cacheKey!=null||t?.cacheKey!=null?e?.cacheKey===t?.cacheKey:e===t}function ad(e,t){return e?.cacheKey===t?.cacheKey&&e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}async function ca(e,t=300){let n;try{await Promise.race([e(),new Promise((r)=>{n=setTimeout(r,t)})])}finally{if(n!=null)clearTimeout(n)}}function ts(e){return[kt(e.additionStart,e.additionCount)+1,Tt(e.additionStart,e.additionCount)+1]}function cn({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:r,collapsedContextThreshold:i}){let o=Math.max(t,0);if(o===0||e)return{fromStart:0,fromEnd:0,rangeSize:o,collapsedLines:o,renderAll:!1};if(n===!0||o<=i)return{fromStart:o,fromEnd:0,rangeSize:o,collapsedLines:0,renderAll:!0};let s=n?.get(r),a=Math.min(Math.max(s?.fromStart??0,0),o),l=Math.min(Math.max(s?.fromEnd??0,0),o),d=a+l,c=d>=o;return{fromStart:c?o:a,fromEnd:c?0:l,rangeSize:o,collapsedLines:Math.max(o-d,0),renderAll:c}}function EI(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-Tt(t.additionStart,t.additionCount),r=e.deletionLines.length-Tt(t.deletionStart,t.deletionCount);if(n<=0&&r<=0)return!1;return n!==r}function Uf({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-Tt(n.additionStart,n.additionCount),i=e.deletionLines.length-Tt(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 mn({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let o=Uf({fileDiff:e,errorPrefix:i});if(o<=0)return;if(n===!0||o<=r)return{fromStart:o,fromEnd:0,rangeSize:o,collapsedLines:0,renderAll:!0};let s=n?.get(e.hunks.length),a=Math.min(Math.max(s?.fromStart??0,0),o);return{fromStart:a,fromEnd:0,rangeSize:o,collapsedLines:o-a,renderAll:a>=o}}function ld({fileDiff:e,lineNumber:t,expandedHunks:n,collapsedContextThreshold:r}){if(n===!0||e.isPartial)return!0;for(let[a,l]of e.hunks.entries()){let[d,c]=ts(l);if(t<d){let m=cn({isPartial:e.isPartial,rangeSize:l.collapsedBefore,expandedHunks:n,hunkIndex:a,collapsedContextThreshold:r}),p=d-m.rangeSize;return m.renderAll||t<p+m.fromStart||t>=d-m.fromEnd}if(t<c)return!0}let i=mn({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:"isAdditionLineRenderable"});if(i==null||i.renderAll)return!0;let o=e.hunks[e.hunks.length-1],[,s]=ts(o);return t<s+i.fromStart||t>=s+i.rangeSize}function vI({fileDiff:e,lineNumber:t,direction:n,expandedHunks:r,collapsedContextThreshold:i}){if(r===!0||e.isPartial)return t;let o=[],s=1;for(let[l,d]of e.hunks.entries()){let[c,m]=ts(d),p=cn({isPartial:e.isPartial,rangeSize:d.collapsedBefore,expandedHunks:r,hunkIndex:l,collapsedContextThreshold:i}),h=c-p.rangeSize;if(p.renderAll)o.push([h,c]);else{if(p.fromStart>0)o.push([h,h+p.fromStart]);if(p.fromEnd>0)o.push([c-p.fromEnd,c])}o.push([c,m]),s=m}let a=mn({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:i,errorPrefix:"getNearestRenderableAdditionLine"});if(a!=null){let l=s;if(s=l+a.rangeSize,a.renderAll)o.push([l,s]);else if(a.fromStart>0)o.push([l,l+a.fromStart])}if(t>=s)return t;if(n==="down"){for(let[l,d]of o)if(d>t)return Math.max(l,t);return}for(let l=o.length-1;l>=0;l--){let[d,c]=o[l];if(d<=t)return Math.min(c-1,t)}}function kI({type:e,metrics:t}){return t.hunkSeparatorHeight??Zx(e)}function TI({type:e,metrics:t}){return e==="simple"||e==="metadata"||e==="line-info-basic"?0:t.spacing}function dN({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 cN(e){return e!=="simple"&&e!=="metadata"}function Zi({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!dN({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=kI({type:e,metrics:t}),o=TI({type:e,metrics:t}),s=n>0?o:0,a=o;return{height:i,gapBefore:s,gapAfter:a,totalHeight:s+i+a}}function _r({type:e,metrics:t}){if(!cN(e))return;let n=kI({type:e,metrics:t}),r=TI({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function wI({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:o,collapsedContextThreshold:s,canHydratePartialDiff:a}){let l=En(t,n),d=l,c=i?!0:o,m=e.hunks.length-1;for(let p=0;p<e.hunks.length;p++){let h=e.hunks[p];if(h==null)throw Error("computeEstimatedDiffHeights: invalid hunk index");let x=cn({isPartial:e.isPartial,rangeSize:h.collapsedBefore,expandedHunks:c,hunkIndex:p,collapsedContextThreshold:s}),I=(x.fromStart+x.fromEnd)*t.lineHeight;if(l+=I,d+=I,x.collapsedLines>0){let b=Zi({type:r,metrics:t,hunkIndex:p,hunkSpecs:h.hunkSpecs})?.totalHeight??0;l+=b,d+=b}l+=h.splitLineCount*t.lineHeight,d+=h.unifiedLineCount*t.lineHeight;let v=mN(h);l+=v.split*t.lineHeight,d+=v.unified*t.lineHeight;let S=p===m?mn({fileDiff:e,hunkIndex:p,expandedHunks:c,collapsedContextThreshold:s,errorPrefix:"computeEstimatedDiffHeights"}):void 0;if(S!=null){let b=(S.fromStart+S.fromEnd)*t.lineHeight;if(l+=b,d+=b,S.collapsedLines>0){let E=_r({type:r,metrics:t})?.totalHeight??0;l+=E,d+=E}}else if(p===m&&e.isPartial&&a){let b=_r({type:r,metrics:t})?.totalHeight??0;l+=b,d+=b}}if(e.hunks.length>0){let p=Wi(t);l+=p,d+=p}return{splitHeight:l,unifiedHeight:d}}function mN(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};let t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type==="context"){let n=t.lines>0?1:0;return{split:n,unified:n}}return fN(e,t)}function fN(e,t){let n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),r=t.deletions>0&&e.noEOFCRDeletions,i=t.additions>0&&e.noEOFCRAdditions;return{split:r||i?1:0,unified:n}}function ma({oldFile:e,newFile:t},n){if(e===void 0&&t===void 0)return;if(e===void 0||t===void 0)throw Error(`${n}: Pass null for an intentionally missing oldFile or newFile side`);if(e===null){if(t===null)throw Error(`${n}: You must pass oldFile, newFile, or both`);return{oldFile:e,newFile:t}}if(t===null)return{oldFile:e,newFile:t};return{oldFile:e,newFile:t}}function ns(e){return e!==""?e.split(LI):[]}function fa(e,t,n){let r=e==="clone"?ud(t):t;if(!r.isPartial)throw Error("hydratePartialDiff: fileDiff must be partial");switch(r.type){case"change":case"rename-changed":return pN(r,gN(r,n),RI(r,n));case"rename-pure":{let i=RI(r,n);yN(r,n);let o=ns(i.contents);return r.isPartial=!1,r.deletionLines=o,r.additionLines=o,AI(r,null,i),r}}throw Error(`hydratePartialDiff: ${r.type} diffs cannot be hydrated from loaded files`)}function pN(e,t,n){let r=ns(t.contents),i=ns(n.contents),{hunks:o,splitLineCount:s,unifiedLineCount:a}=hN(e.hunks,i.length);return e.hunks=o,e.splitLineCount=s,e.unifiedLineCount=a,e.isPartial=!1,e.deletionLines=r,e.additionLines=i,AI(e,t,n),e}function hN(e,t){let n=0,r=0,i=0,o=[];for(let s of e){let a=Math.max(s.additionStart-1,0),l=Math.max(s.deletionStart-1,0),d=a,c=l,m=0,p=0,h=0,x=0,I=[];for(let S of s.hunkContent){if(S.type==="context"){I.push({...S,additionLineIndex:d,deletionLineIndex:c}),d+=S.lines,c+=S.lines,h+=S.lines,x+=S.lines;continue}I.push({...S,additionLineIndex:d,deletionLineIndex:c}),d+=S.additions,c+=S.deletions,m+=S.additions,p+=S.deletions,h+=Math.max(S.additions,S.deletions),x+=S.additions+S.deletions}let v=Math.max(kt(s.additionStart,s.additionCount)-i,0);o.push({...s,collapsedBefore:v,additionLineIndex:a,deletionLineIndex:l,additionLines:m,deletionLines:p,hunkContent:I,splitLineStart:n+v,unifiedLineStart:r+v,splitLineCount:h,unifiedLineCount:x}),n+=v+h,r+=v+x,i=Tt(s.additionStart,s.additionCount)}if(o.length>0){let s=o[o.length-1],a=Tt(s.additionStart,s.additionCount),l=Math.max(t-a,0);n+=l,r+=l}return{hunks:o,splitLineCount:n,unifiedLineCount:r}}function gN(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function RI(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function yN(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function xN(e,t,n){if(e.cacheKey!=null)return`${e.cacheKey}:hydrated`;return IN(t,n)}function AI(e,t,n){let r=xN(e,t,n);if(r==null){delete e.cacheKey;return}e.cacheKey=r}function IN(e,t){if(e!=null&&t!=null)return e.cacheKey!=null&&t.cacheKey!=null?Vi("hydrated-files",e.cacheKey,t.cacheKey):void 0;return e?.cacheKey??t?.cacheKey}function zn({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:o=1,callback:s}){let a=SN({diff:e,diffStyle:t,startingLine:n,expandedHunks:i,collapsedContextThreshold:o}),l={viewportStart:n,viewportEnd:n+r,isWindowedHighlight:n>0||r<1/0,splitCount:a.splitCount,unifiedCount:a.unifiedCount,finalHunkIndex:e.hunks.length-1,shouldBreak(){if(!l.isWindowedHighlight)return!1;let d=l.unifiedCount>=n+r,c=l.splitCount>=n+r;if(t==="unified")return d;else if(t==="split")return c;else return d&&c},shouldSkip(d,c){if(!l.isWindowedHighlight)return!1;let m=d>0&&l.unifiedCount+d<=n,p=c>0&&l.splitCount+c<=n;if(t==="unified")return m;else if(t==="split")return p;else return m&&p},incrementCounts(d,c){if(t==="unified"||t==="both")l.unifiedCount+=d;if(t==="split"||t==="both")l.splitCount+=c},isInWindow(d,c){if(!l.isWindowedHighlight)return!0;let m=l.isInUnifiedWindow(d),p=l.isInSplitWindow(c);if(t==="unified")return m;else if(t==="split")return p;else return m||p},isInUnifiedWindow(d){return!l.isWindowedHighlight||l.unifiedCount>=n-d&&l.unifiedCount<n+r},isInSplitWindow(d){return!l.isWindowedHighlight||l.splitCount>=n-d&&l.splitCount<n+r},emit(d,c=!1){if(!c)if(t==="unified")l.incrementCounts(1,0);else if(t==="split")l.incrementCounts(0,1);else l.incrementCounts(1,1);return s(d)??!1}};e:for(let d=a.hunkIndex;d<e.hunks.length;d++){let b=function(N,B){if(v==null||v.collapsedLines<=0||v.fromStart+v.fromEnd>0)return 0;if(t==="unified")return N===c.unifiedLineStart+c.unifiedLineCount-1?v.collapsedLines:0;return B===c.splitLineStart+c.splitLineCount-1?v.collapsedLines:0},w=function(){if(E)return 0;return E=!0,I.collapsedLines},c=e.hunks[d];if(c==null)throw Error("iterateOverDiff: invalid hunk index");if(l.shouldBreak())break;let m=kt(c.deletionStart,c.deletionCount),p=kt(c.additionStart,c.additionCount),h=!e.isPartial&&c.deletionCount===0?m:c.deletionLineIndex,x=!e.isPartial&&c.additionCount===0?p:c.additionLineIndex,I=cn({isPartial:e.isPartial,rangeSize:c.collapsedBefore,expandedHunks:i,hunkIndex:d,collapsedContextThreshold:o}),v=d===l.finalHunkIndex?mn({fileDiff:e,hunkIndex:d,expandedHunks:i,collapsedContextThreshold:o,errorPrefix:"iterateOverDiff"}):void 0,S=I.fromStart+I.fromEnd,E=I.collapsedLines===0;if(!l.shouldSkip(S,S)){let N=c.unifiedLineStart-I.rangeSize,B=c.splitLineStart-I.rangeSize,pe=h-I.rangeSize,ye=x-I.rangeSize,j=m+1-I.rangeSize,ie=p+1-I.rangeSize;if(dd(l,I.fromStart,t,(Ee)=>l.emit({hunkIndex:d,hunk:c,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:j+Ee,lineIndex:pe+Ee,noEOFCR:!1,unifiedLineIndex:N+Ee,splitLineIndex:B+Ee},additionLine:{unifiedLineIndex:N+Ee,splitLineIndex:B+Ee,lineIndex:ye+Ee,lineNumber:ie+Ee,noEOFCR:!1}})))break e;if(N=c.unifiedLineStart-I.fromEnd,B=c.splitLineStart-I.fromEnd,pe=h-I.fromEnd,ye=x-I.fromEnd,j=m+1-I.fromEnd,ie=p+1-I.fromEnd,dd(l,I.fromEnd,t,(Ee)=>l.emit({hunkIndex:d,hunk:c,collapsedBefore:w(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:j+Ee,lineIndex:pe+Ee,noEOFCR:!1,unifiedLineIndex:N+Ee,splitLineIndex:B+Ee},additionLine:{unifiedLineIndex:N+Ee,splitLineIndex:B+Ee,lineIndex:ye+Ee,lineNumber:ie+Ee,noEOFCR:!1}}),()=>{w()}))break e}else l.incrementCounts(S,S),w();let{unifiedLineStart:T,splitLineStart:L}=c,R=h,A=x,O=m+1,D=p+1,X=c.hunkContent.at(-1);for(let N of c.hunkContent){if(l.shouldBreak())break e;let B=N===X;if(N.type==="context"){if(!l.shouldSkip(N.lines,N.lines)){if(dd(l,N.lines,t,(pe)=>{let ye=B&&pe===N.lines-1,j=T+pe,ie=L+pe;return l.emit({hunkIndex:d,hunk:c,collapsedBefore:w(),collapsedAfter:b(j,ie),type:"context",deletionLine:{lineNumber:O+pe,lineIndex:R+pe,noEOFCR:ye&&c.noEOFCRDeletions,unifiedLineIndex:j,splitLineIndex:ie},additionLine:{unifiedLineIndex:j,splitLineIndex:ie,lineIndex:A+pe,lineNumber:D+pe,noEOFCR:ye&&c.noEOFCRAdditions}})},()=>{w()}))break e}else l.incrementCounts(N.lines,N.lines),w();T+=N.lines,L+=N.lines,R+=N.lines,A+=N.lines,O+=N.lines,D+=N.lines}else{let pe=Math.max(N.deletions,N.additions),ye=N.deletions+N.additions;if(!l.shouldSkip(ye,pe)){let j=EN(l,N,t);if((j[0]?.[0]??0)>0)w();for(let[ie,Ee]of j)for(let Mt=ie;Mt<Ee;Mt++){let Ie=b(T+Mt,t==="unified"?L+(Mt<N.deletions?Mt:Mt-N.deletions):L+Mt);if(l.emit(vN({hunkIndex:d,hunk:c,collapsedBefore:w(),collapsedAfter:Ie,diffStyle:t,index:Mt,unifiedLineIndex:T,splitLineIndex:L,additionLineIndex:A,deletionLineIndex:R,additionLineNumber:D,deletionLineNumber:O,content:N,isLastContent:B,unifiedCount:ye,splitCount:pe}),!0))break e}}w(),l.incrementCounts(ye,pe),T+=ye,L+=pe,R+=N.deletions,A+=N.additions,O+=N.deletions,D+=N.additions}}if(v!=null){let{collapsedLines:N,fromStart:B,fromEnd:pe}=v,ye=B+pe;if(dd(l,ye,t,(j)=>{let ie=j===ye-1;return l.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:ie?N:0,type:"context-expanded",deletionLine:{lineNumber:O+j,lineIndex:R+j,noEOFCR:!1,unifiedLineIndex:T+j,splitLineIndex:L+j},additionLine:{unifiedLineIndex:T+j,splitLineIndex:L+j,lineIndex:A+j,lineNumber:D+j,noEOFCR:!1}})},void 0,()=>l.shouldBreak()))break e}}}function SN({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t==="both")return{hunkIndex:0,splitCount:0,unifiedCount:0};let o=bN({diff:e,expandedHunks:r,collapsedContextThreshold:i}),s=0,a=e.hunks.length-1,l=e.hunks.length;while(s<=a){let c=s+a>>1,m=o[c+1];if(m==null)throw Error("iterateOverDiff: invalid hunk prefix index");if((t==="unified"?m.unifiedCount:m.splitCount)>n)l=c,a=c-1;else s=c+1}if(l>=e.hunks.length){let c=o[e.hunks.length];if(c==null)throw Error("iterateOverDiff: invalid terminal hunk prefix index");return{hunkIndex:e.hunks.length,splitCount:c.splitCount,unifiedCount:c.unifiedCount}}let d=o[l];if(d==null)throw Error("iterateOverDiff: invalid selected hunk prefix index");return{hunkIndex:l,splitCount:d.splitCount,unifiedCount:d.unifiedCount}}function bN({diff:e,expandedHunks:t,collapsedContextThreshold:n}){let r=0,i=0,o=e.hunks.length-1,s=[{splitCount:0,unifiedCount:0}];for(let a=0;a<e.hunks.length;a++){let l=e.hunks[a];if(l==null)throw Error("iterateOverDiff: invalid hunk summary index");let d=cn({isPartial:e.isPartial,rangeSize:l.collapsedBefore,expandedHunks:t,hunkIndex:a,collapsedContextThreshold:n}),c=d.fromStart+d.fromEnd;r+=c+l.splitLineCount,i+=c+l.unifiedLineCount;let m=a===o?mn({fileDiff:e,hunkIndex:a,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:"iterateOverDiff"}):void 0;if(m!=null){let p=m.fromStart+m.fromEnd;r+=p,i+=p}s.push({splitCount:r,unifiedCount:i})}return s}function CN(e,t,n){if(!e.isWindowedHighlight||t<=0)return[0,t];let r=[];function i(a){let l=Math.max(0,e.viewportStart-a),d=Math.min(t,e.viewportEnd-a);if(d>l)r.push([l,d])}if(n!=="split")i(e.unifiedCount);if(n!=="unified")i(e.splitCount);if(r.length===0)return[0,0];let o=r[0][0],s=r[0][1];for(let a=1;a<r.length;a++){let l=r[a];o=Math.min(o,l[0]),s=Math.max(s,l[1])}return[o,s]}function dd(e,t,n,r,i,o){let[s,a]=CN(e,t,n);if(s>0)e.incrementCounts(s,s),i?.();let l=s;while(l<t){if(o?.()===!0)return!0;if(l>=a){e.incrementCounts(t-l,t-l);break}if(e.isInWindow(0,0)){if(r(l)===!0)return!0}else e.incrementCounts(1,1);l++}return!1}function EN(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",o=n==="unified"?"unified":"split",s=[];function a(m,p){if(m+p<=e.viewportStart||m>=e.viewportEnd)return;let h=Math.max(0,e.viewportStart-m),x=Math.min(p,e.viewportEnd-m);return x>h?[h,x]:void 0}function l(m,p){if(o==="split")return m;return p==="additions"?[m[0]+t.deletions,m[1]+t.deletions]:m}function d(m,p){if(m==null)return;let[h,x]=l(m,p);if(x>h)s.push([h,x])}if(r)d(a(e.unifiedCount,t.deletions),"deletions"),d(a(e.unifiedCount+t.deletions,t.additions),"additions");if(i)d(a(e.splitCount,t.deletions),"deletions"),d(a(e.splitCount,t.additions),"additions");if(s.length===0)return s;s.sort((m,p)=>m[0]-p[0]);let c=[s[0]];for(let[m,p]of s.slice(1)){let h=c[c.length-1];if(m<=h[1])h[1]=Math.max(h[1],p);else c.push([m,p])}return c}function vN({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,diffStyle:i,index:o,unifiedLineIndex:s,splitLineIndex:a,additionLineIndex:l,deletionLineIndex:d,additionLineNumber:c,deletionLineNumber:m,content:p,isLastContent:h,unifiedCount:x,splitCount:I}){let v=o<p.deletions?s+o:void 0,S=i==="unified"?o>=p.deletions?s+o:void 0:o<p.additions?s+p.deletions+o:void 0,b=i==="unified"?a+(o<p.deletions?o:o-p.deletions):a+o,E=o<p.deletions?d+o:void 0,w=o<p.deletions?m+o:void 0,T=i==="unified"?o>=p.deletions?l+(o-p.deletions):void 0:o<p.additions?l+o:void 0,L=i==="unified"?o>=p.deletions?c+(o-p.deletions):void 0:o<p.additions?c+o:void 0,R=i==="unified"?h&&o===p.deletions-1&&t.noEOFCRDeletions:h&&o===I-1&&t.noEOFCRDeletions,A=i==="unified"?h&&o===x-1&&t.noEOFCRAdditions:h&&o===I-1&&t.noEOFCRAdditions,O=E!=null&&w!=null&&v!=null?{lineNumber:w,lineIndex:E,noEOFCR:R,unifiedLineIndex:v,splitLineIndex:b}:void 0,D=T!=null&&L!=null&&S!=null?{unifiedLineIndex:S,splitLineIndex:b,lineIndex:T,lineNumber:L,noEOFCR:A}:void 0;if(O==null&&D!=null)return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:D};else if(O!=null&&D==null)return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:O,additionLine:void 0};if(O==null||D==null)throw Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:O,additionLine:D}}class Ur{diff(e,t,n={}){let r;if(typeof n==="function")r=n,n={};else if("callback"in n)r=n.callback;let i=this.castInput(e,n),o=this.castInput(t,n),s=this.removeEmpty(this.tokenize(i,n)),a=this.removeEmpty(this.tokenize(o,n));return this.diffWithOptionsObj(s,a,n,r)}diffWithOptionsObj(e,t,n,r){var i;let o=(S)=>{if(S=this.postProcess(S,n),r){setTimeout(function(){r(S)},0);return}else return S},s=t.length,a=e.length,l=1,d=s+a;if(n.maxEditLength!=null)d=Math.min(d,n.maxEditLength);let c=(i=n.timeout)!==null&&i!==void 0?i:1/0,m=Date.now()+c,p=[{oldPos:-1,lastComponent:void 0}],h=this.extractCommon(p[0],t,e,0,n);if(p[0].oldPos+1>=a&&h+1>=s)return o(this.buildValues(p[0].lastComponent,t,e));let x=-1/0,I=1/0,v=()=>{for(let S=Math.max(x,-l);S<=Math.min(I,l);S+=2){let b,E=p[S-1],w=p[S+1];if(E)p[S-1]=void 0;let T=!1;if(w){let R=w.oldPos-S;T=w&&0<=R&&R<s}let L=E&&E.oldPos+1<a;if(!T&&!L){p[S]=void 0;continue}if(!L||T&&E.oldPos<w.oldPos)b=this.addToPath(w,!0,!1,0,n);else b=this.addToPath(E,!1,!0,1,n);if(h=this.extractCommon(b,t,e,S,n),b.oldPos+1>=a&&h+1>=s)return o(this.buildValues(b.lastComponent,t,e))||!0;else{if(p[S]=b,b.oldPos+1>=a)I=Math.min(I,S-1);if(h+1>=s)x=Math.max(x,S+1)}}l++};if(r)(function S(){setTimeout(function(){if(l>d||Date.now()>m)return r(void 0);if(!v())S()},0)})();else while(l<=d&&Date.now()<=m){let S=v();if(S)return S}}addToPath(e,t,n,r,i){let o=e.lastComponent;if(o&&!i.oneChangePerToken&&o.added===t&&o.removed===n)return{oldPos:e.oldPos+r,lastComponent:{count:o.count+1,added:t,removed:n,previousComponent:o.previousComponent}};else return{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:o}}}extractCommon(e,t,n,r,i){let o=t.length,s=n.length,a=e.oldPos,l=a-r,d=0;while(l+1<o&&a+1<s&&this.equals(n[a+1],t[l+1],i))if(l++,a++,d++,i.oneChangePerToken)e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1};if(d&&!i.oneChangePerToken)e.lastComponent={count:d,previousComponent:e.lastComponent,added:!1,removed:!1};return e.oldPos=a,l}equals(e,t,n){if(n.comparator)return n.comparator(e,t);else return e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)if(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;while(e)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let o=r.length,s=0,a=0,l=0;for(;s<o;s++){let d=r[s];if(!d.removed){if(!d.added&&this.useLongestToken){let c=t.slice(a,a+d.count);c=c.map(function(m,p){let h=n[l+p];return h.length>m.length?h:m}),d.value=this.join(c)}else d.value=this.join(t.slice(a,a+d.count));if(a+=d.count,!d.added)l+=d.count}else d.value=this.join(n.slice(l,l+d.count)),l+=d.count}return r}}class PI extends Ur{}var $I=new PI;function Bf(e,t,n){return $I.diff(e,t,n)}function Gf(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 jf(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 cd(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 md(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 rs(e,t){return cd(e,t,"")}function pa(e,t){return md(e,t,"")}function qf(e,t){return t.slice(0,kN(e,t))}function kN(e,t){let n=0;if(e.length>t.length)n=e.length-t.length;let r=t.length;if(e.length<t.length)r=e.length;let i=Array(r),o=0;i[0]=0;for(let s=1;s<r;s++){if(t[s]==t[o])i[s]=i[o];else i[s]=o;while(o>0&&t[s]!=t[o])o=i[o];if(t[s]==t[o])o++}o=0;for(let s=n;s<e.length;s++){while(o>0&&e[s]!=t[o])o=i[o];if(e[s]==t[o])o++}return o}function zf(e,t){let n=[];for(let r of Array.from(t.segment(e))){let i=r.segment;if(n.length&&/\s/.test(n[n.length-1])&&/\s/.test(i))n[n.length-1]+=i;else n.push(i)}return n}function fd(e,t){if(t)return is(e,t)[1];let n;for(n=e.length-1;n>=0;n--)if(!e[n].match(/\s/))break;return e.substring(n+1)}function Qi(e,t){if(t)return is(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:""}function is(e,t){if(!t)return[Qi(e),fd(e)];if(t.resolvedOptions().granularity!="word")throw Error('The segmenter passed must have a granularity of "word"');let n=zf(e,t),r=n[0],i=n[n.length-1],o=/\s/.test(r)?r:"",s=/\s/.test(i)?i:"";return[o,s]}var pd="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}",TN=new RegExp(`[${pd}]+|\\s+|[^${pd}]`,"ug");class OI extends Ur{equals(e,t,n){if(n.ignoreCase)e=e.toLowerCase(),t=t.toLowerCase();return e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let o=t.intlSegmenter;if(o.resolvedOptions().granularity!="word")throw Error('The segmenter passed must have a granularity of "word"');n=zf(e,o)}else n=e.match(TN)||[];let r=[],i=null;return n.forEach((o)=>{if(/\s/.test(o))if(i==null)r.push(o);else r.push(r.pop()+o);else if(i!=null&&/\s/.test(i))if(r[r.length-1]==i)r.push(r.pop()+o);else r.push(i+o);else r.push(o);i=o}),r}join(e){return e.map((t,n)=>{if(n==0)return t;else return t.replace(/^\s+/,"")}).join("")}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;if(e.forEach((o)=>{if(o.added)r=o;else if(o.removed)i=o;else{if(r||i)MI(n,i,r,o,t.intlSegmenter);n=o,r=null,i=null}}),r||i)MI(n,i,r,null,t.intlSegmenter);return e}}var wN=new OI;function MI(e,t,n,r,i){if(t&&n){let[o,s]=is(t.value,i),[a,l]=is(n.value,i);if(e){let d=Gf(o,a);e.value=md(e.value,a,d),t.value=rs(t.value,d),n.value=rs(n.value,d)}if(r){let d=jf(s,l);r.value=cd(r.value,l,d),t.value=pa(t.value,d),n.value=pa(n.value,d)}}else if(n){if(e){let o=Qi(n.value,i);n.value=n.value.substring(o.length)}if(r){let o=Qi(r.value,i);r.value=r.value.substring(o.length)}}else if(e&&r){let o=Qi(r.value,i),[s,a]=is(t.value,i),l=Gf(o,s);t.value=rs(t.value,l);let d=jf(rs(o,l),a);t.value=pa(t.value,d),r.value=cd(r.value,o,d),e.value=md(e.value,o,o.slice(0,o.length-d.length))}else if(r){let o=Qi(r.value,i),s=fd(t.value,i),a=qf(s,o);t.value=pa(t.value,a)}else if(e){let o=fd(e.value,i),s=Qi(t.value,i),a=qf(o,s);t.value=rs(t.value,a)}}class FI extends Ur{tokenize(e){let t=new RegExp(`(\\r?\\n)|[${pd}]+|[^\\S\\n\\r]+|[^${pd}]`,"ug");return e.match(t)||[]}}var NI=new FI;function Kf(e,t,n){return NI.diff(e,t,n)}class DI extends Ur{constructor(){super(...arguments);this.tokenize=RN}equals(e,t,n){if(n.ignoreWhitespace){if(!n.newlineIsToken||!e.includes(`
|
|
1509
1509
|
`))e=e.trim();if(!n.newlineIsToken||!t.includes(`
|
|
1510
1510
|
`))t=t.trim()}else if(n.ignoreNewlineAtEof&&!n.newlineIsToken){if(e.endsWith(`
|
|
1511
1511
|
`))e=e.slice(0,-1);if(t.endsWith(`
|
|
1512
|
-
`))t=t.slice(0,-1)}return super.equals(e,t,n)}}var
|
|
1513
|
-
`);let n=[],r=e.split(/(\n|\r\n)/);if(!r[r.length-1])r.pop();for(let i=0;i<r.length;i++){let o=r[i];if(i%2&&!t.newlineIsToken)n[n.length-1]+=o;else n.push(o)}return n}function
|
|
1514
|
-
`))b.lines[E]=b.lines[E].slice(0,-1);else b.lines.splice(E+1,0,"\"),E++;return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:o,hunks:p}}}function
|
|
1515
|
-
`)}let l=[];if(e.isGit){if(t=
|
|
1512
|
+
`))t=t.slice(0,-1)}return super.equals(e,t,n)}}var LN=new DI;function Vf(e,t,n){return LN.diff(e,t,n)}function RN(e,t){if(t.stripTrailingCr)e=e.replace(/\r\n/g,`
|
|
1513
|
+
`);let n=[],r=e.split(/(\n|\r\n)/);if(!r[r.length-1])r.pop();for(let i=0;i<r.length;i++){let o=r[i];if(i%2&&!t.newlineIsToken)n[n.length-1]+=o;else n.push(o)}return n}function AN(e){for(let t=0;t<e.length;t++)if(e[t]<" "||e[t]>"~"||e[t]==='"'||e[t]==="\\")return!0;return!1}function fi(e){if(!AN(e))return e;let t='"',n=new TextEncoder().encode(e),r=0;while(r<n.length){let i=n[r];if(i===7)t+="\\a";else if(i===8)t+="\\b";else if(i===9)t+="\\t";else if(i===10)t+="\\n";else if(i===11)t+="\\v";else if(i===12)t+="\\f";else if(i===13)t+="\\r";else if(i===34)t+="\\\"";else if(i===92)t+="\\\\";else if(i>=32&&i<=126)t+=String.fromCharCode(i);else t+="\\"+i.toString(8).padStart(3,"0");r++}return t+='"',t}var Wf={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function Xf(e,t,n,r,i,o,s){let a;if(!s)a={};else if(typeof s==="function")a={callback:s};else a=s;if(typeof a.context>"u")a.context=4;let l=a.context;if(a.newlineIsToken)throw Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(!a.callback)return d(Vf(n,r,a));else{let{callback:c}=a;Vf(n,r,Object.assign(Object.assign({},a),{callback:(m)=>{let p=d(m);c(p)}}))}function d(c){if(!c)return;c.push({value:"",lines:[]});function m(b){return b.map(function(E){return" "+E})}let p=[],h=0,x=0,I=[],v=1,S=1;for(let b=0;b<c.length;b++){let E=c[b],w=E.lines||PN(E.value);if(E.lines=w,E.added||E.removed){if(!h){let T=c[b-1];if(h=v,x=S,T)I=l>0?m(T.lines.slice(-l)):[],h-=I.length,x-=I.length}for(let T of w)I.push((E.added?"+":"-")+T);if(E.added)S+=w.length;else v+=w.length}else{if(h)if(w.length<=l*2&&b<c.length-2)for(let T of m(w))I.push(T);else{let T=Math.min(w.length,l);for(let R of m(w.slice(0,T)))I.push(R);let L={oldStart:h,oldLines:v-h+T,newStart:x,newLines:S-x+T,lines:I};p.push(L),h=0,x=0,I=[]}v+=w.length,S+=w.length}}for(let b of p)for(let E=0;E<b.lines.length;E++)if(b.lines[E].endsWith(`
|
|
1514
|
+
`))b.lines[E]=b.lines[E].slice(0,-1);else b.lines.splice(E+1,0,"\"),E++;return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:o,hunks:p}}}function hd(e,t){var n,r,i,o,s,a;if(!t)t=Wf;if(Array.isArray(e)){if(e.length>1&&!t.includeFileHeaders&&!e.every((c)=>c.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((c)=>hd(c,t)).join(`
|
|
1515
|
+
`)}let l=[];if(e.isGit){if(t=Wf,!e.oldFileName)throw Error("oldFileName must be specified for Git patches");if(!e.newFileName)throw Error("newFileName must be specified for Git patches");let{oldFileName:c,newFileName:m}=e;if(e.isCreate&&c==="/dev/null")c=m.replace(/^b\//,"a/");else if(e.isDelete&&m==="/dev/null")m=c.replace(/^a\//,"b/");if(l.push("diff --git "+fi(c)+" "+fi(m)),e.isDelete)l.push("deleted file mode "+((n=e.oldMode)!==null&&n!==void 0?n:"100644"));if(e.isCreate)l.push("new file mode "+((r=e.newMode)!==null&&r!==void 0?r:"100644"));if(e.oldMode&&e.newMode&&!e.isDelete&&!e.isCreate)l.push("old mode "+e.oldMode),l.push("new mode "+e.newMode);if(e.isRename)l.push("rename from "+fi(((i=e.oldFileName)!==null&&i!==void 0?i:"").replace(/^a\//,""))),l.push("rename to "+fi(((o=e.newFileName)!==null&&o!==void 0?o:"").replace(/^b\//,"")));if(e.isCopy)l.push("copy from "+fi(((s=e.oldFileName)!==null&&s!==void 0?s:"").replace(/^a\//,""))),l.push("copy to "+fi(((a=e.newFileName)!==null&&a!==void 0?a:"").replace(/^b\//,"")))}else{if(t.includeIndex&&e.oldFileName==e.newFileName&&e.oldFileName!==void 0)l.push("Index: "+e.oldFileName);if(t.includeUnderline)l.push("===================================================================")}let d=e.hunks.length>0;if(t.includeFileHeaders&&e.oldFileName!==void 0&&e.newFileName!==void 0&&(!e.isGit||d))l.push("--- "+fi(e.oldFileName)+(e.oldHeader?"\t"+e.oldHeader:"")),l.push("+++ "+fi(e.newFileName)+(e.newHeader?"\t"+e.newHeader:""));for(let c=0;c<e.hunks.length;c++){let m=e.hunks[c],p=m.oldLines===0?m.oldStart-1:m.oldStart,h=m.newLines===0?m.newStart-1:m.newStart;l.push("@@ -"+p+","+m.oldLines+" +"+h+","+m.newLines+" @@");for(let x of m.lines)l.push(x)}return l.join(`
|
|
1516
1516
|
`)+`
|
|
1517
|
-
`}function
|
|
1517
|
+
`}function Yf(e,t,n,r,i,o,s){if(typeof s==="function")s={callback:s};if(!(s===null||s===void 0?void 0:s.callback)){let a=Xf(e,t,n,r,i,o,s);if(!a)return;return hd(a,s===null||s===void 0?void 0:s.headerOptions)}else{let{callback:a}=s;Xf(e,t,n,r,i,o,Object.assign(Object.assign({},s),{callback:(l)=>{if(!l)a(void 0);else a(hd(l,s.headerOptions))}}))}}function PN(e){let t=e.endsWith(`
|
|
1518
1518
|
`),n=e.split(`
|
|
1519
1519
|
`).map((r)=>r+`
|
|
1520
|
-
`);if(t)n.pop();else n.push(n.pop().slice(0,-1));return n}var
|
|
1520
|
+
`);if(t)n.pop();else n.push(n.pop().slice(0,-1));return n}var $N="/dev/null";function Kn(e,t,n,r=!1){if(e===null&&t===null)throw Error("parseDiffFromFile: You must pass oldFile, newFile, or both");let i=e??HI(),o=t??HI(),s=Yf(i.name,o.name,i.contents,o.contents,i.header,o.header,n),a=Pf(s,{cacheKey:(()=>{let d=e?.cacheKey,c=t?.cacheKey;return d!=null&&c!=null?Vi("diff",d,c):void 0})(),oldFile:i,newFile:o,throwOnError:r});if(a==null)throw Error("parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?");if(e===null)a.type="new",a.prevName=void 0;else if(t===null)a.type="deleted",a.prevName=void 0;let l=t?.lang??(t===null?e?.lang:void 0);if(l!=null)a.lang=l;return a}function HI(){return{name:$N,contents:""}}var _I=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){if(!this.enabled)return;this.codeDeletions?.removeEventListener("scroll",this.handleDeletionsScroll),this.codeAdditions?.removeEventListener("scroll",this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,this.enabled=!1}setup(e,t,n){if(t==null||n==null)for(let r of e.children??[]){if(!(r instanceof HTMLElement))continue;if("deletions"in r.dataset)t=r;else if("additions"in r.dataset)n=r}if(n==null||t==null){this.cleanUp();return}if(this.codeDeletions!==t)this.codeDeletions?.removeEventListener("scroll",this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener("scroll",this.handleDeletionsScroll,{passive:!0});if(this.codeAdditions!==n)this.codeAdditions?.removeEventListener("scroll",this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener("scroll",this.handleAdditionsScroll,{passive:!0});this.enabled=!0}handleDeletionsScroll=()=>{if(this.isAdditionsScrolling)return;this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft})};handleAdditionsScroll=()=>{if(this.isDeletionsScrolling)return;this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft})}};function lr(e,t){let n=Kn({name:e.prevName??e.name,contents:e.deletionLines.join("")},{name:e.name,contents:e.additionLines.join(""),lang:e.lang},t);return{hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,additionLines:n.additionLines,deletionLines:n.deletionLines,type:n.type}}function MN(e,t){let n=Math.max(e,1),r=Array.from({length:n},(i,o)=>`${" ".repeat(o+1)}
|
|
1521
1521
|
`).join("");if(r===t)r=Array.from({length:n},(i,o)=>`\x00${" ".repeat(o)}
|
|
1522
|
-
`).join("");return r}function
|
|
1522
|
+
`).join("");return r}function ON(e){for(let t of e)if(t.trim().length>0)return!1;return!0}function gd(e,t){return t.length>0&&t.length<e.deletionLines.length&&ON(t)}function ha(e,t,n){let r=e.deletionLines.join(""),i=MN(t.length,r),o=Kn({name:e.prevName??e.name,contents:r},{name:e.name,contents:i,lang:e.lang},n);return{hunks:o.hunks,splitLineCount:o.splitLineCount,unifiedLineCount:o.unifiedLineCount,additionLines:t,deletionLines:o.deletionLines,type:o.type}}function ga(e,t){return ha(e,[""],t)}function yd(e,t){if(e.additionLines.length===0)return ga(e,t);if(gd(e,e.additionLines))return ha(e,e.additionLines,t);let n=e.additionLines,r=lr(e,t);return Jf(r,n),r}function FN(e){return e.length>1&&e.at(-1)===""}function Jf(e,t){if(!FN(t))return;let n=t.length-e.additionLines.length;if(n<=0)return;let r=e.additionLines.length,i=e.hunks.at(-1);if(i==null)return;if(Tt(i.additionStart,i.additionCount)!==r)return;for(let o of i.hunkContent)if(o.type==="change"&&o.additions<o.deletions&&o.additionLineIndex+o.additions===r){e.additionLines=t,o.additions+=n,i.additionCount+=n,i.additionLines+=n,os(e);return}}function UI(e,t,n){if(e.isPartial)return Br(e,lr(e,n));if(e.deletionLines.length!==e.additionLines.length)return Br(e,lr(e,n));let r=Array.from(t);if(r.length===0)return Br(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type});for(let o of r){let s=e.additionLines[o],a=e.deletionLines[o];if(s==null||a==null)return Br(e,lr(e,n));if(bn(s)===bn(a))return Br(e,lr(e,n))}let i=NN(e,r);if(i.size===0)return Br(e,lr(e,n));for(let o of i)if(!HN(e,o,n))return Br(e,lr(e,n));if(os(e),EI(e))return Br(e,lr(e,n));return Br(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type})}function Br(e,t){return Object.assign(e,t),t}function NN(e,t){let n=new Set;for(let r of t){let i=DN(e,r);if(i==null)return new Set;n.add(i)}return n}function DN(e,t){for(let[n,r]of e.hunks.entries()){let i=r.additionLineIndex+r.additionCount;if(t>=r.additionLineIndex&&t<i)return n}}function HN(e,t,n){let r=e.hunks[t];if(r==null)return!1;let i=e.deletionLines.slice(r.deletionLineIndex,r.deletionLineIndex+r.deletionCount),o=e.additionLines.slice(r.additionLineIndex,r.additionLineIndex+r.additionCount),s=Kn({name:e.prevName??e.name,contents:i.join("")},{name:e.name,contents:o.join(""),lang:e.lang},{...n,context:0}),a=s.hunks[0];if(a==null||s.hunks.length!==1)return!1;return _N(r,a),Zf(e,t),!0}function Zf(e,t){let n=e.hunks[t];if(n==null)return;if(t!==e.hunks.length-1){n.noEOFCRAdditions=!1,n.noEOFCRDeletions=!1;return}let r=e.additionLines.at(-1),i=e.deletionLines.at(-1);n.noEOFCRAdditions=r!=null&&r!==""&&!r.endsWith(`
|
|
1523
1523
|
`),n.noEOFCRDeletions=i!=null&&i!==""&&!i.endsWith(`
|
|
1524
|
-
`)}function EN(e,t){let{additionLineIndex:n,deletionLineIndex:r}=e;if(e.hunkContent=t.hunkContent.map((i)=>Zf(i,n,r)),e.additionLineIndex=n+t.additionLineIndex,e.additionStart=e.additionStart+t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0)e.deletionLineIndex=r+t.deletionLineIndex,e.deletionStart=e.deletionStart+t.deletionLineIndex;e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,yd(e)}function Zf(e,t,n){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+n}}function yd(e){let t=0,n=0;for(let r of e.hunkContent)if(r.type==="context")t+=r.lines,n+=r.lines;else t+=Math.max(r.additions,r.deletions),n+=r.additions+r.deletions;e.splitLineCount=t,e.unifiedLineCount=n}function ns(e){let t=0,n=0,r=0;for(let i of e.hunks)i.collapsedBefore=Math.max(Tt(i.additionStart,i.additionCount)-r,0),i.splitLineStart=t+i.collapsedBefore,i.unifiedLineStart=n+i.collapsedBefore,yd(i),t+=i.collapsedBefore+i.splitLineCount,n+=i.collapsedBefore+i.unifiedLineCount,r=kt(i.additionStart,i.additionCount);if(e.hunks.length>0){let i=e.hunks[e.hunks.length-1],o=Math.max(e.additionLines.length-kt(i.additionStart,i.additionCount),0);t+=o,n+=o}e.splitLineCount=t,e.unifiedLineCount=n}var HI=new WeakMap;function vN(e){if(e.length>1&&e[e.length-1]==="")return e.slice(0,-1);return e}function TN(e,t){let n=Math.min(e.length,t.length),r=0;while(r<n&&e[r]===t[r])r++;let i=e.length,o=t.length;while(i>r&&o>r&&e[i-1]===t[o-1])i--,o--;if(r===i&&r===o)return;return{start:r,deletionEnd:i,additionEnd:o}}function Id(e,t){let{hunks:n,additionLines:r}=e,i=vN(r),o=i===r?e:{...e,additionLines:i},s=AN(n,RN(o,t),e.deletionLines.length),a=MN(o,s);if(e.additionLines=i,e.hunks=a,e.editSessionDirty=!0,DN(e),Yf(e,r),!FN(n,e.hunks))return;return{regions:s.map((l)=>l.previousSpan)}}function GI(e,t,n,r){let i=Array.from(new Set(t)).filter((l)=>l>=0&&l<e.additionLines.length).sort((l,d)=>l-d);if(i.length===0)return;let{hunks:o}=e,s,a=0;for(let l of i){while(a<o.length){let m=o[a];if(l<Sd(m)+m.additionCount)break;a++}let d=o[a],c=d==null?void 0:Sd(d);if(c==null||l<c||s!=null&&s!==a)return Id(e,n);s=a}if(s==null)return;if(kN(e,i,s,r,n)){e.editSessionDirty=!0;return}return Id(e,n)}function kN(e,t,n,r,i){if(r==null||i?.ignoreWhitespace===!0||i?.stripTrailingCr===!0)return!1;let o=wN(e),s=e.hunks[n];if(s.hunkContent.some(LN))return!1;for(let a of t){let l=r.get(a),d=e.additionLines[a];if(l==null||d==null||o.has(l)||o.has(d))return!1;let c=!1;for(let m of s.hunkContent)if(m.type==="change"&&m.additions===m.deletions&&a>=m.additionLineIndex&&a<m.additionLineIndex+m.additions){c=!0;break}if(!c)return!1}return!0}function wN(e){let t=HI.get(e);if(t?.lines===e.deletionLines)return t.set;let n=new Set(e.deletionLines);return HI.set(e,{lines:e.deletionLines,set:n}),n}function LN(e){return e?.type==="change"&&(e.additions===0||e.deletions===0)}function jI(e,t){let n=new Map,{regions:r}=t;for(let i=0;i<=r.length;i++){let o=r[i-1],s=r[i],a=i===0?e.get(0):o==null?void 0:e.get(o.lastIndex+1),l=s==null?void 0:e.get(s.firstIndex),d=a?.fromStart??0,c=l?.fromEnd??0;if(d>0||c>0)n.set(i,{fromStart:d,fromEnd:c})}return n}function qI(e,t,n){let r=[];if(e.isPartial)return r;for(let[o,s]of e.hunks.entries()){let a=cn({isPartial:e.isPartial,rangeSize:s.collapsedBefore,expandedHunks:t,hunkIndex:o,collapsedContextThreshold:n});if(a.rangeSize<=n)continue;let l=eo(s),d=l-a.rangeSize;if(a.fromStart>0)r.push([d,d+a.fromStart]);if(a.fromEnd>0)r.push([l-a.fromEnd,l])}let i=mn({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:"captureExpansionAnchors"});if(i!=null&&i.fromStart>0&&i.rangeSize>n){let o=e.hunks[e.hunks.length-1],s=eo(o)+o.deletionCount;r.push([s,s+i.fromStart])}return r}function zI(e,t){let n=new Map;if(t.length===0)return n;let r=(o,s,a)=>{if(a<=s)return;let l=0,d=0;for(let[c,m]of t){if(m<=s||c>=a)continue;if(c<=s)l=Math.max(l,Math.min(m,a)-s);if(m>=a)d=Math.max(d,a-Math.max(c,s))}if(l>0||d>0)n.set(o,{fromStart:l,fromEnd:d})};for(let[o,s]of e.hunks.entries()){let a=eo(s);r(o,a-Math.max(s.collapsedBefore,0),a)}let i=e.hunks[e.hunks.length-1];if(i!=null&&!e.isPartial&&e.deletionLines.length>0)r(e.hunks.length,eo(i)+i.deletionCount,e.deletionLines.length);return n}function Qf(e,t){if(e.editSessionDirty!==!0)return!1;return delete e.editSessionDirty,Object.assign(e,e.additionLines.length<=1&&e.additionLines.join("")===""?lr(e,t):gd(e,t)),!0}function RN(e,t){if(TN(e.deletionLines,e.additionLines)==null)return[];let n=Kn({name:e.prevName??e.name,contents:e.deletionLines.join("")},{name:e.name,contents:e.additionLines.join(""),lang:e.lang},t),r=[],i=0,o=0;for(let s of n.hunks){let a=s.additionCount>0?s.additionLineIndex-i:s.deletionLineIndex-o;i+=a,o+=a;for(let l of s.hunkContent){if(l.type==="context"){i+=l.lines,o+=l.lines;continue}let d=Zf(l,0,0);if(d.additions===0)d.additionLineIndex=i;if(d.deletions===0)d.deletionLineIndex=o;r.push(d),i+=d.additions,o+=d.deletions}}return r}function AN(e,t,n){let r=e.map((s,a)=>{let l=eo(s);return{deletionStart:l,deletionEnd:l+s.deletionCount,blocks:[],previousSpan:{firstIndex:a,lastIndex:a}}}),i=[],o=0;for(let s of t){let a=s.deletionLineIndex,l=a+s.deletions;while(o<r.length&&r[o].deletionEnd<a)i.push(r[o]),o++;let d=i.length>0&&PN(a,l,i[i.length-1])?i.pop():void 0;while(o<r.length&&r[o].deletionStart<=l)d=$N(d,r[o]),o++;if(d==null){let c=a,m=l;if((s.deletions===0||s.additions===0)&&n>s.deletions){let p=i[i.length-1]?.deletionEnd??0,h=r[o]?.deletionStart??n;if(a>p)c--;else if(l<h)m++}d={deletionStart:c,deletionEnd:m,blocks:[],previousSpan:void 0}}d.deletionStart=Math.min(d.deletionStart,a),d.deletionEnd=Math.max(d.deletionEnd,l),d.blocks.push(s),i.push(d)}while(o<r.length)i.push(r[o]),o++;return i}function PN(e,t,n){return e<=n.deletionEnd&&t>=n.deletionStart}function $N(e,t){if(e==null)return t;if(e.deletionStart=Math.min(e.deletionStart,t.deletionStart),e.deletionEnd=Math.max(e.deletionEnd,t.deletionEnd),e.blocks.push(...t.blocks),t.previousSpan!=null)e.previousSpan??={...t.previousSpan},e.previousSpan.firstIndex=Math.min(e.previousSpan.firstIndex,t.previousSpan.firstIndex),e.previousSpan.lastIndex=Math.max(e.previousSpan.lastIndex,t.previousSpan.lastIndex);return e}function MN(e,t){let n=[],r=0,i=0;for(let o of t){let s=o.deletionStart-r;if(s<0)throw Error("buildRegionHunks: overlapping old-side regions");r+=s,i+=s;let a=i,l=[];for(let c of o.blocks){let m=c.deletionLineIndex-r,p=c.additionLineIndex-i;if(m<0||m!==p)throw Error("buildRegionHunks: canonical block context mismatch");_I(l,m,i,r),r+=m,i+=p,l.push({...c}),r+=c.deletions,i+=c.additions}let d=o.deletionEnd-r;if(d<0)throw Error("buildRegionHunks: block exceeds its old-side region");_I(l,d,i,r),r+=d,i+=d,n.push(ON(e,{additionStart:a,additionEnd:i,deletionStart:o.deletionStart,deletionEnd:o.deletionEnd},l))}if(e.deletionLines.length-r!==e.additionLines.length-i)throw Error("buildRegionHunks: trailing context mismatch");return n}function ON(e,t,n){let r=t.additionEnd-t.additionStart,i=t.deletionEnd-t.deletionStart,o=0,s=0;for(let l of n)if(l.type==="change")o+=l.additions,s+=l.deletions;let a={collapsedBefore:0,additionStart:xd(t.additionStart,r),additionCount:r,additionLines:o,additionLineIndex:BI(t.additionStart,r),deletionStart:xd(t.deletionStart,i),deletionCount:i,deletionLines:s,deletionLineIndex:BI(t.deletionStart,i),hunkContent:n,hunkSpecs:`@@ -${xd(t.deletionStart,i)},${i} +${xd(t.additionStart,r)},${r} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return yd(a),a}function _I(e,t,n,r){if(t>0)e.push({type:"context",lines:t,additionLineIndex:n,deletionLineIndex:r})}function FN(e,t){if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(eo(r)!==eo(i)||r.deletionCount!==i.deletionCount||Sd(r)!==Sd(i)||r.additionCount!==i.additionCount||r.splitLineCount!==i.splitLineCount||!NN(r,i))return!0}return!1}function NN(e,t){let n=UI(e),r=UI(t);while(!0){let i=n.next(),o=r.next();if(i.done===!0||o.done===!0)return i.done===o.done;if(i.value[0]!==o.value[0]||i.value[1]!==o.value[1])return!1}}function*UI(e){for(let t of e.hunkContent){if(t.type==="context"){for(let r=0;r<t.lines;r++)yield[t.deletionLineIndex+r,t.additionLineIndex+r];continue}let n=Math.max(t.deletions,t.additions);for(let r=0;r<n;r++)yield[r<t.deletions?t.deletionLineIndex+r:void 0,r<t.additions?t.additionLineIndex+r:void 0]}}function Sd(e){return Tt(e.additionStart,e.additionCount)}function eo(e){return Tt(e.deletionStart,e.deletionCount)}function xd(e,t){return t===0?e:e+1}function BI(e,t){return t===0?e-1:e}function DN(e){ns(e);for(let t=0;t<e.hunks.length;t++)Jf(e,t)}function to(e){let t=e.lang??tt(e.name),n=e.lang??(e.prevName!=null?tt(e.prevName):"text");return t==="text"&&n==="text"}function ur(e,t){return Cn(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function ga(e){return K({tagName:"div",properties:{"data-content-buffer":"","data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function ya(e){return K({tagName:"div",children:[K({tagName:"span",children:[un("No newline at end of file")]})],properties:{"data-no-newline":"","data-line-type":e,"data-column-content":""}})}function ep(e){return K({tagName:"div",children:[Xi({name:e==="both"?"diffs-icon-expand-all":"diffs-icon-expand",properties:{"data-icon":""}})],properties:{role:"button","data-expand-button":"","data-expand-both":e==="both"?"":void 0,"data-expand-up":e==="up"?"":void 0,"data-expand-down":e==="down"?"":void 0}})}function no({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:o,isLastHunk:s}){let a=0,l=[];if(e==="metadata"&&t!=null)l.push(K({tagName:"div",children:[un(t)],properties:{"data-separator-wrapper":""}}));if((e==="line-info"||e==="line-info-basic")&&t!=null){let d=[];if(n!=null)if(!r)d.push(ep(!o&&!s?"both":o?"down":"up")),a++;else{if(!o)d.push(ep("up")),a++;if(!s)d.push(ep("down")),a++}if(d.push(K({tagName:"div",children:[K({tagName:"span",children:[un(t)],properties:{"data-unmodified-lines":""}})],properties:{"data-separator-content":""}})),r&&n!=null)d.push(K({tagName:"div",children:[un("Expand all")],properties:{role:"button","data-expand-button":"","data-expand-all-button":""}}));l.push(K({tagName:"div",children:d,properties:{"data-separator-wrapper":"","data-separator-multi-button":a>1?"":void 0}}))}if(e==="custom"&&i!=null)l.push(K({tagName:"slot",properties:{name:i}}));return K({tagName:"div",children:l,properties:{"data-separator":l.length===0?"simple":e,"data-expand-index":n,"data-separator-first":o?"":void 0,"data-separator-last":s?"":void 0}})}function KI(e,t){return`hunk-separator-${e}-${t}`}function VI(e){let t=e.at(-1);if(t==null)return 0;return Math.max(kt(t.additionStart,t.additionCount),kt(t.deletionStart,t.deletionCount))}function tp({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 xa({item:e,arr:t,enableJoin:n,isNeutral:r=!1,isLastItem:i=!1}){let o=t[t.length-1];if(o==null||i||!n){t.push([r?0:1,e.value]);return}let s=o[0]===0;if(r===s||r&&e.value.length===1&&!s){o[1]+=e.value;return}t.push([r?0:1,e.value])}var HN={forcePlainText:!1};function WI(e,t,n,{forcePlainText:r,startingLine:i,totalLines:o,expandedHunks:s,collapsedContextThreshold:a=1}=HN){if(r)i??=0,o??=1/0;else i=0,o=1/0;let l=i>0||o<1/0,d=typeof n.theme==="string"?t.getTheme(n.theme).type:void 0,c=Nu({theme:n.theme,highlighter:t}),m=r&&!l&&(e.unifiedLineCount>1000||e.splitLineCount>1000)?"none":n.lineDiffType,p={deletionLines:[],additionLines:[]},{maxLineDiffLength:h}=n,x=!r&&!e.isPartial,I=r?s:void 0,v=new Map;function S(E){let w=x?0:E,k=v.get(w)??UN();return v.set(w,k),k}function b(E,w,k,L){if(l){let R=k.at(-1);if(R==null||R.targetIndex+R.count!==w)R={targetIndex:w,originalOffset:L.length,count:0},k.push(R);R.count++}L.push(E)}zn({diff:e,diffStyle:"both",startingLine:i,totalLines:o,expandedHunks:l?I:!0,collapsedContextThreshold:a,callback:({hunkIndex:E,additionLine:w,deletionLine:k,type:L})=>{let R=S(E),A=w!=null?w.splitLineIndex:k.splitLineIndex;if(L==="change"&&w!=null&&k!=null)_N({additionLine:e.additionLines[w.lineIndex],deletionLine:e.deletionLines[k.lineIndex],deletionLineIndex:R.deletionContent.length,additionLineIndex:R.additionContent.length,deletionDecorations:R.deletionDecorations,additionDecorations:R.additionDecorations,lineDiffType:m,maxLineDiffLength:h});if(k!=null)b(e.deletionLines[k.lineIndex],k.lineIndex,R.deletionSegments,R.deletionContent),R.deletionInfo.push({type:L==="change"?"change-deletion":L,lineNumber:k.lineNumber,altLineNumber:L==="change"?void 0:w.lineNumber??void 0,lineIndex:`${k.unifiedLineIndex},${A}`});if(w!=null)b(e.additionLines[w.lineIndex],w.lineIndex,R.additionSegments,R.additionContent),R.additionInfo.push({type:L==="change"?"change-addition":L,lineNumber:w.lineNumber,altLineNumber:L==="change"?void 0:k.lineNumber??void 0,lineIndex:`${w.unifiedLineIndex},${A}`})}});for(let E of v.values()){if(E.deletionContent.length===0&&E.additionContent.length===0)continue;let w={name:e.prevName??e.name,contents:E.deletionContent.value},k={name:e.name,contents:E.additionContent.value},{deletionLines:L,additionLines:R}=BN({deletionFile:w,deletionInfo:E.deletionInfo,deletionDecorations:E.deletionDecorations,additionFile:k,additionInfo:E.additionInfo,additionDecorations:E.additionDecorations,highlighter:t,options:n,languageOverride:r?"text":e.lang});if(x){p.deletionLines=L,p.additionLines=R;continue}if(E.deletionSegments.length>0)for(let A of E.deletionSegments)for(let O=0;O<A.count;O++)p.deletionLines[A.targetIndex+O]=L[A.originalOffset+O];else aa(p.deletionLines,L);if(E.additionSegments.length>0)for(let A of E.additionSegments)for(let O=0;O<A.count;O++)p.additionLines[A.targetIndex+O]=R[A.originalOffset+O];else aa(p.additionLines,R)}return{code:p,themeStyles:c,baseThemeType:d}}function _N({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:o,lineDiffType:s,maxLineDiffLength:a}){if(e==null||t==null||s==="none")return;if(e=bn(e),t=bn(t),e.length>a||t.length>a)return;let l=s==="char"?Uf(e,t):zf(e,t),d=[],c=[],m=s==="word-alt",p=l.at(-1);for(let x of l){let I=x===p;if(!x.added&&!x.removed)xa({item:x,arr:d,enableJoin:m,isNeutral:!0,isLastItem:I}),xa({item:x,arr:c,enableJoin:m,isNeutral:!0,isLastItem:I});else if(x.removed)xa({item:x,arr:d,enableJoin:m,isLastItem:I});else xa({item:x,arr:c,enableJoin:m,isLastItem:I})}let h=0;for(let x of d){if(x[0]===1)i.push(tp({line:n,spanStart:h,spanLength:x[1].length}));h+=x[1].length}h=0;for(let x of c){if(x[0]===1)o.push(tp({line:r,spanStart:h,spanLength:x[1].length}));h+=x[1].length}}function UN(){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 BN({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:o,additionDecorations:s,languageOverride:a,options:{theme:l,...d}}){let c=a??tt(e.name),m=a??tt(t.name),{state:p,transformers:h}=Ou(d.useTokenTransformer),x=(()=>typeof l==="string"?{...d,lang:"text",theme:l,transformers:h,decorations:void 0,defaultColor:!1,cssVariablePrefix:Gt("token"),tokenizeTimeLimit:0}:{...d,lang:"text",themes:l,transformers:h,decorations:void 0,defaultColor:!1,cssVariablePrefix:Gt("token"),tokenizeTimeLimit:0})();return{deletionLines:(()=>{if(e.contents==="")return[];return x.lang=c,p.lineInfo=n,x.decorations=o,la(i.codeToHast(bn(e.contents),x))})(),additionLines:(()=>{if(t.contents==="")return[];return x.lang=m,x.decorations=s,p.lineInfo=r,la(i.codeToHast(bn(t.contents),x))})()}}var GN=-1,eS=class{options;annotationSlotName;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++GN}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLangs=["text"];renderCache;pendingHighlightResult;pendingStructuralRows;editSessionActive=!1;constructor(e={theme:Oe},t=dn,n,r){if(this.options=e,this.annotationSlotName=t,this.onRenderUpdate=n,this.workerManager=r,r?.isWorkingPool()!==!0)this.highlighter=Qt(e.theme??Oe)?jn():void 0}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this),this.endEditSession()}beginEditSession(e,t){let{editSessionActive:n,renderCache:r}=this;if(this.editSessionActive=!0,!n)this.pendingHighlightResult=void 0;if(this.diff=e,!e.isPartial&&e.additionLines.length===0){Object.assign(e,ha(e,this.options.parseDiffOptions)),this.markEditSessionPass(e),this.clearRenderCache();return}if(r==null)return;if(n&&r.diff===e)return;let{options:i}=this.getRenderOptions(e),o=r.diff===e,s=t!=null&&ze(r.diff,t),{result:a}=r;if(!r.highlighted||a==null||!ur(r.options,i)||!o&&!s){this.clearRenderCache();return}if(o)return;this.renderCache={diff:e,options:i,highlighted:!0,result:{...a,code:{...a.code,additionLines:[...a.code.additionLines]}},renderRange:r.renderRange}}endEditSession(){this.editSessionActive=!1,this.pendingHighlightResult=void 0}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}refreshHighlightedResult(){let{diff:e,renderCache:t,workerManager:n}=this;if(e==null||t==null||!ze(t.diff,e)||to(e)||Ia(e,this.getTokenizeMaxLength()))return Promise.resolve();if(!this.editSessionActive&&n?.isWorkingPool()===!0&&e.cacheKey!=null)return n.evictDiffFromCache(e.cacheKey),n.primeDiffHighlightCache(e).then(()=>{this.applyRefreshedResult(e,n.getDiffResultCache(e))}).catch((r)=>this.onHighlightError(r));return this.asyncHighlight(e).then((r)=>this.applyRefreshedResult(e,r)).catch((r)=>this.onHighlightError(r))}applyRefreshedResult(e,t){let{diff:n,renderCache:r}=this;if(t==null||n==null||r==null||!ze(n,e)||!ze(r.diff,e)||this.editSessionActive)return;let{options:i}=this.getRenderOptions(n);if(!ur(i,t.options))return;this.pendingHighlightResult={diff:n,options:t.options,highlighted:!0,result:t.result},this.onRenderUpdate?.()}get diffCache(){return this.renderCache?.diff??this.diff}clearRenderCache(){this.renderCache=void 0,this.pendingHighlightResult=void 0,this.pendingStructuralRows=void 0}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){let r={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};if(t==="up"||t==="both")r.fromStart+=n;if(t==="down"||t==="both")r.fromEnd+=n;if(this.renderCache?.highlighted!==!0)this.clearRenderCache();this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??QI}getExpandedHunksMap(){return this.expandedHunks}setExpandedHunksMap(e){this.expandedHunks=e}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(let t of e){let n=(()=>{switch(t.side){case"deletions":return this.deletionAnnotations;case"additions":return this.additionAnnotations}})(),r=n[t.lineNumber]??[];n[t.lineNumber]=r,r.push(t)}}updateRenderCache(e,t,n=!1){this.pendingStructuralRows=void 0;let{renderCache:r}=this;if(r==null)return!1;let{result:i,diff:o}=r;if(i==null)return!1;if(o.isPartial)throw Error("Could not update render cache for partial diff");let s=i.code.additionLines,a=this.pendingStructuralRows=n?new Map:void 0,l=[],d=new Map;for(let[m,p]of e){let h=s[m]?.properties??{},x=p.map((E)=>E[2]).join(""),I=m<o.additionLines.length,v=I?o.additionLines[m]??"":"",S=bn(v);if(a==null&&I){if(o.additionLines[m]=wu(v,x),S!==x)l.push(m),d.set(m,v)}let b={type:"element",tagName:"div",properties:{"data-line":h["data-line"]??m+1,"data-line-index":h["data-line-index"]??m,"data-line-type":h["data-line-type"]??"context"},children:p.map(([E,w,k])=>{if(E===0&&w===""){if(k==="")return{type:"element",tagName:"br",properties:{},children:[]};return{type:"text",value:k}}return{type:"element",tagName:"span",properties:{"data-char":E,style:`color:${w};`},children:[{type:"text",value:k}]}})};if(a!=null)a.set(m,b);else s[m]=b}let c=!1;if(l.length>0)if(this.editSessionActive)if(o.additionLines.length<=1&&o.additionLines.join("")==="")this.applyRecomputePreservingSessionType(o,ha(o,this.options.parseDiffOptions)),c=!0;else if(hd(o,o.additionLines))this.applyRecomputePreservingSessionType(o,pa(o,o.additionLines,this.options.parseDiffOptions)),c=!0;else{let m=GI(o,l,this.options.parseDiffOptions,d);this.applyExpansionRemap(m),c=m!=null}else Object.assign(o,DI(o,l,this.options.parseDiffOptions));return i.baseThemeType=t,r.isDirty=!0,c}applyExpansionRemap(e){if(e!=null)this.expandedHunks=jI(this.expandedHunks,e)}applyDocumentChange(e){let{pendingStructuralRows:t,renderCache:n}=this;if(this.pendingStructuralRows=void 0,n==null)return;let{diff:r,result:i}=n;if(i==null)return;if(r.isPartial)throw Error("Could not apply document change for partial diff");let{additionLines:o}=r;if(r.additionLines=KN(e),i.code.additionLines=zN(o,r.additionLines,i.code.additionLines,e),r.additionLines.length<=1&&r.additionLines.join("")==="")this.applyRecomputePreservingSessionType(r,ha(r,this.options.parseDiffOptions)),i.code.additionLines[0]=ip(0,e.getLineText(0));else if(this.editSessionActive)this.applySessionDocumentChange(r);else Object.assign(r,gd(r,this.options.parseDiffOptions));if(t!=null){for(let[s,a]of t)if(s<i.code.additionLines.length)i.code.additionLines[s]=a}n.isDirty=!0}applySessionDocumentChange(e){let{parseDiffOptions:t}=this.options,n=e.additionLines;if(hd(e,n)){this.applyRecomputePreservingSessionType(e,pa(e,n,t));return}this.applyExpansionRemap(Id(e,t))}applyRecomputePreservingSessionType(e,t){let n=this.editSessionActive?e.type:void 0;if(Object.assign(e,t),n!=null)e.type=n;this.markEditSessionPass(e)}markEditSessionPass(e){if(!this.editSessionActive)return;e.editSessionDirty=!0}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){let n=t==="change"?e==="deletions"?"change-deletion":"change-addition":t;return{gutterLineType:n,contentProperties:{"data-line-type":n}}}createAnnotationElement=(e)=>sa(e);getOptionsWithDefaults(){let{diffIndicators:e="bars",diffStyle:t="split",disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:o=!1,collapsed:s=!1,expandUnchanged:a=!1,collapsedContextThreshold:l=1,expansionLineCount:d=100,hunkSeparators:c="line-info",lineDiffType:m="word-alt",maxLineDiffLength:p=1000,overflow:h="scroll",stickyHeader:x=!1,theme:I=Oe,headerRenderMode:v="default",tokenizeMaxLineLength:S=1000,tokenizeMaxLength:b=ZI,useTokenTransformer:E=!1,useCSSClasses:w=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:o,collapsed:s,expandUnchanged:a,collapsedContextThreshold:l,expansionLineCount:d,hunkSeparators:c,lineDiffType:m,maxLineDiffLength:p,overflow:h,stickyHeader:x,theme:this.workerManager?.getDiffRenderOptions().theme??I,headerRenderMode:v,tokenizeMaxLineLength:S,tokenizeMaxLength:b,useTokenTransformer:E,useCSSClasses:w}}async initializeHighlighter(){return this.highlighter=await sr(Pu(this.computedLangs,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=Ia(e,this.getTokenizeMaxLength()),r=this.workerManager?.getDiffResultCache(e);if(r!=null&&!ur(t,r.options))r=void 0;if(this.renderCache??={diff:e,hydrated:!0,highlighted:!n&&!to(e),options:t,result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){if(this.renderCache.result==null&&!n)this.workerManager.highlightDiffAST(this,this.diff)}else if(this.highlighter==null)this.computedLangs=rp(e),this.initializeHighlighter()}getLocalHighlightTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??Oe}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getDiffRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let a=this.workerManager.getDiffRenderOptions();if(this.editSessionActive&&a.useTokenTransformer!==!0)return{...a,useTokenTransformer:!0};return a}let{theme:r,tokenizeMaxLineLength:i,lineDiffType:o,maxLineDiffLength:s}=this.getOptionsWithDefaults();return{theme:r,useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:i,lineDiffType:o,maxLineDiffLength:s}})();this.getOptionsWithDefaults();let{renderCache:n}=this;if(n?.result==null)return{options:t,forceHighlight:!0};if(!ze(e,n.diff)||!ur(t,n.options))return{options:t,forceHighlight:!0};return{options:t,forceHighlight:!1}}getDiffForNextRender(e){let{options:t}=this.getRenderOptions(e);if(this.getReadyRenderResult(e,t)!=null)return e;if(this.renderCache==null)return e;if(ze(this.renderCache.diff,e))return this.renderCache.diff;let n=!(e.additionLines.length>0||e.deletionLines.length>0)||to(e)||Ia(e,this.getTokenizeMaxLength());return this.canRenderDiff(e,t,n)?e:this.renderCache.diff}canRenderDiff(e,t,n){let{renderCache:r}=this;if(r==null||ze(r.diff,e))return!0;if(n)return r.result==null&&r.hydrated!==!0||this.workerManager?.isWorkingPool()===!0||this.highlighter!=null&&Qt(t.theme);if(r.result==null&&r.hydrated!==!0)return!0;if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0)return!r.highlighted;return this.highlighter!=null&&Qt(t.theme)}renderDiff(e=this.diff,t=Xo){if(this.diff=e,e==null){this.pendingHighlightResult=void 0;return}let{expandUnchanged:n,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),{options:i,forceHighlight:o}=this.getRenderOptions(e),s=this.getReadyRenderResult(e,i);if(this.pendingHighlightResult=void 0,s!=null)this.renderCache={...s,diff:e,renderRange:void 0},o=!1;this.renderCache??={diff:e,highlighted:!1,options:i,result:void 0,renderRange:void 0};let a=e.additionLines.length>0||e.deletionLines.length>0,l=!a||to(e)||Ia(e,this.getTokenizeMaxLength()),d=this.canRenderDiff(e,i,l),c=!ze(e,this.renderCache.diff),m=!ci(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){let p=this.renderCache.result==null&&this.renderCache.highlighted&&!l&&!c&&Yi(t);if(d&&!p&&(l||this.renderCache.result==null||!this.renderCache.highlighted&&(c||m))){if(this.renderCache.diff=e,this.renderCache.options=i,this.renderCache.highlighted=!1,this.renderCache.result==null||c||m||o)this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,Yi(t)?!0:n?!0:this.expandedHunks,r);this.renderCache.renderRange=t}if(!l&&a&&(!this.renderCache.highlighted||o))this.workerManager.highlightDiffAST(this,e)}else{this.computedLangs=rp(e),this.highlighter??=jn();let p=this.highlighter!=null&&Qt(i.theme),h=this.highlighter!=null&&ni(this.computedLangs),x=!l&&h;if(d&&this.highlighter!=null&&p&&(o||l||!this.renderCache.highlighted&&x||this.renderCache.result==null)){let{result:I,options:v}=this.renderDiffWithHighlighter(e,this.highlighter,l||!h);this.renderCache={diff:e,options:v,highlighted:x,result:I,renderRange:void 0}}if(!p||!l&&!h)this.asyncHighlight(e).then(({result:I,options:v})=>{this.applyHighlightResult(e,I,v,!l)})}return this.renderCache.result!=null?this.processDiffResult(this.renderCache.diff,t,this.renderCache.result):void 0}async asyncRender(e,t=Xo){this.diff=e;let{result:n}=await this.asyncHighlight(e);return this.processDiffResult(e,t,n)}createPreElement(e,t,n){let{diffIndicators:r,disableBackground:i,disableLineNumbers:o,overflow:s}=this.getOptionsWithDefaults();return Au({type:"diff",diffIndicators:r,disableBackground:i,disableLineNumbers:o,overflow:s,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e){let t=Ia(e,this.getTokenizeMaxLength());this.computedLangs=t?["text"]:rp(e);let n=this.highlighter!=null&&Qt(this.getLocalHighlightTheme()),r=t||this.highlighter!=null&&ni(this.computedLangs);if(this.highlighter==null||!n||!r)this.highlighter=await this.initializeHighlighter();return this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults(),o=WI(e,t,r,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:i});if(this.editSessionActive&&e.additionLines.length===1&&e.additionLines[0]===""&&o.code.additionLines[0]==null){let s;if(zn({diff:e,diffStyle:"both",expandedHunks:n?!0:void 0,collapsedContextThreshold:i,callback:({additionLine:a})=>{if(a?.lineIndex!==0)return;return s=a,!0}}),s==null)throw Error("DiffHunksRenderer: missing empty addition line");o.code.additionLines[0]=ip(0,"",s.unifiedLineIndex,s.splitLineIndex)}return{result:o,options:r}}onHighlightSuccess(e,t,n,r=!0){if(this.editSessionActive)return;this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){let{diff:i,renderCache:o}=this;if(i==null||o==null||!ze(i,e)||!ur(n,this.getRenderOptions(i).options))return;if(!(o.result==null||!o.highlighted||!ur(o.options,n)||!ze(o.diff,i)))return;this.pendingHighlightResult={diff:i,options:n,highlighted:r,result:t},this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getDiffResultCache(e);if(n==null||!ur(t,n.options))return;return n}getReadyRenderResult(e,t){let{pendingHighlightResult:n}=this;if(n!=null&&ze(n.diff,e)&&ur(n.options,t))return n;let r=this.getMatchingWorkerResultCache(e,t);if(r==null||this.hasHighlightedRenderCache(e,t))return;return{diff:e,highlighted:!0,...r}}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&ze(e,n.diff)&&ur(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let{diffStyle:o,disableFileHeader:s,expandUnchanged:a,expansionLineCount:l,collapsedContextThreshold:d,hunkSeparators:c}=this.getOptionsWithDefaults(),m=this.renderCache?.isDirty??!1,p=o==="unified",h=VN(e,this.options.loadDiffFiles!=null),x=!e.isPartial||h,I=[],v=[],S=[],b=[],{additionLines:E,deletionLines:w}=n,k={rowCount:0,hunkSeparators:c,additionsContentAST:I,deletionsContentAST:v,unifiedContentAST:S,unifiedGutterAST:ui(),deletionsGutterAST:ui(),additionsGutterAST:ui(),expansionLineCount:l,hunkData:b,incrementRowCount(j=1){k.rowCount+=j},pushToGutter(j,ie){switch(j){case"unified":k.unifiedGutterAST.children.push(ie);break;case"deletions":k.deletionsGutterAST.children.push(ie);break;case"additions":k.additionsGutterAST.children.push(ie)}}},L=_f({fileDiff:e,errorPrefix:"DiffHunksRenderer.processDiffResult"}),R={size:0,side:void 0,increment(){this.size+=1},flush(){if(o==="unified")return;if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}if(this.side==="additions")k.pushToGutter("additions",en(void 0,"buffer",this.size)),I?.push(ga(this.size));else k.pushToGutter("deletions",en(void 0,"buffer",this.size)),v?.push(ga(this.size));this.size=0,this.side=void 0}},A=(j,ie,Ee,Mt,Ie)=>{k.pushToGutter(j,Eu(ie,Ee,Mt,Ie))};function O(j){if(R.flush(),o==="unified")np("unified",j,k);else np("deletions",j,k),np("additions",j,k)}if(this.pushFileLevelAnnotations(e,o,t,k),zn({diff:e,diffStyle:o,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:a?!0:this.expandedHunks,collapsedContextThreshold:d,callback:({hunkIndex:j,hunk:ie,collapsedBefore:Ee,collapsedAfter:Mt,additionLine:Ie,deletionLine:Me,type:Qe})=>{let gt=Me!=null?Me.splitLineIndex:Ie.splitLineIndex,xn=Ie!=null?Ie.unifiedLineIndex:Me.unifiedLineIndex;if(o==="split"&&Qe!=="change")R.flush();if(Ee>0)O({hunkIndex:j,collapsedLines:Ee,rangeSize:Math.max(ie?.collapsedBefore??0,0),hunkSpecs:ie?.hunkSpecs,isFirstHunk:j===0,isLastHunk:!1,isExpandable:x});let Rn=o==="unified"?xn:gt,An={type:Qe,hunkIndex:j,lineIndex:Rn,unifiedLineIndex:xn,splitLineIndex:gt,deletionLine:Me,additionLine:Ie};if(o==="unified"){let at=this.getUnifiedInjectedRowsForLine?.(An);if(at?.before!=null)XI(at.before,k);let sn=Me!=null?w[Me.lineIndex]:void 0,In=Ie!=null?E[Ie.lineIndex]:void 0;if(sn==null&&In==null)throw console.error("DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong",{file:e.name}),Error("DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong");let _i=Qe==="change"?Ie!=null?"change-addition":"change-deletion":Qe,Un=this.getUnifiedLineDecoration({type:Qe,lineType:_i,additionLineIndex:Ie?.lineIndex,deletionLineIndex:Me?.lineIndex});if(A("unified",Un.gutterLineType,Ie!=null?Ie.lineNumber:Me.lineNumber,`${xn},${gt}`,Un.gutterProperties),In!=null)In=Cd(In,Un.contentProperties,m&&Ie!=null?{"data-line":Ie.lineNumber,"data-line-index":`${xn},${gt}`}:void 0);else if(sn!=null)sn=Cd(sn,Un.contentProperties,m&&Me!=null?{"data-line":Me.lineNumber,"data-line-index":`${xn},${gt}`}:void 0);if(bd({diffStyle:"unified",type:Qe,deletionLine:sn,additionLine:In,unifiedSpan:this.getAnnotations("unified",Me?.lineNumber,Ie?.lineNumber,j,Rn),createAnnotationElement:(wr)=>this.createAnnotationElement(wr),context:k}),at?.after!=null)XI(at.after,k)}else{let at=this.getSplitInjectedRowsForLine?.(An);if(at?.before!=null)YI(at.before,k,R);let sn=Me!=null?w[Me.lineIndex]:void 0,In=Ie!=null?E[Ie.lineIndex]:void 0,_i=this.getSplitLineDecoration({side:"deletions",type:Qe,lineIndex:Me?.lineIndex}),Un=this.getSplitLineDecoration({side:"additions",type:Qe,lineIndex:Ie?.lineIndex});if(sn==null&&In==null)throw console.error("DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong",{file:e.name}),Error("DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong");let wr=(()=>{if(Qe==="change"){if(In==null)return"additions";else if(sn==null)return"deletions"}})();if(wr!=null){if(R.side!=null&&R.side!==wr)R.flush();R.side=wr,R.increment()}else if(Qe==="change")R.flush();let Zr=this.getAnnotations("split",Me?.lineNumber,Ie?.lineNumber,j,Rn);if(Zr!=null&&R.size>0)R.flush();if(Me!=null){let Pn=Cd(sn,_i.contentProperties,m?{"data-line":Me.lineNumber,"data-line-index":`${Me.unifiedLineIndex},${gt}`}:void 0);if(A("deletions",_i.gutterLineType,Me.lineNumber,`${Me.unifiedLineIndex},${gt}`,_i.gutterProperties),Pn!=null)sn=Pn}if(Ie!=null){let Pn=Cd(In,Un.contentProperties,m?{"data-line":Ie.lineNumber,"data-line-index":`${Ie.unifiedLineIndex},${gt}`}:void 0);if(A("additions",Un.gutterLineType,Ie.lineNumber,`${Ie.unifiedLineIndex},${gt}`,Un.gutterProperties),Pn!=null)In=Pn}if(bd({diffStyle:"split",type:Qe,additionLine:In,deletionLine:sn,...Zr,createAnnotationElement:(Pn)=>this.createAnnotationElement(Pn),context:k}),at?.after!=null)YI(at.after,k,R)}let Hi=o==="split"&&ie!=null&>===ie.splitLineStart+ie.splitLineCount-1,Jt=j===e.hunks.length-1&&ie!=null&&(o==="split"?gt===ie.splitLineStart+ie.splitLineCount-1:xn===ie.unifiedLineStart+ie.unifiedLineCount-1),wo=Hi?ie.noEOFCRDeletions:!1,Hs=Hi?ie.noEOFCRAdditions:!1,Tr=(Me?.noEOFCR??!1)||wo,kr=(Ie?.noEOFCR??!1)||Hs;if(kr||Tr){if(o==="split")R.flush();if(Tr){let at=Qe==="context"||Qe==="context-expanded"?Qe:"change-deletion";if(o==="unified")k.unifiedContentAST.push(ya(at)),k.pushToGutter("unified",en(at,"metadata",1));else if(k.deletionsContentAST.push(ya(at)),k.pushToGutter("deletions",en(at,"metadata",1)),!kr)k.pushToGutter("additions",en(void 0,"buffer",1)),k.additionsContentAST.push(ga(1))}if(kr){let at=Qe==="context"||Qe==="context-expanded"?Qe:"change-addition";if(o==="unified")k.unifiedContentAST.push(ya(at)),k.pushToGutter("unified",en(at,"metadata",1));else if(k.additionsContentAST.push(ya(at)),k.pushToGutter("additions",en(at,"metadata",1)),!Tr)k.pushToGutter("deletions",en(void 0,"buffer",1)),k.deletionsContentAST.push(ga(1))}k.incrementRowCount(1)}if(c!=="simple"&&c!=="metadata"&&(Mt>0||Jt&&h))O({hunkIndex:Qe==="context-expanded"?j:j+1,collapsedLines:Jt&&h?"unknown":Mt,rangeSize:L,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:x});k.incrementRowCount(1)}}),o==="split")R.flush();let D=Math.max(VI(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),X=t.bufferBefore>0||t.bufferAfter>0,N=!p&&e.type!=="deleted",B=!p&&e.type!=="new",pe=k.rowCount>0||X;I=N&&pe?I:void 0,v=B&&pe?v:void 0,S=p&&pe?S:void 0;let ye=this.createPreElement(v!=null&&I!=null,D);return{fileDiff:e,unifiedGutterAST:p&&pe?k.unifiedGutterAST.children:void 0,unifiedContentAST:S,deletionsGutterAST:B&&pe?k.deletionsGutterAST.children:void 0,deletionsContentAST:v,additionsGutterAST:N&&pe?k.additionsGutterAST.children:void 0,additionsContentAST:I,hunkData:b,preNode:ye,themeStyles:r,baseThemeType:i,headerElement:!s?this.renderHeader(e):void 0,totalLines:D,rowCount:k.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:""}}renderCodeAST(e,t){let n=e==="unified"?t.unifiedGutterAST:e==="deletions"?t.deletionsGutterAST:t.additionsGutterAST,r=e==="unified"?t.unifiedContentAST:e==="deletions"?t.deletionsContentAST:t.additionsContentAST;if(n==null||r==null)return;let i=ui(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,Lu(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators==="line-info",r=this.renderCodeAST("unified",e);if(r!=null)return t.push(K({tagName:"code",children:r,properties:{"data-code":"","data-container-size":n?"":void 0,"data-unified":""}})),{...e.preNode,children:t};let i=this.renderCodeAST("deletions",e);if(i!=null)t.push(K({tagName:"code",children:i,properties:{"data-code":"","data-container-size":n?"":void 0,"data-deletions":""}}));let o=this.renderCodeAST("additions",e);if(o!=null)t.push(K({tagName:"code",children:o,properties:{"data-code":"","data-container-size":n?"":void 0,"data-additions":""}}));return{...e.preNode,children:t}}renderFullHTML(e,t=[]){return ut(this.renderFullAST(e,t))}renderPartialHTML(e,t){if(t==null)return ut(e);return ut(K({tagName:"code",children:e,properties:{"data-code":"","data-container-size":this.getOptionsWithDefaults().hunkSeparators==="line-info"?"":void 0,[`data-${t}`]:""}}))}pushFileLevelAnnotations(e,t,n,r){if(!li(n))return;let i=e.type!=="new"?this.getAnnotationNames(na(this.deletionAnnotations)):[],o=e.type!=="deleted"?this.getAnnotationNames(na(this.additionAnnotations)):[];if(i.length===0&&o.length===0)return;let s=-1,a=-1,{createAnnotationElement:l}=this;if(t==="unified"){bd({diffStyle:t,type:"context",unifiedSpan:{type:"annotation",hunkIndex:s,lineIndex:a,annotations:i.concat(o)},createAnnotationElement:l,context:r});return}bd({diffStyle:t,type:"context",deletionSpan:{type:"annotation",hunkIndex:s,lineIndex:a,annotations:i},additionSpan:{type:"annotation",hunkIndex:s,lineIndex:a,annotations:o},createAnnotationElement:l,context:r})}getAnnotations(e,t,n,r,i){let o={type:"annotation",hunkIndex:r,lineIndex:i,annotations:[]};if(t!=null)for(let a of this.deletionAnnotations[t]??[])o.annotations.push(this.annotationSlotName(a));let s={type:"annotation",hunkIndex:r,lineIndex:i,annotations:[]};if(n!=null)for(let a of this.additionAnnotations[n]??[])(e==="unified"?o:s).annotations.push(this.annotationSlotName(a));if(e==="unified"){if(o.annotations.length>0)return o;return}if(s.annotations.length===0&&o.annotations.length===0)return;return{deletionSpan:o,additionSpan:s}}getAnnotationNames(e){return e?.map((t)=>this.annotationSlotName(t))??[]}renderHeader(e){let{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return Ru({fileOrDiff:e,mode:t,stickyHeader:n})}},jN=new Intl.PluralRules("en-US");function qN(e){return`${e} unmodified line${jN.select(e)==="one"?"":"s"}`}function XI(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter("unified",n.gutter),t.incrementRowCount(1)}function YI(e,t,n){for(let{deletion:r,addition:i}of e){if(r==null&&i==null)continue;let o=r!=null&&i!=null?void 0:r==null?"deletions":"additions";if(o==null||n.side!==o)n.flush();if(r!=null)t.deletionsContentAST.push(r.content),t.pushToGutter("deletions",r.gutter);if(i!=null)t.additionsContentAST.push(i.content),t.pushToGutter("additions",i.gutter);if(o!=null)n.side=o,n.increment();t.incrementRowCount(1)}}function bd({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:o,additionSpan:s,createAnnotationElement:a,context:l}){let d=!1;if(e==="unified"){if(r!=null)l.unifiedContentAST.push(r);else if(n!=null)l.unifiedContentAST.push(n);if(i!=null){let c=t==="change"?n!=null?"change-deletion":"change-addition":t;l.unifiedContentAST.push(a(i)),l.pushToGutter("unified",en(c,"annotation",1)),d=!0}}else if(e==="split"){if(n!=null)l.deletionsContentAST.push(n);if(r!=null)l.additionsContentAST.push(r);if(o!=null){let c=t==="change"?n!=null?"change-deletion":"context":t;l.deletionsContentAST.push(a(o)),l.pushToGutter("deletions",en(c,"annotation",1)),d=!0}if(s!=null){let c=t==="change"?r!=null?"change-addition":"context":t;l.additionsContentAST.push(a(s)),l.pushToGutter("additions",en(c,"annotation",1)),d=!0}}if(d)l.incrementRowCount(1)}function np(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:o,isLastHunk:s,isExpandable:a},l){if(typeof n==="number"&&n<=0)return;let d=e==="unified"?l.unifiedContentAST:e==="deletions"?l.deletionsContentAST:l.additionsContentAST;if(l.hunkSeparators==="metadata"){if(i!=null){if(l.pushToGutter(e,no({type:"metadata",content:i,isFirstHunk:o,isLastHunk:s})),d.push(no({type:"metadata",content:i,isFirstHunk:o,isLastHunk:s})),e!=="additions")l.incrementRowCount(1)}return}if(l.hunkSeparators==="simple"){if(t>0){if(l.pushToGutter(e,no({type:"simple",isFirstHunk:o,isLastHunk:!1})),d.push(no({type:"simple",isFirstHunk:o,isLastHunk:!1})),e!=="additions")l.incrementRowCount(1)}return}let c=KI(e,t),m=r>l.expansionLineCount,p=a?t:void 0,h=typeof n==="number"?qN(n):"More unchanged context may be available";if(l.pushToGutter(e,no({type:l.hunkSeparators,content:h,expandIndex:p,chunked:m,slotName:c,isFirstHunk:o,isLastHunk:s})),d.push(no({type:l.hunkSeparators,content:h,expandIndex:p,chunked:m,slotName:c,isFirstHunk:o,isLastHunk:s})),e!=="additions")l.incrementRowCount(1);l.hunkData.push({slotName:c,hunkIndex:t,lines:typeof n==="number"?n:0,lineCountKnown:typeof n==="number",type:e,expandable:a?{up:!o,down:!s,chunked:m}:void 0})}function Cd(e,t,n){if(e==null||e.type!=="element"||t==null&&n==null)return e;return{...e,properties:{...e.properties,...t,...n}}}function JI(e){return e.length>0&&e[e.length-1]===""?e.length-1:e.length}function zN(e,t,n,r){let i=JI(e),o=JI(t),s=Math.min(i,o),a=0;while(a<s&&e[a]===t[a])a++;let l=0;while(l<s-a&&e[i-1-l]===t[o-1-l])l++;let d=Array(t.length);for(let c=0;c<a;c++)d[c]=n[c];for(let c=0;c<l;c++)d[o-1-c]=n[i-1-c];if(i<e.length&&o<t.length)d[t.length-1]=n[e.length-1];for(let c=a;c<t.length;c++)d[c]??=ip(c,r.getLineText(c));return d}function ip(e,t,n=e,r=e){return{type:"element",tagName:"div",properties:{"data-line":e+1,"data-line-index":`${n},${r}`,"data-line-type":"context"},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:t}]}]}}function KN(e){let t=[];for(let n=0;n<e.lineCount;n++)t.push(e.getLineText(n,!0));return t}function rp(e){if(e.lang!=null)return[e.lang];let t=tt(e.prevName??e.name),n=tt(e.name);return t===n?[n]:[t,n]}function Ia(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function VN(e,t){return e.isPartial&&t&&(e.type==="change"||e.type==="rename-changed")}function tS(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function nS(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function rS(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:Zu(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators==="function"?"custom":e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader!=null?"custom":"default"}}function WN(e){return e.isPartial&&(e.type==="change"||e.type==="rename-changed"||e.type==="rename-pure")}function XN(e){let t={...e};return delete t.cacheKey,t}function iS(e,t){if(e.isPartial||t.isPartial)throw Error("FileDiff.shouldResetEditorForExternalDiff: diffs must be fully hydrated");let n=e.lang??tt(e.name),r=t.lang??tt(t.name),i=e.type!=="new",o=t.type!=="new";if(e.name!==t.name||n!==r||i!==o||e.deletionLines.length!==t.deletionLines.length)return!0;return e.deletionLines.some((s,a)=>s!==t.deletionLines[a])}function YN(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function JN(e,t){let{oldFile:n}=e;if(n==null)return t.type==="new";return t.type!=="new"&&n.name===(t.prevName??t.name)&&YN(n.lines,t.deletionLines)}var ZN=-1,aS=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++ZN}`;type="file-diff";fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;editSession;renderedDiff;renderRange;pendingFiles;appliedPreAttributes;headerCache={lastRenderedHTML:void 0,html:void 0,fileDiff:void 0};lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;lineStateRefreshPending=!1;deferredSelectedLines;deferredEditorActiveLine;constructor(e={theme:Oe},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new ku,this.scrollSyncManager=new NI,this.interactionManager=new Tu("diff",jo(e,typeof e.hunkSeparators==="function"||(e.hunkSeparators??"line-info")==="line-info"||e.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??Oe}getHunksRendererOptions(e){return rS(e)}createHunksRenderer(e){return new eS(this.getHunksRendererOptions(e),this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t="additions")=>this.getLineIndexForDiff(this.getDiffForLineIndex(),e,t);getDiffForLineIndex(){return this.getRenderedDiff()}getLineIndexForDiff(e,t,n){if(e==null)return;let r=e.hunks.at(-1),i,o;e:for(let s of e.hunks){let a=n==="deletions"?s.deletionStart:s.additionStart,l=n==="deletions"?s.deletionCount:s.additionCount,d=Tt(a,l)+1,c=s.splitLineStart,m=s.unifiedLineStart;if(t<d){let p=d-t;i=Math.max(m-p,0),o=Math.max(c-p,0);break e}if(t>=d+l){if(s===r){let p=t-(d+l);i=m+s.unifiedLineCount+p,o=c+s.splitLineCount+p;break e}continue}for(let p of s.hunkContent)if(p.type==="context")if(t<d+p.lines){let h=t-d;o=c+h,i=m+h;break e}else d+=p.lines,c+=p.lines,m+=p.lines;else{let h=n==="deletions"?p.deletions:p.additions;if(t<d+h){let x=t-d;i=m+(n==="additions"?p.deletions:0)+x,o=c+x;break e}else d+=h,c+=Math.max(p.deletions,p.additions),m+=p.deletions+p.additions}break e}if(i==null||o==null)return;return[i,o]}setOptions(e){if(e==null)return;this.options=e,this.clearReusableHeader(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions()}syncInteractionOptions(){this.interactionManager.setOptions(jo(this.options,typeof this.options.hunkSeparators==="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){if((this.options.themeType??"system")===e)return;this.mergeOptions({themeType:e}),this.applyCachedThemeState(e)}applyCachedThemeState(e){if(typeof this.options.theme==="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;if(this.appliedThemeCSS.themeType===t)return!1;return this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Cn(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();getAnnotationSlotName=(e)=>Ju(this.editSession?.annotations,e,dn);getLatestAnnotations(){return this.editSession?.annotations?.current??this.lineAnnotations}isNewAnnotations(e){let t=this.editSession?.annotations;if(e===this.lineAnnotations)return!1;return t==null||e!==t.provided&&e!==t.current}setLineAnnotations(e){let t=this.editSession?.annotations;if(t==null){this.lineAnnotations=e;return}if(!this.isNewAnnotations(e))return;this.lineAnnotations=e,Yu(t,e,dn)}syncEditSessionAnnotationsFromEditor(e){let t=this.editSession?.annotations;if(t==null||e===t.current)return!1;return t.current=e,this.hunksRenderer.setLineAnnotations(e),this.renderAnnotations(),!0}canPartiallyRender(e,t,n){if(e||t||n||typeof this.options.hunkSeparators==="function")return!1;return!0}setSelectedLines(e,t){if(this.lineStateRefreshPending)this.deferredSelectedLines=[e,t];else this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){if(this.lineStateRefreshPending)this.deferredEditorActiveLine=[e,t];else this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??"additions"})}flushDeferredLineState(){let{deferredEditorActiveLine:e,deferredSelectedLines:t}=this;if(this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,e!=null)this.setEditorActiveLine(...e);if(t!=null)this.interactionManager.setSelection(...t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e="split",overflow:t="scroll"}=this.options;if(this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t==="wrap",columnVariables:this.shouldApplyColumnVariables(t)?"apply":"measure"}),t==="scroll"&&e==="split")this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions);else this.scrollSyncManager.cleanUp();this.managersDirty=!1}shouldApplyColumnVariables(e){if(typeof this.options.hunkSeparators==="function")return!0;return e==="scroll"&&(this.getLatestAnnotations().length>0||this.pre?.hasAttribute("data-has-merge-conflict")===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){if(this.codeUnified!=null)this.codeUnified.scrollLeft=e;if(this.codeAdditions!=null)this.codeAdditions.scrollLeft=e;if(this.codeDeletions!=null)this.codeDeletions.scrollLeft=e}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){let{editor:t}=this;if(di(this.handleEditSessionRender),this.emitPostRender(!0),t?.cleanUp(e?"recycle":"discard"),!e)this.editor=void 0;if(this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,!e)this.pendingFiles=void 0;if(!this.isContainerManaged)this.fileContainer?.remove();if(this.fileContainer=void 0,this.mounted=!1,!e)this.lineAnnotations=[];if(this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.headerCache.lastRenderedHTML=void 0,!e)this.clearReusableHeader();if(this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e)this.hunksRenderer.recycle();else this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.editSession=void 0,this.renderedDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0;if(this.refreshViewTimeout!=null)clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:r,fileDiff:i,...o}){if(!this.enabled)throw Error("FileDiff.hydrate: attempting to call hydrate after cleaned up");if(this.fileContainer!=null)throw Error("FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated");let s=ca(o,"FileDiff.hydrate"),a=s?.oldFile,l=s?.newFile;this.hydrateElements(e,t);let d=this.editor!=null;if(d||tD(this.pre,QN({fileDiff:i,oldFile:a,newFile:l}),this.options.collapsed)||nD(this.headerElement,eD({fileDiff:i,oldFile:a,newFile:l}),this.options.disableFileHeader))this.render({...o,fileContainer:e,lineAnnotations:r,fileDiff:i,forceRender:d||o.forceRender,preventEmit:!0});else this.hydrationSetup({fileDiff:i,lineAnnotations:r,...s});if(!n)this.emitPostRender()}hydrateElements(e,t){if(this.fileContainer!==e)this.emitPostRender(!0);ed(e,t);for(let n of e.shadowRoot?.children??[]){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(!(n instanceof HTMLElement))continue;if(n instanceof HTMLPreElement){this.pre=n;for(let r of n.children){if(!(r instanceof HTMLElement)||r.tagName.toLowerCase()!=="code")continue;if("deletions"in r.dataset)this.codeDeletions=r;if("additions"in r.dataset)this.codeAdditions=r;if("unified"in r.dataset)this.codeUnified=r}continue}if("diffsHeader"in n.dataset){this.headerElement=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}}if(this.pre!=null)this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute("data-dehydrated");this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){if(this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?Kn(t,n,this.options.parseDiffOptions):void 0),this.pre==null)return;this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderedDiff=this.fileDiff,this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers()}rerender(){if(!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null)return;this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.loadFilesIfNecessary(),this.rerender()};loadFilesIfNecessary(){let{fileDiff:e,options:{loadDiffFiles:t}}=this;if(e==null||t==null||!WN(e)||this.pendingFiles?.fileDiff===e)return;let n=this.loadFilesForDiff(e,t),r=this.pendingFiles={fileDiff:e,promise:n},i=()=>{if(this.pendingFiles===r)this.pendingFiles=void 0};r.promise=n.finally(i)}async loadFilesForDiff(e,t){try{let n=await t(e);if(!this.enabled||this.fileDiff!==e)return;await this.handleFilesLoaded(e,n)}catch(n){if(this.options.disableErrorHandling===!0)throw n;console.error(n)}}async handleFilesLoaded(e,t){if(this.fileDiff!==e||!e.isPartial)return;if(ma("merge",e,t),this.setHydratedState(t),this.startHydratedEditSession(e)){this.rerender();return}if(await da(()=>this.primeHighlightCache(e)),!this.enabled||this.fileDiff!==e)return;this.rerender()}startHydratedEditSession(e){if(e.isPartial)throw Error("FileDiff.startHydratedEditSession: diffs cannot be partial for editing");if(this.fileDiff!==e)return!1;let{editor:t}=this;if(this.editSession?.outgoingDiff!=null)return this.installEditSession(e),!0;if(t==null||this.editSession!=null)return!1;return this.installEditSession(e,t.__getDocumentContents(op(e)),t.__getDocumentSessionState()),!0}updateExternalDiff(e,t){if(ze(this.fileDiff,e))return!1;let n=this.editSession?.outgoingDiff??this.editSession?.diff;if(this.fileDiff=e,n!=null){if(e.isPartial)this.loadFilesIfNecessary();else this.installEditSession(e);if(this.editSession!=null)this.editSession.outgoingDiff=n}else if(this.editor!=null)if(e.isPartial)this.loadFilesIfNecessary();else this.installEditSession(e,this.editor.__getDocumentContents(op(e)),this.editor.__getDocumentSessionState());if(this.editSession?.annotations!=null&&t!=null)this.lineAnnotations=t,this.editSession.annotations=Yo(t,dn,this.editSession.annotations);return!0}installEditSession(e,t,n){let r=e.additionLines.join(""),i=t!=null?Qo(t.contents):void 0,o=n!=null&&JN(n,e);if(n!=null&&!o)throw Error("FileDiff: retained session cannot resume against a different old file");if(t!=null&&t.contents!==r&&!o)throw Error("FileDiff: retained edits are missing their diff session state");let s=t==null||t.name===e.name&&t.lang===e.lang&&t.contents===r,a=XN(e);if(t!=null&&i!=null&&!s)a.name=t.name,a.lang=t.lang;if(o&&n!=null&&i!=null)a.additionLines=i,a.type=n.type,a.hunks=n.hunks,a.editSessionDirty=!0,ns(a);this.editSession={diff:a,annotations:this.editSession?.annotations??Yo(this.lineAnnotations,dn),outgoingDiff:this.editSession?.outgoingDiff},this.hunksRenderer.beginEditSession(a,s&&!o?e:void 0)}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:r=!1,lineAnnotations:i,fileContainer:o,containerWrapper:s,renderRange:a,...l}){if(!this.enabled)throw Error("FileDiff.render: attempting to call render after cleaned up");let d=ca(l,"FileDiff.render"),c=d?.oldFile,m=d?.newFile;this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:p=!1,themeType:h="system",expandUnchanged:x=!1}=this.options,I=p?void 0:a,v=this.hasThemeChanged(),S=d!=null,b=S&&(!oS(c,this.deletionFile)||!oS(m,this.additionFile)),E=e!=null&&!ze(e,this.fileDiff),w=i!=null&&(i.length>0||this.getLatestAnnotations().length>0)?this.isNewAnnotations(i):!1;if(!p&&ci(I,this.renderRange)&&!n&&!w&&!v&&(e!=null&&!E||e==null&&!b)){let D=this.applyCachedThemeState(h);if(D)this.finalizeRender();return D}let k;if(e==null&&S&&(b||this.fileDiff==null))k=Kn(d.oldFile,d.newFile,this.options.parseDiffOptions);let{renderRange:L}=this;if(this.renderRange=I,S)this.deletionFile=c,this.additionFile=m;else if(e!=null)this.deletionFile=void 0,this.additionFile=void 0;if(e!=null&&E)this.updateExternalDiff(e,i);else if(k!=null)E=!0,this.updateExternalDiff(k,i);if(E)this.clearReusableHeader();if(i!=null)this.setLineAnnotations(i);let R=this.getLatestDiff();if(R==null)return!1;if(R.editSessionDirty===!0&&this.shouldSelfHealEditSession())Qf(R,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult();if(x)this.loadFilesIfNecessary();this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.getLatestAnnotations());let{disableErrorHandling:A=!1,disableFileHeader:O=!1}=this.options;if(O){if(this.headerElement!=null)this.headerElement.remove(),this.headerElement=void 0,this.headerCache.lastRenderedHTML=void 0;this.clearHeaderSlots()}if(o=this.getOrCreateFileContainer(o,s),this.applyCachedThemeState(h),p){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let D=this.hunksRenderer.renderDiff(R,rd);if(D!=null)this.applyThemeState(o,D.themeStyles,h,D.baseThemeType);if(D?.headerElement!=null)this.applyHeaderToDOM(D.headerElement,o,D.fileDiff);this.renderSeparators([]),this.renderedDiff=D?.fileDiff??R,this.injectUnsafeCSS()}catch(D){if(A)throw D;if(console.error(D),D instanceof Error)this.applyErrorToDOM(D,o)}if(this.finalizeRender(),!r)this.emitPostRender();return!0}try{let D=this.getOrCreatePreNode(o);if(!(this.canPartiallyRender(n,w,b||E||v||!ze(this.renderedDiff,R))&&this.applyPartialRender({fileDiff:R,previousRenderRange:L,renderRange:I}))){let X=this.hunksRenderer.renderDiff(R,I);if(X==null){if(this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool())this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender());return!1}if(this.applyThemeState(o,X.themeStyles,h,X.baseThemeType),X.headerElement!=null)this.applyHeaderToDOM(X.headerElement,o,X.fileDiff);if(X.additionsContentAST!=null||X.deletionsContentAST!=null||X.unifiedContentAST!=null)this.applyHunksToDOM(D,X);else if(this.pre!=null)this.pre.remove(),this.pre=void 0;this.renderSeparators(X.hunkData),this.renderedDiff=X.fileDiff}if(this.applyBuffers(D,I),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,!t)this.flushManagers();if(this.finalizeRender(),this.editor!=null)this.syncRenderViewToEditor()}catch(D){if(A)throw D;if(console.error(D),D instanceof Error)this.applyErrorToDOM(D,o)}if(!r)this.emitPostRender();return!0}finalizeRender(){}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted)return;if(this.mounted=!1,t==null)return;this.options.onPostRender?.(t,this,"unmount");return}if(t==null)return;let r=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,r)}getLatestDiff(e=this.fileDiff){return this.editSession?.diff??e}getRenderedDiff(){return this.renderedDiff}syncRenderViewToEditor(){let{editor:e,fileContainer:t}=this,n=this.getLatestAnnotations(),r=this.computeEditorRenderRange(this.renderRange),i=this.getLatestDiff();if(e==null||t==null||i==null||i.isPartial)return;let o=(d)=>{if(!this.enabled||this.editor!==e||this.fileContainer!==t||this.getLatestDiff()!==i)return;let c=this.editSession?.outgoingDiff,m=this.fileDiff,p=c!=null&&m!=null&&c!==i,h=p?iS(c,m):!1;e.__syncRenderView({highlighter:d,fileContainer:t,fileDiff:i,lineAnnotations:n,renderRange:r,externalDocument:p,resetHistory:h})},s=this.getTheme(),a=i.lang??tt(i.name),l=jn({theme:s,lang:a});if(l!=null)o(l);else sr({themes:On(s),langs:["text",a],preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter}).then(o)}computeEditorRenderRange(e){let t=this.getLatestDiff();if(e==null||t==null||Yi(e))return e;let{diffStyle:n="split",expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,o,s;if(zn({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({additionLine:a})=>{if(a!=null)o??=a.lineNumber,s=a.lineNumber}}),o==null||s==null)return{...e,startingLine:0,totalLines:0};return{...e,startingLine:o-1,totalLines:s-o+1}}__acknowledgeDocumentUpdate(){if(this.editSession!=null)this.editSession.outgoingDiff=void 0}__acceptEditorChange(e){let{lineAnnotations:t}=e;if(t!=null)this.syncEditSessionAnnotationsFromEditor(t)}emitEditChange(e){let{onEditChange:t}=this.options;t?.(e)}__captureDocumentSessionState(e=!0){let{fileDiff:t,editSession:{diff:n,outgoingDiff:r}={}}=this;if(r!=null&&t!=null){if(!t.isPartial&&iS(r,t))return;n=r}if(n==null||n.isPartial)return;return{diffSession:{oldFile:n.type!=="new"?{name:n.prevName??n.name,lines:e?[...n.deletionLines]:n.deletionLines}:null,type:n.type,hunks:e?sS(n.hunks):n.hunks},hasChanges:n.editSessionDirty===!0}}__attachEditor(e){if(this.type!=="file-diff")throw Error(`FileDiff.__attachEditor: cannot attach an editor to a "${this.type}" diff`);if(this.editor!=null)throw Error("FileDiff.__attachEditor: an editor is already attached");let t=()=>{this.editor=void 0,this.finishEditSession()};try{return this.resumeEditorRendering(e),t}catch(n){throw t(),n}}__resumeEditor(e){if(this.editor!==e)throw Error("FileDiff.__resumeEditor: editor association changed");this.resumeEditorRendering(e)}resumeEditorRendering(e){let{fileDiff:t}=this,n=this.editSession?.outgoingDiff;if(n!=null&&t!=null&&!t.isPartial&&this.editSession?.diff===n)this.installEditSession(t);let r=this.editSession==null&&t!=null&&!t.isPartial?t:void 0;if(r!=null)this.installEditSession(r,e.__getDocumentContents(op(r)),e.__getDocumentSessionState());else if(this.editSession!=null)this.hunksRenderer.beginEditSession(this.editSession.diff);if(this.editor=e,this.fileDiff?.isPartial===!0)this.loadFilesIfNecessary();let i=this.editSession?.diff;if(this.hunksRenderer.editorRenderReady()){if(i!=null&&this.hunksRenderer.diffCache===i)this.renderedDiff=i;this.syncRenderViewToEditor()}else this.rerender()}finishEditSession(){this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks()}__completeEditSession(e,t){this.settleEditSession(t==="install",e)}settleEditSession(e,t){let{editSession:n,fileDiff:r,lineAnnotations:i}=this;if(n==null||r==null)return;let{diff:o,annotations:s}=n;if(this.editor!=null)throw Error("FileDiff.__completeEditSession: detach the editor before completing the session");this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks();let a=s?.current,l,d=null,c=null,m=!1,p;if(t==null)throw Error("FileDiff.__completeEditSession: editor is required for completion");let h=ld(o),x={name:h.name,contents:h.additionLines.join("")};if(h.lang!=null)x.lang=h.lang;let I={fileDiff:h,editor:t,originalFileDiff:r,oldFile:h.type==="new"?null:{name:h.prevName??h.name,contents:h.deletionLines.join("")},newFile:x,lineAnnotations:a,originalLineAnnotations:i};Object.freeze(I);try{if(t.__emitEditComplete(I),this.options.onEditComplete?.(I)==="accept"){if(h.cacheKey!=null&&h.cacheKey===r.cacheKey)throw Error("FileDiff.__completeEditSession: an accepted diff must not reuse the replaced diff cacheKey");l=h,d=I.oldFile,c=I.newFile}}catch(v){m=!0,p=v}if(e&&l!=null){if(this.fileDiff=l,this.additionFile!=null)this.deletionFile=d,this.additionFile=c;if(a!=null)this.lineAnnotations=a}if(this.editSession=void 0,e&&this.fileContainer!=null)this.rerender();if(m)throw p}finalizeEditSessionHunks(){let e=this.getLatestDiff();if(e==null||e.editSessionDirty!==!0)return!1;let{collapsedContextThreshold:t=1}=this.options,n=qI(e,this.hunksRenderer.getExpandedHunksMap(),t);return Qf(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(zI(e,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){let n=this.editSession?.diff;if(n==null)throw Error("FileDiff.applyDocumentChange: requires an active edit session");if(this.detachAdditionLines(),this.hunksRenderer.beginEditSession(n),this.hunksRenderer.applyDocumentChange(e),t!=null)this.syncEditSessionAnnotationsFromEditor(t);this.rerender(),this.interactionManager.setSelectionDirty()}updateRenderCache(e,t,n={}){let r=this.editSession?.diff;if(r==null)throw Error("FileDiff.updateRenderCache: requires an active edit session");this.detachAdditionLines(),this.hunksRenderer.beginEditSession(r);let{shouldRefreshDiffsView:i,lineCountChangeInFlight:o}=n;if(this.hunksRenderer.updateRenderCache(e,t,o)){if(this.refreshViewTimeout!=null)clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0;this.lineStateRefreshPending=!0,this.escalateEditSessionRender();return}if(i===!0){if(this.refreshViewTimeout!=null)clearTimeout(this.refreshViewTimeout);this.lineStateRefreshPending=!0,this.refreshViewTimeout=setTimeout(()=>{if(this.refreshViewTimeout=void 0,this.options.diffStyle==="split")this.refreshSplitDiffView();else this.refreshUnifiedDiffView();this.flushDeferredLineState()},150)}}detachAdditionLines(){let e=this.editSession?.diff,{fileDiff:t}=this;if(e!=null&&(e.additionLines===t?.additionLines||e.additionLines===e.deletionLines))e.additionLines=[...e.additionLines]}isLineRenderable(e){let t=this.getRenderedDiff();if(t==null)return!0;let{expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options;return ad({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}getNearestRenderableLine(e,t){let n=this.getRenderedDiff();if(n==null)return e;let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;return bI({fileDiff:n,lineNumber:e,direction:t,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}revealLine(e){let t=this.getRenderedDiff(),{expandUnchanged:n=!1,collapsedContextThreshold:r=1,expansionLineCount:i=100}=this.options;if(t==null||t.isPartial||n)return!1;let o=this.hunksRenderer.getExpandedHunksMap();for(let[d,c]of t.hunks.entries()){let[m,p]=Zo(c);if(e<m){let h=cn({isPartial:t.isPartial,rangeSize:c.collapsedBefore,expandedHunks:o,hunkIndex:d,collapsedContextThreshold:r}),x=m-h.rangeSize;if(h.renderAll||e<x+h.fromStart||e>=m-h.fromEnd)return!1;let I=e-(x+h.fromStart)+1,v=m-h.fromEnd-e;if(I<=v)this.expandHunk(d,"up",I+i);else this.expandHunk(d,"down",v+i);return!0}if(e<p)return!1}let s=mn({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:o,collapsedContextThreshold:r,errorPrefix:"FileDiff.revealLine"});if(s==null||s.renderAll)return!1;let a=t.hunks[t.hunks.length-1],[,l]=Zo(a);if(e<l+s.fromStart||e>=l+s.rangeSize)return!1;return this.expandHunk(t.hunks.length,"up",e-(l+s.fromStart)+1+i),!0}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){Go(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender(),this.flushDeferredLineState()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}async primeHighlightCache(e=this.fileDiff){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||to(e))return;let n=this.options.tokenizeMaxLength??1e5;if(Math.max(e.additionLines.length,e.deletionLines.length)>n)return;await t.primeDiffHighlightCache(e).catch((r)=>{console.error(r)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.headerCache.lastRenderedHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!=="function"){for(let{element:r}of this.separatorCache.values())r.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let r of e){let i=r.slotName,o=this.separatorCache.get(i);if(o==null||!nS(r,o.hunkData)){o?.element.remove();let s=document.createElement("div");s.style.display="contents",s.slot=r.slotName;let a=t(r,this);if(a!=null)s.appendChild(a);this.fileContainer.appendChild(s),o={element:s,hunkData:r},this.separatorCache.set(i,o)}n.delete(i)}for(let[r,{element:i}]of n.entries())this.separatorCache.delete(r),i.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:r}of this.annotationCache.values())r.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options,n=this.getLatestAnnotations();if(t!=null&&n.length>0)for(let[r,i]of n.entries()){let o=this.getAnnotationSlotName(i),s=`${r}-${o}`,a=this.annotationCache.get(s);if(a==null||!tS(i,a.annotation)){a?.element.remove();let l=t(i);if(l==null)continue;a={element:Bu(o),annotation:i},a.element.appendChild(l),this.fileContainer.appendChild(a.element),this.annotationCache.set(s,a)}e.delete(s)}for(let[r,{element:i}]of e.entries())this.annotationCache.delete(r),i.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;else if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=Gu();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement("diffs-container"),i=n!==r;if(n!=null&&i)this.editor?.__captureFocusForDOMReplacement();if(i)this.emitPostRender(!0);if(this.fileContainer=r,n!=null&&i)this.headerCache.lastRenderedHTML=void 0,this.headerElement=void 0;if(t!=null&&this.fileContainer.parentNode!==t)t.appendChild(this.fileContainer);if(i)this.adoptReusableShellElements(this.fileContainer);return this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t==null)return;for(let n of t.children)if(n instanceof SVGElement)this.spriteSVG??=n;else if(ai(n)&&n.hasAttribute("data-theme-css"))this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0;else if(ai(n)&&n.hasAttribute("data-unsafe-css"))this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){let n=document.createElement("div");n.innerHTML=_u;let r=n.firstChild;if(r instanceof SVGElement)this.spriteSVG=r}if(this.spriteSVG!=null&&this.spriteSVG.parentNode!==t)t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.pre==null)this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre);else if(this.pre.parentNode!==t)this.editor?.__captureFocusForDOMReplacement(),t.appendChild(this.pre),this.appliedPreAttributes=void 0;return this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;if(t.hasAttribute("data-unified"))this.codeUnified=t;else if(t.hasAttribute("data-deletions"))this.codeDeletions=t;else if(t.hasAttribute("data-additions"))this.codeAdditions=t}}applyHeaderToDOM(e,t,n){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{headerCache:{fileDiff:r,html:i,lastRenderedHTML:o}}=this,s=(n!==this.editSession?.diff&&ze(r,n)?i:void 0)??ut(e);if(this.headerCache.html=s,this.headerCache.fileDiff=n,s!==o){let x=document.createElement("div");x.innerHTML=s;let I=x.firstElementChild;if(!(I instanceof HTMLElement))return;if(this.headerElement!=null)t.shadowRoot?.replaceChild(I,this.headerElement);else t.shadowRoot?.prepend(I);this.headerElement=I,this.headerCache.lastRenderedHTML=s}if(this.isContainerManaged)return;let{renderCustomHeader:a,renderHeaderPrefix:l,renderHeaderFilenameSuffix:d,renderHeaderMetadata:c}=this.options;if(a!=null){let x=a(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Wo,x),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let m=l?.(n)??void 0,p=d?.(n)??void 0,h=c?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,zo,m),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Ko,p),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,Vo,h),this.headerCustom?.remove(),this.headerCustom=void 0}clearReusableHeader(){this.headerCache.html=void 0,this.headerCache.fileDiff=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);if(t==null)e.appendChild(i);return this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){if(e.replaceChildren(),t instanceof Element)e.appendChild(t);else e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement("div");return t.slot=e,t}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t==null)return;if(e==null||e===""){if(this.unsafeCSSStyle!=null)this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0;this.appliedUnsafeCSS=void 0;return}if(this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e)return;if(this.unsafeCSSStyle??=ju(),this.unsafeCSSStyle.parentNode!==t)t.appendChild(this.unsafeCSSStyle);this.unsafeCSSStyle.textContent=Ku(e),this.appliedUnsafeCSS=e}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:"open"}),o=r??n,s=this.getTheme(),a=typeof s==="string"?s:{...s},l=mi(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===o&&this.appliedThemeCSS.scrollbarGutter===l){this.appliedThemeCSS.theme=a;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:a,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:l};return}this.themeCSSStyle=Qu({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:Vu(t,o,l)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:a,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:l}:void 0}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;if(e==null||this.themeCSSStyle==null)return;this.themeCSSStyle.textContent=Wu(this.themeCSSStyle.textContent??"",mi(e))}shouldGuardRebuildScroll(){return this.editor!=null&&id()}applyHunksToDOM(e,t){if(this.shouldGuardRebuildScroll())ua(e,()=>this.replaceCodeColumns(e,t));else this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){let r=this.getColumnPair(e);if(r==null)return!1;let i=pi(t[0]),o=pi(t[1]);if(i==null||o==null)return!1;if(r.gutter.innerHTML=ut(i),r.content.innerHTML=ut(o),n!==this.lastRowCount)r.gutter.style.setProperty("grid-row",`span ${n}`),r.content.style.setProperty("grid-row",`span ${n}`);return!0}replaceCodeColumns(e,t){let{overflow:n="scroll"}=this.options,r=(this.options.hunkSeparators??"line-info")==="line-info",i=n==="wrap"?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let o=!1,s=[],a=this.hunksRenderer.renderCodeAST("unified",t),l=this.hunksRenderer.renderCodeAST("deletions",t),d=this.hunksRenderer.renderCodeAST("additions",t);if(this.editor?.__captureFocusForDOMReplacement(),a!=null){if(o=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=Jo({code:this.codeUnified,columnType:"unified",rowSpan:i,containerSize:r}),!this.applyCodeColumnsInPlace(this.codeUnified,a,t.rowCount))this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(a);s.push(this.codeUnified)}else if(l!=null||d!=null){if(l!=null){if(o=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=Jo({code:this.codeDeletions,columnType:"deletions",rowSpan:i,containerSize:r}),!this.applyCodeColumnsInPlace(this.codeDeletions,l,t.rowCount))this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(l);s.push(this.codeDeletions)}else this.codeDeletions?.remove(),this.codeDeletions=void 0;if(d!=null){if(o=o||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=Jo({code:this.codeAdditions,columnType:"additions",rowSpan:i,containerSize:r}),!this.applyCodeColumnsInPlace(this.codeAdditions,d,t.rowCount))this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(d);s.push(this.codeAdditions)}else this.codeAdditions?.remove(),this.codeAdditions=void 0}else this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0;if(s.length===0)e.textContent="";else if(o)e.replaceChildren(...s);this.lastRowCount=t.rowCount}applyPartialRender({fileDiff:e,previousRenderRange:t,renderRange:n}){let{pre:r,codeUnified:i,codeAdditions:o,codeDeletions:s,options:{diffStyle:a="split"}}=this;if(r==null||t==null||n==null||!Number.isFinite(t.totalLines)||!Number.isFinite(n.totalLines)||this.lastRowCount==null)return!1;let l=this.getCodeColumns(a,i,s,o);if(l==null)return!1;let d=t.startingLine,c=n.startingLine,m=d+t.totalLines,p=c+n.totalLines,h=Math.max(d,c),x=Math.min(m,p);if(x<=h)return!1;let I=Math.max(0,h-d),v=Math.max(0,m-x),S=this.trimColumns({columns:l,trimStart:I,trimEnd:v,previousStart:d,overlapStart:h,overlapEnd:x,diffStyle:a});if(S<0)throw Error("FileDiff.applyPartialRender: failed to trim to overlap");if(this.lastRowCount<S)throw Error("FileDiff.applyPartialRender: trimmed beyond DOM row count");let b=this.lastRowCount-S,E=(R,A)=>{if(A<=0)return;return this.hunksRenderer.renderDiff(e,{startingLine:R,totalLines:A,bufferBefore:0,bufferAfter:0})},w=E(c,Math.max(h-c,0));if(w==null&&c<h)return!1;let k=E(x,Math.max(p-x,0));if(k==null&&p>x)return!1;let L=(R,A)=>{if(R==null)return;if(a==="unified"&&!Array.isArray(l))this.insertPartialHTML(a,l,R,A);else if(a==="split"&&Array.isArray(l))this.insertPartialHTML(a,l,R,A);else throw Error("FileDiff.applyPartialRender.applyChunk: invalid chunk application");b+=R.rowCount,this.renderedDiff=R.fileDiff};if(this.cleanupErrorWrapper(),L(w,"afterbegin"),L(k,"beforeend"),this.lastRowCount!==b)this.applyRowSpan(a,l,b),this.lastRowCount=b;return!0}insertPartialHTML(e,t,n,r){if(e==="unified"&&!Array.isArray(t)){let i=this.hunksRenderer.renderCodeAST("unified",n);this.renderPartialColumn(t,i,r)}else if(e==="split"&&Array.isArray(t)){let i=this.hunksRenderer.renderCodeAST("deletions",n),o=this.hunksRenderer.renderCodeAST("additions",n);this.renderPartialColumn(t[0],i,r),this.renderPartialColumn(t[1],o,r)}else throw Error("FileDiff.insertPartialHTML: Invalid argument composition")}refreshSplitDiffView(){let e=this.getLatestDiff();if(this.options.diffStyle!=="split"||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns("split",this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(n))return;let r=(i,o)=>{if(o==null)return;let s=this.hunksRenderer.renderCodeAST(i,t),a=pi(s?.[0]),l=pi(s?.[1]);for(let[d,c]of[[o.gutter,a],[o.content,l]])if(c!=null&&d.childElementCount===c.length)for(let m=0;m<c.length;m++){let p=d.children[m],h=c[m].properties["data-line-type"];if(h!=null&&p.dataset.lineType!==h)p.dataset.lineType=h}};r("deletions",n[0]),r("additions",n[1]),this.renderedDiff=t.fileDiff}refreshUnifiedDiffView(){let e=this.getLatestDiff();if(this.options.diffStyle!=="unified"||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns("unified",this.codeUnified,this.codeDeletions,this.codeAdditions);if(n==null||Array.isArray(n))return;let r=this.hunksRenderer.renderCodeAST("unified",t),i=pi(r?.[0]),o=pi(r?.[1]),s=()=>{for(let[a,l]of[[n.gutter,i],[n.content,o]])if(l!=null)a.innerHTML=ut(l);if(t.rowCount!==this.lastRowCount)this.applyRowSpan("unified",n,t.rowCount),this.lastRowCount=t.rowCount;this.renderedDiff=t.fileDiff};if(this.shouldGuardRebuildScroll())ua(this.pre,s);else s();this.renderSeparators(t.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=pi(t[0]),i=pi(t[1]);if(r==null||i==null)throw Error("FileDiff.insertPartialHTML: Unexpected AST structure");let o=i.at(0);if(n==="beforeend"&&o?.type==="element"&&typeof o.properties["data-buffer-size"]==="number")this.mergeBuffersIfNecessary(o.properties["data-buffer-size"],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let s=i.at(-1);if(n==="afterbegin"&&s?.type==="element"&&typeof s.properties["data-buffer-size"]==="number")this.mergeBuffersIfNecessary(s.properties["data-buffer-size"],e.content.children[0],e.gutter.children[0],r,i,!1);e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,o){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let s=this.getBufferSize(t.dataset);if(s==null)return;if(o)r.shift(),i.shift();else r.pop(),i.pop();this.updateBufferSize(t,s+e),this.updateBufferSize(n,s+e)}applyRowSpan(e,t,n){let r=(i)=>{if(i==null)return;i.gutter.style.setProperty("grid-row",`span ${n}`),i.content.style.setProperty("grid-row",`span ${n}`)};if(e==="unified"&&!Array.isArray(t))r(t);else if(e==="split"&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error("dun fuuuuked up")}trimColumnRows(e,t,n){let r=0,i=0,o=0,s=!1,a=n>=0;if(e==null)return 0;let l=Array.from(e.content.children),d=Array.from(e.gutter.children);if(l.length!==d.length)throw Error("FileDiff.trimColumnRows: columns do not match");while(o<l.length){if(t<=0&&!a&&!s)break;let c=d[o],m=l[o];if(o++,!(c instanceof HTMLElement)||!(m instanceof HTMLElement))throw console.error({gutterElement:c,contentElement:m}),Error("FileDiff.trimColumnRows: invalid row elements");if(s){if(s=!1,c.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in m.dataset||c.dataset.gutterBuffer==="metadata"&&"noNewline"in m.dataset){c.remove(),m.remove(),i++;continue}}if("lineIndex"in c.dataset&&"lineIndex"in m.dataset){if(t>0||a&&r>=n){if(c.remove(),m.remove(),t>0){if(t--,t===0)s=!0}i++}r++;continue}if("separator"in c.dataset&&"separator"in m.dataset){if(t>0||a&&r>=n)c.remove(),m.remove(),i++;continue}if(c.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in m.dataset){if(t>0||a&&r>=n)c.remove(),m.remove(),i++;continue}if(c.dataset.gutterBuffer==="metadata"&&"noNewline"in m.dataset){if(t>0||a&&r>=n)c.remove(),m.remove(),i++;continue}if(c.dataset.gutterBuffer==="buffer"&&"contentBuffer"in m.dataset){let p=this.getBufferSize(m.dataset);if(p==null)throw Error("FileDiff.trimColumnRows: invalid element");if(t>0){let h=Math.min(t,p),x=p-h;if(x>0)this.updateBufferSize(c,x),this.updateBufferSize(m,x),i+=h;else c.remove(),m.remove(),i+=p;if(t-=h,t===0&&x===0)s=!0}else if(a){let h=r,x=r+p-1;if(n<=h)c.remove(),m.remove(),i+=p;else if(n<=x){let I=x-n+1,v=p-I;this.updateBufferSize(c,v),this.updateBufferSize(m,v),i+=I}}r+=p;continue}throw console.error({gutterElement:c,contentElement:m}),Error("FileDiff.trimColumnRows: unknown row elements")}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:o,trimStart:s}){let a=Math.max(0,r-i),l=n-i;if(l<0)throw Error("FileDiff.trimColumns: overlap ends before previous");let d=s>0,c=o>0;if(!d&&!c)return 0;let m=d?a:0,p=c?l:-1;if(t==="unified"&&!Array.isArray(e))return this.trimColumnRows(e,m,p);else if(t==="split"&&Array.isArray(e)){let h=this.trimColumnRows(e[0],m,p),x=this.trimColumnRows(e[1],m,p);if(e[0]!=null&&e[1]!=null&&h!==x)throw Error("FileDiff.trimColumns: split columns out of sync");return e[0]!=null?h:x}else throw console.error({diffStyle:t,columns:e}),Error("FileDiff.trimColumns: Invalid columns for diffType")}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??"",10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty("grid-row",`span ${t}`),e.style.setProperty("min-height",`calc(${t} * 1lh)`)}getColumnPair(e){if(e==null)return;let t=e.children[0],n=e.children[1];if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null)return;return{gutter:t,content:n}}getCodeColumns(e,t,n,r){if(e==="unified")return this.getColumnPair(t);else{let i=this.getColumnPair(n),o=this.getColumnPair(r);return i!=null||o!=null?[i,o]:void 0}}updateBuffers(e){if(this.pre!=null)this.applyBuffers(this.pre,e)}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){if(this.bufferBefore!=null)this.bufferBefore.remove(),this.bufferBefore=void 0;if(this.bufferAfter!=null)this.bufferAfter.remove(),this.bufferAfter=void 0;return}if(t.bufferBefore>0){if(this.bufferBefore==null)this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore);this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")}else if(this.bufferBefore!=null)this.bufferBefore.remove(),this.bufferBefore=void 0;if(t.bufferAfter>0){if(this.bufferAfter==null)this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter);this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")}else if(this.bufferAfter!=null)this.bufferAfter.remove(),this.bufferAfter=void 0}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:o="bars",disableBackground:s=!1,disableLineNumbers:a=!1,overflow:l="scroll",diffStyle:d="split"}=this.options,c={type:"diff",diffIndicators:o,disableBackground:s,disableLineNumbers:a,overflow:l,split:d==="unified"?!1:t!=null&&n!=null,totalLines:r,customProperties:i};if(Uu(c,this.appliedPreAttributes))return;td(e,c),this.appliedPreAttributes=c}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);let r=document.createElement("div");r.dataset.errorMessage="",r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement("pre");i.dataset.errorStack="",i.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function op(e){return{name:e.name,lang:e.lang,contents:e.additionLines.join("")}}function oS(e,t){if(e==null||t==null)return e==null&&t==null;return sd(e,t)}function QN({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function eD({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function tD(e,t,n=!1){return!n&&e==null&&t}function nD(e,t,n=!1){return e==null&&t&&!n}function pi(e){if(e==null||e.type!=="element")return;return e.children??[]}var ap=3000,Ed=new Map,rD=-1,cS=class extends aS{__id=`little-virtualized-file-diff:${++rD}`;renderType="virtualized";top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0,ghostTextRows:Ed,ghostTextRowsByIndex:new Map};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;pendingHydratedDiff;pendingExpansions;pendingRender;constructor(e,t,n,r,i=!1){super(e,r,i);this.virtualizer=t,this.metrics=Bo(n)}setMetrics(e,t=!1){let n=Bo(e);if(!t&&ar(this.metrics,n))return;this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0})}setLineAnnotations(e){if(this.syncLineAnnotations(e))this.resetLayoutCache({includeEstimatedHeights:!1})}syncLineAnnotations(e){if(e==null||!this.isNewAnnotations(e)||e.length===0&&this.getLatestAnnotations().length===0)return!1;return super.setLineAnnotations(e),!0}syncEditSessionAnnotationsFromEditor(e){if(super.syncEditSessionAnnotationsFromEditor(e))return this.resetLayoutCache({includeEstimatedHeights:!1}),!0;return!1}setFileAnnotationHeight(e){let t=this.cache.fileAnnotationHeight;if(e===t)return!1;return this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0}hasFileAnnotations(e){let t=this.getLatestAnnotations();if(!ta(t))return!1;return t.some((n)=>{if(n.lineNumber!==0)return!1;if(e.type==="new")return n.side==="additions";if(e.type==="deleted")return n.side==="deletions";return!0})}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error("VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(e==null)return;let{options:t}=this,n=!_o(t,e),r=n&&uD(t,e);if(super.setOptions(e),r)this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:dD(t,e)});if(n)this.forceRenderOverride=!0;if(n&&this.isSimpleMode())this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error("VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){if(this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal=0,this.cache.ghostTextRows=Ed,this.cache.ghostTextRowsByIndex.size>0)this.cache.ghostTextRowsByIndex.clear();if(this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode())this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){if(this.layoutDirty=!0,this.cache.checkpoints.length>0)this.cache.checkpoints.length=0;if(this.cache.totalLines!==0)this.cache.totalLines=0;if(e)this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;if(this.renderRange!=null&&t)this.renderRange=void 0}applyGhostTextRows(e,t){let{cache:{heightDeltas:n,ghostTextRows:r,ghostTextRowsByIndex:i},metrics:{lineHeight:o}}=this;if(r===t)return!1;let s=this.getDiffStyle(),a=new Map;for(let[d,c]of t){let m=this.getLineIndexForDiff(e,d+1,"additions");if(m==null)continue;a.set(s==="split"?m[1]:m[0],c)}let l=!1;for(let d of new Set([...i.keys(),...a.keys()])){let c=((a.get(d)??0)-(i.get(d)??0))*o;if(c===0)continue;let m=(n.get(d)??0)+c;if(m===0)n.delete(d);else n.set(d,m);this.cache.measuredHeightDeltaTotal+=c,l=!0}return this.cache.ghostTextRows=t,this.cache.ghostTextRowsByIndex=a,l}reconcileHeights(){let e=!1,{options:{overflow:t="scroll"},cache:{ghostTextRowsByIndex:n},metrics:{lineHeight:r}}=this,i=this.getRenderedDiff();if(this.fileContainer==null||i==null){if(this.height!==0)e=!0;return this.height=0,e}this.top=this.getVirtualizedTop(),e=this.applyGhostTextRows(i,this.editor?.__getGhostTextRows()??Ed);let o=this.getLatestAnnotations();if(t==="scroll"&&o.length===0&&!this.isResizeDebuggingEnabled()){if(e)this.computeApproximateSize(!0);return e}let s=this.getDiffStyle(),a=s==="split"?[this.codeDeletions,this.codeAdditions]:[this.codeUnified],l=this.hasFileAnnotations(i);if(this.renderRange!=null&&l&&li(this.renderRange)){let d=iD(a)??0;if(this.setFileAnnotationHeight(d))e=!0}else if(!l&&this.setFileAnnotationHeight(0))e=!0;for(let d of a){if(d==null)continue;let c=d.children[1];if(!(c instanceof HTMLElement))continue;let m=s==="split"&&d===this.codeDeletions;for(let p of c.children){if(!(p instanceof HTMLElement))continue;let h=p.dataset.lineIndex;if(h==null)continue;let x=mD(h,s),I=n.get(x)??0;if(m&&I>0)continue;let v=p.getBoundingClientRect().height+I*r,S=!1;if(p.nextElementSibling instanceof HTMLElement&&(("lineAnnotation"in p.nextElementSibling.dataset)||("noNewline"in p.nextElementSibling.dataset))){if("noNewline"in p.nextElementSibling.dataset)S=!0;v+=p.nextElementSibling.getBoundingClientRect().height}let b=this.getEstimatedLineHeight(S),E=this.cache.heightDeltas.get(x)??0,w=v-b;if(w===E)continue;if(e=!0,this.cache.measuredHeightDeltaTotal+=w-E,w===0)this.cache.heightDeltas.delete(x);else this.cache.heightDeltas.set(x,w)}}if(e||this.isResizeDebuggingEnabled())this.computeApproximateSize(!0);return e}onRender=(e)=>{if(this.fileContainer==null)return!1;if(e)this.top=this.getVirtualizedTop();return this.render()};flushManagers(){if(super.flushManagers(),this.lineStateRefreshPending)this.flushDeferredLineState()}updateCodeViewLayout(e,t,n,r){let i=!1,o=!1,{pendingExpansions:s,pendingHydratedDiff:a,options:{collapsed:l=!1}}=this;if(a!=null){if(this.pendingHydratedDiff=void 0,a.expectedDiff===e)Object.assign(e,a.nextDiff),this.setHydratedState(a.files),this.startHydratedEditSession(e),this.forceRenderOverride=!0,i=!0,o=!0}if(s!=null){this.pendingExpansions=void 0;for(let{hunkIndex:x,direction:I,expansionLineCountOverride:v}of s)this.hunksRenderer.expandHunk(x,I,v),this.forceRenderOverride=!0,o=!0}let d=this.updateExternalDiff(e,r),{pendingRenderDiff:c,layoutDiffChanged:m,renderedDiffChanged:p,annotationsChanged:h}=this.updatePendingRender(e,r);if(!this.forceRenderOverride&&(d||p||h))this.forceRenderOverride=!0;if(n?.resetDiffLayoutCache===!0||m||h)i=!0;if(m||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights)o=!0;if(n?.metrics!=null)this.metrics=Bo(n.metrics),i=!0,o=!0;if(this.currentCollapsed!==l)this.currentCollapsed=l,i=!0;if(i)this.resetLayoutCache({includeEstimatedHeights:o});else if(o)this.invalidateDerivedLayoutCache(!0);return this.top=t,this.computeApproximateSize(!1,c),this.height}getLinePosition(e,t="additions"){let n=this.getLayoutDiff();if(n==null||e<1)return;let r=this.getLineIndexForDiff(n,e,t);if(r==null)return;let{disableFileHeader:i=!1,expandUnchanged:o=!1,collapsed:s=!1,collapsedContextThreshold:a=1}=this.options,l=this.getDiffStyle(),d=this.getHunkSeparatorType(),c=l==="split"?r[1]:r[0];this.approximateLayoutCheckpoints(n);let m=En(this.metrics,i),p=this.getLayoutCheckpointBeforeLineIndex(c),h=p?.top??m+this.cache.fileAnnotationHeight;if(s)return{top:m,height:0};let x;return zn({diff:n,diffStyle:l,startingLine:p?.renderedLineIndex??0,expandedHunks:o?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:a,callback:({hunkIndex:I,hunk:v,collapsedBefore:S,collapsedAfter:b,deletionLine:E,additionLine:w})=>{let k=l==="split"?w?.splitLineIndex??E?.splitLineIndex:w?.unifiedLineIndex??E?.unifiedLineIndex;if(k==null)throw Error("VirtualizedFileDiff.getLinePosition: missing line index data");if(S>0){let R=Zi({type:d,metrics:this.metrics,hunkIndex:I,hunkSpecs:v?.hunkSpecs});if(R!=null){if(h+=R.gapBefore,c>=k-S&&c<k)return x={top:h,height:R.height},!0;h+=R.height+R.gapAfter}}let L=this.getLineHeight(k,(w?.noEOFCR??!1)||(E?.noEOFCR??!1));if(k===c)return x={top:h,height:L},!0;if(h+=L,b>0){let R=Hr({type:d,metrics:this.metrics});if(R!=null){if(c>k&&c<=k+b)return x={top:h+R.gapBefore,height:R.height},!0;h+=R.totalHeight}}return!1}}),x}getEditorViewport(){return this.virtualizer.type==="simple"?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){let t=this.getLayoutDiff();if(t==null)return;let{disableFileHeader:n=!1,expandUnchanged:r=!1,collapsed:i=!1,collapsedContextThreshold:o=1}=this.options;if(i)return;let s=this.getDiffStyle(),a=this.getHunkSeparatorType();this.approximateLayoutCheckpoints(t);let l=this.getLayoutCheckpointBeforeTop(e),d=l?.top??En(this.metrics,n)+this.cache.fileAnnotationHeight,c;return zn({diff:t,diffStyle:s,startingLine:l?.renderedLineIndex??0,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:m,hunk:p,collapsedBefore:h,collapsedAfter:x,deletionLine:I,additionLine:v})=>{let S=s==="split"?v?.splitLineIndex??I?.splitLineIndex:v?.unifiedLineIndex??I?.unifiedLineIndex;if(S==null)throw Error("VirtualizedFileDiff.getNumericScrollAnchor: missing line index data");if(h>0){let E=Zi({type:a,metrics:this.metrics,hunkIndex:m,hunkSpecs:p?.hunkSpecs});if(E!=null)d+=E.totalHeight}if(d>=e){if(I!=null)c={lineNumber:I.lineNumber,side:"deletions",top:d};else if(v!=null)c={lineNumber:v.lineNumber,side:"additions",top:d};if(c!=null)return!0}let b=this.getLineHeight(S,(v?.noEOFCR??!1)||(I?.noEOFCR??!1));if(d+=b,x>0){let E=Hr({type:a,metrics:this.metrics});if(E!=null)d+=E.totalHeight}return!1}}),c}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){let t=this.getLayoutDiff();if(this.top==null||t==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let n=e!=null?this.computeRenderRangeFromWindow(t,this.top,e):this.renderRange;if(n==null)return;let{bufferBefore:r,bufferAfter:i,totalLines:o}=n,s=0;if(o===0){let a=e??this.virtualizer.getWindowSpecs();if(this.top<a.top)s=i}return{topOffset:this.top+r+s,height:this.height-(r+i)}}cleanUp(e=!1){let t=this.cache.ghostTextRows.size>0;if(t)this.layoutDirty=!0;let n=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(t||!ze(this.getRenderedDiff(),this.getLatestDiff()));if(this.fileContainer!=null&&this.isSimpleMode())this.getSimpleVirtualizer()?.disconnect(this.fileContainer);if(!e)this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0;if(this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),n)this.virtualizer.instanceChanged(this,!0)}expandHunk=(e,t,n)=>{if(this.fileDiff==null)return;if(this.isAdvancedMode())this.pendingExpansions??=[],this.pendingExpansions.push({hunkIndex:e,direction:t,expansionLineCountOverride:n});else this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize();this.loadFilesIfNecessary(),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)};async handleFilesLoaded(e,t){if(this.fileDiff!==e||!e.isPartial)return;if(this.isAdvancedMode()){let n=ma("clone",e,t);if(await da(()=>this.primeHighlightCache(n)),!this.enabled||this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(ma("merge",e,t),this.setHydratedState(t),!this.startHydratedEditSession(e)){if(await da(()=>this.primeHighlightCache(e)),!this.enabled||this.fileDiff!==e)return}this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.fileDiff)return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}isLineRenderable(e){if(super.isLineRenderable(e))return!0;let{pendingExpansions:t}=this,n=this.getRenderedDiff();if(t==null||t.length===0||n==null)return!1;let{expansionLineCount:r=100,collapsedContextThreshold:i=1}=this.options,o=new Map(this.hunksRenderer.getExpandedHunksMap());for(let s of t){let a={...o.get(s.hunkIndex)??{fromStart:0,fromEnd:0}},l=s.expansionLineCountOverride??r;if(s.direction==="up"||s.direction==="both")a.fromStart+=l;if(s.direction==="down"||s.direction==="both")a.fromEnd+=l;o.set(s.hunkIndex,a)}return ad({fileDiff:n,lineNumber:e,expandedHunks:o,collapsedContextThreshold:i})}invalidateEditSessionLayout(){if(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),!this.isSimpleMode())this.computeApproximateSize(!0);this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){if(this.invalidateEditSessionLayout(),!this.enabled||this.fileDiff==null)return;this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){if(this.isAdvancedMode()||this.fileContainer==null)return;if(this.renderRange=void 0,e&&!this.isVisible)this.top=this.getVirtualizedTop(),this.isVisible=!0;else if(!e&&this.isVisible)this.isVisible=!1,this.rerender()}rerender(){if(!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null)return;let e=this.getLatestDiff(),t=e==null?void 0:this.hunksRenderer.getDiffForNextRender(e);if(this.isSimpleMode())this.pendingRender=void 0;this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!ze(this.getRenderedDiff(),t))}syncGhostTextRows(){let e=this.getAdvancedVirtualizer();if(e!=null)e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0);else this.getSimpleVirtualizer()?.requestHeightReconcile(this)}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1});let i=this.getRenderedDiff();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!=null&&i!=null){let o=this.virtualizer.getWindowSpecs(),s=this.computeRenderRangeFromWindow(i,this.top??0,o);if(s.bufferAfter!==r.bufferAfter)this.updateBuffers(s)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.getLayoutDiff()){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}this.applyGhostTextRows(t,this.editor?.__getGhostTextRows()??Ed);let{disableFileHeader:i=!1,collapsed:o=!1}=this.options,s=En(this.metrics,i);if(this.height+=s,o){this.layoutDirty=!1;return}if(this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!r)this.validateComputedHeight(t);this.layoutDirty=!1}getLayoutDiff(){return this.pendingRender?.diff??this.getRenderedDiff()}getActiveEstimatedHeight(e=this.getLayoutDiff()){this.ensureEstimatedDiffHeights(e);let t=this.getDiffStyle()==="split"?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw Error("VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height");return t}ensureEstimatedDiffHeights(e=this.getLayoutDiff()){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,{splitHeight:i,unifiedHeight:o}=vI({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:sp(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=i,this.cache.estimatedUnifiedHeight=o}validateComputedHeight(e=this.getLayoutDiff()){if(this.fileContainer==null||e==null)return;let t=this.fileContainer.getBoundingClientRect();if(t.height!==this.height)console.log("VirtualizedFileDiff.computeApproximateSize: computed height doesnt match",{name:e.name,elementHeight:t.height,computedHeight:this.height});else console.log("VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT")}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:r,...i}={}){let o=ca(i,"VirtualizedFileDiff.render"),s=o!=null,a=o?.oldFile,l=o?.newFile,d=s&&(!dS(a,this.deletionFile)||!dS(l,this.additionFile)),c=t??this.fileDiff;if(t==null&&s&&(d||this.fileDiff==null))c=Kn(o.oldFile,o.newFile,this.options.parseDiffOptions);let{forceRenderOverride:m,isSetup:p}=this;this.forceRenderOverride=void 0;let h=c!=null&&!ze(this.fileDiff,c),x=h||d;if(e=this.getOrCreateFileContainer(e),c==null)return console.error("VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data"),!1;if(h)this.updateExternalDiff(c,r);let{pendingRenderDiff:I,layoutDiffChanged:v,renderedDiffChanged:S,annotationsChanged:b}=(()=>{if(this.pendingRender!=null&&this.pendingRender.latestDiff===(this.getLatestDiff(c)??c))return{pendingRenderDiff:this.pendingRender.diff,layoutDiffChanged:!1,renderedDiffChanged:!1,annotationsChanged:!1};return this.updatePendingRender(c,r)})();if(b||v)this.resetLayoutCache({includeEstimatedHeights:v});if(!p){this.computeApproximateSize(!1,I);let L=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(L==null)throw Error("VirtualizedFileDiff.render: simple virtualizer is not available");L.connect(e,this),this.isVisible=L.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}else if(this.top??=this.getVirtualizedTop(),v)this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,I);if(!this.isVisible&&this.isSimpleMode()&&(!x||!p)){if(o!=null)this.deletionFile=a,this.additionFile=l;if(h)this.clearReusableHeader();return this.pendingRender=void 0,this.renderPlaceholder(this.height)}let E=this.virtualizer.getWindowSpecs(),w=this.top??0,k=this.computeRenderRangeFromWindow(I,w,E);return super.render({fileDiff:c,fileContainer:e,renderRange:k,lineAnnotations:r,forceRender:(m??n)||b||S||h,...o,...i})}finalizeRender(){if(this.getRenderedDiff()!==this.pendingRender?.diff)throw Error("VirtualizedFileDiff.render: rendered a different diff than its prepared layout");if(this.pendingRender=void 0,this.isSimpleMode())this.getSimpleVirtualizer()?.requestHeightReconcile(this)}updatePendingRender(e,t){let n=this.getLatestDiff(e)??e,r=this.getRenderedDiff(),{pendingRender:i}=this,o=i?.diff??r,s=this.hunksRenderer.getDiffForNextRender(n);return this.pendingRender={latestDiff:n,diff:s},{pendingRenderDiff:s,annotationsChanged:this.syncLineAnnotations(t),layoutDiffChanged:!ze(o,s),renderedDiffChanged:!ze(r,s)}}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}getVirtualizedTop(){if(this.virtualizer.type==="advanced")return this.virtualizer.getLocalTopForInstance(this);return this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type==="advanced"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??"split"}getHunkSeparatorType(){return cD(this.options.hunkSeparators)}approximateLayoutCheckpoints(e){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,i=e.hunks.length-1,o=sp(e,this.options.loadDiffFiles!=null),s=this.getDiffStyle(),a=this.getHunkSeparatorType(),l=n?!0:this.hunksRenderer.getExpandedHunksMap(),d=oD(this.cache.heightDeltas),c=En(this.metrics,t)+this.cache.fileAnnotationHeight,m=0,p=({rowCount:h,startLineIndex:x,preSeparatorHeight:I=0,postSeparatorHeight:v=0,metadataOffsets:S=[]})=>{if(h<=0)return;let b=m,E=m+h,w=sD(b);while(w<E){let k=w-b,L=c+(k>0?I:0)+k*this.metrics.lineHeight+aD(S,k)*this.metrics.lineHeight+lS(d,x,x+k);this.cache.checkpoints.push({renderedLineIndex:w,lineIndex:x+k,top:L}),w+=ap}c+=I+h*this.metrics.lineHeight+S.length*this.metrics.lineHeight+lS(d,x,x+h)+v,m=E};for(let h=0;h<e.hunks.length;h++){let x=e.hunks[h];if(x==null)throw Error("VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index");let I=cn({isPartial:e.isPartial,rangeSize:x.collapsedBefore,expandedHunks:l,hunkIndex:h,collapsedContextThreshold:r}),v=I.collapsedLines>0?Zi({type:a,metrics:this.metrics,hunkIndex:h,hunkSpecs:x.hunkSpecs})?.totalHeight??0:0;p({rowCount:I.fromStart,startLineIndex:(s==="split"?x.splitLineStart:x.unifiedLineStart)-I.rangeSize});let S=v;if(p({rowCount:I.fromEnd,startLineIndex:(s==="split"?x.splitLineStart:x.unifiedLineStart)-I.fromEnd,preSeparatorHeight:S}),I.fromEnd>0)S=0;let b=h===i?mn({fileDiff:e,hunkIndex:h,expandedHunks:l,collapsedContextThreshold:r,errorPrefix:"VirtualizedFileDiff"}):void 0,E=b!=null&&b.collapsedLines>0?Hr({type:a,metrics:this.metrics})?.totalHeight??0:h===i&&o?Hr({type:a,metrics:this.metrics})?.totalHeight??0:0,w=b!=null?b.fromStart+b.fromEnd:0,k=s==="split"?x.splitLineCount:x.unifiedLineCount,L=s==="split"?x.splitLineStart:x.unifiedLineStart;if(p({rowCount:k,startLineIndex:L,preSeparatorHeight:S,postSeparatorHeight:w===0?E:0,metadataOffsets:lD({diffStyle:s,hunk:x,rowCount:k})}),b!=null&&w>0)p({rowCount:w,startLineIndex:L+k,postSeparatorHeight:E})}this.cache.totalLines=m}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;while(t<=n){let i=t+n>>1,o=this.cache.checkpoints[i];if(o==null)throw Error("VirtualizedFileDiff: invalid checkpoint index");if(o.lineIndex<=e)r=o,t=i+1;else n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;while(n<=r){let o=n+r>>1,s=this.cache.checkpoints[o];if(s==null)throw Error("VirtualizedFileDiff: invalid checkpoint index");if(s.top<=e)i=o,n=o+1;else r=o-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let o=i;o>=0;o--){let s=this.cache.checkpoints[o];if(s==null)throw Error("VirtualizedFileDiff: invalid checkpoint index");if(s.renderedLineIndex%t===0)return s}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let a of e.hunks)n+=t==="split"?a.splitLineCount:a.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,o=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[a,l]of e.hunks.entries()){let d=t==="split"?l.splitLineCount:l.unifiedLineCount;n+=d;let c=Math.max(l.collapsedBefore,0),{fromStart:m,fromEnd:p,renderAll:h}=cn({isPartial:e.isPartial,rangeSize:c,expandedHunks:o,hunkIndex:a,collapsedContextThreshold:i});if(c>0)n+=h?c:m+p}let s=mn({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:o,collapsedContextThreshold:i,errorPrefix:"VirtualizedFileDiff"});if(s!=null)n+=s.fromStart+s.fromEnd;return n}getLayoutLineCount(e,t){let n=this.getExpandedLineCount(e,t),r=t==="split"?e.splitLineCount:e.unifiedLineCount;return Math.max(n,r,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:o=!1,collapsedContextThreshold:s=1}=this.options,{hunkLineCount:a,lineHeight:l}=this.metrics,d=this.getDiffStyle(),c=this.getHunkSeparatorType(),m=sp(e,this.options.loadDiffFiles!=null),p=this.height,h=this.getLayoutLineCount(e,d),x=En(this.metrics,i),I=e.hunks.length>0?Wi(this.metrics):0,{fileAnnotationHeight:v}=this.cache,S=x+v,b=Math.max(0,p-x-v-I),E=this.hasFileAnnotations(e),w=t+x,k=v>0&&E&&w<r&&w+v>n;if(t<n-p||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:p-x-I};if(h<=a||e.hunks.length===0)return{startingLine:0,totalLines:a,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),h=this.getLayoutLineCount(e,d);let L=Math.ceil(Math.max(r-n,0)/l),R=Math.ceil(L/a)*a+a,A=R/a,O=A,D=[],X=(n+r)/2,N=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-R*l*2),a),B=t+(N?.top??S),pe=N?.renderedLineIndex??0,ye,j,ie;if(zn({diff:e,diffStyle:d,startingLine:N?.renderedLineIndex??0,expandedHunks:o?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:Hi,hunk:Jt,collapsedBefore:wo,collapsedAfter:Hs,deletionLine:Tr,additionLine:kr})=>{let at=kr!=null?kr.splitLineIndex:Tr.splitLineIndex,sn=kr!=null?kr.unifiedLineIndex:Tr.unifiedLineIndex,In=(kr?.noEOFCR??!1)||(Tr?.noEOFCR??!1),_i=Hi===e.hunks.length-1&&Jt!=null&&(d==="split"?at===Jt.splitLineStart+Jt.splitLineCount-1:sn===Jt.unifiedLineStart+Jt.unifiedLineCount-1),Un=(wo>0?Zi({type:c,metrics:this.metrics,hunkIndex:Hi,hunkSpecs:Jt?.hunkSpecs}):void 0)?.totalHeight??0;B+=Un;let wr=pe%a===0,Zr=Math.floor(pe/a);if(wr){if(D[Zr]=B-(t+S+Un),ie!=null){if(ie<=0)return!0;ie--}}let Pn=this.getLineHeight(d==="split"?at:sn,In);if(B>n-Pn&&B<r)ye??=Zr;if(j==null&&B+Pn>X)j=Zr;if(ie==null&&B>=r&&wr)ie=O;if(pe++,B+=Pn,Hs>0||_i&&m){let Ol=Hr({type:c,metrics:this.metrics});if(Ol!=null){if(B<r&&B+Ol.totalHeight>n)ye??=Zr;if(j==null&&B+Ol.totalHeight>X)j=Zr;B+=Ol.totalHeight}}return!1}}),ye==null)if(k)ye=0,j=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:p-x-I};j??=ye;let Ee=Math.round(j-A/2),Mt=Math.max(0,Math.ceil(h/a)-A),Ie=Math.max(0,Math.min(Ee,Mt)),Me=Ie*a,Qe=Ee<0?R+Ee*a:R,gt=D[Ie]??0,xn=Me===0?0:v+gt,Rn=Ie+Qe/a,An=Rn<D.length?b-D[Rn]:b-(B-t-S);return{startingLine:Me,totalLines:Qe,bufferBefore:xn,bufferAfter:Math.max(0,An)}}};function iD(e){let t;for(let n of e){if(n==null)continue;let r=n.children[1];if(!(r instanceof HTMLElement))continue;for(let i of r.children){if(!(i instanceof HTMLElement))continue;if(i.dataset.lineAnnotation!==Cu)continue;t=Math.max(t??0,i.getBoundingClientRect().height)}}return t}function oD(e){let t=Array.from(e).sort((o,s)=>o[0]-s[0]),n=[],r=[0],i=0;for(let[o,s]of t)n.push(o),i+=s,r.push(i);return{lineIndexes:n,prefixTotals:r}}function lS({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=uS(e,n);return(t[uS(e,r)]??0)-(t[i]??0)}function uS(e,t){let n=0,r=e.length;while(n<r){let i=n+r>>1,o=e[i];if(o==null)throw Error("VirtualizedFileDiff: invalid prefix index");if(o<t)n=i+1;else r=i}return n}function sD(e){return Math.ceil(e/ap)*ap}function aD(e,t){let n=0;for(let r of e)if(r<t)n++;return n}function lD({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];let r=t.hunkContent.at(-1);if(r==null)return[];if(r.type==="context")return[n-1];let i=Math.max(r.deletions,r.additions),o=r.deletions+r.additions;if(e==="split")return i>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];let s=[],a=n-o;if(r.deletions>0&&t.noEOFCRDeletions)s.push(a+r.deletions-1);if(r.additions>0&&t.noEOFCRAdditions)s.push(n-1);return s}function uD(e,t){return(e.diffStyle??"split")!==(t.diffStyle??"split")||(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??"bars")!==(t.diffIndicators??"bars")||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||Boolean(e.loadDiffFiles)!==Boolean(t.loadDiffFiles)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function dD(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||Boolean(e.loadDiffFiles)!==Boolean(t.loadDiffFiles)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function sp(e,t){return e.isPartial&&t&&(e.type==="change"||e.type==="rename-changed")}function cD(e){return typeof e==="function"?"custom":e??"line-info"}function dS(e,t){if(e==null||t==null)return e==null&&t==null;return sd(e,t)}function mD(e,t){let[n,r]=e.split(",").map(Number);return t==="split"?r:n}var TS=["theme","disableLineNumbers","overflow","themeType","disableFileHeader","disableVirtualizationBuffers","preferredHighlighter","useCSSClasses","useTokenTransformer","tokenizeMaxLineLength","tokenizeMaxLength","unsafeCSS","diffStyle","diffIndicators","disableBackground","expandUnchanged","loadDiffFiles","collapsedContextThreshold","lineDiffType","maxLineDiffLength","expansionLineCount","lineHoverHighlight","enableTokenInteractionsOnWhitespace","enableGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","disableErrorHandling"],kS=["theme","disableLineNumbers","overflow","themeType","disableFileHeader","disableVirtualizationBuffers","preferredHighlighter","useCSSClasses","useTokenTransformer","tokenizeMaxLineLength","tokenizeMaxLength","unsafeCSS","lineHoverHighlight","enableTokenInteractionsOnWhitespace","enableGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","disableErrorHandling"],mS=["renderCustomHeader","renderHeaderPrefix","renderHeaderFilenameSuffix","renderHeaderMetadata","renderAnnotation","renderGutterUtility","onPostRender","onGutterUtilityClick","onLineClick","onLineNumberClick","onLineEnter","onLineLeave","onTokenClick","onTokenEnter","onTokenLeave"],fS=["onLineSelected","onLineSelectionStart","onLineSelectionChange","onLineSelectionEnd"],wS=Symbol("CodeView.itemOptionsState");function pS(e,t){Object.defineProperty(e,wS,{configurable:!1,enumerable:!1,value:t})}function hi(e){return e[wS]}function Vn(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return n(this)}})}var fD=120,hS=1,gS="--diffs-overflow-override",pD=12000000,hD=1e6,gD=2000000,yD=1e7,yS=11000000;function xD(e){if(e==null)throw Error("CodeView: createEditor is required for items with edit: true")}var ID=(()=>{let{navigator:e}=globalThis,t=e.userAgent,n=/iP(?:hone|ad|od)/.test(t),r=e.platform==="MacIntel"&&e.maxTouchPoints>1;return(n||r)&&/AppleWebKit/.test(t)&&/Safari/.test(t)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(t)})(),SD=class e{static __STOP=!1;static __lastScrollPosition=0;type="advanced";config={overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1};items=[];idToItem=new Map;selectedLines=null;itemEditors=new Map;attachedEditors=new Set;instanceToItem=new Map;layoutDirtyIndex;pendingLayoutReset;renderOptionsRevision=0;slotCoordinator;slotSnapshot;scrollListeners=new Set;scrollHeight=0;containerHeight=-1;scrollTop=0;scrollPageOffset=0;scrollDirty=!0;scrollInteractionFixTimer;pointerEventsDisabled=!1;codeOverflowFix=!1;height=0;heightDirty=!0;windowSpecs={top:0,bottom:0};renderState={scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1};itemMetricsCache=rs;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;shouldFixContainerFocus=!1;scrollAnimation;root;resizeObserver;container=document.createElement("div");stickyContainer=document.createElement("div");stickyOffset=document.createElement("div");header={element:void 0,render:void 0,height:0};footer={element:void 0,render:void 0,height:0};elementPool=[];elementPoolVersion=0;elementPoolTracker=new WeakMap;pendingElementPool=[];options;workerManager;isReadySubscription;pendingHighlighterTheme;isContainerManaged;constructor(t={theme:Oe},n,r=!1){this.options=t,this.computeMetricsCache(t.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=n,this.isContainerManaged=r,this.stickyOffset.style.contain="layout size",this.stickyContainer.style.position="sticky",this.stickyContainer.style.width="100%",this.stickyContainer.style.contain="layout style inline-size",this.stickyContainer.style.isolation="isolate",this.stickyContainer.style.display="flex",this.stickyContainer.style.flexDirection="column"}getLayout(){return this.options.layout??ES}getItemTopOffset(){return this.getLayout().paddingTop+this.header.height}computeMetricsCache(t){return this.itemMetricsCache={hunkLineCount:t?.hunkLineCount??rs.hunkLineCount,lineHeight:t?.lineHeight??rs.lineHeight,diffHeaderHeight:t?.diffHeaderHeight??rs.diffHeaderHeight,hunkSeparatorHeight:t?.hunkSeparatorHeight,spacing:t?.spacing??rs.spacing,paddingTop:t?.paddingTop,paddingBottom:t?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??vS}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return CS&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(t){if(!this.shouldValidateItemHeights()||t.element==null)return;let n=t.instance.getAdvancedStickySpecs();if(n==null)return;let r=n.height,i=t.element.getBoundingClientRect().height;if(r===i)return;console.error("CodeView: reconciled item height does not match DOM height",{id:t.item.id,type:t.type,index:t.index,version:t.version,expectedHeight:r,actualHeight:i,delta:i-r,stickyTopOffset:n.topOffset,virtualizedHeight:t.instance.getVirtualizedHeight(),top:t.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:t.element,instance:t.instance})}validateStickyContainerHeight(){if(!this.shouldValidateItemHeights())return;let{firstIndex:t,lastIndex:n,stickyHeight:r,stickyTop:i,stickyBottom:o}=this.renderState;if(t===-1||n===-1)return;let s=this.stickyContainer.getBoundingClientRect().height;if(Math.abs(s-r)<hS)return;console.error("CodeView: sticky container height does not match computed layout",{computedStickyHeight:r,actualStickyHeight:s,delta:s-r,stickyTop:i,stickyBottom:o,firstIndex:t,lastIndex:n,firstStickySpecs:this.items[t]?.instance.getAdvancedStickySpecs(),lastStickySpecs:this.items[n]?.instance.getAdvancedStickySpecs(),scrollTop:this.getScrollTop(),scrollPageOffset:this.scrollPageOffset,windowSpecs:{...this.windowSpecs},stickyContainer:this.stickyContainer})}clearScrollInteractionTimer(){if(this.scrollInteractionFixTimer!=null)clearTimeout(this.scrollInteractionFixTimer),this.scrollInteractionFixTimer=void 0}suspendScrollInteractions(){if(this.clearScrollInteractionTimer(),this.shouldDisablePointerEvents()&&!this.pointerEventsDisabled)this.stickyContainer.style.pointerEvents="none",this.pointerEventsDisabled=!0;if(ID&&!this.codeOverflowFix)this.stickyContainer.style.setProperty(gS,"hidden"),this.codeOverflowFix=!0;this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,fD)}restoreScrollInteractions=()=>{if(this.clearScrollInteractionTimer(),this.pointerEventsDisabled)this.stickyContainer.style.removeProperty("pointer-events"),this.pointerEventsDisabled=!1;if(this.codeOverflowFix)this.stickyContainer.style.setProperty(gS,"auto"),this.codeOverflowFix=!1};syncLayout(){let{gap:t,paddingBottom:n,paddingTop:r}=this.getLayout();this.stickyContainer.style.gap=`${t}px`,this.container?.style.setProperty("margin-top",`${r}px`),this.container?.style.setProperty("margin-bottom",`${n}px`)}reconcileHeaderFooterHosts(){let t=this.reconcileHost("header"),n=this.reconcileHost("footer");return t||n}reconcileHost(t){let{root:n,container:r}=this;if(n==null||r==null)return!1;let i=t==="header"?this.header:this.footer,o=t==="header"?this.options.renderCodeViewHeader:this.options.renderCodeViewFooter;if(o==null){if(i.element==null)return!1;return this.resizeObserver?.unobserve(i.element),i.element.remove(),i.element=void 0,i.render=void 0,this.setHostHeight(i,0),!1}if(i.element!=null&&o===i.render)return!1;let s=i.element??zx(t,r,this.resizeObserver);i.element=s;let a=o();if(a!=null)s.replaceChildren(a);else if(!this.isContainerManaged&&s.children.length>0)s.textContent="";return i.render=o,!0}setHostHeight(t,n){if(t.height===n)return;t.height=n,this.scrollDirty=!0}measureMountedHosts(){if(this.header.element!=null)this.setHostHeight(this.header,this.header.element.getBoundingClientRect().height);if(this.footer.element!=null)this.setHostHeight(this.footer,this.footer.element.getBoundingClientRect().height)}setup(t){if(this.root!=null)throw Error("CodeView.setup: already setup");if(this.workerManager?.subscribeToThemeChanges(this),this.root=t,this.root.style.overflowAnchor="none",!this.root.hasAttribute("tabindex"))this.root.tabIndex=-1;this.container??=document.createElement("div"),this.container.style.contain="layout style",this.syncLayout(),this.container.appendChild(this.stickyOffset),this.container.appendChild(this.stickyContainer),this.root.appendChild(this.container),this.scrollDirty=!0,this.heightDirty=!0,this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.stickyContainer),this.root.addEventListener("scroll",this.handleScroll,{passive:!0}),this.root.addEventListener("wheel",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("touchstart",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("pointerdown",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("keydown",this.clearPendingScroll,{passive:!0}),this.resizeObserver.observe(this.root),this.render(!0),window.__INSTANCE=this,window.__TOGGLE=()=>{if(e.__STOP)e.__STOP=!1,this.scrollTo({type:"position",position:e.__lastScrollPosition,behavior:"instant"});else e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0}}reset(){di(this.computeRenderRangeAndEmit),this.clearReadySubscription(),this.restoreScrollInteractions(),this.cleanAllRenderedItems();let t=[...this.itemEditors.values()].map((i)=>{let o=this.idToItem.get(i.state.id);if(o!=null)i.state.removedItem=o.item;return{record:i,instance:o?.instance}});this.itemEditors.clear(),this.attachedEditors.clear(),this.selectedLines=null,this.items.length=0,this.idToItem.clear(),this.instanceToItem.clear();let n=!1,r;for(let{record:i,instance:o}of t)try{i.editor.cleanUp("discard"),o?.cleanUp()}catch(s){if(!n)n=!0,r=s}if(this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent="",this.stickyOffset.style.height="",this.container?.style.removeProperty("height"),this.containerHeight=-1,this.windowSpecs={top:0,bottom:0},this.pendingLayoutAnchor=void 0,this.shouldFixContainerFocus=!1,this.height=0,this.scrollTop=0,this.scrollPageOffset=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.resetRenderState(),!this.isContainerManaged)this.flushSlotCoordinator();if(n)throw r}cleanUp(){let t=!1,n;try{this.reset()}catch(r){t=!0,n=r}if(this.clearElementPool(),this.restoreScrollInteractions(),this.workerManager?.unsubscribeToThemeChanges(this),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.root?.removeEventListener("scroll",this.handleScroll),this.root?.removeEventListener("wheel",this.clearPendingScroll),this.root?.removeEventListener("touchstart",this.clearPendingScroll),this.root?.removeEventListener("pointerdown",this.clearPendingScroll),this.root?.removeEventListener("keydown",this.clearPendingScroll),this.root?.style.removeProperty("overflow-anchor"),this.container?.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent="",this.header.element?.remove(),this.header.element=void 0,this.header.render=void 0,this.header.height=0,this.footer.element?.remove(),this.footer.element=void 0,this.footer.render=void 0,this.footer.height=0,this.root=void 0,this.container=void 0,t)throw n}cleanAllRenderedItems(){if(this.renderState.firstIndex===-1)return;for(let t=this.renderState.firstIndex;t<=this.renderState.lastIndex;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${t}`);this.releaseRenderedItem(n)}}primeScrollTarget(t){if(t.type==="position")return;let n=this.idToItem.get(t.id);if(n==null)return;n.instance.primeHighlightCache()}getElementPoolLimit(){let t=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:n}=this.itemMetricsCache;return Math.max(8,Math.ceil(t/Math.max(n,10))+1)*(this.isContainerManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let t=this.elementPool.pop();while(t!=null&&!this.isElementPoolGenerationCurrent(t))t=this.elementPool.pop();return t??=document.createElement(nd),this.markElementPoolGenerationCurrent(t),t}releaseRenderedItem(t){let{element:n}=t;if(n!=null&&this.renderedItemOwnsFocus(n))this.shouldFixContainerFocus=!0;if(t.instance.cleanUp(!0),this.attachedEditors.delete(t.item.id),t.element=void 0,n==null)return;n.remove(),this.cleanElement(n),this.queueElementForPool(n)}renderedItemOwnsFocus(t){let{activeElement:n}=document;return n===t||t.contains(n)||t.shadowRoot?.activeElement!=null}fixContainerFocus(){if(this.shouldFixContainerFocus)this.shouldFixContainerFocus=!1,this.root?.focus({preventScroll:!0})}cleanElement(t){let{shadowRoot:n}=t;if(n!=null){for(let r of Array.from(n.children))if(!TD(r))r.remove()}if(!this.isContainerManaged)t.replaceChildren()}queueElementForPool(t){let n=this.getElementPoolLimit();if(!this.isElementPoolGenerationCurrent(t)||this.getElementPoolSize()>=n)return;if(this.isElementClean(t))this.elementPool.push(t);else this.pendingElementPool.push(t)}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;let{pendingElementPool:t}=this;this.pendingElementPool=[];let n=this.getElementPoolLimit();for(let r of t)if(this.isElementPoolGenerationCurrent(r)&&this.isElementClean(r)&&this.elementPool.length<n)this.elementPool.push(r);else if(this.isElementPoolGenerationCurrent(r)&&this.getElementPoolSize()<n)this.pendingElementPool.push(r)}isElementClean(t){return t.childNodes.length===0}getElementPoolSize(){return this.elementPool.length+this.pendingElementPool.length}clearElementPool(){this.elementPool.length=0,this.pendingElementPool.length=0}invalidateElementPool(){this.elementPoolVersion++,this.clearElementPool()}markElementPoolGenerationCurrent(t){this.elementPoolTracker.set(t,this.elementPoolVersion)}isElementPoolGenerationCurrent(t){return this.elementPoolTracker.get(t)===this.elementPoolVersion}resolveEffectiveScrollBehavior(t,n){if(Vx())return"instant";if(t.behavior!=="smooth-auto")return t.behavior??"instant";return Math.abs(n-this.getScrollTop())<=this.getHeight()*10?"smooth":"instant"}scrollTo(t){if(this.root==null)return;let n=this.normalizeScrollTarget(t);if(n==null)return;let r=this.resolveScrollTargetTop(n);if(r==null)return;if(this.primeScrollTarget(n),this.resolveEffectiveScrollBehavior(n,r)==="smooth")this.scrollAnimation??={position:this.getScrollTop(),velocity:0,lastTimestamp:performance.now()};else this.scrollAnimation=void 0;this.suspendScrollInteractions(),this.pendingLayoutAnchor=void 0,this.pendingScrollTarget=n,this.render()}setSelectedLines(t,n){this.applySelectedLines(t,n)}getSelectedLines(){return this.selectedLines}clearSelectedLines(t){this.applySelectedLines(null,t)}getItem(t){return this.idToItem.get(t)?.item}getEditor(t){return this.itemEditors.get(t)?.editor}updateItem(t){let n=this.idToItem.get(t.id);if(n==null)return console.error(`CodeView.updateItem: unknown item id "${t.id}"`),!1;if(!this.syncItemRecord(n,t))return!1;return this.markItemLayoutDirty(n),this.scrollDirty=!0,this.render(),this.syncItemEditors(),this.syncSelection(),!0}updateItemId(t,n){if(t===n)return!0;let r=this.idToItem.get(t);if(r==null)return console.error(`CodeView.updateItemId: unknown item id "${t}"`),!1;if(this.idToItem.has(n))return console.error(`CodeView.updateItemId: duplicate item id "${n}"`),!1;if(this.idToItem.delete(t),r.item.id=n,this.idToItem.set(n,r),this.updateItemOptionsId(r.instance.options,n),this.selectedLines?.id===t)this.selectedLines={...this.selectedLines,id:n},this.options.onSelectedLinesChange?.(this.selectedLines);let i=this.itemEditors.get(t);if(i!=null){if(this.itemEditors.delete(t),this.itemEditors.set(n,i),this.attachedEditors.delete(t))this.attachedEditors.add(n)}return this.renamePendingScrollTarget(t,n),this.renamePendingLayoutAnchor(t,n),this.render(),!0}addItem(t){this.addItems([t])}addItems(t){this.appendItemsInternal(t),this.syncItemEditors(),this.syncSelection()}removeItem(t){let n=this.idToItem.get(t);if(n==null)return console.error(`CodeView.removeItem: unknown item id "${t}"`),!1;let r=[];for(let i of this.items)if(i!==n)r.push(i.item);return this.setItems(r),!0}setItems(t){let n;if(this.items.length===0)this.appendItemsInternal(t);else if(!this.tryAppendItems(t))n=this.reconcileItems(t);this.syncItemEditors(n),this.syncSelection()}appendItemsInternal(t,n=!0){if(t.length===0)return;let r=this.getLayout(),i=this.items.length===0?0:this.scrollHeight+r.gap,o=i;for(let s=0;s<t.length;s++){let a=t[s];if(a==null)throw Error("CodeView.appendItemsInternal: missing input item");if(this.idToItem.has(a.id))throw Error(`CodeView.addItem: duplicate id "${a.id}"`);let l=this.createItem(a,this.items.length,i);this.items.push(l),this.idToItem.set(l.item.id,l),this.instanceToItem.set(l.instance,l),l.height=bD(l),i+=l.height+r.gap}if(this.scrollHeight=i-r.gap,this.scrollDirty=!0,n)if(this.canSkipRenderForAppend(o))this.syncContainerHeight();else this.render()}canSkipRenderForAppend(t){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&t>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(t){if(t==null)return;this.capturePendingLayoutAnchor();let{options:n}=this,r=this.getLayout(),{itemMetricsCache:i}=this;if(CD(n,t))this.invalidateElementPool();this.options=t;let o=this.computeMetricsCache(t.itemMetrics),s=!ar(i,o),a=!ar(r,this.getLayout());if(a)this.syncLayout();let l=s||ED(n,t);if(l){let c=this.pendingLayoutReset;this.pendingLayoutReset={metrics:s?o:c?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:c?.includeEstimatedDiffHeights===!0||s||vD(n,t)}}if(a||l)this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0;if(!_o(n,t))this.renderOptionsRevision++;this.syncItemEditors();let d=n.renderCodeViewHeader!==t.renderCodeViewHeader||n.renderCodeViewFooter!==t.renderCodeViewFooter;if(!this.isContainerManaged&&(this.items.length>0||d))this.render()}capturePendingLayoutAnchor(t=this.idToItem){if(this.root==null||this.items.length===0||this.pendingScrollTarget!=null)return;this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop(),t)}render(t=!1){if(e.__STOP)return;if(t)di(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit();else Go(this.computeRenderRangeAndEmit)}isReady(){let{workerManager:t}=this;if(t==null||t.getStats().workersFailed)return this.isSharedHighlighterReady();if(t.isInitialized())return this.clearReadySubscription(),!0;if(this.isReadySubscription??=t.subscribeToStatChanges((n)=>{if(n.managerState!=="initialized"&&!n.workersFailed)return;this.clearReadySubscription(),this.render(!0)}),t.getStats().managerState==="waiting")t.initialize().catch(()=>{});return!1}clearReadySubscription(){if(this.isReadySubscription==null)return;this.isReadySubscription(),this.isReadySubscription=void 0,this.pendingHighlighterTheme=void 0}isSharedHighlighterReady(){let t=this.workerManager?.getFileRenderOptions().theme??this.options.theme??Oe;if(vf()&&Qt(t))return this.clearReadySubscription(),!0;if(!Cn(this.pendingHighlighterTheme,t))this.clearReadySubscription();return this.isReadySubscription??=(()=>{this.pendingHighlighterTheme=t;let n=!1;return Tf({themes:On(t),langs:[],preferredHighlighter:this.options.preferredHighlighter}).then(()=>{if(n)return;this.clearReadySubscription(),this.render(!0)},(r)=>{if(n)return;this.clearReadySubscription(),console.error(r)}),()=>{n=!0}})(),!1}instanceChanged(t,n){let r=this.instanceToItem.get(t);if(r==null)throw Error("CodeView.instanceChanged: An instance has changed that is not registered");if(n)this.markItemLayoutDirty(r);this.render()}getWindowSpecs(){return this.windowSpecs}getContainerElement(){return this.root}getHeaderElement(){return this.header.element}getFooterElement(){return this.footer.element}getRenderedItems(){let{firstIndex:t,lastIndex:n}=this.renderState;if(t===-1||n===-1||n<t)return[];let r=[];for(let i=t;i<=n;i++){let o=this.items[i];if(o?.element==null)continue;if(o.type==="diff")r.push({id:o.item.id,type:"diff",item:o.item,version:o.version,element:o.element,instance:o.instance});else r.push({id:o.item.id,type:"file",item:o.item,version:o.version,element:o.element,instance:o.instance})}return r}setSlotCoordinator(t){if(t===this.slotCoordinator)return!1;return this.slotCoordinator=t,this.slotSnapshot=void 0,!0}getSlotSnapshot(t){return this.buildSlotSnapshot(t)}buildSlotSnapshot(t){let n=wD(this.getRenderedItems(),t),{element:r}=this.header,{element:i}=this.footer;if(n==null&&r==null&&i==null)return;return{items:n,header:r,footer:i}}subscribeToScroll(t){return this.scrollListeners.add(t),()=>{this.scrollListeners.delete(t)}}getLocalTopForInstance(t){let n=this.instanceToItem.get(t);if(n==null)throw Error("CodeView.getLocalTopForInstance: unknown virtualized instance");return n.top}getTopForItem(t){let n=this.idToItem.get(t);if(n==null)return;return n.top+this.getItemTopOffset()}createItem(t,n,r){let{itemMetricsCache:i}=this;if(t.type==="diff"){let s=new cS(this.createDiffOptions(t.id),this,i,this.workerManager,this.isContainerManaged);return{type:"diff",item:t,version:t.version,index:n,top:r,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:s}}let o=new II(this.createFileOptions(t.id),this,i,this.workerManager,this.isContainerManaged);return{type:"file",item:t,version:t.version,index:n,top:r,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:o}}applySelectedLines(t,n){let{selectedLines:r}=this;if(t==null&&r==null||t!=null&&r?.id===t.id&&Uo(r.range,t.range))return;if(r!=null&&r.id!==t?.id)this.idToItem.get(r.id)?.instance.setSelectedLines(null,{notify:!1});this.selectedLines=t,this.idToItem.get(t?.id??"")?.instance.setSelectedLines(t?.range??null,n)}syncSelection(){if(this.selectedLines==null)return;let t=this.idToItem.get(this.selectedLines.id);if(t==null){this.selectedLines=null,this.options.onSelectedLinesChange?.(null);return}t.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}isItemInEditMode(t){return t.item.edit===!0&&t.item.collapsed!==!0}attachItemEditor(t){let{id:n}=t.item,{createEditor:r}=this.options;if(t.element==null||this.attachedEditors.has(n)||!this.isItemInEditMode(t))return;let i=this.itemEditors.get(n),o;try{if(i==null){xD(r);let s=hi(t.instance.options);if(s==null)throw Error("CodeView.attachItemEditor: instance options are missing their state");let a=(d)=>{let c=this.idToItem.get(s.id);if(c==null)return;this.options.onItemEditChange?.(d,c.item)},l=this.options.getEditStateKey?.(t.item);if(t.type==="diff"){let d=r("file-diff",{onChange:a},l);o=d,this.itemEditors.set(n,{editor:d,state:s,dispose:d.edit(t.instance)})}else{let d=r("file",{onChange:a},l);o=d,this.itemEditors.set(n,{editor:d,state:s,dispose:d.edit(t.instance)})}}else if(t.type==="diff")i.dispose=i.editor.edit(t.instance);else i.dispose=i.editor.edit(t.instance);this.attachedEditors.add(n)}catch(s){throw o?.cleanUp(),this.releaseRenderedItem(t),s}}syncItemEditors(t){if(this.itemEditors.size===0)return;let n=[];for(let[o,s]of this.itemEditors){let a=this.idToItem.get(o),l=t?.get(o);if(l==null&&a!=null){let{edit:d=!1,collapsed:c=!1}=a.item;if(d){if(c&&this.attachedEditors.delete(o))s.editor.cleanUp("recycle");continue}}else if(l!=null)s.state.removedItem=l.item;this.itemEditors.delete(o),this.attachedEditors.delete(o),n.push(s)}if(n.length===0)return;let r=!1,i;for(let o of n){try{o.dispose()}catch(a){if(!r)r=!0,i=a}let s=this.idToItem.get(o.state.id);if(s!=null)this.markItemLayoutDirty(s)}if(this.render(),r)throw i}requireItemFromState(t){let n=this.idToItem.get(t.id)?.item??t.removedItem;if(n==null)throw Error(`CodeView.onItemEditComplete: unknown item "${t.id}"`);return n}completeFileItemEdit(t,n){let r=this.requireItemFromState(t);if(r.type!=="file")throw Error(`CodeView.onItemEditComplete: item "${t.id}" is not a file item`);let i={...r,file:n.file,annotations:n.lineAnnotations,edit:!1,version:(r.version??0)+1};if((this.options.onItemEditComplete?.(n,r,i)??"reject")==="reject")return"reject";if(this.idToItem.has(r.id))this.updateItem(i);return"accept"}completeDiffItemEdit(t,n){let r=this.requireItemFromState(t);if(r.type!=="diff")throw Error(`CodeView.onItemEditComplete: item "${t.id}" is not a diff item`);let i={...r,fileDiff:n.fileDiff,annotations:n.lineAnnotations,edit:!1,version:(r.version??0)+1};if((this.options.onItemEditComplete?.(n,r,i)??"reject")==="reject")return"reject";if(this.idToItem.has(r.id))this.updateItem(i);return"accept"}renamePendingScrollTarget(t,n){let{pendingScrollTarget:r}=this;if(r==null||r.type==="position"||r.id!==t)return;this.pendingScrollTarget={...r,id:n}}renamePendingLayoutAnchor(t,n){if(this.pendingLayoutAnchor?.id===t)this.pendingLayoutAnchor.id=n}createFileOptionsPrototype(){let t={};for(let n of kS)Vn(t,n,()=>this.options[n]);Vn(t,"stickyHeader",()=>this.options.stickyHeaders),Vn(t,"collapsed",(n)=>{let r=hi(n);if(r==null)return;return this.getItemOptions(r,"file")?.item.collapsed}),Vn(t,"onEditComplete",(n)=>{if(this.options.onItemEditComplete==null)return;let r=hi(n);if(r==null)return;return(i)=>this.completeFileItemEdit(r,i)});for(let n of mS)this.defineItemSharedCallback(t,"file",n);for(let n of fS)this.defineItemSelectionCallback(t,"file",n);return t}createDiffOptionsPrototype(){let t={};for(let n of TS)Vn(t,n,()=>this.options[n]);Vn(t,"stickyHeader",()=>this.options.stickyHeaders),Vn(t,"hunkSeparators",()=>this.options.hunkSeparators),Vn(t,"collapsed",(n)=>{let r=hi(n);if(r==null)return;return this.getItemOptions(r,"diff")?.item.collapsed}),Vn(t,"onEditComplete",(n)=>{if(this.options.onItemEditComplete==null)return;let r=hi(n);if(r==null)return;return(i)=>this.completeDiffItemEdit(r,i)});for(let n of mS)this.defineItemSharedCallback(t,"diff",n);for(let n of fS)this.defineItemSelectionCallback(t,"diff",n);return t}createFileOptions(t){let n=Object.create(this.fileOptionsPrototype);return pS(n,{id:t}),n}createDiffOptions(t){let n=Object.create(this.diffOptionsPrototype);return pS(n,{id:t}),n}updateItemOptionsId(t,n){let r=hi(t);if(r==null)throw Error("CodeView.updateItemOptionsId: No valid state");r.id=n}getItemOptions(t,n){let r=this.idToItem.get(t.id);if(r==null||r.type!==n)return;return r}defineItemSharedCallback(t,n,r){Vn(t,r,(i)=>{if(this.options[r]==null)return;let o=hi(i);if(o==null)return;let s=o.callbackCache??={},a=s[r];if(a==null)a=(...l)=>{let d=this.getItemOptions(o,n);if(d==null)return;let c=this.options[r];return c?.(...l,d)},s[r]=a;return a})}defineItemSelectionCallback(t,n,r){Vn(t,r,(i)=>{let o=hi(i);if(o==null)return;let s=o.callbackCache??={},a=s[r];if(a==null)a=(l)=>{let d=this.getItemOptions(o,n);if(d==null)return;let c=l==null?null:{id:d.item.id,range:l};if(this.options.controlledSelection!==!0){if(l!=null||this.selectedLines?.id===d.item.id)this.applySelectedLines(c,{notify:!1})}this.options.onSelectedLinesChange?.(c);let m=this.options[r];return m?.(l,d)},s[r]=a;return a})}markLayoutDirtyFromIndex(t){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??t,t)}markItemLayoutDirty(t){if(this.items[t.index]!==t)throw Error(`CodeView.markItemLayoutDirty: unknown item id "${t.item.id}"`);this.markLayoutDirtyFromIndex(t.index)}tryAppendItems(t){if(t.length<=this.items.length)return!1;for(let n=0;n<this.items.length;n++){let r=this.items[n];if(r==null)throw Error("CodeView.tryAppendItems: missing existing item");let i=t[n];if(i==null||r.item.id!==i.id||r.type!==i.type)return!1}for(let n=0;n<this.items.length;n++){let r=this.items[n];if(r==null)throw Error("CodeView.tryAppendItems: missing existing item");let i=t[n];if(i==null)throw Error("CodeView.tryAppendItems: append candidate missing prefix item");if(this.syncItemRecord(r,i))this.markLayoutDirtyFromIndex(n)}return this.appendItemsInternal(t.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(t){let{items:n,idToItem:r}=this,i=new Set(n),o=[],s=new Map,a=new Map,l=new Map,d;for(let c=0;c<t.length;c++){let m=t[c];if(m==null)throw Error("CodeView.reconcileItems: missing input item");if(s.has(m.id))throw Error(`CodeView.setItems: duplicate id "${m.id}"`);let p=r.get(m.id),h=p!=null&&p.type===m.type?p:this.createItem(m,c,0);if(h.index=c,p!=null&&p.type===m.type){if(i.delete(p),this.syncItemRecord(h,m))d=Math.min(d??c,c)}else d=Math.min(d??c,c);if(n[c]!==h)d=Math.min(d??c,c);o.push(h),s.set(m.id,h),a.set(h.instance,h)}if(d==null){if(i.size===0)return;d=Math.max(o.length-1,0)}this.capturePendingLayoutAnchor(s);for(let c=0;c<n.length;c++){let m=n[c];if(m==null||!i.has(m))continue;l.set(m.item.id,m),this.releaseRenderedItem(m);let p=Math.max(o.length-1,0);d=Math.min(d??p,p)}if(this.items=o,this.idToItem=s,this.instanceToItem=a,this.renderState.firstIndex>=o.length)this.resetRenderState();else if(this.renderState.lastIndex>=o.length)this.renderState.lastIndex=o.length-1;return this.markLayoutDirtyFromIndex(d),this.scrollDirty=!0,this.render(),l.size>0?l:void 0}syncItemRecord(t,n){if(t.type!==n.type)throw Error(`CodeView.syncItemRecord: type mismatch for id "${n.id}"`);if(t.version===n.version)return!1;return t.item=n,t.version=n.version,t.renderedOptionsRevision=-1,!0}getMaxScrollTopForHeight(t){let{paddingBottom:n,paddingTop:r}=this.getLayout();return Math.max(r+this.header.height+t+this.footer.height+n-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>yS}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),pD):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(t){let n=this.getMaxPagedScrollTop();return Math.max(0,Math.min(t,n))}clampScrollTop(t){let n=this.getMaxScrollTop();return Math.max(0,Math.min(t,n))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(t){let n=this.getMaxScrollPageOffset();return Math.max(0,Math.min(t,n))}resolveScrollPageWindow(t,n){let r=qn(this.clampPagedScrollTop(n)),i=this.clampScrollPageOffset(t-r);return r=qn(this.clampPagedScrollTop(t-i)),i=this.clampScrollPageOffset(t-r),{pagedScrollTop:r,scrollPageOffset:i}}resolvePagedScrollPosition(t){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(t),scrollPageOffset:0};let n=this.clampScrollPageOffset(this.scrollPageOffset),r=t-n,i=this.getMaxPagedScrollTop(),o=this.getMaxScrollPageOffset(),s=r>yS&&n<o,a=r<hD&&n>0;if(r<0||r>i||s||a)return this.resolveScrollPageWindow(t,a?Math.min(yD,i):gD);return{pagedScrollTop:qn(this.clampPagedScrollTop(r)),scrollPageOffset:n}}needsScrollPageUpdate(t){let n=qn(this.clampScrollTop(t)),{scrollPageOffset:r}=this.resolvePagedScrollPosition(n);return r!==this.scrollPageOffset}getPagedLayoutTop(t){if(!this.shouldRebaseScroll())return t;return Math.max(t-this.scrollPageOffset,0)}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(t){let n=this.idToItem.get(t.id);if(n==null){console.warn(`CodeView.scrollTo: unknown item id "${t.id}"`);return}if(t.type==="item")return{top:n.top,height:n.height};if(t.type==="range"){let i=this.getRangeScrollPosition(n,t);if(i==null){console.warn(`CodeView.scrollTo: unable to resolve range ${xS(t.range)} for item "${t.id}"`);return}return{top:n.top+i.top,height:i.height}}let r=this.getLineScrollPosition(n,t);if(r==null){console.warn(`CodeView.scrollTo: unable to resolve line ${t.lineNumber} for item "${t.id}"`);return}return{top:n.top+r.top,height:r.height}}normalizeScrollTarget(t){if(t.type==="position"||t.align!=="nearest")return t;let n=this.getScrollTargetRect(t);if(n==null)return;let r=t.offset??0,i=this.getItemTopOffset()+n.top,o=i+n.height,s=this.getScrollTop(),a=s+(t.type==="line"||t.type==="range"?this.getStickyHeaderOffset():0),l=s+this.getHeight();if(i-r<=a&&o+r>=l)return;if(i-r<a)return{...t,align:"start"};if(o+r>l)return{...t,align:"end"}}resolveScrollTargetTop(t){if(t.type==="position"){let i=this.clampScrollTop(t.position);return i!==t.position?i:this.clampScrollTop(t.position-this.getStickyHeaderOffset())}let n=this.idToItem.get(t.id);if(n==null){console.warn(`CodeView.scrollTo: unknown item id "${t.id}"`);return}if(t.type==="item")return this.clampScrollTop(this.resolveAlignedScrollPosition(n.top,n.height,t.align,t.offset));if(t.type==="range"){let i=this.getRangeScrollPosition(n,t);if(i==null){console.warn(`CodeView.scrollTo: unable to resolve range ${xS(t.range)} for item "${t.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(n.top+i.top,i.height,t.align,t.offset,this.getStickyHeaderOffset()))}let r=this.getLineScrollPosition(n,t);if(r==null){console.warn(`CodeView.scrollTo: unable to resolve line ${t.lineNumber} for item "${t.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(n.top+r.top,r.height,t.align,t.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(t,n,r,i=0,o=0){t+=this.getItemTopOffset();let s=this.getHeight();if(r==="center"&&n+i<s)return t-(s-n)/2+i;if(r==="end")return t-(s-n)+i;return t-o-i}getLineScrollPosition(t,n){if(t.type==="diff")return t.instance.getLinePosition(n.lineNumber,n.side);return t.instance.getLinePosition(n.lineNumber)}getRangeScrollPosition(t,n){let{range:r}=n,i=this.getLineScrollPosition(t,{type:"line",id:n.id,lineNumber:r.start,side:r.side}),o=this.getLineScrollPosition(t,{type:"line",id:n.id,lineNumber:r.end,side:r.endSide??r.side});if(i==null||o==null)return;let s=i.top,a=s+i.height,l=o.top,d=l+o.height,c=Math.min(s,l);return{top:c,height:Math.max(a,d)-c}}computeTargetScrollTopForFrame(t,n){if(this.pendingScrollTarget==null)return t;let r=this.resolveScrollTargetTop(this.pendingScrollTarget);if(r==null)return t;let{scrollAnimation:i}=this;if(i==null)return r;return this.computeSpringStep(i,r,n).position}computeSpringStep(t,n,r){let i=Math.max(0,r-t.lastTimestamp),{omega:o}=this.getSmoothScrollSettings(),s=Math.exp(-o*i),a=t.position-n,l=t.velocity+o*a;return{position:n+(a+l*i)*s,velocity:(l*(1-o*i)-o*a)*s}}advanceScrollAnimation(t,n){if(this.pendingScrollTarget==null)return;let r=this.resolveScrollTargetTop(this.pendingScrollTarget);if(r==null){this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;return}let i=this.scrollAnimation;if(i==null)return r;i.position+=n;let{position:o,velocity:s}=this.computeSpringStep(i,r,t);i.lastTimestamp=t,i.position=o,i.velocity=s;let{positionEpsilon:a,velocityEpsilon:l}=this.getSmoothScrollSettings();if(Math.abs(r-o)<=a&&Math.abs(s)<=l)return i.position=r,i.velocity=0,this.scrollAnimation=void 0,r;return i.position}computeRenderRangeAndEmit=(t=performance.now())=>{if(e.__STOP||this.container==null)return;if(!this.isReady())return;let n=this.getHeight(),r=this.getScrollTop(),i=r,o=this.pendingLayoutAnchor!=null,s=this.getScrollAnchor(i);if(this.layoutDirtyIndex!=null)this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,o=!0;if(o&&s!=null){let R=this.resolveAnchoredScrollTop(s);if(R!=null){let A=R-i;if(i=R,this.scrollAnimation!=null)this.scrollAnimation.position+=A}}if(o)i=this.clampScrollTop(i),this.syncContainerHeight();let a=this.computeTargetScrollTopForFrame(i,t),l=!o&&(this.renderState.scrollTop===-1||Math.abs(a-this.renderState.scrollTop)>n+this.config.overscrollSize*2);if(l)s=void 0;this.windowSpecs=Kx({scrollTop:a-this.header.height,height:n,scrollHeight:this.getScrollHeight(),fitPerfectly:l,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let d=r;if(this.pendingScrollTarget!=null&&a!==d||this.needsScrollPageUpdate(a))this.applyScrollFix(a,d,this.windowSpecs),d=a;let{top:c,bottom:m}=this.windowSpecs,{firstIndex:p,lastIndex:h}=this.renderState;if(p>=0)for(let R=p;R<=h;R++){let A=this.items[R];if(A==null)throw Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${R}`);if(!(A.top>c-A.height&&A.top<=m))this.releaseRenderedItem(A)}let x=this.reconcileHeaderFooterHosts(),I,v=new Set,S=this.findFirstVisibleIndex(c),b=this.findLastVisibleIndex(m);for(let R=S;R<=b;R++){let A=this.items[R];if(A==null)throw Error("CodeView.computeRenderRangeAndEmit: missing item");let{instance:O}=A;if(A.element==null){if(A.element=this.acquireElement(),bS(this.stickyContainer,A.element,I),O.virtualizedSetup(),SS(A,A.element))A.renderedOptionsRevision=this.renderOptionsRevision,v.add(A);I=A.element}else{if(bS(this.stickyContainer,A.element,I),SS(A,void 0,A.renderedOptionsRevision!==this.renderOptionsRevision))A.renderedOptionsRevision=this.renderOptionsRevision,v.add(A);I=A.element}if(A.item.edit===!0)this.attachItemEditor(A)}if(this.renderState.firstIndex=S<=b?S:-1,this.renderState.lastIndex=b,this.flushSlotCoordinator(),this.flushManagers(v),x)this.measureMountedHosts();this.reconcileRenderedItems(v),this.syncContainerHeight(),this.updateStickyPositioning();let E=s!=null?this.resolveAnchoredScrollTop(s):void 0;if(s===this.pendingLayoutAnchor)this.pendingLayoutAnchor=void 0;let w=E!=null?E-i:0,k=a,L=!1;if(this.pendingScrollTarget!=null){let R=this.advanceScrollAnimation(t,w);if(R!=null)k=R,L=!0;else k=i}else k=E??a;if(k!==d)this.applyScrollFix(k,d,this.windowSpecs),d=k;if(L&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget))this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;if(this.renderState.scrollTop=qn(d),this.updateStickyPositioning(),this.validateStickyContainerHeight(),this.fixContainerFocus(),l||this.scrollAnimation!=null)this.render()};flushManagers(t){for(let n of t)n.instance.flushManagers()}syncContainerHeight(){let t=this.getPagedScrollHeight();if(this.container==null||this.containerHeight===t)return;this.container.style.height=`${t}px`,this.containerHeight=t}getStickyBounds(t){let{firstIndex:n,lastIndex:r}=t!=null?{firstIndex:this.findFirstVisibleIndex(t.top),lastIndex:this.findLastVisibleIndex(t.bottom)}:this.renderState;if(n===-1||r===-1||n>r)return;let i=this.items[n]?.instance.getAdvancedStickySpecs(t),o=this.items[r]?.instance.getAdvancedStickySpecs(t);if(i==null||o==null)return;return{stickyTop:this.getPagedLayoutTop(Math.max(i.topOffset,0)),stickyBottom:this.getPagedLayoutTop(o.topOffset+o.height)}}applyStickyPositioning({stickyTop:t,stickyBottom:n}){let r=this.getHeight(),{itemMetricsCache:i}=this,o=n-t;this.renderState.stickyHeight=o,this.renderState.stickyTop=t,this.renderState.stickyBottom=n,this.stickyOffset.style.height=`${t}px`;let s=(Math.random()*i.lineHeight>>0)*-1,a=-Math.max(o+s,0)+r;this.stickyContainer.style.top=`${a}px`,this.stickyContainer.style.bottom=`${a+i.diffHeaderHeight}px`}syncPagedScrollScaffolding(t){this.syncContainerHeight();let n=this.getStickyBounds(t);if(n==null){this.stickyOffset.style.height=`${this.getPagedLayoutTop(t.top)}px`;return}this.applyStickyPositioning(n)}reconcileRenderedItems(t){let{firstIndex:n,lastIndex:r}=this.renderState;if(n===-1)return;let i=-1,o=!1;for(let s=n;s<this.items.length;s++){if(!o&&s>r)break;let a=this.items[s];if(a==null)throw Error("CodeView.reconcileRenderedItems: Invalid item");if(i===-1)i=a.top;else if(a.top!==i)a.top=i,a.instance.syncVirtualizedTop(),o=!0;if(t==null?s<=r:t.has(a)){if(a.instance.reconcileHeights())o=!0,a.height=a.instance.getVirtualizedHeight();this.validateRenderedItemHeight(a)}if(i+=a.instance.getVirtualizedHeight(),s<this.items.length-1)i+=this.getLayout().gap}if(o&&i!=null)this.scrollDirty=!0,this.scrollHeight=i}updateStickyPositioning(){let t=this.getStickyBounds();if(t==null){if(this.renderState.firstIndex===-1)this.stickyOffset.style.height="";return}let{stickyTop:n,stickyBottom:r}=t;if(r-n===this.renderState.stickyHeight&&n===this.renderState.stickyTop&&r===this.renderState.stickyBottom)return;this.applyStickyPositioning(t)}handleScroll=()=>{if(e.__STOP)return;this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render()};clearPendingScroll=()=>{this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0};handleResize=(t)=>{let n=!1;for(let r of t)if(r.target===this.stickyContainer){let i=r.borderBoxSize[0].blockSize;if(Math.abs(i-this.renderState.stickyHeight)>=hS){let o=this.getScrollTop(),s=this.getScrollAnchor(o);this.reconcileRenderedItems(),this.updateStickyPositioning();let a=s!=null?this.resolveAnchoredScrollTop(s):void 0;if(a!=null){let l=a-o;if(this.applyScrollFix(a,o,this.windowSpecs),this.scrollAnimation!=null)this.scrollAnimation.position+=l}if(this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget))this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;n=!0}}else if(r.target===this.header.element||r.target===this.footer.element){let i=r.target===this.header.element?this.header:this.footer,o=r.borderBoxSize[0].blockSize;if(o!==i.height){let s=this.getScrollTop(),a=this.getScrollAnchor(s);this.setHostHeight(i,o);let l=a!=null?this.resolveAnchoredScrollTop(a):void 0;if(l!=null){let d=l-s;if(this.applyScrollFix(l,s,this.windowSpecs),this.scrollAnimation!=null)this.scrollAnimation.position+=d}if(this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget))this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;n=!0}}else this.scrollDirty=!0,this.heightDirty=!0,n=!0;if(n)this.render(!0)};getScrollAnchorViewportTop(t,n){return t<n?n+this.getStickyHeaderOffset():n}getScrollAnchor(t,n=this.idToItem){let r,{pendingLayoutAnchor:i}=this;if(i!=null){let c=this.idToItem.get(i.id);if(c!=null&&n.get(i.id)===c)return i;if(c!=null)r=c}if(t<=0)return;let{firstIndex:o,lastIndex:s,stickyTop:a,stickyBottom:l}=this.renderState;if(o===-1||s===-1)return;let d=this.getHeight();if(a===-1||l===-1)return;for(let c=o;c<=s;c++){let m=this.items[c];if(m==null)continue;let p=this.getItemTopOffset()+m.top;if(p+m.height<=t)continue;if(p>=t+d)break;if(n.get(m.item.id)!==m){r??=m;continue}if(p>=t)return{type:"item",id:m.item.id,viewportOffset:p-t};let h=this.getScrollAnchorViewportTop(p,t)-p,x=m.instance.getNumericScrollAnchor(h);if(x!=null){let I=p+x.top;return{type:"line",id:m.item.id,lineNumber:x.lineNumber,side:x.side,viewportOffset:I-t}}}if(r!=null)for(let c=r.index+1;c<this.items.length;c++){let m=this.items[c];if(m!=null&&n.get(m.item.id)===m)return{type:"item",id:m.item.id,viewportOffset:0}}}resolveAnchoredScrollTop(t){let n=this.idToItem.get(t.id);if(n==null)return;let r=this.getItemTopOffset();if(t.type==="item"){let s=r+n.top;return this.clampScrollTop(s-t.viewportOffset)}let i=n.type==="diff"?n.instance.getLinePosition(t.lineNumber,t.side):n.instance.getLinePosition(t.lineNumber);if(i==null)return;let o=r+n.top+i.top;return this.clampScrollTop(o-t.viewportOffset)}applyScrollFix(t,n,r){if(this.root==null)return;let i=qn(this.clampScrollTop(t)),o=qn(n),{scrollPageOffset:s}=this,a=qn(this.clampPagedScrollTop(o-s)),{pagedScrollTop:l,scrollPageOffset:d}=this.resolvePagedScrollPosition(i),c=l,m=s!==d;if(i===this.renderState.scrollTop&&i===o&&c===a&&!m)return;if(this.suspendScrollInteractions(),c!==a||m)this.scrollPageOffset=d,this.syncPagedScrollScaffolding(r);if(c!==a)this.root.scrollTo({top:c,behavior:"instant"});this.renderState.scrollTop=i,this.scrollTop=i,this.scrollDirty=!1}isPendingTargetSettled(t){let n=this.resolveScrollTargetTop(t);if(n==null)return!0;return qn(this.getScrollTop())===qn(n)}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let t=this.root?.scrollTop??0;return this.scrollTop=this.clampScrollTop(t+this.scrollPageOffset),this.scrollTop}getHeight(){if(!this.heightDirty)return this.height;return this.heightDirty=!1,this.height=this.root?.getBoundingClientRect().height??0,this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;let t=this.buildSlotSnapshot(this.slotCoordinator);if(Bx(this.slotSnapshot,t))return;this.slotSnapshot=t,this.slotCoordinator.onSnapshotChange(t)}notifyScroll(){if(this.scrollListeners.size===0)return;let t=this.getScrollTop();for(let n of this.scrollListeners)n(t,this)}findFirstVisibleIndex(t){let n=0,r=this.items.length-1,i=this.items.length;while(n<=r){let o=n+r>>1,s=this.items[o];if(s==null)throw Error("CodeView.findFirstVisibleIndex: invalid item index");if(s.top+s.height>t)i=o,r=o-1;else n=o+1}return i}findLastVisibleIndex(t){let n=0,r=this.items.length-1,i=-1;while(n<=r){let o=n+r>>1,s=this.items[o];if(s==null)throw Error("CodeView.findLastVisibleIndex: invalid item index");if(s.top<=t)i=o,n=o+1;else r=o-1}return i}recomputeLayout(t=0,n){if(this.items.length===0){this.scrollHeight=0;return}let r=this.getLayout(),i=0;if(t>0){let o=this.items[t-1];if(o==null)throw Error("CodeView.recomputeLayout: invalid dirty index");i=o.top+o.height+r.gap}for(let o=t;o<this.items.length;o++){let s=this.items[o];if(s==null)throw Error("CodeView.recomputeLayout: invalid item index");if(s.top=i,s.type==="diff")s.height=s.instance.updateCodeViewLayout(s.item.fileDiff,i,n,s.item.annotations??[]);else s.height=s.instance.updateCodeViewLayout(s.item.file,i,n,s.item.annotations??[]);if(i+=s.height,o<this.items.length-1)i+=r.gap}if(i!==this.scrollHeight)this.scrollDirty=!0;this.scrollHeight=i}resetRenderState(){this.renderState.scrollTop=-1,this.renderState.firstIndex=-1,this.renderState.lastIndex=-1,this.renderState.stickyHeight=0,this.renderState.stickyTop=-1,this.renderState.stickyBottom=-1}getFitPerfectlyOverscroll(){return this.getLayout().gap+this.itemMetricsCache.diffHeaderHeight}};function bD(e){if(e.instance.cleanUp(!0),e.type==="diff")return e.instance.updateCodeViewLayout(e.item.fileDiff,e.top,void 0,e.item.annotations??[]);else return e.instance.updateCodeViewLayout(e.item.file,e.top,void 0,e.item.annotations??[])}function CD(e,t){return!Cn(e.theme??Oe,t.theme??Oe)||(e.themeType??"system")!==(t.themeType??"system")||e.unsafeCSS!==t.unsafeCSS}function ED(e,t){return(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS||(e.diffStyle??"split")!==(t.diffStyle??"split")||(e.diffIndicators??"bars")!==(t.diffIndicators??"bars")||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function vD(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function TD(e){if(e instanceof SVGElement)return!0;return ai(e)&&(e.hasAttribute("data-core-css")||e.hasAttribute("data-theme-css")||e.hasAttribute("data-unsafe-css"))}function xS(e){let t=IS(e.start,e.side),n=IS(e.end,e.endSide??e.side);return t===n?t:`${t}-${n}`}function IS(e,t){if(t==null)return`${e}`;return`${t==="deletions"?"D":"A"}${e}`}function SS(e,t,n=!1){if(e.type==="diff")return e.instance.render({deferManagers:!0,fileContainer:t,fileDiff:e.item.fileDiff,forceRender:n,lineAnnotations:e.item.annotations??[]});else return e.instance.render({deferManagers:!0,fileContainer:t,file:e.item.file,forceRender:n,lineAnnotations:e.item.annotations??[]})}function bS(e,t,n){if(n==null){if(e.firstChild!==t)e.prepend(t);return}if(n.nextSibling!==t)n.after(t)}function kD(e){return(e.annotations?.length??0)>0}function wD(e,{hasHeaderRenderers:t,hasAnnotationRenderer:n,hasGutterRenderer:r}){if(e.length===0)return;if(t||r)return e;if(!n)return;let i=[];for(let o of e)if(kD(o.item))i.push(o);return i.length>0?i:void 0}var C={};Ut(C,{Assign:()=>d_,Clone:()=>oo,Create:()=>C_,Discard:()=>E_,Metrics:()=>Wn,Update:()=>v_});var Wn={assign:0,create:0,clone:0,discard:0,update:0};var He={};Ut(He,{Get:()=>u_,Reset:()=>a_,Set:()=>l_});var y={};Ut(y,{And:()=>fp,ArrayLiteral:()=>LH,ArrowFunction:()=>RH,Call:()=>AH,ConstDeclaration:()=>FH,Constant:()=>KS,Counted:()=>EH,Entries:()=>vH,Every:()=>SH,HasPropertyKey:()=>kH,If:()=>NH,IsArray:()=>qS,IsBigInt:()=>nH,IsBoolean:()=>rH,IsConstructor:()=>mH,IsDeepEqual:()=>wH,IsEqual:()=>fH,IsFunction:()=>cH,IsGreaterEqualThan:()=>yH,IsGreaterThan:()=>pH,IsInteger:()=>iH,IsLessEqualThan:()=>gH,IsLessThan:()=>hH,IsMaxLength:()=>IH,IsMinLength:()=>xH,IsNull:()=>oH,IsNumber:()=>sH,IsObject:()=>zS,IsObjectNotArray:()=>aH,IsString:()=>lH,IsSymbol:()=>uH,IsUndefined:()=>dH,Keys:()=>TH,Member:()=>$H,MultipleOf:()=>UH,New:()=>PH,Not:()=>jS,Or:()=>GS,ReduceAnd:()=>HH,ReduceOr:()=>_H,Return:()=>DH,Some:()=>bH,SomeAll:()=>CH,Statements:()=>OH,Ternary:()=>MH});var u={};Ut(u,{Counted:()=>KD,Entries:()=>XD,EntriesRegExp:()=>WD,Every:()=>GD,EveryAll:()=>jD,GraphemeCount:()=>_D,HasPropertyKey:()=>VD,IsArray:()=>ba,IsBigInt:()=>Sa,IsBoolean:()=>DS,IsClassInstance:()=>HD,IsConstructor:()=>$D,IsDeepEqual:()=>mp,IsEqual:()=>se,IsFunction:()=>HS,IsGreaterEqualThan:()=>US,IsGreaterThan:()=>FD,IsInteger:()=>up,IsLessEqualThan:()=>_S,IsLessThan:()=>ND,IsMaxLength:()=>UD,IsMinLength:()=>BD,IsMultipleOf:()=>DD,IsNull:()=>kd,IsNumber:()=>wd,IsObject:()=>Ca,IsObjectNotArray:()=>MD,IsString:()=>Ea,IsSymbol:()=>OD,IsUndefined:()=>dp,IsUnsafePropertyKey:()=>BS,IsValueLike:()=>cp,Keys:()=>Td,ShiftLeft:()=>Ld,Some:()=>qD,SomeAll:()=>zD,Symbols:()=>YD,Values:()=>JD});function ro(e,t,n){return e>=t&&e<=n}function AS(e){return e===8205}function LD(e){return ro(e,55296,56319)}function LS(e){return ro(e,127462,127487)}function PS(e){return ro(e,65024,65039)}function $S(e){return ro(e,768,879)||ro(e,6832,6911)||ro(e,7616,7679)||ro(e,65056,65071)}function vd(e){return e>65535?2:1}function RS(e,t){while(t<e.length){let n=e.codePointAt(t);if($S(n)||PS(n))t+=vd(n);else break}return t}function lp(e,t){let n=e.codePointAt(t),r=t+vd(n);r=RS(e,r);while(r<e.length-1&&AS(e.codePointAt(r))){let i=e.codePointAt(r+1);r+=1+vd(i),r=RS(e,r)}if(LS(n)&&r<e.length&&LS(e.codePointAt(r)))r+=vd(e.codePointAt(r));return r}function MS(e){return e>=768&&(LD(e)||$S(e)||PS(e)||AS(e))}function OS(e){let t=0,n=0;while(n<e.length)n=lp(e,n),t++;return t}function RD(e,t){let n=0,r=0;while(r<e.length)if(r=lp(e,r),++n>=t)return!0;return!1}function AD(e,t){let n=0,r=0;while(r<e.length)if(r=lp(e,r),++n>t)return!1;return!0}function FS(e,t){if(t===0)return!0;if(e.length<t)return!1;let n=0;while(!0){if(MS(e.charCodeAt(n)))return RD(e,t);if(++n>=t)return!0}}function NS(e,t){if(e.length<=t)return!0;let n=0;while(!0){if(MS(e.charCodeAt(n)))return AD(e,t);if(++n>t)return!1}}function ba(e){return Array.isArray(e)}function Sa(e){return se(typeof e,"bigint")}function DS(e){return se(typeof e,"boolean")}function $D(e){if(dp(e)||!HS(e))return!1;let t=Function.prototype.toString.call(e);if(/^class\s/.test(t))return!0;if(/\[native code\]/.test(t))return!0;return!1}function HS(e){return se(typeof e,"function")}function up(e){return Number.isInteger(e)}function kd(e){return se(e,null)}function wd(e){return Number.isFinite(e)}function MD(e){return Ca(e)&&!ba(e)}function Ca(e){return se(typeof e,"object")&&!kd(e)}function Ea(e){return se(typeof e,"string")}function OD(e){return se(typeof e,"symbol")}function dp(e){return se(e,void 0)}function se(e,t){return e===t}function FD(e,t){return e>t}function ND(e,t){return e<t}function _S(e,t){return e<=t}function US(e,t){return e>=t}function DD(e,t){if(Sa(e)||Sa(t))return BigInt(e)%BigInt(t)===0n;let n=0.0000000001;if(!wd(e))return!0;if(up(e)&&1/t%1===0)return!0;let r=e%t;return Math.min(Math.abs(r),Math.abs(r-t),Math.abs(r+t))<n}function HD(e){if(!Ca(e))return!1;let t=globalThis.Object.getPrototypeOf(e);if(kd(t))return!1;return se(typeof t.constructor,"function")&&!(se(t.constructor,globalThis.Object)||se(t.constructor.name,"Object"))}function cp(e){return Sa(e)||DS(e)||kd(e)||wd(e)||Ea(e)||dp(e)}function _D(e){return OS(e)}function UD(e,t){return NS(e,t)}function BD(e,t){return FS(e,t)}function GD(e,t,n){return e.every((r,i)=>i<t||n(r,i))}function jD(e,t,n){let r=!0;return e.forEach((i,o)=>{if(o>=t&&!n(i,o))r=!1}),r}function qD(e,t){return e.some((n,r)=>t(n,r))}function zD(e,t){let n=!1;return e.forEach((r,i)=>{if(t(r,i))n=!0}),n}function KD(e,t){return e.reduce((n,r,i)=>t(r,i)?++n:n,0)}function Ld(e,t,n){return se(e.length,0)?n():t(e[0],e.slice(1))}function BS(e){return se(e,"__proto__")||se(e,"constructor")||se(e,"prototype")}function VD(e,t){return BS(t)?Object.prototype.hasOwnProperty.call(e,t):(t in e)}function WD(e){return Td(e).map((t)=>[new RegExp(`^${t}$`),e[t]])}function XD(e){return Object.entries(e)}function Td(e){return Object.getOwnPropertyNames(e)}function YD(e){return Object.getOwnPropertySymbols(e)}function JD(e){return Object.values(e)}function ZD(e,t){if(!Ca(t))return!1;let n=Td(e);return se(n.length,Td(t).length)&&n.every((r)=>mp(e[r],t[r]))}function QD(e,t){return ba(t)&&se(e.length,t.length)&&e.every((n,r)=>mp(e[r],t[r]))}function mp(e,t){return ba(e)?QD(e,t):Ca(e)?ZD(e,t):se(e,t)}var eH=/^[\p{ID_Start}_$][\p{ID_Continue}_$\u200C\u200D]*$/u;function tH(e){return eH.test(e)}function fp(e,t){return`(${e} && ${t})`}function GS(e,t){return`(${e} || ${t})`}function jS(e){return`!(${e})`}function qS(e){return`Array.isArray(${e})`}function nH(e){return`typeof ${e} === "bigint"`}function rH(e){return`typeof ${e} === "boolean"`}function iH(e){return`Number.isInteger(${e})`}function oH(e){return`${e} === null`}function sH(e){return`Number.isFinite(${e})`}function aH(e){return fp(zS(e),jS(qS(e)))}function zS(e){return`typeof ${e} === "object" && ${e} !== null`}function lH(e){return`typeof ${e} === "string"`}function uH(e){return`typeof ${e} === "symbol"`}function dH(e){return`${e} === undefined`}function cH(e){return`typeof ${e} === "function"`}function mH(e){return`Guard.IsConstructor(${e})`}function fH(e,t){return`${e} === ${t}`}function pH(e,t){return`${e} > ${t}`}function hH(e,t){return`${e} < ${t}`}function gH(e,t){return`${e} <= ${t}`}function yH(e,t){return`${e} >= ${t}`}function xH(e,t){return`Guard.IsMinLength(${e}, ${t})`}function IH(e,t){return`Guard.IsMaxLength(${e}, ${t})`}function SH(e,t,n,r){return se(t,"0")?`${e}.every((${n[0]}, ${n[1]}) => (${r}))`:`${e}.every((${n[0]}, ${n[1]}) => (${n[1]} < ${t}) || (${r}))`}function bH(e,t,n){return`${e}.some((${t[0]}, ${t[1]}) => ${n})`}function CH(e,t,n){return`((value) => { let result = false; value.forEach((${t[0]}, ${t[1]}) => { if (${n}) result = true }); return result })(${e})`}function EH(e,t,n){return`${e}.reduce((result, ${t[0]}, ${t[1]}) => (${n}) ? ++result : result, 0)`}function vH(e){return`Object.entries(${e})`}function TH(e){return`Object.getOwnPropertyNames(${e})`}function kH(e,t){return se(t,'"__proto__"')||se(t,'"constructor"')?`Object.prototype.hasOwnProperty.call(${e}, ${t})`:`${t} in ${e}`}function wH(e,t){return`Guard.IsDeepEqual(${e}, ${t})`}function LH(e){return`[${e.join(", ")}]`}function RH(e,t){return`((${e.join(", ")}) => ${t})`}function AH(e,t){return`${e}(${t.join(", ")})`}function PH(e,t){return`new ${e}(${t.join(", ")})`}function $H(e,t){return`${e}${tH(t)?`.${t}`:`[${KS(t)}]`}`}function KS(e){if(!cp(e))throw Error("Unsupported Constant");return Ea(e)?JSON.stringify(e):`${e}`}function MH(e,t,n){return`(${e} ? ${t} : ${n})`}function OH(e){return`{ ${e.join("; ")}; }`}function FH(e,t){return`const ${e} = ${t}`}function NH(e,t){return`if(${e}) { ${t} }`}function DH(e){return`return ${e}`}function HH(e){return se(e.length,0)?"true":e.reduce((t,n)=>fp(t,n))}function _H(e){return se(e.length,0)?"false":e.reduce((t,n)=>GS(t,n))}function UH(e,t){return`Guard.IsMultipleOf(${e}, ${t})`}var jt={};Ut(jt,{IsBigInt64Array:()=>e_,IsBigUint64Array:()=>t_,IsBoolean:()=>BH,IsDate:()=>r_,IsFloat32Array:()=>ZH,IsFloat64Array:()=>QH,IsInt16Array:()=>WH,IsInt32Array:()=>YH,IsInt8Array:()=>zH,IsMap:()=>o_,IsNumber:()=>GH,IsRegExp:()=>n_,IsSet:()=>i_,IsString:()=>jH,IsTypeArray:()=>qH,IsUint16Array:()=>XH,IsUint32Array:()=>JH,IsUint8Array:()=>KH,IsUint8ClampedArray:()=>VH});function BH(e){return e instanceof Boolean}function GH(e){return e instanceof Number}function jH(e){return e instanceof String}function qH(e){return globalThis.ArrayBuffer.isView(e)}function zH(e){return e instanceof globalThis.Int8Array}function KH(e){return e instanceof globalThis.Uint8Array}function VH(e){return e instanceof globalThis.Uint8ClampedArray}function WH(e){return e instanceof globalThis.Int16Array}function XH(e){return e instanceof globalThis.Uint16Array}function YH(e){return e instanceof globalThis.Int32Array}function JH(e){return e instanceof globalThis.Uint32Array}function ZH(e){return e instanceof globalThis.Float32Array}function QH(e){return e instanceof globalThis.Float64Array}function e_(e){return e instanceof globalThis.BigInt64Array}function t_(e){return e instanceof globalThis.BigUint64Array}function n_(e){return e instanceof globalThis.RegExp}function r_(e){return e instanceof globalThis.Date}function i_(e){return e instanceof globalThis.Set}function o_(e){return e instanceof globalThis.Map}var Rd=u;var dr={immutableTypes:!1,maxErrors:8,maxInstantiationCount:128,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function a_(){dr.immutableTypes=!1,dr.maxErrors=8,dr.maxInstantiationCount=128,dr.useAcceleration=!0,dr.exactOptionalPropertyTypes=!1,dr.enumerableKind=!1,dr.correctiveParse=!1,dr.unionPrioritySort=!0}function l_(e){for(let t of u.Keys(e)){let n=e[t];if(n!==void 0)Object.defineProperty(dr,t,{value:n})}}function u_(){return dr}function gi(e){return He.Get().immutableTypes?Object.freeze(e):e}function d_(e,t){return Wn.assign+=1,gi({...e,...t})}function c_(e){return e}function m_(e){return u.HasPropertyKey(e,"~kind")||u.HasPropertyKey(e,"~unsafe")}function f_(e){let t={};for(let n of u.Keys(e)){if(u.IsUnsafePropertyKey(n))continue;let r=Object.getOwnPropertyDescriptor(e,n);if(r.value=io(r.value),u.IsEqual(r.enumerable,!0))t[n]=r.value;else Object.defineProperty(t,n,r)}return t}function p_(e){let t={};for(let n of u.Keys(e)){if(u.IsUnsafePropertyKey(n))continue;t[n]=io(e[n])}for(let n of u.Symbols(e))t[n]=io(e[n]);return t}function h_(e){return u.IsClassInstance(e)?c_(e):m_(e)?f_(e):p_(e)}function g_(e){return e.map((t)=>io(t))}function y_(e){return e.slice()}function x_(e){return new RegExp(e.source,e.flags)}function I_(e){return new Map(io([...e.entries()]))}function S_(e){return new Set(io([...e.values()]))}function io(e){return jt.IsTypeArray(e)?y_(e):jt.IsRegExp(e)?x_(e):jt.IsMap(e)?I_(e):jt.IsSet(e)?S_(e):u.IsArray(e)?g_(e):u.IsObject(e)?h_(e):e}function oo(e){return Wn.clone+=1,io(e)}function b_(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}function VS(e,t){return{...e,...t}}function C_(e,t,n={}){Wn.create+=1;let r=VS(t,n),i=He.Get().enumerableKind?VS(r,e):b_(r,e);return gi(i)}function E_(e,t){Wn.discard+=1;let n={};for(let r of u.Keys(e)){if(t.includes(r))continue;let i=Object.getOwnPropertyDescriptor(e,r);i.value=oo(i.value),Object.defineProperty(n,r,i)}return gi(n)}function v_(e,t,n){Wn.update+=1;let r=He.Get(),i=oo(e);for(let o of Object.keys(t))Object.defineProperty(i,o,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[o]});for(let o of Object.keys(n))Object.defineProperty(i,o,{configurable:!0,enumerable:!0,writable:!0,value:n[o]});return gi(i)}function _(e,t){return u.IsObject(e)&&u.HasPropertyKey(e,"~kind")&&u.IsEqual(e["~kind"],t)}function Ge(e){return u.IsObject(e)}function U(e,t,n){return C.Create({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:n},{})}function yi(e){return _(e,"Deferred")}function T_(e){return C.Update(e,{"~readonly":!0},{})}function va(e,t){return C.Update(T_(e),{},t)}function WS(e,t,n,r){let i=M(e,t,n);return va(i,r)}function k_(e){return C.Update(e,{"~optional":!0},{})}function Ta(e,t){return C.Update(k_(e),{},t)}function XS(e,t,n,r){let i=M(e,t,n);return Ta(i,r)}function tn(e,t){return C.Create({"~kind":"Array"},{type:"array",items:e},t)}function le(e){return _(e,"Array")}function is(e){return C.Discard(e,["~kind","type","items"])}function cr(e,t,n={}){return C.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},n)}function nt(e){return _(e,"Constructor")}function YS(e){return C.Discard(e,["~kind","type","parameters","instanceType"])}function mr(e,t,n={}){return C.Create({["~kind"]:"Function"},{type:"function",parameters:e,returnType:t},n)}function rt(e){return _(e,"Function")}function JS(e){return C.Discard(e,["~kind","type","parameters","returnType"])}function pt(e,t){return C.Create({["~kind"]:"Ref"},{$ref:e},t)}function xe(e){return _(e,"Ref")}function xi(e,t){return C.Create({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function os(e){return _(e,"Generic")}function ss(e){return C.Create({["~kind"]:"Any"},{},e)}function je(e){return _(e,"Any")}var ZS="(?!)";function be(e){return C.Create({"~kind":"Never"},{not:{}},e)}function fn(e){return _(e,"Never")}function fr(e,t={}){return U("AddOptional",[e],t)}function so(e,t={}){return Ta(e,t)}function QS(e){return so(e)}function ht(e){return Ge(e)&&u.HasPropertyKey(e,"~optional")}function eb(e){return u.Keys(e).filter((t)=>!ht(e[t]))}function Ad(e){return u.Keys(e)}function Pd(e){return u.Values(e)}function q(e,t={}){let n=eb(e),r=n.length>0?{required:n}:{};return C.Create({"~kind":"Object"},{type:"object",...r,properties:e},t)}function V(e){return _(e,"Object")}function tb(e){return C.Discard(e,["~kind","type","properties","required"])}function dt(e){return C.Create({["~kind"]:"Unknown"},{},e)}function it(e){return _(e,"Unknown")}function pr(e,t,n){let r=u.Keys(e).reduce((i,o)=>({...i,[o]:C.Update(e[o],{},{$id:o})}),{});return C.Create({["~kind"]:"Cyclic"},{$defs:r,$ref:t},n)}function ke(e){return _(e,"Cyclic")}function nb(e){return C.Update(e,{["~unsafe"]:null},{})}function $d(e){return u.IsObjectNotArray(e)&&u.HasPropertyKey(e,"~unsafe")&&u.IsNull(e["~unsafe"])}var ee={};Ut(ee,{Match:()=>w_});function w_(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}function ka(...e){let[t,n]=ee.Match(e,{2:(r,i)=>[r,i,i],1:(r)=>[r,dt(),dt()]});return C.Create({["~kind"]:"Infer"},{type:"infer",name:t,extends:n},{})}function ot(e){return _(e,"Infer")}function ao(e,t,n,r={}){return C.Create({"~kind":"Dependent"},{if:e,then:t,else:n},r)}function Ke(e){return _(e,"Dependent")}function rb(e){return C.Discard(e,["~kind","if","then","else"])}function ib(e){return u.IsObjectNotArray(e)}function ob(e){return u.Keys(e).filter((n)=>isNaN(n)).reduce((n,r)=>[...n,e[r]],[])}function sb(e){return u.IsString(e)||u.IsNumber(e)}function ab(e,t){let n=ib(e)?ob(e):e;return C.Create({"~kind":"Enum"},{enum:n},t)}function st(e){return _(e,"Enum")}function Ft(e,t={}){return C.Create({"~kind":"Intersect"},{allOf:e},t)}function z(e){return _(e,"Intersect")}function lb(e){return C.Discard(e,["~kind","allOf"])}var as={};Ut(as,{CanEvaluate:()=>R_,Evaluate:()=>ub});var pp=void 0;function L_(){try{return ub("null")(),!0}catch{return!1}}function R_(){if(u.IsUndefined(pp))pp=L_();return pp&&He.Get().useAcceleration}function ub(...e){return new globalThis.Function(...e)}var Br={};Ut(Br,{Hash:()=>V_,HashCode:()=>hb});function Ve(){throw Error("Unreachable")}function A_(e){let t=new Set,n=e;while(n&&n!==Object.prototype){for(let r of Reflect.ownKeys(n))if(r!=="constructor"&&typeof r!=="symbol")t.add(r);n=Object.getPrototypeOf(n)}return[...t]}function P_(e){return typeof e==="number"}var qt;(function(e){e[e.Array=0]="Array",e[e.BigInt=1]="BigInt",e[e.Boolean=2]="Boolean",e[e.Date=3]="Date",e[e.Constructor=4]="Constructor",e[e.Function=5]="Function",e[e.Null=6]="Null",e[e.Number=7]="Number",e[e.Object=8]="Object",e[e.RegExp=9]="RegExp",e[e.String=10]="String",e[e.Symbol=11]="Symbol",e[e.TypeArray=12]="TypeArray",e[e.Undefined=13]="Undefined"})(qt||(qt={}));var ls=BigInt("14695981039346656037"),[$_,M_]=[BigInt("1099511628211"),BigInt("18446744073709551616")],O_=Array.from({length:256}).map((e,t)=>BigInt(t)),mb=new Float64Array(1),fb=new DataView(mb.buffer),pb=new Uint8Array(mb.buffer);function wt(e){ls=ls^O_[e],ls=ls*$_%M_}function F_(e){wt(qt.Array);for(let t of e)Ii(t)}function N_(e){wt(qt.BigInt),fb.setBigInt64(0,e);for(let t of pb)wt(t)}function db(e){wt(qt.Boolean),wt(e?1:0)}function D_(e){wt(qt.Constructor),Ii(e.toString())}function H_(e){wt(qt.Date),Ii(e.getTime())}function __(e){wt(qt.Function),Ii(e.toString())}function U_(e){wt(qt.Null)}function cb(e){wt(qt.Number),fb.setFloat64(0,e,!0);for(let t of pb)wt(t)}function B_(e){wt(qt.Object);for(let t of A_(e).sort())Ii(t),Ii(e[t])}function G_(e){wt(qt.RegExp),hp(e.toString())}var j_=new TextEncoder;function hp(e){wt(qt.String);for(let t of j_.encode(e))wt(t)}function q_(e){wt(qt.Symbol),Ii(e.toString())}function z_(e){wt(qt.TypeArray);let t=new Uint8Array(e.buffer);for(let n=0;n<t.length;n++)wt(t[n])}function K_(e){return wt(qt.Undefined)}function Ii(e){return jt.IsTypeArray(e)?z_(e):jt.IsDate(e)?H_(e):jt.IsRegExp(e)?G_(e):jt.IsBoolean(e)?db(e.valueOf()):jt.IsString(e)?hp(e.valueOf()):jt.IsNumber(e)?cb(e.valueOf()):P_(e)?cb(e):u.IsArray(e)?F_(e):u.IsBoolean(e)?db(e):u.IsBigInt(e)?N_(e):u.IsConstructor(e)?D_(e):u.IsNull(e)?U_(e):u.IsObject(e)?B_(e):u.IsString(e)?hp(e):u.IsSymbol(e)?q_(e):u.IsUndefined(e)?K_(e):u.IsFunction(e)?__(e):Ve()}function hb(e){return ls=BigInt("14695981039346656037"),Ii(e),ls}function V_(e){return hb(e).toString(16).padStart(16,"0")}function gb(e){switch(e.keyword){case"additionalProperties":return"must not have additional properties";case"anyOf":return"must match a schema in anyOf";case"boolean":return"schema is false";case"const":return"must be equal to constant";case"contains":return"must contain at least 1 valid item";case"dependencies":return`must have properties ${e.params.dependencies.join(", ")} when property ${e.params.property} is present`;case"dependentRequired":return`must have properties ${e.params.dependencies.join(", ")} when property ${e.params.property} is present`;case"enum":return"must be equal to one of the allowed values";case"exclusiveMaximum":return`must be ${e.params.comparison} ${e.params.limit}`;case"exclusiveMinimum":return`must be ${e.params.comparison} ${e.params.limit}`;case"format":return`must match format "${e.params.format}"`;case"if":return`must match "${e.params.failingKeyword}" schema`;case"maxItems":return`must not have more than ${e.params.limit} items`;case"maxLength":return`must not have more than ${e.params.limit} characters`;case"maxProperties":return`must not have more than ${e.params.limit} properties`;case"maximum":return`must be ${e.params.comparison} ${e.params.limit}`;case"minItems":return`must not have fewer than ${e.params.limit} items`;case"minLength":return`must not have fewer than ${e.params.limit} characters`;case"minProperties":return`must not have fewer than ${e.params.limit} properties`;case"minimum":return`must be ${e.params.comparison} ${e.params.limit}`;case"multipleOf":return`must be multiple of ${e.params.multipleOf}`;case"not":return"must not be valid";case"oneOf":return"must match exactly one schema in oneOf";case"pattern":return`must match pattern "${e.params.pattern}"`;case"propertyNames":return`property names ${e.params.propertyNames.join(", ")} are invalid`;case"required":return`must have required properties ${e.params.requiredProperties.join(", ")}`;case"type":return typeof e.params.type==="string"?`must be ${e.params.type}`:`must be either ${e.params.type.join(" or ")}`;case"unevaluatedItems":return"must not have unevaluated items";case"unevaluatedProperties":return"must not have unevaluated properties";case"uniqueItems":return"must not have duplicate items";case"~refine":return e.params.message;default:return"an unknown validation error occurred"}}var W_=gb;function yb(){return W_}class Md{constructor(e,t){this.type=e,this.decode=t}Encode(e){let t=this.type,n=zt(t)?(o)=>this.decode(t["~codec"].decode(o)):this.decode,r=zt(t)?(o)=>t["~codec"].encode(e(o)):e,i={decode:n,encode:r};return C.Update(this.type,{"~codec":i},{})}}class Od{constructor(e){this.type=e}Decode(e){return new Md(this.type,e)}}function Fd(e){return new Od(e)}function Ib(e,t){return Fd(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function Sb(e,t){return Fd(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function zt(e){return Ge(e)&&u.HasPropertyKey(e,"~codec")&&u.IsObject(e["~codec"])&&u.HasPropertyKey(e["~codec"],"encode")&&u.HasPropertyKey(e["~codec"],"decode")}function bb(e){return us(e)}function lo(e){return Ge(e)&&u.HasPropertyKey(e,"~immutable")}function hr(e,t={}){return U("AddReadonly",[e],t)}function uo(e,t={}){return va(e,t)}function Cb(e){return uo(e)}function co(e){return Ge(e)&&u.HasPropertyKey(e,"~readonly")}function Y_(e,t){let n=Nd(e)?[...e["~refine"],t]:[t];return C.Update(e,{"~refine":n},{})}function Eb(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[i,o,()=>"Refine Error"]});return Y_(t,{check:n,error:r})}function J_(e){return u.IsObjectNotArray(e)&&u.HasPropertyKey(e,"check")&&u.HasPropertyKey(e,"error")&&u.IsFunction(e.check)&&u.IsFunction(e.error)}function Nd(e){return Ge(e)&&u.HasPropertyKey(e,"~refine")&&u.IsArray(e["~refine"])&&u.Every(e["~refine"],0,(t)=>J_(t))}var vb="-?(?:0|[1-9][0-9]*)n";function wa(e){return C.Create({"~kind":"BigInt"},{type:"bigint"},e)}function pn(e){return _(e,"BigInt")}function Dd(e){return C.Create({"~kind":"Boolean"},{type:"boolean"},e)}function Kt(e){return _(e,"Boolean")}function La(e){return C.Create({"~kind":"Identifier"},{name:e})}function Tb(e){return _(e,"Identifier")}var Hd="-?(?:0|[1-9][0-9]*)";function mo(e){return C.Create({"~kind":"Integer"},{type:"integer"},e)}function It(e){return _(e,"Integer")}class kb extends Error{constructor(e){super("Invalid Literal value");Object.defineProperty(this,"cause",{value:{value:e},writable:!1,configurable:!1,enumerable:!1})}}function Z_(e){return u.IsBigInt(e)?"bigint":u.IsBoolean(e)?"boolean":u.IsNumber(e)?"number":u.IsString(e)?"string":(()=>{throw new kb(e)})()}function ne(e,t){return C.Create({"~kind":"Literal"},{type:Z_(e),const:e},t)}function _d(e){return u.IsBigInt(e)||u.IsBoolean(e)||u.IsNumber(e)||u.IsString(e)}function wb(e){return ae(e)&&u.IsBigInt(e.const)}function Lb(e){return ae(e)&&u.IsBoolean(e.const)}function Ud(e){return ae(e)&&u.IsNumber(e.const)}function Bd(e){return ae(e)&&u.IsString(e.const)}function ae(e){return _(e,"Literal")}function ds(e){return C.Create({"~kind":"Null"},{type:"null"},e)}function gr(e){return _(e,"Null")}var Gd="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function hn(e){return C.Create({"~kind":"Number"},{type:"number"},e)}function _e(e){return _(e,"Number")}function cs(e){return C.Create({"~kind":"Symbol"},{type:"symbol"},e)}function yr(e){return _(e,"Symbol")}function fo(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[i,o,o],1:(i)=>[i,dt(),dt()]});return C.Create({"~kind":"Parameter"},{name:t,extends:n,equals:r},{})}function Rb(e){return _(e,"Parameter")}var jd=".*";function Vt(e){return C.Create({"~kind":"String"},{type:"string"},e)}function ct(e){return _(e,"String")}function J(e,t={}){return C.Create({"~kind":"Union"},{anyOf:e},t)}function F(e){return _(e,"Union")}function Ab(e){return C.Discard(e,["~kind","anyOf"])}function Ra(e){let t=Pb(e);return u.IsEqual(t.length,2)?t[0]:[]}function Q_(e){return!0}function $b(e){return u.ShiftLeft(e,(t,n)=>eU(t)?$b(n):!1,()=>!0)}function Mb(e){return u.IsEqual(e.length,0)?!1:$b(e)}function eU(e){return F(e)?Mb(e.anyOf):ae(e)?Q_(e.const):!1}function qd(e){return Mb(e)}function zd(e){return C.Create({["~kind"]:"TemplateLiteral"},{type:"string",pattern:e},{})}function Ob(e,t,n=[]){return u.ShiftLeft(e,(r,i)=>Ob(i,t,[...n,`${r}${t}`]),()=>n)}function tU(e,t){return u.IsEqual(e.length,0)?[`${t}`]:Ob(e,t)}function Fb(e,t,n=[]){return u.ShiftLeft(t,(r,i)=>Fb(e,i,[...n,...Nb(e,r)]),()=>n)}function Nb(e,t){return F(t)?Fb(e,t.anyOf):ae(t)?tU(e,t.const):Ve()}function Db(e,t){return u.ShiftLeft(t,(n,r)=>Db(Nb(e,n),r),()=>e)}function nU(e){return e.map((t)=>ne(t))}function rU(e){let t=Db([],e),n=nU(t);return J(n)}function iU(e){return u.IsEqual(e.length,0)?Ve():u.IsEqual(e.length,1)&&ae(e[0])?e[0]:rU(e)}function gp(e){let t=Ra(e);return u.IsEqual(t.length,0)?Vt():qd(t)?iU(t):zd(e)}function Aa(e){let t=gp(e);return Le(t)?Vt():t}function nn(e,t){let r={[e]:t};return C.Create({["~kind"]:"Record"},{type:"object",patternProperties:r})}function Hb(e){return nn(Xn,e)}function _b(e){return q({true:e,false:e})}function We(e,t={}){let[n,r,i]=[e,e.length,!1];return C.Create({["~kind"]:"Tuple"},{type:"array",additionalItems:i,items:n,minItems:r},t)}function re(e){return _(e,"Tuple")}function Ub(e){return C.Discard(e,["~kind","type","items","minItems","additionalItems"])}function oU(e){return C.Discard(e,["~readonly"])}function yp(e,t){return C.Update(oU(e),{},t)}function Bb(e,t,n,r){let i=M(e,t,n);return yp(i,r)}function Gb(e,t={}){return U("RemoveReadonly",[e],t)}function jb(e,t={}){return yp(e,t)}function sU(e){return C.Discard(e,["~optional"])}function xp(e,t){return C.Update(sU(e),{},t)}function qb(e,t,n,r){let i=M(e,t,n);return xp(i,r)}function zb(e,t={}){return U("RemoveOptional",[e],t)}function Kd(e,t={}){return xp(e,t)}function Ip(e){return e.reduceRight((n,r,i)=>({[i]:r,...n}),{})}function Kb(e){let t=Ip(e.items);return q(t)}function Sp(e){return V(e)||re(e)}function aU(e,t){return co(e)?co(t)?!0:!1:!1}function lU(e,t){return ht(e)?ht(t)?!0:!1:!1}function uU(e,t){let n=aU(e,t),r=lU(e,t),i=Ue([e,t]),o=jb(Kd(i));return n&&r?uo(so(o)):n&&!r?uo(o):!n&&r?so(o):o}function dU(e,t,n){return n in e?n in t?uU(e[n],t[n]):e[n]:(n in t)?t[n]:be()}function cU(e,t){return[...new Set([...u.Keys(e),...u.Keys(t)])].reduce((i,o)=>({...i,[o]:dU(e,t,o)}),{})}function Vb(e){return V(e)?e.properties:re(e)?Ip(e.items):{}}function Wb(e,t){let n=Vb(e),r=Vb(t),i=cU(n,r);return q(i)}function mU(e,t){let n=ms(e,t);return u.IsEqual(n,$a)?e:u.IsEqual(n,Ma)?t:u.IsEqual(n,Pa)?t:be()}function fU(e,t){let n=Sp(e),r=Sp(t);return n&&r?Wb(e,t):n&&!r?e:!n&&r?t:mU(e,t)}function Xb(e,t){return fn(e)?e:je(e)?e:it(e)?t:fn(t)?t:je(t)?t:it(t)?e:fU(e,t)}function pU(e,t){return F(e)||F(t)}function hU(e,t){let n=Fn(e),r=Fn(t);return pU(n,r)?Ue([n,r]):Xb(n,r)}function Yb(e,t,n=[]){return u.ShiftLeft(t,(r,i)=>Yb(e,i,[...n,hU(r,e)]),()=>u.IsEqual(n.length,0)?[e]:n)}function Jb(e,t,n=[]){return u.ShiftLeft(e,(r,i)=>Jb(i,t,[...n,...Oa([r],t)]),()=>n)}function Oa(e,t=[]){return u.ShiftLeft(e,(n,r)=>F(n)?Oa(r,Jb(n.anyOf,t)):Oa(r,Yb(n,t)),()=>t)}function gU(e,t){let n=Pt({},e,t);return W.IsExtendsTrueLike(n)?[]:[e]}function Zb(e,t,n=[]){return u.ShiftLeft(e,(r,i)=>Zb(i,t,[...n,...gU(r,t)]),()=>n)}function Vd(e,t){let n=Fn(e),r=F(n)?n.anyOf:[n],i=Zb(r,t);return rn(i)}function Yn(e,t,n){let r=Ue([e,t]),i=Vd(n,e);return rn([r,i])}function Wt(e,t=[]){return u.ShiftLeft(e,(n,r)=>Wt(r,[...t,ne(n)]),()=>rn(t))}function Ue(e){let t=Oa(e),n=bp(t);return rn(n)}function Nt(e){let t=Aa(e);return Fn(t)}function rn(e){let t=bp(e);return Si(t)}function Fn(e){return Ke(e)?Yn(e.if,e.then,e.else):st(e)?Wt(e.enum):z(e)?Ue(e.allOf):Le(e)?Nt(e.pattern):F(e)?rn(e.anyOf):e}function Si(e){return u.IsEqual(e.length,1)?e[0]:u.IsEqual(e.length,0)?be():J(e)}function Qb(e,t){let n=Wt(e);return bi(n,t)}function eC(e,t){return nn(Ci,t)}function tC(e,t){let n=Ue(e);return bi(n,t)}function nC(e,t){return u.IsString(e)||u.IsNumber(e)?q({[e]:t}):u.IsEqual(e,!1)?q({false:t}):u.IsEqual(e,!0)?q({true:t}):q({})}function rC(e,t){return nn(fs,t)}function iC(e,t){return u.HasPropertyKey(e,"pattern")&&(u.IsString(e.pattern)||e.pattern instanceof RegExp)?nn(e.pattern.toString(),t):nn(Xn,t)}function oC(e,t){let n=Ra(e);return qd(n)?bi(Nt(e),t):nn(e,t)}function yU(e){return F(e)?po(e.anyOf):[e]}function po(e,t=[]){return u.ShiftLeft(e,(n,r)=>po(r,[...t,...yU(n)]),()=>t)}function xU(e){return e.some((t)=>ct(t)||_e(t)||It(t))}function IU(e,t){return u.IsEqual(xU(e),!0)?nn(Xn,t):void 0}function SU(e,t){return e.reduce((n,r)=>ae(r)&&(u.IsString(r.const)||u.IsNumber(r.const))?{...n,[r.const]:t}:n,{})}function bU(e,t){let n=SU(e,t);return q(n)}function sC(e,t){let n=po(e),r=IU(n,t);return Ge(r)?r:bU(n,t)}function bi(e,t){return je(e)?Hb(t):Kt(e)?_b(t):st(e)?Qb(e.enum,t):It(e)?eC(e,t):z(e)?tC(e.allOf,t):ae(e)?nC(e.const,t):_e(e)?rC(e,t):F(e)?sC(e.anyOf,t):ct(e)?iC(e,t):Le(e)?oC(e.pattern,t):q({})}function Cp(e,t,n){return te([e])?C.Update(bi(e,t),{},n):Wd(e,t,n)}function aC(e,t,n,r,i){let o=M(e,t,n),s=M(e,t,r);return Cp(o,s,i)}var Ci=`^${Hd}$`,fs=`^${Gd}$`,Xn=`^${jd}$`;function Wd(e,t,n={}){return U("Record",[e,t],n)}function ps(e,t,n={}){return Cp(e,t,n)}function lC(e,t){return nn(e,t)}function Xd(e){return u.IsEqual(e,Xn)?Vt():u.IsEqual(e,Ci)?mo():u.IsEqual(e,fs)?hn():gp(e)}function St(e){return u.Keys(e.patternProperties)[0]}function Ei(e){let t=St(e);return Xd(t)}function Ae(e){return e.patternProperties[St(e)]}function Se(e){return _(e,"Record")}function ho(e){return C.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function vi(e){return _(e,"Rest")}function Yd(e){return C.Create({["~kind"]:"This"},{$ref:"#"},e)}function Jd(e){return _(e,"This")}function hs(e){return C.Create({"~kind":"Undefined"},{type:"undefined"},e)}function Jn(e){return _(e,"Undefined")}function Zd(e){return C.Create({"~kind":"Void"},{type:"void"},e)}function gn(e){return _(e,"Void")}function EU(e,t){return u.IsEqual(e,"Array")?tn(t[0]):u.IsEqual(e,"Capitalize")?ec(t[0]):u.IsEqual(e,"ConstructorParameters")?oc(t[0]):u.IsEqual(e,"Evaluate")?TE(t[0]):u.IsEqual(e,"Exclude")?sc(t[0],t[1]):u.IsEqual(e,"Extract")?ac(t[0],t[1]):u.IsEqual(e,"Index")?Ha(t[0],t[1]):u.IsEqual(e,"InstanceType")?lc(t[0]):u.IsEqual(e,"Lowercase")?tc(t[0]):u.IsEqual(e,"NonNullable")?uc(t[0]):u.IsEqual(e,"Omit")?dc(t[0],t[1]):u.IsEqual(e,"Parameters")?cc(t[0]):u.IsEqual(e,"Partial")?mc(t[0]):u.IsEqual(e,"Pick")?fc(t[0],t[1]):u.IsEqual(e,"Readonly")?pc(t[0]):u.IsEqual(e,"KeyOf")?_a(t[0]):u.IsEqual(e,"Record")?Wd(t[0],t[1]):u.IsEqual(e,"Required")?hc(t[0]):u.IsEqual(e,"ReturnType")?gc(t[0]):u.IsEqual(e,"Uncapitalize")?nc(t[0]):u.IsEqual(e,"Uppercase")?rc(t[0]):Da(pt(e),t)}function go(){throw Error("Unreachable")}function fC(e,t=[]){return u.ShiftLeft(e,(n,r)=>fC(r,[...t,n[1]]),()=>t)}function Gr(e){return u.IsEqual(e.length,3)?[e[0],...fC(e[1])]:[]}function pC(e){return fo(e[0],e[2],e[4])}function hC(e){return fo(e[0],e[2],e[2])}function gC(e){return fo(e[0],dt(),e[2])}function yC(e){return fo(e,dt(),dt())}function xC(e){return e}function IC(e){return Gr(e)}function SC(e){return e[1]}function bC(e){return Gr(e)}function CC(e){return e[1]}function EC(e){return EU(e[0],e[1])}function vC(e){return null}function TC(e){return Vt()}function kC(e){return hn()}function wC(e){return Dd()}function LC(e){return hs()}function RC(e){return ds()}function AC(e){return mo()}function PC(e){return wa()}function $C(e){return dt()}function MC(e){return ss()}function OC(e){return q({})}function FC(e){return be()}function NC(e){return cs()}function DC(e){return Zd()}function HC(e){return Yd()}function _C(e){return ne(BigInt(e))}function UC(e){return ne(u.IsEqual(e,"true"))}function BC(e){return ne(parseFloat(e))}function GC(e){return ne(e)}function jC(e){return e[1]}function qC(e){return ne(e)}function zC(e){return u.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function KC(e){return e[1]}function VC(e){return Qd(e)}function WC(e){return u.IsEqual(e.length,6)?ao(e[1],e[3],e[5]):ao(e[1],e[3],dt())}function XC(e){return e.length>0}function YC(e){return e.reduce((t,n)=>u.IsEqual(n.length,3)?[...t,[n[1]]]:[...t,[]],[])}function JC(e){return u.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function ZC(e){return u.IsArray(e)&&u.IsEqual(e.length,3)?e[1]:e}function QC(e){return u.IsEqual(e.length,2)?e[1]:[]}function uC(e,t){return t.reduce((n,r)=>{let i=r;return u.IsEqual(i.length,1)?Ha(n,i[0]):u.IsEqual(i.length,0)?tn(n):go()},e)}function dC(e,t){return u.IsEqual(t.length,3)?ic(e,t[0],t[1],t[2]):e}function vU(e,t){return u.IsArray(t)&&u.IsEqual(t.length,0)?e:yc(e,t)}function e0(e){let[t,n,r,i,o]=e;return vU(t?dC(_a(uC(n,r)),i):dC(uC(n,r),i),o)}function Ep(e,t){return u.IsEqual(t.length,3)?(()=>{let[n,r,i]=t,o=Ep(r,i);if(u.IsEqual(n,"&"))return z(o)?Ft([e,...o.allOf]):Ft([e,o]);if(u.IsEqual(n,"|"))return F(o)?J([e,...o.anyOf]):J([e,o]);go()})():e}function t0(e){return e}function n0(e){let[t,n]=e;return Ep(t,n)}function r0(e){return e}function i0(e){let[t,n]=e;return Ep(t,n)}function o0(e){return vE(e[1])}function s0(e){return e[1]}function a0(e){return xi(e[0],e[2])}function l0(e){return u.IsEqual(e.length,4)?ka(e[1],e[3]):u.IsEqual(e.length,2)?ka(e[1],dt()):go()}function u0(e){return e}function d0(e){return`${e}`}function c0(e){return e}function m0(e){return e}function f0(e){return It(e[3])?Ci:_e(e[3])?fs:yr(e[3])?Xn:ct(e[3])?Xn:go()}function p0(e){return e}function h0(e){return e.length>0}function g0(e){return e.length>0}function y0(e){let[t,n,r,i,o]=e;return{[n]:t&&r?hr(fr(o)):t&&!r?hr(o):!t&&r?fr(o):o}}function x0(e){return e}function I0(e){return Gr(e)}function S0(e){return e.reduce((t,n)=>u.HasPropertyKey(n,Ci)||u.HasPropertyKey(n,fs)||u.HasPropertyKey(n,Xn)?[t[0],C.Assign(t[1],n)]:[C.Assign(t[0],n),t[1]],[{},{}])}function b0(e){return S0(e[1])}function C0(e){let[t,n]=e,r=u.IsEqual(u.Keys(n).length,0)?{}:{patternProperties:n};return q(t,r)}function E0(e){return u.IsEqual(e.length,5)?hr(fr(e[4])):u.IsEqual(e.length,3)?e[2]:u.IsEqual(e.length,4)?u.IsEqual(e[2],"readonly")?hr(e[3]):fr(e[3]):go()}function v0(e){if(!u.IsArray(e)||!u.IsEqual(e.length,3))return e;let[t,n,r]=e;return t&&r?hr(fr(n)):t&&!r?hr(n):!t&&r?fr(n):n}function T0(e){return u.IsEqual(e.length,2)?ho(e[1]):u.IsEqual(e.length,1)?e[0]:go()}function k0(e){return Gr(e)}function w0(e){return We(e[1])}function L0(e){return hr(fr(e[4]))}function R0(e){return hr(e[3])}function A0(e){return fr(e[3])}function P0(e){return e[2]}function $0(e){return e}function M0(e){return u.IsEqual(e.length,2)?ho(e[1]):u.IsEqual(e.length,1)?e[0]:go()}function O0(e){return Gr(e)}function F0(e){return mr(e[1],e[4])}function N0(e){return cr(e[2],e[5])}function cC(e,t){return u.IsEqual(e,"remove")?Gb(t):u.IsEqual(e,"add")?hr(t):t}function D0(e){return u.IsEqual(e.length,2)&&u.IsEqual(e[0],"-")?"remove":u.IsEqual(e.length,2)&&u.IsEqual(e[0],"+")?"add":u.IsEqual(e.length,1)?"add":"none"}function mC(e,t){return u.IsEqual(e,"remove")?zb(t):u.IsEqual(e,"add")?fr(t):t}function H0(e){return u.IsEqual(e.length,2)&&u.IsEqual(e[0],"-")?"remove":u.IsEqual(e.length,2)&&u.IsEqual(e[0],"+")?"add":u.IsEqual(e.length,1)?"add":"none"}function _0(e){return u.IsEqual(e.length,2)?[e[1]]:[]}function U0(e){return u.IsArray(e[6])&&u.IsEqual(e[6].length,1)?Fa(La(e[3]),e[5],e[6][0],cC(e[1],mC(e[8],e[10]))):Fa(La(e[3]),e[5],pt(e[3]),cC(e[1],mC(e[8],e[10])))}function B0(e){return pt(e)}function G0(e){return BigInt(e)}function j0(e){return parseFloat(e)}function q0(e){return u.IsEqual(e,"true")}function z0(e){return e}function K0(e){return null}function V0(e){return}function W0(e){return{[e[0]]:e[2]}}function X0(e){return Gr(e)}function TU(e){return e.reduce((t,n)=>C.Assign(t,n),{})}function Y0(e){return TU(e[1])}function J0(e){return Gr(e)}function Z0(e){return e[1]}function Q0(e){return e}function eE(e){return wa()}function tE(e){return Vt()}function nE(e){return hn()}function rE(e){return mo()}function iE(e){return be()}function oE(e){return ne(e)}function sE(e){return e}function aE(e){return J(e[1])}function lE(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function uE(e){return[e[0],...e[1]]}function dE(e){return e}function cE(e){return e[1]}function mE(e){return Gr(e)}function fE(e){return u.IsEqual(e.length,2)?e[1]:[]}function pE(e){let t=e[2],n=e[3],[r,i]=e[4],o=u.IsEqual(u.Keys(i).length,0)?{}:{patternProperties:i};return{[e[1]]:xi(t,Na(n,r,o))}}function hE(e){let t=e[2],[n,r]=e[3],i=u.IsEqual(u.Keys(r).length,0)?{}:{patternProperties:r};return{[e[1]]:Na(t,n,i)}}function gE(e){return{[e[1]]:xi(e[2],e[4])}}function yE(e){return{[e[1]]:e[3]}}function xE(e){return null}function IE(e){return e}function SE(e){return Gr(e)}function bE(e){return e[1]}function CE(e){let[t,n]=[e[0],e[1]];return kE(C.Assign(t,S0(n)[0]))}function EE(e){return e}function Ua(e){return se(e.length,2)}function ue(e,t,n){return Ua(e)?t(e[0],e[1]):n()}function LU(e,t){return se(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function qe(e,t){for(let n=0;n<e.length;n++){let r=LU(e[n],t);if(Ua(r))return r}return[]}function vp(e,t){return Array.from({length:t-e+1},(n,r)=>String.fromCharCode(e+r))}var wE=[...vp(97,122),...vp(65,90)],Tp="0",kp=vp(49,57),gs=[Tp,...kp],LE=" ",ys=`
|
|
1525
|
-
`;var
|
|
1526
|
-
`,n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f(f(
|
|
1527
|
-
`,n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f(f(
|
|
1528
|
-
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))))),([t,n])=>[
|
|
1529
|
-
`,n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f(f(
|
|
1530
|
-
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[IE(t),n]),Cv=(e,t=[])=>f(f(bv(e),([n,r])=>f(Np(r),([i,o])=>[[n,i],o])),([n,r])=>Cv(r,[...t,n]),()=>[t,e]),kB=(e)=>f(f(f(Np(e),([t,n])=>f(Cv(n),([r,i])=>f(f(bv(i),([o,s])=>[[o],s],()=>[[],i]),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[SE(t),n]),Np=(e)=>f(f(TB(e),([t,n])=>f(f(bB(n),([r,i])=>[r,i],()=>f(CB(n),([r,i])=>[r,i],()=>f(EB(n),([r,i])=>[r,i],()=>f(vB(n),([r,i])=>[r,i],()=>[])))),([r,i])=>f(VE(i),([o,s])=>[[t,r,o],s]))),([t,n])=>[bE(t),n]),wB=(e)=>f(f(Np(e),([t,n])=>f(kB(n),([r,i])=>[[t,r],i])),([t,n])=>[CE(t),n]),Ev=(e)=>f(f(wB(e),([t,n])=>[t,n],()=>f(F2(e),([t,n])=>[t,n],()=>f(me(e),([t,n])=>[t,n],()=>[]))),([t,n])=>[EE(t),n]);function vv(e){let t=$p(`\`${e}\``);return u.IsEqual(t.length,2)?t[0]:Ve()}function RB(e){return e.join("|")}function AB(e){return e.slice(1,e.length-1)}function PB(e,t,n){return wi(t,`${n}${e}`)}function $B(e,t){return wi(e,`${t}${vb}`)}function MB(e,t){return wi(e,`${t}${Hd}`)}function OB(e,t){return wi(e,`${t}${Gd}`)}function FB(e,t){return Ba(J([ne("false"),ne("true")]),e,t)}function NB(e,t){return wi(e,`${t}${jd}`)}function DB(e,t,n){return wi(t,`${n}${AB(e)}`)}function HB(e,t,n){let r=Ga(e,{});return Ba(r,t,n)}function _B(e,t,n){let r=Wt(e);return Ba(r,t,n)}function Tv(e,t,n,r=[]){return u.ShiftLeft(e,(i,o)=>Tv(o,t,n,[...r,Ba(i,[],"")]),()=>wi(t,`${n}(${RB(r)})`))}function Ba(e,t,n){return st(e)?_B(e.enum,t,n):It(e)?MB(t,n):ae(e)?PB(e.const,t,n):pn(e)?$B(t,n):Kt(e)?FB(t,n):_e(e)?OB(t,n):ct(e)?NB(t,n):Le(e)?DB(e.pattern,t,n):wv(e)?HB(e.parameters[0],t,n):F(e)?Tv(e.anyOf,t,n):ZS}function wi(e,t){return u.ShiftLeft(e,(n,r)=>Ba(n,r,t),()=>t)}function UB(e){return`^${wi(e,"")}$`}function kv(e){let t=UB(e);return zd(t)}function Ga(e,t){return te(e)?C.Update(kv(e),{},t):Qd(e,t)}function Lv(e,t,n,r){let i=vn(e,t,n);return Ga(i,r)}function Qd(e,t={}){return U("TemplateLiteral",[e],t)}function wv(e){return Ge(e)&&u.HasPropertyKey(e,"action")&&u.IsEqual(e.action,"TemplateLiteral")}function Rv(e){return Ga(e,{})}function BB(e){let t=vv(e);return Rv(t)}function Av(e,t={}){let n=u.IsString(e)?BB(e):Rv(e);return C.Update(n,{},t)}function Le(e){return _(e,"TemplateLiteral")}var W={};Ut(W,{ExtendsFalse:()=>Z,ExtendsTrue:()=>H,ExtendsUnion:()=>Dp,IsExtendsFalse:()=>GB,IsExtendsTrue:()=>$v,IsExtendsTrueLike:()=>Is,IsExtendsUnion:()=>Pv,Match:()=>Fe});function Dp(e){return C.Create({["~kind"]:"ExtendsUnion"},{inferred:e})}function Pv(e){return u.IsObject(e)&&u.HasPropertyKey(e,"~kind")&&u.HasPropertyKey(e,"inferred")&&u.IsEqual(e["~kind"],"ExtendsUnion")&&u.IsObject(e.inferred)}function H(e){return C.Create({["~kind"]:"ExtendsTrue"},{inferred:e})}function $v(e){return u.IsObject(e)&&u.HasPropertyKey(e,"~kind")&&u.HasPropertyKey(e,"inferred")&&u.IsEqual(e["~kind"],"ExtendsTrue")&&u.IsObject(e.inferred)}function Z(){return C.Create({["~kind"]:"ExtendsFalse"},{})}function GB(e){return u.IsObject(e)&&u.HasPropertyKey(e,"~kind")&&u.IsEqual(e["~kind"],"ExtendsFalse")}function Is(e){return Pv(e)||$v(e)}function Fe(e,t,n){return Is(e)?t(e.inferred):n()}function jB(e,t,n,r){return Fe(de(e,n,r),(i)=>H(C.Assign(C.Assign(e,i),{[t]:n})),()=>Z())}function qB(e,t){return H(e)}function zB(e,t,n,r,i){return Fe(de(e,t,n),(o)=>Fe(de(o,t,r),(s)=>H(s),()=>Z()),()=>Fe(de(e,t,i),(o)=>H(o),()=>Z()))}function KB(e,t,n){let r=Wt(n);return de(e,t,r)}function Mv(e,t,n){return u.ShiftLeft(n,(r,i)=>Fe(de(e,t,r),(o)=>Mv(o,t,i),()=>Z()),()=>H(e))}function VB(e,t,n){let r=Nt(n);return de(e,t,r)}function Ov(e,t,n){return u.ShiftLeft(n,(r,i)=>Fe(de(e,t,r),(o)=>H(o),()=>Ov(e,t,i)),()=>Z())}function ge(e,t,n){return je(n)?qB(e,t):Ke(n)?zB(e,t,n.if,n.then,n.else):st(n)?KB(e,t,n.enum):ot(n)?jB(e,n.name,t,n.extends):z(n)?Mv(e,t,n.allOf):Le(n)?VB(e,t,n.pattern):F(n)?Ov(e,t,n.anyOf):it(n)?H(e):Z()}function Fv(e,t,n){return ot(n)?ge(e,t,n):je(n)?H(e):it(n)?H(e):Dp(e)}function WB(e,t){let n=lo(e),r=lo(t);return n&&r?!0:!n&&r?!0:n&&!r?!1:!0}function Nv(e,t,n,r){return le(r)?WB(t,r)?de(e,n,r.items):Z():ge(e,t,r)}function Dv(e,t,n){return pn(n)?H(e):ge(e,t,n)}function Hv(e,t,n){return Kt(n)?H(e):ge(e,t,n)}function XB(e,t,n,r,i){let o=ot(r)?t:r,s=ot(r)?r:t,a=ht(t),l=ht(r);return!a&&l?Z():Fe(de(e,o,s),(d)=>ja(d,n,i),()=>Z())}function YB(e,t,n,r){return u.ShiftLeft(r,(i,o)=>XB(e,t,n,i,o),()=>ht(t)?H(e):Z())}function JB(e,t,n){return u.ShiftLeft(t,(r,i)=>YB(e,r,i,n),()=>H(e))}function ja(e,t,n){return JB(e,t,n)}function wc(e,t,n){return gn(n)?H(e):de(e,t,n)}function _v(e,t,n,r){return je(r)?H(e):it(r)?H(e):nt(r)?Fe(ja(e,t,r.parameters),(i)=>wc(i,n,r.instanceType),()=>Z()):Z()}function Uv(e,t,n,r,i){return Fe(de(e,t,i),()=>de(e,n,i),()=>de(e,r,i))}function Bv(e,t,n){let r=Wt(t);return de(e,r,n)}function Gv(e,t,n,r){return je(r)?H(e):it(r)?H(e):rt(r)?Fe(ja(e,t,r.parameters),(i)=>wc(i,n,r.returnType),()=>Z()):Z()}function jv(e,t,n){return It(n)?H(e):_e(n)?H(e):ge(e,t,n)}function qv(e,t,n){let r=Ue(t);return de(e,r,n)}function Lc(e,t,n){return t===n?H(e):Z()}function ZB(e,t,n){return ae(n)?Lc(e,t,n.const):pn(n)?H(e):ge(e,ne(t),n)}function QB(e,t,n){return ae(n)?Lc(e,t,n.const):Kt(n)?H(e):ge(e,ne(t),n)}function eG(e,t,n){return ae(n)?Lc(e,t,n.const):_e(n)?H(e):ge(e,ne(t),n)}function tG(e,t,n){return ae(n)?Lc(e,t,n.const):ct(n)?H(e):ge(e,ne(t),n)}function zv(e,t,n){return u.IsBigInt(t.const)?ZB(e,t.const,n):u.IsBoolean(t.const)?QB(e,t.const,n):u.IsNumber(t.const)?eG(e,t.const,n):u.IsString(t.const)?tG(e,t.const,n):Ve()}function Kv(e,t,n){return ot(n)?ge(e,t,n):H(e)}function Vv(e,t,n){return gr(n)?H(e):ge(e,t,n)}function Wv(e,t,n){return _e(n)?H(e):ge(e,t,n)}function nG(e,t,n){return ht(t)?ht(n)?H(e):Z():H(e)}function rG(e,t,n){return ot(n)&&fn(n.extends)?Z():Fe(de(e,t,n),(r)=>nG(r,t,n),()=>Z())}function iG(e,t){return e.reduce((n,r)=>(r in t)?Is(t[r])?{...n,...t[r].inferred}:Ve():Ve(),{})}function oG(e,t,n){let r={};for(let s of u.Keys(n))r[s]=s in t?rG({},t[s],n[s]):ht(n[s])?ot(n[s])?H(C.Assign(e,{[n[s].name]:n[s].extends})):H(e):Z();let i=u.Values(r).every((s)=>Is(s)),o=i?iG(u.Keys(r),r):{};return i?H(o):Z()}function sG(e,t,n){let r=oG(e,t,n);return Is(r)?H(C.Assign(e,r.inferred)):Z()}function aG(e,t,n){return sG(e,t,n)}function lG(e,t){return u.Keys(t).reduce((n,r)=>({...n,[r]:u.HasPropertyKey(e,r)?F(n[r])?J([...n[r].anyOf,t[r]]):J([e[r],t[r]]):t[r]}),e)}function Xv(e,t,n,r){return u.ShiftLeft(t,(i,o)=>Fe(de({},e[i],n),(s)=>Xv(e,o,n,lG(r,s)),()=>Z()),()=>H(r))}function uG(e,t,n,r){let i=u.Keys(t);return Xv(t,i,r,e)}function Yv(e,t,n){return Se(n)?uG(e,t,St(n),Ae(n)):V(n)?aG(e,t,n.properties):ge(e,q(t),n)}function dG(e,t){return u.IsEqual(u.Keys(t).length,0)?H(e):Z()}function cG(e,t,n,r,i){return de(e,n,i)}function Jv(e,t,n,r){return Se(r)?cG(e,Xd(t),n,Xd(St(r)),Ae(r)):V(r)?dG(e,r.properties):je(r)?H(e):it(r)?H(e):Z()}function Zv(e,t,n){return ct(n)?H(e):ge(e,t,n)}function Qv(e,t,n){return yr(n)?H(e):ge(e,t,n)}function eT(e,t,n){let r=Nt(t);return de(e,r,n)}function Hp(e,t){return C.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function qa(e){return u.IsObject(e)&&u.HasPropertyKey(e,"~kind")&&u.HasPropertyKey(e,"name")&&u.HasPropertyKey(e,"type")&&u.IsEqual(e["~kind"],"Inferrable")&&u.IsString(e.name)&&u.IsObject(e.type)}function _p(e){return vi(e)?ot(e.items)?le(e.items.extends)?Hp(e.items.name,e.items.extends.items):it(e.items.extends)?Hp(e.items.name,e.items.extends):void 0:Ve():void 0}function Rc(e){return ot(e)?Hp(e.name,e.extends):void 0}function Up(e,t,n=[]){return u.ShiftLeft(e,(r,i)=>Fe(de({},r,t),()=>Up(i,t,[...n,r]),()=>{return}),()=>n)}function tT(e,t,n,r){let i=Up(n,r);return u.IsArray(i)?H(C.Assign(e,{[t]:We(i)})):Z()}function Ac(e,t,n,r){let i=Up(n,r);return u.IsArray(i)?H(C.Assign(e,{[t]:J(i)})):Z()}function mG(e){return[...e].reverse()}function Bp(e,t){return t?mG(e):e}function fG(e){let t=e.length>0?e[0]:void 0,n=Ge(t)?_p(t):void 0;return Ge(n)}function pG(e,t,n,r,i,o){return Fe(de(e,n,i),(s)=>nT(s,t,r,o),()=>Z())}function hG(e,t,n,r,i){let o=_p(r);return qa(o)?tT(e,o.name,Bp(n,t),o.type):u.ShiftLeft(n,(s,a)=>pG(e,t,s,a,r,i),()=>Z())}function gG(e,t,n,r){return u.ShiftLeft(r,(i,o)=>hG(e,t,n,i,o),()=>u.IsEqual(n.length,0)?H(e):Z())}function nT(e,t,n,r){return gG(e,t,n,r)}function yG(e,t,n){let r=Li(e,Pe([],[]),n),i=fG(r);return nT(e,i,Bp(t,i),Bp(r,i))}function rT(e,t,n){let r=Rc(n);return qa(r)?Ac(e,r.name,t,r.type):u.ShiftLeft(t,(i,o)=>Fe(de(e,i,n),(s)=>rT(s,o,n),()=>Z()),()=>H(e))}function iT(e,t,n){let r=Li(e,Pe([],[]),t);return re(n)?yG(e,r,n.items):le(n)?rT(e,r,n.items):ge(e,We(r),n)}function oT(e,t,n){return gn(n)?H(e):Jn(n)?H(e):ge(e,t,n)}function sT(e,t,n){return u.ShiftLeft(n,(r,i)=>Fe(de(e,t,r),(o)=>H(o),()=>sT(e,t,i)),()=>Z())}function Gp(e,t,n){return u.ShiftLeft(t,(r,i)=>Fe(sT(e,r,n),(o)=>Gp(o,i,n),()=>Z()),()=>H(e))}function aT(e,t,n){let r=Rc(n);return qa(r)?Ac(e,r.name,t,r.type):F(n)?Gp(e,t,n.anyOf):Gp(e,t,[n])}function lT(e,t,n){return ot(n)?ge(e,t,n):je(n)?H(e):it(n)?H(e):Z()}function uT(e,t,n){return gn(n)?H(e):ge(e,t,n)}function de(e,t,n){return je(t)?Fv(e,t,n):le(t)?Nv(e,t,t.items,n):pn(t)?Dv(e,t,n):Kt(t)?Hv(e,t,n):nt(t)?_v(e,t.parameters,t.instanceType,n):Ke(t)?Uv(e,t.if,t.then,t.else,n):st(t)?Bv(e,t.enum,n):rt(t)?Gv(e,t.parameters,t.returnType,n):It(t)?jv(e,t,n):z(t)?qv(e,t.allOf,n):ae(t)?zv(e,t,n):fn(t)?Kv(e,t,n):gr(t)?Vv(e,t,n):_e(t)?Wv(e,t,n):V(t)?Yv(e,t.properties,n):Se(t)?Jv(e,St(t),Ae(t),n):ct(t)?Zv(e,t,n):yr(t)?Qv(e,t,n):Le(t)?eT(e,t.pattern,n):re(t)?iT(e,t.items,n):Jn(t)?oT(e,t,n):F(t)?aT(e,t.anyOf,n):it(t)?lT(e,t,n):gn(t)?uT(e,t,n):Z()}function xG(e,t){return Ue([...e,q(t)])}function jp(e,t,n){return te(e)?C.Update(xG(e,t),{},n):Na(e,t,n)}function dT(e,t,n,r,i){let o=vn(e,t,n),s=za(e,t,r);return jp(o,s,i)}function Na(e,t,n={}){return U("Interface",[e,t],n)}function Ss(e){return Ge(e)&&u.HasPropertyKey(e,"action")&&u.IsEqual(e.action,"Interface")}function cT(e,t,n={}){return jp(e,t,n)}function IG(e,t,n){return e.includes(n)?!0:Ka([...e,n],t,t[n])}function mT(e,t,n){let r=Pd(n);return yo(e,t,r)}function yo(e,t,n){return u.ShiftLeft(n,(r,i)=>Ka(e,t,r)?!0:yo(e,t,i),()=>!1)}function Ka(e,t,n){return xe(n)?IG(e,t,n.$ref):le(n)?Ka(e,t,n.items):nt(n)?yo(e,t,[...n.parameters,n.instanceType]):rt(n)?yo(e,t,[...n.parameters,n.returnType]):Ss(n)?mT(e,t,n.parameters[1]):z(n)?yo(e,t,n.allOf):V(n)?mT(e,t,n.properties):F(n)?yo(e,t,n.anyOf):re(n)?yo(e,t,n.items):Se(n)?Ka(e,t,Ae(n)):!1}function fT(e,t,n){return Ka(e,t,n)}function SG(e,t){return t.reduce((n,r)=>fT([r],e,e[r])?[...n,r]:n,[])}function pT(e){let t=Ad(e);return SG(e,t)}function bG(e,t,n){return n.includes(t)?n:(t in e)?Va(e,e[t],[...n,t]):Ve()}function hT(e,t,n){let r=Pd(t);return bs(e,r,n)}function bs(e,t,n){return t.reduce((r,i)=>Va(e,i,r),n)}function Va(e,t,n){return xe(t)?bG(e,t.$ref,n):le(t)?Va(e,t.items,n):nt(t)?bs(e,[...t.parameters,t.instanceType],n):rt(t)?bs(e,[...t.parameters,t.returnType],n):Ss(t)?hT(e,t.parameters[1],n):z(t)?bs(e,t.allOf,n):V(t)?hT(e,t.properties,n):F(t)?bs(e,t.anyOf,n):re(t)?bs(e,t.items,n):Se(t)?Va(e,Ae(t),n):n}function gT(e,t,n){return Va(e,n,[t])}function CG(e){return ss()}function EG(e){return u.Keys(e).reduce((t,n)=>({...t,[n]:xo(e[n])}),{})}function Wa(e){return e.reduce((t,n)=>[...t,xo(n)],[])}function xo(e){return xe(e)?CG(e.$ref):le(e)?tn(xo(e.items),is(e)):nt(e)?cr(Wa(e.parameters),xo(e.instanceType)):rt(e)?mr(Wa(e.parameters),xo(e.returnType)):z(e)?Ft(Wa(e.allOf)):V(e)?q(EG(e.properties)):Se(e)?ps(Ei(e),xo(Ae(e))):F(e)?J(Wa(e.anyOf)):re(e)?We(Wa(e.items)):e}function vG(e,t){return t in e?xo(e[t]):dt()}function yT(e){return vG(e.$defs,e.$ref)}function TG(e,t,n){let r=vn(e,Pe([],[]),t),i=za({},Pe([],[]),n);return Ue([...r,q(i)])}function kG(e,t){return u.Keys(e).filter((r)=>t.includes(r)).reduce((r,i)=>{let o=e[i],s=Ss(o)?TG(e,o.parameters[0],o.parameters[1]):o;return{...r,[i]:s}},{})}function xT(e,t,n){let r=gT(e,t,n),i=kG(e,r);return pr(i,t)}function IT(e,t){return t in e?xe(e[t])?IT(e,e[t].$ref):e[t]:be()}function xr(e,t){return IT(e,t)}function ST(e){return ke(e)?yT(e):$d(e)?dt():e}function Pt(e,t,n){let r=ST(t),i=ST(n);return de(e,r,i)}var Pa=0,Xa=1,$a=2,Ma=3;function ms(e,t){let n=[Pt({},e,t),Pt({},t,e)];return W.IsExtendsTrueLike(n[0])&&W.IsExtendsTrueLike(n[1])?Pa:W.IsExtendsTrueLike(n[0])&&W.IsExtendsFalse(n[1])?$a:W.IsExtendsFalse(n[0])&&W.IsExtendsTrueLike(n[1])?Ma:Xa}function qp(e,t,n=[],r=t){return u.ShiftLeft(t,(i,o)=>{let s=ms(e,i);return u.IsEqual(s,$a)||u.IsEqual(s,Pa)?r:u.IsEqual(s,Xa)?qp(e,o,[...n,i],r):qp(e,o,n,r)},()=>[...n,e])}function wG(e,t,n){let r=Fn(e);return je(r)?[r]:it(r)?[r]:fn(r)?Pc(t,n):V(r)?Pc(t,[...n,r]):Pc(t,qp(r,n))}function Pc(e,t=[]){return u.ShiftLeft(e,(n,r)=>wG(n,r,t),()=>t)}function bp(e){let t=Pc(e);return po(t)}function zp(e,t){return C.Update(Fn(e),{},t)}function bT(e,t,n,r){let i=M(e,t,n);return zp(i,r)}function Ya(e,t=[]){return yi(e)&&u.IsEqual(e.action,"Conditional")?xe(e.parameters[0])?Ya(e.parameters[2],Ya(e.parameters[3],[...t,e.parameters[0].$ref])):Ya(e.parameters[2],Ya(e.parameters[3],t)):yi(e)&&u.IsEqual(e.action,"Mapped")?yi(e.parameters[1])&&u.IsEqual(e.parameters[1].action,"KeyOf")&&xe(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t:t}function LG(e,t){return e.reduce((n,r)=>[...n,t.includes(r.name)],[])}function vT(e,t,n=[]){return u.ShiftLeft(e,(r,i)=>u.ShiftLeft(t,(o,s)=>vT(i,s,[...n,[o,r]]),()=>n),()=>n)}function RG(e){return Le(e)?Nt(e.pattern):st(e)?Wt(e.enum):e}function AG(e){let t=RG(e);return F(t)?[...t.anyOf]:[t]}function PG(e,t){return e.reduce((n,r)=>[...n,[...r,t]],[])}function CT(e,t){return t.reduce((n,r)=>[...n,...PG(e,r)],[])}function ET(e){return e.reduce((t,n)=>u.IsEqual(n[0],!0)?CT(t,AG(n[1])):CT(t,[n[1]]),[[]])}function TT(e,t,n){let r=Ya(n),i=LG(e,r),o=vT(t,i);return yi(n)&&u.IsEqual(n.action,"Conditional")?ET(o):yi(n)&&u.IsEqual(n.action,"Mapped")?ET(o):[t]}function $G(){return["(not-resolvable)",be()]}function MG(){return["(not-generic)",be()]}function OG(e,t,n){return[e,xi(t,n)]}function FG(e,t,n){return t in e?kT(e,t,e[t],n):$G()}function kT(e,t,n,r){return os(n)?OG(t,n.parameters,n.expression):xe(n)?FG(e,n.$ref,r):MG()}function wT(e,t,n){return kT(e,"(anonymous)",t,n)}function NG(e,t,n){if(ot(t)||Cs(t)||W.IsExtendsTrueLike(Pt({},t,n)))return;let r={parameter:e,expect:n,actual:t};throw Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:r})}function LT(e,t,n,r,i){let o=M(e,t,i);return NG(n,o,r),C.Assign(e,{[n]:o})}function DG(e,t,n,r,i){let o=M(e,t,n.extends),s=M(e,t,n.equals);return u.ShiftLeft(i,(a,l)=>Kp(LT(e,t,n.name,o,a),t,r,l),()=>Kp(LT(e,t,n.name,o,s),t,r,[]))}function Kp(e,t,n,r){return u.ShiftLeft(n,(i,o)=>DG(e,t,i,o,r),()=>e)}function RT(e,t,n,r){return Kp(e,t,n,r)}var Vp=0,Wp=0;function HG(){if(u.IsLessThan(Wp,He.Get().maxInstantiationCount))return;throw Error("Type instantiation is excessively deep and possibly infinite")}function _G(){HG(),Wp++,Vp++}function UG(){if(Vp--,u.IsEqual(Vp,0))Wp=0}function BG(e){return u.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function GG(e,t){return u.IsEqual(BG(e),t)}function jG(e,t,n,r,i,o){_G();try{let s=RT(e,t,r,o),a=M(s,Pe([...t.callstack,n.$ref],t.visited),i);return M(s,Pe([],[]),a)}finally{UG()}}function qG(e,t,n,r,i,o){return o.reduce((s,a)=>{let l=jG(e,t,n,r,i,a);return[...s,l]},[])}function zG(e,t,n,r,i,o){let s=TT(r,o,i),a=qG(e,t,n,r,i,s);return u.IsEqual(a.length,1)?a[0]:rn(a)}function $c(e,t,n,r){let i=vn(e,t,r),o=wT(e,n,r),s=o[0],a=o[1];return os(a)?GG(t,s)?Da(pt(s),i):zG(e,t,pt(s),a.parameters,a.expression,i):Da(n,i)}function Da(e,t){return C.Create({["~kind"]:"Call"},{type:"call",target:e,arguments:t},{})}function AT(e,t){return $c({},Pe([],[]),e,t)}function Cs(e){return _(e,"Call")}function KG(e){return C.Discard(e,["~immutable"])}function PT(e,t){return C.Update(KG(e),{},t)}function $T(e,t,n,r){let i=M(e,t,n);return PT(i,r)}function MT(e,t){return e(t)}function OT(e,t){return u.IsString(t)?ne(MT(e,t)):ne(t)}function FT(e,t){let n=Nt(t);return jr(e,n)}function NT(e,t){let n=t.map((r)=>jr(e,r));return J(n)}function jr(e,t){return ae(t)?OT(e,t.const):Le(t)?FT(e,t.pattern):F(t)?NT(e,t.anyOf):t}function ec(e,t={}){return U("Capitalize",[e],t)}function DT(e,t={}){return Xp(e,t)}function tc(e,t={}){return U("Lowercase",[e],t)}function HT(e,t={}){return Yp(e,t)}function nc(e,t={}){return U("Uncapitalize",[e],t)}function _T(e,t={}){return Jp(e,t)}function rc(e,t={}){return U("Uppercase",[e],t)}function UT(e,t={}){return Zp(e,t)}var VG=(e)=>e[0].toUpperCase()+e.slice(1),WG=(e)=>e.toLowerCase(),XG=(e)=>e[0].toLowerCase()+e.slice(1),YG=(e)=>e.toUpperCase();function Xp(e,t){return te([e])?C.Update(jr(VG,e),{},t):ec(e,t)}function Yp(e,t){return te([e])?C.Update(jr(WG,e),{},t):tc(e,t)}function Jp(e,t){return te([e])?C.Update(jr(XG,e),{},t):nc(e,t)}function Zp(e,t){return te([e])?C.Update(jr(YG,e),{},t):rc(e,t)}function BT(e,t,n,r){let i=M(e,t,n);return Xp(i,r)}function GT(e,t,n,r){let i=M(e,t,n);return Yp(i,r)}function jT(e,t,n,r){let i=M(e,t,n);return Jp(i,r)}function qT(e,t,n,r){let i=M(e,t,n);return Zp(i,r)}function ic(e,t,n,r,i={}){return U("Conditional",[e,t,n,r],i)}function zT(e,t,n,r,i={}){return Qp({},Pe([],[]),e,t,n,r,i)}function JG(e,t,n,r,i,o){let s=Pt(e,n,r);return W.IsExtendsUnion(s)?J([M(s.inferred,t,i),M(e,t,o)]):W.IsExtendsTrue(s)?M(s.inferred,t,i):M(e,t,o)}function Qp(e,t,n,r,i,o,s){return te([n,r])?C.Update(JG(e,t,n,r,i,o),{},s):ic(n,r,i,o,s)}function KT(e,t,n,r,i,o,s){let a=M(e,t,n),l=M(e,t,r);return Qp(e,t,a,l,i,o,s)}function oc(e,t={}){return U("ConstructorParameters",[e],t)}function VT(e,t={}){return eh(e,t)}function ZG(e){let t=nt(e)?e.parameters:[],n=Li({},Pe([],[]),t);return We(n)}function eh(e,t){return te([e])?C.Update(ZG(e),{},t):oc(e,t)}function WT(e,t,n,r){let i=M(e,t,n);return eh(i,r)}function sc(e,t,n={}){return U("Exclude",[e,t],n)}function XT(e,t,n={}){return Ja(e,t,n)}function Ja(e,t,n){return te([e,t])?C.Update(Vd(e,t),{},n):sc(e,t,n)}function YT(e,t,n,r,i){let o=M(e,t,n),s=M(e,t,r);return Ja(o,s,i)}function ac(e,t,n={}){return U("Extract",[e,t],n)}function JT(e,t,n={}){return th(e,t,n)}function QG(e,t){let n=Pt({},e,t);return W.IsExtendsTrueLike(n)?[e]:[]}function ZT(e,t,n=[]){return u.ShiftLeft(e,(r,i)=>ZT(i,t,[...n,...QG(r,t)]),()=>n)}function QT(e,t){let n=Fn(e),r=F(n)?n.anyOf:[n],i=ZT(r,t);return rn(i)}function th(e,t,n){return te([e,t])?C.Update(QT(e,t),{},n):ac(e,t,n)}function ek(e,t,n,r,i){let o=M(e,t,n),s=M(e,t,r);return th(o,s,i)}function ej(e){return e.reduce((t,n)=>_d(n)?[...t,ne(n)]:t,[])}function Es(e){let t=ej(e);return J(t)}function Ha(e,t,n={}){return U("Index",[e,t],n)}function tk(e,t,n={}){let r=u.IsArray(t)?Es(t):t;return nh(e,r,n)}function nk(e,t){let n=xr(e,t);return Tn(n)}function rk(e,t,n){let r=Yn(e,t,n);return Tn(r)}function tj(e,t){let n=u.Keys(e).filter((c)=>!u.HasPropertyKey(t,c)),r=u.Keys(t).filter((c)=>!u.HasPropertyKey(e,c)),i=u.Keys(e).filter((c)=>u.HasPropertyKey(t,c)),o=n.reduce((c,m)=>({...c,[m]:e[m]}),{}),s=r.reduce((c,m)=>({...c,[m]:t[m]}),{}),a=i.reduce((c,m)=>({...c,[m]:Ue([e[m],t[m]])}),{}),l=C.Assign(o,s);return C.Assign(l,a)}function ik(e){return e.reduce((t,n)=>tj(t,Tn(n)),{})}function ok(e){return e}function sk(e){let t=Kb(We(e));return Tn(t)}function nj(e,t){return u.Keys(e).filter((i)=>(i in t)).reduce((i,o)=>({...i,[o]:rn([e[o],t[o]])}),{})}function ak(e,t){return u.ShiftLeft(e,(n,r)=>ak(r,nj(t,Tn(n))),()=>t)}function lk(e){return u.ShiftLeft(e,(t,n)=>ak(n,Tn(t)),()=>Ve())}function Tn(e){return ke(e)?nk(e.$defs,e.$ref):Ke(e)?rk(e.if,e.then,e.else):z(e)?ik(e.allOf):F(e)?lk(e.anyOf):re(e)?sk(e.items):V(e)?ok(e.properties):{}}function vs(e){let t=Tn(e);return q(t)}var rj=new RegExp("^(?:0|[1-9][0-9]*)$");function Ts(e){let t=`${e}`;return rj.test(t)?parseInt(t):e}function ij(e){return ne(Ts(e))}function uk(e){return e.map((t)=>dk(t))}function dk(e){return z(e)?Ft(uk(e.allOf)):F(e)?J(uk(e.anyOf)):ae(e)?ij(e.const):e}function ck(e,t){let n=dk(t),r=Pt({},n,hn());return W.IsExtendsTrueLike(r)?e:ae(t)&&u.IsEqual(t.const,"length")?hn():be()}function mk(e,t){let n=xr(e,t);return yn(n)}function fk(e,t,n){let r=Yn(e,t,n);return yn(r)}function pk(e){let t=Wt(e);return yn(t)}function hk(e){let t=Ue(e);return yn(t)}function gk(e){return[`${e}`]}function yk(e){let t=Nt(e);return yn(t)}function xk(e){return e.reduce((t,n)=>[...t,...yn(n)],[])}function yn(e){return ke(e)?mk(e.$defs,e.$ref):Ke(e)?fk(e.if,e.then,e.else):st(e)?pk(e.enum):z(e)?hk(e.allOf):ae(e)?gk(e.const):Le(e)?yk(e.pattern):F(e)?xk(e.anyOf):[]}function ks(e){return yn(e)}function Za(e,t){return t.map((n)=>Qa(e,n))}function Qa(e,t){return le(t)?tn(Qa(e,t.items)):nt(t)?cr(Za(e,t.parameters),Qa(e,t.instanceType)):rt(t)?mr(Za(e,t.parameters),Qa(e,t.returnType)):re(t)?We(Za(e,t.items)):F(t)?J(Za(e,t.anyOf)):z(t)?Ft(Za(e,t.allOf)):Jd(t)?q(e):t}function Ik(e,t){return Qa(e,t)}function oj(e,t){let n=t in e?e[t]:be();return Ik(e,n)}function Sk(e,t){return t.reduce((n,r)=>[...n,oj(e,r)],[])}function sj(e,t){let n=ks(t),r=Sk(e,n);return rn(r)}var aj=new RegExp(Ci);function lj(e){return e.filter((n)=>aj.test(n))}function uj(e){let t=Ad(e),n=lj(t),r=Sk(e,n);return rn(r)}function bk(e,t){return _e(t)?uj(e):sj(e,t)}function dj(e){return ne(Ts(e))}function Ck(e){return e.map((t)=>rh(t))}function rh(e){return z(e)?Ft(Ck(e.allOf)):F(e)?J(Ck(e.anyOf)):ae(e)?dj(e.const):e}function cj(e,t){return e.reduceRight((n,r,i)=>{let o=Pt({},ne(i),t);return W.IsExtendsTrueLike(o)?[r,...n]:n},[])}function mj(e,t){let n=rh(t),r=cj(e,n);return Si(r)}function fj(e){return Si(e)}function Ek(e,t){return ae(t)&&u.IsEqual(t.const,"length")?ne(e.length):_e(t)||It(t)?fj(e):mj(e,t)}function vk(e,t){return le(e)?ck(e.items,t):V(e)?bk(e.properties,t):re(e)?Ek(e.items,t):be()}function pj(e){return ke(e)||Ke(e)||z(e)||F(e)?vs(e):e}function nh(e,t,n){return te([e,t])?C.Update(vk(pj(e),t),{},n):Ha(e,t,n)}function Tk(e,t,n,r,i){let o=M(e,t,n),s=M(e,t,r);return nh(o,s,i)}function lc(e,t={}){return U("InstanceType",[e],t)}function kk(e,t={}){return ih(e,t)}function hj(e){return nt(e)?e.instanceType:be()}function ih(e,t){return te([e])?C.Update(hj(e),{},t):lc(e,t)}function wk(e,t,n,r={}){let i=M(e,t,n);return ih(i,r)}function _a(e,t={}){return U("KeyOf",[e],t)}function Lk(e,t={}){return oh(e,t)}function Rk(){return J([hn(),Vt(),cs()])}function Ak(e){return hn()}function gj(e){return e.reduce((n,r)=>_d(r)?[...n,ne(Ts(r))]:Ve(),[])}function Pk(e){let t=u.Keys(e),n=gj(t);return Si(n)}function $k(e){return Ei(e)}function Mk(e){let t=e.map((n,r)=>ne(r));return Si(t)}function Ok(e){return je(e)?Rk():le(e)?Ak(e.items):V(e)?Pk(e.properties):Se(e)?$k(e):re(e)?Mk(e.items):be()}function yj(e){return ke(e)||Ke(e)||z(e)||F(e)?vs(e):e}function oh(e,t){return te([e])?C.Update(Ok(yj(e)),{},t):_a(e,t)}function Fk(e,t,n,r){let i=M(e,t,n);return oh(i,r)}function Fa(e,t,n,r,i={}){return U("Mapped",[e,t,n,r],i)}function Nk(e,t,n,r,i={}){return sh({},Pe([],[]),e,t,n,r,i)}function xj(e){let t=Nt(e);return Mc(t)}function Ij(e){return e.reduce((t,n)=>[...t,...Mc(n)],[])}function Sj(e){let t=Wt(e);return Mc(t)}function bj(e){return u.IsNumber(e)?[ne(`${e}`)]:[ne(e)]}function Mc(e){return st(e)?Sj(e.enum):ae(e)?bj(e.const):Le(e)?xj(e.pattern):F(e)?Ij(e.anyOf):[e]}function Dk(e){return Mc(e)}function Cj(e){return Le(e)?Nt(e.pattern):e}function Ej(e,t,n,r,i,o){let s=C.Assign(e,{[n.name]:r}),a=M(s,t,i),l=Cj(a),d=M(s,t,o);return Ud(l)||Bd(l)?{[l.const]:d}:{}}function vj(e,t,n,r,i,o){return r.reduce((s,a)=>[...s,Ej(e,t,n,a,i,o)],[])}function Tj(e){return e.reduce((t,n)=>[...t,q(n)],[])}function Hk(e,t,n,r,i,o){let s=Dk(r),a=vj(e,t,n,s,i,o),l=Tj(a);return Ue(l)}function sh(e,t,n,r,i,o,s){return te([r])?C.Update(Hk(e,t,n,r,i,o),{},s):Fa(n,r,i,o,s)}function _k(e,t,n,r,i,o,s){let a=M(e,t,r);return sh(e,t,n,a,i,o,s)}function kj(e,t,n){let r=C.Assign(e,t);return u.Keys(t).filter((o)=>n.includes(o)).reduce((o,s)=>({...o,[s]:xT(r,s,t[s])}),{})}function wj(e,t,n){let r=C.Assign(e,t);return u.Keys(t).filter((o)=>!n.includes(o)).reduce((o,s)=>({...o,[s]:M(r,Pe([],[]),t[s])}),{})}function Lj(e,t,n){let r=pT(t),i=kj(e,t,r),o=wj(e,t,r),s={...i,...o};return C.Update(s,{},n)}function Oc(e,t,n,r){return Lj(e,n,r)}function uc(e,t={}){return U("NonNullable",[e],t)}function Uk(e,t={}){return ah(e,t)}function Rj(e){let t=J([ds(),hs()]);return Ja(e,t,{})}function ah(e,t){return te([e])?C.Update(Rj(e),{},t):uc(e,t)}function Bk(e,t,n,r){let i=M(e,t,n);return ah(i,r)}function dc(e,t,n={}){return U("Omit",[e,t],n)}function Gk(e,t,n={}){let r=u.IsArray(t)?Es(t):t;return lh(e,r,n)}function Fc(e){let t=vs(e);return V(t)?t.properties:Ve()}function Aj(e,t){return u.Keys(e).reduce((r,i)=>t.includes(i)?r:{...r,[i]:e[i]},{})}function jk(e,t){let n=Fc(e),r=ks(t),i=Aj(n,r);return q(i)}function lh(e,t,n){return te([e,t])?C.Update(jk(e,t),{},n):dc(e,t,n)}function qk(e,t,n,r,i){let o=M(e,t,n),s=M(e,t,r);return lh(o,s,i)}function cc(e,t={}){return U("Parameters",[e],t)}function zk(e,t={}){return uh(e,t)}function Pj(e){let t=rt(e)?e.parameters:[],n=Li({},Pe([],[]),t);return We(n)}function uh(e,t){return te([e])?C.Update(Pj(e),{},t):cc(e,t)}function Kk(e,t,n,r){let i=M(e,t,n);return uh(i,r)}function mc(e,t={}){return U("Partial",[e],t)}function Vk(e,t={}){return dh(e,t)}function Wk(e,t){let n=xr(e,t),r=Ir(n);return pr(C.Assign(e,{[t]:r}),t)}function Xk(e,t,n){let r=Yn(e,t,n);return Ir(r)}function Yk(e){let t=Ue(e);return Ir(t)}function Jk(e){let t=e.map((n)=>Ir(n));return J(t)}function Zk(e){let t=u.Keys(e).reduce((r,i)=>({...r,[i]:so(e[i])}),{});return q(t)}function Ir(e){return ke(e)?Wk(e.$defs,e.$ref):Ke(e)?Xk(e.if,e.then,e.else):z(e)?Yk(e.allOf):F(e)?Jk(e.anyOf):V(e)?Zk(e.properties):q({})}function dh(e,t){return te([e])?C.Update(Ir(e),{},t):mc(e,t)}function Qk(e,t,n,r){let i=M(e,t,n);return dh(i,r)}function fc(e,t,n={}){return U("Pick",[e,t],n)}function ew(e,t,n={}){let r=u.IsArray(t)?Es(t):t;return ch(e,r,n)}function $j(e,t){return u.Keys(e).reduce((r,i)=>t.includes(i)?C.Assign(r,{[i]:e[i]}):r,{})}function tw(e,t){let n=Fc(e),r=ks(t),i=$j(n,r);return q(i)}function ch(e,t,n){return te([e,t])?C.Update(tw(e,t),{},n):fc(e,t,n)}function nw(e,t,n,r,i){let o=M(e,t,n),s=M(e,t,r);return ch(o,s,i)}function pc(e,t={}){return U("ReadonlyObject",[e],t)}function mh(e,t={}){return fh(e,t)}var rw=mh;function iw(e){return us(tn(e))}function ow(e,t){let n=xr(e,t),r=Sr(n);return pr(C.Assign(e,{[t]:r}),t)}function sw(e,t,n){let r=Yn(e,t,n);return Sr(r)}function aw(e){let t=Ue(e);return Sr(t)}function lw(e){let t=u.Keys(e).reduce((r,i)=>({...r,[i]:uo(e[i])}),{});return q(t)}function uw(e){return us(We(e))}function dw(e){let t=e.map((n)=>Sr(n));return J(t)}function Sr(e){return le(e)?iw(e.items):ke(e)?ow(e.$defs,e.$ref):Ke(e)?sw(e.if,e.then,e.else):z(e)?aw(e.allOf):V(e)?lw(e.properties):re(e)?uw(e.items):F(e)?dw(e.anyOf):e}function fh(e,t){return te([e])?C.Update(Sr(e),{},t):pc(e)}function cw(e,t,n,r){let i=M(e,t,n);return fh(i,r)}function mw(e,t,n,r){return t.visited.includes(r)?n:(r in e)?M(e,Pe(t.callstack,[...t.visited,r]),e[r]):n}function fw(e,t){let n=xr(e,t),r=br(n);return pr(C.Assign(e,{[t]:r}),t)}function pw(e,t,n){let r=Yn(e,t,n);return br(r)}function hw(e){let t=Ue(e);return br(t)}function gw(e){let t=e.map((n)=>br(n));return J(t)}function yw(e){let t=u.Keys(e).reduce((r,i)=>({...r,[i]:Kd(e[i])}),{});return q(t)}function br(e){return ke(e)?fw(e.$defs,e.$ref):Ke(e)?pw(e.if,e.then,e.else):z(e)?hw(e.allOf):F(e)?gw(e.anyOf):V(e)?yw(e.properties):q({})}function hc(e,t={}){return U("Required",[e],t)}function xw(e,t={}){return ph(e,t)}function ph(e,t){return te([e])?C.Update(br(e),{},t):hc(e,t)}function Iw(e,t,n,r){let i=M(e,t,n);return ph(i,r)}function gc(e,t={}){return U("ReturnType",[e],t)}function Sw(e,t={}){return hh(e,t)}function Mj(e){return rt(e)?e.returnType:be()}function hh(e,t){return te([e])?C.Update(Mj(e),{},t):gc(e,t)}function bw(e,t,n,r={}){let i=M(e,t,n);return hh(i,r)}function yc(e,t){return U("With",[e,t],{})}function Nc(e,t){return gh(e,t)}function gh(e,t){return te([e])?C.Update(e,{},t):yc(e,t)}function Cw(e,t,n,r){let i=M(e,t,n);return gh(i,r)}function Oj(e){return vi(e)?re(e.items)?yh(e.items.items):ot(e.items)?[e]:xe(e.items)?[e]:[be()]:[e]}function yh(e){return e.reduce((n,r)=>[...n,...Oj(r)],[])}function Pe(e,t){return{callstack:e,visited:t}}function te(e){return u.ShiftLeft(e,(t,n)=>xe(t)?!1:te(n),()=>!0)}function za(e,t,n){return u.Keys(n).reduce((r,i)=>({...r,[i]:M(e,t,n[i])}),{})}function Li(e,t,n){let r=vn(e,t,n);return yh(r)}function vn(e,t,n){return n.map((r)=>M(e,t,r))}function Fj(e,t){let n=ht(e)?Ta(t,{}):t,r=co(e)?va(n,{}):n;return lo(e)?el(r,{}):r}function Nj(e,t,n,r,i){return u.IsEqual(n,"AddImmutable")?Ew(e,t,r[0],i):u.IsEqual(n,"RemoveImmutable")?$T(e,t,r[0],i):u.IsEqual(n,"AddReadonly")?WS(e,t,r[0],i):u.IsEqual(n,"RemoveReadonly")?Bb(e,t,r[0],i):u.IsEqual(n,"AddOptional")?XS(e,t,r[0],i):u.IsEqual(n,"RemoveOptional")?qb(e,t,r[0],i):u.IsEqual(n,"Capitalize")?BT(e,t,r[0],i):u.IsEqual(n,"Conditional")?KT(e,t,r[0],r[1],r[2],r[3],i):u.IsEqual(n,"ConstructorParameters")?WT(e,t,r[0],i):u.IsEqual(n,"Evaluate")?bT(e,t,r[0],i):u.IsEqual(n,"Exclude")?YT(e,t,r[0],r[1],i):u.IsEqual(n,"Extract")?ek(e,t,r[0],r[1],i):u.IsEqual(n,"Index")?Tk(e,t,r[0],r[1],i):u.IsEqual(n,"InstanceType")?wk(e,t,r[0],i):u.IsEqual(n,"Interface")?dT(e,t,r[0],r[1],i):u.IsEqual(n,"KeyOf")?Fk(e,t,r[0],i):u.IsEqual(n,"Lowercase")?GT(e,t,r[0],i):u.IsEqual(n,"Mapped")?_k(e,t,r[0],r[1],r[2],r[3],i):u.IsEqual(n,"Module")?Oc(e,t,r[0],i):u.IsEqual(n,"NonNullable")?Bk(e,t,r[0],i):u.IsEqual(n,"Pick")?nw(e,t,r[0],r[1],i):u.IsEqual(n,"Parameters")?Kk(e,t,r[0],i):u.IsEqual(n,"Partial")?Qk(e,t,r[0],i):u.IsEqual(n,"Omit")?qk(e,t,r[0],r[1],i):u.IsEqual(n,"ReadonlyObject")?cw(e,t,r[0],i):u.IsEqual(n,"Record")?aC(e,t,r[0],r[1],i):u.IsEqual(n,"Required")?Iw(e,t,r[0],i):u.IsEqual(n,"ReturnType")?bw(e,t,r[0],i):u.IsEqual(n,"TemplateLiteral")?Lv(e,t,r[0],i):u.IsEqual(n,"Uncapitalize")?jT(e,t,r[0],i):u.IsEqual(n,"Uppercase")?qT(e,t,r[0],i):u.IsEqual(n,"With")?Cw(e,t,r[0],r[1]):U(n,r,i)}function Dj(e,t,n){let r=xe(n)?mw(e,t,n,n.$ref):le(n)?tn(M(e,t,n.items),is(n)):Cs(n)?$c(e,t,n.target,n.arguments):nt(n)?cr(vn(e,t,n.parameters),M(e,t,n.instanceType),YS(n)):rt(n)?mr(vn(e,t,n.parameters),M(e,t,n.returnType),JS(n)):Ke(n)?ao(M(e,t,n.if),M(e,t,n.then),M(e,t,n.else),rb(n)):z(n)?Ft(vn(e,t,n.allOf),lb(n)):V(n)?q(za(e,t,n.properties),tb(n)):Se(n)?lC(St(n),M(e,t,Ae(n))):vi(n)?ho(M(e,t,n.items)):re(n)?We(Li(e,t,n.items),Ub(n)):F(n)?J(vn(e,t,n.anyOf),Ab(n)):n;return Fj(n,r)}function M(e,t,n){return yi(n)?Nj(e,t,n.action,n.parameters,n.options):Dj(e,t,n)}function Nn(e,t){return M(e,Pe([],[]),t)}function Hj(e){return C.Update(e,{"~immutable":!0},{})}function el(e,t){return C.Update(Hj(e),{},t)}function Ew(e,t,n,r){let i=M(e,t,n);return el(i,r)}function vE(e,t={}){return U("AddImmutable",[e],t)}function us(e,t={}){return el(e,t)}function TE(e,t={}){return U("Evaluate",[e],t)}function $t(e,t={}){return zp(e,t)}function kE(e,t={}){return U("Module",[e],t)}function vw(e,t={}){return Oc({},Pe([],[]),e,t)}function _j(e,t){let n=ms(e,t);return u.IsEqual(n,Ma)?1:u.IsEqual(n,Xa)?1:0}function Tw(e,t,n=[]){return u.ShiftLeft(t,(r,i)=>u.IsEqual(_j(e,r),1)?Tw(e,i,[...n,r]):[...n,e,...t],()=>[...n,e])}function kw(e,t=[]){return u.ShiftLeft(e,(n,r)=>kw(r,Tw(n,t)),()=>t)}function ww(e){return kw(e)}function Lw(...e){let[t,n,r]=ee.Match(e,{2:(s,a)=>u.IsString(s)?[{},s,a]:[s,a,{}],3:(s,a,l)=>[s,a,l],1:(s)=>[{},s,{}]}),i=Ev(n),o=u.IsArray(i)&&u.IsEqual(i.length,2)?M(t,Pe([],[]),i[0]):be();return C.Update(o,{},r)}var Dc={};Ut(Dc,{Any:()=>ss,Array:()=>tn,BigInt:()=>wa,Boolean:()=>Dd,Call:()=>AT,Capitalize:()=>DT,Codec:()=>Fd,Conditional:()=>zT,Constructor:()=>cr,ConstructorParameters:()=>VT,Cyclic:()=>pr,Decode:()=>Ib,DecodeBuilder:()=>Od,Dependent:()=>ao,Encode:()=>Sb,EncodeBuilder:()=>Md,Enum:()=>ab,Evaluate:()=>$t,Exclude:()=>XT,Extends:()=>Pt,ExtendsResult:()=>W,Extract:()=>JT,Function:()=>mr,Generic:()=>xi,Identifier:()=>La,Immutable:()=>bb,Index:()=>tk,Infer:()=>ka,InstanceType:()=>kk,Instantiate:()=>Nn,Integer:()=>mo,Interface:()=>cT,Intersect:()=>Ft,IsAny:()=>je,IsArray:()=>le,IsBigInt:()=>pn,IsBoolean:()=>Kt,IsCall:()=>Cs,IsCodec:()=>zt,IsConstructor:()=>nt,IsCyclic:()=>ke,IsDependent:()=>Ke,IsEnum:()=>st,IsEnumValue:()=>sb,IsFunction:()=>rt,IsGeneric:()=>os,IsIdentifier:()=>Tb,IsImmutable:()=>lo,IsInfer:()=>ot,IsInteger:()=>It,IsIntersect:()=>z,IsKind:()=>_,IsLiteral:()=>ae,IsNever:()=>fn,IsNull:()=>gr,IsNumber:()=>_e,IsObject:()=>V,IsOptional:()=>ht,IsParameter:()=>Rb,IsReadonly:()=>co,IsRecord:()=>Se,IsRef:()=>xe,IsRefine:()=>Nd,IsRest:()=>vi,IsSchema:()=>Ge,IsString:()=>ct,IsSymbol:()=>yr,IsTemplateLiteral:()=>Le,IsThis:()=>Jd,IsTuple:()=>re,IsUndefined:()=>Jn,IsUnion:()=>F,IsUnknown:()=>it,IsUnsafe:()=>$d,IsVoid:()=>gn,KeyOf:()=>Lk,Literal:()=>ne,Lowercase:()=>HT,Mapped:()=>Nk,Module:()=>vw,Never:()=>be,NonNullable:()=>Uk,Null:()=>ds,Number:()=>hn,Object:()=>q,Omit:()=>Gk,Optional:()=>QS,Parameter:()=>fo,Parameters:()=>zk,Partial:()=>Vk,Pick:()=>ew,Readonly:()=>Cb,ReadonlyObject:()=>mh,ReadonlyType:()=>rw,Record:()=>ps,RecordKey:()=>Ei,RecordPattern:()=>St,RecordValue:()=>Ae,Ref:()=>pt,Refine:()=>Eb,Required:()=>xw,Rest:()=>ho,ReturnType:()=>Sw,Script:()=>Lw,String:()=>Vt,Symbol:()=>cs,TemplateLiteral:()=>Av,This:()=>Yd,Tuple:()=>We,Uncapitalize:()=>_T,Undefined:()=>hs,Union:()=>J,Unknown:()=>dt,Unsafe:()=>nb,Uppercase:()=>UT,Void:()=>Zd,With:()=>Nc});var Hc=Dc;function tl(e){return u.HasPropertyKey(e,"~refine")&&u.IsArray(e["~refine"])&&u.Every(e["~refine"],0,(t)=>u.IsObject(t)&&u.HasPropertyKey(t,"check")&&u.HasPropertyKey(t,"error")&&u.IsFunction(t.check)&&u.IsFunction(t.error))}function Rt(e){return u.IsObject(e)&&!u.IsArray(e)}function Ri(e){return u.IsBoolean(e)}function Y(e){return Rt(e)||Ri(e)}function ws(e){return u.HasPropertyKey(e,"additionalItems")&&Y(e.additionalItems)}function Dn(e){return u.HasPropertyKey(e,"additionalProperties")&&Y(e.additionalProperties)}function nl(e){return u.HasPropertyKey(e,"allOf")&&u.IsArray(e.allOf)&&e.allOf.every((t)=>Y(t))}function Rw(e){return u.HasPropertyKey(e,"$anchor")&&u.IsString(e.$anchor)}function rl(e){return u.HasPropertyKey(e,"anyOf")&&u.IsArray(e.anyOf)&&e.anyOf.every((t)=>Y(t))}function _c(e){return u.HasPropertyKey(e,"const")}function Cr(e){return u.HasPropertyKey(e,"contains")&&Y(e.contains)}function kn(e){return u.HasPropertyKey(e,"default")}function il(e){return u.HasPropertyKey(e,"dependencies")&&u.IsObject(e.dependencies)&&Object.values(e.dependencies).every((t)=>Y(t)||u.IsArray(t)&&t.every((n)=>u.IsString(n)))}function ol(e){return u.HasPropertyKey(e,"dependentRequired")&&u.IsObject(e.dependentRequired)&&Object.values(e.dependentRequired).every((t)=>u.IsArray(t)&&t.every((n)=>u.IsString(n)))}function Ls(e){return u.HasPropertyKey(e,"dependentSchemas")&&u.IsObject(e.dependentSchemas)&&Object.values(e.dependentSchemas).every((t)=>Y(t))}function Ai(e){return u.HasPropertyKey(e,"$dynamicAnchor")&&u.IsString(e.$dynamicAnchor)}function sl(e){return u.HasPropertyKey(e,"$dynamicRef")&&u.IsString(e.$dynamicRef)}function al(e){return u.HasPropertyKey(e,"else")&&Y(e.else)}function Uc(e){return u.HasPropertyKey(e,"enum")&&u.IsArray(e.enum)}function ll(e){return u.HasPropertyKey(e,"exclusiveMaximum")&&(u.IsNumber(e.exclusiveMaximum)||u.IsBigInt(e.exclusiveMaximum))}function Zn(e){return u.HasPropertyKey(e,"exclusiveMinimum")&&(u.IsNumber(e.exclusiveMinimum)||u.IsBigInt(e.exclusiveMinimum))}function Io(e){return u.HasPropertyKey(e,"format")&&u.IsString(e.format)}function Xt(e){return u.HasPropertyKey(e,"$id")&&u.IsString(e.$id)}function ul(e){return u.HasPropertyKey(e,"if")&&Y(e.if)}function qr(e){return u.HasPropertyKey(e,"items")&&(Y(e.items)||u.IsArray(e.items)&&e.items.every((t)=>Y(t)))}function dl(e){return qr(e)&&u.IsArray(e.items)}function cl(e){return u.HasPropertyKey(e,"maximum")&&(u.IsNumber(e.maximum)||u.IsBigInt(e.maximum))}function ml(e){return u.HasPropertyKey(e,"maxContains")&&u.IsNumber(e.maxContains)}function Rs(e){return u.HasPropertyKey(e,"maxItems")&&u.IsNumber(e.maxItems)}function fl(e){return u.HasPropertyKey(e,"maxLength")&&u.IsNumber(e.maxLength)}function pl(e){return u.HasPropertyKey(e,"maxProperties")&&u.IsNumber(e.maxProperties)}function Qn(e){return u.HasPropertyKey(e,"minimum")&&(u.IsNumber(e.minimum)||u.IsBigInt(e.minimum))}function zr(e){return u.HasPropertyKey(e,"minContains")&&u.IsNumber(e.minContains)}function Pi(e){return u.HasPropertyKey(e,"minItems")&&u.IsNumber(e.minItems)}function So(e){return u.HasPropertyKey(e,"minLength")&&u.IsNumber(e.minLength)}function bo(e){return u.HasPropertyKey(e,"minProperties")&&u.IsNumber(e.minProperties)}function hl(e){return u.HasPropertyKey(e,"multipleOf")&&(u.IsNumber(e.multipleOf)||u.IsBigInt(e.multipleOf))}function gl(e){return u.HasPropertyKey(e,"not")&&Y(e.not)}function yl(e){return u.HasPropertyKey(e,"oneOf")&&u.IsArray(e.oneOf)&&e.oneOf.every((t)=>Y(t))}function Co(e){return u.HasPropertyKey(e,"pattern")&&(u.IsString(e.pattern)||e.pattern instanceof RegExp)}function Kr(e){return u.HasPropertyKey(e,"patternProperties")&&u.IsObject(e.patternProperties)&&Object.values(e.patternProperties).every((t)=>Y(t))}function er(e){return u.HasPropertyKey(e,"prefixItems")&&u.IsArray(e.prefixItems)&&e.prefixItems.every((t)=>Y(t))}function Vr(e){return u.HasPropertyKey(e,"properties")&&u.IsObject(e.properties)&&Object.values(e.properties).every((t)=>Y(t))}function As(e){return u.HasPropertyKey(e,"propertyNames")&&(u.IsObject(e.propertyNames)||Y(e.propertyNames))}function Uj(e){return u.HasPropertyKey(e,"$recursiveAnchor")&&u.IsBoolean(e.$recursiveAnchor)}function xl(e){return Uj(e)&&u.IsEqual(e.$recursiveAnchor,!0)}function Il(e){return u.HasPropertyKey(e,"$recursiveRef")&&u.IsString(e.$recursiveRef)}function Sl(e){return u.HasPropertyKey(e,"$ref")&&u.IsString(e.$ref)}function tr(e){return u.HasPropertyKey(e,"required")&&u.IsArray(e.required)&&e.required.every((t)=>u.IsString(t))}function bl(e){return u.HasPropertyKey(e,"then")&&Y(e.then)}function Cl(e){return u.HasPropertyKey(e,"type")&&(u.IsString(e.type)||u.IsArray(e.type)&&e.type.every((t)=>u.IsString(t)))}function $i(e){return u.HasPropertyKey(e,"uniqueItems")&&u.IsBoolean(e.uniqueItems)}function Mi(e){return u.HasPropertyKey(e,"unevaluatedItems")&&Y(e.unevaluatedItems)}function Oi(e){return u.HasPropertyKey(e,"unevaluatedProperties")&&Y(e.unevaluatedProperties)}function Bj(e){return Mi(e)||Oi(e)||u.Some(u.Keys(e),(t)=>Bc(e[t]))}function Gj(e){return u.Some(e,(t)=>Bc(t))}function Bc(e){return u.IsArray(e)?Gj(e):u.IsObject(e)?Bj(e):!1}function Aw(e,t){return Bc(t)||u.Some(u.Keys(e),(n)=>Bc(e[n]))}class xh{constructor(e){this.hasUnevaluated=e}UseUnevaluated(){return this.hasUnevaluated}Push(){return y.Call(y.Member("context","Push"),[])}Pop(){return y.Call(y.Member("context","Pop"),[])}AddIndex(e){return y.Call(y.Member("context","AddIndex"),[e])}AddKey(e){return y.Call(y.Member("context","AddKey"),[e])}Merge(e){return y.Call(y.Member("context","Merge"),[e])}}class Ht{constructor(){let e=new Set,t=new Set;this.stack=[{indices:e,keys:t}]}Push(){let e=new Set,t=new Set;return this.stack.push({indices:e,keys:t}),!0}Pop(){return this.stack.pop(),!0}AddIndex(e){return this.GetIndices().add(e),!0}AddKey(e){return this.GetKeys().add(e),!0}GetIndices(){return this.stack[this.stack.length-1].indices}GetKeys(){return this.stack[this.stack.length-1].keys}Merge(e){for(let t of e)t.GetIndices().forEach((n)=>this.GetIndices().add(n)),t.GetKeys().forEach((n)=>this.GetKeys().add(n));return!0}}class _t extends Ht{constructor(){super();this.errors=[]}AtCapacity(){return this.errors.length>=He.Get().maxErrors}AddError(e,t,n,r){return this.AddErrorObject({keyword:e,schemaPath:t,instancePath:n,params:r})}AddErrors(e){return e.forEach((t)=>this.AddErrorObject(t)),!1}GetErrors(){return this.errors}AddErrorObject(e){if(!this.AtCapacity())this.errors.push(e);return!1}}var Gc={identifier:"External",variables:[]};function Hn(e){let t=`External[${Gc.variables.length}]`;return Gc.variables.push(e),t}function Pw(){Gc.variables=[]}function $w(){return{...Gc}}function Mw(e,t,n,r){let i=Hn(n["~refine"].map((o)=>o));return y.Every(i,y.Constant(0),["refinement","_"],y.Call(y.Member("refinement","check"),[r]))}function Ow(e,t,n,r){return u.Every(n["~refine"],0,(i,o)=>i.check(r))}function Fw(e,t,n,r,i,o){return u.EveryAll(i["~refine"],0,(s,a)=>s.check(o)||t.AddError("~refine",n,r,{index:a,message:s.error(o)}))}var El="urn:typebox:root";function Wr(e,t){return URL.canParse(e,t)?new URL(e,t):u.IsEqual(t,El)?new URL(`${t}:${e}`):new URL(`${t.slice(0,t.lastIndexOf(":"))}:${e}`)}function Fi(e,t){let n=Rt(t)&&Xt(t)?Wr(t.$id,El).href:El;return{context:e,schema:t,lexicalSchema:t,lexicalBase:n,resourceBase:n,referenceBase:n,ids:[],useResourceBaseForReference:!0,recursiveAnchor:void 0,dynamicAnchors:[],resourceEntries:new Map,pendingResource:!0,enteredResource:!1}}function Ih(e,t,n=!0){if(Ri(t))return e;if(Array.isArray(t))return t.reduce((i,o)=>Ih(i,o,!1),e);if(!Rt(t))return e;if(!n&&Xt(t))return e;let r=!n&&Ai(t)?[...e,t]:e;return Object.keys(t).reduce((i,o)=>Ih(i,t[o],!1),r)}function vl(e,t){return e.resourceEntries.get(t)}function Nw(e,t){return e.enteredResource||vl(e,t)!==void 0}function jj(e){return!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e.$id)}function qj(e,t){return Xt(t)?[...e.ids,t]:e.ids}function zj(e,t){return e.recursiveAnchor??(xl(t)?t:void 0)}function Kj(e,t){let n=Xt(t)?Ih(e.dynamicAnchors,t):e.dynamicAnchors;return Ai(t)?[...n,t]:n}function Vj(e,t){return Xt(t)?!1:e.pendingResource}function Dw(e,t){let n=vl(e,t);if(n)return n.base;return Xt(t)?Wr(t.$id,e.lexicalBase).href:e.lexicalBase}function Hw(e,t){let n=vl(e,t);if(n)return n.base;return Xt(t)&&e.pendingResource?Wr(t.$id,e.resourceBase).href:e.resourceBase}function _w(e,t){return Xt(t)?!jj(t):e.useResourceBaseForReference}function Wj(e,t){let n=Nw(e,t),r=_w(e,t);return n||r?Hw(e,t):Dw(e,t)}function Xj(e,t){let n=vl(e,t);if(n)return n.root;return Xt(t)?t:e.lexicalSchema}function Yj(e,t){return Rt(t)&&(Xt(t)||Ai(t)||u.IsUndefined(e.recursiveAnchor)&&xl(t)||!u.IsUndefined(vl(e,t)))}function Eo(e,t){return Yj(e,t)?{...e,ids:qj(e,t),dynamicAnchors:Kj(e,t),recursiveAnchor:zj(e,t),pendingResource:Vj(e,t),lexicalBase:Dw(e,t),resourceBase:Hw(e,t),useResourceBaseForReference:_w(e,t),referenceBase:Wj(e,t),lexicalSchema:Xj(e,t),enteredResource:Nw(e,t)}:e}var Jj=0;function Ce(){return`var_${Jj++}`}function bh(e){return qr(e)&&u.IsArray(e.items)}function Zj(e,t,n,r){let[i,o]=[Ce(),Ce()],s=Yt(e,t,n.additionalItems,i),a=y.IsLessThan(o,y.Constant(n.items.length)),l=t.AddIndex(o);return y.Every(r,y.Constant(0),[i,o],y.Or(a,y.And(s,l)))}function Qj(e,t,n,r){let[i,o]=[Ce(),Ce()],s=Yt(e,t,n.additionalItems,i),a=y.IsLessThan(o,y.Constant(n.items.length));return y.Every(r,y.Constant(0),[i,o],y.Or(a,s))}function Uw(e,t,n,r){if(!bh(n))return y.Constant(!0);return t.UseUnevaluated()?Zj(e,t,n,r):Qj(e,t,n,r)}function Bw(e,t,n,r){if(!bh(n))return!0;return u.Every(r,0,(o,s)=>u.IsLessThan(s,n.items.length)||wn(e,t,n.additionalItems,o)&&t.AddIndex(s))}function Gw(e,t,n,r,i,o){if(!bh(i))return!0;return u.Every(o,0,(a,l)=>{let d=`${n}/additionalItems`,c=`${r}/${l}`;return u.IsLessThan(l,i.items.length)||Ln(e,t,d,c,i.additionalItems,a)&&t.AddIndex(l)})}function nr(e){return new RegExp(e,"u")}function eq(e,t){return!e.UseUnevaluated()&&(u.IsEqual(t,!0)||u.IsObject(t)&&u.IsEqual(u.Keys(t).length,0))}function tq(e){return`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`}function Ch(e){let t=[];if(Kr(e))t.push(...u.Keys(e.patternProperties));if(Vr(e))t.push(...u.Keys(e.properties).map(tq));return u.IsEqual(t.length,0)?"(?!)":`(${t.join("|")})`}function nq(e,t,n){return tr(t)&&Vr(t)&&!Kr(t)&&u.IsEqual(t.additionalProperties,!1)&&u.IsEqual(u.Keys(t.properties).length,t.required.length)}function rq(e,t,n){return y.IsEqual(y.Member(y.Call(y.Member("Object","getOwnPropertyNames"),[n]),"length"),y.Constant(t.required.length))}function iq(e,t,n,r){let[i,o]=[Ce(),Ce()],s=Hn(nr(Ch(n))),a=Yt(e,t,n.additionalProperties,`${r}[${i}]`),l=y.Call(y.Member(s,"test"),[i]),d=t.AddKey(i),c=t.UseUnevaluated()?y.Or(l,y.And(a,d)):y.Or(l,a);return y.Every(y.Keys(r),y.Constant(0),[i,o],c)}function jw(e,t,n,r){if(eq(t,n.additionalProperties))return y.Constant(!0);return nq(t,n,r)?rq(t,n,r):iq(e,t,n,r)}function qw(e,t,n,r){let i=nr(Ch(n));return u.Every(u.Keys(r),0,(s,a)=>i.test(s)||wn(e,t,n.additionalProperties,r[s])&&t.AddKey(s))}function zw(e,t,n,r,i,o){let s=nr(Ch(i)),a=[];return u.EveryAll(u.Keys(o),0,(d,c)=>{let m=`${n}/additionalProperties`,p=`${r}/${d}`,h=s.test(d)||Ln(e,t,m,p,i.additionalProperties,o[d])&&t.AddKey(d);if(!h)a.push(d);return h})||t.AddError("additionalProperties",n,r,{additionalProperties:a})}function Ni(e,t,n,r,i){let o=y.ConstDeclaration("results","[]"),s=n.map((c,m)=>y.ConstDeclaration(`context_${m}`,y.New("CheckContext",[]))),a=n.map((c,m)=>y.ConstDeclaration(`condition_${m}`,y.Call(y.ArrowFunction(["context"],he(e,t,c,r)),[`context_${m}`]))),l=n.map((c,m)=>y.If(`condition_${m}`,y.Call(y.Member("results","push"),[`context_${m}`]))),d=y.Return(y.And(i,t.Merge("results")));return y.Call(y.ArrowFunction([],y.Statements([o,...s,...a,...l,d])),[])}function oq(e,t,n,r){return Ni(e,t,n.allOf,r,y.IsEqual(y.Member("results","length"),y.Constant(n.allOf.length)))}function sq(e,t,n,r){return y.ReduceAnd(n.allOf.map((i)=>he(e,t,i,r)))}function Kw(e,t,n,r){return t.UseUnevaluated()?oq(e,t,n,r):sq(e,t,n,r)}function Vw(e,t,n,r){let i=n.allOf.reduce((o,s)=>{let a=new Ht;return ce(e,a,s,r)?[...o,a]:o},[]);return u.IsEqual(i.length,n.allOf.length)&&t.Merge(i)}function Ww(e,t,n,r,i,o){let s=[],a=i.allOf.reduce((d,c,m)=>{let p=`${n}/allOf/${m}`,h=new _t,x=Re(e,h,p,r,c,o);if(!x)s.push(h);return x?[...d,h]:d},[]),l=u.IsEqual(a.length,i.allOf.length)&&t.Merge(a);if(!l)s.forEach((d)=>t.AddErrors(d.GetErrors()));return l}function aq(e,t,n,r){return Ni(e,t,n.anyOf,r,y.IsGreaterThan(y.Member("results","length"),y.Constant(0)))}function lq(e,t,n,r){return y.ReduceOr(n.anyOf.map((i)=>he(e,t,i,r)))}function Xw(e,t,n,r){return t.UseUnevaluated()?aq(e,t,n,r):lq(e,t,n,r)}function Yw(e,t,n,r){let i=n.anyOf.reduce((o,s)=>{let a=new Ht;return ce(e,a,s,r)?[...o,a]:o},[]);return u.IsGreaterThan(i.length,0)&&t.Merge(i)}function Jw(e,t,n,r,i,o){let s=[],a=i.anyOf.reduce((d,c,m)=>{let p=new _t,h=`${n}/anyOf/${m}`,x=Re(e,p,h,r,c,o);if(!x)s.push(p);return x?[...d,p]:d},[]),l=u.IsGreaterThan(a.length,0)&&t.Merge(a);if(!l)s.forEach((d)=>t.AddErrors(d.GetErrors()));return l||t.AddError("anyOf",n,r,{})}function Zw(e,t,n,r){return n?y.Constant(!0):y.Constant(!1)}function Eh(e,t,n,r){return n}function Qw(e,t,n,r,i,o){return Eh(e,t,i,o)||t.AddError("boolean",n,r,{})}function eL(e,t,n,r){return u.IsValueLike(n.const)?y.IsEqual(r,y.Constant(n.const)):y.IsDeepEqual(r,Hn(n.const))}function vh(e,t,n,r){return u.IsValueLike(n.const)?u.IsEqual(r,n.const):u.IsDeepEqual(r,n.const)}function tL(e,t,n,r,i,o){return vh(e,t,i,o)||t.AddError("const",n,r,{allowedValue:i.const})}function nL(e){return!(zr(e)&&u.IsEqual(e.minContains,0))}function uq(e,t,n,r){let[i,o]=[Ce(),Ce()],s=y.Not(y.IsEqual(y.Member(r,"length"),y.Constant(0))),a=y.SomeAll(r,[i,o],y.And(he(e,t,n.contains,i),t.AddIndex(o)));return y.And(s,a)}function dq(e,t,n,r){let[i]=[Ce()],o=y.Not(y.IsEqual(y.Member(r,"length"),y.Constant(0))),s=y.Some(r,[i,"_"],he(e,t,n.contains,i));return y.And(o,s)}function rL(e,t,n,r){if(!nL(n))return y.Constant(!0);return t.UseUnevaluated()?uq(e,t,n,r):dq(e,t,n,r)}function Th(e,t,n,r){if(!nL(n))return!0;return!u.IsEqual(r.length,0)&&u.SomeAll(r,(i,o)=>ce(e,t,n.contains,i)&&t.AddIndex(o))}function iL(e,t,n,r,i,o){return Th(e,t,i,o)||t.AddError("contains",n,r,{minContains:1})}function oL(e,t,n,r){let i=y.IsEqual(y.Member(y.Keys(r),"length"),y.Constant(0)),o=y.ReduceAnd(u.Entries(n.dependencies).map(([s,a])=>{let l=y.Not(y.HasPropertyKey(r,y.Constant(s))),d=he(e,t,a,r),c=(m)=>y.ReduceAnd(m.map((p)=>y.HasPropertyKey(r,y.Constant(p))));return y.Or(l,u.IsArray(a)?c(a):d)}));return y.Or(i,o)}function sL(e,t,n,r){let i=u.IsEqual(u.Keys(r).length,0),o=u.Every(u.Entries(n.dependencies),0,([s,a])=>!u.HasPropertyKey(r,s)||(u.IsArray(a)?a.every((l)=>u.HasPropertyKey(r,l)):ce(e,t,a,r)));return i||o}function aL(e,t,n,r,i,o){let s=u.IsEqual(u.Keys(o).length,0),a=u.EveryAll(u.Entries(i.dependencies),0,([l,d])=>{let c=`${n}/dependencies/${l}`;return!u.HasPropertyKey(o,l)||(u.IsArray(d)?d.every((m)=>u.HasPropertyKey(o,m)||t.AddError("dependencies",n,r,{property:l,dependencies:d})):Re(e,t,c,r,d,o))});return s||a}function lL(e,t,n,r){let i=y.IsEqual(y.Member(y.Keys(r),"length"),y.Constant(0)),o=y.ReduceAnd(u.Entries(n.dependentRequired).map(([s,a])=>{let l=y.Not(y.HasPropertyKey(r,y.Constant(s))),d=y.ReduceAnd(a.map((c)=>y.HasPropertyKey(r,y.Constant(c))));return y.Or(l,d)}));return y.Or(i,o)}function uL(e,t,n,r){let i=u.IsEqual(u.Keys(r).length,0),o=u.Every(u.Entries(n.dependentRequired),0,([s,a])=>!u.HasPropertyKey(r,s)||a.every((l)=>u.HasPropertyKey(r,l)));return i||o}function dL(e,t,n,r,i,o){let s=u.IsEqual(u.Keys(o).length,0),a=u.EveryAll(u.Entries(i.dependentRequired),0,([l,d])=>!u.HasPropertyKey(o,l)||u.EveryAll(d,0,(c)=>u.HasPropertyKey(o,c)||t.AddError("dependentRequired",n,r,{property:l,dependencies:d})));return s||a}function cL(e,t,n,r){let i=y.IsEqual(y.Member(y.Keys(r),"length"),y.Constant(0)),o=y.ReduceAnd(u.Entries(n.dependentSchemas).map(([s,a])=>{let l=y.Not(y.HasPropertyKey(r,y.Constant(s))),d=he(e,t,a,r);return y.Or(l,d)}));return y.Or(i,o)}function mL(e,t,n,r){let i=u.IsEqual(u.Keys(r).length,0),o=u.Every(u.Entries(n.dependentSchemas),0,([s,a])=>!u.HasPropertyKey(r,s)||ce(e,t,a,r));return i||o}function fL(e,t,n,r,i,o){let s=u.IsEqual(u.Keys(o).length,0),a=u.EveryAll(u.Entries(i.dependentSchemas),0,([l,d])=>{let c=`${n}/dependentSchemas/${l}`;return!u.HasPropertyKey(o,l)||Re(e,t,c,r,d,o)});return s||a}var on={};Ut(on,{DynamicRef:()=>zq,RecursiveRef:()=>Gq,Ref:()=>Uq});var $s={};Ut($s,{Delete:()=>xq,Get:()=>gq,Has:()=>hq,Indices:()=>Tl,Set:()=>yq});function pL(e){if(e.length===0)throw Error("Cannot set root")}function hL(e){if(!u.IsObject(e))throw Error("Cannot set value")}function cq(e){if(u.IsUnsafePropertyKey(e))throw Error("Pointer contains unsafe property key")}function gL(e){for(let t of e)cq(t)}function mq(e){return/^(0|[1-9]\d*)$/.test(e)}function yL(e){return[e.slice(0,e.length-1),e.slice(e.length-1)[0]]}function fq(e,t){return u.IsObject(t)&&u.HasPropertyKey(t,e)}function pq(e,t){return u.IsObject(t)&&!u.IsUnsafePropertyKey(e)?t[e]:void 0}function kh(e,t){return e.reduce((n,r)=>pq(r,n),t)}function Tl(e){if(u.IsEqual(e.length,0))return[];let t=e.split("/").map((n)=>n.replace(/~1/g,"/").replace(/~0/g,"~"));return t.length>0&&t[0]===""?t.slice(1):t}function hq(e,t){let n=e;return Tl(t).every((r)=>{if(!fq(r,n))return!1;return n=n[r],!0})}function gq(e,t){let n=Tl(t);return kh(n,e)}function yq(e,t,n){let r=Tl(t);pL(r),gL(r);let[i,o]=yL(r),s=kh(i,e);return hL(s),s[o]=n,e}function xq(e,t){let n=Tl(t);pL(n),gL(n);let[r,i]=yL(n),o=kh(r,e);if(hL(o),u.IsArray(o)&&mq(i))o.splice(+i,1);else delete o[i];return e}function Rh(e,t){return Rt(e)&&Xt(e)?Wr(e.$id,t.href):t}function Ah(e){return Wr(e,El)}function wh(e){return e.href.split("#")[0]}function Iq(e,t,n){return Lh(e,Ah(t),n)}function Sq(e,t){return t.$ref.startsWith("#")||e.enteredResource?e.lexicalSchema:e.schema}function bq(e){return e.startsWith("#/")}function xL(e,t){if(u.IsObject(e)&&Ai(e)&&u.IsEqual(e.$dynamicAnchor,t))return e;if(u.IsObject(e))for(let n of u.Keys(e)){let r=xL(e[n],t);if(r)return r}return}function Lh(e,t,n){if(u.IsEqual(e,n))return t.href;let r=Rh(e,t);if(u.IsArray(e))for(let i of e){let o=Lh(i,r,n);if(!u.IsUndefined(o))return o}else if(u.IsObject(e))for(let i of u.Keys(e)){let o=Lh(e[i],r,n);if(!u.IsUndefined(o))return o}return}function IL(e,t){if(t.href.endsWith("#"))return e;if(!t.hash.startsWith("#"))return;let n=decodeURIComponent(t.hash.slice(1));if(!n.startsWith("/"))return;return $s.Get(e,n)}function Cq(e,t,n){if(!Xt(e))return;if(u.IsEqual(e.$id,n.hash))return e;let r=new URL(n.href,t.href);if(u.IsEqual(t.pathname,r.pathname))return n.hash.startsWith("#")?IL(e,n):e;return}function Eq(e,t,n){if(!Rw(e))return;let r=new URL(`#${e.$anchor}`,t.href),i=new URL(n.href,t.href);return u.IsEqual(r.href,i.href)?e:void 0}function vq(e,t,n){if(!Ai(e))return;let r=new URL(`#${e.$dynamicAnchor}`,t.href),i=new URL(n.href,t.href);return u.IsEqual(r.href,i.href)?e:void 0}function Tq(e,t,n){if(!Rt(e))return;return Cq(e,t,n)??Eq(e,t,n)??vq(e,t,n)??IL(e,n)}function kq(e,t,n){if(!u.IsArray(e))return;return e.reduce((r,i)=>{let o=jc(i,t,n);return!u.IsUndefined(o)?o:r},void 0)}function wq(e,t,n){if(!u.IsObject(e))return;return u.Keys(e).reduce((r,i)=>{if(u.IsEqual(i,"const")||u.IsEqual(i,"enum"))return r;let o=jc(e[i],t,n);return!u.IsUndefined(o)?o:r},void 0)}function jc(e,t,n){let r=Rh(e,t);return Tq(e,r,n)??kq(e,r,n)??wq(e,r,n)}function Lq(e,t,n,r){let i=qc(e,t,n,r);return Rt(i)&&Xt(i)?i:void 0}function Rq(e,t,n){if(!t.$ref.startsWith("#"))return;if(!Rt(e.schema)||u.HasPropertyKey(e.schema,"$schema"))return;let r=Iq(e.lexicalSchema,e.referenceBase,n);if(u.IsUndefined(r)||u.IsEqual(r,e.referenceBase))return;return{target:n,base:r,root:e.lexicalSchema}}function Aq(e,t,n){let r=e.context[t];if(!Rt(r))return;return{target:n,base:t,root:r}}function Pq(e,t,n,r,i){let o=i?Aq(e,r,n):void 0;return u.IsUndefined(o)?Rq(e,t,n):o}function $q(e,t,n){if(Xt(n))return;let r=Lq(e.context,e.schema,e.referenceBase,t);if(!r||e.ids.includes(r))return;return{resource:r}}function Mq(e,t){return u.HasPropertyKey(e,t)?e[t]:void 0}function Oq(e,t,n){return jc(e,t,n)}function Fq(e,t,n){let r=wh(n);if(!u.HasPropertyKey(e,r)||u.IsEqual(r,wh(t)))return;let i=e[r],o=Rh(i,new URL(r));return u.IsEqual(n.hash,"")?i:jc(i,o,n)}function qc(e,t,n,r){let i=Ah(n),o=Wr(r,i.href);return Mq(e,r)??Oq(t,i,o)??Fq(e,i,o)}function Nq(e,t){if(!t)return e;let n=new Map(e.resourceEntries);return n.set(t.target,{base:t.base,root:t.root}),{...e,resourceEntries:n}}function Dq(e,t){return t?Eo(e,t.resource):e}function SL(e,t,n,r){let i=Nq({...e,pendingResource:t},n);return Dq(i,r)}function Hq(e,t,n){let r=wh(Wr(t.$ref,e.referenceBase)),i=!u.IsEqual(r,e.resourceBase),o=Pq(e,t,n,r,i),s=i?$q(e,r,n):void 0;return{schema:n,stack:SL(e,!0,o,s)}}function _q(e,t){return{schema:t,stack:SL(e,!u.IsUndefined(t))}}function Uq(e,t){let n=qc(e.context,Sq(e,t),e.referenceBase,t.$ref);return Rt(n)?Hq(e,t,n):_q(e,n)}function Bq(e){return Rt(e.lexicalSchema)&&xl(e.lexicalSchema)}function Gq(e,t){let n=Bq(e)?e.recursiveAnchor:e.lexicalSchema;return qc(e.context,n,e.lexicalBase,t.$recursiveRef)}function bL(e,t){return Wr(t.$dynamicRef,Ah(e.lexicalBase).href).hash}function CL(e,t){return e.dynamicAnchors.find((n)=>u.IsEqual(n.$dynamicAnchor,t))??xL(e.schema,t)}function jq(e,t,n){if(!Rt(n)||!Ai(n))return n;let r=bL(e,t);return bq(r)?n:CL(e,n.$dynamicAnchor)}function qq(e,t){let n=bL(e,t);return CL(e,decodeURIComponent(n.slice(1)))}function zq(e,t){let n=t.$dynamicRef.startsWith("#")?e.lexicalSchema:e.schema,r=qc(e.context,n,e.lexicalBase,t.$dynamicRef);return u.IsUndefined(r)?qq(e,t):jq(e,t,r)}function EL(e,t,n,r){let i=on.DynamicRef(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Xr(o,t,i,r)}function vL(e,t,n,r){let i=on.DynamicRef(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Y(i)&&ce(o,t,i,r)}function TL(e,t,n,r,i,o){let s=on.DynamicRef(e,i)??!1,a=s?{...e,pendingResource:!0}:e;return Y(s)&&Re(a,t,"#",r,s,o)}function kL(e,t,n,r){return y.ReduceOr(n.enum.map((i)=>{if(u.IsValueLike(i))return y.IsEqual(r,y.Constant(i));let o=Hn(i);return y.IsDeepEqual(r,o)}))}function $h(e,t,n,r){return u.Some(n.enum,(i)=>u.IsValueLike(i)?u.IsEqual(r,i):u.IsDeepEqual(r,i))}function wL(e,t,n,r,i,o){return $h(e,t,i,o)||t.AddError("enum",n,r,{allowedValues:i.enum})}function LL(e,t,n,r){return y.IsLessThan(r,y.Constant(n.exclusiveMaximum))}function Mh(e,t,n,r){return u.IsLessThan(r,n.exclusiveMaximum)}function RL(e,t,n,r,i,o){return Mh(e,t,i,o)||t.AddError("exclusiveMaximum",n,r,{comparison:"<",limit:i.exclusiveMaximum})}function AL(e,t,n,r){return y.IsGreaterThan(r,y.Constant(n.exclusiveMinimum))}function Oh(e,t,n,r){return u.IsGreaterThan(r,n.exclusiveMinimum)}function PL(e,t,n,r,i,o){return Oh(e,t,i,o)||t.AddError("exclusiveMinimum",n,r,{comparison:">",limit:i.exclusiveMinimum})}var vo={};Ut(vo,{Clear:()=>iR,Entries:()=>Fz,Get:()=>Hz,Has:()=>Dz,IsDate:()=>Ms,IsDateTime:()=>zc,IsDuration:()=>Kc,IsEmail:()=>Vc,IsHostname:()=>tm,IsIPv4:()=>im,IsIPv6:()=>om,IsIdnEmail:()=>nm,IsIdnHostname:()=>rm,IsIri:()=>am,IsIriReference:()=>sm,IsJsonPointer:()=>um,IsJsonPointerUriFragment:()=>lm,IsRegex:()=>dm,IsRelativeJsonPointer:()=>cm,IsTime:()=>Os,IsUri:()=>pm,IsUriReference:()=>mm,IsUriTemplate:()=>fm,IsUrl:()=>hm,IsUuid:()=>gm,Reset:()=>oR,Set:()=>Nz,Test:()=>_z});var Kq=[0,31,28,31,30,31,30,31,31,30,31,30,31],Vq=/^(\d\d\d\d)-(\d\d)-(\d\d)$/;function Wq(e){return e%4===0&&(e%100!==0||e%400===0)}function Ms(e){let t=Vq.exec(e);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r===2&&Wq(n)?29:Kq[r])}var Xq=/^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;function Os(e,t=!0){let n=Xq.exec(e);if(!n)return!1;if(t&&!n[4]&&!n[5])return!1;let r=+n[1],i=+n[2],o=+n[3];if(r>23||i>59||o>60)return!1;if(n[5]){let c=+n[6],m=+n[7];if(c>23||m>59)return!1}if(o<60)return!0;let s=n[5]==="-"?-1:1,a=+(n[6]||0),l=+(n[7]||0);return((r*60+i-s*(a*60+l))%1440+1440)%1440===1439}function zc(e){let t=e.split(/T/i);return t.length===2&&Ms(t[0])&&Os(t[1])}var Yq=/^P((\d+Y(\d+M(\d+D)?)?|\d+M(\d+D)?|\d+D)(T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S))?|T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S)|\d+W)$/;function Kc(e){return Yq.test(e)}var Jq=/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;function Vc(e){return Jq.test(e)}var $L=/^(?!-).*(?<!-)$/,ML=/^(?!..--)/,OL=/^[a-zA-Z0-9-]*$/;var Fs=/[^\p{ASCII}]/u;var Zq=/[0-9]/,FL=/[\u{0660}-\u{0669}]/u,Qq=/[\u{06f0}-\u{06f9}]/u,ez=/[\u{002e}\u{002c}\u{003a}\u{002f}]/u,tz=/[\u{002d}\u{002b}]/u,Fh=/\p{Mn}/u,nz=/\p{Mc}/u;var NL=/[\p{Mn}\p{Mc}\p{Me}]/u,Nh=/\p{L}/u,rz=/\p{Nd}/u,DL=/\p{Script=Greek}/u,Wc=/\p{Script=Hebrew}/u,HL=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,_L=/[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u,Dh=/[\u{094d}\u{09cd}\u{0a4d}\u{0acd}\u{0b4d}\u{0bcd}\u{0c4d}\u{0ccd}\u{0d3b}\u{0d3c}\u{0d4d}\u{0dca}\u{1b44}\u{1baa}\u{1bab}\u{a9c0}\u{11046}\u{1107f}\u{110b9}\u{11133}\u{11134}\u{111c0}\u{11235}\u{1134d}\u{11442}\u{114c2}\u{115bf}\u{1163f}\u{116b6}\u{11c3f}\u{11d44}\u{11d45}]/u,UL=/[\u{0640}\u{07fa}\u{302e}\u{302f}\u{3031}\u{3032}\u{3033}\u{3034}\u{3035}\u{303b}]/u,iz=/[\u{00b7}\u{0375}\u{05f3}\u{05f4}\u{200c}\u{200d}\u{30fb}]/u,oz=/[\u{00df}\u{03c2}\u{06fd}\u{06fe}\u{0f0b}\u{3007}]/u,BL=new RegExp([Zq,Qq].map((e)=>e.source).join("|"),"u"),GL=new RegExp([Nh,tz,ez,rz,Fh,nz,iz,oz].map((e)=>e.source).join("|"),"u");function jL(e){return $L.test(e)&&ML.test(e)&&OL.test(e)}var rr=36,wl=1,Ll=26,az=38,lz=700,zL=72,KL=128;function Hh(){throw null}function Xc(e){return e.toLowerCase().startsWith("xn--")}function VL(e,t,n){e=n?Math.floor(e/lz):e>>1,e+=Math.floor(e/t);let r=0;while(e>(rr-wl)*Ll>>1)e=Math.floor(e/(rr-wl)),r+=rr;return r+Math.floor((rr-wl+1)*e/(e+az))}function Yc(e){let t=[],n=KL,r=0,i=zL,o=e.lastIndexOf("-");if(o>0)for(let a=0;a<o;a++){let l=e.charCodeAt(a);if(l>=128)Hh();t.push(l)}let s=o<0?0:o+1;while(s<e.length){let a=r,l=1,d=rr;while(!0){if(s>=e.length)Hh();let m=e.charCodeAt(s++),p;if(m>=97&&m<=122)p=m-97;else if(m>=48&&m<=57)p=m-48+26;else Hh();r+=p*l;let h=d<=i?wl:d>=i+Ll?Ll:d-i;if(p<h)break;l*=rr-h,d+=rr}let c=t.length+1;i=VL(r-a,c,a===0),n+=Math.floor(r/c),r%=c,t.splice(r,0,n),r++}return String.fromCodePoint(...t)}function qL(e){return e<26?String.fromCharCode(e+97):String.fromCharCode(e-26+48)}var uz=new RegExp(Fs.source,"gu");function WL(e){let t=e.replace(uz,""),n=t.length,r=n>0?[t,"-"]:[],i=Array.from(e,(d)=>d.codePointAt(0)),o=KL,s=0,a=zL,l=n;while(l<i.length){let d=1/0;for(let c of i)if(c>=o&&c<d)d=c;s+=(d-o)*(l+1),o=d;for(let c of i){if(c<o)s++;if(c===o){let m=s;for(let p=rr;;p+=rr){let h=p<=a?wl:p>=a+Ll?Ll:p-a;if(m<h)break;let x=h+(m-h)%(rr-h);r.push(qL(x)),m=Math.floor((m-h)/(rr-h))}r.push(qL(m)),a=VL(s,l+1,l===n),s=0,l++}}s++,o++}return r.join("")}var dz=/^(?:R|AL|AN|EN|ES|CS|ET|ON|BN|NSM)$/,XL=/^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/,cz=/^(?:R|AL|AN)$/;function YL(e){if(Xc(e))try{return Jc(Yc(e.slice(4).toLowerCase()))}catch{return!1}return Jc(e)}function JL(e){let t=String.fromCodePoint(e);return BL.test(t)?"EN":FL.test(t)?"AN":Fh.test(t)?"NSM":Wc.test(t)?"R":_L.test(t)?"AL":Nh.test(t)?"L":"ON"}function Jc(e){for(let t of e)if(cz.test(JL(t.codePointAt(0))))return!0;return!1}function Zc(e){let t=!1,n=XL,r=!1,i=!1,o=!0;for(let s of e){let a=JL(s.codePointAt(0));if(o){if(a!=="L"&&a!=="R"&&a!=="AL")return!1;t=a==="R"||a==="AL",n=t?dz:XL,o=!1}if(!n.test(a))return!1;if(a==="EN")r=!0;else if(a==="AN")i=!0}if(t&&r&&i)return!1;return!0}function mz(e){return Fs.test(e)&&WL(e).length+4>63}function fz(e){if(e[0]==="-"||e[e.length-1]==="-")return!0;return e.slice(2).join("").startsWith("--")}function Qc(e){if(mz(e))return!1;if(Jc(e)&&!Zc(e))return!1;let t=[...e],n=t.map((o)=>o.codePointAt(0)),r=n.length;if(fz(t))return!1;if(NL.test(t[0]))return!1;let i=!1;for(let o=0;o<r;o++){let s=n[o],a=t[o];if(UL.test(a))return!1;if(!GL.test(a))return!1;if(HL.test(a))i=!0;let l=n[o-1],d=n[o+1];switch(s){case 183:if(l!==108||d!==108)return!1;break;case 885:if(!d||!DL.test(t[o+1]))return!1;break;case 1523:case 1524:if(!l||!Wc.test(t[o-1]))return!1;break;case 8204:if(!l||l<128&&!Dh.test(t[o-1]))return!1;break;case 8205:if(!l||!Dh.test(t[o-1]))return!1;break;case 12539:break}}if(e.includes("・")&&!i)return!1;return!0}function em(e){if(!Xc(e))return!1;try{let t=e.slice(4).toLowerCase();if(t.lastIndexOf("-")===0)return!1;let n=Yc(t);if(!Fs.test(n))return!1;return Qc(n)}catch{return!1}}function pz(e){return e.length>0&&e.length<=63}function hz(e){return pz(e)&&(em(e)||jL(e))}function tR(e){if(e.length===0||e.length>253)return!1;if(e.charCodeAt(e.length-1)===46)return!1;return e.split(".").every((t)=>hz(t))}function gz(e){return e.length>0&&e.length<=63}function yz(e){return gz(e)&&(em(e)||Qc(e))}function xz(e){return e.replace(/[\uff01-\uff5e]/g,(t)=>String.fromCharCode(t.charCodeAt(0)-65248)).normalize("NFC").replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu,"").replace(/[\u002E\u3002\uFF0E\uFF61]/g,".")}function nR(e){if(e.length===0||e.includes(" "))return!1;let t=xz(e);if(t.length>253)return!1;let n=t.split("."),r=n.some((i)=>YL(i));return n.every((i)=>yz(i)&&(!r||Zc(i)))}function tm(e){return tR(e)}var Iz=/^(?:[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+(?:\.[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+)*|"(?:[^"\\]|\\.)*")@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-)(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-))*$/iu;function nm(e){return Iz.test(e.normalize("NFC"))}function rm(e){return nR(e)}var Sz=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function im(e){return Sz.test(e)}var bz=/^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;function om(e){return bz.test(e)}var Cz=/[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/,Ez=/^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;function sm(e){return!Cz.test(e)&&!Ez.test(e)&&URL.canParse(e,"http://example.com")}var vz=/\[[vV][0-9a-fA-F]+\.[^\]]+\]/,Tz=/[\x00-\x20<>\^`{|}\\]/,kz=/%(?![0-9a-fA-F]{2})/;function wz(e){return e.length<2048?e.replace(vz,"[::1]"):e}function am(e){if(Tz.test(e))return!1;if(kz.test(e))return!1;return URL.canParse(wz(e))}var Lz=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function lm(e){return Lz.test(e)}var Rz=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function um(e){return Rz.test(e)}function dm(e){try{return new RegExp(e,"u"),!0}catch{return!1}}var Az=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function cm(e){return Az.test(e)}var Pz=/^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function mm(e){return Pz.test(e)}var $z=/^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?)*\})*$/i;function fm(e){return $z.test(e)}var Mz=/^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function pm(e){return Mz.test(e)}function hm(e){return URL.canParse(e)}var Oz=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function gm(e){return Oz.test(e)}var Ne=new Map;function iR(){Ne.clear()}function Fz(){return[...Ne.entries()]}function Nz(e,t){Ne.set(e,t)}function Dz(e){return Ne.has(e)}function Hz(e){return Ne.get(e)}function _z(e,t){return Ne.get(e)?.(t)??!0}function oR(){iR(),Ne.set("date-time",zc),Ne.set("date",Ms),Ne.set("duration",Kc),Ne.set("email",Vc),Ne.set("hostname",tm),Ne.set("idn-email",nm),Ne.set("idn-hostname",rm),Ne.set("ipv4",im),Ne.set("ipv6",om),Ne.set("iri-reference",sm),Ne.set("iri",am),Ne.set("json-pointer-uri-fragment",lm),Ne.set("json-pointer",um),Ne.set("regex",dm),Ne.set("relative-json-pointer",cm),Ne.set("time",Os),Ne.set("uri-reference",mm),Ne.set("uri-template",fm),Ne.set("uri",pm),Ne.set("url",hm),Ne.set("uuid",gm)}oR();function sR(e,t,n,r){return y.Call(y.Member("Format","Test"),[y.Constant(n.format),r])}function Uh(e,t,n,r){return vo.Test(n.format,r)}function aR(e,t,n,r,i,o){return Uh(e,t,i,o)||t.AddError("format",n,r,{format:i.format})}function lR(e,t,n,r){let i=bl(n)?n.then:!0,o=al(n)?n.else:!0;return y.Ternary(he(e,t,n.if,r),he(e,t,i,r),he(e,t,o,r))}function uR(e,t,n,r){let i=bl(n)?n.then:!0,o=al(n)?n.else:!0;return ce(e,t,n.if,r)?ce(e,t,i,r):ce(e,t,o,r)}function dR(e,t,n,r,i,o){let s=bl(i)?i.then:!0,a=al(i)?i.else:!0,l=new _t,d=Re(e,l,`${n}/if`,r,i.if,o)?Re(e,l,`${n}/then`,r,s,o)||t.AddError("if",n,r,{failingKeyword:"then"}):Re(e,t,`${n}/else`,r,a,o)||t.AddError("if",n,r,{failingKeyword:"else"});if(d)t.Merge([l]);return d}function Uz(e,t,n,r){return y.ReduceAnd(n.items.map((i,o)=>{let s=y.IsLessEqualThan(y.Member(r,"length"),y.Constant(o)),a=Yt(e,t,i,`${r}[${o}]`),l=t.AddIndex(y.Constant(o));return y.Or(s,y.And(a,l))}))}function Bz(e,t,n,r){return y.ReduceAnd(n.items.map((i,o)=>{let s=y.IsLessEqualThan(y.Member(r,"length"),y.Constant(o)),a=Yt(e,t,i,`${r}[${o}]`);return y.Or(s,a)}))}function Gz(e,t,n,r){return t.UseUnevaluated()?Uz(e,t,n,r):Bz(e,t,n,r)}function jz(e,t,n,r){return u.Every(n.items,0,(i,o)=>u.IsLessEqualThan(r.length,o)||wn(e,t,i,r[o])&&t.AddIndex(o))}function qz(e,t,n,r,i,o){return u.EveryAll(i.items,0,(s,a)=>{let l=`${n}/items/${a}`,d=`${r}/${a}`;return u.IsLessEqualThan(o.length,a)||Ln(e,t,l,d,s,o[a])&&t.AddIndex(a)})}function zz(e,t,n,r){let i=er(n)?n.prefixItems.length:0,o=Yt(e,t,n.items,"element"),s=t.AddIndex("index");return y.Every(r,y.Constant(i),["element","index"],y.And(o,s))}function Kz(e,t,n,r){let i=er(n)?n.prefixItems.length:0,o=Yt(e,t,n.items,"element");return y.Every(r,y.Constant(i),["element","index"],o)}function Vz(e,t,n,r){return t.UseUnevaluated()?zz(e,t,n,r):Kz(e,t,n,r)}function Wz(e,t,n,r){let i=er(n)?n.prefixItems.length:0;return u.Every(r,i,(o,s)=>wn(e,t,n.items,o)&&t.AddIndex(s))}function Xz(e,t,n,r,i,o){let s=er(i)?i.prefixItems.length:0;return u.EveryAll(o,s,(a,l)=>{let d=`${n}/items`,c=`${r}/${l}`;return Ln(e,t,d,c,i.items,a)&&t.AddIndex(l)})}function cR(e,t,n,r){return dl(n)?Gz(e,t,n,r):Vz(e,t,n,r)}function mR(e,t,n,r){return dl(n)?jz(e,t,n,r):Wz(e,t,n,r)}function fR(e,t,n,r,i,o){return dl(i)?qz(e,t,n,r,i,o):Xz(e,t,n,r,i,o)}function pR(e){return Cr(e)}function hR(e,t,n,r){if(!pR(n))return y.Constant(!0);let[i]=[Ce()],o=y.Counted(r,[i,"_"],he(e,t,n.contains,i));return y.IsLessEqualThan(o,y.Constant(n.maxContains))}function Bh(e,t,n,r){if(!pR(n))return!0;let i=u.Counted(r,(o)=>ce(e,t,n.contains,o));return u.IsLessEqualThan(i,n.maxContains)}function gR(e,t,n,r,i,o){let s=zr(i)?i.minContains:1;return Bh(e,t,i,o)||t.AddError("contains",n,r,{minContains:s,maxContains:i.maxContains})}function yR(e,t,n,r){return y.IsLessEqualThan(r,y.Constant(n.maximum))}function Gh(e,t,n,r){return u.IsLessEqualThan(r,n.maximum)}function xR(e,t,n,r,i,o){return Gh(e,t,i,o)||t.AddError("maximum",n,r,{comparison:"<=",limit:i.maximum})}function IR(e,t,n,r){return y.IsLessEqualThan(y.Member(r,"length"),y.Constant(n.maxItems))}function jh(e,t,n,r){return u.IsLessEqualThan(r.length,n.maxItems)}function SR(e,t,n,r,i,o){return jh(e,t,i,o)||t.AddError("maxItems",n,r,{limit:i.maxItems})}function bR(e,t,n,r){return y.IsMaxLength(r,y.Constant(n.maxLength))}function qh(e,t,n,r){return u.IsMaxLength(r,n.maxLength)}function CR(e,t,n,r,i,o){return qh(e,t,i,o)||t.AddError("maxLength",n,r,{limit:i.maxLength})}function ER(e,t,n,r){return y.IsLessEqualThan(y.Member(y.Keys(r),"length"),y.Constant(n.maxProperties))}function zh(e,t,n,r){return u.IsLessEqualThan(u.Keys(r).length,n.maxProperties)}function vR(e,t,n,r,i,o){return zh(e,t,i,o)||t.AddError("maxProperties",n,r,{limit:i.maxProperties})}function TR(e){return Cr(e)}function Yz(e,t,n,r){let[i,o]=[Ce(),Ce()],s=y.Counted(r,[i,o],y.And(he(e,t,n.contains,i),t.AddIndex(o)));return y.IsGreaterEqualThan(s,y.Constant(n.minContains))}function Jz(e,t,n,r){let[i]=[Ce()],o=y.Counted(r,[i,"_"],he(e,t,n.contains,i));return y.IsGreaterEqualThan(o,y.Constant(n.minContains))}function kR(e,t,n,r){if(!TR(n))return y.Constant(!0);return t.UseUnevaluated()?Yz(e,t,n,r):Jz(e,t,n,r)}function Kh(e,t,n,r){if(!TR(n))return!0;let i=u.Counted(r,(o,s)=>ce(e,t,n.contains,o)&&t.AddIndex(s));return u.IsGreaterEqualThan(i,n.minContains)}function wR(e,t,n,r,i,o){return Kh(e,t,i,o)||t.AddError("contains",n,r,{minContains:i.minContains})}function LR(e,t,n,r){return y.IsGreaterEqualThan(r,y.Constant(n.minimum))}function Vh(e,t,n,r){return u.IsGreaterEqualThan(r,n.minimum)}function RR(e,t,n,r,i,o){return Vh(e,t,i,o)||t.AddError("minimum",n,r,{comparison:">=",limit:i.minimum})}function AR(e,t,n,r){return y.IsGreaterEqualThan(y.Member(r,"length"),y.Constant(n.minItems))}function Wh(e,t,n,r){return u.IsGreaterEqualThan(r.length,n.minItems)}function PR(e,t,n,r,i,o){return Wh(e,t,i,o)||t.AddError("minItems",n,r,{limit:i.minItems})}function $R(e,t,n,r){return y.IsMinLength(r,y.Constant(n.minLength))}function Xh(e,t,n,r){return u.IsMinLength(r,n.minLength)}function MR(e,t,n,r,i,o){return Xh(e,t,i,o)||t.AddError("minLength",n,r,{limit:i.minLength})}function OR(e,t,n,r){return y.IsGreaterEqualThan(y.Member(y.Keys(r),"length"),y.Constant(n.minProperties))}function Yh(e,t,n,r){return u.IsGreaterEqualThan(u.Keys(r).length,n.minProperties)}function FR(e,t,n,r,i,o){return Yh(e,t,i,o)||t.AddError("minProperties",n,r,{limit:i.minProperties})}function NR(e,t,n,r){return y.MultipleOf(r,y.Constant(n.multipleOf))}function Jh(e,t,n,r){return u.IsMultipleOf(r,n.multipleOf)}function DR(e,t,n,r,i,o){return Jh(e,t,i,o)||t.AddError("multipleOf",n,r,{multipleOf:i.multipleOf})}function Zz(e,t,n,r){return Ni(e,t,[n.not],r,y.Not(y.IsEqual(y.Member("results","length"),y.Constant(1))))}function Qz(e,t,n,r){return y.Not(he(e,t,n.not,r))}function HR(e,t,n,r){return t.UseUnevaluated()?Zz(e,t,n,r):Qz(e,t,n,r)}function Zh(e,t,n,r){let i=new Ht;return!ce(e,i,n.not,r)&&t.Merge([i])}function _R(e,t,n,r,i,o){return Zh(e,t,i,o)||t.AddError("not",n,r,{})}function e8(e,t,n,r){return Ni(e,t,n.oneOf,r,y.IsEqual(y.Member("results","length"),y.Constant(1)))}function t8(e,t,n,r){let[i]=[Ce()],o=y.ArrayLiteral(n.oneOf.map((a)=>he(e,t,a,r))),s=y.Counted(o,[i,"_"],y.IsEqual(i,y.Constant(!0)));return y.IsEqual(s,y.Constant(1))}function UR(e,t,n,r){return t.UseUnevaluated()?e8(e,t,n,r):t8(e,t,n,r)}function BR(e,t,n,r){let i=n.oneOf.reduce((o,s)=>{let a=new Ht;return ce(e,a,s,r)?[...o,a]:o},[]);return u.IsEqual(i.length,1)&&t.Merge(i)}function GR(e,t,n,r,i,o){let s=[],a=[],l=i.oneOf.reduce((c,m,p)=>{let h=new _t,x=`${n}/oneOf/${p}`,I=Re(e,h,x,r,m,o);if(I)a.push(p);if(!I)s.push(h);return I?[...c,h]:c},[]),d=u.IsEqual(l.length,1)&&t.Merge(l);if(!d&&u.IsEqual(a.length,0))s.forEach((c)=>t.AddErrors(c.GetErrors()));return d||t.AddError("oneOf",n,r,{passingSchemas:a})}function jR(e,t,n,r){let i=Hn(u.IsString(n.pattern)?nr(n.pattern):n.pattern);return y.Call(y.Member(i,"test"),[r])}function Qh(e,t,n,r){return(u.IsString(n.pattern)?nr(n.pattern):n.pattern).test(r)}function qR(e,t,n,r,i,o){return Qh(e,t,i,o)||t.AddError("pattern",n,r,{pattern:i.pattern})}function zR(e,t,n,r){return y.ReduceAnd(u.Entries(n.patternProperties).map(([i,o])=>{let[s,a]=[Ce(),Ce()],l=Hn(nr(i)),d=y.Not(y.Call(y.Member(l,"test"),[s])),c=Yt(e,t,o,a),m=t.AddKey(s),p=t.UseUnevaluated()?y.Or(d,y.And(c,m)):y.Or(d,c);return y.Every(y.Entries(r),y.Constant(0),[`[${s}, ${a}]`,"_"],p)}))}function KR(e,t,n,r){return u.Every(u.Entries(n.patternProperties),0,([i,o])=>{let s=nr(i);return u.Every(u.Entries(r),0,([a,l])=>!s.test(a)||wn(e,t,o,l)&&t.AddKey(a))})}function VR(e,t,n,r,i,o){return u.EveryAll(u.Entries(i.patternProperties),0,([s,a])=>{let l=`${n}/patternProperties/${s}`,d=nr(s);return u.EveryAll(u.Entries(o),0,([c,m])=>{let p=`${r}/${c}`;return!d.test(c)||Ln(e,t,l,p,a,m)&&t.AddKey(c)})})}function WR(e,t,n,r){return y.ReduceAnd(n.prefixItems.map((i,o)=>{let s=y.IsLessEqualThan(y.Member(r,"length"),y.Constant(o)),a=Yt(e,t,i,`${r}[${o}]`),l=t.AddIndex(y.Constant(o)),d=t.UseUnevaluated()?y.And(a,l):a;return y.Or(s,d)}))}function XR(e,t,n,r){return u.IsEqual(r.length,0)||u.Every(n.prefixItems,0,(i,o)=>u.IsLessEqualThan(r.length,o)||wn(e,t,i,r[o])&&t.AddIndex(o))}function YR(e,t,n,r,i,o){return u.IsEqual(o.length,0)||u.EveryAll(i.prefixItems,0,(s,a)=>{let l=`${n}/prefixItems/${a}`,d=`${r}/${a}`;return u.IsLessEqualThan(o.length,a)||Ln(e,t,l,d,s,o[a])&&t.AddIndex(a)})}function ym(e,t){return e.includes(t)||He.Get().exactOptionalPropertyTypes}function JR(e,t){return y.IsUndefined(y.Member(e,t))}function eg(e,t){return u.IsUndefined(e[t])}function ZR(e,t,n,r){let i=tr(n)?n.required:[],o=u.Entries(n.properties).map(([s,a])=>{let l=y.Not(y.HasPropertyKey(r,y.Constant(s))),d=Yt(e,t,a,y.Member(r,s)),c=t.AddKey(y.Constant(s)),m=t.UseUnevaluated()?y.And(d,c):d,p=i.includes(s)?m:y.Or(l,m);return ym(i,s)?p:y.Or(JR(r,s),p)});return y.ReduceAnd(o)}function QR(e,t,n,r){let i=tr(n)?n.required:[];return u.Every(u.Entries(n.properties),0,([s,a])=>{let l=!u.HasPropertyKey(r,s)||wn(e,t,a,r[s])&&t.AddKey(s);return ym(i,s)?l:eg(r,s)||l})}function eA(e,t,n,r,i,o){let s=tr(i)?i.required:[];return u.EveryAll(u.Entries(i.properties),0,([l,d])=>{let c=`${n}/properties/${l}`,m=`${r}/${l}`,p=()=>!u.HasPropertyKey(o,l)||Ln(e,t,c,m,d,o[l])&&t.AddKey(l);return ym(s,l)?p():eg(o,l)||p()})}function tA(e,t,n,r){let[i,o]=[Ce(),Ce()];return y.Every(y.Keys(r),y.Constant(0),[i,o],he(e,t,n.propertyNames,i))}function nA(e,t,n,r){return u.Every(u.Keys(r),0,(i,o)=>ce(e,t,n.propertyNames,i))}function rA(e,t,n,r,i,o){let s=[];return u.EveryAll(u.Keys(o),0,(l,d)=>{let c=`${r}/${l}`,m=`${n}/propertyNames`,p=Re(e,t,m,c,i.propertyNames,l);if(!p)s.push(l);return p})||t.AddError("propertyNames",n,r,{propertyNames:s})}function iA(e,t,n,r){let i=on.RecursiveRef(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Xr(o,t,i,r)}function oA(e,t,n,r){let i=on.RecursiveRef(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Y(i)&&ce(o,t,i,r)}function sA(e,t,n,r,i,o){let s=on.RecursiveRef(e,i)??!1,a=s?{...e,pendingResource:!0}:e;return Y(s)&&Re(a,t,"#",r,s,o)}function n8(e,t,n,r){let i=y.ArrowFunction(["context","value"],Xr(e,t,n,"value")),o=y.ArrowFunction(["context","value"],y.Statements([y.ConstDeclaration("nextContext",y.New("CheckContext",[])),y.ConstDeclaration("result",y.Call(i,["nextContext","value"])),y.If("result",t.Merge("[nextContext]")),y.Return("result")]));return y.Call(o,["context",r])}function r8(e,t,n,r){return Xr(e,t,n,r)}function aA(e,t,n,r){let i=on.Ref(e,n),o=i.schema??!1;return t.UseUnevaluated()?n8(i.stack,t,o,r):r8(i.stack,t,o,r)}function lA(e,t,n,r){let i=on.Ref(e,n),o=i.schema??!1,s=new Ht,a=Y(o)&&ce(i.stack,s,o,r);if(a)t.Merge([s]);return a}function uA(e,t,n,r,i,o){let s=on.Ref(e,i),a=s.schema??!1,l=new _t,d=Y(a)&&Re(s.stack,l,"#",r,a,o);if(d)t.Merge([l]);if(!d)t.AddErrors(l.GetErrors());return d}function dA(e,t,n,r){return y.ReduceAnd(n.required.map((i)=>y.HasPropertyKey(r,y.Constant(i))))}function cA(e,t,n,r){return u.Every(n.required,0,(i)=>u.HasPropertyKey(r,i))}function mA(e,t,n,r,i,o){let s=[];return u.EveryAll(i.required,0,(l)=>{let d=u.HasPropertyKey(o,l);if(!d)s.push(l);return d})||t.AddError("required",n,r,{requiredProperties:s})}function fA(e,t,n,r){return u.IsEqual(n,"object")?y.IsObjectNotArray(r):u.IsEqual(n,"array")?y.IsArray(r):u.IsEqual(n,"boolean")?y.IsBoolean(r):u.IsEqual(n,"integer")?y.IsInteger(r):u.IsEqual(n,"number")?y.IsNumber(r):u.IsEqual(n,"null")?y.IsNull(r):u.IsEqual(n,"string")?y.IsString(r):u.IsEqual(n,"bigint")?y.IsBigInt(r):u.IsEqual(n,"constructor")?y.IsConstructor(r):u.IsEqual(n,"function")?y.IsFunction(r):u.IsEqual(n,"symbol")?y.IsSymbol(r):u.IsEqual(n,"undefined")?y.IsUndefined(r):u.IsEqual(n,"void")?y.IsUndefined(r):y.Constant(!0)}function tg(e,t,n,r,i){return u.IsEqual(n,"object")?u.IsObjectNotArray(i):u.IsEqual(n,"array")?u.IsArray(i):u.IsEqual(n,"boolean")?u.IsBoolean(i):u.IsEqual(n,"integer")?u.IsInteger(i):u.IsEqual(n,"number")?u.IsNumber(i):u.IsEqual(n,"null")?u.IsNull(i):u.IsEqual(n,"string")?u.IsString(i):u.IsEqual(n,"bigint")?u.IsBigInt(i):u.IsEqual(n,"constructor")?u.IsConstructor(i):u.IsEqual(n,"function")?u.IsFunction(i):u.IsEqual(n,"symbol")?u.IsSymbol(i):u.IsEqual(n,"undefined")?u.IsUndefined(i):u.IsEqual(n,"void")?u.IsUndefined(i):!0}function i8(e,t,n,r){return y.ReduceOr(n.map((i)=>fA(e,t,i,r)))}function pA(e,t,n,r,i){return u.Some(n,(o)=>tg(e,t,o,r,i))}function hA(e,t,n,r){return u.IsArray(n.type)?i8(e,t,n.type,r):fA(e,t,n.type,r)}function gA(e,t,n,r){return u.IsArray(n.type)?pA(e,t,n.type,n,r):tg(e,t,n.type,n,r)}function yA(e,t,n,r,i,o){return(u.IsArray(i.type)?pA(e,t,i.type,i,o):tg(e,t,i.type,i,o))||t.AddError("type",n,r,{type:i.type})}function xA(e,t,n,r){let[i,o]=[Ce(),Ce()],s=y.Call(y.Member("context","GetIndices"),[]),a=y.Call(y.Member("indices","has"),[i]),l=he(e,t,n.unevaluatedItems,o),d=y.Call(y.Member("context","AddIndex"),[i]),c=y.Every(r,y.Constant(0),[o,i],y.And(y.Or(a,l),d));return y.Call(y.ArrowFunction(["context"],y.Statements([y.ConstDeclaration("indices",s),y.Return(c)])),["context"])}function IA(e,t,n,r){let i=t.GetIndices();return u.Every(r,0,(o,s)=>(i.has(s)||ce(e,t,n.unevaluatedItems,o))&&t.AddIndex(s))}function SA(e,t,n,r,i,o){let s=t.GetIndices(),a=[];return u.EveryAll(o,0,(d,c)=>{let m=new _t,p=(s.has(c)||Re(e,m,n,r,i.unevaluatedItems,d))&&t.AddIndex(c);if(!p)a.push(c);return p})||t.AddError("unevaluatedItems",n,r,{unevaluatedItems:a})}function bA(e,t,n,r){let[i,o]=[Ce(),Ce()],s=y.Call(y.Member("context","GetKeys"),[]),a=y.Call(y.Member("keys","has"),[i]),l=y.Call(y.Member("context","AddKey"),[i]),d=he(e,t,n.unevaluatedProperties,o),c=y.Every(y.Entries(r),y.Constant(0),[`[${i}, ${o}]`,"_"],y.Or(a,y.And(d,l)));return y.Call(y.ArrowFunction(["context"],y.Statements([y.ConstDeclaration("keys",s),y.Return(c)])),["context"])}function CA(e,t,n,r){let i=t.GetKeys();return u.Every(u.Entries(r),0,([o,s])=>i.has(o)||ce(e,t,n.unevaluatedProperties,s)&&t.AddKey(o))}function EA(e,t,n,r,i,o){let s=t.GetKeys(),a=[];return u.EveryAll(u.Entries(o),0,([d,c])=>{let m=new _t,p=s.has(d)||Re(e,m,n,r,i.unevaluatedProperties,c)&&t.AddKey(d);if(!p)a.push(d);return p})||t.AddError("unevaluatedProperties",n,r,{unevaluatedProperties:a})}function ng(e){return!u.IsEqual(e.uniqueItems,!1)}function vA(e,t,n,r){if(!ng(n))return y.Constant(!0);let i=y.Member(y.New("Set",[y.Call(y.Member(r,"map"),[y.Member("Hashing","Hash")])]),"size"),o=y.Member(r,"length");return y.IsEqual(i,o)}function TA(e,t,n,r){if(!ng(n))return!0;let i=new Set(r.map(Br.Hash)).size,o=r.length;return u.IsEqual(i,o)}function kA(e,t,n,r,i,o){if(!ng(i))return!0;let s=new Set,a=o.reduce((d,c,m)=>{let p=Br.Hash(c);if(s.has(p))return[...d,m];return s.add(p),d},[]);return u.IsEqual(a.length,0)||t.AddError("uniqueItems",n,r,{duplicateItems:a})}function Rl(e,t){return Cl(e)&&(u.IsArray(e.type)&&u.IsGreaterThan(e.type.length,0)&&u.Every(e.type,0,(n)=>u.IsEqual(n,t))||u.IsEqual(e.type,t))}function o8(e){return Rl(e,"object")}function s8(e){return Rt(e)&&(Dn(e)||il(e)||ol(e)||Ls(e)||Vr(e)||Kr(e)||As(e)||bo(e)||pl(e)||tr(e)||Oi(e))}function a8(e){return Rl(e,"array")}function l8(e){return Rt(e)&&(ws(e)||qr(e)||Cr(e)||ml(e)||Rs(e)||zr(e)||Pi(e)||er(e)||Mi(e)||$i(e))}function u8(e){return Rl(e,"string")}function d8(e){return Rt(e)&&(So(e)||fl(e)||Io(e)||Co(e))}function c8(e){return Rl(e,"number")||Rl(e,"bigint")}function m8(e){return Rt(e)&&(Qn(e)||cl(e)||ll(e)||Zn(e)||hl(e))}function Yt(e,t,n,r){return t.UseUnevaluated()?y.And(y.And(t.Push(),he(e,t,n,r)),t.Pop()):he(e,t,n,r)}function he(e,t,n,r){let i=Eo(e,n),o=[];if(Ri(n))return Zw(i,t,n,r);if(Cl(n))o.push(hA(i,t,n,r));if(s8(n)){let a=[];if(tr(n))a.push(dA(i,t,n,r));if(Dn(n))a.push(jw(i,t,n,r));if(il(n))a.push(oL(i,t,n,r));if(ol(n))a.push(lL(i,t,n,r));if(Ls(n))a.push(cL(i,t,n,r));if(Kr(n))a.push(zR(i,t,n,r));if(Vr(n))a.push(ZR(i,t,n,r));if(As(n))a.push(tA(i,t,n,r));if(bo(n))a.push(OR(i,t,n,r));if(pl(n))a.push(ER(i,t,n,r));let l=y.ReduceAnd(a),d=y.Or(y.Not(y.IsObjectNotArray(r)),l);o.push(o8(n)?l:d)}if(l8(n)){let a=[];if(ws(n))a.push(Uw(i,t,n,r));if(Cr(n))a.push(rL(i,t,n,r));if(qr(n))a.push(cR(i,t,n,r));if(ml(n))a.push(hR(i,t,n,r));if(Rs(n))a.push(IR(i,t,n,r));if(zr(n))a.push(kR(i,t,n,r));if(Pi(n))a.push(AR(i,t,n,r));if(er(n))a.push(WR(i,t,n,r));if($i(n))a.push(vA(i,t,n,r));let l=y.ReduceAnd(a),d=y.Or(y.Not(y.IsArray(r)),l);o.push(a8(n)?l:d)}if(d8(n)){let a=[];if(fl(n))a.push(bR(i,t,n,r));if(So(n))a.push($R(i,t,n,r));if(Io(n))a.push(sR(i,t,n,r));if(Co(n))a.push(jR(i,t,n,r));let l=y.ReduceAnd(a),d=y.Or(y.Not(y.IsString(r)),l);o.push(u8(n)?l:d)}if(m8(n)){let a=[];if(ll(n))a.push(LL(i,t,n,r));if(Zn(n))a.push(AL(i,t,n,r));if(cl(n))a.push(yR(i,t,n,r));if(Qn(n))a.push(LR(i,t,n,r));if(hl(n))a.push(NR(i,t,n,r));let l=y.ReduceAnd(a),d=y.Or(y.Not(y.Or(y.IsNumber(r),y.IsBigInt(r))),l);o.push(c8(n)?l:d)}if(Sl(n))o.push(aA(i,t,n,r));if(Il(n))o.push(iA(i,t,n,r));if(sl(n))o.push(EL(i,t,n,r));if(_c(n))o.push(eL(i,t,n,r));if(Uc(n))o.push(kL(i,t,n,r));if(ul(n))o.push(lR(i,t,n,r));if(gl(n))o.push(HR(i,t,n,r));if(nl(n))o.push(Kw(i,t,n,r));if(rl(n))o.push(Xw(i,t,n,r));if(yl(n))o.push(UR(i,t,n,r));if(Mi(n))o.push(y.Or(y.Not(y.IsArray(r)),xA(i,t,n,r)));if(Oi(n))o.push(y.Or(y.Not(y.IsObject(r)),bA(i,t,n,r)));if(tl(n))o.push(Mw(i,t,n,r));return y.ReduceAnd(o)}function wn(e,t,n,r){return t.Push()&&ce(e,t,n,r)&&t.Pop()}function ce(e,t,n,r){let i=Eo(e,n);return Ri(n)?Eh(i,t,n,r):(!Cl(n)||gA(i,t,n,r))&&(!(u.IsObject(r)&&!u.IsArray(r))||(!tr(n)||cA(i,t,n,r))&&(!Dn(n)||qw(i,t,n,r))&&(!il(n)||sL(i,t,n,r))&&(!ol(n)||uL(i,t,n,r))&&(!Ls(n)||mL(i,t,n,r))&&(!Kr(n)||KR(i,t,n,r))&&(!Vr(n)||QR(i,t,n,r))&&(!As(n)||nA(i,t,n,r))&&(!bo(n)||Yh(i,t,n,r))&&(!pl(n)||zh(i,t,n,r)))&&(!u.IsArray(r)||(!ws(n)||Bw(i,t,n,r))&&(!Cr(n)||Th(i,t,n,r))&&(!qr(n)||mR(i,t,n,r))&&(!ml(n)||Bh(i,t,n,r))&&(!Rs(n)||jh(i,t,n,r))&&(!zr(n)||Kh(i,t,n,r))&&(!Pi(n)||Wh(i,t,n,r))&&(!er(n)||XR(i,t,n,r))&&(!$i(n)||TA(i,t,n,r)))&&(!u.IsString(r)||(!fl(n)||qh(i,t,n,r))&&(!So(n)||Xh(i,t,n,r))&&(!Io(n)||Uh(i,t,n,r))&&(!Co(n)||Qh(i,t,n,r)))&&(!(u.IsNumber(r)||u.IsBigInt(r))||(!ll(n)||Mh(i,t,n,r))&&(!Zn(n)||Oh(i,t,n,r))&&(!cl(n)||Gh(i,t,n,r))&&(!Qn(n)||Vh(i,t,n,r))&&(!hl(n)||Jh(i,t,n,r)))&&(!Sl(n)||lA(i,t,n,r))&&(!Il(n)||oA(i,t,n,r))&&(!sl(n)||vL(i,t,n,r))&&(!_c(n)||vh(i,t,n,r))&&(!Uc(n)||$h(i,t,n,r))&&(!ul(n)||uR(i,t,n,r))&&(!gl(n)||Zh(i,t,n,r))&&(!nl(n)||Vw(i,t,n,r))&&(!rl(n)||Yw(i,t,n,r))&&(!yl(n)||BR(i,t,n,r))&&(!Mi(n)||(!u.IsArray(r)||IA(i,t,n,r)))&&(!Oi(n)||(!u.IsObject(r)||CA(i,t,n,r)))&&(!tl(n)||Ow(i,t,n,r))}function Ln(e,t,n,r,i,o){return t.Push()&&Re(e,t,n,r,i,o)&&t.Pop()}function Re(e,t,n,r,i,o){if(t.AtCapacity())return!1;let s=Eo(e,i);return Ri(i)?Qw(s,t,n,r,i,o):!!(+(!Cl(i)||yA(s,t,n,r,i,o))&+(!(u.IsObject(o)&&!u.IsArray(o))||!!(+(!tr(i)||mA(s,t,n,r,i,o))&+(!Dn(i)||zw(s,t,n,r,i,o))&+(!il(i)||aL(s,t,n,r,i,o))&+(!ol(i)||dL(s,t,n,r,i,o))&+(!Ls(i)||fL(s,t,n,r,i,o))&+(!Kr(i)||VR(s,t,n,r,i,o))&+(!Vr(i)||eA(s,t,n,r,i,o))&+(!As(i)||rA(s,t,n,r,i,o))&+(!bo(i)||FR(s,t,n,r,i,o))&+(!pl(i)||vR(s,t,n,r,i,o))))&+(!u.IsArray(o)||!!(+(!ws(i)||Gw(s,t,n,r,i,o))&+(!Cr(i)||iL(s,t,n,r,i,o))&+(!qr(i)||fR(s,t,n,r,i,o))&+(!ml(i)||gR(s,t,n,r,i,o))&+(!Rs(i)||SR(s,t,n,r,i,o))&+(!zr(i)||wR(s,t,n,r,i,o))&+(!Pi(i)||PR(s,t,n,r,i,o))&+(!er(i)||YR(s,t,n,r,i,o))&+(!$i(i)||kA(s,t,n,r,i,o))))&+(!u.IsString(o)||!!(+(!fl(i)||CR(s,t,n,r,i,o))&+(!So(i)||MR(s,t,n,r,i,o))&+(!Io(i)||aR(s,t,n,r,i,o))&+(!Co(i)||qR(s,t,n,r,i,o))))&+(!(u.IsNumber(o)||u.IsBigInt(o))||!!(+(!ll(i)||RL(s,t,n,r,i,o))&+(!Zn(i)||PL(s,t,n,r,i,o))&+(!cl(i)||xR(s,t,n,r,i,o))&+(!Qn(i)||RR(s,t,n,r,i,o))&+(!hl(i)||DR(s,t,n,r,i,o))))&+(!Sl(i)||uA(s,t,n,r,i,o))&+(!Il(i)||sA(s,t,n,r,i,o))&+(!sl(i)||TL(s,t,n,r,i,o))&+(!_c(i)||tL(s,t,n,r,i,o))&+(!Uc(i)||wL(s,t,n,r,i,o))&+(!ul(i)||dR(s,t,n,r,i,o))&+(!gl(i)||_R(s,t,n,r,i,o))&+(!nl(i)||Ww(s,t,n,r,i,o))&+(!rl(i)||Jw(s,t,n,r,i,o))&+(!yl(i)||GR(s,t,n,r,i,o))&+(!Mi(i)||(!u.IsArray(o)||SA(s,t,n,r,i,o)))&+(!Oi(i)||(!u.IsObject(o)||EA(s,t,n,r,i,o))))&&(!tl(i)||Fw(s,t,n,r,i,o))}var wA=[0],xm=new Map,Al=new Map;function f8(){return`${wA[0]++}`}function p8(e,t){if(!xm.has(e))xm.set(e,new Map);let n=xm.get(e);if(n.has(t))return n.get(t);let r=f8();return n.set(t,r),r}function h8(e,t,n,r){return e.UseUnevaluated()?y.Call(`check_${n}`,["context",r]):y.Call(`check_${n}`,[r])}function g8(e,t,n,r){let i=he(e,t,n,"value");return t.UseUnevaluated()?y.ConstDeclaration(`check_${r}`,y.ArrowFunction(["context","value"],i)):y.ConstDeclaration(`check_${r}`,y.ArrowFunction(["value"],i))}function LA(){wA[0]=0,xm.clear(),Al.clear()}function RA(){return[...Al.values()]}function Xr(e,t,n,r){let i=p8(n,e.lexicalBase),o=h8(t,n,i,r);if(Al.has(i))return o;return Al.set(i,""),Al.set(i,g8(e,t,n,i)),o}function y8(e){let t=e.Functions().join(`;
|
|
1531
|
-
`),n=e.UseUnevaluated()?["const context = new CheckContext({}, {})",`return ${e.Entry()}`]:[`return ${e.Entry()}`];return`${t}; return (value) => { ${n.join("; ")} }`}function x8(e,t){return as.Evaluate("CheckContext","Guard","Format","Hashing",e.External().identifier,t)(Ht,u,vo,Br,e.External().variables)}function I8(e){let t=Fi(e.Context(),e.Schema()),n=new Ht;return(r)=>ce(t,n,e.Schema(),r)}function S8(e,t){return as.CanEvaluate()?x8(e,t):I8(e)}class AA{constructor(e,t,n){this.isAccelerated=e,this.code=t,this.check=n}IsAccelerated(){return this.isAccelerated}Code(){return this.code}Check(e){return this.check(e)}}class PA{constructor(e,t,n,r,i,o){this.context=e,this.schema=t,this.external=n,this.functions=r,this.entry=i,this.useUnevaluated=o}Context(){return this.context}Schema(){return this.schema}UseUnevaluated(){return this.useUnevaluated}External(){return this.external}Functions(){return this.functions}Entry(){return this.entry}Evaluate(){let e=y8(this),t=S8(this,e);return new AA(as.CanEvaluate(),e,t)}}function Im(...e){let[t,n]=ee.Match(e,{2:(l,d)=>[l,d],1:(l)=>[{},l]});Pw(),LA();let r=Fi(t,n),i=new xh(Aw(t,n)),o=Xr(r,i,n,"value"),s=RA(),a=$w();return new PA(t,n,a,s,o,i.UseUnevaluated())}function Sm(...e){let[t,n,r]=ee.Match(e,{3:(c,m,p)=>[c,m,p],2:(c,m)=>[{},c,m]}),i=Fi(t,n),o=new _t,s=Re(i,o,"#","",n,r),a=o.GetErrors(),l=yb(),d=a.map((c)=>({...c,message:l(c)}));return[s,d]}function ig(...e){let[t,n,r]=ee.Match(e,{3:(s,a,l)=>[s,a,l],2:(s,a)=>[{},s,a]}),i=Fi(t,n),o=new Ht;return ce(i,o,n,r)}function ve(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[{},i,o]});return ig(t,n,r)}function ir(...e){let[t,n,r]=ee.Match(e,{3:(s,a,l)=>[s,a,l],2:(s,a)=>[{},s,a]}),[i,o]=Sm(t,n,r);return o}class To extends Error{constructor(e,t,n){super(e);Object.defineProperty(this,"cause",{value:{source:e,errors:n,value:t},writable:!1,configurable:!1,enumerable:!1})}}function $A(e,t,n){if(!u.IsArray(n))return n;return n.map((r)=>bt(e,t.items,r))}function MA(e,t,n){return bt({...e,...t.$defs},pt(t.$ref),n)}function E8(e,t){let n=u.HasPropertyKey(t,"unevaluatedProperties")?{additionalProperties:t.unevaluatedProperties}:{},r=Nn(e,t),i=$t(r);return V(i)?Nc(i,n):i}function OA(e,t,n){let r=E8(e,t);return bt(e,r,n)}function bm(e){return u.HasPropertyKey(e,"additionalProperties")?e.additionalProperties:void 0}function FA(e,t,n){if(!u.IsObject(n)||u.IsArray(n))return n;let r=bm(t);for(let i of u.Keys(n)){if(u.HasPropertyKey(t.properties,i)){n[i]=bt(e,t.properties[i],n[i]);continue}if(u.IsBoolean(r)&&u.IsEqual(r,!0)||Ge(r)&&ve(e,r,n[i])){n[i]=bt(e,r,n[i]);continue}delete n[i]}return n}function NA(e,t,n){if(!u.IsObject(n))return n;let r=bm(t),[i,o]=[new RegExp(St(t)),Ae(t)];for(let s of u.Keys(n)){if(i.test(s)){n[s]=bt(e,o,n[s]);continue}if(u.IsBoolean(r)&&u.IsEqual(r,!0)||Ge(r)&&ve(e,r,n[s])){n[s]=bt(e,r,n[s]);continue}delete n[s]}return n}function DA(e,t,n){return u.HasPropertyKey(e,t.$ref)?bt(e,e[t.$ref],n):n}function HA(e,t,n){if(!u.IsArray(n))return n;let r=Math.min(n.length,t.items.length);for(let i=0;i<r;i++)n[i]=bt(e,t.items[i],n[i]);return u.IsGreaterThan(n.length,r)?n.slice(0,r):n}function Ye(e){return oo(e)}function _A(e,t,n){for(let r of t.anyOf){let i=bt(e,r,Ye(n));if(ve(e,r,i))return i}return n}function bt(e,t,n){return le(t)?$A(e,t,n):ke(t)?MA(e,t,n):z(t)?OA(e,t,n):V(t)?FA(e,t,n):Se(t)?NA(e,t,n):xe(t)?DA(e,t,n):re(t)?HA(e,t,n):F(t)?_A(e,t,n):n}function v8(e,t){for(let n of Rd.Keys(e)){if(Rd.HasPropertyKey(t,n))continue;t[n]=e[n]}return t}function T8(e){let t={};for(let n of Rd.Keys(e))t[n]=Pl(e[n]);return t}function k8(e){return og(ww(e))}function og(e){return e.map((t)=>Pl(t))}function Pl(e){let t=le(e)?tn(Pl(e.items),is(e)):z(e)?Ft(og(e.allOf)):F(e)?J(k8(e.anyOf)):V(e)?q(T8(e.properties)):Se(e)?ps(Ei(e),Pl(Ae(e))):re(e)?We(og(e.items)):e;return v8(e,t)}function Ns(e){return Pl(e)}function _n(...e){let[t,n,r]=ee.Match(e,{3:(o,s,a)=>[o,s,a],2:(o,s)=>[{},o,s]}),i=He.Get().unionPrioritySort?Ns(n):n;return bt(t,i,r)}var fe={};Ut(fe,{Fail:()=>$e,IsOk:()=>sg,Ok:()=>G,TryArray:()=>w8,TryBigInt:()=>ag,TryBoolean:()=>_8,TryNull:()=>q8,TryNumber:()=>W8,TryString:()=>X8,TryUndefined:()=>e5});function sg(e){return u.IsObject(e)&&u.HasPropertyKey(e,"value")}function G(e){return{value:e}}function $e(){return}function w8(e){return u.IsArray(e)?G(e):G([e])}function L8(e){return u.IsEqual(e,!0)?G(BigInt(1)):G(BigInt(0))}var R8=/^-?(0|[1-9]\d*)n$/,A8=/^-?(0|[1-9]\d*)\.\d+$/,P8=/^-?(0|[1-9]\d*)$/;function $8(e){return R8.test(e)}function M8(e){return A8.test(e)}function O8(e){return P8.test(e)}function F8(e){let t=e.toLowerCase();return $8(e)?G(BigInt(e.slice(0,e.length-1))):M8(e)?G(BigInt(e.split(".")[0])):O8(e)?G(BigInt(e)):u.IsEqual(t,"false")?G(BigInt(0)):u.IsEqual(t,"true")?G(BigInt(1)):$e()}function ag(e){return u.IsBigInt(e)?G(e):u.IsBoolean(e)?L8(e):u.IsNumber(e)?G(BigInt(Math.trunc(e))):u.IsNull(e)?G(BigInt(0)):u.IsString(e)?F8(e):u.IsUndefined(e)?G(BigInt(0)):$e()}function N8(e){return u.IsEqual(e,BigInt(0))?G(!1):u.IsEqual(e,BigInt(1))?G(!0):$e()}function D8(e){return u.IsEqual(e,0)?G(!1):u.IsEqual(e,1)?G(!0):$e()}function H8(e){return u.IsEqual(e.toLowerCase(),"false")?G(!1):u.IsEqual(e.toLowerCase(),"true")?G(!0):u.IsEqual(e,"0")?G(!1):u.IsEqual(e,"1")?G(!0):$e()}function _8(e){return u.IsBigInt(e)?N8(e):u.IsBoolean(e)?G(e):u.IsNumber(e)?D8(e):u.IsNull(e)?G(!1):u.IsString(e)?H8(e):u.IsUndefined(e)?G(!1):$e()}function U8(e){return u.IsEqual(e,BigInt(0))?G(null):$e()}function B8(e){return u.IsEqual(e,!1)?G(null):$e()}function G8(e){return u.IsEqual(e,0)?G(null):$e()}function j8(e){let t=e.toLowerCase();return u.IsEqual(t,"undefined")||u.IsEqual(t,"null")||u.IsEqual(e,"")||u.IsEqual(e,"0")?G(null):$e()}function q8(e){return u.IsBigInt(e)?U8(e):u.IsBoolean(e)?B8(e):u.IsNumber(e)?G8(e):u.IsNull(e)?G(null):u.IsString(e)?j8(e):u.IsUndefined(e)?G(null):$e()}var UA=BigInt(Number.MAX_SAFE_INTEGER),BA=BigInt(Number.MIN_SAFE_INTEGER);function z8(e){return e<=UA&&e>=BA?G(Number(e)):$e()}function K8(e){return G(e?1:0)}function V8(e){let t=+e;if(u.IsNumber(t))return G(t);let n=e.toLowerCase();if(u.IsEqual(n,"false"))return G(0);if(u.IsEqual(n,"true"))return G(1);let r=ag(e);if(sg(r))return r.value<=UA&&r.value>=BA?G(Number(r.value)):$e();return $e()}function W8(e){return u.IsBigInt(e)?z8(e):u.IsBoolean(e)?K8(e):u.IsNumber(e)?G(e):u.IsNull(e)?G(0):u.IsString(e)?V8(e):u.IsUndefined(e)?G(0):$e()}function X8(e){return u.IsBigInt(e)?G(e.toString()):u.IsBoolean(e)?G(e.toString()):u.IsNumber(e)?G(e.toString()):u.IsNull(e)?G("null"):u.IsString(e)?G(e):u.IsUndefined(e)?G(""):$e()}function Y8(e){return u.IsEqual(e,BigInt(0))?G(void 0):$e()}function J8(e){return u.IsEqual(e,!1)?G(void 0):$e()}function Z8(e){return u.IsEqual(e,0)?G(void 0):$e()}function Q8(e){let t=e.toLowerCase();return u.IsEqual(t,"undefined")||u.IsEqual(t,"null")||u.IsEqual(e,"")||u.IsEqual(e,"0")?G(void 0):$e()}function e5(e){return u.IsBigInt(e)?Y8(e):u.IsBoolean(e)?J8(e):u.IsNumber(e)?Z8(e):u.IsNull(e)?G(void 0):u.IsString(e)?Q8(e):u.IsUndefined(e)?G(e):$e()}function GA(e,t,n){return fe.TryArray(n).value.map((i)=>Je(e,t.items,i))}function jA(e,t,n){let r=fe.TryBigInt(n);return fe.IsOk(r)?r.value:n}function qA(e,t,n){let r=fe.TryBoolean(n);return fe.IsOk(r)?r.value:n}function zA(e,t,n){return Je({...e,...t.$defs},pt(t.$ref),n)}function KA(e,t,n){return Je(e,$t(t),n)}function VA(e,t,n){let r=fe.TryNumber(n);return fe.IsOk(r)?Math.trunc(r.value):n}function WA(e,t,n){let r=Nn(e,t),i=$t(r);return Je(e,i,n)}function t5(e,t,n){let r=fe.TryBigInt(n);return fe.IsOk(r)&&u.IsEqual(t.const,r.value)?r.value:n}function n5(e,t,n){let r=fe.TryBoolean(n);return fe.IsOk(r)&&u.IsEqual(t.const,r.value)?r.value:n}function r5(e,t,n){let r=fe.TryNumber(n);return fe.IsOk(r)&&u.IsEqual(t.const,r.value)?r.value:n}function i5(e,t,n){let r=fe.TryString(n);return fe.IsOk(r)&&u.IsEqual(t.const,r.value)?r.value:n}function XA(e,t,n){if(u.IsEqual(t.const,n))return n;return wb(t)?t5(e,t,n):Lb(t)?n5(e,t,n):Ud(t)?r5(e,t,n):Bd(t)?i5(e,t,n):Ve()}function YA(e,t,n){let r=fe.TryNull(n);return fe.IsOk(r)?r.value:n}function JA(e,t,n){let r=fe.TryNumber(n);return fe.IsOk(r)?r.value:n}function Cm(e,t,n,r){let i=u.Keys(r);for(let[o,s]of t)for(let a of i)if(!o.test(a))r[a]=Je(e,n,r[a]);return r}function $l(e,t,n){return ht(e)&&u.IsUndefined(n[t])}function o5(e,t,n){let r=u.EntriesRegExp(t.properties),i=u.Keys(n);for(let[o,s]of r)for(let a of i){if(!o.test(a)||$l(s,a,n))continue;n[a]=Je(e,s,n[a])}return u.HasPropertyKey(t,"additionalProperties")&&u.IsObject(t.additionalProperties)?Cm(e,r,t.additionalProperties,n):n}function ZA(e,t,n){return u.IsObjectNotArray(n)?o5(e,t,n):n}function s5(e,t,n){let r=u.EntriesRegExp(t.patternProperties),i=u.Keys(n);for(let[o,s]of r)for(let a of i)if(o.test(a))n[a]=Je(e,s,n[a]);return u.HasPropertyKey(t,"additionalProperties")&&u.IsObject(t.additionalProperties)?Cm(e,r,t.additionalProperties,n):n}function QA(e,t,n){return u.IsObjectNotArray(n)?s5(e,t,n):n}function e1(e,t,n){return u.HasPropertyKey(e,t.$ref)?Je(e,e[t.$ref],n):n}function t1(e,t,n){let r=fe.TryString(n);return fe.IsOk(r)?r.value:n}function n1(e,t,n){return Je(e,$t(t),n)}function r1(e,t,n){if(!u.IsArray(n))return n;for(let r=0;r<Math.min(t.items.length,n.length);r++)n[r]=Je(e,t.items[r],n[r]);return n}function i1(e,t,n){let r=fe.TryUndefined(n);return fe.IsOk(r)?r.value:n}function o1(e,t,n){if(t.anyOf.some((s)=>ve(e,s,n)))return n;let o=t.anyOf.map((s)=>Je(e,s,Ye(n))).find((s)=>ve(e,t,s));return u.IsUndefined(o)?n:o}function s1(e,t,n){let r=fe.TryUndefined(n);return fe.IsOk(r)?void 0:n}function Je(e,t,n){return le(t)?GA(e,t,n):pn(t)?jA(e,t,n):Kt(t)?qA(e,t,n):ke(t)?zA(e,t,n):st(t)?KA(e,t,n):It(t)?VA(e,t,n):z(t)?WA(e,t,n):ae(t)?XA(e,t,n):gr(t)?YA(e,t,n):_e(t)?JA(e,t,n):V(t)?ZA(e,t,n):Se(t)?QA(e,t,n):xe(t)?e1(e,t,n):ct(t)?t1(e,t,n):Le(t)?n1(e,t,n):re(t)?r1(e,t,n):Jn(t)?i1(e,t,n):F(t)?o1(e,t,n):gn(t)?s1(e,t,n):n}function Er(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[{},i,o]});return Je(t,n,r)}function a1(e,t,n){if(!u.IsArray(n))return n;for(let r=0;r<n.length;r++)n[r]=Ct(e,t.items,n[r]);return n}function l1(e,t,n){return Ct({...e,...t.$defs},pt(t.$ref),n)}function u1(e,t){if(!u.IsUndefined(t))return t;return u.IsFunction(e.default)?e.default():Ye(e.default)}function d1(e,t,n){let r=Nn(e,t),i=$t(r);return Ct(e,i,n)}function c1(e,t,n){if(!u.IsObject(n))return n;let r=u.Keys(t.properties);for(let i of r){let o=Ct(e,t.properties[i],n[i]);if(u.IsUndefined(o)&&(ht(t.properties[i])||!u.HasPropertyKey(t.properties[i],"default")))continue;n[i]=o}if(!Dn(t)||u.IsBoolean(t.additionalProperties))return n;for(let i of u.Keys(n)){if(r.includes(i))continue;n[i]=Ct(e,t.additionalProperties,n[i])}return n}function m1(e,t,n){if(!u.IsObject(n))return n;let[r,i]=[new RegExp(St(t)),Ae(t)];for(let o of u.Keys(n)){if(!(r.test(o)&&kn(i)))continue;n[o]=Ct(e,i,n[o])}if(!Dn(t))return n;for(let o of u.Keys(n)){if(r.test(o))continue;n[o]=Ct(e,t.additionalProperties,n[o])}return n}function f1(e,t,n){return u.HasPropertyKey(e,t.$ref)?Ct(e,e[t.$ref],n):n}function p1(e,t,n){if(!u.IsArray(n))return n;let[r,i]=[t.items,Math.max(t.items.length,n.length)];for(let o=0;o<i;o++)if(o<r.length)n[o]=Ct(e,r[o],n[o]);return n}function h1(e,t,n){for(let r of t.anyOf){let i=Ct(e,r,Ye(n));if(ve(e,r,i))return i}return n}function Ct(e,t,n){let r=kn(t)?u1(t,n):n;return le(t)?a1(e,t,r):ke(t)?l1(e,t,r):z(t)?d1(e,t,r):V(t)?c1(e,t,r):Se(t)?m1(e,t,r):xe(t)?f1(e,t,r):re(t)?p1(e,t,r):F(t)?h1(e,t,r):r}function Yr(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[{},i,o]});return Ct(t,n,r)}function Ds(e){return(...t)=>{let[n,r,i]=ee.Match(t,{3:(o,s,a)=>[o,s,a],2:(o,s)=>[{},o,s]});return e.reduce((o,s)=>s(n,r,o),i)}}function a5(e,t,n){return t["~codec"].decode(n)}function l5(e,t,n){return t["~codec"].encode(n)}function De(e,t,n,r){if(!zt(n))return r;return u.IsEqual(e,"Decode")?a5(t,n,r):l5(t,n,r)}function u5(e,t,n,r){if(!u.IsArray(r))return r;for(let i=0;i<r.length;i++)r[i]=Be(e,t,n.items,r[i]);return De(e,t,n,r)}function d5(e,t,n,r){let i=De(e,t,n,r);if(!u.IsArray(i))return i;for(let o=0;o<i.length;o++)i[o]=Be(e,t,n.items,i[o]);return i}function g1(e,t,n,r){return u.IsEqual(e,"Decode")?u5(e,t,n,r):d5(e,t,n,r)}function y1(e,t,n,r){return r=Be(e,{...t,...n.$defs},pt(n.$ref),r),De(e,t,n,r)}function x1(e){return e.reduce((t,n)=>({...t,...n}),{})}function I1(e,t){for(let n of t)if(!u.IsDeepEqual(e,n))return n;return e}function c5(e,t,n,r){if(u.IsEqual(n.allOf.length,0))return De(e,t,n,r);let i=n.allOf.map((a)=>Be(e,t,a,_n(a,Ye(r)))),s=i.every((a)=>u.IsObject(a))?x1(i):I1(r,i);return De(e,t,n,s)}function m5(e,t,n,r){if(u.IsEqual(n.allOf.length,0))return De(e,t,n,r);let i=De(e,t,n,r),o=n.allOf.map((a)=>Be(e,t,a,_n(a,Ye(i))));if(o.every((a)=>u.IsObject(a)))return x1(o);return I1(i,o)}function S1(e,t,n,r){return u.IsEqual(e,"Decode")?c5(e,t,n,r):m5(e,t,n,r)}function f5(e,t,n,r){if(!u.IsObjectNotArray(r))return r;for(let i of u.Keys(n.properties)){if(!u.HasPropertyKey(r,i)||$l(n.properties[i],i,r))continue;r[i]=Be(e,t,n.properties[i],r[i])}return De(e,t,n,r)}function p5(e,t,n,r){let i=De(e,t,n,r);if(!u.IsObjectNotArray(i))return i;for(let o of u.Keys(n.properties)){if(!u.HasPropertyKey(i,o)||$l(n.properties[o],o,i))continue;i[o]=Be(e,t,n.properties[o],i[o])}return i}function b1(e,t,n,r){return u.IsEqual(e,"Decode")?f5(e,t,n,r):p5(e,t,n,r)}function h5(e,t,n,r){if(!u.IsObjectNotArray(r))return r;let i=new RegExp(St(n));for(let o of u.Keys(r)){if(!i.test(o))continue;r[o]=Be(e,t,Ae(n),r[o])}return De(e,t,n,r)}function g5(e,t,n,r){let i=De(e,t,n,r);if(!u.IsObjectNotArray(i))return i;let o=new RegExp(St(n));for(let s of u.Keys(i)){if(!o.test(s))continue;i[s]=Be(e,t,Ae(n),i[s])}return i}function C1(e,t,n,r){return u.IsEqual(e,"Decode")?h5(e,t,n,r):g5(e,t,n,r)}function E1(e,t,n,r){return u.HasPropertyKey(t,n.$ref)?Be(e,t,t[n.$ref],r):r}function v1(e,t,n,r){return u.IsEqual(e,"Decode")?De(e,t,n,E1(e,t,n,r)):E1(e,t,n,De(e,t,n,r))}function y5(e,t,n,r){if(!u.IsArray(r))return r;for(let i=0;i<Math.min(n.items.length,r.length);i++)r[i]=Be(e,t,n.items[i],r[i]);return De(e,t,n,r)}function x5(e,t,n,r){let i=De(e,t,n,r);if(!u.IsArray(i))return r;for(let o=0;o<Math.min(n.items.length,i.length);o++)i[o]=Be(e,t,n.items[o],i[o]);return i}function T1(e,t,n,r){return u.IsEqual(e,"Decode")?y5(e,t,n,r):x5(e,t,n,r)}function I5(e,t,n,r){for(let i of n.anyOf){if(!ve(t,i,r))continue;let o=Be(e,t,i,r);return De(e,t,n,o)}return r}function S5(e,t,n,r){let i=De(e,t,n,r);for(let o of n.anyOf){let s=Be(e,t,o,Ye(i));if(!ve(t,o,s))continue;return s}return i}function k1(e,t,n,r){return u.IsEqual(e,"Decode")?I5(e,t,n,r):S5(e,t,n,r)}function Be(e,t,n,r){return le(n)?g1(e,t,n,r):ke(n)?y1(e,t,n,r):z(n)?S1(e,t,n,r):V(n)?b1(e,t,n,r):Se(n)?C1(e,t,n,r):xe(n)?v1(e,t,n,r):re(n)?T1(e,t,n,r):F(n)?k1(e,t,n,r):De(e,t,n,r)}class w1 extends To{constructor(e,t){super("Decode",e,t)}}function b5(e,t,n){if(!ve(e,t,n))throw new w1(n,ir(e,t,n));return n}function C5(e,t,n){let r=He.Get().unionPrioritySort?Ns(t):t;return Be("Decode",e,r,n)}var E5=Ds([(e,t,n)=>Ye(n),(e,t,n)=>Yr(e,t,n),(e,t,n)=>Er(e,t,n),(e,t,n)=>_n(e,t,n),(e,t,n)=>b5(e,t,n),(e,t,n)=>C5(e,t,n)]);function lg(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[{},i,o]});return E5(t,n,r)}class L1 extends To{constructor(e,t){super("Encode",e,t)}}function v5(e,t,n){if(!ve(e,t,n))throw new L1(n,ir(e,t,n));return n}function T5(e,t,n){let r=He.Get().unionPrioritySort?Ns(t):t;return Be("Encode",e,r,n)}var k5=Ds([(e,t,n)=>Ye(n),(e,t,n)=>T5(e,t,n),(e,t,n)=>Yr(e,t,n),(e,t,n)=>Er(e,t,n),(e,t,n)=>_n(e,t,n),(e,t,n)=>v5(e,t,n)]);function ug(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[{},i,o]});return k5(t,n,r)}function w5(e,t){return zt(t)||Di(e,t.items)}function L5(e,t){return zt(t)||R1({...e,...t.$defs},pt(t.$ref))}function R5(e,t){return zt(t)||t.allOf.some((n)=>Di(e,n))}function A5(e,t){return zt(t)||u.Keys(t.properties).some((n)=>Di(e,t.properties[n]))}function P5(e,t){return zt(t)||Di(e,Ae(t))}function R1(e,t){if(dg.has(t.$ref))return!1;return dg.add(t.$ref),zt(t)||u.HasPropertyKey(e,t.$ref)&&Di(e,e[t.$ref])}function $5(e,t){return zt(t)||t.items.some((n)=>Di(e,n))}function M5(e,t){return zt(t)||t.anyOf.some((n)=>Di(e,n))}function Di(e,t){return le(t)?w5(e,t):ke(t)?L5(e,t):z(t)?R5(e,t):V(t)?A5(e,t):Se(t)?P5(e,t):xe(t)?R1(e,t):re(t)?$5(e,t):F(t)?M5(e,t):zt(t)}var dg=new Set;function cg(...e){let[t,n]=ee.Match(e,{2:(r,i)=>[r,i],1:(r)=>[{},r]});return dg.clear(),Di(t,n)}class or extends Error{constructor(e,t){super(t);this.type=e}}function A1(e,t){return u.IsFunction(t.default)?t.default(t):u.IsObject(t.default)?Ye(t.default):t.default}function P1(e,t){if($i(t)&&!kn(t))throw new or(t,"Arrays with uniqueItems constraints must specify a default annotation");let n=Pi(t)?t.minItems:0;return Array.from({length:n},()=>Ze(e,t.items))}function $1(e,t){return Zn(t)?BigInt(t.exclusiveMinimum)+BigInt(1):Qn(t)?BigInt(t.minimum):BigInt(0)}function M1(e,t){return!1}function O1(e,t){let n=Ze(e,t.instanceType);return class{constructor(){Object.assign(this,n)}}}function F1(e,t){return Ze({...e,...t.$defs},pt(t.$ref))}function N1(e,t){return Ze(e,$t(t))}function D1(e,t){let n=Ze(e,t.returnType);return()=>n}function H1(e,t){return Zn(t)&&u.IsNumber(t.exclusiveMinimum)?t.exclusiveMinimum+1:Qn(t)?t.minimum:0}function _1(e,t){let n=Nn(e,t),r=$t(n);return Ze(e,r)}function U1(e,t){return t.const}function B1(e,t){throw new or(t,"Cannot create TNever types")}function G1(e,t){return null}function j1(e,t){return Zn(t)&&u.IsNumber(t.exclusiveMinimum)?t.exclusiveMinimum+1:Qn(t)?t.minimum:0}function q1(e,t){return(u.IsUndefined(t.required)?[]:t.required).reduce((r,i)=>({...r,[i]:Ze(e,t.properties[i])}),{})}function z1(e,t){if(bo(t)&&!kn(t))throw new or(t,"Record with the minProperties constraint must have a default annotation");return{}}function K1(e,t){return u.HasPropertyKey(e,t.$ref)?Ze(e,e[t.$ref]):(()=>{throw new or(t,"Unable to deref Ref")})()}function V1(e,t){if((Co(t)||Io(t))&&!kn(t))throw Error("Strings with format or pattern constraints must specify default");let r=So(t)?t.minLength:0;return"".padEnd(r)}function W1(e,t){return Symbol()}function X1(e,t){let n=Aa(t.pattern);if(ct(n))throw new or(t,"Unable to create TemplateLiteral due to infinite type expansion");return Ze(e,n)}function Y1(e,t){return Array.from({length:t.minItems},(n,r)=>Ze(e,t.items[r]))}function J1(e,t){return}function Z1(e,t){if(u.IsEqual(t.anyOf.length,0))throw Error("Unable to create Union with no variants");return Ze(e,t.anyOf[0])}function Q1(e,t){return}function Ze(e,t){return kn(t)?A1(e,t):le(t)?P1(e,t):pn(t)?$1(e,t):Kt(t)?M1(e,t):nt(t)?O1(e,t):ke(t)?F1(e,t):st(t)?N1(e,t):rt(t)?D1(e,t):It(t)?H1(e,t):z(t)?_1(e,t):ae(t)?U1(e,t):fn(t)?B1(e,t):gr(t)?G1(e,t):_e(t)?j1(e,t):V(t)?q1(e,t):Se(t)?z1(e,t):xe(t)?K1(e,t):ct(t)?V1(e,t):yr(t)?W1(e,t):Le(t)?X1(e,t):re(t)?Y1(e,t):Jn(t)?J1(e,t):F(t)?Z1(e,t):gn(t)?Q1(e,t):void 0}function vr(...e){let[t,n]=ee.Match(e,{2:(r,i)=>[r,i],1:(r)=>[{},r]});return Ze(t,n)}class Ml extends To{constructor(e,t){super("Parse",e,t)}}function O5(e,t,n){if(!ve(e,t,n))throw new Ml(n,ir(e,t,n));return n}var mg=Ds([(e,t,n)=>Ye(n),(e,t,n)=>Yr(e,t,n),(e,t,n)=>Er(e,t,n),(e,t,n)=>_n(e,t,n),(e,t,n)=>O5(e,t,n)]);function F5(...e){let[t,n,r]=ee.Match(e,{3:(o,s,a)=>[o,s,a],2:(o,s)=>[{},o,s]});if(ve(t,n,r))return r;if(He.Get().correctiveParse)return mg(t,n,r);throw new Ml(r,ir(t,n,r))}var D5=q({type:ne("insert"),path:Vt(),value:dt()}),H5=Object({type:ne("update"),path:Vt(),value:dt()}),_5=q({type:ne("delete"),path:Vt()}),EWe=J([D5,H5,_5]);class Em{constructor(e,t){this.hasCodec=cg(e,t),this.buildResult=Im(e,t),this.evaluateResult=this.buildResult.Evaluate()}IsAccelerated(){return this.evaluateResult.IsAccelerated()}Context(){return this.buildResult.Context()}Type(){return this.buildResult.Schema()}Code(){return this.evaluateResult.Code()}Check(e){return this.evaluateResult.Check(e)}Parse(e){if(this.Check(e))return e;if(He.Get().correctiveParse)return mg(this.Context(),this.Type(),e);throw new Ml(e,this.Errors(e))}Errors(e){if(this.IsAccelerated()&&this.Check(e))return[];return ir(this.Context(),this.Type(),e)}Clean(e){return _n(this.Context(),this.Type(),e)}Convert(e){return Er(this.Context(),this.Type(),e)}Create(){return vr(this.Context(),this.Type())}Default(e){return Yr(this.Context(),this.Type(),e)}Decode(e){return this.hasCodec?lg(this.Context(),this.Type(),e):this.Parse(e)}Encode(e){return this.hasCodec?ug(this.Context(),this.Type(),e):this.Parse(e)}}function fg(...e){let[t,n]=ee.Match(e,{2:(r,i)=>[r,i],1:(r)=>[{},r]});return new Em(t,n)}var G5=fg(Hc.Object({dark:Hc.String(),light:Hc.String()}));function xXe(e){return G5.Check(e)}var j5={dark:"pierre-dark-soft",light:"pierre-light"},nP=j5;function IXe(){return nP}function SXe(e){nP={dark:e.dark,light:e.light}}
|
|
1532
|
-
export{
|
|
1524
|
+
`)}function _N(e,t){let{additionLineIndex:n,deletionLineIndex:r}=e;if(e.hunkContent=t.hunkContent.map((i)=>Qf(i,n,r)),e.additionLineIndex=n+t.additionLineIndex,e.additionStart=e.additionStart+t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0)e.deletionLineIndex=r+t.deletionLineIndex,e.deletionStart=e.deletionStart+t.deletionLineIndex;e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,xd(e)}function Qf(e,t,n){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+n}}function xd(e){let t=0,n=0;for(let r of e.hunkContent)if(r.type==="context")t+=r.lines,n+=r.lines;else t+=Math.max(r.additions,r.deletions),n+=r.additions+r.deletions;e.splitLineCount=t,e.unifiedLineCount=n}function os(e){let t=0,n=0,r=0;for(let i of e.hunks)i.collapsedBefore=Math.max(kt(i.additionStart,i.additionCount)-r,0),i.splitLineStart=t+i.collapsedBefore,i.unifiedLineStart=n+i.collapsedBefore,xd(i),t+=i.collapsedBefore+i.splitLineCount,n+=i.collapsedBefore+i.unifiedLineCount,r=Tt(i.additionStart,i.additionCount);if(e.hunks.length>0){let i=e.hunks[e.hunks.length-1],o=Math.max(e.additionLines.length-Tt(i.additionStart,i.additionCount),0);t+=o,n+=o}e.splitLineCount=t,e.unifiedLineCount=n}var BI=new WeakMap;function UN(e){if(e.length>1&&e[e.length-1]==="")return e.slice(0,-1);return e}function BN(e,t){let n=Math.min(e.length,t.length),r=0;while(r<n&&e[r]===t[r])r++;let i=e.length,o=t.length;while(i>r&&o>r&&e[i-1]===t[o-1])i--,o--;if(r===i&&r===o)return;return{start:r,deletionEnd:i,additionEnd:o}}function Sd(e,t){let{hunks:n,additionLines:r}=e,i=UN(r),o=i===r?e:{...e,additionLines:i},s=KN(n,zN(o,t),e.deletionLines.length),a=XN(o,s);if(e.additionLines=i,e.hunks=a,e.editSessionDirty=!0,QN(e),Jf(e,r),!JN(n,e.hunks))return;return{regions:s.map((l)=>l.previousSpan)}}function zI(e,t,n,r){let i=Array.from(new Set(t)).filter((l)=>l>=0&&l<e.additionLines.length).sort((l,d)=>l-d);if(i.length===0)return;let{hunks:o}=e,s,a=0;for(let l of i){while(a<o.length){let m=o[a];if(l<bd(m)+m.additionCount)break;a++}let d=o[a],c=d==null?void 0:bd(d);if(c==null||l<c||s!=null&&s!==a)return Sd(e,n);s=a}if(s==null)return;if(GN(e,i,s,r,n)){e.editSessionDirty=!0;return}return Sd(e,n)}function GN(e,t,n,r,i){if(r==null||i?.ignoreWhitespace===!0||i?.stripTrailingCr===!0)return!1;let o=jN(e),s=e.hunks[n];if(s.hunkContent.some(qN))return!1;for(let a of t){let l=r.get(a),d=e.additionLines[a];if(l==null||d==null||o.has(l)||o.has(d))return!1;let c=!1;for(let m of s.hunkContent)if(m.type==="change"&&m.additions===m.deletions&&a>=m.additionLineIndex&&a<m.additionLineIndex+m.additions){c=!0;break}if(!c)return!1}return!0}function jN(e){let t=BI.get(e);if(t?.lines===e.deletionLines)return t.set;let n=new Set(e.deletionLines);return BI.set(e,{lines:e.deletionLines,set:n}),n}function qN(e){return e?.type==="change"&&(e.additions===0||e.deletions===0)}function KI(e,t){let n=new Map,{regions:r}=t;for(let i=0;i<=r.length;i++){let o=r[i-1],s=r[i],a=i===0?e.get(0):o==null?void 0:e.get(o.lastIndex+1),l=s==null?void 0:e.get(s.firstIndex),d=a?.fromStart??0,c=l?.fromEnd??0;if(d>0||c>0)n.set(i,{fromStart:d,fromEnd:c})}return n}function VI(e,t,n){let r=[];if(e.isPartial)return r;for(let[o,s]of e.hunks.entries()){let a=cn({isPartial:e.isPartial,rangeSize:s.collapsedBefore,expandedHunks:t,hunkIndex:o,collapsedContextThreshold:n});if(a.rangeSize<=n)continue;let l=eo(s),d=l-a.rangeSize;if(a.fromStart>0)r.push([d,d+a.fromStart]);if(a.fromEnd>0)r.push([l-a.fromEnd,l])}let i=mn({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:"captureExpansionAnchors"});if(i!=null&&i.fromStart>0&&i.rangeSize>n){let o=e.hunks[e.hunks.length-1],s=eo(o)+o.deletionCount;r.push([s,s+i.fromStart])}return r}function WI(e,t){let n=new Map;if(t.length===0)return n;let r=(o,s,a)=>{if(a<=s)return;let l=0,d=0;for(let[c,m]of t){if(m<=s||c>=a)continue;if(c<=s)l=Math.max(l,Math.min(m,a)-s);if(m>=a)d=Math.max(d,a-Math.max(c,s))}if(l>0||d>0)n.set(o,{fromStart:l,fromEnd:d})};for(let[o,s]of e.hunks.entries()){let a=eo(s);r(o,a-Math.max(s.collapsedBefore,0),a)}let i=e.hunks[e.hunks.length-1];if(i!=null&&!e.isPartial&&e.deletionLines.length>0)r(e.hunks.length,eo(i)+i.deletionCount,e.deletionLines.length);return n}function ep(e,t){if(e.editSessionDirty!==!0)return!1;return delete e.editSessionDirty,Object.assign(e,e.additionLines.length<=1&&e.additionLines.join("")===""?lr(e,t):yd(e,t)),!0}function zN(e,t){if(BN(e.deletionLines,e.additionLines)==null)return[];let n=Kn({name:e.prevName??e.name,contents:e.deletionLines.join("")},{name:e.name,contents:e.additionLines.join(""),lang:e.lang},t),r=[],i=0,o=0;for(let s of n.hunks){let a=s.additionCount>0?s.additionLineIndex-i:s.deletionLineIndex-o;i+=a,o+=a;for(let l of s.hunkContent){if(l.type==="context"){i+=l.lines,o+=l.lines;continue}let d=Qf(l,0,0);if(d.additions===0)d.additionLineIndex=i;if(d.deletions===0)d.deletionLineIndex=o;r.push(d),i+=d.additions,o+=d.deletions}}return r}function KN(e,t,n){let r=e.map((s,a)=>{let l=eo(s);return{deletionStart:l,deletionEnd:l+s.deletionCount,blocks:[],previousSpan:{firstIndex:a,lastIndex:a}}}),i=[],o=0;for(let s of t){let a=s.deletionLineIndex,l=a+s.deletions;while(o<r.length&&r[o].deletionEnd<a)i.push(r[o]),o++;let d=i.length>0&&VN(a,l,i[i.length-1])?i.pop():void 0;while(o<r.length&&r[o].deletionStart<=l)d=WN(d,r[o]),o++;if(d==null){let c=a,m=l;if((s.deletions===0||s.additions===0)&&n>s.deletions){let p=i[i.length-1]?.deletionEnd??0,h=r[o]?.deletionStart??n;if(a>p)c--;else if(l<h)m++}d={deletionStart:c,deletionEnd:m,blocks:[],previousSpan:void 0}}d.deletionStart=Math.min(d.deletionStart,a),d.deletionEnd=Math.max(d.deletionEnd,l),d.blocks.push(s),i.push(d)}while(o<r.length)i.push(r[o]),o++;return i}function VN(e,t,n){return e<=n.deletionEnd&&t>=n.deletionStart}function WN(e,t){if(e==null)return t;if(e.deletionStart=Math.min(e.deletionStart,t.deletionStart),e.deletionEnd=Math.max(e.deletionEnd,t.deletionEnd),e.blocks.push(...t.blocks),t.previousSpan!=null)e.previousSpan??={...t.previousSpan},e.previousSpan.firstIndex=Math.min(e.previousSpan.firstIndex,t.previousSpan.firstIndex),e.previousSpan.lastIndex=Math.max(e.previousSpan.lastIndex,t.previousSpan.lastIndex);return e}function XN(e,t){let n=[],r=0,i=0;for(let o of t){let s=o.deletionStart-r;if(s<0)throw Error("buildRegionHunks: overlapping old-side regions");r+=s,i+=s;let a=i,l=[];for(let c of o.blocks){let m=c.deletionLineIndex-r,p=c.additionLineIndex-i;if(m<0||m!==p)throw Error("buildRegionHunks: canonical block context mismatch");GI(l,m,i,r),r+=m,i+=p,l.push({...c}),r+=c.deletions,i+=c.additions}let d=o.deletionEnd-r;if(d<0)throw Error("buildRegionHunks: block exceeds its old-side region");GI(l,d,i,r),r+=d,i+=d,n.push(YN(e,{additionStart:a,additionEnd:i,deletionStart:o.deletionStart,deletionEnd:o.deletionEnd},l))}if(e.deletionLines.length-r!==e.additionLines.length-i)throw Error("buildRegionHunks: trailing context mismatch");return n}function YN(e,t,n){let r=t.additionEnd-t.additionStart,i=t.deletionEnd-t.deletionStart,o=0,s=0;for(let l of n)if(l.type==="change")o+=l.additions,s+=l.deletions;let a={collapsedBefore:0,additionStart:Id(t.additionStart,r),additionCount:r,additionLines:o,additionLineIndex:qI(t.additionStart,r),deletionStart:Id(t.deletionStart,i),deletionCount:i,deletionLines:s,deletionLineIndex:qI(t.deletionStart,i),hunkContent:n,hunkSpecs:`@@ -${Id(t.deletionStart,i)},${i} +${Id(t.additionStart,r)},${r} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return xd(a),a}function GI(e,t,n,r){if(t>0)e.push({type:"context",lines:t,additionLineIndex:n,deletionLineIndex:r})}function JN(e,t){if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(eo(r)!==eo(i)||r.deletionCount!==i.deletionCount||bd(r)!==bd(i)||r.additionCount!==i.additionCount||r.splitLineCount!==i.splitLineCount||!ZN(r,i))return!0}return!1}function ZN(e,t){let n=jI(e),r=jI(t);while(!0){let i=n.next(),o=r.next();if(i.done===!0||o.done===!0)return i.done===o.done;if(i.value[0]!==o.value[0]||i.value[1]!==o.value[1])return!1}}function*jI(e){for(let t of e.hunkContent){if(t.type==="context"){for(let r=0;r<t.lines;r++)yield[t.deletionLineIndex+r,t.additionLineIndex+r];continue}let n=Math.max(t.deletions,t.additions);for(let r=0;r<n;r++)yield[r<t.deletions?t.deletionLineIndex+r:void 0,r<t.additions?t.additionLineIndex+r:void 0]}}function bd(e){return kt(e.additionStart,e.additionCount)}function eo(e){return kt(e.deletionStart,e.deletionCount)}function Id(e,t){return t===0?e:e+1}function qI(e,t){return t===0?e-1:e}function QN(e){os(e);for(let t=0;t<e.hunks.length;t++)Zf(e,t)}function to(e){let t=e.lang??tt(e.name),n=e.lang??(e.prevName!=null?tt(e.prevName):"text");return t==="text"&&n==="text"}function ur(e,t){return Cn(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function ya(e){return K({tagName:"div",properties:{"data-content-buffer":"","data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function xa(e){return K({tagName:"div",children:[K({tagName:"span",children:[un("No newline at end of file")]})],properties:{"data-no-newline":"","data-line-type":e,"data-column-content":""}})}function tp(e){return K({tagName:"div",children:[Xi({name:e==="both"?"diffs-icon-expand-all":"diffs-icon-expand",properties:{"data-icon":""}})],properties:{role:"button","data-expand-button":"","data-expand-both":e==="both"?"":void 0,"data-expand-up":e==="up"?"":void 0,"data-expand-down":e==="down"?"":void 0}})}function no({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:o,isLastHunk:s}){let a=0,l=[];if(e==="metadata"&&t!=null)l.push(K({tagName:"div",children:[un(t)],properties:{"data-separator-wrapper":""}}));if((e==="line-info"||e==="line-info-basic")&&t!=null){let d=[];if(n!=null)if(!r)d.push(tp(!o&&!s?"both":o?"down":"up")),a++;else{if(!o)d.push(tp("up")),a++;if(!s)d.push(tp("down")),a++}if(d.push(K({tagName:"div",children:[K({tagName:"span",children:[un(t)],properties:{"data-unmodified-lines":""}})],properties:{"data-separator-content":""}})),r&&n!=null)d.push(K({tagName:"div",children:[un("Expand all")],properties:{role:"button","data-expand-button":"","data-expand-all-button":""}}));l.push(K({tagName:"div",children:d,properties:{"data-separator-wrapper":"","data-separator-multi-button":a>1?"":void 0}}))}if(e==="custom"&&i!=null)l.push(K({tagName:"slot",properties:{name:i}}));return K({tagName:"div",children:l,properties:{"data-separator":l.length===0?"simple":e,"data-expand-index":n,"data-separator-first":o?"":void 0,"data-separator-last":s?"":void 0}})}function XI(e,t){return`hunk-separator-${e}-${t}`}function YI(e){let t=e.at(-1);if(t==null)return 0;return Math.max(Tt(t.additionStart,t.additionCount),Tt(t.deletionStart,t.deletionCount))}function np({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 Ia({item:e,arr:t,enableJoin:n,isNeutral:r=!1,isLastItem:i=!1}){let o=t[t.length-1];if(o==null||i||!n){t.push([r?0:1,e.value]);return}let s=o[0]===0;if(r===s||r&&e.value.length===1&&!s){o[1]+=e.value;return}t.push([r?0:1,e.value])}var eD={forcePlainText:!1};function JI(e,t,n,{forcePlainText:r,startingLine:i,totalLines:o,expandedHunks:s,collapsedContextThreshold:a=1}=eD){if(r)i??=0,o??=1/0;else i=0,o=1/0;let l=i>0||o<1/0,d=typeof n.theme==="string"?t.getTheme(n.theme).type:void 0,c=Du({theme:n.theme,highlighter:t}),m=r&&!l&&(e.unifiedLineCount>1000||e.splitLineCount>1000)?"none":n.lineDiffType,p={deletionLines:[],additionLines:[]},{maxLineDiffLength:h}=n,x=!r&&!e.isPartial,I=r?s:void 0,v=new Map;function S(E){let w=x?0:E,T=v.get(w)??nD();return v.set(w,T),T}function b(E,w,T,L){if(l){let R=T.at(-1);if(R==null||R.targetIndex+R.count!==w)R={targetIndex:w,originalOffset:L.length,count:0},T.push(R);R.count++}L.push(E)}zn({diff:e,diffStyle:"both",startingLine:i,totalLines:o,expandedHunks:l?I:!0,collapsedContextThreshold:a,callback:({hunkIndex:E,additionLine:w,deletionLine:T,type:L})=>{let R=S(E),A=w!=null?w.splitLineIndex:T.splitLineIndex;if(L==="change"&&w!=null&&T!=null)tD({additionLine:e.additionLines[w.lineIndex],deletionLine:e.deletionLines[T.lineIndex],deletionLineIndex:R.deletionContent.length,additionLineIndex:R.additionContent.length,deletionDecorations:R.deletionDecorations,additionDecorations:R.additionDecorations,lineDiffType:m,maxLineDiffLength:h});if(T!=null)b(e.deletionLines[T.lineIndex],T.lineIndex,R.deletionSegments,R.deletionContent),R.deletionInfo.push({type:L==="change"?"change-deletion":L,lineNumber:T.lineNumber,altLineNumber:L==="change"?void 0:w.lineNumber??void 0,lineIndex:`${T.unifiedLineIndex},${A}`});if(w!=null)b(e.additionLines[w.lineIndex],w.lineIndex,R.additionSegments,R.additionContent),R.additionInfo.push({type:L==="change"?"change-addition":L,lineNumber:w.lineNumber,altLineNumber:L==="change"?void 0:T.lineNumber??void 0,lineIndex:`${w.unifiedLineIndex},${A}`})}});for(let E of v.values()){if(E.deletionContent.length===0&&E.additionContent.length===0)continue;let w={name:e.prevName??e.name,contents:E.deletionContent.value},T={name:e.name,contents:E.additionContent.value},{deletionLines:L,additionLines:R}=rD({deletionFile:w,deletionInfo:E.deletionInfo,deletionDecorations:E.deletionDecorations,additionFile:T,additionInfo:E.additionInfo,additionDecorations:E.additionDecorations,highlighter:t,options:n,languageOverride:r?"text":e.lang});if(x){p.deletionLines=L,p.additionLines=R;continue}if(E.deletionSegments.length>0)for(let A of E.deletionSegments)for(let O=0;O<A.count;O++)p.deletionLines[A.targetIndex+O]=L[A.originalOffset+O];else la(p.deletionLines,L);if(E.additionSegments.length>0)for(let A of E.additionSegments)for(let O=0;O<A.count;O++)p.additionLines[A.targetIndex+O]=R[A.originalOffset+O];else la(p.additionLines,R)}return{code:p,themeStyles:c,baseThemeType:d}}function tD({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:o,lineDiffType:s,maxLineDiffLength:a}){if(e==null||t==null||s==="none")return;if(e=bn(e),t=bn(t),e.length>a||t.length>a)return;let l=s==="char"?Bf(e,t):Kf(e,t),d=[],c=[],m=s==="word-alt",p=l.at(-1);for(let x of l){let I=x===p;if(!x.added&&!x.removed)Ia({item:x,arr:d,enableJoin:m,isNeutral:!0,isLastItem:I}),Ia({item:x,arr:c,enableJoin:m,isNeutral:!0,isLastItem:I});else if(x.removed)Ia({item:x,arr:d,enableJoin:m,isLastItem:I});else Ia({item:x,arr:c,enableJoin:m,isLastItem:I})}let h=0;for(let x of d){if(x[0]===1)i.push(np({line:n,spanStart:h,spanLength:x[1].length}));h+=x[1].length}h=0;for(let x of c){if(x[0]===1)o.push(np({line:r,spanStart:h,spanLength:x[1].length}));h+=x[1].length}}function nD(){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 rD({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:o,additionDecorations:s,languageOverride:a,options:{theme:l,...d}}){let c=a??tt(e.name),m=a??tt(t.name),{state:p,transformers:h}=Fu(d.useTokenTransformer),x=(()=>typeof l==="string"?{...d,lang:"text",theme:l,transformers:h,decorations:void 0,defaultColor:!1,cssVariablePrefix:jt("token"),tokenizeTimeLimit:0}:{...d,lang:"text",themes:l,transformers:h,decorations:void 0,defaultColor:!1,cssVariablePrefix:jt("token"),tokenizeTimeLimit:0})();return{deletionLines:(()=>{if(e.contents==="")return[];return x.lang=c,p.lineInfo=n,x.decorations=o,ua(i.codeToHast(bn(e.contents),x))})(),additionLines:(()=>{if(t.contents==="")return[];return x.lang=m,x.decorations=s,p.lineInfo=r,ua(i.codeToHast(bn(t.contents),x))})()}}var iD=-1,rS=class{options;annotationSlotName;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++iD}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLangs=["text"];renderCache;pendingHighlightResult;pendingStructuralRows;editSessionActive=!1;constructor(e={theme:Oe},t=dn,n,r){if(this.options=e,this.annotationSlotName=t,this.onRenderUpdate=n,this.workerManager=r,r?.isWorkingPool()!==!0)this.highlighter=Qt(e.theme??Oe)?jn():void 0}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this),this.endEditSession()}beginEditSession(e,t){let{editSessionActive:n,renderCache:r}=this;if(this.editSessionActive=!0,!n)this.pendingHighlightResult=void 0;if(this.diff=e,!e.isPartial&&e.additionLines.length===0){Object.assign(e,ga(e,this.options.parseDiffOptions)),this.markEditSessionPass(e),this.clearRenderCache();return}if(r==null)return;if(n&&r.diff===e)return;let{options:i}=this.getRenderOptions(e),o=r.diff===e,s=t!=null&&ze(r.diff,t),{result:a}=r;if(!r.highlighted||a==null||!ur(r.options,i)||!o&&!s){this.clearRenderCache();return}if(o)return;this.renderCache={diff:e,options:i,highlighted:!0,result:{...a,code:{...a.code,additionLines:[...a.code.additionLines]}},renderRange:r.renderRange}}endEditSession(){this.editSessionActive=!1,this.pendingHighlightResult=void 0}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}refreshHighlightedResult(){let{diff:e,renderCache:t,workerManager:n}=this;if(e==null||t==null||!ze(t.diff,e)||to(e)||Sa(e,this.getTokenizeMaxLength()))return Promise.resolve();if(!this.editSessionActive&&n?.isWorkingPool()===!0&&e.cacheKey!=null)return n.evictDiffFromCache(e.cacheKey),n.primeDiffHighlightCache(e).then(()=>{this.applyRefreshedResult(e,n.getDiffResultCache(e))}).catch((r)=>this.onHighlightError(r));return this.asyncHighlight(e).then((r)=>this.applyRefreshedResult(e,r)).catch((r)=>this.onHighlightError(r))}applyRefreshedResult(e,t){let{diff:n,renderCache:r}=this;if(t==null||n==null||r==null||!ze(n,e)||!ze(r.diff,e)||this.editSessionActive)return;let{options:i}=this.getRenderOptions(n);if(!ur(i,t.options))return;this.pendingHighlightResult={diff:n,options:t.options,highlighted:!0,result:t.result},this.onRenderUpdate?.()}get diffCache(){return this.renderCache?.diff??this.diff}clearRenderCache(){this.renderCache=void 0,this.pendingHighlightResult=void 0,this.pendingStructuralRows=void 0}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){let r={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};if(t==="up"||t==="both")r.fromStart+=n;if(t==="down"||t==="both")r.fromEnd+=n;if(this.renderCache?.highlighted!==!0)this.clearRenderCache();this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??nS}getExpandedHunksMap(){return this.expandedHunks}setExpandedHunksMap(e){this.expandedHunks=e}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(let t of e){let n=(()=>{switch(t.side){case"deletions":return this.deletionAnnotations;case"additions":return this.additionAnnotations}})(),r=n[t.lineNumber]??[];n[t.lineNumber]=r,r.push(t)}}updateRenderCache(e,t,n=!1){this.pendingStructuralRows=void 0;let{renderCache:r}=this;if(r==null)return!1;let{result:i,diff:o}=r;if(i==null)return!1;if(o.isPartial)throw Error("Could not update render cache for partial diff");let s=i.code.additionLines,a=this.pendingStructuralRows=n?new Map:void 0,l=[],d=new Map;for(let[m,p]of e){let h=s[m]?.properties??{},x=p.map((E)=>E[2]).join(""),I=m<o.additionLines.length,v=I?o.additionLines[m]??"":"",S=bn(v);if(a==null&&I){if(o.additionLines[m]=Lu(v,x),S!==x)l.push(m),d.set(m,v)}let b={type:"element",tagName:"div",properties:{"data-line":h["data-line"]??m+1,"data-line-index":h["data-line-index"]??m,"data-line-type":h["data-line-type"]??"context"},children:p.map(([E,w,T])=>{if(E===0&&w===""){if(T==="")return{type:"element",tagName:"br",properties:{},children:[]};return{type:"text",value:T}}return{type:"element",tagName:"span",properties:{"data-char":E,style:`color:${w};`},children:[{type:"text",value:T}]}})};if(a!=null)a.set(m,b);else s[m]=b}let c=!1;if(l.length>0)if(this.editSessionActive)if(o.additionLines.length<=1&&o.additionLines.join("")==="")this.applyRecomputePreservingSessionType(o,ga(o,this.options.parseDiffOptions)),c=!0;else if(gd(o,o.additionLines))this.applyRecomputePreservingSessionType(o,ha(o,o.additionLines,this.options.parseDiffOptions)),c=!0;else{let m=zI(o,l,this.options.parseDiffOptions,d);this.applyExpansionRemap(m),c=m!=null}else Object.assign(o,UI(o,l,this.options.parseDiffOptions));return i.baseThemeType=t,r.isDirty=!0,c}applyExpansionRemap(e){if(e!=null)this.expandedHunks=KI(this.expandedHunks,e)}applyDocumentChange(e){let{pendingStructuralRows:t,renderCache:n}=this;if(this.pendingStructuralRows=void 0,n==null)return;let{diff:r,result:i}=n;if(i==null)return;if(r.isPartial)throw Error("Could not apply document change for partial diff");let{additionLines:o}=r;if(r.additionLines=lD(e),i.code.additionLines=aD(o,r.additionLines,i.code.additionLines,e),r.additionLines.length<=1&&r.additionLines.join("")==="")this.applyRecomputePreservingSessionType(r,ga(r,this.options.parseDiffOptions)),i.code.additionLines[0]=op(0,e.getLineText(0));else if(this.editSessionActive)this.applySessionDocumentChange(r);else Object.assign(r,yd(r,this.options.parseDiffOptions));if(t!=null){for(let[s,a]of t)if(s<i.code.additionLines.length)i.code.additionLines[s]=a}n.isDirty=!0}applySessionDocumentChange(e){let{parseDiffOptions:t}=this.options,n=e.additionLines;if(gd(e,n)){this.applyRecomputePreservingSessionType(e,ha(e,n,t));return}this.applyExpansionRemap(Sd(e,t))}applyRecomputePreservingSessionType(e,t){let n=this.editSessionActive?e.type:void 0;if(Object.assign(e,t),n!=null)e.type=n;this.markEditSessionPass(e)}markEditSessionPass(e){if(!this.editSessionActive)return;e.editSessionDirty=!0}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){let n=t==="change"?e==="deletions"?"change-deletion":"change-addition":t;return{gutterLineType:n,contentProperties:{"data-line-type":n}}}createAnnotationElement=(e)=>aa(e);getOptionsWithDefaults(){let{diffIndicators:e="bars",diffStyle:t="split",disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:o=!1,collapsed:s=!1,expandUnchanged:a=!1,collapsedContextThreshold:l=1,expansionLineCount:d=100,hunkSeparators:c="line-info",lineDiffType:m="word-alt",maxLineDiffLength:p=1000,overflow:h="scroll",stickyHeader:x=!1,theme:I=Oe,headerRenderMode:v="default",tokenizeMaxLineLength:S=1000,tokenizeMaxLength:b=tS,useTokenTransformer:E=!1,useCSSClasses:w=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:o,collapsed:s,expandUnchanged:a,collapsedContextThreshold:l,expansionLineCount:d,hunkSeparators:c,lineDiffType:m,maxLineDiffLength:p,overflow:h,stickyHeader:x,theme:this.workerManager?.getDiffRenderOptions().theme??I,headerRenderMode:v,tokenizeMaxLineLength:S,tokenizeMaxLength:b,useTokenTransformer:E,useCSSClasses:w}}async initializeHighlighter(){return this.highlighter=await sr($u(this.computedLangs,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=Sa(e,this.getTokenizeMaxLength()),r=this.workerManager?.getDiffResultCache(e);if(r!=null&&!ur(t,r.options))r=void 0;if(this.renderCache??={diff:e,hydrated:!0,highlighted:!n&&!to(e),options:t,result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){if(this.renderCache.result==null&&!n)this.workerManager.highlightDiffAST(this,this.diff)}else if(this.highlighter==null)this.computedLangs=ip(e),this.initializeHighlighter()}getLocalHighlightTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??Oe}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getDiffRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let a=this.workerManager.getDiffRenderOptions();if(this.editSessionActive&&a.useTokenTransformer!==!0)return{...a,useTokenTransformer:!0};return a}let{theme:r,tokenizeMaxLineLength:i,lineDiffType:o,maxLineDiffLength:s}=this.getOptionsWithDefaults();return{theme:r,useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:i,lineDiffType:o,maxLineDiffLength:s}})();this.getOptionsWithDefaults();let{renderCache:n}=this;if(n?.result==null)return{options:t,forceHighlight:!0};if(!ze(e,n.diff)||!ur(t,n.options))return{options:t,forceHighlight:!0};return{options:t,forceHighlight:!1}}getDiffForNextRender(e){let{options:t}=this.getRenderOptions(e);if(this.getReadyRenderResult(e,t)!=null)return e;if(this.renderCache==null)return e;if(ze(this.renderCache.diff,e))return this.renderCache.diff;let n=!(e.additionLines.length>0||e.deletionLines.length>0)||to(e)||Sa(e,this.getTokenizeMaxLength());return this.canRenderDiff(e,t,n)?e:this.renderCache.diff}canRenderDiff(e,t,n){let{renderCache:r}=this;if(r==null||ze(r.diff,e))return!0;if(n)return r.result==null&&r.hydrated!==!0||this.workerManager?.isWorkingPool()===!0||this.highlighter!=null&&Qt(t.theme);if(r.result==null&&r.hydrated!==!0)return!0;if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0)return!r.highlighted;return this.highlighter!=null&&Qt(t.theme)}renderDiff(e=this.diff,t=Zo){if(this.diff=e,e==null){this.pendingHighlightResult=void 0;return}let{expandUnchanged:n,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),{options:i,forceHighlight:o}=this.getRenderOptions(e),s=this.getReadyRenderResult(e,i);if(this.pendingHighlightResult=void 0,s!=null)this.renderCache={...s,diff:e,renderRange:void 0},o=!1;this.renderCache??={diff:e,highlighted:!1,options:i,result:void 0,renderRange:void 0};let a=e.additionLines.length>0||e.deletionLines.length>0,l=!a||to(e)||Sa(e,this.getTokenizeMaxLength()),d=this.canRenderDiff(e,i,l),c=!ze(e,this.renderCache.diff),m=!ci(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){let p=this.renderCache.result==null&&this.renderCache.highlighted&&!l&&!c&&Yi(t);if(d&&!p&&(l||this.renderCache.result==null||!this.renderCache.highlighted&&(c||m))){if(this.renderCache.diff=e,this.renderCache.options=i,this.renderCache.highlighted=!1,this.renderCache.result==null||c||m||o)this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,Yi(t)?!0:n?!0:this.expandedHunks,r);this.renderCache.renderRange=t}if(!l&&a&&(!this.renderCache.highlighted||o))this.workerManager.highlightDiffAST(this,e)}else{this.computedLangs=ip(e),this.highlighter??=jn();let p=this.highlighter!=null&&Qt(i.theme),h=this.highlighter!=null&&ni(this.computedLangs),x=!l&&h;if(d&&this.highlighter!=null&&p&&(o||l||!this.renderCache.highlighted&&x||this.renderCache.result==null)){let{result:I,options:v}=this.renderDiffWithHighlighter(e,this.highlighter,l||!h);this.renderCache={diff:e,options:v,highlighted:x,result:I,renderRange:void 0}}if(!p||!l&&!h)this.asyncHighlight(e).then(({result:I,options:v})=>{this.applyHighlightResult(e,I,v,!l)})}return this.renderCache.result!=null?this.processDiffResult(this.renderCache.diff,t,this.renderCache.result):void 0}async asyncRender(e,t=Zo){this.diff=e;let{result:n}=await this.asyncHighlight(e);return this.processDiffResult(e,t,n)}createPreElement(e,t,n){let{diffIndicators:r,disableBackground:i,disableLineNumbers:o,overflow:s}=this.getOptionsWithDefaults();return Pu({type:"diff",diffIndicators:r,disableBackground:i,disableLineNumbers:o,overflow:s,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e){let t=Sa(e,this.getTokenizeMaxLength());this.computedLangs=t?["text"]:ip(e);let n=this.highlighter!=null&&Qt(this.getLocalHighlightTheme()),r=t||this.highlighter!=null&&ni(this.computedLangs);if(this.highlighter==null||!n||!r)this.highlighter=await this.initializeHighlighter();return this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults(),o=JI(e,t,r,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:i});if(this.editSessionActive&&e.additionLines.length===1&&e.additionLines[0]===""&&o.code.additionLines[0]==null){let s;if(zn({diff:e,diffStyle:"both",expandedHunks:n?!0:void 0,collapsedContextThreshold:i,callback:({additionLine:a})=>{if(a?.lineIndex!==0)return;return s=a,!0}}),s==null)throw Error("DiffHunksRenderer: missing empty addition line");o.code.additionLines[0]=op(0,"",s.unifiedLineIndex,s.splitLineIndex)}return{result:o,options:r}}onHighlightSuccess(e,t,n,r=!0){if(this.editSessionActive)return;this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){let{diff:i,renderCache:o}=this;if(i==null||o==null||!ze(i,e)||!ur(n,this.getRenderOptions(i).options))return;if(!(o.result==null||!o.highlighted||!ur(o.options,n)||!ze(o.diff,i)))return;this.pendingHighlightResult={diff:i,options:n,highlighted:r,result:t},this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getDiffResultCache(e);if(n==null||!ur(t,n.options))return;return n}getReadyRenderResult(e,t){let{pendingHighlightResult:n}=this;if(n!=null&&ze(n.diff,e)&&ur(n.options,t))return n;let r=this.getMatchingWorkerResultCache(e,t);if(r==null||this.hasHighlightedRenderCache(e,t))return;return{diff:e,highlighted:!0,...r}}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&ze(e,n.diff)&&ur(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let{diffStyle:o,disableFileHeader:s,expandUnchanged:a,expansionLineCount:l,collapsedContextThreshold:d,hunkSeparators:c}=this.getOptionsWithDefaults(),m=this.renderCache?.isDirty??!1,p=o==="unified",h=uD(e,this.options.loadDiffFiles!=null),x=!e.isPartial||h,I=[],v=[],S=[],b=[],{additionLines:E,deletionLines:w}=n,T={rowCount:0,hunkSeparators:c,additionsContentAST:I,deletionsContentAST:v,unifiedContentAST:S,unifiedGutterAST:ui(),deletionsGutterAST:ui(),additionsGutterAST:ui(),expansionLineCount:l,hunkData:b,incrementRowCount(j=1){T.rowCount+=j},pushToGutter(j,ie){switch(j){case"unified":T.unifiedGutterAST.children.push(ie);break;case"deletions":T.deletionsGutterAST.children.push(ie);break;case"additions":T.additionsGutterAST.children.push(ie)}}},L=Uf({fileDiff:e,errorPrefix:"DiffHunksRenderer.processDiffResult"}),R={size:0,side:void 0,increment(){this.size+=1},flush(){if(o==="unified")return;if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}if(this.side==="additions")T.pushToGutter("additions",en(void 0,"buffer",this.size)),I?.push(ya(this.size));else T.pushToGutter("deletions",en(void 0,"buffer",this.size)),v?.push(ya(this.size));this.size=0,this.side=void 0}},A=(j,ie,Ee,Mt,Ie)=>{T.pushToGutter(j,vu(ie,Ee,Mt,Ie))};function O(j){if(R.flush(),o==="unified")rp("unified",j,T);else rp("deletions",j,T),rp("additions",j,T)}if(this.pushFileLevelAnnotations(e,o,t,T),zn({diff:e,diffStyle:o,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:a?!0:this.expandedHunks,collapsedContextThreshold:d,callback:({hunkIndex:j,hunk:ie,collapsedBefore:Ee,collapsedAfter:Mt,additionLine:Ie,deletionLine:Me,type:Qe})=>{let gt=Me!=null?Me.splitLineIndex:Ie.splitLineIndex,xn=Ie!=null?Ie.unifiedLineIndex:Me.unifiedLineIndex;if(o==="split"&&Qe!=="change")R.flush();if(Ee>0)O({hunkIndex:j,collapsedLines:Ee,rangeSize:Math.max(ie?.collapsedBefore??0,0),hunkSpecs:ie?.hunkSpecs,isFirstHunk:j===0,isLastHunk:!1,isExpandable:x});let Rn=o==="unified"?xn:gt,An={type:Qe,hunkIndex:j,lineIndex:Rn,unifiedLineIndex:xn,splitLineIndex:gt,deletionLine:Me,additionLine:Ie};if(o==="unified"){let at=this.getUnifiedInjectedRowsForLine?.(An);if(at?.before!=null)ZI(at.before,T);let sn=Me!=null?w[Me.lineIndex]:void 0,In=Ie!=null?E[Ie.lineIndex]:void 0;if(sn==null&&In==null)throw console.error("DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong",{file:e.name}),Error("DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong");let _i=Qe==="change"?Ie!=null?"change-addition":"change-deletion":Qe,Un=this.getUnifiedLineDecoration({type:Qe,lineType:_i,additionLineIndex:Ie?.lineIndex,deletionLineIndex:Me?.lineIndex});if(A("unified",Un.gutterLineType,Ie!=null?Ie.lineNumber:Me.lineNumber,`${xn},${gt}`,Un.gutterProperties),In!=null)In=Ed(In,Un.contentProperties,m&&Ie!=null?{"data-line":Ie.lineNumber,"data-line-index":`${xn},${gt}`}:void 0);else if(sn!=null)sn=Ed(sn,Un.contentProperties,m&&Me!=null?{"data-line":Me.lineNumber,"data-line-index":`${xn},${gt}`}:void 0);if(Cd({diffStyle:"unified",type:Qe,deletionLine:sn,additionLine:In,unifiedSpan:this.getAnnotations("unified",Me?.lineNumber,Ie?.lineNumber,j,Rn),createAnnotationElement:(wr)=>this.createAnnotationElement(wr),context:T}),at?.after!=null)ZI(at.after,T)}else{let at=this.getSplitInjectedRowsForLine?.(An);if(at?.before!=null)QI(at.before,T,R);let sn=Me!=null?w[Me.lineIndex]:void 0,In=Ie!=null?E[Ie.lineIndex]:void 0,_i=this.getSplitLineDecoration({side:"deletions",type:Qe,lineIndex:Me?.lineIndex}),Un=this.getSplitLineDecoration({side:"additions",type:Qe,lineIndex:Ie?.lineIndex});if(sn==null&&In==null)throw console.error("DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong",{file:e.name}),Error("DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong");let wr=(()=>{if(Qe==="change"){if(In==null)return"additions";else if(sn==null)return"deletions"}})();if(wr!=null){if(R.side!=null&&R.side!==wr)R.flush();R.side=wr,R.increment()}else if(Qe==="change")R.flush();let Qr=this.getAnnotations("split",Me?.lineNumber,Ie?.lineNumber,j,Rn);if(Qr!=null&&R.size>0)R.flush();if(Me!=null){let Pn=Ed(sn,_i.contentProperties,m?{"data-line":Me.lineNumber,"data-line-index":`${Me.unifiedLineIndex},${gt}`}:void 0);if(A("deletions",_i.gutterLineType,Me.lineNumber,`${Me.unifiedLineIndex},${gt}`,_i.gutterProperties),Pn!=null)sn=Pn}if(Ie!=null){let Pn=Ed(In,Un.contentProperties,m?{"data-line":Ie.lineNumber,"data-line-index":`${Ie.unifiedLineIndex},${gt}`}:void 0);if(A("additions",Un.gutterLineType,Ie.lineNumber,`${Ie.unifiedLineIndex},${gt}`,Un.gutterProperties),Pn!=null)In=Pn}if(Cd({diffStyle:"split",type:Qe,additionLine:In,deletionLine:sn,...Qr,createAnnotationElement:(Pn)=>this.createAnnotationElement(Pn),context:T}),at?.after!=null)QI(at.after,T,R)}let Hi=o==="split"&&ie!=null&>===ie.splitLineStart+ie.splitLineCount-1,Zt=j===e.hunks.length-1&&ie!=null&&(o==="split"?gt===ie.splitLineStart+ie.splitLineCount-1:xn===ie.unifiedLineStart+ie.unifiedLineCount-1),wo=Hi?ie.noEOFCRDeletions:!1,Bs=Hi?ie.noEOFCRAdditions:!1,kr=(Me?.noEOFCR??!1)||wo,Tr=(Ie?.noEOFCR??!1)||Bs;if(Tr||kr){if(o==="split")R.flush();if(kr){let at=Qe==="context"||Qe==="context-expanded"?Qe:"change-deletion";if(o==="unified")T.unifiedContentAST.push(xa(at)),T.pushToGutter("unified",en(at,"metadata",1));else if(T.deletionsContentAST.push(xa(at)),T.pushToGutter("deletions",en(at,"metadata",1)),!Tr)T.pushToGutter("additions",en(void 0,"buffer",1)),T.additionsContentAST.push(ya(1))}if(Tr){let at=Qe==="context"||Qe==="context-expanded"?Qe:"change-addition";if(o==="unified")T.unifiedContentAST.push(xa(at)),T.pushToGutter("unified",en(at,"metadata",1));else if(T.additionsContentAST.push(xa(at)),T.pushToGutter("additions",en(at,"metadata",1)),!kr)T.pushToGutter("deletions",en(void 0,"buffer",1)),T.deletionsContentAST.push(ya(1))}T.incrementRowCount(1)}if(c!=="simple"&&c!=="metadata"&&(Mt>0||Zt&&h))O({hunkIndex:Qe==="context-expanded"?j:j+1,collapsedLines:Zt&&h?"unknown":Mt,rangeSize:L,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:x});T.incrementRowCount(1)}}),o==="split")R.flush();let D=Math.max(YI(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),X=t.bufferBefore>0||t.bufferAfter>0,N=!p&&e.type!=="deleted",B=!p&&e.type!=="new",pe=T.rowCount>0||X;I=N&&pe?I:void 0,v=B&&pe?v:void 0,S=p&&pe?S:void 0;let ye=this.createPreElement(v!=null&&I!=null,D);return{fileDiff:e,unifiedGutterAST:p&&pe?T.unifiedGutterAST.children:void 0,unifiedContentAST:S,deletionsGutterAST:B&&pe?T.deletionsGutterAST.children:void 0,deletionsContentAST:v,additionsGutterAST:N&&pe?T.additionsGutterAST.children:void 0,additionsContentAST:I,hunkData:b,preNode:ye,themeStyles:r,baseThemeType:i,headerElement:!s?this.renderHeader(e):void 0,totalLines:D,rowCount:T.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:""}}renderCodeAST(e,t){let n=e==="unified"?t.unifiedGutterAST:e==="deletions"?t.deletionsGutterAST:t.additionsGutterAST,r=e==="unified"?t.unifiedContentAST:e==="deletions"?t.deletionsContentAST:t.additionsContentAST;if(n==null||r==null)return;let i=ui(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,Ru(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators==="line-info",r=this.renderCodeAST("unified",e);if(r!=null)return t.push(K({tagName:"code",children:r,properties:{"data-code":"","data-container-size":n?"":void 0,"data-unified":""}})),{...e.preNode,children:t};let i=this.renderCodeAST("deletions",e);if(i!=null)t.push(K({tagName:"code",children:i,properties:{"data-code":"","data-container-size":n?"":void 0,"data-deletions":""}}));let o=this.renderCodeAST("additions",e);if(o!=null)t.push(K({tagName:"code",children:o,properties:{"data-code":"","data-container-size":n?"":void 0,"data-additions":""}}));return{...e.preNode,children:t}}renderFullHTML(e,t=[]){return ut(this.renderFullAST(e,t))}renderPartialHTML(e,t){if(t==null)return ut(e);return ut(K({tagName:"code",children:e,properties:{"data-code":"","data-container-size":this.getOptionsWithDefaults().hunkSeparators==="line-info"?"":void 0,[`data-${t}`]:""}}))}pushFileLevelAnnotations(e,t,n,r){if(!li(n))return;let i=e.type!=="new"?this.getAnnotationNames(ra(this.deletionAnnotations)):[],o=e.type!=="deleted"?this.getAnnotationNames(ra(this.additionAnnotations)):[];if(i.length===0&&o.length===0)return;let s=-1,a=-1,{createAnnotationElement:l}=this;if(t==="unified"){Cd({diffStyle:t,type:"context",unifiedSpan:{type:"annotation",hunkIndex:s,lineIndex:a,annotations:i.concat(o)},createAnnotationElement:l,context:r});return}Cd({diffStyle:t,type:"context",deletionSpan:{type:"annotation",hunkIndex:s,lineIndex:a,annotations:i},additionSpan:{type:"annotation",hunkIndex:s,lineIndex:a,annotations:o},createAnnotationElement:l,context:r})}getAnnotations(e,t,n,r,i){let o={type:"annotation",hunkIndex:r,lineIndex:i,annotations:[]};if(t!=null)for(let a of this.deletionAnnotations[t]??[])o.annotations.push(this.annotationSlotName(a));let s={type:"annotation",hunkIndex:r,lineIndex:i,annotations:[]};if(n!=null)for(let a of this.additionAnnotations[n]??[])(e==="unified"?o:s).annotations.push(this.annotationSlotName(a));if(e==="unified"){if(o.annotations.length>0)return o;return}if(s.annotations.length===0&&o.annotations.length===0)return;return{deletionSpan:o,additionSpan:s}}getAnnotationNames(e){return e?.map((t)=>this.annotationSlotName(t))??[]}renderHeader(e){let{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return Au({fileOrDiff:e,mode:t,stickyHeader:n})}},oD=new Intl.PluralRules("en-US");function sD(e){return`${e} unmodified line${oD.select(e)==="one"?"":"s"}`}function ZI(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter("unified",n.gutter),t.incrementRowCount(1)}function QI(e,t,n){for(let{deletion:r,addition:i}of e){if(r==null&&i==null)continue;let o=r!=null&&i!=null?void 0:r==null?"deletions":"additions";if(o==null||n.side!==o)n.flush();if(r!=null)t.deletionsContentAST.push(r.content),t.pushToGutter("deletions",r.gutter);if(i!=null)t.additionsContentAST.push(i.content),t.pushToGutter("additions",i.gutter);if(o!=null)n.side=o,n.increment();t.incrementRowCount(1)}}function Cd({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:o,additionSpan:s,createAnnotationElement:a,context:l}){let d=!1;if(e==="unified"){if(r!=null)l.unifiedContentAST.push(r);else if(n!=null)l.unifiedContentAST.push(n);if(i!=null){let c=t==="change"?n!=null?"change-deletion":"change-addition":t;l.unifiedContentAST.push(a(i)),l.pushToGutter("unified",en(c,"annotation",1)),d=!0}}else if(e==="split"){if(n!=null)l.deletionsContentAST.push(n);if(r!=null)l.additionsContentAST.push(r);if(o!=null){let c=t==="change"?n!=null?"change-deletion":"context":t;l.deletionsContentAST.push(a(o)),l.pushToGutter("deletions",en(c,"annotation",1)),d=!0}if(s!=null){let c=t==="change"?r!=null?"change-addition":"context":t;l.additionsContentAST.push(a(s)),l.pushToGutter("additions",en(c,"annotation",1)),d=!0}}if(d)l.incrementRowCount(1)}function rp(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:o,isLastHunk:s,isExpandable:a},l){if(typeof n==="number"&&n<=0)return;let d=e==="unified"?l.unifiedContentAST:e==="deletions"?l.deletionsContentAST:l.additionsContentAST;if(l.hunkSeparators==="metadata"){if(i!=null){if(l.pushToGutter(e,no({type:"metadata",content:i,isFirstHunk:o,isLastHunk:s})),d.push(no({type:"metadata",content:i,isFirstHunk:o,isLastHunk:s})),e!=="additions")l.incrementRowCount(1)}return}if(l.hunkSeparators==="simple"){if(t>0){if(l.pushToGutter(e,no({type:"simple",isFirstHunk:o,isLastHunk:!1})),d.push(no({type:"simple",isFirstHunk:o,isLastHunk:!1})),e!=="additions")l.incrementRowCount(1)}return}let c=XI(e,t),m=r>l.expansionLineCount,p=a?t:void 0,h=typeof n==="number"?sD(n):"More unchanged context may be available";if(l.pushToGutter(e,no({type:l.hunkSeparators,content:h,expandIndex:p,chunked:m,slotName:c,isFirstHunk:o,isLastHunk:s})),d.push(no({type:l.hunkSeparators,content:h,expandIndex:p,chunked:m,slotName:c,isFirstHunk:o,isLastHunk:s})),e!=="additions")l.incrementRowCount(1);l.hunkData.push({slotName:c,hunkIndex:t,lines:typeof n==="number"?n:0,lineCountKnown:typeof n==="number",type:e,expandable:a?{up:!o,down:!s,chunked:m}:void 0})}function Ed(e,t,n){if(e==null||e.type!=="element"||t==null&&n==null)return e;return{...e,properties:{...e.properties,...t,...n}}}function eS(e){return e.length>0&&e[e.length-1]===""?e.length-1:e.length}function aD(e,t,n,r){let i=eS(e),o=eS(t),s=Math.min(i,o),a=0;while(a<s&&e[a]===t[a])a++;let l=0;while(l<s-a&&e[i-1-l]===t[o-1-l])l++;let d=Array(t.length);for(let c=0;c<a;c++)d[c]=n[c];for(let c=0;c<l;c++)d[o-1-c]=n[i-1-c];if(i<e.length&&o<t.length)d[t.length-1]=n[e.length-1];for(let c=a;c<t.length;c++)d[c]??=op(c,r.getLineText(c));return d}function op(e,t,n=e,r=e){return{type:"element",tagName:"div",properties:{"data-line":e+1,"data-line-index":`${n},${r}`,"data-line-type":"context"},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:t}]}]}}function lD(e){let t=[];for(let n=0;n<e.lineCount;n++)t.push(e.getLineText(n,!0));return t}function ip(e){if(e.lang!=null)return[e.lang];let t=tt(e.prevName??e.name),n=tt(e.name);return t===n?[n]:[t,n]}function Sa(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function uD(e,t){return e.isPartial&&t&&(e.type==="change"||e.type==="rename-changed")}function iS(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function oS(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function sS(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:Qu(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators==="function"?"custom":e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader!=null?"custom":"default"}}function dD(e){return e.isPartial&&(e.type==="change"||e.type==="rename-changed"||e.type==="rename-pure")}function cD(e){let t={...e};return delete t.cacheKey,t}function aS(e,t){if(e.isPartial||t.isPartial)throw Error("FileDiff.shouldResetEditorForExternalDiff: diffs must be fully hydrated");let n=e.lang??tt(e.name),r=t.lang??tt(t.name),i=e.type!=="new",o=t.type!=="new";if(e.name!==t.name||n!==r||i!==o||e.deletionLines.length!==t.deletionLines.length)return!0;return e.deletionLines.some((s,a)=>s!==t.deletionLines[a])}function mD(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function fD(e,t){let{oldFile:n}=e;if(n==null)return t.type==="new";return t.type!=="new"&&n.name===(t.prevName??t.name)&&mD(n.lines,t.deletionLines)}var pD=-1,dS=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++pD}`;type="file-diff";fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;editSession;renderedDiff;renderRange;pendingFiles;appliedPreAttributes;headerCache={lastRenderedHTML:void 0,html:void 0,fileDiff:void 0};lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;lineStateRefreshPending=!1;deferredSelectedLines;deferredEditorActiveLine;constructor(e={theme:Oe},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new wu,this.scrollSyncManager=new _I,this.interactionManager=new Tu("diff",Ko(e,typeof e.hunkSeparators==="function"||(e.hunkSeparators??"line-info")==="line-info"||e.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??Oe}getHunksRendererOptions(e){return sS(e)}createHunksRenderer(e){return new rS(this.getHunksRendererOptions(e),this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t="additions")=>this.getLineIndexForDiff(this.getDiffForLineIndex(),e,t);getDiffForLineIndex(){return this.getRenderedDiff()}getLineIndexForDiff(e,t,n){if(e==null)return;let r=e.hunks.at(-1),i,o;e:for(let s of e.hunks){let a=n==="deletions"?s.deletionStart:s.additionStart,l=n==="deletions"?s.deletionCount:s.additionCount,d=kt(a,l)+1,c=s.splitLineStart,m=s.unifiedLineStart;if(t<d){let p=d-t;i=Math.max(m-p,0),o=Math.max(c-p,0);break e}if(t>=d+l){if(s===r){let p=t-(d+l);i=m+s.unifiedLineCount+p,o=c+s.splitLineCount+p;break e}continue}for(let p of s.hunkContent)if(p.type==="context")if(t<d+p.lines){let h=t-d;o=c+h,i=m+h;break e}else d+=p.lines,c+=p.lines,m+=p.lines;else{let h=n==="deletions"?p.deletions:p.additions;if(t<d+h){let x=t-d;i=m+(n==="additions"?p.deletions:0)+x,o=c+x;break e}else d+=h,c+=Math.max(p.deletions,p.additions),m+=p.deletions+p.additions}break e}if(i==null||o==null)return;return[i,o]}setOptions(e){if(e==null)return;this.options=e,this.clearReusableHeader(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions()}syncInteractionOptions(){this.interactionManager.setOptions(Ko(this.options,typeof this.options.hunkSeparators==="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){if((this.options.themeType??"system")===e)return;this.mergeOptions({themeType:e}),this.applyCachedThemeState(e)}applyCachedThemeState(e){if(typeof this.options.theme==="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;if(this.appliedThemeCSS.themeType===t)return!1;return this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Cn(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();getAnnotationSlotName=(e)=>Zu(this.editSession?.annotations,e,dn);getLatestAnnotations(){return this.editSession?.annotations?.current??this.lineAnnotations}isNewAnnotations(e){let t=this.editSession?.annotations;if(e===this.lineAnnotations)return!1;return t==null||e!==t.provided&&e!==t.current}setLineAnnotations(e){let t=this.editSession?.annotations;if(t==null){this.lineAnnotations=e;return}if(!this.isNewAnnotations(e))return;this.lineAnnotations=e,Ju(t,e,dn)}syncEditSessionAnnotationsFromEditor(e){let t=this.editSession?.annotations;if(t==null||e===t.current)return!1;return t.current=e,this.hunksRenderer.setLineAnnotations(e),this.renderAnnotations(),!0}canPartiallyRender(e,t,n){if(e||t||n||typeof this.options.hunkSeparators==="function")return!1;return!0}setSelectedLines(e,t){if(this.lineStateRefreshPending)this.deferredSelectedLines=[e,t];else this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){if(this.lineStateRefreshPending)this.deferredEditorActiveLine=[e,t];else this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??"additions"})}flushDeferredLineState(){let{deferredEditorActiveLine:e,deferredSelectedLines:t}=this;if(this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,e!=null)this.setEditorActiveLine(...e);if(t!=null)this.interactionManager.setSelection(...t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e="split",overflow:t="scroll"}=this.options;if(this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t==="wrap",columnVariables:this.shouldApplyColumnVariables(t)?"apply":"measure"}),t==="scroll"&&e==="split")this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions);else this.scrollSyncManager.cleanUp();this.managersDirty=!1}shouldApplyColumnVariables(e){if(typeof this.options.hunkSeparators==="function")return!0;return e==="scroll"&&(this.getLatestAnnotations().length>0||this.pre?.hasAttribute("data-has-merge-conflict")===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){if(this.codeUnified!=null)this.codeUnified.scrollLeft=e;if(this.codeAdditions!=null)this.codeAdditions.scrollLeft=e;if(this.codeDeletions!=null)this.codeDeletions.scrollLeft=e}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){let{editor:t}=this;if(di(this.handleEditSessionRender),this.emitPostRender(!0),t?.cleanUp(e?"recycle":"discard"),!e)this.editor=void 0;if(this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,!e)this.pendingFiles=void 0;if(!this.isContainerManaged)this.fileContainer?.remove();if(this.fileContainer=void 0,this.mounted=!1,!e)this.lineAnnotations=[];if(this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.headerCache.lastRenderedHTML=void 0,!e)this.clearReusableHeader();if(this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e)this.hunksRenderer.recycle();else this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.editSession=void 0,this.renderedDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0;if(this.refreshViewTimeout!=null)clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:r,fileDiff:i,...o}){if(!this.enabled)throw Error("FileDiff.hydrate: attempting to call hydrate after cleaned up");if(this.fileContainer!=null)throw Error("FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated");let s=ma(o,"FileDiff.hydrate"),a=s?.oldFile,l=s?.newFile;this.hydrateElements(e,t);let d=this.editor!=null;if(d||yD(this.pre,hD({fileDiff:i,oldFile:a,newFile:l}),this.options.collapsed)||xD(this.headerElement,gD({fileDiff:i,oldFile:a,newFile:l}),this.options.disableFileHeader))this.render({...o,fileContainer:e,lineAnnotations:r,fileDiff:i,forceRender:d||o.forceRender,preventEmit:!0});else this.hydrationSetup({fileDiff:i,lineAnnotations:r,...s});if(!n)this.emitPostRender()}hydrateElements(e,t){if(this.fileContainer!==e)this.emitPostRender(!0);td(e,t);for(let n of e.shadowRoot?.children??[]){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(!(n instanceof HTMLElement))continue;if(n instanceof HTMLPreElement){this.pre=n;for(let r of n.children){if(!(r instanceof HTMLElement)||r.tagName.toLowerCase()!=="code")continue;if("deletions"in r.dataset)this.codeDeletions=r;if("additions"in r.dataset)this.codeAdditions=r;if("unified"in r.dataset)this.codeUnified=r}continue}if("diffsHeader"in n.dataset){this.headerElement=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}}if(this.pre!=null)this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute("data-dehydrated");this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){if(this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?Kn(t,n,this.options.parseDiffOptions):void 0),this.pre==null)return;this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderedDiff=this.fileDiff,this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers()}rerender(){if(!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null)return;this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.loadFilesIfNecessary(),this.rerender()};loadFilesIfNecessary(){let{fileDiff:e,options:{loadDiffFiles:t}}=this;if(e==null||t==null||!dD(e)||this.pendingFiles?.fileDiff===e)return;let n=this.loadFilesForDiff(e,t),r=this.pendingFiles={fileDiff:e,promise:n},i=()=>{if(this.pendingFiles===r)this.pendingFiles=void 0};r.promise=n.finally(i)}async loadFilesForDiff(e,t){try{let n=await t(e);if(!this.enabled||this.fileDiff!==e)return;await this.handleFilesLoaded(e,n)}catch(n){if(this.options.disableErrorHandling===!0)throw n;console.error(n)}}async handleFilesLoaded(e,t){if(this.fileDiff!==e||!e.isPartial)return;if(fa("merge",e,t),this.setHydratedState(t),this.startHydratedEditSession(e)){this.rerender();return}if(await ca(()=>this.primeHighlightCache(e)),!this.enabled||this.fileDiff!==e)return;this.rerender()}startHydratedEditSession(e){if(e.isPartial)throw Error("FileDiff.startHydratedEditSession: diffs cannot be partial for editing");if(this.fileDiff!==e)return!1;let{editor:t}=this;if(this.editSession?.outgoingDiff!=null)return this.installEditSession(e),!0;if(t==null||this.editSession!=null)return!1;return this.installEditSession(e,t.__getDocumentContents(sp(e)),t.__getDocumentSessionState()),!0}updateExternalDiff(e,t){if(ze(this.fileDiff,e))return!1;let n=this.editSession?.outgoingDiff??this.editSession?.diff;if(this.fileDiff=e,n!=null){if(e.isPartial)this.loadFilesIfNecessary();else this.installEditSession(e);if(this.editSession!=null)this.editSession.outgoingDiff=n}else if(this.editor!=null)if(e.isPartial)this.loadFilesIfNecessary();else this.installEditSession(e,this.editor.__getDocumentContents(sp(e)),this.editor.__getDocumentSessionState());if(this.editSession?.annotations!=null&&t!=null)this.lineAnnotations=t,this.editSession.annotations=Qo(t,dn,this.editSession.annotations);return!0}installEditSession(e,t,n){let r=e.additionLines.join(""),i=t!=null?ns(t.contents):void 0,o=n!=null&&fD(n,e);if(n!=null&&!o)throw Error("FileDiff: retained session cannot resume against a different old file");if(t!=null&&t.contents!==r&&!o)throw Error("FileDiff: retained edits are missing their diff session state");let s=t==null||t.name===e.name&&t.lang===e.lang&&t.contents===r,a=cD(e);if(t!=null&&i!=null&&!s)a.name=t.name,a.lang=t.lang;if(o&&n!=null&&i!=null)a.additionLines=i,a.type=n.type,a.hunks=n.hunks,a.editSessionDirty=!0,os(a);this.editSession={diff:a,annotations:this.editSession?.annotations??Qo(this.lineAnnotations,dn),outgoingDiff:this.editSession?.outgoingDiff},this.hunksRenderer.beginEditSession(a,s&&!o?e:void 0)}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:r=!1,lineAnnotations:i,fileContainer:o,containerWrapper:s,renderRange:a,...l}){if(!this.enabled)throw Error("FileDiff.render: attempting to call render after cleaned up");let d=ma(l,"FileDiff.render"),c=d?.oldFile,m=d?.newFile;this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:p=!1,themeType:h="system",expandUnchanged:x=!1}=this.options,I=p?void 0:a,v=this.hasThemeChanged(),S=d!=null,b=S&&(!lS(c,this.deletionFile)||!lS(m,this.additionFile)),E=e!=null&&!ze(e,this.fileDiff),w=i!=null&&(i.length>0||this.getLatestAnnotations().length>0)?this.isNewAnnotations(i):!1;if(!p&&ci(I,this.renderRange)&&!n&&!w&&!v&&(e!=null&&!E||e==null&&!b)){let D=this.applyCachedThemeState(h);if(D)this.finalizeRender();return D}let T;if(e==null&&S&&(b||this.fileDiff==null))T=Kn(d.oldFile,d.newFile,this.options.parseDiffOptions);let{renderRange:L}=this;if(this.renderRange=I,S)this.deletionFile=c,this.additionFile=m;else if(e!=null)this.deletionFile=void 0,this.additionFile=void 0;if(e!=null&&E)this.updateExternalDiff(e,i);else if(T!=null)E=!0,this.updateExternalDiff(T,i);if(E)this.clearReusableHeader();if(i!=null)this.setLineAnnotations(i);let R=this.getLatestDiff();if(R==null)return!1;if(R.editSessionDirty===!0&&this.shouldSelfHealEditSession())ep(R,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult();if(x)this.loadFilesIfNecessary();this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.getLatestAnnotations());let{disableErrorHandling:A=!1,disableFileHeader:O=!1}=this.options;if(O){if(this.headerElement!=null)this.headerElement.remove(),this.headerElement=void 0,this.headerCache.lastRenderedHTML=void 0;this.clearHeaderSlots()}if(o=this.getOrCreateFileContainer(o,s),this.applyCachedThemeState(h),p){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let D=this.hunksRenderer.renderDiff(R,id);if(D!=null)this.applyThemeState(o,D.themeStyles,h,D.baseThemeType);if(D?.headerElement!=null)this.applyHeaderToDOM(D.headerElement,o,D.fileDiff);this.renderSeparators([]),this.renderedDiff=D?.fileDiff??R,this.injectUnsafeCSS()}catch(D){if(A)throw D;if(console.error(D),D instanceof Error)this.applyErrorToDOM(D,o)}if(this.finalizeRender(),!r)this.emitPostRender();return!0}try{let D=this.getOrCreatePreNode(o);if(!(this.canPartiallyRender(n,w,b||E||v||!ze(this.renderedDiff,R))&&this.applyPartialRender({fileDiff:R,previousRenderRange:L,renderRange:I}))){let X=this.hunksRenderer.renderDiff(R,I);if(X==null){if(this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool())this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender());return!1}if(this.applyThemeState(o,X.themeStyles,h,X.baseThemeType),X.headerElement!=null)this.applyHeaderToDOM(X.headerElement,o,X.fileDiff);if(X.additionsContentAST!=null||X.deletionsContentAST!=null||X.unifiedContentAST!=null)this.applyHunksToDOM(D,X);else if(this.pre!=null)this.pre.remove(),this.pre=void 0;this.renderSeparators(X.hunkData),this.renderedDiff=X.fileDiff}if(this.applyBuffers(D,I),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,!t)this.flushManagers();if(this.finalizeRender(),this.editor!=null)this.syncRenderViewToEditor()}catch(D){if(A)throw D;if(console.error(D),D instanceof Error)this.applyErrorToDOM(D,o)}if(!r)this.emitPostRender();return!0}finalizeRender(){}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted)return;if(this.mounted=!1,t==null)return;this.options.onPostRender?.(t,this,"unmount");return}if(t==null)return;let r=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,r)}getLatestDiff(e=this.fileDiff){return this.editSession?.diff??e}getRenderedDiff(){return this.renderedDiff}syncRenderViewToEditor(){let{editor:e,fileContainer:t}=this,n=this.getLatestAnnotations(),r=this.computeEditorRenderRange(this.renderRange),i=this.getLatestDiff();if(e==null||t==null||i==null||i.isPartial)return;let o=(d)=>{if(!this.enabled||this.editor!==e||this.fileContainer!==t||this.getLatestDiff()!==i)return;let c=this.editSession?.outgoingDiff,m=this.fileDiff,p=c!=null&&m!=null&&c!==i,h=p?aS(c,m):!1;e.__syncRenderView({highlighter:d,fileContainer:t,fileDiff:i,lineAnnotations:n,renderRange:r,externalDocument:p,resetHistory:h})},s=this.getTheme(),a=i.lang??tt(i.name),l=jn({theme:s,lang:a});if(l!=null)o(l);else sr({themes:On(s),langs:["text",a],preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter}).then(o)}computeEditorRenderRange(e){let t=this.getLatestDiff();if(e==null||t==null||Yi(e))return e;let{diffStyle:n="split",expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,o,s;if(zn({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({additionLine:a})=>{if(a!=null)o??=a.lineNumber,s=a.lineNumber}}),o==null||s==null)return{...e,startingLine:0,totalLines:0};return{...e,startingLine:o-1,totalLines:s-o+1}}__acknowledgeDocumentUpdate(){if(this.editSession!=null)this.editSession.outgoingDiff=void 0}__acceptEditorChange(e){let{lineAnnotations:t}=e;if(t!=null)this.syncEditSessionAnnotationsFromEditor(t)}emitEditChange(e){let{onEditChange:t}=this.options;t?.(e)}__captureDocumentSessionState(e=!0){let{fileDiff:t,editSession:{diff:n,outgoingDiff:r}={}}=this;if(r!=null&&t!=null){if(!t.isPartial&&aS(r,t))return;n=r}if(n==null||n.isPartial)return;return{diffSession:{oldFile:n.type!=="new"?{name:n.prevName??n.name,lines:e?[...n.deletionLines]:n.deletionLines}:null,type:n.type,hunks:e?uS(n.hunks):n.hunks},hasChanges:n.editSessionDirty===!0}}__attachEditor(e){if(this.type!=="file-diff")throw Error(`FileDiff.__attachEditor: cannot attach an editor to a "${this.type}" diff`);if(this.editor!=null)throw Error("FileDiff.__attachEditor: an editor is already attached");let t=()=>{this.editor=void 0,this.finishEditSession()};try{return this.resumeEditorRendering(e),t}catch(n){throw t(),n}}__resumeEditor(e){if(this.editor!==e)throw Error("FileDiff.__resumeEditor: editor association changed");this.resumeEditorRendering(e)}resumeEditorRendering(e){let{fileDiff:t}=this,n=this.editSession?.outgoingDiff;if(n!=null&&t!=null&&!t.isPartial&&this.editSession?.diff===n)this.installEditSession(t);let r=this.editSession==null&&t!=null&&!t.isPartial?t:void 0;if(r!=null)this.installEditSession(r,e.__getDocumentContents(sp(r)),e.__getDocumentSessionState());else if(this.editSession!=null)this.hunksRenderer.beginEditSession(this.editSession.diff);if(this.editor=e,this.fileDiff?.isPartial===!0)this.loadFilesIfNecessary();let i=this.editSession?.diff;if(this.hunksRenderer.editorRenderReady()){if(i!=null&&this.hunksRenderer.diffCache===i)this.renderedDiff=i;this.syncRenderViewToEditor()}else this.rerender()}finishEditSession(){this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks()}__completeEditSession(e,t){this.settleEditSession(t==="install",e)}settleEditSession(e,t){let{editSession:n,fileDiff:r,lineAnnotations:i}=this;if(n==null||r==null)return;let{diff:o,annotations:s}=n;if(this.editor!=null)throw Error("FileDiff.__completeEditSession: detach the editor before completing the session");this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks();let a=s?.current,l,d=null,c=null,m=!1,p;if(t==null)throw Error("FileDiff.__completeEditSession: editor is required for completion");let h=ud(o),x={name:h.name,contents:h.additionLines.join("")};if(h.lang!=null)x.lang=h.lang;let I={fileDiff:h,editor:t,originalFileDiff:r,oldFile:h.type==="new"?null:{name:h.prevName??h.name,contents:h.deletionLines.join("")},newFile:x,lineAnnotations:a,originalLineAnnotations:i};Object.freeze(I);try{if(t.__emitEditComplete(I),this.options.onEditComplete?.(I)==="accept"){if(h.cacheKey!=null&&h.cacheKey===r.cacheKey)throw Error("FileDiff.__completeEditSession: an accepted diff must not reuse the replaced diff cacheKey");l=h,d=I.oldFile,c=I.newFile}}catch(v){m=!0,p=v}if(e&&l!=null){if(this.fileDiff=l,this.additionFile!=null)this.deletionFile=d,this.additionFile=c;if(a!=null)this.lineAnnotations=a}if(this.editSession=void 0,e&&this.fileContainer!=null)this.rerender();if(m)throw p}finalizeEditSessionHunks(){let e=this.getLatestDiff();if(e==null||e.editSessionDirty!==!0)return!1;let{collapsedContextThreshold:t=1}=this.options,n=VI(e,this.hunksRenderer.getExpandedHunksMap(),t);return ep(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(WI(e,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){let n=this.editSession?.diff;if(n==null)throw Error("FileDiff.applyDocumentChange: requires an active edit session");if(this.detachAdditionLines(),this.hunksRenderer.beginEditSession(n),this.hunksRenderer.applyDocumentChange(e),t!=null)this.syncEditSessionAnnotationsFromEditor(t);this.rerender(),this.interactionManager.setSelectionDirty()}updateRenderCache(e,t,n={}){let r=this.editSession?.diff;if(r==null)throw Error("FileDiff.updateRenderCache: requires an active edit session");this.detachAdditionLines(),this.hunksRenderer.beginEditSession(r);let{shouldRefreshDiffsView:i,lineCountChangeInFlight:o}=n;if(this.hunksRenderer.updateRenderCache(e,t,o)){if(this.refreshViewTimeout!=null)clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0;this.lineStateRefreshPending=!0,this.escalateEditSessionRender();return}if(i===!0){if(this.refreshViewTimeout!=null)clearTimeout(this.refreshViewTimeout);this.lineStateRefreshPending=!0,this.refreshViewTimeout=setTimeout(()=>{if(this.refreshViewTimeout=void 0,this.options.diffStyle==="split")this.refreshSplitDiffView();else this.refreshUnifiedDiffView();this.flushDeferredLineState()},150)}}detachAdditionLines(){let e=this.editSession?.diff,{fileDiff:t}=this;if(e!=null&&(e.additionLines===t?.additionLines||e.additionLines===e.deletionLines))e.additionLines=[...e.additionLines]}isLineRenderable(e){let t=this.getRenderedDiff();if(t==null)return!0;let{expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options;return ld({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}getNearestRenderableLine(e,t){let n=this.getRenderedDiff();if(n==null)return e;let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;return vI({fileDiff:n,lineNumber:e,direction:t,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}revealLine(e){let t=this.getRenderedDiff(),{expandUnchanged:n=!1,collapsedContextThreshold:r=1,expansionLineCount:i=100}=this.options;if(t==null||t.isPartial||n)return!1;let o=this.hunksRenderer.getExpandedHunksMap();for(let[d,c]of t.hunks.entries()){let[m,p]=ts(c);if(e<m){let h=cn({isPartial:t.isPartial,rangeSize:c.collapsedBefore,expandedHunks:o,hunkIndex:d,collapsedContextThreshold:r}),x=m-h.rangeSize;if(h.renderAll||e<x+h.fromStart||e>=m-h.fromEnd)return!1;let I=e-(x+h.fromStart)+1,v=m-h.fromEnd-e;if(I<=v)this.expandHunk(d,"up",I+i);else this.expandHunk(d,"down",v+i);return!0}if(e<p)return!1}let s=mn({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:o,collapsedContextThreshold:r,errorPrefix:"FileDiff.revealLine"});if(s==null||s.renderAll)return!1;let a=t.hunks[t.hunks.length-1],[,l]=ts(a);if(e<l+s.fromStart||e>=l+s.rangeSize)return!1;return this.expandHunk(t.hunks.length,"up",e-(l+s.fromStart)+1+i),!0}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){zo(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender(),this.flushDeferredLineState()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}async primeHighlightCache(e=this.fileDiff){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||to(e))return;let n=this.options.tokenizeMaxLength??1e5;if(Math.max(e.additionLines.length,e.deletionLines.length)>n)return;await t.primeDiffHighlightCache(e).catch((r)=>{console.error(r)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.headerCache.lastRenderedHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!=="function"){for(let{element:r}of this.separatorCache.values())r.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let r of e){let i=r.slotName,o=this.separatorCache.get(i);if(o==null||!oS(r,o.hunkData)){o?.element.remove();let s=document.createElement("div");s.style.display="contents",s.slot=r.slotName;let a=t(r,this);if(a!=null)s.appendChild(a);this.fileContainer.appendChild(s),o={element:s,hunkData:r},this.separatorCache.set(i,o)}n.delete(i)}for(let[r,{element:i}]of n.entries())this.separatorCache.delete(r),i.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:r}of this.annotationCache.values())r.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options,n=this.getLatestAnnotations();if(t!=null&&n.length>0)for(let[r,i]of n.entries()){let o=this.getAnnotationSlotName(i),s=`${r}-${o}`,a=this.annotationCache.get(s);if(a==null||!iS(i,a.annotation)){a?.element.remove();let l=t(i);if(l==null)continue;a={element:Gu(o),annotation:i},a.element.appendChild(l),this.fileContainer.appendChild(a.element),this.annotationCache.set(s,a)}e.delete(s)}for(let[r,{element:i}]of e.entries())this.annotationCache.delete(r),i.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;else if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=ju();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement("diffs-container"),i=n!==r;if(n!=null&&i)this.editor?.__captureFocusForDOMReplacement();if(i)this.emitPostRender(!0);if(this.fileContainer=r,n!=null&&i)this.headerCache.lastRenderedHTML=void 0,this.headerElement=void 0;if(t!=null&&this.fileContainer.parentNode!==t)t.appendChild(this.fileContainer);if(i)this.adoptReusableShellElements(this.fileContainer);return this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t==null)return;for(let n of t.children)if(n instanceof SVGElement)this.spriteSVG??=n;else if(ai(n)&&n.hasAttribute("data-theme-css"))this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0;else if(ai(n)&&n.hasAttribute("data-unsafe-css"))this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){let n=document.createElement("div");n.innerHTML=Uu;let r=n.firstChild;if(r instanceof SVGElement)this.spriteSVG=r}if(this.spriteSVG!=null&&this.spriteSVG.parentNode!==t)t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.pre==null)this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre);else if(this.pre.parentNode!==t)this.editor?.__captureFocusForDOMReplacement(),t.appendChild(this.pre),this.appliedPreAttributes=void 0;return this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;if(t.hasAttribute("data-unified"))this.codeUnified=t;else if(t.hasAttribute("data-deletions"))this.codeDeletions=t;else if(t.hasAttribute("data-additions"))this.codeAdditions=t}}applyHeaderToDOM(e,t,n){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{headerCache:{fileDiff:r,html:i,lastRenderedHTML:o}}=this,s=(n!==this.editSession?.diff&&ze(r,n)?i:void 0)??ut(e);if(this.headerCache.html=s,this.headerCache.fileDiff=n,s!==o){let x=document.createElement("div");x.innerHTML=s;let I=x.firstElementChild;if(!(I instanceof HTMLElement))return;if(this.headerElement!=null)t.shadowRoot?.replaceChild(I,this.headerElement);else t.shadowRoot?.prepend(I);this.headerElement=I,this.headerCache.lastRenderedHTML=s}if(this.isContainerManaged)return;let{renderCustomHeader:a,renderHeaderPrefix:l,renderHeaderFilenameSuffix:d,renderHeaderMetadata:c}=this.options;if(a!=null){let x=a(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Jo,x),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let m=l?.(n)??void 0,p=d?.(n)??void 0,h=c?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Wo,m),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Xo,p),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,Yo,h),this.headerCustom?.remove(),this.headerCustom=void 0}clearReusableHeader(){this.headerCache.html=void 0,this.headerCache.fileDiff=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);if(t==null)e.appendChild(i);return this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){if(e.replaceChildren(),t instanceof Element)e.appendChild(t);else e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement("div");return t.slot=e,t}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t==null)return;if(e==null||e===""){if(this.unsafeCSSStyle!=null)this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0;this.appliedUnsafeCSS=void 0;return}if(this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e)return;if(this.unsafeCSSStyle??=qu(),this.unsafeCSSStyle.parentNode!==t)t.appendChild(this.unsafeCSSStyle);this.unsafeCSSStyle.textContent=Vu(e),this.appliedUnsafeCSS=e}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:"open"}),o=r??n,s=this.getTheme(),a=typeof s==="string"?s:{...s},l=mi(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===o&&this.appliedThemeCSS.scrollbarGutter===l){this.appliedThemeCSS.theme=a;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:a,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:l};return}this.themeCSSStyle=ed({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:Wu(t,o,l)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:a,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:l}:void 0}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;if(e==null||this.themeCSSStyle==null)return;this.themeCSSStyle.textContent=Xu(this.themeCSSStyle.textContent??"",mi(e))}shouldGuardRebuildScroll(){return this.editor!=null&&od()}applyHunksToDOM(e,t){if(this.shouldGuardRebuildScroll())da(e,()=>this.replaceCodeColumns(e,t));else this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){let r=this.getColumnPair(e);if(r==null)return!1;let i=pi(t[0]),o=pi(t[1]);if(i==null||o==null)return!1;if(r.gutter.innerHTML=ut(i),r.content.innerHTML=ut(o),n!==this.lastRowCount)r.gutter.style.setProperty("grid-row",`span ${n}`),r.content.style.setProperty("grid-row",`span ${n}`);return!0}replaceCodeColumns(e,t){let{overflow:n="scroll"}=this.options,r=(this.options.hunkSeparators??"line-info")==="line-info",i=n==="wrap"?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let o=!1,s=[],a=this.hunksRenderer.renderCodeAST("unified",t),l=this.hunksRenderer.renderCodeAST("deletions",t),d=this.hunksRenderer.renderCodeAST("additions",t);if(this.editor?.__captureFocusForDOMReplacement(),a!=null){if(o=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=es({code:this.codeUnified,columnType:"unified",rowSpan:i,containerSize:r}),!this.applyCodeColumnsInPlace(this.codeUnified,a,t.rowCount))this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(a);s.push(this.codeUnified)}else if(l!=null||d!=null){if(l!=null){if(o=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=es({code:this.codeDeletions,columnType:"deletions",rowSpan:i,containerSize:r}),!this.applyCodeColumnsInPlace(this.codeDeletions,l,t.rowCount))this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(l);s.push(this.codeDeletions)}else this.codeDeletions?.remove(),this.codeDeletions=void 0;if(d!=null){if(o=o||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=es({code:this.codeAdditions,columnType:"additions",rowSpan:i,containerSize:r}),!this.applyCodeColumnsInPlace(this.codeAdditions,d,t.rowCount))this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(d);s.push(this.codeAdditions)}else this.codeAdditions?.remove(),this.codeAdditions=void 0}else this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0;if(s.length===0)e.textContent="";else if(o)e.replaceChildren(...s);this.lastRowCount=t.rowCount}applyPartialRender({fileDiff:e,previousRenderRange:t,renderRange:n}){let{pre:r,codeUnified:i,codeAdditions:o,codeDeletions:s,options:{diffStyle:a="split"}}=this;if(r==null||t==null||n==null||!Number.isFinite(t.totalLines)||!Number.isFinite(n.totalLines)||this.lastRowCount==null)return!1;let l=this.getCodeColumns(a,i,s,o);if(l==null)return!1;let d=t.startingLine,c=n.startingLine,m=d+t.totalLines,p=c+n.totalLines,h=Math.max(d,c),x=Math.min(m,p);if(x<=h)return!1;let I=Math.max(0,h-d),v=Math.max(0,m-x),S=this.trimColumns({columns:l,trimStart:I,trimEnd:v,previousStart:d,overlapStart:h,overlapEnd:x,diffStyle:a});if(S<0)throw Error("FileDiff.applyPartialRender: failed to trim to overlap");if(this.lastRowCount<S)throw Error("FileDiff.applyPartialRender: trimmed beyond DOM row count");let b=this.lastRowCount-S,E=(R,A)=>{if(A<=0)return;return this.hunksRenderer.renderDiff(e,{startingLine:R,totalLines:A,bufferBefore:0,bufferAfter:0})},w=E(c,Math.max(h-c,0));if(w==null&&c<h)return!1;let T=E(x,Math.max(p-x,0));if(T==null&&p>x)return!1;let L=(R,A)=>{if(R==null)return;if(a==="unified"&&!Array.isArray(l))this.insertPartialHTML(a,l,R,A);else if(a==="split"&&Array.isArray(l))this.insertPartialHTML(a,l,R,A);else throw Error("FileDiff.applyPartialRender.applyChunk: invalid chunk application");b+=R.rowCount,this.renderedDiff=R.fileDiff};if(this.cleanupErrorWrapper(),L(w,"afterbegin"),L(T,"beforeend"),this.lastRowCount!==b)this.applyRowSpan(a,l,b),this.lastRowCount=b;return!0}insertPartialHTML(e,t,n,r){if(e==="unified"&&!Array.isArray(t)){let i=this.hunksRenderer.renderCodeAST("unified",n);this.renderPartialColumn(t,i,r)}else if(e==="split"&&Array.isArray(t)){let i=this.hunksRenderer.renderCodeAST("deletions",n),o=this.hunksRenderer.renderCodeAST("additions",n);this.renderPartialColumn(t[0],i,r),this.renderPartialColumn(t[1],o,r)}else throw Error("FileDiff.insertPartialHTML: Invalid argument composition")}refreshSplitDiffView(){let e=this.getLatestDiff();if(this.options.diffStyle!=="split"||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns("split",this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(n))return;let r=(i,o)=>{if(o==null)return;let s=this.hunksRenderer.renderCodeAST(i,t),a=pi(s?.[0]),l=pi(s?.[1]);for(let[d,c]of[[o.gutter,a],[o.content,l]])if(c!=null&&d.childElementCount===c.length)for(let m=0;m<c.length;m++){let p=d.children[m],h=c[m].properties["data-line-type"];if(h!=null&&p.dataset.lineType!==h)p.dataset.lineType=h}};r("deletions",n[0]),r("additions",n[1]),this.renderedDiff=t.fileDiff}refreshUnifiedDiffView(){let e=this.getLatestDiff();if(this.options.diffStyle!=="unified"||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns("unified",this.codeUnified,this.codeDeletions,this.codeAdditions);if(n==null||Array.isArray(n))return;let r=this.hunksRenderer.renderCodeAST("unified",t),i=pi(r?.[0]),o=pi(r?.[1]),s=()=>{for(let[a,l]of[[n.gutter,i],[n.content,o]])if(l!=null)a.innerHTML=ut(l);if(t.rowCount!==this.lastRowCount)this.applyRowSpan("unified",n,t.rowCount),this.lastRowCount=t.rowCount;this.renderedDiff=t.fileDiff};if(this.shouldGuardRebuildScroll())da(this.pre,s);else s();this.renderSeparators(t.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=pi(t[0]),i=pi(t[1]);if(r==null||i==null)throw Error("FileDiff.insertPartialHTML: Unexpected AST structure");let o=i.at(0);if(n==="beforeend"&&o?.type==="element"&&typeof o.properties["data-buffer-size"]==="number")this.mergeBuffersIfNecessary(o.properties["data-buffer-size"],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let s=i.at(-1);if(n==="afterbegin"&&s?.type==="element"&&typeof s.properties["data-buffer-size"]==="number")this.mergeBuffersIfNecessary(s.properties["data-buffer-size"],e.content.children[0],e.gutter.children[0],r,i,!1);e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,o){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let s=this.getBufferSize(t.dataset);if(s==null)return;if(o)r.shift(),i.shift();else r.pop(),i.pop();this.updateBufferSize(t,s+e),this.updateBufferSize(n,s+e)}applyRowSpan(e,t,n){let r=(i)=>{if(i==null)return;i.gutter.style.setProperty("grid-row",`span ${n}`),i.content.style.setProperty("grid-row",`span ${n}`)};if(e==="unified"&&!Array.isArray(t))r(t);else if(e==="split"&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error("dun fuuuuked up")}trimColumnRows(e,t,n){let r=0,i=0,o=0,s=!1,a=n>=0;if(e==null)return 0;let l=Array.from(e.content.children),d=Array.from(e.gutter.children);if(l.length!==d.length)throw Error("FileDiff.trimColumnRows: columns do not match");while(o<l.length){if(t<=0&&!a&&!s)break;let c=d[o],m=l[o];if(o++,!(c instanceof HTMLElement)||!(m instanceof HTMLElement))throw console.error({gutterElement:c,contentElement:m}),Error("FileDiff.trimColumnRows: invalid row elements");if(s){if(s=!1,c.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in m.dataset||c.dataset.gutterBuffer==="metadata"&&"noNewline"in m.dataset){c.remove(),m.remove(),i++;continue}}if("lineIndex"in c.dataset&&"lineIndex"in m.dataset){if(t>0||a&&r>=n){if(c.remove(),m.remove(),t>0){if(t--,t===0)s=!0}i++}r++;continue}if("separator"in c.dataset&&"separator"in m.dataset){if(t>0||a&&r>=n)c.remove(),m.remove(),i++;continue}if(c.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in m.dataset){if(t>0||a&&r>=n)c.remove(),m.remove(),i++;continue}if(c.dataset.gutterBuffer==="metadata"&&"noNewline"in m.dataset){if(t>0||a&&r>=n)c.remove(),m.remove(),i++;continue}if(c.dataset.gutterBuffer==="buffer"&&"contentBuffer"in m.dataset){let p=this.getBufferSize(m.dataset);if(p==null)throw Error("FileDiff.trimColumnRows: invalid element");if(t>0){let h=Math.min(t,p),x=p-h;if(x>0)this.updateBufferSize(c,x),this.updateBufferSize(m,x),i+=h;else c.remove(),m.remove(),i+=p;if(t-=h,t===0&&x===0)s=!0}else if(a){let h=r,x=r+p-1;if(n<=h)c.remove(),m.remove(),i+=p;else if(n<=x){let I=x-n+1,v=p-I;this.updateBufferSize(c,v),this.updateBufferSize(m,v),i+=I}}r+=p;continue}throw console.error({gutterElement:c,contentElement:m}),Error("FileDiff.trimColumnRows: unknown row elements")}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:o,trimStart:s}){let a=Math.max(0,r-i),l=n-i;if(l<0)throw Error("FileDiff.trimColumns: overlap ends before previous");let d=s>0,c=o>0;if(!d&&!c)return 0;let m=d?a:0,p=c?l:-1;if(t==="unified"&&!Array.isArray(e))return this.trimColumnRows(e,m,p);else if(t==="split"&&Array.isArray(e)){let h=this.trimColumnRows(e[0],m,p),x=this.trimColumnRows(e[1],m,p);if(e[0]!=null&&e[1]!=null&&h!==x)throw Error("FileDiff.trimColumns: split columns out of sync");return e[0]!=null?h:x}else throw console.error({diffStyle:t,columns:e}),Error("FileDiff.trimColumns: Invalid columns for diffType")}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??"",10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty("grid-row",`span ${t}`),e.style.setProperty("min-height",`calc(${t} * 1lh)`)}getColumnPair(e){if(e==null)return;let t=e.children[0],n=e.children[1];if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null)return;return{gutter:t,content:n}}getCodeColumns(e,t,n,r){if(e==="unified")return this.getColumnPair(t);else{let i=this.getColumnPair(n),o=this.getColumnPair(r);return i!=null||o!=null?[i,o]:void 0}}updateBuffers(e){if(this.pre!=null)this.applyBuffers(this.pre,e)}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){if(this.bufferBefore!=null)this.bufferBefore.remove(),this.bufferBefore=void 0;if(this.bufferAfter!=null)this.bufferAfter.remove(),this.bufferAfter=void 0;return}if(t.bufferBefore>0){if(this.bufferBefore==null)this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore);this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")}else if(this.bufferBefore!=null)this.bufferBefore.remove(),this.bufferBefore=void 0;if(t.bufferAfter>0){if(this.bufferAfter==null)this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter);this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")}else if(this.bufferAfter!=null)this.bufferAfter.remove(),this.bufferAfter=void 0}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:o="bars",disableBackground:s=!1,disableLineNumbers:a=!1,overflow:l="scroll",diffStyle:d="split"}=this.options,c={type:"diff",diffIndicators:o,disableBackground:s,disableLineNumbers:a,overflow:l,split:d==="unified"?!1:t!=null&&n!=null,totalLines:r,customProperties:i};if(Bu(c,this.appliedPreAttributes))return;nd(e,c),this.appliedPreAttributes=c}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);let r=document.createElement("div");r.dataset.errorMessage="",r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement("pre");i.dataset.errorStack="",i.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function sp(e){return{name:e.name,lang:e.lang,contents:e.additionLines.join("")}}function lS(e,t){if(e==null||t==null)return e==null&&t==null;return ad(e,t)}function hD({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function gD({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function yD(e,t,n=!1){return!n&&e==null&&t}function xD(e,t,n=!1){return e==null&&t&&!n}function pi(e){if(e==null||e.type!=="element")return;return e.children??[]}var lp=3000,vd=new Map,ID=-1,pS=class extends dS{__id=`little-virtualized-file-diff:${++ID}`;renderType="virtualized";top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0,ghostTextRows:vd,ghostTextRowsByIndex:new Map};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;pendingHydratedDiff;pendingExpansions;pendingRender;constructor(e,t,n,r,i=!1){super(e,r,i);this.virtualizer=t,this.metrics=qo(n)}setMetrics(e,t=!1){let n=qo(e);if(!t&&ar(this.metrics,n))return;this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0})}setLineAnnotations(e){if(this.syncLineAnnotations(e))this.resetLayoutCache({includeEstimatedHeights:!1})}syncLineAnnotations(e){if(e==null||!this.isNewAnnotations(e)||e.length===0&&this.getLatestAnnotations().length===0)return!1;return super.setLineAnnotations(e),!0}syncEditSessionAnnotationsFromEditor(e){if(super.syncEditSessionAnnotationsFromEditor(e))return this.resetLayoutCache({includeEstimatedHeights:!1}),!0;return!1}setFileAnnotationHeight(e){let t=this.cache.fileAnnotationHeight;if(e===t)return!1;return this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0}hasFileAnnotations(e){let t=this.getLatestAnnotations();if(!na(t))return!1;return t.some((n)=>{if(n.lineNumber!==0)return!1;if(e.type==="new")return n.side==="additions";if(e.type==="deleted")return n.side==="deletions";return!0})}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error("VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(e==null)return;let{options:t}=this,n=!Go(t,e),r=n&&kD(t,e);if(super.setOptions(e),r)this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:TD(t,e)});if(n)this.forceRenderOverride=!0;if(n&&this.isSimpleMode())this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error("VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){if(this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal=0,this.cache.ghostTextRows=vd,this.cache.ghostTextRowsByIndex.size>0)this.cache.ghostTextRowsByIndex.clear();if(this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode())this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){if(this.layoutDirty=!0,this.cache.checkpoints.length>0)this.cache.checkpoints.length=0;if(this.cache.totalLines!==0)this.cache.totalLines=0;if(e)this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;if(this.renderRange!=null&&t)this.renderRange=void 0}applyGhostTextRows(e,t){let{cache:{heightDeltas:n,ghostTextRows:r,ghostTextRowsByIndex:i},metrics:{lineHeight:o}}=this;if(r===t)return!1;let s=this.getDiffStyle(),a=new Map;for(let[d,c]of t){let m=this.getLineIndexForDiff(e,d+1,"additions");if(m==null)continue;a.set(s==="split"?m[1]:m[0],c)}let l=!1;for(let d of new Set([...i.keys(),...a.keys()])){let c=((a.get(d)??0)-(i.get(d)??0))*o;if(c===0)continue;let m=(n.get(d)??0)+c;if(m===0)n.delete(d);else n.set(d,m);this.cache.measuredHeightDeltaTotal+=c,l=!0}return this.cache.ghostTextRows=t,this.cache.ghostTextRowsByIndex=a,l}reconcileHeights(){let e=!1,{options:{overflow:t="scroll"},cache:{ghostTextRowsByIndex:n},metrics:{lineHeight:r}}=this,i=this.getRenderedDiff();if(this.fileContainer==null||i==null){if(this.height!==0)e=!0;return this.height=0,e}this.top=this.getVirtualizedTop(),e=this.applyGhostTextRows(i,this.editor?.__getGhostTextRows()??vd);let o=this.getLatestAnnotations();if(t==="scroll"&&o.length===0&&!this.isResizeDebuggingEnabled()){if(e)this.computeApproximateSize(!0);return e}let s=this.getDiffStyle(),a=s==="split"?[this.codeDeletions,this.codeAdditions]:[this.codeUnified],l=this.hasFileAnnotations(i);if(this.renderRange!=null&&l&&li(this.renderRange)){let d=SD(a)??0;if(this.setFileAnnotationHeight(d))e=!0}else if(!l&&this.setFileAnnotationHeight(0))e=!0;for(let d of a){if(d==null)continue;let c=d.children[1];if(!(c instanceof HTMLElement))continue;let m=s==="split"&&d===this.codeDeletions;for(let p of c.children){if(!(p instanceof HTMLElement))continue;let h=p.dataset.lineIndex;if(h==null)continue;let x=LD(h,s),I=n.get(x)??0;if(m&&I>0)continue;let v=p.getBoundingClientRect().height+I*r,S=!1;if(p.nextElementSibling instanceof HTMLElement&&(("lineAnnotation"in p.nextElementSibling.dataset)||("noNewline"in p.nextElementSibling.dataset))){if("noNewline"in p.nextElementSibling.dataset)S=!0;v+=p.nextElementSibling.getBoundingClientRect().height}let b=this.getEstimatedLineHeight(S),E=this.cache.heightDeltas.get(x)??0,w=v-b;if(w===E)continue;if(e=!0,this.cache.measuredHeightDeltaTotal+=w-E,w===0)this.cache.heightDeltas.delete(x);else this.cache.heightDeltas.set(x,w)}}if(e||this.isResizeDebuggingEnabled())this.computeApproximateSize(!0);return e}onRender=(e)=>{if(this.fileContainer==null)return!1;if(e)this.top=this.getVirtualizedTop();return this.render()};flushManagers(){if(super.flushManagers(),this.lineStateRefreshPending)this.flushDeferredLineState()}updateCodeViewLayout(e,t,n,r){let i=!1,o=!1,{pendingExpansions:s,pendingHydratedDiff:a,options:{collapsed:l=!1}}=this;if(a!=null){if(this.pendingHydratedDiff=void 0,a.expectedDiff===e)Object.assign(e,a.nextDiff),this.setHydratedState(a.files),this.startHydratedEditSession(e),this.forceRenderOverride=!0,i=!0,o=!0}if(s!=null){this.pendingExpansions=void 0;for(let{hunkIndex:x,direction:I,expansionLineCountOverride:v}of s)this.hunksRenderer.expandHunk(x,I,v),this.forceRenderOverride=!0,o=!0}let d=this.updateExternalDiff(e,r),{pendingRenderDiff:c,layoutDiffChanged:m,renderedDiffChanged:p,annotationsChanged:h}=this.updatePendingRender(e,r);if(!this.forceRenderOverride&&(d||p||h))this.forceRenderOverride=!0;if(n?.resetDiffLayoutCache===!0||m||h)i=!0;if(m||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights)o=!0;if(n?.metrics!=null)this.metrics=qo(n.metrics),i=!0,o=!0;if(this.currentCollapsed!==l)this.currentCollapsed=l,i=!0;if(i)this.resetLayoutCache({includeEstimatedHeights:o});else if(o)this.invalidateDerivedLayoutCache(!0);return this.top=t,this.computeApproximateSize(!1,c),this.height}getLinePosition(e,t="additions"){let n=this.getLayoutDiff();if(n==null||e<1)return;let r=this.getLineIndexForDiff(n,e,t);if(r==null)return;let{disableFileHeader:i=!1,expandUnchanged:o=!1,collapsed:s=!1,collapsedContextThreshold:a=1}=this.options,l=this.getDiffStyle(),d=this.getHunkSeparatorType(),c=l==="split"?r[1]:r[0];this.approximateLayoutCheckpoints(n);let m=En(this.metrics,i),p=this.getLayoutCheckpointBeforeLineIndex(c),h=p?.top??m+this.cache.fileAnnotationHeight;if(s)return{top:m,height:0};let x;return zn({diff:n,diffStyle:l,startingLine:p?.renderedLineIndex??0,expandedHunks:o?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:a,callback:({hunkIndex:I,hunk:v,collapsedBefore:S,collapsedAfter:b,deletionLine:E,additionLine:w})=>{let T=l==="split"?w?.splitLineIndex??E?.splitLineIndex:w?.unifiedLineIndex??E?.unifiedLineIndex;if(T==null)throw Error("VirtualizedFileDiff.getLinePosition: missing line index data");if(S>0){let R=Zi({type:d,metrics:this.metrics,hunkIndex:I,hunkSpecs:v?.hunkSpecs});if(R!=null){if(h+=R.gapBefore,c>=T-S&&c<T)return x={top:h,height:R.height},!0;h+=R.height+R.gapAfter}}let L=this.getLineHeight(T,(w?.noEOFCR??!1)||(E?.noEOFCR??!1));if(T===c)return x={top:h,height:L},!0;if(h+=L,b>0){let R=_r({type:d,metrics:this.metrics});if(R!=null){if(c>T&&c<=T+b)return x={top:h+R.gapBefore,height:R.height},!0;h+=R.totalHeight}}return!1}}),x}getEditorViewport(){return this.virtualizer.type==="simple"?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){let t=this.getLayoutDiff();if(t==null)return;let{disableFileHeader:n=!1,expandUnchanged:r=!1,collapsed:i=!1,collapsedContextThreshold:o=1}=this.options;if(i)return;let s=this.getDiffStyle(),a=this.getHunkSeparatorType();this.approximateLayoutCheckpoints(t);let l=this.getLayoutCheckpointBeforeTop(e),d=l?.top??En(this.metrics,n)+this.cache.fileAnnotationHeight,c;return zn({diff:t,diffStyle:s,startingLine:l?.renderedLineIndex??0,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:m,hunk:p,collapsedBefore:h,collapsedAfter:x,deletionLine:I,additionLine:v})=>{let S=s==="split"?v?.splitLineIndex??I?.splitLineIndex:v?.unifiedLineIndex??I?.unifiedLineIndex;if(S==null)throw Error("VirtualizedFileDiff.getNumericScrollAnchor: missing line index data");if(h>0){let E=Zi({type:a,metrics:this.metrics,hunkIndex:m,hunkSpecs:p?.hunkSpecs});if(E!=null)d+=E.totalHeight}if(d>=e){if(I!=null)c={lineNumber:I.lineNumber,side:"deletions",top:d};else if(v!=null)c={lineNumber:v.lineNumber,side:"additions",top:d};if(c!=null)return!0}let b=this.getLineHeight(S,(v?.noEOFCR??!1)||(I?.noEOFCR??!1));if(d+=b,x>0){let E=_r({type:a,metrics:this.metrics});if(E!=null)d+=E.totalHeight}return!1}}),c}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){let t=this.getLayoutDiff();if(this.top==null||t==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let n=e!=null?this.computeRenderRangeFromWindow(t,this.top,e):this.renderRange;if(n==null)return;let{bufferBefore:r,bufferAfter:i,totalLines:o}=n,s=0;if(o===0){let a=e??this.virtualizer.getWindowSpecs();if(this.top<a.top)s=i}return{topOffset:this.top+r+s,height:this.height-(r+i)}}cleanUp(e=!1){let t=this.cache.ghostTextRows.size>0;if(t)this.layoutDirty=!0;let n=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(t||!ze(this.getRenderedDiff(),this.getLatestDiff()));if(this.fileContainer!=null&&this.isSimpleMode())this.getSimpleVirtualizer()?.disconnect(this.fileContainer);if(!e)this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0;if(this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),n)this.virtualizer.instanceChanged(this,!0)}expandHunk=(e,t,n)=>{if(this.fileDiff==null)return;if(this.isAdvancedMode())this.pendingExpansions??=[],this.pendingExpansions.push({hunkIndex:e,direction:t,expansionLineCountOverride:n});else this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize();this.loadFilesIfNecessary(),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)};async handleFilesLoaded(e,t){if(this.fileDiff!==e||!e.isPartial)return;if(this.isAdvancedMode()){let n=fa("clone",e,t);if(await ca(()=>this.primeHighlightCache(n)),!this.enabled||this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(fa("merge",e,t),this.setHydratedState(t),!this.startHydratedEditSession(e)){if(await ca(()=>this.primeHighlightCache(e)),!this.enabled||this.fileDiff!==e)return}this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.fileDiff)return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}isLineRenderable(e){if(super.isLineRenderable(e))return!0;let{pendingExpansions:t}=this,n=this.getRenderedDiff();if(t==null||t.length===0||n==null)return!1;let{expansionLineCount:r=100,collapsedContextThreshold:i=1}=this.options,o=new Map(this.hunksRenderer.getExpandedHunksMap());for(let s of t){let a={...o.get(s.hunkIndex)??{fromStart:0,fromEnd:0}},l=s.expansionLineCountOverride??r;if(s.direction==="up"||s.direction==="both")a.fromStart+=l;if(s.direction==="down"||s.direction==="both")a.fromEnd+=l;o.set(s.hunkIndex,a)}return ld({fileDiff:n,lineNumber:e,expandedHunks:o,collapsedContextThreshold:i})}invalidateEditSessionLayout(){if(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),!this.isSimpleMode())this.computeApproximateSize(!0);this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){if(this.invalidateEditSessionLayout(),!this.enabled||this.fileDiff==null)return;this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){if(this.isAdvancedMode()||this.fileContainer==null)return;if(this.renderRange=void 0,e&&!this.isVisible)this.top=this.getVirtualizedTop(),this.isVisible=!0;else if(!e&&this.isVisible)this.isVisible=!1,this.rerender()}rerender(){if(!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null)return;let e=this.getLatestDiff(),t=e==null?void 0:this.hunksRenderer.getDiffForNextRender(e);if(this.isSimpleMode())this.pendingRender=void 0;this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!ze(this.getRenderedDiff(),t))}syncGhostTextRows(){let e=this.getAdvancedVirtualizer();if(e!=null)e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0);else this.getSimpleVirtualizer()?.requestHeightReconcile(this)}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1});let i=this.getRenderedDiff();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!=null&&i!=null){let o=this.virtualizer.getWindowSpecs(),s=this.computeRenderRangeFromWindow(i,this.top??0,o);if(s.bufferAfter!==r.bufferAfter)this.updateBuffers(s)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.getLayoutDiff()){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}this.applyGhostTextRows(t,this.editor?.__getGhostTextRows()??vd);let{disableFileHeader:i=!1,collapsed:o=!1}=this.options,s=En(this.metrics,i);if(this.height+=s,o){this.layoutDirty=!1;return}if(this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!r)this.validateComputedHeight(t);this.layoutDirty=!1}getLayoutDiff(){return this.pendingRender?.diff??this.getRenderedDiff()}getActiveEstimatedHeight(e=this.getLayoutDiff()){this.ensureEstimatedDiffHeights(e);let t=this.getDiffStyle()==="split"?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw Error("VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height");return t}ensureEstimatedDiffHeights(e=this.getLayoutDiff()){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,{splitHeight:i,unifiedHeight:o}=wI({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:ap(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=i,this.cache.estimatedUnifiedHeight=o}validateComputedHeight(e=this.getLayoutDiff()){if(this.fileContainer==null||e==null)return;let t=this.fileContainer.getBoundingClientRect();if(t.height!==this.height)console.log("VirtualizedFileDiff.computeApproximateSize: computed height doesnt match",{name:e.name,elementHeight:t.height,computedHeight:this.height});else console.log("VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT")}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:r,...i}={}){let o=ma(i,"VirtualizedFileDiff.render"),s=o!=null,a=o?.oldFile,l=o?.newFile,d=s&&(!fS(a,this.deletionFile)||!fS(l,this.additionFile)),c=t??this.fileDiff;if(t==null&&s&&(d||this.fileDiff==null))c=Kn(o.oldFile,o.newFile,this.options.parseDiffOptions);let{forceRenderOverride:m,isSetup:p}=this;this.forceRenderOverride=void 0;let h=c!=null&&!ze(this.fileDiff,c),x=h||d;if(e=this.getOrCreateFileContainer(e),c==null)return console.error("VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data"),!1;if(h)this.updateExternalDiff(c,r);let{pendingRenderDiff:I,layoutDiffChanged:v,renderedDiffChanged:S,annotationsChanged:b}=(()=>{if(this.pendingRender!=null&&this.pendingRender.latestDiff===(this.getLatestDiff(c)??c))return{pendingRenderDiff:this.pendingRender.diff,layoutDiffChanged:!1,renderedDiffChanged:!1,annotationsChanged:!1};return this.updatePendingRender(c,r)})();if(b||v)this.resetLayoutCache({includeEstimatedHeights:v});if(!p){this.computeApproximateSize(!1,I);let L=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(L==null)throw Error("VirtualizedFileDiff.render: simple virtualizer is not available");L.connect(e,this),this.isVisible=L.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}else if(this.top??=this.getVirtualizedTop(),v)this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,I);if(!this.isVisible&&this.isSimpleMode()&&(!x||!p)){if(o!=null)this.deletionFile=a,this.additionFile=l;if(h)this.clearReusableHeader();return this.pendingRender=void 0,this.renderPlaceholder(this.height)}let E=this.virtualizer.getWindowSpecs(),w=this.top??0,T=this.computeRenderRangeFromWindow(I,w,E);return super.render({fileDiff:c,fileContainer:e,renderRange:T,lineAnnotations:r,forceRender:(m??n)||b||S||h,...o,...i})}finalizeRender(){if(this.getRenderedDiff()!==this.pendingRender?.diff)throw Error("VirtualizedFileDiff.render: rendered a different diff than its prepared layout");if(this.pendingRender=void 0,this.isSimpleMode())this.getSimpleVirtualizer()?.requestHeightReconcile(this)}updatePendingRender(e,t){let n=this.getLatestDiff(e)??e,r=this.getRenderedDiff(),{pendingRender:i}=this,o=i?.diff??r,s=this.hunksRenderer.getDiffForNextRender(n);return this.pendingRender={latestDiff:n,diff:s},{pendingRenderDiff:s,annotationsChanged:this.syncLineAnnotations(t),layoutDiffChanged:!ze(o,s),renderedDiffChanged:!ze(r,s)}}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}getVirtualizedTop(){if(this.virtualizer.type==="advanced")return this.virtualizer.getLocalTopForInstance(this);return this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type==="advanced"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??"split"}getHunkSeparatorType(){return wD(this.options.hunkSeparators)}approximateLayoutCheckpoints(e){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,i=e.hunks.length-1,o=ap(e,this.options.loadDiffFiles!=null),s=this.getDiffStyle(),a=this.getHunkSeparatorType(),l=n?!0:this.hunksRenderer.getExpandedHunksMap(),d=bD(this.cache.heightDeltas),c=En(this.metrics,t)+this.cache.fileAnnotationHeight,m=0,p=({rowCount:h,startLineIndex:x,preSeparatorHeight:I=0,postSeparatorHeight:v=0,metadataOffsets:S=[]})=>{if(h<=0)return;let b=m,E=m+h,w=CD(b);while(w<E){let T=w-b,L=c+(T>0?I:0)+T*this.metrics.lineHeight+ED(S,T)*this.metrics.lineHeight+cS(d,x,x+T);this.cache.checkpoints.push({renderedLineIndex:w,lineIndex:x+T,top:L}),w+=lp}c+=I+h*this.metrics.lineHeight+S.length*this.metrics.lineHeight+cS(d,x,x+h)+v,m=E};for(let h=0;h<e.hunks.length;h++){let x=e.hunks[h];if(x==null)throw Error("VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index");let I=cn({isPartial:e.isPartial,rangeSize:x.collapsedBefore,expandedHunks:l,hunkIndex:h,collapsedContextThreshold:r}),v=I.collapsedLines>0?Zi({type:a,metrics:this.metrics,hunkIndex:h,hunkSpecs:x.hunkSpecs})?.totalHeight??0:0;p({rowCount:I.fromStart,startLineIndex:(s==="split"?x.splitLineStart:x.unifiedLineStart)-I.rangeSize});let S=v;if(p({rowCount:I.fromEnd,startLineIndex:(s==="split"?x.splitLineStart:x.unifiedLineStart)-I.fromEnd,preSeparatorHeight:S}),I.fromEnd>0)S=0;let b=h===i?mn({fileDiff:e,hunkIndex:h,expandedHunks:l,collapsedContextThreshold:r,errorPrefix:"VirtualizedFileDiff"}):void 0,E=b!=null&&b.collapsedLines>0?_r({type:a,metrics:this.metrics})?.totalHeight??0:h===i&&o?_r({type:a,metrics:this.metrics})?.totalHeight??0:0,w=b!=null?b.fromStart+b.fromEnd:0,T=s==="split"?x.splitLineCount:x.unifiedLineCount,L=s==="split"?x.splitLineStart:x.unifiedLineStart;if(p({rowCount:T,startLineIndex:L,preSeparatorHeight:S,postSeparatorHeight:w===0?E:0,metadataOffsets:vD({diffStyle:s,hunk:x,rowCount:T})}),b!=null&&w>0)p({rowCount:w,startLineIndex:L+T,postSeparatorHeight:E})}this.cache.totalLines=m}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;while(t<=n){let i=t+n>>1,o=this.cache.checkpoints[i];if(o==null)throw Error("VirtualizedFileDiff: invalid checkpoint index");if(o.lineIndex<=e)r=o,t=i+1;else n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;while(n<=r){let o=n+r>>1,s=this.cache.checkpoints[o];if(s==null)throw Error("VirtualizedFileDiff: invalid checkpoint index");if(s.top<=e)i=o,n=o+1;else r=o-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let o=i;o>=0;o--){let s=this.cache.checkpoints[o];if(s==null)throw Error("VirtualizedFileDiff: invalid checkpoint index");if(s.renderedLineIndex%t===0)return s}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let a of e.hunks)n+=t==="split"?a.splitLineCount:a.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,o=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[a,l]of e.hunks.entries()){let d=t==="split"?l.splitLineCount:l.unifiedLineCount;n+=d;let c=Math.max(l.collapsedBefore,0),{fromStart:m,fromEnd:p,renderAll:h}=cn({isPartial:e.isPartial,rangeSize:c,expandedHunks:o,hunkIndex:a,collapsedContextThreshold:i});if(c>0)n+=h?c:m+p}let s=mn({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:o,collapsedContextThreshold:i,errorPrefix:"VirtualizedFileDiff"});if(s!=null)n+=s.fromStart+s.fromEnd;return n}getLayoutLineCount(e,t){let n=this.getExpandedLineCount(e,t),r=t==="split"?e.splitLineCount:e.unifiedLineCount;return Math.max(n,r,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:o=!1,collapsedContextThreshold:s=1}=this.options,{hunkLineCount:a,lineHeight:l}=this.metrics,d=this.getDiffStyle(),c=this.getHunkSeparatorType(),m=ap(e,this.options.loadDiffFiles!=null),p=this.height,h=this.getLayoutLineCount(e,d),x=En(this.metrics,i),I=e.hunks.length>0?Wi(this.metrics):0,{fileAnnotationHeight:v}=this.cache,S=x+v,b=Math.max(0,p-x-v-I),E=this.hasFileAnnotations(e),w=t+x,T=v>0&&E&&w<r&&w+v>n;if(t<n-p||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:p-x-I};if(h<=a||e.hunks.length===0)return{startingLine:0,totalLines:a,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),h=this.getLayoutLineCount(e,d);let L=Math.ceil(Math.max(r-n,0)/l),R=Math.ceil(L/a)*a+a,A=R/a,O=A,D=[],X=(n+r)/2,N=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-R*l*2),a),B=t+(N?.top??S),pe=N?.renderedLineIndex??0,ye,j,ie;if(zn({diff:e,diffStyle:d,startingLine:N?.renderedLineIndex??0,expandedHunks:o?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:Hi,hunk:Zt,collapsedBefore:wo,collapsedAfter:Bs,deletionLine:kr,additionLine:Tr})=>{let at=Tr!=null?Tr.splitLineIndex:kr.splitLineIndex,sn=Tr!=null?Tr.unifiedLineIndex:kr.unifiedLineIndex,In=(Tr?.noEOFCR??!1)||(kr?.noEOFCR??!1),_i=Hi===e.hunks.length-1&&Zt!=null&&(d==="split"?at===Zt.splitLineStart+Zt.splitLineCount-1:sn===Zt.unifiedLineStart+Zt.unifiedLineCount-1),Un=(wo>0?Zi({type:c,metrics:this.metrics,hunkIndex:Hi,hunkSpecs:Zt?.hunkSpecs}):void 0)?.totalHeight??0;B+=Un;let wr=pe%a===0,Qr=Math.floor(pe/a);if(wr){if(D[Qr]=B-(t+S+Un),ie!=null){if(ie<=0)return!0;ie--}}let Pn=this.getLineHeight(d==="split"?at:sn,In);if(B>n-Pn&&B<r)ye??=Qr;if(j==null&&B+Pn>X)j=Qr;if(ie==null&&B>=r&&wr)ie=O;if(pe++,B+=Pn,Bs>0||_i&&m){let Fl=_r({type:c,metrics:this.metrics});if(Fl!=null){if(B<r&&B+Fl.totalHeight>n)ye??=Qr;if(j==null&&B+Fl.totalHeight>X)j=Qr;B+=Fl.totalHeight}}return!1}}),ye==null)if(T)ye=0,j=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:p-x-I};j??=ye;let Ee=Math.round(j-A/2),Mt=Math.max(0,Math.ceil(h/a)-A),Ie=Math.max(0,Math.min(Ee,Mt)),Me=Ie*a,Qe=Ee<0?R+Ee*a:R,gt=D[Ie]??0,xn=Me===0?0:v+gt,Rn=Ie+Qe/a,An=Rn<D.length?b-D[Rn]:b-(B-t-S);return{startingLine:Me,totalLines:Qe,bufferBefore:xn,bufferAfter:Math.max(0,An)}}};function SD(e){let t;for(let n of e){if(n==null)continue;let r=n.children[1];if(!(r instanceof HTMLElement))continue;for(let i of r.children){if(!(i instanceof HTMLElement))continue;if(i.dataset.lineAnnotation!==Eu)continue;t=Math.max(t??0,i.getBoundingClientRect().height)}}return t}function bD(e){let t=Array.from(e).sort((o,s)=>o[0]-s[0]),n=[],r=[0],i=0;for(let[o,s]of t)n.push(o),i+=s,r.push(i);return{lineIndexes:n,prefixTotals:r}}function cS({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=mS(e,n);return(t[mS(e,r)]??0)-(t[i]??0)}function mS(e,t){let n=0,r=e.length;while(n<r){let i=n+r>>1,o=e[i];if(o==null)throw Error("VirtualizedFileDiff: invalid prefix index");if(o<t)n=i+1;else r=i}return n}function CD(e){return Math.ceil(e/lp)*lp}function ED(e,t){let n=0;for(let r of e)if(r<t)n++;return n}function vD({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];let r=t.hunkContent.at(-1);if(r==null)return[];if(r.type==="context")return[n-1];let i=Math.max(r.deletions,r.additions),o=r.deletions+r.additions;if(e==="split")return i>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];let s=[],a=n-o;if(r.deletions>0&&t.noEOFCRDeletions)s.push(a+r.deletions-1);if(r.additions>0&&t.noEOFCRAdditions)s.push(n-1);return s}function kD(e,t){return(e.diffStyle??"split")!==(t.diffStyle??"split")||(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??"bars")!==(t.diffIndicators??"bars")||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||Boolean(e.loadDiffFiles)!==Boolean(t.loadDiffFiles)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function TD(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||Boolean(e.loadDiffFiles)!==Boolean(t.loadDiffFiles)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function ap(e,t){return e.isPartial&&t&&(e.type==="change"||e.type==="rename-changed")}function wD(e){return typeof e==="function"?"custom":e??"line-info"}function fS(e,t){if(e==null||t==null)return e==null&&t==null;return ad(e,t)}function LD(e,t){let[n,r]=e.split(",").map(Number);return t==="split"?r:n}var LS=["theme","disableLineNumbers","overflow","themeType","disableFileHeader","disableVirtualizationBuffers","preferredHighlighter","useCSSClasses","useTokenTransformer","tokenizeMaxLineLength","tokenizeMaxLength","unsafeCSS","diffStyle","diffIndicators","disableBackground","expandUnchanged","loadDiffFiles","collapsedContextThreshold","lineDiffType","maxLineDiffLength","expansionLineCount","lineHoverHighlight","enableTokenInteractionsOnWhitespace","enableGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","disableErrorHandling"],RS=["theme","disableLineNumbers","overflow","themeType","disableFileHeader","disableVirtualizationBuffers","preferredHighlighter","useCSSClasses","useTokenTransformer","tokenizeMaxLineLength","tokenizeMaxLength","unsafeCSS","lineHoverHighlight","enableTokenInteractionsOnWhitespace","enableGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","disableErrorHandling"],hS=["renderCustomHeader","renderHeaderPrefix","renderHeaderFilenameSuffix","renderHeaderMetadata","renderAnnotation","renderGutterUtility","onPostRender","onGutterUtilityClick","onLineClick","onLineNumberClick","onLineEnter","onLineLeave","onTokenClick","onTokenEnter","onTokenLeave"],gS=["onLineSelected","onLineSelectionStart","onLineSelectionChange","onLineSelectionEnd"],AS=Symbol("CodeView.itemOptionsState");function yS(e,t){Object.defineProperty(e,AS,{configurable:!1,enumerable:!1,value:t})}function hi(e){return e[AS]}function Vn(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return n(this)}})}var RD=120,xS=1,IS="--diffs-overflow-override",AD=12000000,PD=1e6,$D=2000000,MD=1e7,SS=11000000;function OD(e){if(e==null)throw Error("CodeView: createEditor is required for items with edit: true")}var FD=(()=>{let{navigator:e}=globalThis,t=e.userAgent,n=/iP(?:hone|ad|od)/.test(t),r=e.platform==="MacIntel"&&e.maxTouchPoints>1;return(n||r)&&/AppleWebKit/.test(t)&&/Safari/.test(t)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(t)})(),ND=class e{static __STOP=!1;static __lastScrollPosition=0;type="advanced";config={overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1};items=[];idToItem=new Map;selectedLines=null;itemEditors=new Map;attachedEditors=new Set;instanceToItem=new Map;layoutDirtyIndex;pendingLayoutReset;renderOptionsRevision=0;slotCoordinator;slotSnapshot;scrollListeners=new Set;scrollHeight=0;containerHeight=-1;scrollTop=0;scrollPageOffset=0;scrollDirty=!0;scrollInteractionFixTimer;pointerEventsDisabled=!1;codeOverflowFix=!1;height=0;heightDirty=!0;windowSpecs={top:0,bottom:0};renderState={scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1};itemMetricsCache=ss;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;shouldFixContainerFocus=!1;scrollAnimation;root;resizeObserver;container=document.createElement("div");stickyContainer=document.createElement("div");stickyOffset=document.createElement("div");header={element:void 0,render:void 0,height:0};footer={element:void 0,render:void 0,height:0};elementPool=[];elementPoolVersion=0;elementPoolTracker=new WeakMap;pendingElementPool=[];options;workerManager;isReadySubscription;pendingHighlighterTheme;isContainerManaged;constructor(t={theme:Oe},n,r=!1){this.options=t,this.computeMetricsCache(t.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=n,this.isContainerManaged=r,this.stickyOffset.style.contain="layout size",this.stickyContainer.style.position="sticky",this.stickyContainer.style.width="100%",this.stickyContainer.style.contain="layout style inline-size",this.stickyContainer.style.isolation="isolate",this.stickyContainer.style.display="flex",this.stickyContainer.style.flexDirection="column"}getLayout(){return this.options.layout??TS}getItemTopOffset(){return this.getLayout().paddingTop+this.header.height}computeMetricsCache(t){return this.itemMetricsCache={hunkLineCount:t?.hunkLineCount??ss.hunkLineCount,lineHeight:t?.lineHeight??ss.lineHeight,diffHeaderHeight:t?.diffHeaderHeight??ss.diffHeaderHeight,hunkSeparatorHeight:t?.hunkSeparatorHeight,spacing:t?.spacing??ss.spacing,paddingTop:t?.paddingTop,paddingBottom:t?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??wS}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return kS&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(t){if(!this.shouldValidateItemHeights()||t.element==null)return;let n=t.instance.getAdvancedStickySpecs();if(n==null)return;let r=n.height,i=t.element.getBoundingClientRect().height;if(r===i)return;console.error("CodeView: reconciled item height does not match DOM height",{id:t.item.id,type:t.type,index:t.index,version:t.version,expectedHeight:r,actualHeight:i,delta:i-r,stickyTopOffset:n.topOffset,virtualizedHeight:t.instance.getVirtualizedHeight(),top:t.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:t.element,instance:t.instance})}validateStickyContainerHeight(){if(!this.shouldValidateItemHeights())return;let{firstIndex:t,lastIndex:n,stickyHeight:r,stickyTop:i,stickyBottom:o}=this.renderState;if(t===-1||n===-1)return;let s=this.stickyContainer.getBoundingClientRect().height;if(Math.abs(s-r)<xS)return;console.error("CodeView: sticky container height does not match computed layout",{computedStickyHeight:r,actualStickyHeight:s,delta:s-r,stickyTop:i,stickyBottom:o,firstIndex:t,lastIndex:n,firstStickySpecs:this.items[t]?.instance.getAdvancedStickySpecs(),lastStickySpecs:this.items[n]?.instance.getAdvancedStickySpecs(),scrollTop:this.getScrollTop(),scrollPageOffset:this.scrollPageOffset,windowSpecs:{...this.windowSpecs},stickyContainer:this.stickyContainer})}clearScrollInteractionTimer(){if(this.scrollInteractionFixTimer!=null)clearTimeout(this.scrollInteractionFixTimer),this.scrollInteractionFixTimer=void 0}suspendScrollInteractions(){if(this.clearScrollInteractionTimer(),this.shouldDisablePointerEvents()&&!this.pointerEventsDisabled)this.stickyContainer.style.pointerEvents="none",this.pointerEventsDisabled=!0;if(FD&&!this.codeOverflowFix)this.stickyContainer.style.setProperty(IS,"hidden"),this.codeOverflowFix=!0;this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,RD)}restoreScrollInteractions=()=>{if(this.clearScrollInteractionTimer(),this.pointerEventsDisabled)this.stickyContainer.style.removeProperty("pointer-events"),this.pointerEventsDisabled=!1;if(this.codeOverflowFix)this.stickyContainer.style.setProperty(IS,"auto"),this.codeOverflowFix=!1};syncLayout(){let{gap:t,paddingBottom:n,paddingTop:r}=this.getLayout();this.stickyContainer.style.gap=`${t}px`,this.container?.style.setProperty("margin-top",`${r}px`),this.container?.style.setProperty("margin-bottom",`${n}px`)}reconcileHeaderFooterHosts(){let t=this.reconcileHost("header"),n=this.reconcileHost("footer");return t||n}reconcileHost(t){let{root:n,container:r}=this;if(n==null||r==null)return!1;let i=t==="header"?this.header:this.footer,o=t==="header"?this.options.renderCodeViewHeader:this.options.renderCodeViewFooter;if(o==null){if(i.element==null)return!1;return this.resizeObserver?.unobserve(i.element),i.element.remove(),i.element=void 0,i.render=void 0,this.setHostHeight(i,0),!1}if(i.element!=null&&o===i.render)return!1;let s=i.element??Xx(t,r,this.resizeObserver);i.element=s;let a=o();if(a!=null)s.replaceChildren(a);else if(!this.isContainerManaged&&s.children.length>0)s.textContent="";return i.render=o,!0}setHostHeight(t,n){if(t.height===n)return;t.height=n,this.scrollDirty=!0}measureMountedHosts(){if(this.header.element!=null)this.setHostHeight(this.header,this.header.element.getBoundingClientRect().height);if(this.footer.element!=null)this.setHostHeight(this.footer,this.footer.element.getBoundingClientRect().height)}setup(t){if(this.root!=null)throw Error("CodeView.setup: already setup");if(this.workerManager?.subscribeToThemeChanges(this),this.root=t,this.root.style.overflowAnchor="none",!this.root.hasAttribute("tabindex"))this.root.tabIndex=-1;this.container??=document.createElement("div"),this.container.style.contain="layout style",this.syncLayout(),this.container.appendChild(this.stickyOffset),this.container.appendChild(this.stickyContainer),this.root.appendChild(this.container),this.scrollDirty=!0,this.heightDirty=!0,this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.stickyContainer),this.root.addEventListener("scroll",this.handleScroll,{passive:!0}),this.root.addEventListener("wheel",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("touchstart",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("pointerdown",this.clearPendingScroll,{passive:!0}),this.root.addEventListener("keydown",this.clearPendingScroll,{passive:!0}),this.resizeObserver.observe(this.root),this.render(!0),window.__INSTANCE=this,window.__TOGGLE=()=>{if(e.__STOP)e.__STOP=!1,this.scrollTo({type:"position",position:e.__lastScrollPosition,behavior:"instant"});else e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0}}reset(){di(this.computeRenderRangeAndEmit),this.clearReadySubscription(),this.restoreScrollInteractions(),this.cleanAllRenderedItems();let t=[...this.itemEditors.values()].map((i)=>{let o=this.idToItem.get(i.state.id);if(o!=null)i.state.removedItem=o.item;return{record:i,instance:o?.instance}});this.itemEditors.clear(),this.attachedEditors.clear(),this.selectedLines=null,this.items.length=0,this.idToItem.clear(),this.instanceToItem.clear();let n=!1,r;for(let{record:i,instance:o}of t)try{i.editor.cleanUp("discard"),o?.cleanUp()}catch(s){if(!n)n=!0,r=s}if(this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent="",this.stickyOffset.style.height="",this.container?.style.removeProperty("height"),this.containerHeight=-1,this.windowSpecs={top:0,bottom:0},this.pendingLayoutAnchor=void 0,this.shouldFixContainerFocus=!1,this.height=0,this.scrollTop=0,this.scrollPageOffset=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.resetRenderState(),!this.isContainerManaged)this.flushSlotCoordinator();if(n)throw r}cleanUp(){let t=!1,n;try{this.reset()}catch(r){t=!0,n=r}if(this.clearElementPool(),this.restoreScrollInteractions(),this.workerManager?.unsubscribeToThemeChanges(this),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.root?.removeEventListener("scroll",this.handleScroll),this.root?.removeEventListener("wheel",this.clearPendingScroll),this.root?.removeEventListener("touchstart",this.clearPendingScroll),this.root?.removeEventListener("pointerdown",this.clearPendingScroll),this.root?.removeEventListener("keydown",this.clearPendingScroll),this.root?.style.removeProperty("overflow-anchor"),this.container?.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent="",this.header.element?.remove(),this.header.element=void 0,this.header.render=void 0,this.header.height=0,this.footer.element?.remove(),this.footer.element=void 0,this.footer.render=void 0,this.footer.height=0,this.root=void 0,this.container=void 0,t)throw n}cleanAllRenderedItems(){if(this.renderState.firstIndex===-1)return;for(let t=this.renderState.firstIndex;t<=this.renderState.lastIndex;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${t}`);this.releaseRenderedItem(n)}}primeScrollTarget(t){if(t.type==="position")return;let n=this.idToItem.get(t.id);if(n==null)return;n.instance.primeHighlightCache()}getElementPoolLimit(){let t=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:n}=this.itemMetricsCache;return Math.max(8,Math.ceil(t/Math.max(n,10))+1)*(this.isContainerManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let t=this.elementPool.pop();while(t!=null&&!this.isElementPoolGenerationCurrent(t))t=this.elementPool.pop();return t??=document.createElement(rd),this.markElementPoolGenerationCurrent(t),t}releaseRenderedItem(t){let{element:n}=t;if(n!=null&&this.renderedItemOwnsFocus(n))this.shouldFixContainerFocus=!0;if(t.instance.cleanUp(!0),this.attachedEditors.delete(t.item.id),t.element=void 0,n==null)return;n.remove(),this.cleanElement(n),this.queueElementForPool(n)}renderedItemOwnsFocus(t){let{activeElement:n}=document;return n===t||t.contains(n)||t.shadowRoot?.activeElement!=null}fixContainerFocus(){if(this.shouldFixContainerFocus)this.shouldFixContainerFocus=!1,this.root?.focus({preventScroll:!0})}cleanElement(t){let{shadowRoot:n}=t;if(n!=null){for(let r of Array.from(n.children))if(!BD(r))r.remove()}if(!this.isContainerManaged)t.replaceChildren()}queueElementForPool(t){let n=this.getElementPoolLimit();if(!this.isElementPoolGenerationCurrent(t)||this.getElementPoolSize()>=n)return;if(this.isElementClean(t))this.elementPool.push(t);else this.pendingElementPool.push(t)}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;let{pendingElementPool:t}=this;this.pendingElementPool=[];let n=this.getElementPoolLimit();for(let r of t)if(this.isElementPoolGenerationCurrent(r)&&this.isElementClean(r)&&this.elementPool.length<n)this.elementPool.push(r);else if(this.isElementPoolGenerationCurrent(r)&&this.getElementPoolSize()<n)this.pendingElementPool.push(r)}isElementClean(t){return t.childNodes.length===0}getElementPoolSize(){return this.elementPool.length+this.pendingElementPool.length}clearElementPool(){this.elementPool.length=0,this.pendingElementPool.length=0}invalidateElementPool(){this.elementPoolVersion++,this.clearElementPool()}markElementPoolGenerationCurrent(t){this.elementPoolTracker.set(t,this.elementPoolVersion)}isElementPoolGenerationCurrent(t){return this.elementPoolTracker.get(t)===this.elementPoolVersion}resolveEffectiveScrollBehavior(t,n){if(Jx())return"instant";if(t.behavior!=="smooth-auto")return t.behavior??"instant";return Math.abs(n-this.getScrollTop())<=this.getHeight()*10?"smooth":"instant"}scrollTo(t){if(this.root==null)return;let n=this.normalizeScrollTarget(t);if(n==null)return;let r=this.resolveScrollTargetTop(n);if(r==null)return;if(this.primeScrollTarget(n),this.resolveEffectiveScrollBehavior(n,r)==="smooth")this.scrollAnimation??={position:this.getScrollTop(),velocity:0,lastTimestamp:performance.now()};else this.scrollAnimation=void 0;this.suspendScrollInteractions(),this.pendingLayoutAnchor=void 0,this.pendingScrollTarget=n,this.render()}setSelectedLines(t,n){this.applySelectedLines(t,n)}getSelectedLines(){return this.selectedLines}clearSelectedLines(t){this.applySelectedLines(null,t)}getItem(t){return this.idToItem.get(t)?.item}getEditor(t){return this.itemEditors.get(t)?.editor}updateItem(t){let n=this.idToItem.get(t.id);if(n==null)return console.error(`CodeView.updateItem: unknown item id "${t.id}"`),!1;if(!this.syncItemRecord(n,t))return!1;return this.markItemLayoutDirty(n),this.scrollDirty=!0,this.render(),this.syncItemEditors(),this.syncSelection(),!0}updateItemId(t,n){if(t===n)return!0;let r=this.idToItem.get(t);if(r==null)return console.error(`CodeView.updateItemId: unknown item id "${t}"`),!1;if(this.idToItem.has(n))return console.error(`CodeView.updateItemId: duplicate item id "${n}"`),!1;if(this.idToItem.delete(t),r.item.id=n,this.idToItem.set(n,r),this.updateItemOptionsId(r.instance.options,n),this.selectedLines?.id===t)this.selectedLines={...this.selectedLines,id:n},this.options.onSelectedLinesChange?.(this.selectedLines);let i=this.itemEditors.get(t);if(i!=null){if(this.itemEditors.delete(t),this.itemEditors.set(n,i),this.attachedEditors.delete(t))this.attachedEditors.add(n)}return this.renamePendingScrollTarget(t,n),this.renamePendingLayoutAnchor(t,n),this.render(),!0}addItem(t){this.addItems([t])}addItems(t){this.appendItemsInternal(t),this.syncItemEditors(),this.syncSelection()}removeItem(t){let n=this.idToItem.get(t);if(n==null)return console.error(`CodeView.removeItem: unknown item id "${t}"`),!1;let r=[];for(let i of this.items)if(i!==n)r.push(i.item);return this.setItems(r),!0}setItems(t){let n;if(this.items.length===0)this.appendItemsInternal(t);else if(!this.tryAppendItems(t))n=this.reconcileItems(t);this.syncItemEditors(n),this.syncSelection()}appendItemsInternal(t,n=!0){if(t.length===0)return;let r=this.getLayout(),i=this.items.length===0?0:this.scrollHeight+r.gap,o=i;for(let s=0;s<t.length;s++){let a=t[s];if(a==null)throw Error("CodeView.appendItemsInternal: missing input item");if(this.idToItem.has(a.id))throw Error(`CodeView.addItem: duplicate id "${a.id}"`);let l=this.createItem(a,this.items.length,i);this.items.push(l),this.idToItem.set(l.item.id,l),this.instanceToItem.set(l.instance,l),l.height=DD(l),i+=l.height+r.gap}if(this.scrollHeight=i-r.gap,this.scrollDirty=!0,n)if(this.canSkipRenderForAppend(o))this.syncContainerHeight();else this.render()}canSkipRenderForAppend(t){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&t>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(t){if(t==null)return;this.capturePendingLayoutAnchor();let{options:n}=this,r=this.getLayout(),{itemMetricsCache:i}=this;if(HD(n,t))this.invalidateElementPool();this.options=t;let o=this.computeMetricsCache(t.itemMetrics),s=!ar(i,o),a=!ar(r,this.getLayout());if(a)this.syncLayout();let l=s||_D(n,t);if(l){let c=this.pendingLayoutReset;this.pendingLayoutReset={metrics:s?o:c?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:c?.includeEstimatedDiffHeights===!0||s||UD(n,t)}}if(a||l)this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0;if(!Go(n,t))this.renderOptionsRevision++;this.syncItemEditors();let d=n.renderCodeViewHeader!==t.renderCodeViewHeader||n.renderCodeViewFooter!==t.renderCodeViewFooter;if(!this.isContainerManaged&&(this.items.length>0||d))this.render()}capturePendingLayoutAnchor(t=this.idToItem){if(this.root==null||this.items.length===0||this.pendingScrollTarget!=null)return;this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop(),t)}render(t=!1){if(e.__STOP)return;if(t)di(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit();else zo(this.computeRenderRangeAndEmit)}isReady(){let{workerManager:t}=this;if(t==null||t.getStats().workersFailed)return this.isSharedHighlighterReady();if(t.isInitialized())return this.clearReadySubscription(),!0;if(this.isReadySubscription??=t.subscribeToStatChanges((n)=>{if(n.managerState!=="initialized"&&!n.workersFailed)return;this.clearReadySubscription(),this.render(!0)}),t.getStats().managerState==="waiting")t.initialize().catch(()=>{});return!1}clearReadySubscription(){if(this.isReadySubscription==null)return;this.isReadySubscription(),this.isReadySubscription=void 0,this.pendingHighlighterTheme=void 0}isSharedHighlighterReady(){let t=this.workerManager?.getFileRenderOptions().theme??this.options.theme??Oe;if(vf()&&Qt(t))return this.clearReadySubscription(),!0;if(!Cn(this.pendingHighlighterTheme,t))this.clearReadySubscription();return this.isReadySubscription??=(()=>{this.pendingHighlighterTheme=t;let n=!1;return kf({themes:On(t),langs:[],preferredHighlighter:this.options.preferredHighlighter}).then(()=>{if(n)return;this.clearReadySubscription(),this.render(!0)},(r)=>{if(n)return;this.clearReadySubscription(),console.error(r)}),()=>{n=!0}})(),!1}instanceChanged(t,n){let r=this.instanceToItem.get(t);if(r==null)throw Error("CodeView.instanceChanged: An instance has changed that is not registered");if(n)this.markItemLayoutDirty(r);this.render()}getWindowSpecs(){return this.windowSpecs}getContainerElement(){return this.root}getHeaderElement(){return this.header.element}getFooterElement(){return this.footer.element}getRenderedItems(){let{firstIndex:t,lastIndex:n}=this.renderState;if(t===-1||n===-1||n<t)return[];let r=[];for(let i=t;i<=n;i++){let o=this.items[i];if(o?.element==null)continue;if(o.type==="diff")r.push({id:o.item.id,type:"diff",item:o.item,version:o.version,element:o.element,instance:o.instance});else r.push({id:o.item.id,type:"file",item:o.item,version:o.version,element:o.element,instance:o.instance})}return r}setSlotCoordinator(t){if(t===this.slotCoordinator)return!1;return this.slotCoordinator=t,this.slotSnapshot=void 0,!0}getSlotSnapshot(t){return this.buildSlotSnapshot(t)}buildSlotSnapshot(t){let n=jD(this.getRenderedItems(),t),{element:r}=this.header,{element:i}=this.footer;if(n==null&&r==null&&i==null)return;return{items:n,header:r,footer:i}}subscribeToScroll(t){return this.scrollListeners.add(t),()=>{this.scrollListeners.delete(t)}}getLocalTopForInstance(t){let n=this.instanceToItem.get(t);if(n==null)throw Error("CodeView.getLocalTopForInstance: unknown virtualized instance");return n.top}getTopForItem(t){let n=this.idToItem.get(t);if(n==null)return;return n.top+this.getItemTopOffset()}createItem(t,n,r){let{itemMetricsCache:i}=this;if(t.type==="diff"){let s=new pS(this.createDiffOptions(t.id),this,i,this.workerManager,this.isContainerManaged);return{type:"diff",item:t,version:t.version,index:n,top:r,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:s}}let o=new CI(this.createFileOptions(t.id),this,i,this.workerManager,this.isContainerManaged);return{type:"file",item:t,version:t.version,index:n,top:r,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:o}}applySelectedLines(t,n){let{selectedLines:r}=this;if(t==null&&r==null||t!=null&&r?.id===t.id&&jo(r.range,t.range))return;if(r!=null&&r.id!==t?.id)this.idToItem.get(r.id)?.instance.setSelectedLines(null,{notify:!1});this.selectedLines=t,this.idToItem.get(t?.id??"")?.instance.setSelectedLines(t?.range??null,n)}syncSelection(){if(this.selectedLines==null)return;let t=this.idToItem.get(this.selectedLines.id);if(t==null){this.selectedLines=null,this.options.onSelectedLinesChange?.(null);return}t.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}isItemInEditMode(t){return t.item.edit===!0&&t.item.collapsed!==!0}attachItemEditor(t){let{id:n}=t.item,{createEditor:r}=this.options;if(t.element==null||this.attachedEditors.has(n)||!this.isItemInEditMode(t))return;let i=this.itemEditors.get(n),o;try{if(i==null){OD(r);let s=hi(t.instance.options);if(s==null)throw Error("CodeView.attachItemEditor: instance options are missing their state");let a=(d)=>{let c=this.idToItem.get(s.id);if(c==null)return;this.options.onItemEditChange?.(d,c.item)},l=this.options.getEditStateKey?.(t.item);if(t.type==="diff"){let d=r("file-diff",{onChange:a},l);o=d,this.itemEditors.set(n,{editor:d,state:s,dispose:d.edit(t.instance)})}else{let d=r("file",{onChange:a},l);o=d,this.itemEditors.set(n,{editor:d,state:s,dispose:d.edit(t.instance)})}}else if(t.type==="diff")i.dispose=i.editor.edit(t.instance);else i.dispose=i.editor.edit(t.instance);this.attachedEditors.add(n)}catch(s){throw o?.cleanUp(),this.releaseRenderedItem(t),s}}syncItemEditors(t){if(this.itemEditors.size===0)return;let n=[];for(let[o,s]of this.itemEditors){let a=this.idToItem.get(o),l=t?.get(o);if(l==null&&a!=null){let{edit:d=!1,collapsed:c=!1}=a.item;if(d){if(c&&this.attachedEditors.delete(o))s.editor.cleanUp("recycle");continue}}else if(l!=null)s.state.removedItem=l.item;this.itemEditors.delete(o),this.attachedEditors.delete(o),n.push(s)}if(n.length===0)return;let r=!1,i;for(let o of n){try{o.dispose()}catch(a){if(!r)r=!0,i=a}let s=this.idToItem.get(o.state.id);if(s!=null)this.markItemLayoutDirty(s)}if(this.render(),r)throw i}requireItemFromState(t){let n=this.idToItem.get(t.id)?.item??t.removedItem;if(n==null)throw Error(`CodeView.onItemEditComplete: unknown item "${t.id}"`);return n}completeFileItemEdit(t,n){let r=this.requireItemFromState(t);if(r.type!=="file")throw Error(`CodeView.onItemEditComplete: item "${t.id}" is not a file item`);let i={...r,file:n.file,annotations:n.lineAnnotations,edit:!1,version:(r.version??0)+1};if((this.options.onItemEditComplete?.(n,r,i)??"reject")==="reject")return"reject";if(this.idToItem.has(r.id))this.updateItem(i);return"accept"}completeDiffItemEdit(t,n){let r=this.requireItemFromState(t);if(r.type!=="diff")throw Error(`CodeView.onItemEditComplete: item "${t.id}" is not a diff item`);let i={...r,fileDiff:n.fileDiff,annotations:n.lineAnnotations,edit:!1,version:(r.version??0)+1};if((this.options.onItemEditComplete?.(n,r,i)??"reject")==="reject")return"reject";if(this.idToItem.has(r.id))this.updateItem(i);return"accept"}renamePendingScrollTarget(t,n){let{pendingScrollTarget:r}=this;if(r==null||r.type==="position"||r.id!==t)return;this.pendingScrollTarget={...r,id:n}}renamePendingLayoutAnchor(t,n){if(this.pendingLayoutAnchor?.id===t)this.pendingLayoutAnchor.id=n}createFileOptionsPrototype(){let t={};for(let n of RS)Vn(t,n,()=>this.options[n]);Vn(t,"stickyHeader",()=>this.options.stickyHeaders),Vn(t,"collapsed",(n)=>{let r=hi(n);if(r==null)return;return this.getItemOptions(r,"file")?.item.collapsed}),Vn(t,"onEditComplete",(n)=>{if(this.options.onItemEditComplete==null)return;let r=hi(n);if(r==null)return;return(i)=>this.completeFileItemEdit(r,i)});for(let n of hS)this.defineItemSharedCallback(t,"file",n);for(let n of gS)this.defineItemSelectionCallback(t,"file",n);return t}createDiffOptionsPrototype(){let t={};for(let n of LS)Vn(t,n,()=>this.options[n]);Vn(t,"stickyHeader",()=>this.options.stickyHeaders),Vn(t,"hunkSeparators",()=>this.options.hunkSeparators),Vn(t,"collapsed",(n)=>{let r=hi(n);if(r==null)return;return this.getItemOptions(r,"diff")?.item.collapsed}),Vn(t,"onEditComplete",(n)=>{if(this.options.onItemEditComplete==null)return;let r=hi(n);if(r==null)return;return(i)=>this.completeDiffItemEdit(r,i)});for(let n of hS)this.defineItemSharedCallback(t,"diff",n);for(let n of gS)this.defineItemSelectionCallback(t,"diff",n);return t}createFileOptions(t){let n=Object.create(this.fileOptionsPrototype);return yS(n,{id:t}),n}createDiffOptions(t){let n=Object.create(this.diffOptionsPrototype);return yS(n,{id:t}),n}updateItemOptionsId(t,n){let r=hi(t);if(r==null)throw Error("CodeView.updateItemOptionsId: No valid state");r.id=n}getItemOptions(t,n){let r=this.idToItem.get(t.id);if(r==null||r.type!==n)return;return r}defineItemSharedCallback(t,n,r){Vn(t,r,(i)=>{if(this.options[r]==null)return;let o=hi(i);if(o==null)return;let s=o.callbackCache??={},a=s[r];if(a==null)a=(...l)=>{let d=this.getItemOptions(o,n);if(d==null)return;let c=this.options[r];return c?.(...l,d)},s[r]=a;return a})}defineItemSelectionCallback(t,n,r){Vn(t,r,(i)=>{let o=hi(i);if(o==null)return;let s=o.callbackCache??={},a=s[r];if(a==null)a=(l)=>{let d=this.getItemOptions(o,n);if(d==null)return;let c=l==null?null:{id:d.item.id,range:l};if(this.options.controlledSelection!==!0){if(l!=null||this.selectedLines?.id===d.item.id)this.applySelectedLines(c,{notify:!1})}this.options.onSelectedLinesChange?.(c);let m=this.options[r];return m?.(l,d)},s[r]=a;return a})}markLayoutDirtyFromIndex(t){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??t,t)}markItemLayoutDirty(t){if(this.items[t.index]!==t)throw Error(`CodeView.markItemLayoutDirty: unknown item id "${t.item.id}"`);this.markLayoutDirtyFromIndex(t.index)}tryAppendItems(t){if(t.length<=this.items.length)return!1;for(let n=0;n<this.items.length;n++){let r=this.items[n];if(r==null)throw Error("CodeView.tryAppendItems: missing existing item");let i=t[n];if(i==null||r.item.id!==i.id||r.type!==i.type)return!1}for(let n=0;n<this.items.length;n++){let r=this.items[n];if(r==null)throw Error("CodeView.tryAppendItems: missing existing item");let i=t[n];if(i==null)throw Error("CodeView.tryAppendItems: append candidate missing prefix item");if(this.syncItemRecord(r,i))this.markLayoutDirtyFromIndex(n)}return this.appendItemsInternal(t.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(t){let{items:n,idToItem:r}=this,i=new Set(n),o=[],s=new Map,a=new Map,l=new Map,d;for(let c=0;c<t.length;c++){let m=t[c];if(m==null)throw Error("CodeView.reconcileItems: missing input item");if(s.has(m.id))throw Error(`CodeView.setItems: duplicate id "${m.id}"`);let p=r.get(m.id),h=p!=null&&p.type===m.type?p:this.createItem(m,c,0);if(h.index=c,p!=null&&p.type===m.type){if(i.delete(p),this.syncItemRecord(h,m))d=Math.min(d??c,c)}else d=Math.min(d??c,c);if(n[c]!==h)d=Math.min(d??c,c);o.push(h),s.set(m.id,h),a.set(h.instance,h)}if(d==null){if(i.size===0)return;d=Math.max(o.length-1,0)}this.capturePendingLayoutAnchor(s);for(let c=0;c<n.length;c++){let m=n[c];if(m==null||!i.has(m))continue;l.set(m.item.id,m),this.releaseRenderedItem(m);let p=Math.max(o.length-1,0);d=Math.min(d??p,p)}if(this.items=o,this.idToItem=s,this.instanceToItem=a,this.renderState.firstIndex>=o.length)this.resetRenderState();else if(this.renderState.lastIndex>=o.length)this.renderState.lastIndex=o.length-1;return this.markLayoutDirtyFromIndex(d),this.scrollDirty=!0,this.render(),l.size>0?l:void 0}syncItemRecord(t,n){if(t.type!==n.type)throw Error(`CodeView.syncItemRecord: type mismatch for id "${n.id}"`);if(t.version===n.version)return!1;return t.item=n,t.version=n.version,t.renderedOptionsRevision=-1,!0}getMaxScrollTopForHeight(t){let{paddingBottom:n,paddingTop:r}=this.getLayout();return Math.max(r+this.header.height+t+this.footer.height+n-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>SS}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),AD):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(t){let n=this.getMaxPagedScrollTop();return Math.max(0,Math.min(t,n))}clampScrollTop(t){let n=this.getMaxScrollTop();return Math.max(0,Math.min(t,n))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(t){let n=this.getMaxScrollPageOffset();return Math.max(0,Math.min(t,n))}resolveScrollPageWindow(t,n){let r=qn(this.clampPagedScrollTop(n)),i=this.clampScrollPageOffset(t-r);return r=qn(this.clampPagedScrollTop(t-i)),i=this.clampScrollPageOffset(t-r),{pagedScrollTop:r,scrollPageOffset:i}}resolvePagedScrollPosition(t){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(t),scrollPageOffset:0};let n=this.clampScrollPageOffset(this.scrollPageOffset),r=t-n,i=this.getMaxPagedScrollTop(),o=this.getMaxScrollPageOffset(),s=r>SS&&n<o,a=r<PD&&n>0;if(r<0||r>i||s||a)return this.resolveScrollPageWindow(t,a?Math.min(MD,i):$D);return{pagedScrollTop:qn(this.clampPagedScrollTop(r)),scrollPageOffset:n}}needsScrollPageUpdate(t){let n=qn(this.clampScrollTop(t)),{scrollPageOffset:r}=this.resolvePagedScrollPosition(n);return r!==this.scrollPageOffset}getPagedLayoutTop(t){if(!this.shouldRebaseScroll())return t;return Math.max(t-this.scrollPageOffset,0)}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(t){let n=this.idToItem.get(t.id);if(n==null){console.warn(`CodeView.scrollTo: unknown item id "${t.id}"`);return}if(t.type==="item")return{top:n.top,height:n.height};if(t.type==="range"){let i=this.getRangeScrollPosition(n,t);if(i==null){console.warn(`CodeView.scrollTo: unable to resolve range ${bS(t.range)} for item "${t.id}"`);return}return{top:n.top+i.top,height:i.height}}let r=this.getLineScrollPosition(n,t);if(r==null){console.warn(`CodeView.scrollTo: unable to resolve line ${t.lineNumber} for item "${t.id}"`);return}return{top:n.top+r.top,height:r.height}}normalizeScrollTarget(t){if(t.type==="position"||t.align!=="nearest")return t;let n=this.getScrollTargetRect(t);if(n==null)return;let r=t.offset??0,i=this.getItemTopOffset()+n.top,o=i+n.height,s=this.getScrollTop(),a=s+(t.type==="line"||t.type==="range"?this.getStickyHeaderOffset():0),l=s+this.getHeight();if(i-r<=a&&o+r>=l)return;if(i-r<a)return{...t,align:"start"};if(o+r>l)return{...t,align:"end"}}resolveScrollTargetTop(t){if(t.type==="position"){let i=this.clampScrollTop(t.position);return i!==t.position?i:this.clampScrollTop(t.position-this.getStickyHeaderOffset())}let n=this.idToItem.get(t.id);if(n==null){console.warn(`CodeView.scrollTo: unknown item id "${t.id}"`);return}if(t.type==="item")return this.clampScrollTop(this.resolveAlignedScrollPosition(n.top,n.height,t.align,t.offset));if(t.type==="range"){let i=this.getRangeScrollPosition(n,t);if(i==null){console.warn(`CodeView.scrollTo: unable to resolve range ${bS(t.range)} for item "${t.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(n.top+i.top,i.height,t.align,t.offset,this.getStickyHeaderOffset()))}let r=this.getLineScrollPosition(n,t);if(r==null){console.warn(`CodeView.scrollTo: unable to resolve line ${t.lineNumber} for item "${t.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(n.top+r.top,r.height,t.align,t.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(t,n,r,i=0,o=0){t+=this.getItemTopOffset();let s=this.getHeight();if(r==="center"&&n+i<s)return t-(s-n)/2+i;if(r==="end")return t-(s-n)+i;return t-o-i}getLineScrollPosition(t,n){if(t.type==="diff")return t.instance.getLinePosition(n.lineNumber,n.side);return t.instance.getLinePosition(n.lineNumber)}getRangeScrollPosition(t,n){let{range:r}=n,i=this.getLineScrollPosition(t,{type:"line",id:n.id,lineNumber:r.start,side:r.side}),o=this.getLineScrollPosition(t,{type:"line",id:n.id,lineNumber:r.end,side:r.endSide??r.side});if(i==null||o==null)return;let s=i.top,a=s+i.height,l=o.top,d=l+o.height,c=Math.min(s,l);return{top:c,height:Math.max(a,d)-c}}computeTargetScrollTopForFrame(t,n){if(this.pendingScrollTarget==null)return t;let r=this.resolveScrollTargetTop(this.pendingScrollTarget);if(r==null)return t;let{scrollAnimation:i}=this;if(i==null)return r;return this.computeSpringStep(i,r,n).position}computeSpringStep(t,n,r){let i=Math.max(0,r-t.lastTimestamp),{omega:o}=this.getSmoothScrollSettings(),s=Math.exp(-o*i),a=t.position-n,l=t.velocity+o*a;return{position:n+(a+l*i)*s,velocity:(l*(1-o*i)-o*a)*s}}advanceScrollAnimation(t,n){if(this.pendingScrollTarget==null)return;let r=this.resolveScrollTargetTop(this.pendingScrollTarget);if(r==null){this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;return}let i=this.scrollAnimation;if(i==null)return r;i.position+=n;let{position:o,velocity:s}=this.computeSpringStep(i,r,t);i.lastTimestamp=t,i.position=o,i.velocity=s;let{positionEpsilon:a,velocityEpsilon:l}=this.getSmoothScrollSettings();if(Math.abs(r-o)<=a&&Math.abs(s)<=l)return i.position=r,i.velocity=0,this.scrollAnimation=void 0,r;return i.position}computeRenderRangeAndEmit=(t=performance.now())=>{if(e.__STOP||this.container==null)return;if(!this.isReady())return;let n=this.getHeight(),r=this.getScrollTop(),i=r,o=this.pendingLayoutAnchor!=null,s=this.getScrollAnchor(i);if(this.layoutDirtyIndex!=null)this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,o=!0;if(o&&s!=null){let R=this.resolveAnchoredScrollTop(s);if(R!=null){let A=R-i;if(i=R,this.scrollAnimation!=null)this.scrollAnimation.position+=A}}if(o)i=this.clampScrollTop(i),this.syncContainerHeight();let a=this.computeTargetScrollTopForFrame(i,t),l=!o&&(this.renderState.scrollTop===-1||Math.abs(a-this.renderState.scrollTop)>n+this.config.overscrollSize*2);if(l)s=void 0;this.windowSpecs=Yx({scrollTop:a-this.header.height,height:n,scrollHeight:this.getScrollHeight(),fitPerfectly:l,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let d=r;if(this.pendingScrollTarget!=null&&a!==d||this.needsScrollPageUpdate(a))this.applyScrollFix(a,d,this.windowSpecs),d=a;let{top:c,bottom:m}=this.windowSpecs,{firstIndex:p,lastIndex:h}=this.renderState;if(p>=0)for(let R=p;R<=h;R++){let A=this.items[R];if(A==null)throw Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${R}`);if(!(A.top>c-A.height&&A.top<=m))this.releaseRenderedItem(A)}let x=this.reconcileHeaderFooterHosts(),I,v=new Set,S=this.findFirstVisibleIndex(c),b=this.findLastVisibleIndex(m);for(let R=S;R<=b;R++){let A=this.items[R];if(A==null)throw Error("CodeView.computeRenderRangeAndEmit: missing item");let{instance:O}=A;if(A.element==null){if(A.element=this.acquireElement(),vS(this.stickyContainer,A.element,I),O.virtualizedSetup(),ES(A,A.element))A.renderedOptionsRevision=this.renderOptionsRevision,v.add(A);I=A.element}else{if(vS(this.stickyContainer,A.element,I),ES(A,void 0,A.renderedOptionsRevision!==this.renderOptionsRevision))A.renderedOptionsRevision=this.renderOptionsRevision,v.add(A);I=A.element}if(A.item.edit===!0)this.attachItemEditor(A)}if(this.renderState.firstIndex=S<=b?S:-1,this.renderState.lastIndex=b,this.flushSlotCoordinator(),this.flushManagers(v),x)this.measureMountedHosts();this.reconcileRenderedItems(v),this.syncContainerHeight(),this.updateStickyPositioning();let E=s!=null?this.resolveAnchoredScrollTop(s):void 0;if(s===this.pendingLayoutAnchor)this.pendingLayoutAnchor=void 0;let w=E!=null?E-i:0,T=a,L=!1;if(this.pendingScrollTarget!=null){let R=this.advanceScrollAnimation(t,w);if(R!=null)T=R,L=!0;else T=i}else T=E??a;if(T!==d)this.applyScrollFix(T,d,this.windowSpecs),d=T;if(L&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget))this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;if(this.renderState.scrollTop=qn(d),this.updateStickyPositioning(),this.validateStickyContainerHeight(),this.fixContainerFocus(),l||this.scrollAnimation!=null)this.render()};flushManagers(t){for(let n of t)n.instance.flushManagers()}syncContainerHeight(){let t=this.getPagedScrollHeight();if(this.container==null||this.containerHeight===t)return;this.container.style.height=`${t}px`,this.containerHeight=t}getStickyBounds(t){let{firstIndex:n,lastIndex:r}=t!=null?{firstIndex:this.findFirstVisibleIndex(t.top),lastIndex:this.findLastVisibleIndex(t.bottom)}:this.renderState;if(n===-1||r===-1||n>r)return;let i=this.items[n]?.instance.getAdvancedStickySpecs(t),o=this.items[r]?.instance.getAdvancedStickySpecs(t);if(i==null||o==null)return;return{stickyTop:this.getPagedLayoutTop(Math.max(i.topOffset,0)),stickyBottom:this.getPagedLayoutTop(o.topOffset+o.height)}}applyStickyPositioning({stickyTop:t,stickyBottom:n}){let r=this.getHeight(),{itemMetricsCache:i}=this,o=n-t;this.renderState.stickyHeight=o,this.renderState.stickyTop=t,this.renderState.stickyBottom=n,this.stickyOffset.style.height=`${t}px`;let s=(Math.random()*i.lineHeight>>0)*-1,a=-Math.max(o+s,0)+r;this.stickyContainer.style.top=`${a}px`,this.stickyContainer.style.bottom=`${a+i.diffHeaderHeight}px`}syncPagedScrollScaffolding(t){this.syncContainerHeight();let n=this.getStickyBounds(t);if(n==null){this.stickyOffset.style.height=`${this.getPagedLayoutTop(t.top)}px`;return}this.applyStickyPositioning(n)}reconcileRenderedItems(t){let{firstIndex:n,lastIndex:r}=this.renderState;if(n===-1)return;let i=-1,o=!1;for(let s=n;s<this.items.length;s++){if(!o&&s>r)break;let a=this.items[s];if(a==null)throw Error("CodeView.reconcileRenderedItems: Invalid item");if(i===-1)i=a.top;else if(a.top!==i)a.top=i,a.instance.syncVirtualizedTop(),o=!0;if(t==null?s<=r:t.has(a)){if(a.instance.reconcileHeights())o=!0,a.height=a.instance.getVirtualizedHeight();this.validateRenderedItemHeight(a)}if(i+=a.instance.getVirtualizedHeight(),s<this.items.length-1)i+=this.getLayout().gap}if(o&&i!=null)this.scrollDirty=!0,this.scrollHeight=i}updateStickyPositioning(){let t=this.getStickyBounds();if(t==null){if(this.renderState.firstIndex===-1)this.stickyOffset.style.height="";return}let{stickyTop:n,stickyBottom:r}=t;if(r-n===this.renderState.stickyHeight&&n===this.renderState.stickyTop&&r===this.renderState.stickyBottom)return;this.applyStickyPositioning(t)}handleScroll=()=>{if(e.__STOP)return;this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render()};clearPendingScroll=()=>{this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0};handleResize=(t)=>{let n=!1;for(let r of t)if(r.target===this.stickyContainer){let i=r.borderBoxSize[0].blockSize;if(Math.abs(i-this.renderState.stickyHeight)>=xS){let o=this.getScrollTop(),s=this.getScrollAnchor(o);this.reconcileRenderedItems(),this.updateStickyPositioning();let a=s!=null?this.resolveAnchoredScrollTop(s):void 0;if(a!=null){let l=a-o;if(this.applyScrollFix(a,o,this.windowSpecs),this.scrollAnimation!=null)this.scrollAnimation.position+=l}if(this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget))this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;n=!0}}else if(r.target===this.header.element||r.target===this.footer.element){let i=r.target===this.header.element?this.header:this.footer,o=r.borderBoxSize[0].blockSize;if(o!==i.height){let s=this.getScrollTop(),a=this.getScrollAnchor(s);this.setHostHeight(i,o);let l=a!=null?this.resolveAnchoredScrollTop(a):void 0;if(l!=null){let d=l-s;if(this.applyScrollFix(l,s,this.windowSpecs),this.scrollAnimation!=null)this.scrollAnimation.position+=d}if(this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget))this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;n=!0}}else this.scrollDirty=!0,this.heightDirty=!0,n=!0;if(n)this.render(!0)};getScrollAnchorViewportTop(t,n){return t<n?n+this.getStickyHeaderOffset():n}getScrollAnchor(t,n=this.idToItem){let r,{pendingLayoutAnchor:i}=this;if(i!=null){let c=this.idToItem.get(i.id);if(c!=null&&n.get(i.id)===c)return i;if(c!=null)r=c}if(t<=0)return;let{firstIndex:o,lastIndex:s,stickyTop:a,stickyBottom:l}=this.renderState;if(o===-1||s===-1)return;let d=this.getHeight();if(a===-1||l===-1)return;for(let c=o;c<=s;c++){let m=this.items[c];if(m==null)continue;let p=this.getItemTopOffset()+m.top;if(p+m.height<=t)continue;if(p>=t+d)break;if(n.get(m.item.id)!==m){r??=m;continue}if(p>=t)return{type:"item",id:m.item.id,viewportOffset:p-t};let h=this.getScrollAnchorViewportTop(p,t)-p,x=m.instance.getNumericScrollAnchor(h);if(x!=null){let I=p+x.top;return{type:"line",id:m.item.id,lineNumber:x.lineNumber,side:x.side,viewportOffset:I-t}}}if(r!=null)for(let c=r.index+1;c<this.items.length;c++){let m=this.items[c];if(m!=null&&n.get(m.item.id)===m)return{type:"item",id:m.item.id,viewportOffset:0}}}resolveAnchoredScrollTop(t){let n=this.idToItem.get(t.id);if(n==null)return;let r=this.getItemTopOffset();if(t.type==="item"){let s=r+n.top;return this.clampScrollTop(s-t.viewportOffset)}let i=n.type==="diff"?n.instance.getLinePosition(t.lineNumber,t.side):n.instance.getLinePosition(t.lineNumber);if(i==null)return;let o=r+n.top+i.top;return this.clampScrollTop(o-t.viewportOffset)}applyScrollFix(t,n,r){if(this.root==null)return;let i=qn(this.clampScrollTop(t)),o=qn(n),{scrollPageOffset:s}=this,a=qn(this.clampPagedScrollTop(o-s)),{pagedScrollTop:l,scrollPageOffset:d}=this.resolvePagedScrollPosition(i),c=l,m=s!==d;if(i===this.renderState.scrollTop&&i===o&&c===a&&!m)return;if(this.suspendScrollInteractions(),c!==a||m)this.scrollPageOffset=d,this.syncPagedScrollScaffolding(r);if(c!==a)this.root.scrollTo({top:c,behavior:"instant"});this.renderState.scrollTop=i,this.scrollTop=i,this.scrollDirty=!1}isPendingTargetSettled(t){let n=this.resolveScrollTargetTop(t);if(n==null)return!0;return qn(this.getScrollTop())===qn(n)}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let t=this.root?.scrollTop??0;return this.scrollTop=this.clampScrollTop(t+this.scrollPageOffset),this.scrollTop}getHeight(){if(!this.heightDirty)return this.height;return this.heightDirty=!1,this.height=this.root?.getBoundingClientRect().height??0,this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;let t=this.buildSlotSnapshot(this.slotCoordinator);if(zx(this.slotSnapshot,t))return;this.slotSnapshot=t,this.slotCoordinator.onSnapshotChange(t)}notifyScroll(){if(this.scrollListeners.size===0)return;let t=this.getScrollTop();for(let n of this.scrollListeners)n(t,this)}findFirstVisibleIndex(t){let n=0,r=this.items.length-1,i=this.items.length;while(n<=r){let o=n+r>>1,s=this.items[o];if(s==null)throw Error("CodeView.findFirstVisibleIndex: invalid item index");if(s.top+s.height>t)i=o,r=o-1;else n=o+1}return i}findLastVisibleIndex(t){let n=0,r=this.items.length-1,i=-1;while(n<=r){let o=n+r>>1,s=this.items[o];if(s==null)throw Error("CodeView.findLastVisibleIndex: invalid item index");if(s.top<=t)i=o,n=o+1;else r=o-1}return i}recomputeLayout(t=0,n){if(this.items.length===0){this.scrollHeight=0;return}let r=this.getLayout(),i=0;if(t>0){let o=this.items[t-1];if(o==null)throw Error("CodeView.recomputeLayout: invalid dirty index");i=o.top+o.height+r.gap}for(let o=t;o<this.items.length;o++){let s=this.items[o];if(s==null)throw Error("CodeView.recomputeLayout: invalid item index");if(s.top=i,s.type==="diff")s.height=s.instance.updateCodeViewLayout(s.item.fileDiff,i,n,s.item.annotations??[]);else s.height=s.instance.updateCodeViewLayout(s.item.file,i,n,s.item.annotations??[]);if(i+=s.height,o<this.items.length-1)i+=r.gap}if(i!==this.scrollHeight)this.scrollDirty=!0;this.scrollHeight=i}resetRenderState(){this.renderState.scrollTop=-1,this.renderState.firstIndex=-1,this.renderState.lastIndex=-1,this.renderState.stickyHeight=0,this.renderState.stickyTop=-1,this.renderState.stickyBottom=-1}getFitPerfectlyOverscroll(){return this.getLayout().gap+this.itemMetricsCache.diffHeaderHeight}};function DD(e){if(e.instance.cleanUp(!0),e.type==="diff")return e.instance.updateCodeViewLayout(e.item.fileDiff,e.top,void 0,e.item.annotations??[]);else return e.instance.updateCodeViewLayout(e.item.file,e.top,void 0,e.item.annotations??[])}function HD(e,t){return!Cn(e.theme??Oe,t.theme??Oe)||(e.themeType??"system")!==(t.themeType??"system")||e.unsafeCSS!==t.unsafeCSS}function _D(e,t){return(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS||(e.diffStyle??"split")!==(t.diffStyle??"split")||(e.diffIndicators??"bars")!==(t.diffIndicators??"bars")||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function UD(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function BD(e){if(e instanceof SVGElement)return!0;return ai(e)&&(e.hasAttribute("data-core-css")||e.hasAttribute("data-theme-css")||e.hasAttribute("data-unsafe-css"))}function bS(e){let t=CS(e.start,e.side),n=CS(e.end,e.endSide??e.side);return t===n?t:`${t}-${n}`}function CS(e,t){if(t==null)return`${e}`;return`${t==="deletions"?"D":"A"}${e}`}function ES(e,t,n=!1){if(e.type==="diff")return e.instance.render({deferManagers:!0,fileContainer:t,fileDiff:e.item.fileDiff,forceRender:n,lineAnnotations:e.item.annotations??[]});else return e.instance.render({deferManagers:!0,fileContainer:t,file:e.item.file,forceRender:n,lineAnnotations:e.item.annotations??[]})}function vS(e,t,n){if(n==null){if(e.firstChild!==t)e.prepend(t);return}if(n.nextSibling!==t)n.after(t)}function GD(e){return(e.annotations?.length??0)>0}function jD(e,{hasHeaderRenderers:t,hasAnnotationRenderer:n,hasGutterRenderer:r}){if(e.length===0)return;if(t||r)return e;if(!n)return;let i=[];for(let o of e)if(GD(o.item))i.push(o);return i.length>0?i:void 0}var C={};Bt(C,{Assign:()=>T_,Clone:()=>oo,Create:()=>H_,Discard:()=>__,Metrics:()=>Wn,Update:()=>U_});var Wn={assign:0,create:0,clone:0,discard:0,update:0};var He={};Bt(He,{Get:()=>k_,Reset:()=>E_,Set:()=>v_});var y={};Bt(y,{And:()=>pp,ArrayLiteral:()=>qH,ArrowFunction:()=>zH,Call:()=>KH,ConstDeclaration:()=>JH,Constant:()=>XS,Counted:()=>_H,Entries:()=>UH,Every:()=>NH,HasPropertyKey:()=>GH,If:()=>ZH,IsArray:()=>VS,IsBigInt:()=>xH,IsBoolean:()=>IH,IsConstructor:()=>LH,IsDeepEqual:()=>jH,IsEqual:()=>RH,IsFunction:()=>wH,IsGreaterEqualThan:()=>MH,IsGreaterThan:()=>AH,IsInteger:()=>SH,IsLessEqualThan:()=>$H,IsLessThan:()=>PH,IsMaxLength:()=>FH,IsMinLength:()=>OH,IsNull:()=>bH,IsNumber:()=>CH,IsObject:()=>WS,IsObjectNotArray:()=>EH,IsString:()=>vH,IsSymbol:()=>kH,IsUndefined:()=>TH,Keys:()=>BH,Member:()=>WH,MultipleOf:()=>n_,New:()=>VH,Not:()=>KS,Or:()=>zS,ReduceAnd:()=>e_,ReduceOr:()=>t_,Return:()=>QH,Some:()=>DH,SomeAll:()=>HH,Statements:()=>YH,Ternary:()=>XH});var u={};Bt(u,{Counted:()=>lH,Entries:()=>cH,EntriesRegExp:()=>dH,Every:()=>iH,EveryAll:()=>oH,GraphemeCount:()=>tH,HasPropertyKey:()=>uH,IsArray:()=>Ca,IsBigInt:()=>ba,IsBoolean:()=>US,IsClassInstance:()=>eH,IsConstructor:()=>WD,IsDeepEqual:()=>fp,IsEqual:()=>se,IsFunction:()=>BS,IsGreaterEqualThan:()=>jS,IsGreaterThan:()=>JD,IsInteger:()=>dp,IsLessEqualThan:()=>GS,IsLessThan:()=>ZD,IsMaxLength:()=>nH,IsMinLength:()=>rH,IsMultipleOf:()=>QD,IsNull:()=>wd,IsNumber:()=>Ld,IsObject:()=>Ea,IsObjectNotArray:()=>XD,IsString:()=>va,IsSymbol:()=>YD,IsUndefined:()=>cp,IsUnsafePropertyKey:()=>qS,IsValueLike:()=>mp,Keys:()=>Td,ShiftLeft:()=>Rd,Some:()=>sH,SomeAll:()=>aH,Symbols:()=>mH,Values:()=>fH});function ro(e,t,n){return e>=t&&e<=n}function MS(e){return e===8205}function qD(e){return ro(e,55296,56319)}function PS(e){return ro(e,127462,127487)}function OS(e){return ro(e,65024,65039)}function FS(e){return ro(e,768,879)||ro(e,6832,6911)||ro(e,7616,7679)||ro(e,65056,65071)}function kd(e){return e>65535?2:1}function $S(e,t){while(t<e.length){let n=e.codePointAt(t);if(FS(n)||OS(n))t+=kd(n);else break}return t}function up(e,t){let n=e.codePointAt(t),r=t+kd(n);r=$S(e,r);while(r<e.length-1&&MS(e.codePointAt(r))){let i=e.codePointAt(r+1);r+=1+kd(i),r=$S(e,r)}if(PS(n)&&r<e.length&&PS(e.codePointAt(r)))r+=kd(e.codePointAt(r));return r}function NS(e){return e>=768&&(qD(e)||FS(e)||OS(e)||MS(e))}function DS(e){let t=0,n=0;while(n<e.length)n=up(e,n),t++;return t}function zD(e,t){let n=0,r=0;while(r<e.length)if(r=up(e,r),++n>=t)return!0;return!1}function KD(e,t){let n=0,r=0;while(r<e.length)if(r=up(e,r),++n>t)return!1;return!0}function HS(e,t){if(t===0)return!0;if(e.length<t)return!1;let n=0;while(!0){if(NS(e.charCodeAt(n)))return zD(e,t);if(++n>=t)return!0}}function _S(e,t){if(e.length<=t)return!0;let n=0;while(!0){if(NS(e.charCodeAt(n)))return KD(e,t);if(++n>t)return!1}}function Ca(e){return Array.isArray(e)}function ba(e){return se(typeof e,"bigint")}function US(e){return se(typeof e,"boolean")}function WD(e){if(cp(e)||!BS(e))return!1;let t=Function.prototype.toString.call(e);if(/^class\s/.test(t))return!0;if(/\[native code\]/.test(t))return!0;return!1}function BS(e){return se(typeof e,"function")}function dp(e){return Number.isInteger(e)}function wd(e){return se(e,null)}function Ld(e){return Number.isFinite(e)}function XD(e){return Ea(e)&&!Ca(e)}function Ea(e){return se(typeof e,"object")&&!wd(e)}function va(e){return se(typeof e,"string")}function YD(e){return se(typeof e,"symbol")}function cp(e){return se(e,void 0)}function se(e,t){return e===t}function JD(e,t){return e>t}function ZD(e,t){return e<t}function GS(e,t){return e<=t}function jS(e,t){return e>=t}function QD(e,t){if(ba(e)||ba(t))return BigInt(e)%BigInt(t)===0n;let n=0.0000000001;if(!Ld(e))return!0;if(dp(e)&&1/t%1===0)return!0;let r=e%t;return Math.min(Math.abs(r),Math.abs(r-t),Math.abs(r+t))<n}function eH(e){if(!Ea(e))return!1;let t=globalThis.Object.getPrototypeOf(e);if(wd(t))return!1;return se(typeof t.constructor,"function")&&!(se(t.constructor,globalThis.Object)||se(t.constructor.name,"Object"))}function mp(e){return ba(e)||US(e)||wd(e)||Ld(e)||va(e)||cp(e)}function tH(e){return DS(e)}function nH(e,t){return _S(e,t)}function rH(e,t){return HS(e,t)}function iH(e,t,n){return e.every((r,i)=>i<t||n(r,i))}function oH(e,t,n){let r=!0;return e.forEach((i,o)=>{if(o>=t&&!n(i,o))r=!1}),r}function sH(e,t){return e.some((n,r)=>t(n,r))}function aH(e,t){let n=!1;return e.forEach((r,i)=>{if(t(r,i))n=!0}),n}function lH(e,t){return e.reduce((n,r,i)=>t(r,i)?++n:n,0)}function Rd(e,t,n){return se(e.length,0)?n():t(e[0],e.slice(1))}function qS(e){return se(e,"__proto__")||se(e,"constructor")||se(e,"prototype")}function uH(e,t){return qS(t)?Object.prototype.hasOwnProperty.call(e,t):(t in e)}function dH(e){return Td(e).map((t)=>[new RegExp(`^${t}$`),e[t]])}function cH(e){return Object.entries(e)}function Td(e){return Object.getOwnPropertyNames(e)}function mH(e){return Object.getOwnPropertySymbols(e)}function fH(e){return Object.values(e)}function pH(e,t){if(!Ea(t))return!1;let n=Td(e);return se(n.length,Td(t).length)&&n.every((r)=>fp(e[r],t[r]))}function hH(e,t){return Ca(t)&&se(e.length,t.length)&&e.every((n,r)=>fp(e[r],t[r]))}function fp(e,t){return Ca(e)?hH(e,t):Ea(e)?pH(e,t):se(e,t)}var gH=/^[\p{ID_Start}_$][\p{ID_Continue}_$\u200C\u200D]*$/u;function yH(e){return gH.test(e)}function pp(e,t){return`(${e} && ${t})`}function zS(e,t){return`(${e} || ${t})`}function KS(e){return`!(${e})`}function VS(e){return`Array.isArray(${e})`}function xH(e){return`typeof ${e} === "bigint"`}function IH(e){return`typeof ${e} === "boolean"`}function SH(e){return`Number.isInteger(${e})`}function bH(e){return`${e} === null`}function CH(e){return`Number.isFinite(${e})`}function EH(e){return pp(WS(e),KS(VS(e)))}function WS(e){return`typeof ${e} === "object" && ${e} !== null`}function vH(e){return`typeof ${e} === "string"`}function kH(e){return`typeof ${e} === "symbol"`}function TH(e){return`${e} === undefined`}function wH(e){return`typeof ${e} === "function"`}function LH(e){return`Guard.IsConstructor(${e})`}function RH(e,t){return`${e} === ${t}`}function AH(e,t){return`${e} > ${t}`}function PH(e,t){return`${e} < ${t}`}function $H(e,t){return`${e} <= ${t}`}function MH(e,t){return`${e} >= ${t}`}function OH(e,t){return`Guard.IsMinLength(${e}, ${t})`}function FH(e,t){return`Guard.IsMaxLength(${e}, ${t})`}function NH(e,t,n,r){return se(t,"0")?`${e}.every((${n[0]}, ${n[1]}) => (${r}))`:`${e}.every((${n[0]}, ${n[1]}) => (${n[1]} < ${t}) || (${r}))`}function DH(e,t,n){return`${e}.some((${t[0]}, ${t[1]}) => ${n})`}function HH(e,t,n){return`((value) => { let result = false; value.forEach((${t[0]}, ${t[1]}) => { if (${n}) result = true }); return result })(${e})`}function _H(e,t,n){return`${e}.reduce((result, ${t[0]}, ${t[1]}) => (${n}) ? ++result : result, 0)`}function UH(e){return`Object.entries(${e})`}function BH(e){return`Object.getOwnPropertyNames(${e})`}function GH(e,t){return se(t,'"__proto__"')||se(t,'"constructor"')?`Object.prototype.hasOwnProperty.call(${e}, ${t})`:`${t} in ${e}`}function jH(e,t){return`Guard.IsDeepEqual(${e}, ${t})`}function qH(e){return`[${e.join(", ")}]`}function zH(e,t){return`((${e.join(", ")}) => ${t})`}function KH(e,t){return`${e}(${t.join(", ")})`}function VH(e,t){return`new ${e}(${t.join(", ")})`}function WH(e,t){return`${e}${yH(t)?`.${t}`:`[${XS(t)}]`}`}function XS(e){if(!mp(e))throw Error("Unsupported Constant");return va(e)?JSON.stringify(e):`${e}`}function XH(e,t,n){return`(${e} ? ${t} : ${n})`}function YH(e){return`{ ${e.join("; ")}; }`}function JH(e,t){return`const ${e} = ${t}`}function ZH(e,t){return`if(${e}) { ${t} }`}function QH(e){return`return ${e}`}function e_(e){return se(e.length,0)?"true":e.reduce((t,n)=>pp(t,n))}function t_(e){return se(e.length,0)?"false":e.reduce((t,n)=>zS(t,n))}function n_(e,t){return`Guard.IsMultipleOf(${e}, ${t})`}var qt={};Bt(qt,{IsBigInt64Array:()=>g_,IsBigUint64Array:()=>y_,IsBoolean:()=>r_,IsDate:()=>I_,IsFloat32Array:()=>p_,IsFloat64Array:()=>h_,IsInt16Array:()=>d_,IsInt32Array:()=>m_,IsInt8Array:()=>a_,IsMap:()=>b_,IsNumber:()=>i_,IsRegExp:()=>x_,IsSet:()=>S_,IsString:()=>o_,IsTypeArray:()=>s_,IsUint16Array:()=>c_,IsUint32Array:()=>f_,IsUint8Array:()=>l_,IsUint8ClampedArray:()=>u_});function r_(e){return e instanceof Boolean}function i_(e){return e instanceof Number}function o_(e){return e instanceof String}function s_(e){return globalThis.ArrayBuffer.isView(e)}function a_(e){return e instanceof globalThis.Int8Array}function l_(e){return e instanceof globalThis.Uint8Array}function u_(e){return e instanceof globalThis.Uint8ClampedArray}function d_(e){return e instanceof globalThis.Int16Array}function c_(e){return e instanceof globalThis.Uint16Array}function m_(e){return e instanceof globalThis.Int32Array}function f_(e){return e instanceof globalThis.Uint32Array}function p_(e){return e instanceof globalThis.Float32Array}function h_(e){return e instanceof globalThis.Float64Array}function g_(e){return e instanceof globalThis.BigInt64Array}function y_(e){return e instanceof globalThis.BigUint64Array}function x_(e){return e instanceof globalThis.RegExp}function I_(e){return e instanceof globalThis.Date}function S_(e){return e instanceof globalThis.Set}function b_(e){return e instanceof globalThis.Map}var Ad=u;var dr={immutableTypes:!1,maxErrors:8,maxInstantiationCount:128,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function E_(){dr.immutableTypes=!1,dr.maxErrors=8,dr.maxInstantiationCount=128,dr.useAcceleration=!0,dr.exactOptionalPropertyTypes=!1,dr.enumerableKind=!1,dr.correctiveParse=!1,dr.unionPrioritySort=!0}function v_(e){for(let t of u.Keys(e)){let n=e[t];if(n!==void 0)Object.defineProperty(dr,t,{value:n})}}function k_(){return dr}function gi(e){return He.Get().immutableTypes?Object.freeze(e):e}function T_(e,t){return Wn.assign+=1,gi({...e,...t})}function w_(e){return e}function L_(e){return u.HasPropertyKey(e,"~kind")||u.HasPropertyKey(e,"~unsafe")}function R_(e){let t={};for(let n of u.Keys(e)){if(u.IsUnsafePropertyKey(n))continue;let r=Object.getOwnPropertyDescriptor(e,n);if(r.value=io(r.value),u.IsEqual(r.enumerable,!0))t[n]=r.value;else Object.defineProperty(t,n,r)}return t}function A_(e){let t={};for(let n of u.Keys(e)){if(u.IsUnsafePropertyKey(n))continue;t[n]=io(e[n])}for(let n of u.Symbols(e))t[n]=io(e[n]);return t}function P_(e){return u.IsClassInstance(e)?w_(e):L_(e)?R_(e):A_(e)}function $_(e){return e.map((t)=>io(t))}function M_(e){return e.slice()}function O_(e){return new RegExp(e.source,e.flags)}function F_(e){return new Map(io([...e.entries()]))}function N_(e){return new Set(io([...e.values()]))}function io(e){return qt.IsTypeArray(e)?M_(e):qt.IsRegExp(e)?O_(e):qt.IsMap(e)?F_(e):qt.IsSet(e)?N_(e):u.IsArray(e)?$_(e):u.IsObject(e)?P_(e):e}function oo(e){return Wn.clone+=1,io(e)}function D_(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}function YS(e,t){return{...e,...t}}function H_(e,t,n={}){Wn.create+=1;let r=YS(t,n),i=He.Get().enumerableKind?YS(r,e):D_(r,e);return gi(i)}function __(e,t){Wn.discard+=1;let n={};for(let r of u.Keys(e)){if(t.includes(r))continue;let i=Object.getOwnPropertyDescriptor(e,r);i.value=oo(i.value),Object.defineProperty(n,r,i)}return gi(n)}function U_(e,t,n){Wn.update+=1;let r=He.Get(),i=oo(e);for(let o of Object.keys(t))Object.defineProperty(i,o,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[o]});for(let o of Object.keys(n))Object.defineProperty(i,o,{configurable:!0,enumerable:!0,writable:!0,value:n[o]});return gi(i)}function _(e,t){return u.IsObject(e)&&u.HasPropertyKey(e,"~kind")&&u.IsEqual(e["~kind"],t)}function Ge(e){return u.IsObject(e)}function U(e,t,n){return C.Create({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:n},{})}function yi(e){return _(e,"Deferred")}function B_(e){return C.Update(e,{"~readonly":!0},{})}function ka(e,t){return C.Update(B_(e),{},t)}function JS(e,t,n,r){let i=M(e,t,n);return ka(i,r)}function G_(e){return C.Update(e,{"~optional":!0},{})}function Ta(e,t){return C.Update(G_(e),{},t)}function ZS(e,t,n,r){let i=M(e,t,n);return Ta(i,r)}function tn(e,t){return C.Create({"~kind":"Array"},{type:"array",items:e},t)}function le(e){return _(e,"Array")}function as(e){return C.Discard(e,["~kind","type","items"])}function cr(e,t,n={}){return C.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},n)}function nt(e){return _(e,"Constructor")}function QS(e){return C.Discard(e,["~kind","type","parameters","instanceType"])}function mr(e,t,n={}){return C.Create({["~kind"]:"Function"},{type:"function",parameters:e,returnType:t},n)}function rt(e){return _(e,"Function")}function eb(e){return C.Discard(e,["~kind","type","parameters","returnType"])}function pt(e,t){return C.Create({["~kind"]:"Ref"},{$ref:e},t)}function xe(e){return _(e,"Ref")}function xi(e,t){return C.Create({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function ls(e){return _(e,"Generic")}function us(e){return C.Create({["~kind"]:"Any"},{},e)}function je(e){return _(e,"Any")}var tb="(?!)";function be(e){return C.Create({"~kind":"Never"},{not:{}},e)}function fn(e){return _(e,"Never")}function fr(e,t={}){return U("AddOptional",[e],t)}function so(e,t={}){return Ta(e,t)}function nb(e){return so(e)}function ht(e){return Ge(e)&&u.HasPropertyKey(e,"~optional")}function rb(e){return u.Keys(e).filter((t)=>!ht(e[t]))}function Pd(e){return u.Keys(e)}function $d(e){return u.Values(e)}function q(e,t={}){let n=rb(e),r=n.length>0?{required:n}:{};return C.Create({"~kind":"Object"},{type:"object",...r,properties:e},t)}function V(e){return _(e,"Object")}function ib(e){return C.Discard(e,["~kind","type","properties","required"])}function dt(e){return C.Create({["~kind"]:"Unknown"},{},e)}function it(e){return _(e,"Unknown")}function pr(e,t,n){let r=u.Keys(e).reduce((i,o)=>({...i,[o]:C.Update(e[o],{},{$id:o})}),{});return C.Create({["~kind"]:"Cyclic"},{$defs:r,$ref:t},n)}function Te(e){return _(e,"Cyclic")}function ob(e){return C.Update(e,{["~unsafe"]:null},{})}function Md(e){return u.IsObjectNotArray(e)&&u.HasPropertyKey(e,"~unsafe")&&u.IsNull(e["~unsafe"])}var ee={};Bt(ee,{Match:()=>j_});function j_(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}function wa(...e){let[t,n]=ee.Match(e,{2:(r,i)=>[r,i,i],1:(r)=>[r,dt(),dt()]});return C.Create({["~kind"]:"Infer"},{type:"infer",name:t,extends:n},{})}function ot(e){return _(e,"Infer")}function ao(e,t,n,r={}){return C.Create({"~kind":"Dependent"},{if:e,then:t,else:n},r)}function Ke(e){return _(e,"Dependent")}function sb(e){return C.Discard(e,["~kind","if","then","else"])}function ab(e){return u.IsObjectNotArray(e)}function lb(e){return u.Keys(e).filter((n)=>isNaN(n)).reduce((n,r)=>[...n,e[r]],[])}function ub(e){return u.IsString(e)||u.IsNumber(e)}function db(e,t){let n=ab(e)?lb(e):e;return C.Create({"~kind":"Enum"},{enum:n},t)}function st(e){return _(e,"Enum")}function Ft(e,t={}){return C.Create({"~kind":"Intersect"},{allOf:e},t)}function z(e){return _(e,"Intersect")}function cb(e){return C.Discard(e,["~kind","allOf"])}var ds={};Bt(ds,{CanEvaluate:()=>z_,Evaluate:()=>mb});var hp=void 0;function q_(){try{return mb("null")(),!0}catch{return!1}}function z_(){if(u.IsUndefined(hp))hp=q_();return hp&&He.Get().useAcceleration}function mb(...e){return new globalThis.Function(...e)}var Gr={};Bt(Gr,{Hash:()=>uU,HashCode:()=>xb});function Ve(){throw Error("Unreachable")}function K_(e){let t=new Set,n=e;while(n&&n!==Object.prototype){for(let r of Reflect.ownKeys(n))if(r!=="constructor"&&typeof r!=="symbol")t.add(r);n=Object.getPrototypeOf(n)}return[...t]}function V_(e){return typeof e==="number"}var zt;(function(e){e[e.Array=0]="Array",e[e.BigInt=1]="BigInt",e[e.Boolean=2]="Boolean",e[e.Date=3]="Date",e[e.Constructor=4]="Constructor",e[e.Function=5]="Function",e[e.Null=6]="Null",e[e.Number=7]="Number",e[e.Object=8]="Object",e[e.RegExp=9]="RegExp",e[e.String=10]="String",e[e.Symbol=11]="Symbol",e[e.TypeArray=12]="TypeArray",e[e.Undefined=13]="Undefined"})(zt||(zt={}));var cs=BigInt("14695981039346656037"),[W_,X_]=[BigInt("1099511628211"),BigInt("18446744073709551616")],Y_=Array.from({length:256}).map((e,t)=>BigInt(t)),hb=new Float64Array(1),gb=new DataView(hb.buffer),yb=new Uint8Array(hb.buffer);function wt(e){cs=cs^Y_[e],cs=cs*W_%X_}function J_(e){wt(zt.Array);for(let t of e)Ii(t)}function Z_(e){wt(zt.BigInt),gb.setBigInt64(0,e);for(let t of yb)wt(t)}function fb(e){wt(zt.Boolean),wt(e?1:0)}function Q_(e){wt(zt.Constructor),Ii(e.toString())}function eU(e){wt(zt.Date),Ii(e.getTime())}function tU(e){wt(zt.Function),Ii(e.toString())}function nU(e){wt(zt.Null)}function pb(e){wt(zt.Number),gb.setFloat64(0,e,!0);for(let t of yb)wt(t)}function rU(e){wt(zt.Object);for(let t of K_(e).sort())Ii(t),Ii(e[t])}function iU(e){wt(zt.RegExp),gp(e.toString())}var oU=new TextEncoder;function gp(e){wt(zt.String);for(let t of oU.encode(e))wt(t)}function sU(e){wt(zt.Symbol),Ii(e.toString())}function aU(e){wt(zt.TypeArray);let t=new Uint8Array(e.buffer);for(let n=0;n<t.length;n++)wt(t[n])}function lU(e){return wt(zt.Undefined)}function Ii(e){return qt.IsTypeArray(e)?aU(e):qt.IsDate(e)?eU(e):qt.IsRegExp(e)?iU(e):qt.IsBoolean(e)?fb(e.valueOf()):qt.IsString(e)?gp(e.valueOf()):qt.IsNumber(e)?pb(e.valueOf()):V_(e)?pb(e):u.IsArray(e)?J_(e):u.IsBoolean(e)?fb(e):u.IsBigInt(e)?Z_(e):u.IsConstructor(e)?Q_(e):u.IsNull(e)?nU(e):u.IsObject(e)?rU(e):u.IsString(e)?gp(e):u.IsSymbol(e)?sU(e):u.IsUndefined(e)?lU(e):u.IsFunction(e)?tU(e):Ve()}function xb(e){return cs=BigInt("14695981039346656037"),Ii(e),cs}function uU(e){return xb(e).toString(16).padStart(16,"0")}function Ib(e){switch(e.keyword){case"additionalProperties":return"must not have additional properties";case"anyOf":return"must match a schema in anyOf";case"boolean":return"schema is false";case"const":return"must be equal to constant";case"contains":return"must contain at least 1 valid item";case"dependencies":return`must have properties ${e.params.dependencies.join(", ")} when property ${e.params.property} is present`;case"dependentRequired":return`must have properties ${e.params.dependencies.join(", ")} when property ${e.params.property} is present`;case"enum":return"must be equal to one of the allowed values";case"exclusiveMaximum":return`must be ${e.params.comparison} ${e.params.limit}`;case"exclusiveMinimum":return`must be ${e.params.comparison} ${e.params.limit}`;case"format":return`must match format "${e.params.format}"`;case"if":return`must match "${e.params.failingKeyword}" schema`;case"maxItems":return`must not have more than ${e.params.limit} items`;case"maxLength":return`must not have more than ${e.params.limit} characters`;case"maxProperties":return`must not have more than ${e.params.limit} properties`;case"maximum":return`must be ${e.params.comparison} ${e.params.limit}`;case"minItems":return`must not have fewer than ${e.params.limit} items`;case"minLength":return`must not have fewer than ${e.params.limit} characters`;case"minProperties":return`must not have fewer than ${e.params.limit} properties`;case"minimum":return`must be ${e.params.comparison} ${e.params.limit}`;case"multipleOf":return`must be multiple of ${e.params.multipleOf}`;case"not":return"must not be valid";case"oneOf":return"must match exactly one schema in oneOf";case"pattern":return`must match pattern "${e.params.pattern}"`;case"propertyNames":return`property names ${e.params.propertyNames.join(", ")} are invalid`;case"required":return`must have required properties ${e.params.requiredProperties.join(", ")}`;case"type":return typeof e.params.type==="string"?`must be ${e.params.type}`:`must be either ${e.params.type.join(" or ")}`;case"unevaluatedItems":return"must not have unevaluated items";case"unevaluatedProperties":return"must not have unevaluated properties";case"uniqueItems":return"must not have duplicate items";case"~refine":return e.params.message;default:return"an unknown validation error occurred"}}var dU=Ib;function Sb(){return dU}class Od{constructor(e,t){this.type=e,this.decode=t}Encode(e){let t=this.type,n=Kt(t)?(o)=>this.decode(t["~codec"].decode(o)):this.decode,r=Kt(t)?(o)=>t["~codec"].encode(e(o)):e,i={decode:n,encode:r};return C.Update(this.type,{"~codec":i},{})}}class Fd{constructor(e){this.type=e}Decode(e){return new Od(this.type,e)}}function Nd(e){return new Fd(e)}function Cb(e,t){return Nd(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function Eb(e,t){return Nd(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function Kt(e){return Ge(e)&&u.HasPropertyKey(e,"~codec")&&u.IsObject(e["~codec"])&&u.HasPropertyKey(e["~codec"],"encode")&&u.HasPropertyKey(e["~codec"],"decode")}function vb(e){return ms(e)}function lo(e){return Ge(e)&&u.HasPropertyKey(e,"~immutable")}function hr(e,t={}){return U("AddReadonly",[e],t)}function uo(e,t={}){return ka(e,t)}function kb(e){return uo(e)}function co(e){return Ge(e)&&u.HasPropertyKey(e,"~readonly")}function mU(e,t){let n=Dd(e)?[...e["~refine"],t]:[t];return C.Update(e,{"~refine":n},{})}function Tb(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[i,o,()=>"Refine Error"]});return mU(t,{check:n,error:r})}function fU(e){return u.IsObjectNotArray(e)&&u.HasPropertyKey(e,"check")&&u.HasPropertyKey(e,"error")&&u.IsFunction(e.check)&&u.IsFunction(e.error)}function Dd(e){return Ge(e)&&u.HasPropertyKey(e,"~refine")&&u.IsArray(e["~refine"])&&u.Every(e["~refine"],0,(t)=>fU(t))}var wb="-?(?:0|[1-9][0-9]*)n";function La(e){return C.Create({"~kind":"BigInt"},{type:"bigint"},e)}function pn(e){return _(e,"BigInt")}function Hd(e){return C.Create({"~kind":"Boolean"},{type:"boolean"},e)}function Vt(e){return _(e,"Boolean")}function Ra(e){return C.Create({"~kind":"Identifier"},{name:e})}function Lb(e){return _(e,"Identifier")}var _d="-?(?:0|[1-9][0-9]*)";function mo(e){return C.Create({"~kind":"Integer"},{type:"integer"},e)}function It(e){return _(e,"Integer")}class Rb extends Error{constructor(e){super("Invalid Literal value");Object.defineProperty(this,"cause",{value:{value:e},writable:!1,configurable:!1,enumerable:!1})}}function pU(e){return u.IsBigInt(e)?"bigint":u.IsBoolean(e)?"boolean":u.IsNumber(e)?"number":u.IsString(e)?"string":(()=>{throw new Rb(e)})()}function ne(e,t){return C.Create({"~kind":"Literal"},{type:pU(e),const:e},t)}function Ud(e){return u.IsBigInt(e)||u.IsBoolean(e)||u.IsNumber(e)||u.IsString(e)}function Ab(e){return ae(e)&&u.IsBigInt(e.const)}function Pb(e){return ae(e)&&u.IsBoolean(e.const)}function Bd(e){return ae(e)&&u.IsNumber(e.const)}function Gd(e){return ae(e)&&u.IsString(e.const)}function ae(e){return _(e,"Literal")}function fs(e){return C.Create({"~kind":"Null"},{type:"null"},e)}function gr(e){return _(e,"Null")}var jd="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function hn(e){return C.Create({"~kind":"Number"},{type:"number"},e)}function _e(e){return _(e,"Number")}function ps(e){return C.Create({"~kind":"Symbol"},{type:"symbol"},e)}function yr(e){return _(e,"Symbol")}function fo(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[i,o,o],1:(i)=>[i,dt(),dt()]});return C.Create({"~kind":"Parameter"},{name:t,extends:n,equals:r},{})}function $b(e){return _(e,"Parameter")}var qd=".*";function Wt(e){return C.Create({"~kind":"String"},{type:"string"},e)}function ct(e){return _(e,"String")}function J(e,t={}){return C.Create({"~kind":"Union"},{anyOf:e},t)}function F(e){return _(e,"Union")}function Mb(e){return C.Discard(e,["~kind","anyOf"])}function Aa(e){let t=Ob(e);return u.IsEqual(t.length,2)?t[0]:[]}function hU(e){return!0}function Fb(e){return u.ShiftLeft(e,(t,n)=>gU(t)?Fb(n):!1,()=>!0)}function Nb(e){return u.IsEqual(e.length,0)?!1:Fb(e)}function gU(e){return F(e)?Nb(e.anyOf):ae(e)?hU(e.const):!1}function zd(e){return Nb(e)}function Kd(e){return C.Create({["~kind"]:"TemplateLiteral"},{type:"string",pattern:e},{})}function Db(e,t,n=[]){return u.ShiftLeft(e,(r,i)=>Db(i,t,[...n,`${r}${t}`]),()=>n)}function yU(e,t){return u.IsEqual(e.length,0)?[`${t}`]:Db(e,t)}function Hb(e,t,n=[]){return u.ShiftLeft(t,(r,i)=>Hb(e,i,[...n,..._b(e,r)]),()=>n)}function _b(e,t){return F(t)?Hb(e,t.anyOf):ae(t)?yU(e,t.const):Ve()}function Ub(e,t){return u.ShiftLeft(t,(n,r)=>Ub(_b(e,n),r),()=>e)}function xU(e){return e.map((t)=>ne(t))}function IU(e){let t=Ub([],e),n=xU(t);return J(n)}function SU(e){return u.IsEqual(e.length,0)?Ve():u.IsEqual(e.length,1)&&ae(e[0])?e[0]:IU(e)}function yp(e){let t=Aa(e);return u.IsEqual(t.length,0)?Wt():zd(t)?SU(t):Kd(e)}function Pa(e){let t=yp(e);return Le(t)?Wt():t}function nn(e,t){let r={[e]:t};return C.Create({["~kind"]:"Record"},{type:"object",patternProperties:r})}function Bb(e){return nn(Xn,e)}function Gb(e){return q({true:e,false:e})}function We(e,t={}){let[n,r,i]=[e,e.length,!1];return C.Create({["~kind"]:"Tuple"},{type:"array",additionalItems:i,items:n,minItems:r},t)}function re(e){return _(e,"Tuple")}function jb(e){return C.Discard(e,["~kind","type","items","minItems","additionalItems"])}function bU(e){return C.Discard(e,["~readonly"])}function xp(e,t){return C.Update(bU(e),{},t)}function qb(e,t,n,r){let i=M(e,t,n);return xp(i,r)}function zb(e,t={}){return U("RemoveReadonly",[e],t)}function Kb(e,t={}){return xp(e,t)}function CU(e){return C.Discard(e,["~optional"])}function Ip(e,t){return C.Update(CU(e),{},t)}function Vb(e,t,n,r){let i=M(e,t,n);return Ip(i,r)}function Wb(e,t={}){return U("RemoveOptional",[e],t)}function Vd(e,t={}){return Ip(e,t)}function Sp(e){return e.reduceRight((n,r,i)=>({[i]:r,...n}),{})}function Xb(e){let t=Sp(e.items);return q(t)}function bp(e){return V(e)||re(e)}function EU(e,t){return co(e)?co(t)?!0:!1:!1}function vU(e,t){return ht(e)?ht(t)?!0:!1:!1}function kU(e,t){let n=EU(e,t),r=vU(e,t),i=Ue([e,t]),o=Kb(Vd(i));return n&&r?uo(so(o)):n&&!r?uo(o):!n&&r?so(o):o}function TU(e,t,n){return n in e?n in t?kU(e[n],t[n]):e[n]:(n in t)?t[n]:be()}function wU(e,t){return[...new Set([...u.Keys(e),...u.Keys(t)])].reduce((i,o)=>({...i,[o]:TU(e,t,o)}),{})}function Yb(e){return V(e)?e.properties:re(e)?Sp(e.items):{}}function Jb(e,t){let n=Yb(e),r=Yb(t),i=wU(n,r);return q(i)}function LU(e,t){let n=hs(e,t);return u.IsEqual(n,Ma)?e:u.IsEqual(n,Oa)?t:u.IsEqual(n,$a)?t:be()}function RU(e,t){let n=bp(e),r=bp(t);return n&&r?Jb(e,t):n&&!r?e:!n&&r?t:LU(e,t)}function Zb(e,t){return fn(e)?e:je(e)?e:it(e)?t:fn(t)?t:je(t)?t:it(t)?e:RU(e,t)}function AU(e,t){return F(e)||F(t)}function PU(e,t){let n=Fn(e),r=Fn(t);return AU(n,r)?Ue([n,r]):Zb(n,r)}function Qb(e,t,n=[]){return u.ShiftLeft(t,(r,i)=>Qb(e,i,[...n,PU(r,e)]),()=>u.IsEqual(n.length,0)?[e]:n)}function eC(e,t,n=[]){return u.ShiftLeft(e,(r,i)=>eC(i,t,[...n,...Fa([r],t)]),()=>n)}function Fa(e,t=[]){return u.ShiftLeft(e,(n,r)=>F(n)?Fa(r,eC(n.anyOf,t)):Fa(r,Qb(n,t)),()=>t)}function $U(e,t){let n=Pt({},e,t);return W.IsExtendsTrueLike(n)?[]:[e]}function tC(e,t,n=[]){return u.ShiftLeft(e,(r,i)=>tC(i,t,[...n,...$U(r,t)]),()=>n)}function Wd(e,t){let n=Fn(e),r=F(n)?n.anyOf:[n],i=tC(r,t);return rn(i)}function Yn(e,t,n){let r=Ue([e,t]),i=Wd(n,e);return rn([r,i])}function Xt(e,t=[]){return u.ShiftLeft(e,(n,r)=>Xt(r,[...t,ne(n)]),()=>rn(t))}function Ue(e){let t=Fa(e),n=Cp(t);return rn(n)}function Nt(e){let t=Pa(e);return Fn(t)}function rn(e){let t=Cp(e);return Si(t)}function Fn(e){return Ke(e)?Yn(e.if,e.then,e.else):st(e)?Xt(e.enum):z(e)?Ue(e.allOf):Le(e)?Nt(e.pattern):F(e)?rn(e.anyOf):e}function Si(e){return u.IsEqual(e.length,1)?e[0]:u.IsEqual(e.length,0)?be():J(e)}function nC(e,t){let n=Xt(e);return bi(n,t)}function rC(e,t){return nn(Ci,t)}function iC(e,t){let n=Ue(e);return bi(n,t)}function oC(e,t){return u.IsString(e)||u.IsNumber(e)?q({[e]:t}):u.IsEqual(e,!1)?q({false:t}):u.IsEqual(e,!0)?q({true:t}):q({})}function sC(e,t){return nn(gs,t)}function aC(e,t){return u.HasPropertyKey(e,"pattern")&&(u.IsString(e.pattern)||e.pattern instanceof RegExp)?nn(e.pattern.toString(),t):nn(Xn,t)}function lC(e,t){let n=Aa(e);return zd(n)?bi(Nt(e),t):nn(e,t)}function MU(e){return F(e)?po(e.anyOf):[e]}function po(e,t=[]){return u.ShiftLeft(e,(n,r)=>po(r,[...t,...MU(n)]),()=>t)}function OU(e){return e.some((t)=>ct(t)||_e(t)||It(t))}function FU(e,t){return u.IsEqual(OU(e),!0)?nn(Xn,t):void 0}function NU(e,t){return e.reduce((n,r)=>ae(r)&&(u.IsString(r.const)||u.IsNumber(r.const))?{...n,[r.const]:t}:n,{})}function DU(e,t){let n=NU(e,t);return q(n)}function uC(e,t){let n=po(e),r=FU(n,t);return Ge(r)?r:DU(n,t)}function bi(e,t){return je(e)?Bb(t):Vt(e)?Gb(t):st(e)?nC(e.enum,t):It(e)?rC(e,t):z(e)?iC(e.allOf,t):ae(e)?oC(e.const,t):_e(e)?sC(e,t):F(e)?uC(e.anyOf,t):ct(e)?aC(e,t):Le(e)?lC(e.pattern,t):q({})}function Ep(e,t,n){return te([e])?C.Update(bi(e,t),{},n):Xd(e,t,n)}function dC(e,t,n,r,i){let o=M(e,t,n),s=M(e,t,r);return Ep(o,s,i)}var Ci=`^${_d}$`,gs=`^${jd}$`,Xn=`^${qd}$`;function Xd(e,t,n={}){return U("Record",[e,t],n)}function ys(e,t,n={}){return Ep(e,t,n)}function cC(e,t){return nn(e,t)}function Yd(e){return u.IsEqual(e,Xn)?Wt():u.IsEqual(e,Ci)?mo():u.IsEqual(e,gs)?hn():yp(e)}function St(e){return u.Keys(e.patternProperties)[0]}function Ei(e){let t=St(e);return Yd(t)}function Ae(e){return e.patternProperties[St(e)]}function Se(e){return _(e,"Record")}function ho(e){return C.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function vi(e){return _(e,"Rest")}function Jd(e){return C.Create({["~kind"]:"This"},{$ref:"#"},e)}function Zd(e){return _(e,"This")}function xs(e){return C.Create({"~kind":"Undefined"},{type:"undefined"},e)}function Jn(e){return _(e,"Undefined")}function Qd(e){return C.Create({"~kind":"Void"},{type:"void"},e)}function gn(e){return _(e,"Void")}function _U(e,t){return u.IsEqual(e,"Array")?tn(t[0]):u.IsEqual(e,"Capitalize")?tc(t[0]):u.IsEqual(e,"ConstructorParameters")?sc(t[0]):u.IsEqual(e,"Evaluate")?LE(t[0]):u.IsEqual(e,"Exclude")?ac(t[0],t[1]):u.IsEqual(e,"Extract")?lc(t[0],t[1]):u.IsEqual(e,"Index")?_a(t[0],t[1]):u.IsEqual(e,"InstanceType")?uc(t[0]):u.IsEqual(e,"Lowercase")?nc(t[0]):u.IsEqual(e,"NonNullable")?dc(t[0]):u.IsEqual(e,"Omit")?cc(t[0],t[1]):u.IsEqual(e,"Parameters")?mc(t[0]):u.IsEqual(e,"Partial")?fc(t[0]):u.IsEqual(e,"Pick")?pc(t[0],t[1]):u.IsEqual(e,"Readonly")?hc(t[0]):u.IsEqual(e,"KeyOf")?Ua(t[0]):u.IsEqual(e,"Record")?Xd(t[0],t[1]):u.IsEqual(e,"Required")?gc(t[0]):u.IsEqual(e,"ReturnType")?yc(t[0]):u.IsEqual(e,"Uncapitalize")?rc(t[0]):u.IsEqual(e,"Uppercase")?ic(t[0]):Ha(pt(e),t)}function go(){throw Error("Unreachable")}function gC(e,t=[]){return u.ShiftLeft(e,(n,r)=>gC(r,[...t,n[1]]),()=>t)}function jr(e){return u.IsEqual(e.length,3)?[e[0],...gC(e[1])]:[]}function yC(e){return fo(e[0],e[2],e[4])}function xC(e){return fo(e[0],e[2],e[2])}function IC(e){return fo(e[0],dt(),e[2])}function SC(e){return fo(e,dt(),dt())}function bC(e){return e}function CC(e){return jr(e)}function EC(e){return e[1]}function vC(e){return jr(e)}function kC(e){return e[1]}function TC(e){return _U(e[0],e[1])}function wC(e){return null}function LC(e){return Wt()}function RC(e){return hn()}function AC(e){return Hd()}function PC(e){return xs()}function $C(e){return fs()}function MC(e){return mo()}function OC(e){return La()}function FC(e){return dt()}function NC(e){return us()}function DC(e){return q({})}function HC(e){return be()}function _C(e){return ps()}function UC(e){return Qd()}function BC(e){return Jd()}function GC(e){return ne(BigInt(e))}function jC(e){return ne(u.IsEqual(e,"true"))}function qC(e){return ne(parseFloat(e))}function zC(e){return ne(e)}function KC(e){return e[1]}function VC(e){return ne(e)}function WC(e){return u.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function XC(e){return e[1]}function YC(e){return ec(e)}function JC(e){return u.IsEqual(e.length,6)?ao(e[1],e[3],e[5]):ao(e[1],e[3],dt())}function ZC(e){return e.length>0}function QC(e){return e.reduce((t,n)=>u.IsEqual(n.length,3)?[...t,[n[1]]]:[...t,[]],[])}function e0(e){return u.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function t0(e){return u.IsArray(e)&&u.IsEqual(e.length,3)?e[1]:e}function n0(e){return u.IsEqual(e.length,2)?e[1]:[]}function mC(e,t){return t.reduce((n,r)=>{let i=r;return u.IsEqual(i.length,1)?_a(n,i[0]):u.IsEqual(i.length,0)?tn(n):go()},e)}function fC(e,t){return u.IsEqual(t.length,3)?oc(e,t[0],t[1],t[2]):e}function UU(e,t){return u.IsArray(t)&&u.IsEqual(t.length,0)?e:xc(e,t)}function r0(e){let[t,n,r,i,o]=e;return UU(t?fC(Ua(mC(n,r)),i):fC(mC(n,r),i),o)}function vp(e,t){return u.IsEqual(t.length,3)?(()=>{let[n,r,i]=t,o=vp(r,i);if(u.IsEqual(n,"&"))return z(o)?Ft([e,...o.allOf]):Ft([e,o]);if(u.IsEqual(n,"|"))return F(o)?J([e,...o.anyOf]):J([e,o]);go()})():e}function i0(e){return e}function o0(e){let[t,n]=e;return vp(t,n)}function s0(e){return e}function a0(e){let[t,n]=e;return vp(t,n)}function l0(e){return wE(e[1])}function u0(e){return e[1]}function d0(e){return xi(e[0],e[2])}function c0(e){return u.IsEqual(e.length,4)?wa(e[1],e[3]):u.IsEqual(e.length,2)?wa(e[1],dt()):go()}function m0(e){return e}function f0(e){return`${e}`}function p0(e){return e}function h0(e){return e}function g0(e){return It(e[3])?Ci:_e(e[3])?gs:yr(e[3])?Xn:ct(e[3])?Xn:go()}function y0(e){return e}function x0(e){return e.length>0}function I0(e){return e.length>0}function S0(e){let[t,n,r,i,o]=e;return{[n]:t&&r?hr(fr(o)):t&&!r?hr(o):!t&&r?fr(o):o}}function b0(e){return e}function C0(e){return jr(e)}function E0(e){return e.reduce((t,n)=>u.HasPropertyKey(n,Ci)||u.HasPropertyKey(n,gs)||u.HasPropertyKey(n,Xn)?[t[0],C.Assign(t[1],n)]:[C.Assign(t[0],n),t[1]],[{},{}])}function v0(e){return E0(e[1])}function k0(e){let[t,n]=e,r=u.IsEqual(u.Keys(n).length,0)?{}:{patternProperties:n};return q(t,r)}function T0(e){return u.IsEqual(e.length,5)?hr(fr(e[4])):u.IsEqual(e.length,3)?e[2]:u.IsEqual(e.length,4)?u.IsEqual(e[2],"readonly")?hr(e[3]):fr(e[3]):go()}function w0(e){if(!u.IsArray(e)||!u.IsEqual(e.length,3))return e;let[t,n,r]=e;return t&&r?hr(fr(n)):t&&!r?hr(n):!t&&r?fr(n):n}function L0(e){return u.IsEqual(e.length,2)?ho(e[1]):u.IsEqual(e.length,1)?e[0]:go()}function R0(e){return jr(e)}function A0(e){return We(e[1])}function P0(e){return hr(fr(e[4]))}function $0(e){return hr(e[3])}function M0(e){return fr(e[3])}function O0(e){return e[2]}function F0(e){return e}function N0(e){return u.IsEqual(e.length,2)?ho(e[1]):u.IsEqual(e.length,1)?e[0]:go()}function D0(e){return jr(e)}function H0(e){return mr(e[1],e[4])}function _0(e){return cr(e[2],e[5])}function pC(e,t){return u.IsEqual(e,"remove")?zb(t):u.IsEqual(e,"add")?hr(t):t}function U0(e){return u.IsEqual(e.length,2)&&u.IsEqual(e[0],"-")?"remove":u.IsEqual(e.length,2)&&u.IsEqual(e[0],"+")?"add":u.IsEqual(e.length,1)?"add":"none"}function hC(e,t){return u.IsEqual(e,"remove")?Wb(t):u.IsEqual(e,"add")?fr(t):t}function B0(e){return u.IsEqual(e.length,2)&&u.IsEqual(e[0],"-")?"remove":u.IsEqual(e.length,2)&&u.IsEqual(e[0],"+")?"add":u.IsEqual(e.length,1)?"add":"none"}function G0(e){return u.IsEqual(e.length,2)?[e[1]]:[]}function j0(e){return u.IsArray(e[6])&&u.IsEqual(e[6].length,1)?Na(Ra(e[3]),e[5],e[6][0],pC(e[1],hC(e[8],e[10]))):Na(Ra(e[3]),e[5],pt(e[3]),pC(e[1],hC(e[8],e[10])))}function q0(e){return pt(e)}function z0(e){return BigInt(e)}function K0(e){return parseFloat(e)}function V0(e){return u.IsEqual(e,"true")}function W0(e){return e}function X0(e){return null}function Y0(e){return}function J0(e){return{[e[0]]:e[2]}}function Z0(e){return jr(e)}function BU(e){return e.reduce((t,n)=>C.Assign(t,n),{})}function Q0(e){return BU(e[1])}function eE(e){return jr(e)}function tE(e){return e[1]}function nE(e){return e}function rE(e){return La()}function iE(e){return Wt()}function oE(e){return hn()}function sE(e){return mo()}function aE(e){return be()}function lE(e){return ne(e)}function uE(e){return e}function dE(e){return J(e[1])}function cE(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function mE(e){return[e[0],...e[1]]}function fE(e){return e}function pE(e){return e[1]}function hE(e){return jr(e)}function gE(e){return u.IsEqual(e.length,2)?e[1]:[]}function yE(e){let t=e[2],n=e[3],[r,i]=e[4],o=u.IsEqual(u.Keys(i).length,0)?{}:{patternProperties:i};return{[e[1]]:xi(t,Da(n,r,o))}}function xE(e){let t=e[2],[n,r]=e[3],i=u.IsEqual(u.Keys(r).length,0)?{}:{patternProperties:r};return{[e[1]]:Da(t,n,i)}}function IE(e){return{[e[1]]:xi(e[2],e[4])}}function SE(e){return{[e[1]]:e[3]}}function bE(e){return null}function CE(e){return e}function EE(e){return jr(e)}function vE(e){return e[1]}function kE(e){let[t,n]=[e[0],e[1]];return RE(C.Assign(t,E0(n)[0]))}function TE(e){return e}function Ba(e){return se(e.length,2)}function ue(e,t,n){return Ba(e)?t(e[0],e[1]):n()}function qU(e,t){return se(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function qe(e,t){for(let n=0;n<e.length;n++){let r=qU(e[n],t);if(Ba(r))return r}return[]}function kp(e,t){return Array.from({length:t-e+1},(n,r)=>String.fromCharCode(e+r))}var AE=[...kp(97,122),...kp(65,90)],Tp="0",wp=kp(49,57),Is=[Tp,...wp],PE=" ",Ss=`
|
|
1525
|
+
`;var ki="_",Ic=".",$E="$",Sc="-";var ME="//",OE="/*",KU="*/";function FE(e){let t=e.indexOf(KU);return se(t,-1)?"":e.slice(t+2)}function NE(e){let t=e.indexOf(Ss);return se(t,-1)?"":e.slice(t)}function VU(e){return e.replace(/^[ \t\r\f\v]+/,"")}function bc(e){let t=VU(e);return t.startsWith(OE)?bc(FE(t.slice(2))):t.startsWith(ME)?bc(NE(t.slice(2))):t}function Lt(e){let t=e.trimStart();return t.startsWith(OE)?Lt(FE(t.slice(2))):t.startsWith(ME)?Lt(NE(t.slice(2))):t}function Cc(e,t){return ue(qe([e],t),(n,r)=>[n,r],()=>["",t])}function WU(e,t){return e.includes(t)}function bs(e,t,n,r=""){return ue(qe(e,n),(i,o)=>WU(t,i)?bs(e,t,o,r):bs(e,t,o,`${r}${i}`),()=>[r,n])}function XU(e){return qe(wp,e)}var YU=[...Is,ki];function JU(e){return bs(YU,[ki],e)}function ZU(e){return ue(qe([Tp],e),(t,n)=>[t,n],()=>ue(XU(e),(t,n)=>ue(JU(n),(r,i)=>[`${t}${r}`,i],()=>[]),()=>[]))}function Ec(e){return ZU(Lt(e))}function QU(e){return Cc(Sc,e)}function e2(e){return ue(QU(e),(t,n)=>ue(Ec(n),(r,i)=>[`${t}${r}`,i],()=>[]),()=>[])}function DE(e){return e2(Lt(e))}function t2(e){return ue(DE(e),(t,n)=>ue(qe(["n"],n),(r,i)=>[`${t}`,i],()=>[]),()=>[])}function Lp(e){return t2(e)}function Rp(e,t){return qe([e],t)}function k(e,t){return se(e,"")?["",t]:e.startsWith(Ss)?Rp(e,bc(t)):e.startsWith(PE)?Rp(e,t):Rp(e,Lt(t))}var HE=[...AE,ki,$E];function n2(e){return qe(HE,e)}var r2=[...HE,...Is];function _E(e,t=""){return ue(qe(r2,e),(n,r)=>_E(r,`${t}${n}`),()=>[t,e])}function i2(e){return ue(n2(e),(t,n)=>ue(_E(n),(r,i)=>[`${t}${r}`,i],()=>[]),()=>[])}function Xe(e){return i2(Lt(e))}var o2=[...Is,ki];function s2(e){return Ba(qe([Ic],e))}function UE(e){return ue(bs(o2,[ki],e),(t,n)=>se(t,"")?[]:[t,n],()=>[])}function a2(e){return ue(qe([Ic],e),(t,n)=>ue(UE(n),(r,i)=>[`0${t}${r}`,i],()=>[]),()=>[])}function l2(e){return ue(Ec(e),(t,n)=>ue(qe([Ic],n),(r,i)=>ue(UE(i),(o,s)=>[`${t}${r}${o}`,s],()=>[`${t}`,i]),()=>[`${t}`,n]),()=>[])}function u2(e){return s2(e)?a2(e):l2(e)}function BE(e){return u2(Lt(e))}function d2(e){return Cc(Sc,e)}function c2(e){return ue(d2(e),(t,n)=>ue(BE(n),(r,i)=>[`${t}${r}`,i],()=>[]),()=>[])}function vc(e){return c2(Lt(e))}function m2(e){return se(e,"")?[]:[e.slice(0,1),e.slice(1)]}function GE(e,t){return Rd(e,(n,r)=>t.startsWith(n)?!0:GE(r,t),()=>!1)}function Ti(e,t,n=""){return ue(m2(t),(r,i)=>GE(e,t)?[n,t]:Ti(e,i,`${n}${r}`),()=>[])}function f2(e,t,n){return ue(qe([e],n),(r,i)=>ue(Ti([t],i),(o,s)=>ue(qe([t],s),(a,l)=>[`${o}`,l],()=>[]),()=>[]),()=>[])}function p2(e,t,n){return ue(qe([e],n),(r,i)=>ue(Ti([Ss,t],i),(o,s)=>ue(qe([t],s),(a,l)=>[`${o}`,l],()=>[]),()=>[]),()=>[])}function jE(e,t,n,r){return n?f2(e,t,Lt(r)):p2(e,t,Lt(r))}function h2(e,t){return qe(e,t)}function g2(e,t){return jE(e,e,!1,t)}function y2(e,t){return ue(h2(e,t),(n,r)=>g2(n,`${n}${r}`),()=>[])}function kc(e,t){return y2(e,Lt(t))}function qE(e,t){return ue(Ti(e,t),(n,r)=>se(n,"")?[]:[n,r],()=>[])}var f=(e,t,n=()=>[])=>e.length===2?t(e):n(),I2=(e)=>f(f(Xe(e),([t,n])=>f(k("extends",n),([r,i])=>f(me(i),([o,s])=>f(k("=",s),([a,l])=>f(me(l),([d,c])=>[[t,r,o,a,d],c]))))),([t,n])=>[yC(t),n]),S2=(e)=>f(f(Xe(e),([t,n])=>f(k("extends",n),([r,i])=>f(me(i),([o,s])=>[[t,r,o],s]))),([t,n])=>[xC(t),n]),b2=(e)=>f(f(Xe(e),([t,n])=>f(k("=",n),([r,i])=>f(me(i),([o,s])=>[[t,r,o],s]))),([t,n])=>[IC(t),n]),C2=(e)=>f(Xe(e),([t,n])=>[SC(t),n]),VE=(e)=>f(f(I2(e),([t,n])=>[t,n],()=>f(S2(e),([t,n])=>[t,n],()=>f(b2(e),([t,n])=>[t,n],()=>f(C2(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[bC(t),n]),WE=(e,t=[])=>f(f(k(",",e),([n,r])=>f(VE(r),([i,o])=>[[n,i],o])),([n,r])=>WE(r,[...t,n]),()=>[t,e]),E2=(e)=>f(f(f(VE(e),([t,n])=>f(WE(n),([r,i])=>f(f(k(",",i),([o,s])=>[[o],s],()=>[[],i]),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[CC(t),n]),$p=(e)=>f(f(k("<",e),([t,n])=>f(E2(n),([r,i])=>f(k(">",i),([o,s])=>[[t,r,o],s]))),([t,n])=>[EC(t),n]),XE=(e,t=[])=>f(f(k(",",e),([n,r])=>f(me(r),([i,o])=>[[n,i],o])),([n,r])=>XE(r,[...t,n]),()=>[t,e]),v2=(e)=>f(f(f(me(e),([t,n])=>f(XE(n),([r,i])=>f(f(k(",",i),([o,s])=>[[o],s],()=>[[],i]),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[vC(t),n]),k2=(e)=>f(f(k("<",e),([t,n])=>f(v2(n),([r,i])=>f(k(">",i),([o,s])=>[[t,r,o],s]))),([t,n])=>[kC(t),n]),T2=(e)=>f(f(Xe(e),([t,n])=>f(k2(n),([r,i])=>[[t,r],i])),([t,n])=>[TC(t),n]),YE=(e)=>f(f(f(k(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[wC(t),n]),JE=(e)=>f(k("string",e),([t,n])=>[LC(t),n]),ZE=(e)=>f(k("number",e),([t,n])=>[RC(t),n]),w2=(e)=>f(k("boolean",e),([t,n])=>[AC(t),n]),L2=(e)=>f(k("undefined",e),([t,n])=>[PC(t),n]),R2=(e)=>f(k("null",e),([t,n])=>[$C(t),n]),QE=(e)=>f(k("integer",e),([t,n])=>[MC(t),n]),A2=(e)=>f(k("bigint",e),([t,n])=>[OC(t),n]),P2=(e)=>f(k("unknown",e),([t,n])=>[FC(t),n]),$2=(e)=>f(k("any",e),([t,n])=>[NC(t),n]),M2=(e)=>f(k("object",e),([t,n])=>[DC(t),n]),O2=(e)=>f(k("never",e),([t,n])=>[HC(t),n]),ev=(e)=>f(k("symbol",e),([t,n])=>[_C(t),n]),F2=(e)=>f(k("void",e),([t,n])=>[UC(t),n]),N2=(e)=>f(k("this",e),([t,n])=>[BC(t),n]),D2=(e)=>f(f(k("${",e),([t,n])=>f(me(n),([r,i])=>f(k("}",i),([o,s])=>[[t,r,o],s]))),([t,n])=>[KC(t),n]),Ap=(e)=>f(Ti(["${","`"],e),([t,n])=>[VC(t),n]),tv=(e)=>f(f(f(Ap(e),([t,n])=>f(D2(n),([r,i])=>f(tv(i),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f(f(Ap(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>f(f(Ap(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[WC(t),n]),Mp=(e)=>f(f(k("`",e),([t,n])=>f(tv(n),([r,i])=>f(k("`",i),([o,s])=>[[t,r,o],s]))),([t,n])=>[XC(t),n]),H2=(e)=>f(Mp(e),([t,n])=>[YC(t),n]),_2=(e)=>f(f(f(k("if",e),([t,n])=>f(me(n),([r,i])=>f(k("then",i),([o,s])=>f(me(s),([a,l])=>f(k("else",l),([d,c])=>f(me(c),([m,p])=>[[t,r,o,a,d,m],p])))))),([t,n])=>[t,n],()=>f(f(k("if",e),([t,n])=>f(me(n),([r,i])=>f(k("then",i),([o,s])=>f(me(s),([a,l])=>[[t,r,o,a],l])))),([t,n])=>[t,n],()=>[])),([t,n])=>[JC(t),n]),U2=(e)=>f(Lp(e),([t,n])=>[GC(t),n]),B2=(e)=>f(f(k("true",e),([t,n])=>[t,n],()=>f(k("false",e),([t,n])=>[t,n],()=>[])),([t,n])=>[jC(t),n]),G2=(e)=>f(vc(e),([t,n])=>[qC(t),n]),j2=(e)=>f(kc(["'",'"'],e),([t,n])=>[zC(t),n]),q2=(e)=>f(f(f(k("keyof",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[ZC(t),n]),nv=(e,t=[])=>f(f(f(k("[",e),([n,r])=>f(me(r),([i,o])=>f(k("]",o),([s,a])=>[[n,i,s],a]))),([n,r])=>[n,r],()=>f(f(k("[",e),([n,r])=>f(k("]",r),([i,o])=>[[n,i],o])),([n,r])=>[n,r],()=>[])),([n,r])=>nv(r,[...t,n]),()=>[t,e]),z2=(e)=>f(nv(e),([t,n])=>[QC(t),n]),K2=(e)=>f(f(f(k("extends",e),([t,n])=>f(me(n),([r,i])=>f(k("?",i),([o,s])=>f(me(s),([a,l])=>f(k(":",l),([d,c])=>f(me(c),([m,p])=>[[t,r,o,a,d,m],p])))))),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[e0(t),n]),V2=(e)=>f(f(f(k("(",e),([t,n])=>f(me(n),([r,i])=>f(k(")",i),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f(JE(e),([t,n])=>[t,n],()=>f(ZE(e),([t,n])=>[t,n],()=>f(w2(e),([t,n])=>[t,n],()=>f(L2(e),([t,n])=>[t,n],()=>f(R2(e),([t,n])=>[t,n],()=>f(QE(e),([t,n])=>[t,n],()=>f(A2(e),([t,n])=>[t,n],()=>f(P2(e),([t,n])=>[t,n],()=>f($2(e),([t,n])=>[t,n],()=>f(M2(e),([t,n])=>[t,n],()=>f(O2(e),([t,n])=>[t,n],()=>f(ev(e),([t,n])=>[t,n],()=>f(F2(e),([t,n])=>[t,n],()=>f(N2(e),([t,n])=>[t,n],()=>f(U2(e),([t,n])=>[t,n],()=>f(B2(e),([t,n])=>[t,n],()=>f(G2(e),([t,n])=>[t,n],()=>f(j2(e),([t,n])=>[t,n],()=>f(H2(e),([t,n])=>[t,n],()=>f(_2(e),([t,n])=>[t,n],()=>f(iB(e),([t,n])=>[t,n],()=>f(aB(e),([t,n])=>[t,n],()=>f(fB(e),([t,n])=>[t,n],()=>f(mB(e),([t,n])=>[t,n],()=>f(yB(e),([t,n])=>[t,n],()=>f(T2(e),([t,n])=>[t,n],()=>f(xB(e),([t,n])=>[t,n],()=>[])))))))))))))))))))))))))))),([t,n])=>[t0(t),n]),W2=(e)=>f(f(f(k("with",e),([t,n])=>f(Iv(n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[n0(t),n]),rv=(e)=>f(f(q2(e),([t,n])=>f(V2(n),([r,i])=>f(z2(i),([o,s])=>f(K2(s),([a,l])=>f(W2(l),([d,c])=>[[t,r,o,a,d],c]))))),([t,n])=>[r0(t),n]),iv=(e)=>f(f(f(k("&",e),([t,n])=>f(rv(n),([r,i])=>f(iv(i),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[i0(t),n]),ov=(e)=>f(f(rv(e),([t,n])=>f(iv(n),([r,i])=>[[t,r],i])),([t,n])=>[o0(t),n]),sv=(e)=>f(f(f(k("|",e),([t,n])=>f(ov(n),([r,i])=>f(sv(i),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[s0(t),n]),Tc=(e)=>f(f(ov(e),([t,n])=>f(sv(n),([r,i])=>[[t,r],i])),([t,n])=>[a0(t),n]),X2=(e)=>f(f(k("readonly",e),([t,n])=>f(Tc(n),([r,i])=>[[t,r],i])),([t,n])=>[l0(t),n]),Y2=(e)=>f(f(k("|",e),([t,n])=>f(Tc(n),([r,i])=>[[t,r],i])),([t,n])=>[u0(t),n]),J2=(e)=>f(f($p(e),([t,n])=>f(k("=",n),([r,i])=>f(me(i),([o,s])=>[[t,r,o],s]))),([t,n])=>[d0(t),n]),Z2=(e)=>f(f(f(k("infer",e),([t,n])=>f(Xe(n),([r,i])=>f(k("extends",i),([o,s])=>f(Tc(s),([a,l])=>[[t,r,o,a],l])))),([t,n])=>[t,n],()=>f(f(k("infer",e),([t,n])=>f(Xe(n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>[])),([t,n])=>[c0(t),n]),me=(e)=>f(f(Z2(e),([t,n])=>[t,n],()=>f(Y2(e),([t,n])=>[t,n],()=>f(X2(e),([t,n])=>[t,n],()=>f(Tc(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[m0(t),n]),Q2=(e)=>f(vc(e),([t,n])=>[f0(t),n]),eB=(e)=>f(Xe(e),([t,n])=>[p0(t),n]),tB=(e)=>f(kc(["'",'"'],e),([t,n])=>[h0(t),n]),nB=(e)=>f(f(k("[",e),([t,n])=>f(Xe(n),([r,i])=>f(k(":",i),([o,s])=>f(f(QE(s),([a,l])=>[a,l],()=>f(ZE(s),([a,l])=>[a,l],()=>f(JE(s),([a,l])=>[a,l],()=>f(ev(s),([a,l])=>[a,l],()=>[])))),([a,l])=>f(k("]",l),([d,c])=>[[t,r,o,a,d],c]))))),([t,n])=>[g0(t),n]),av=(e)=>f(f(Q2(e),([t,n])=>[t,n],()=>f(eB(e),([t,n])=>[t,n],()=>f(tB(e),([t,n])=>[t,n],()=>f(nB(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[y0(t),n]),lv=(e)=>f(f(f(k("readonly",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[x0(t),n]),uv=(e)=>f(f(f(k("?",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[I0(t),n]),dv=(e)=>f(f(lv(e),([t,n])=>f(av(n),([r,i])=>f(uv(i),([o,s])=>f(k(":",s),([a,l])=>f(me(l),([d,c])=>[[t,r,o,a,d],c]))))),([t,n])=>[S0(t),n]),wc=(e)=>f(f(f(k(",",e),([t,n])=>f(k(`
|
|
1526
|
+
`,n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f(f(k(";",e),([t,n])=>f(k(`
|
|
1527
|
+
`,n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f(f(k(",",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>f(f(k(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>f(f(k(`
|
|
1528
|
+
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))))),([t,n])=>[b0(t),n]),cv=(e,t=[])=>f(f(wc(e),([n,r])=>f(dv(r),([i,o])=>[[n,i],o])),([n,r])=>cv(r,[...t,n]),()=>[t,e]),rB=(e)=>f(f(f(dv(e),([t,n])=>f(cv(n),([r,i])=>f(f(wc(i),([o,s])=>[[o],s],()=>[[],i]),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[C0(t),n]),Op=(e)=>f(f(k("{",e),([t,n])=>f(rB(n),([r,i])=>f(k("}",i),([o,s])=>[[t,r,o],s]))),([t,n])=>[v0(t),n]),iB=(e)=>f(Op(e),([t,n])=>[k0(t),n]),oB=(e)=>f(f(f(Xe(e),([t,n])=>f(k("?",n),([r,i])=>f(k(":",i),([o,s])=>f(k("readonly",s),([a,l])=>f(me(l),([d,c])=>[[t,r,o,a,d],c]))))),([t,n])=>[t,n],()=>f(f(Xe(e),([t,n])=>f(k(":",n),([r,i])=>f(k("readonly",i),([o,s])=>f(me(s),([a,l])=>[[t,r,o,a],l])))),([t,n])=>[t,n],()=>f(f(Xe(e),([t,n])=>f(k("?",n),([r,i])=>f(k(":",i),([o,s])=>f(me(s),([a,l])=>[[t,r,o,a],l])))),([t,n])=>[t,n],()=>f(f(Xe(e),([t,n])=>f(k(":",n),([r,i])=>f(me(i),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>[])))),([t,n])=>[T0(t),n]),zE=(e)=>f(f(oB(e),([t,n])=>[t,n],()=>f(f(lv(e),([t,n])=>f(me(n),([r,i])=>f(uv(i),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>[])),([t,n])=>[w0(t),n]),mv=(e)=>f(f(f(k("...",e),([t,n])=>f(zE(n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f(f(zE(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[])),([t,n])=>[L0(t),n]),fv=(e,t=[])=>f(f(k(",",e),([n,r])=>f(mv(r),([i,o])=>[[n,i],o])),([n,r])=>fv(r,[...t,n]),()=>[t,e]),sB=(e)=>f(f(f(mv(e),([t,n])=>f(fv(n),([r,i])=>f(f(k(",",i),([o,s])=>[[o],s],()=>[[],i]),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[R0(t),n]),aB=(e)=>f(f(k("[",e),([t,n])=>f(sB(n),([r,i])=>f(k("]",i),([o,s])=>[[t,r,o],s]))),([t,n])=>[A0(t),n]),lB=(e)=>f(f(Xe(e),([t,n])=>f(k("?",n),([r,i])=>f(k(":",i),([o,s])=>f(k("readonly",s),([a,l])=>f(me(l),([d,c])=>[[t,r,o,a,d],c]))))),([t,n])=>[P0(t),n]),uB=(e)=>f(f(Xe(e),([t,n])=>f(k(":",n),([r,i])=>f(k("readonly",i),([o,s])=>f(me(s),([a,l])=>[[t,r,o,a],l])))),([t,n])=>[$0(t),n]),dB=(e)=>f(f(Xe(e),([t,n])=>f(k("?",n),([r,i])=>f(k(":",i),([o,s])=>f(me(s),([a,l])=>[[t,r,o,a],l])))),([t,n])=>[M0(t),n]),cB=(e)=>f(f(Xe(e),([t,n])=>f(k(":",n),([r,i])=>f(me(i),([o,s])=>[[t,r,o],s]))),([t,n])=>[O0(t),n]),KE=(e)=>f(f(lB(e),([t,n])=>[t,n],()=>f(uB(e),([t,n])=>[t,n],()=>f(dB(e),([t,n])=>[t,n],()=>f(cB(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[F0(t),n]),pv=(e)=>f(f(f(k("...",e),([t,n])=>f(KE(n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f(f(KE(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[])),([t,n])=>[N0(t),n]),hv=(e,t=[])=>f(f(k(",",e),([n,r])=>f(pv(r),([i,o])=>[[n,i],o])),([n,r])=>hv(r,[...t,n]),()=>[t,e]),gv=(e)=>f(f(f(pv(e),([t,n])=>f(hv(n),([r,i])=>f(f(k(",",i),([o,s])=>[[o],s],()=>[[],i]),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[D0(t),n]),mB=(e)=>f(f(k("(",e),([t,n])=>f(gv(n),([r,i])=>f(k(")",i),([o,s])=>f(k("=>",s),([a,l])=>f(me(l),([d,c])=>[[t,r,o,a,d],c]))))),([t,n])=>[H0(t),n]),fB=(e)=>f(f(k("new",e),([t,n])=>f(k("(",n),([r,i])=>f(gv(i),([o,s])=>f(k(")",s),([a,l])=>f(k("=>",l),([d,c])=>f(me(c),([m,p])=>[[t,r,o,a,d,m],p])))))),([t,n])=>[_0(t),n]),pB=(e)=>f(f(f(k("+",e),([t,n])=>f(k("readonly",n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f(f(k("-",e),([t,n])=>f(k("readonly",n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f(f(k("readonly",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])))),([t,n])=>[U0(t),n]),hB=(e)=>f(f(f(k("+",e),([t,n])=>f(k("?",n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f(f(k("-",e),([t,n])=>f(k("?",n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f(f(k("?",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])))),([t,n])=>[B0(t),n]),gB=(e)=>f(f(f(k("as",e),([t,n])=>f(me(n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[G0(t),n]),yB=(e)=>f(f(k("{",e),([t,n])=>f(pB(n),([r,i])=>f(k("[",i),([o,s])=>f(Xe(s),([a,l])=>f(k("in",l),([d,c])=>f(me(c),([m,p])=>f(gB(p),([h,x])=>f(k("]",x),([I,v])=>f(hB(v),([S,b])=>f(k(":",b),([E,w])=>f(me(w),([T,L])=>f(YE(L),([R,A])=>f(k("}",A),([O,D])=>[[t,r,o,a,d,m,h,I,S,E,T,R,O],D]))))))))))))),([t,n])=>[j0(t),n]),xB=(e)=>f(Xe(e),([t,n])=>[q0(t),n]),IB=(e)=>f(Lp(e),([t,n])=>[z0(t),n]),SB=(e)=>f(vc(e),([t,n])=>[K0(t),n]),bB=(e)=>f(f(k("true",e),([t,n])=>[t,n],()=>f(k("false",e),([t,n])=>[t,n],()=>[])),([t,n])=>[V0(t),n]),CB=(e)=>f(kc(['"',"'"],e),([t,n])=>[W0(t),n]),EB=(e)=>f(k("null",e),([t,n])=>[X0(t),n]),vB=(e)=>f(k("undefined",e),([t,n])=>[Y0(t),n]),yv=(e)=>f(f(av(e),([t,n])=>f(k(":",n),([r,i])=>f(Fp(i),([o,s])=>[[t,r,o],s]))),([t,n])=>[J0(t),n]),xv=(e,t=[])=>f(f(wc(e),([n,r])=>f(yv(r),([i,o])=>[[n,i],o])),([n,r])=>xv(r,[...t,n]),()=>[t,e]),kB=(e)=>f(f(f(yv(e),([t,n])=>f(xv(n),([r,i])=>f(f(wc(i),([o,s])=>[[o],s],()=>[[],i]),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Z0(t),n]),Iv=(e)=>f(f(k("{",e),([t,n])=>f(kB(n),([r,i])=>f(k("}",i),([o,s])=>[[t,r,o],s]))),([t,n])=>[Q0(t),n]),Sv=(e,t=[])=>f(f(k(",",e),([n,r])=>f(Fp(r),([i,o])=>[[n,i],o])),([n,r])=>Sv(r,[...t,n]),()=>[t,e]),TB=(e)=>f(f(f(Fp(e),([t,n])=>f(Sv(n),([r,i])=>f(f(k(",",i),([o,s])=>[[o],s],()=>[[],i]),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[eE(t),n]),wB=(e)=>f(f(k("[",e),([t,n])=>f(TB(n),([r,i])=>f(k("]",i),([o,s])=>[[t,r,o],s]))),([t,n])=>[tE(t),n]),Fp=(e)=>f(f(IB(e),([t,n])=>[t,n],()=>f(SB(e),([t,n])=>[t,n],()=>f(bB(e),([t,n])=>[t,n],()=>f(CB(e),([t,n])=>[t,n],()=>f(EB(e),([t,n])=>[t,n],()=>f(vB(e),([t,n])=>[t,n],()=>f(Iv(e),([t,n])=>[t,n],()=>f(wB(e),([t,n])=>[t,n],()=>[])))))))),([t,n])=>[nE(t),n]),LB=(e)=>f(k("-?(?:0|[1-9][0-9]*)n",e),([t,n])=>[rE(t),n]),RB=(e)=>f(k(".*",e),([t,n])=>[iE(t),n]),AB=(e)=>f(k("-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?",e),([t,n])=>[oE(t),n]),PB=(e)=>f(k("-?(?:0|[1-9][0-9]*)",e),([t,n])=>[sE(t),n]),$B=(e)=>f(k("(?!)",e),([t,n])=>[aE(t),n]),MB=(e)=>f(qE(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([t,n])=>[lE(t),n]),OB=(e)=>f(f(LB(e),([t,n])=>[t,n],()=>f(RB(e),([t,n])=>[t,n],()=>f(AB(e),([t,n])=>[t,n],()=>f(PB(e),([t,n])=>[t,n],()=>f($B(e),([t,n])=>[t,n],()=>f(FB(e),([t,n])=>[t,n],()=>f(MB(e),([t,n])=>[t,n],()=>[]))))))),([t,n])=>[uE(t),n]),FB=(e)=>f(f(k("(",e),([t,n])=>f(Np(n),([r,i])=>f(k(")",i),([o,s])=>[[t,r,o],s]))),([t,n])=>[dE(t),n]),bv=(e)=>f(f(f(Pp(e),([t,n])=>f(k("|",n),([r,i])=>f(bv(i),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f(f(Pp(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[]))),([t,n])=>[cE(t),n]),Pp=(e)=>f(f(OB(e),([t,n])=>f(Np(n),([r,i])=>[[t,r],i])),([t,n])=>[mE(t),n]),Np=(e)=>f(f(bv(e),([t,n])=>[t,n],()=>f(Pp(e),([t,n])=>[t,n],()=>[])),([t,n])=>[fE(t),n]),Ob=(e)=>f(f(k("^",e),([t,n])=>f(Np(n),([r,i])=>f(k("$",i),([o,s])=>[[t,r,o],s]))),([t,n])=>[pE(t),n]),Cv=(e,t=[])=>f(f(k(",",e),([n,r])=>f(me(r),([i,o])=>[[n,i],o])),([n,r])=>Cv(r,[...t,n]),()=>[t,e]),NB=(e)=>f(f(f(me(e),([t,n])=>f(Cv(n),([r,i])=>f(f(k(",",i),([o,s])=>[[o],s],()=>[[],i]),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[hE(t),n]),Ev=(e)=>f(f(f(k("extends",e),([t,n])=>f(NB(n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[gE(t),n]),DB=(e)=>f(f(k("interface",e),([t,n])=>f(Xe(n),([r,i])=>f($p(i),([o,s])=>f(Ev(s),([a,l])=>f(Op(l),([d,c])=>[[t,r,o,a,d],c]))))),([t,n])=>[yE(t),n]),HB=(e)=>f(f(k("interface",e),([t,n])=>f(Xe(n),([r,i])=>f(Ev(i),([o,s])=>f(Op(s),([a,l])=>[[t,r,o,a],l])))),([t,n])=>[xE(t),n]),_B=(e)=>f(f(k("type",e),([t,n])=>f(Xe(n),([r,i])=>f($p(i),([o,s])=>f(k("=",s),([a,l])=>f(me(l),([d,c])=>[[t,r,o,a,d],c]))))),([t,n])=>[IE(t),n]),UB=(e)=>f(f(k("type",e),([t,n])=>f(Xe(n),([r,i])=>f(k("=",i),([o,s])=>f(me(s),([a,l])=>[[t,r,o,a],l])))),([t,n])=>[SE(t),n]),BB=(e)=>f(f(f(k("export",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[bE(t),n]),vv=(e)=>f(f(f(k(";",e),([t,n])=>f(k(`
|
|
1529
|
+
`,n),([r,i])=>[[t,r],i])),([t,n])=>[t,n],()=>f(f(k(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>f(f(k(`
|
|
1530
|
+
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[CE(t),n]),kv=(e,t=[])=>f(f(vv(e),([n,r])=>f(Dp(r),([i,o])=>[[n,i],o])),([n,r])=>kv(r,[...t,n]),()=>[t,e]),GB=(e)=>f(f(f(Dp(e),([t,n])=>f(kv(n),([r,i])=>f(f(vv(i),([o,s])=>[[o],s],()=>[[],i]),([o,s])=>[[t,r,o],s]))),([t,n])=>[t,n],()=>f([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[EE(t),n]),Dp=(e)=>f(f(BB(e),([t,n])=>f(f(DB(n),([r,i])=>[r,i],()=>f(HB(n),([r,i])=>[r,i],()=>f(_B(n),([r,i])=>[r,i],()=>f(UB(n),([r,i])=>[r,i],()=>[])))),([r,i])=>f(YE(i),([o,s])=>[[t,r,o],s]))),([t,n])=>[vE(t),n]),jB=(e)=>f(f(Dp(e),([t,n])=>f(GB(n),([r,i])=>[[t,r],i])),([t,n])=>[kE(t),n]),Tv=(e)=>f(f(jB(e),([t,n])=>[t,n],()=>f(J2(e),([t,n])=>[t,n],()=>f(me(e),([t,n])=>[t,n],()=>[]))),([t,n])=>[TE(t),n]);function wv(e){let t=Mp(`\`${e}\``);return u.IsEqual(t.length,2)?t[0]:Ve()}function zB(e){return e.join("|")}function KB(e){return e.slice(1,e.length-1)}function VB(e,t,n){return wi(t,`${n}${e}`)}function WB(e,t){return wi(e,`${t}${wb}`)}function XB(e,t){return wi(e,`${t}${_d}`)}function YB(e,t){return wi(e,`${t}${jd}`)}function JB(e,t){return Ga(J([ne("false"),ne("true")]),e,t)}function ZB(e,t){return wi(e,`${t}${qd}`)}function QB(e,t,n){return wi(t,`${n}${KB(e)}`)}function eG(e,t,n){let r=ja(e,{});return Ga(r,t,n)}function tG(e,t,n){let r=Xt(e);return Ga(r,t,n)}function Lv(e,t,n,r=[]){return u.ShiftLeft(e,(i,o)=>Lv(o,t,n,[...r,Ga(i,[],"")]),()=>wi(t,`${n}(${zB(r)})`))}function Ga(e,t,n){return st(e)?tG(e.enum,t,n):It(e)?XB(t,n):ae(e)?VB(e.const,t,n):pn(e)?WB(t,n):Vt(e)?JB(t,n):_e(e)?YB(t,n):ct(e)?ZB(t,n):Le(e)?QB(e.pattern,t,n):Av(e)?eG(e.parameters[0],t,n):F(e)?Lv(e.anyOf,t,n):tb}function wi(e,t){return u.ShiftLeft(e,(n,r)=>Ga(n,r,t),()=>t)}function nG(e){return`^${wi(e,"")}$`}function Rv(e){let t=nG(e);return Kd(t)}function ja(e,t){return te(e)?C.Update(Rv(e),{},t):ec(e,t)}function Pv(e,t,n,r){let i=vn(e,t,n);return ja(i,r)}function ec(e,t={}){return U("TemplateLiteral",[e],t)}function Av(e){return Ge(e)&&u.HasPropertyKey(e,"action")&&u.IsEqual(e.action,"TemplateLiteral")}function $v(e){return ja(e,{})}function rG(e){let t=wv(e);return $v(t)}function Mv(e,t={}){let n=u.IsString(e)?rG(e):$v(e);return C.Update(n,{},t)}function Le(e){return _(e,"TemplateLiteral")}var W={};Bt(W,{ExtendsFalse:()=>Z,ExtendsTrue:()=>H,ExtendsUnion:()=>Hp,IsExtendsFalse:()=>iG,IsExtendsTrue:()=>Fv,IsExtendsTrueLike:()=>Cs,IsExtendsUnion:()=>Ov,Match:()=>Fe});function Hp(e){return C.Create({["~kind"]:"ExtendsUnion"},{inferred:e})}function Ov(e){return u.IsObject(e)&&u.HasPropertyKey(e,"~kind")&&u.HasPropertyKey(e,"inferred")&&u.IsEqual(e["~kind"],"ExtendsUnion")&&u.IsObject(e.inferred)}function H(e){return C.Create({["~kind"]:"ExtendsTrue"},{inferred:e})}function Fv(e){return u.IsObject(e)&&u.HasPropertyKey(e,"~kind")&&u.HasPropertyKey(e,"inferred")&&u.IsEqual(e["~kind"],"ExtendsTrue")&&u.IsObject(e.inferred)}function Z(){return C.Create({["~kind"]:"ExtendsFalse"},{})}function iG(e){return u.IsObject(e)&&u.HasPropertyKey(e,"~kind")&&u.IsEqual(e["~kind"],"ExtendsFalse")}function Cs(e){return Ov(e)||Fv(e)}function Fe(e,t,n){return Cs(e)?t(e.inferred):n()}function oG(e,t,n,r){return Fe(de(e,n,r),(i)=>H(C.Assign(C.Assign(e,i),{[t]:n})),()=>Z())}function sG(e,t){return H(e)}function aG(e,t,n,r,i){return Fe(de(e,t,n),(o)=>Fe(de(o,t,r),(s)=>H(s),()=>Z()),()=>Fe(de(e,t,i),(o)=>H(o),()=>Z()))}function lG(e,t,n){let r=Xt(n);return de(e,t,r)}function Nv(e,t,n){return u.ShiftLeft(n,(r,i)=>Fe(de(e,t,r),(o)=>Nv(o,t,i),()=>Z()),()=>H(e))}function uG(e,t,n){let r=Nt(n);return de(e,t,r)}function Dv(e,t,n){return u.ShiftLeft(n,(r,i)=>Fe(de(e,t,r),(o)=>H(o),()=>Dv(e,t,i)),()=>Z())}function ge(e,t,n){return je(n)?sG(e,t):Ke(n)?aG(e,t,n.if,n.then,n.else):st(n)?lG(e,t,n.enum):ot(n)?oG(e,n.name,t,n.extends):z(n)?Nv(e,t,n.allOf):Le(n)?uG(e,t,n.pattern):F(n)?Dv(e,t,n.anyOf):it(n)?H(e):Z()}function Hv(e,t,n){return ot(n)?ge(e,t,n):je(n)?H(e):it(n)?H(e):Hp(e)}function dG(e,t){let n=lo(e),r=lo(t);return n&&r?!0:!n&&r?!0:n&&!r?!1:!0}function _v(e,t,n,r){return le(r)?dG(t,r)?de(e,n,r.items):Z():ge(e,t,r)}function Uv(e,t,n){return pn(n)?H(e):ge(e,t,n)}function Bv(e,t,n){return Vt(n)?H(e):ge(e,t,n)}function cG(e,t,n,r,i){let o=ot(r)?t:r,s=ot(r)?r:t,a=ht(t),l=ht(r);return!a&&l?Z():Fe(de(e,o,s),(d)=>qa(d,n,i),()=>Z())}function mG(e,t,n,r){return u.ShiftLeft(r,(i,o)=>cG(e,t,n,i,o),()=>ht(t)?H(e):Z())}function fG(e,t,n){return u.ShiftLeft(t,(r,i)=>mG(e,r,i,n),()=>H(e))}function qa(e,t,n){return fG(e,t,n)}function Lc(e,t,n){return gn(n)?H(e):de(e,t,n)}function Gv(e,t,n,r){return je(r)?H(e):it(r)?H(e):nt(r)?Fe(qa(e,t,r.parameters),(i)=>Lc(i,n,r.instanceType),()=>Z()):Z()}function jv(e,t,n,r,i){return Fe(de(e,t,i),()=>de(e,n,i),()=>de(e,r,i))}function qv(e,t,n){let r=Xt(t);return de(e,r,n)}function zv(e,t,n,r){return je(r)?H(e):it(r)?H(e):rt(r)?Fe(qa(e,t,r.parameters),(i)=>Lc(i,n,r.returnType),()=>Z()):Z()}function Kv(e,t,n){return It(n)?H(e):_e(n)?H(e):ge(e,t,n)}function Vv(e,t,n){let r=Ue(t);return de(e,r,n)}function Rc(e,t,n){return t===n?H(e):Z()}function pG(e,t,n){return ae(n)?Rc(e,t,n.const):pn(n)?H(e):ge(e,ne(t),n)}function hG(e,t,n){return ae(n)?Rc(e,t,n.const):Vt(n)?H(e):ge(e,ne(t),n)}function gG(e,t,n){return ae(n)?Rc(e,t,n.const):_e(n)?H(e):ge(e,ne(t),n)}function yG(e,t,n){return ae(n)?Rc(e,t,n.const):ct(n)?H(e):ge(e,ne(t),n)}function Wv(e,t,n){return u.IsBigInt(t.const)?pG(e,t.const,n):u.IsBoolean(t.const)?hG(e,t.const,n):u.IsNumber(t.const)?gG(e,t.const,n):u.IsString(t.const)?yG(e,t.const,n):Ve()}function Xv(e,t,n){return ot(n)?ge(e,t,n):H(e)}function Yv(e,t,n){return gr(n)?H(e):ge(e,t,n)}function Jv(e,t,n){return _e(n)?H(e):ge(e,t,n)}function xG(e,t,n){return ht(t)?ht(n)?H(e):Z():H(e)}function IG(e,t,n){return ot(n)&&fn(n.extends)?Z():Fe(de(e,t,n),(r)=>xG(r,t,n),()=>Z())}function SG(e,t){return e.reduce((n,r)=>(r in t)?Cs(t[r])?{...n,...t[r].inferred}:Ve():Ve(),{})}function bG(e,t,n){let r={};for(let s of u.Keys(n))r[s]=s in t?IG({},t[s],n[s]):ht(n[s])?ot(n[s])?H(C.Assign(e,{[n[s].name]:n[s].extends})):H(e):Z();let i=u.Values(r).every((s)=>Cs(s)),o=i?SG(u.Keys(r),r):{};return i?H(o):Z()}function CG(e,t,n){let r=bG(e,t,n);return Cs(r)?H(C.Assign(e,r.inferred)):Z()}function EG(e,t,n){return CG(e,t,n)}function vG(e,t){return u.Keys(t).reduce((n,r)=>({...n,[r]:u.HasPropertyKey(e,r)?F(n[r])?J([...n[r].anyOf,t[r]]):J([e[r],t[r]]):t[r]}),e)}function Zv(e,t,n,r){return u.ShiftLeft(t,(i,o)=>Fe(de({},e[i],n),(s)=>Zv(e,o,n,vG(r,s)),()=>Z()),()=>H(r))}function kG(e,t,n,r){let i=u.Keys(t);return Zv(t,i,r,e)}function Qv(e,t,n){return Se(n)?kG(e,t,St(n),Ae(n)):V(n)?EG(e,t,n.properties):ge(e,q(t),n)}function TG(e,t){return u.IsEqual(u.Keys(t).length,0)?H(e):Z()}function wG(e,t,n,r,i){return de(e,n,i)}function ek(e,t,n,r){return Se(r)?wG(e,Yd(t),n,Yd(St(r)),Ae(r)):V(r)?TG(e,r.properties):je(r)?H(e):it(r)?H(e):Z()}function tk(e,t,n){return ct(n)?H(e):ge(e,t,n)}function nk(e,t,n){return yr(n)?H(e):ge(e,t,n)}function rk(e,t,n){let r=Nt(t);return de(e,r,n)}function _p(e,t){return C.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function za(e){return u.IsObject(e)&&u.HasPropertyKey(e,"~kind")&&u.HasPropertyKey(e,"name")&&u.HasPropertyKey(e,"type")&&u.IsEqual(e["~kind"],"Inferrable")&&u.IsString(e.name)&&u.IsObject(e.type)}function Up(e){return vi(e)?ot(e.items)?le(e.items.extends)?_p(e.items.name,e.items.extends.items):it(e.items.extends)?_p(e.items.name,e.items.extends):void 0:Ve():void 0}function Ac(e){return ot(e)?_p(e.name,e.extends):void 0}function Bp(e,t,n=[]){return u.ShiftLeft(e,(r,i)=>Fe(de({},r,t),()=>Bp(i,t,[...n,r]),()=>{return}),()=>n)}function ik(e,t,n,r){let i=Bp(n,r);return u.IsArray(i)?H(C.Assign(e,{[t]:We(i)})):Z()}function Pc(e,t,n,r){let i=Bp(n,r);return u.IsArray(i)?H(C.Assign(e,{[t]:J(i)})):Z()}function LG(e){return[...e].reverse()}function Gp(e,t){return t?LG(e):e}function RG(e){let t=e.length>0?e[0]:void 0,n=Ge(t)?Up(t):void 0;return Ge(n)}function AG(e,t,n,r,i,o){return Fe(de(e,n,i),(s)=>ok(s,t,r,o),()=>Z())}function PG(e,t,n,r,i){let o=Up(r);return za(o)?ik(e,o.name,Gp(n,t),o.type):u.ShiftLeft(n,(s,a)=>AG(e,t,s,a,r,i),()=>Z())}function $G(e,t,n,r){return u.ShiftLeft(r,(i,o)=>PG(e,t,n,i,o),()=>u.IsEqual(n.length,0)?H(e):Z())}function ok(e,t,n,r){return $G(e,t,n,r)}function MG(e,t,n){let r=Li(e,Pe([],[]),n),i=RG(r);return ok(e,i,Gp(t,i),Gp(r,i))}function sk(e,t,n){let r=Ac(n);return za(r)?Pc(e,r.name,t,r.type):u.ShiftLeft(t,(i,o)=>Fe(de(e,i,n),(s)=>sk(s,o,n),()=>Z()),()=>H(e))}function ak(e,t,n){let r=Li(e,Pe([],[]),t);return re(n)?MG(e,r,n.items):le(n)?sk(e,r,n.items):ge(e,We(r),n)}function lk(e,t,n){return gn(n)?H(e):Jn(n)?H(e):ge(e,t,n)}function uk(e,t,n){return u.ShiftLeft(n,(r,i)=>Fe(de(e,t,r),(o)=>H(o),()=>uk(e,t,i)),()=>Z())}function jp(e,t,n){return u.ShiftLeft(t,(r,i)=>Fe(uk(e,r,n),(o)=>jp(o,i,n),()=>Z()),()=>H(e))}function dk(e,t,n){let r=Ac(n);return za(r)?Pc(e,r.name,t,r.type):F(n)?jp(e,t,n.anyOf):jp(e,t,[n])}function ck(e,t,n){return ot(n)?ge(e,t,n):je(n)?H(e):it(n)?H(e):Z()}function mk(e,t,n){return gn(n)?H(e):ge(e,t,n)}function de(e,t,n){return je(t)?Hv(e,t,n):le(t)?_v(e,t,t.items,n):pn(t)?Uv(e,t,n):Vt(t)?Bv(e,t,n):nt(t)?Gv(e,t.parameters,t.instanceType,n):Ke(t)?jv(e,t.if,t.then,t.else,n):st(t)?qv(e,t.enum,n):rt(t)?zv(e,t.parameters,t.returnType,n):It(t)?Kv(e,t,n):z(t)?Vv(e,t.allOf,n):ae(t)?Wv(e,t,n):fn(t)?Xv(e,t,n):gr(t)?Yv(e,t,n):_e(t)?Jv(e,t,n):V(t)?Qv(e,t.properties,n):Se(t)?ek(e,St(t),Ae(t),n):ct(t)?tk(e,t,n):yr(t)?nk(e,t,n):Le(t)?rk(e,t.pattern,n):re(t)?ak(e,t.items,n):Jn(t)?lk(e,t,n):F(t)?dk(e,t.anyOf,n):it(t)?ck(e,t,n):gn(t)?mk(e,t,n):Z()}function OG(e,t){return Ue([...e,q(t)])}function qp(e,t,n){return te(e)?C.Update(OG(e,t),{},n):Da(e,t,n)}function fk(e,t,n,r,i){let o=vn(e,t,n),s=Ka(e,t,r);return qp(o,s,i)}function Da(e,t,n={}){return U("Interface",[e,t],n)}function Es(e){return Ge(e)&&u.HasPropertyKey(e,"action")&&u.IsEqual(e.action,"Interface")}function pk(e,t,n={}){return qp(e,t,n)}function FG(e,t,n){return e.includes(n)?!0:Va([...e,n],t,t[n])}function hk(e,t,n){let r=$d(n);return yo(e,t,r)}function yo(e,t,n){return u.ShiftLeft(n,(r,i)=>Va(e,t,r)?!0:yo(e,t,i),()=>!1)}function Va(e,t,n){return xe(n)?FG(e,t,n.$ref):le(n)?Va(e,t,n.items):nt(n)?yo(e,t,[...n.parameters,n.instanceType]):rt(n)?yo(e,t,[...n.parameters,n.returnType]):Es(n)?hk(e,t,n.parameters[1]):z(n)?yo(e,t,n.allOf):V(n)?hk(e,t,n.properties):F(n)?yo(e,t,n.anyOf):re(n)?yo(e,t,n.items):Se(n)?Va(e,t,Ae(n)):!1}function gk(e,t,n){return Va(e,t,n)}function NG(e,t){return t.reduce((n,r)=>gk([r],e,e[r])?[...n,r]:n,[])}function yk(e){let t=Pd(e);return NG(e,t)}function DG(e,t,n){return n.includes(t)?n:(t in e)?Wa(e,e[t],[...n,t]):Ve()}function xk(e,t,n){let r=$d(t);return vs(e,r,n)}function vs(e,t,n){return t.reduce((r,i)=>Wa(e,i,r),n)}function Wa(e,t,n){return xe(t)?DG(e,t.$ref,n):le(t)?Wa(e,t.items,n):nt(t)?vs(e,[...t.parameters,t.instanceType],n):rt(t)?vs(e,[...t.parameters,t.returnType],n):Es(t)?xk(e,t.parameters[1],n):z(t)?vs(e,t.allOf,n):V(t)?xk(e,t.properties,n):F(t)?vs(e,t.anyOf,n):re(t)?vs(e,t.items,n):Se(t)?Wa(e,Ae(t),n):n}function Ik(e,t,n){return Wa(e,n,[t])}function HG(e){return us()}function _G(e){return u.Keys(e).reduce((t,n)=>({...t,[n]:xo(e[n])}),{})}function Xa(e){return e.reduce((t,n)=>[...t,xo(n)],[])}function xo(e){return xe(e)?HG(e.$ref):le(e)?tn(xo(e.items),as(e)):nt(e)?cr(Xa(e.parameters),xo(e.instanceType)):rt(e)?mr(Xa(e.parameters),xo(e.returnType)):z(e)?Ft(Xa(e.allOf)):V(e)?q(_G(e.properties)):Se(e)?ys(Ei(e),xo(Ae(e))):F(e)?J(Xa(e.anyOf)):re(e)?We(Xa(e.items)):e}function UG(e,t){return t in e?xo(e[t]):dt()}function Sk(e){return UG(e.$defs,e.$ref)}function BG(e,t,n){let r=vn(e,Pe([],[]),t),i=Ka({},Pe([],[]),n);return Ue([...r,q(i)])}function GG(e,t){return u.Keys(e).filter((r)=>t.includes(r)).reduce((r,i)=>{let o=e[i],s=Es(o)?BG(e,o.parameters[0],o.parameters[1]):o;return{...r,[i]:s}},{})}function bk(e,t,n){let r=Ik(e,t,n),i=GG(e,r);return pr(i,t)}function Ck(e,t){return t in e?xe(e[t])?Ck(e,e[t].$ref):e[t]:be()}function xr(e,t){return Ck(e,t)}function Ek(e){return Te(e)?Sk(e):Md(e)?dt():e}function Pt(e,t,n){let r=Ek(t),i=Ek(n);return de(e,r,i)}var $a=0,Ya=1,Ma=2,Oa=3;function hs(e,t){let n=[Pt({},e,t),Pt({},t,e)];return W.IsExtendsTrueLike(n[0])&&W.IsExtendsTrueLike(n[1])?$a:W.IsExtendsTrueLike(n[0])&&W.IsExtendsFalse(n[1])?Ma:W.IsExtendsFalse(n[0])&&W.IsExtendsTrueLike(n[1])?Oa:Ya}function zp(e,t,n=[],r=t){return u.ShiftLeft(t,(i,o)=>{let s=hs(e,i);return u.IsEqual(s,Ma)||u.IsEqual(s,$a)?r:u.IsEqual(s,Ya)?zp(e,o,[...n,i],r):zp(e,o,n,r)},()=>[...n,e])}function jG(e,t,n){let r=Fn(e);return je(r)?[r]:it(r)?[r]:fn(r)?$c(t,n):V(r)?$c(t,[...n,r]):$c(t,zp(r,n))}function $c(e,t=[]){return u.ShiftLeft(e,(n,r)=>jG(n,r,t),()=>t)}function Cp(e){let t=$c(e);return po(t)}function Kp(e,t){return C.Update(Fn(e),{},t)}function vk(e,t,n,r){let i=M(e,t,n);return Kp(i,r)}function Ja(e,t=[]){return yi(e)&&u.IsEqual(e.action,"Conditional")?xe(e.parameters[0])?Ja(e.parameters[2],Ja(e.parameters[3],[...t,e.parameters[0].$ref])):Ja(e.parameters[2],Ja(e.parameters[3],t)):yi(e)&&u.IsEqual(e.action,"Mapped")?yi(e.parameters[1])&&u.IsEqual(e.parameters[1].action,"KeyOf")&&xe(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t:t}function qG(e,t){return e.reduce((n,r)=>[...n,t.includes(r.name)],[])}function wk(e,t,n=[]){return u.ShiftLeft(e,(r,i)=>u.ShiftLeft(t,(o,s)=>wk(i,s,[...n,[o,r]]),()=>n),()=>n)}function zG(e){return Le(e)?Nt(e.pattern):st(e)?Xt(e.enum):e}function KG(e){let t=zG(e);return F(t)?[...t.anyOf]:[t]}function VG(e,t){return e.reduce((n,r)=>[...n,[...r,t]],[])}function kk(e,t){return t.reduce((n,r)=>[...n,...VG(e,r)],[])}function Tk(e){return e.reduce((t,n)=>u.IsEqual(n[0],!0)?kk(t,KG(n[1])):kk(t,[n[1]]),[[]])}function Lk(e,t,n){let r=Ja(n),i=qG(e,r),o=wk(t,i);return yi(n)&&u.IsEqual(n.action,"Conditional")?Tk(o):yi(n)&&u.IsEqual(n.action,"Mapped")?Tk(o):[t]}function WG(){return["(not-resolvable)",be()]}function XG(){return["(not-generic)",be()]}function YG(e,t,n){return[e,xi(t,n)]}function JG(e,t,n){return t in e?Rk(e,t,e[t],n):WG()}function Rk(e,t,n,r){return ls(n)?YG(t,n.parameters,n.expression):xe(n)?JG(e,n.$ref,r):XG()}function Ak(e,t,n){return Rk(e,"(anonymous)",t,n)}function ZG(e,t,n){if(ot(t)||ks(t)||W.IsExtendsTrueLike(Pt({},t,n)))return;let r={parameter:e,expect:n,actual:t};throw Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:r})}function Pk(e,t,n,r,i){let o=M(e,t,i);return ZG(n,o,r),C.Assign(e,{[n]:o})}function QG(e,t,n,r,i){let o=M(e,t,n.extends),s=M(e,t,n.equals);return u.ShiftLeft(i,(a,l)=>Vp(Pk(e,t,n.name,o,a),t,r,l),()=>Vp(Pk(e,t,n.name,o,s),t,r,[]))}function Vp(e,t,n,r){return u.ShiftLeft(n,(i,o)=>QG(e,t,i,o,r),()=>e)}function $k(e,t,n,r){return Vp(e,t,n,r)}var Wp=0,Xp=0;function ej(){if(u.IsLessThan(Xp,He.Get().maxInstantiationCount))return;throw Error("Type instantiation is excessively deep and possibly infinite")}function tj(){ej(),Xp++,Wp++}function nj(){if(Wp--,u.IsEqual(Wp,0))Xp=0}function rj(e){return u.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function ij(e,t){return u.IsEqual(rj(e),t)}function oj(e,t,n,r,i,o){tj();try{let s=$k(e,t,r,o),a=M(s,Pe([...t.callstack,n.$ref],t.visited),i);return M(s,Pe([],[]),a)}finally{nj()}}function sj(e,t,n,r,i,o){return o.reduce((s,a)=>{let l=oj(e,t,n,r,i,a);return[...s,l]},[])}function aj(e,t,n,r,i,o){let s=Lk(r,o,i),a=sj(e,t,n,r,i,s);return u.IsEqual(a.length,1)?a[0]:rn(a)}function Mc(e,t,n,r){let i=vn(e,t,r),o=Ak(e,n,r),s=o[0],a=o[1];return ls(a)?ij(t,s)?Ha(pt(s),i):aj(e,t,pt(s),a.parameters,a.expression,i):Ha(n,i)}function Ha(e,t){return C.Create({["~kind"]:"Call"},{type:"call",target:e,arguments:t},{})}function Mk(e,t){return Mc({},Pe([],[]),e,t)}function ks(e){return _(e,"Call")}function lj(e){return C.Discard(e,["~immutable"])}function Ok(e,t){return C.Update(lj(e),{},t)}function Fk(e,t,n,r){let i=M(e,t,n);return Ok(i,r)}function Nk(e,t){return e(t)}function Dk(e,t){return u.IsString(t)?ne(Nk(e,t)):ne(t)}function Hk(e,t){let n=Nt(t);return qr(e,n)}function _k(e,t){let n=t.map((r)=>qr(e,r));return J(n)}function qr(e,t){return ae(t)?Dk(e,t.const):Le(t)?Hk(e,t.pattern):F(t)?_k(e,t.anyOf):t}function tc(e,t={}){return U("Capitalize",[e],t)}function Uk(e,t={}){return Yp(e,t)}function nc(e,t={}){return U("Lowercase",[e],t)}function Bk(e,t={}){return Jp(e,t)}function rc(e,t={}){return U("Uncapitalize",[e],t)}function Gk(e,t={}){return Zp(e,t)}function ic(e,t={}){return U("Uppercase",[e],t)}function jk(e,t={}){return Qp(e,t)}var uj=(e)=>e[0].toUpperCase()+e.slice(1),dj=(e)=>e.toLowerCase(),cj=(e)=>e[0].toLowerCase()+e.slice(1),mj=(e)=>e.toUpperCase();function Yp(e,t){return te([e])?C.Update(qr(uj,e),{},t):tc(e,t)}function Jp(e,t){return te([e])?C.Update(qr(dj,e),{},t):nc(e,t)}function Zp(e,t){return te([e])?C.Update(qr(cj,e),{},t):rc(e,t)}function Qp(e,t){return te([e])?C.Update(qr(mj,e),{},t):ic(e,t)}function qk(e,t,n,r){let i=M(e,t,n);return Yp(i,r)}function zk(e,t,n,r){let i=M(e,t,n);return Jp(i,r)}function Kk(e,t,n,r){let i=M(e,t,n);return Zp(i,r)}function Vk(e,t,n,r){let i=M(e,t,n);return Qp(i,r)}function oc(e,t,n,r,i={}){return U("Conditional",[e,t,n,r],i)}function Wk(e,t,n,r,i={}){return eh({},Pe([],[]),e,t,n,r,i)}function fj(e,t,n,r,i,o){let s=Pt(e,n,r);return W.IsExtendsUnion(s)?J([M(s.inferred,t,i),M(e,t,o)]):W.IsExtendsTrue(s)?M(s.inferred,t,i):M(e,t,o)}function eh(e,t,n,r,i,o,s){return te([n,r])?C.Update(fj(e,t,n,r,i,o),{},s):oc(n,r,i,o,s)}function Xk(e,t,n,r,i,o,s){let a=M(e,t,n),l=M(e,t,r);return eh(e,t,a,l,i,o,s)}function sc(e,t={}){return U("ConstructorParameters",[e],t)}function Yk(e,t={}){return th(e,t)}function pj(e){let t=nt(e)?e.parameters:[],n=Li({},Pe([],[]),t);return We(n)}function th(e,t){return te([e])?C.Update(pj(e),{},t):sc(e,t)}function Jk(e,t,n,r){let i=M(e,t,n);return th(i,r)}function ac(e,t,n={}){return U("Exclude",[e,t],n)}function Zk(e,t,n={}){return Za(e,t,n)}function Za(e,t,n){return te([e,t])?C.Update(Wd(e,t),{},n):ac(e,t,n)}function Qk(e,t,n,r,i){let o=M(e,t,n),s=M(e,t,r);return Za(o,s,i)}function lc(e,t,n={}){return U("Extract",[e,t],n)}function eT(e,t,n={}){return nh(e,t,n)}function hj(e,t){let n=Pt({},e,t);return W.IsExtendsTrueLike(n)?[e]:[]}function tT(e,t,n=[]){return u.ShiftLeft(e,(r,i)=>tT(i,t,[...n,...hj(r,t)]),()=>n)}function nT(e,t){let n=Fn(e),r=F(n)?n.anyOf:[n],i=tT(r,t);return rn(i)}function nh(e,t,n){return te([e,t])?C.Update(nT(e,t),{},n):lc(e,t,n)}function rT(e,t,n,r,i){let o=M(e,t,n),s=M(e,t,r);return nh(o,s,i)}function gj(e){return e.reduce((t,n)=>Ud(n)?[...t,ne(n)]:t,[])}function Ts(e){let t=gj(e);return J(t)}function _a(e,t,n={}){return U("Index",[e,t],n)}function iT(e,t,n={}){let r=u.IsArray(t)?Ts(t):t;return rh(e,r,n)}function oT(e,t){let n=xr(e,t);return kn(n)}function sT(e,t,n){let r=Yn(e,t,n);return kn(r)}function yj(e,t){let n=u.Keys(e).filter((c)=>!u.HasPropertyKey(t,c)),r=u.Keys(t).filter((c)=>!u.HasPropertyKey(e,c)),i=u.Keys(e).filter((c)=>u.HasPropertyKey(t,c)),o=n.reduce((c,m)=>({...c,[m]:e[m]}),{}),s=r.reduce((c,m)=>({...c,[m]:t[m]}),{}),a=i.reduce((c,m)=>({...c,[m]:Ue([e[m],t[m]])}),{}),l=C.Assign(o,s);return C.Assign(l,a)}function aT(e){return e.reduce((t,n)=>yj(t,kn(n)),{})}function lT(e){return e}function uT(e){let t=Xb(We(e));return kn(t)}function xj(e,t){return u.Keys(e).filter((i)=>(i in t)).reduce((i,o)=>({...i,[o]:rn([e[o],t[o]])}),{})}function dT(e,t){return u.ShiftLeft(e,(n,r)=>dT(r,xj(t,kn(n))),()=>t)}function cT(e){return u.ShiftLeft(e,(t,n)=>dT(n,kn(t)),()=>Ve())}function kn(e){return Te(e)?oT(e.$defs,e.$ref):Ke(e)?sT(e.if,e.then,e.else):z(e)?aT(e.allOf):F(e)?cT(e.anyOf):re(e)?uT(e.items):V(e)?lT(e.properties):{}}function ws(e){let t=kn(e);return q(t)}var Ij=new RegExp("^(?:0|[1-9][0-9]*)$");function Ls(e){let t=`${e}`;return Ij.test(t)?parseInt(t):e}function Sj(e){return ne(Ls(e))}function mT(e){return e.map((t)=>fT(t))}function fT(e){return z(e)?Ft(mT(e.allOf)):F(e)?J(mT(e.anyOf)):ae(e)?Sj(e.const):e}function pT(e,t){let n=fT(t),r=Pt({},n,hn());return W.IsExtendsTrueLike(r)?e:ae(t)&&u.IsEqual(t.const,"length")?hn():be()}function hT(e,t){let n=xr(e,t);return yn(n)}function gT(e,t,n){let r=Yn(e,t,n);return yn(r)}function yT(e){let t=Xt(e);return yn(t)}function xT(e){let t=Ue(e);return yn(t)}function IT(e){return[`${e}`]}function ST(e){let t=Nt(e);return yn(t)}function bT(e){return e.reduce((t,n)=>[...t,...yn(n)],[])}function yn(e){return Te(e)?hT(e.$defs,e.$ref):Ke(e)?gT(e.if,e.then,e.else):st(e)?yT(e.enum):z(e)?xT(e.allOf):ae(e)?IT(e.const):Le(e)?ST(e.pattern):F(e)?bT(e.anyOf):[]}function Rs(e){return yn(e)}function Qa(e,t){return t.map((n)=>el(e,n))}function el(e,t){return le(t)?tn(el(e,t.items)):nt(t)?cr(Qa(e,t.parameters),el(e,t.instanceType)):rt(t)?mr(Qa(e,t.parameters),el(e,t.returnType)):re(t)?We(Qa(e,t.items)):F(t)?J(Qa(e,t.anyOf)):z(t)?Ft(Qa(e,t.allOf)):Zd(t)?q(e):t}function CT(e,t){return el(e,t)}function bj(e,t){let n=t in e?e[t]:be();return CT(e,n)}function ET(e,t){return t.reduce((n,r)=>[...n,bj(e,r)],[])}function Cj(e,t){let n=Rs(t),r=ET(e,n);return rn(r)}var Ej=new RegExp(Ci);function vj(e){return e.filter((n)=>Ej.test(n))}function kj(e){let t=Pd(e),n=vj(t),r=ET(e,n);return rn(r)}function vT(e,t){return _e(t)?kj(e):Cj(e,t)}function Tj(e){return ne(Ls(e))}function kT(e){return e.map((t)=>ih(t))}function ih(e){return z(e)?Ft(kT(e.allOf)):F(e)?J(kT(e.anyOf)):ae(e)?Tj(e.const):e}function wj(e,t){return e.reduceRight((n,r,i)=>{let o=Pt({},ne(i),t);return W.IsExtendsTrueLike(o)?[r,...n]:n},[])}function Lj(e,t){let n=ih(t),r=wj(e,n);return Si(r)}function Rj(e){return Si(e)}function TT(e,t){return ae(t)&&u.IsEqual(t.const,"length")?ne(e.length):_e(t)||It(t)?Rj(e):Lj(e,t)}function wT(e,t){return le(e)?pT(e.items,t):V(e)?vT(e.properties,t):re(e)?TT(e.items,t):be()}function Aj(e){return Te(e)||Ke(e)||z(e)||F(e)?ws(e):e}function rh(e,t,n){return te([e,t])?C.Update(wT(Aj(e),t),{},n):_a(e,t,n)}function LT(e,t,n,r,i){let o=M(e,t,n),s=M(e,t,r);return rh(o,s,i)}function uc(e,t={}){return U("InstanceType",[e],t)}function RT(e,t={}){return oh(e,t)}function Pj(e){return nt(e)?e.instanceType:be()}function oh(e,t){return te([e])?C.Update(Pj(e),{},t):uc(e,t)}function AT(e,t,n,r={}){let i=M(e,t,n);return oh(i,r)}function Ua(e,t={}){return U("KeyOf",[e],t)}function PT(e,t={}){return sh(e,t)}function $T(){return J([hn(),Wt(),ps()])}function MT(e){return hn()}function $j(e){return e.reduce((n,r)=>Ud(r)?[...n,ne(Ls(r))]:Ve(),[])}function OT(e){let t=u.Keys(e),n=$j(t);return Si(n)}function FT(e){return Ei(e)}function NT(e){let t=e.map((n,r)=>ne(r));return Si(t)}function DT(e){return je(e)?$T():le(e)?MT(e.items):V(e)?OT(e.properties):Se(e)?FT(e):re(e)?NT(e.items):be()}function Mj(e){return Te(e)||Ke(e)||z(e)||F(e)?ws(e):e}function sh(e,t){return te([e])?C.Update(DT(Mj(e)),{},t):Ua(e,t)}function HT(e,t,n,r){let i=M(e,t,n);return sh(i,r)}function Na(e,t,n,r,i={}){return U("Mapped",[e,t,n,r],i)}function _T(e,t,n,r,i={}){return ah({},Pe([],[]),e,t,n,r,i)}function Oj(e){let t=Nt(e);return Oc(t)}function Fj(e){return e.reduce((t,n)=>[...t,...Oc(n)],[])}function Nj(e){let t=Xt(e);return Oc(t)}function Dj(e){return u.IsNumber(e)?[ne(`${e}`)]:[ne(e)]}function Oc(e){return st(e)?Nj(e.enum):ae(e)?Dj(e.const):Le(e)?Oj(e.pattern):F(e)?Fj(e.anyOf):[e]}function UT(e){return Oc(e)}function Hj(e){return Le(e)?Nt(e.pattern):e}function _j(e,t,n,r,i,o){let s=C.Assign(e,{[n.name]:r}),a=M(s,t,i),l=Hj(a),d=M(s,t,o);return Bd(l)||Gd(l)?{[l.const]:d}:{}}function Uj(e,t,n,r,i,o){return r.reduce((s,a)=>[...s,_j(e,t,n,a,i,o)],[])}function Bj(e){return e.reduce((t,n)=>[...t,q(n)],[])}function BT(e,t,n,r,i,o){let s=UT(r),a=Uj(e,t,n,s,i,o),l=Bj(a);return Ue(l)}function ah(e,t,n,r,i,o,s){return te([r])?C.Update(BT(e,t,n,r,i,o),{},s):Na(n,r,i,o,s)}function GT(e,t,n,r,i,o,s){let a=M(e,t,r);return ah(e,t,n,a,i,o,s)}function Gj(e,t,n){let r=C.Assign(e,t);return u.Keys(t).filter((o)=>n.includes(o)).reduce((o,s)=>({...o,[s]:bk(r,s,t[s])}),{})}function jj(e,t,n){let r=C.Assign(e,t);return u.Keys(t).filter((o)=>!n.includes(o)).reduce((o,s)=>({...o,[s]:M(r,Pe([],[]),t[s])}),{})}function qj(e,t,n){let r=yk(t),i=Gj(e,t,r),o=jj(e,t,r),s={...i,...o};return C.Update(s,{},n)}function Fc(e,t,n,r){return qj(e,n,r)}function dc(e,t={}){return U("NonNullable",[e],t)}function jT(e,t={}){return lh(e,t)}function zj(e){let t=J([fs(),xs()]);return Za(e,t,{})}function lh(e,t){return te([e])?C.Update(zj(e),{},t):dc(e,t)}function qT(e,t,n,r){let i=M(e,t,n);return lh(i,r)}function cc(e,t,n={}){return U("Omit",[e,t],n)}function zT(e,t,n={}){let r=u.IsArray(t)?Ts(t):t;return uh(e,r,n)}function Nc(e){let t=ws(e);return V(t)?t.properties:Ve()}function Kj(e,t){return u.Keys(e).reduce((r,i)=>t.includes(i)?r:{...r,[i]:e[i]},{})}function KT(e,t){let n=Nc(e),r=Rs(t),i=Kj(n,r);return q(i)}function uh(e,t,n){return te([e,t])?C.Update(KT(e,t),{},n):cc(e,t,n)}function VT(e,t,n,r,i){let o=M(e,t,n),s=M(e,t,r);return uh(o,s,i)}function mc(e,t={}){return U("Parameters",[e],t)}function WT(e,t={}){return dh(e,t)}function Vj(e){let t=rt(e)?e.parameters:[],n=Li({},Pe([],[]),t);return We(n)}function dh(e,t){return te([e])?C.Update(Vj(e),{},t):mc(e,t)}function XT(e,t,n,r){let i=M(e,t,n);return dh(i,r)}function fc(e,t={}){return U("Partial",[e],t)}function YT(e,t={}){return ch(e,t)}function JT(e,t){let n=xr(e,t),r=Ir(n);return pr(C.Assign(e,{[t]:r}),t)}function ZT(e,t,n){let r=Yn(e,t,n);return Ir(r)}function QT(e){let t=Ue(e);return Ir(t)}function ew(e){let t=e.map((n)=>Ir(n));return J(t)}function tw(e){let t=u.Keys(e).reduce((r,i)=>({...r,[i]:so(e[i])}),{});return q(t)}function Ir(e){return Te(e)?JT(e.$defs,e.$ref):Ke(e)?ZT(e.if,e.then,e.else):z(e)?QT(e.allOf):F(e)?ew(e.anyOf):V(e)?tw(e.properties):q({})}function ch(e,t){return te([e])?C.Update(Ir(e),{},t):fc(e,t)}function nw(e,t,n,r){let i=M(e,t,n);return ch(i,r)}function pc(e,t,n={}){return U("Pick",[e,t],n)}function rw(e,t,n={}){let r=u.IsArray(t)?Ts(t):t;return mh(e,r,n)}function Wj(e,t){return u.Keys(e).reduce((r,i)=>t.includes(i)?C.Assign(r,{[i]:e[i]}):r,{})}function iw(e,t){let n=Nc(e),r=Rs(t),i=Wj(n,r);return q(i)}function mh(e,t,n){return te([e,t])?C.Update(iw(e,t),{},n):pc(e,t,n)}function ow(e,t,n,r,i){let o=M(e,t,n),s=M(e,t,r);return mh(o,s,i)}function hc(e,t={}){return U("ReadonlyObject",[e],t)}function fh(e,t={}){return ph(e,t)}var sw=fh;function aw(e){return ms(tn(e))}function lw(e,t){let n=xr(e,t),r=Sr(n);return pr(C.Assign(e,{[t]:r}),t)}function uw(e,t,n){let r=Yn(e,t,n);return Sr(r)}function dw(e){let t=Ue(e);return Sr(t)}function cw(e){let t=u.Keys(e).reduce((r,i)=>({...r,[i]:uo(e[i])}),{});return q(t)}function mw(e){return ms(We(e))}function fw(e){let t=e.map((n)=>Sr(n));return J(t)}function Sr(e){return le(e)?aw(e.items):Te(e)?lw(e.$defs,e.$ref):Ke(e)?uw(e.if,e.then,e.else):z(e)?dw(e.allOf):V(e)?cw(e.properties):re(e)?mw(e.items):F(e)?fw(e.anyOf):e}function ph(e,t){return te([e])?C.Update(Sr(e),{},t):hc(e)}function pw(e,t,n,r){let i=M(e,t,n);return ph(i,r)}function hw(e,t,n,r){return t.visited.includes(r)?n:(r in e)?M(e,Pe(t.callstack,[...t.visited,r]),e[r]):n}function gw(e,t){let n=xr(e,t),r=br(n);return pr(C.Assign(e,{[t]:r}),t)}function yw(e,t,n){let r=Yn(e,t,n);return br(r)}function xw(e){let t=Ue(e);return br(t)}function Iw(e){let t=e.map((n)=>br(n));return J(t)}function Sw(e){let t=u.Keys(e).reduce((r,i)=>({...r,[i]:Vd(e[i])}),{});return q(t)}function br(e){return Te(e)?gw(e.$defs,e.$ref):Ke(e)?yw(e.if,e.then,e.else):z(e)?xw(e.allOf):F(e)?Iw(e.anyOf):V(e)?Sw(e.properties):q({})}function gc(e,t={}){return U("Required",[e],t)}function bw(e,t={}){return hh(e,t)}function hh(e,t){return te([e])?C.Update(br(e),{},t):gc(e,t)}function Cw(e,t,n,r){let i=M(e,t,n);return hh(i,r)}function yc(e,t={}){return U("ReturnType",[e],t)}function Ew(e,t={}){return gh(e,t)}function Xj(e){return rt(e)?e.returnType:be()}function gh(e,t){return te([e])?C.Update(Xj(e),{},t):yc(e,t)}function vw(e,t,n,r={}){let i=M(e,t,n);return gh(i,r)}function xc(e,t){return U("With",[e,t],{})}function Dc(e,t){return yh(e,t)}function yh(e,t){return te([e])?C.Update(e,{},t):xc(e,t)}function kw(e,t,n,r){let i=M(e,t,n);return yh(i,r)}function Yj(e){return vi(e)?re(e.items)?xh(e.items.items):ot(e.items)?[e]:xe(e.items)?[e]:[be()]:[e]}function xh(e){return e.reduce((n,r)=>[...n,...Yj(r)],[])}function Pe(e,t){return{callstack:e,visited:t}}function te(e){return u.ShiftLeft(e,(t,n)=>xe(t)?!1:te(n),()=>!0)}function Ka(e,t,n){return u.Keys(n).reduce((r,i)=>({...r,[i]:M(e,t,n[i])}),{})}function Li(e,t,n){let r=vn(e,t,n);return xh(r)}function vn(e,t,n){return n.map((r)=>M(e,t,r))}function Jj(e,t){let n=ht(e)?Ta(t,{}):t,r=co(e)?ka(n,{}):n;return lo(e)?tl(r,{}):r}function Zj(e,t,n,r,i){return u.IsEqual(n,"AddImmutable")?Tw(e,t,r[0],i):u.IsEqual(n,"RemoveImmutable")?Fk(e,t,r[0],i):u.IsEqual(n,"AddReadonly")?JS(e,t,r[0],i):u.IsEqual(n,"RemoveReadonly")?qb(e,t,r[0],i):u.IsEqual(n,"AddOptional")?ZS(e,t,r[0],i):u.IsEqual(n,"RemoveOptional")?Vb(e,t,r[0],i):u.IsEqual(n,"Capitalize")?qk(e,t,r[0],i):u.IsEqual(n,"Conditional")?Xk(e,t,r[0],r[1],r[2],r[3],i):u.IsEqual(n,"ConstructorParameters")?Jk(e,t,r[0],i):u.IsEqual(n,"Evaluate")?vk(e,t,r[0],i):u.IsEqual(n,"Exclude")?Qk(e,t,r[0],r[1],i):u.IsEqual(n,"Extract")?rT(e,t,r[0],r[1],i):u.IsEqual(n,"Index")?LT(e,t,r[0],r[1],i):u.IsEqual(n,"InstanceType")?AT(e,t,r[0],i):u.IsEqual(n,"Interface")?fk(e,t,r[0],r[1],i):u.IsEqual(n,"KeyOf")?HT(e,t,r[0],i):u.IsEqual(n,"Lowercase")?zk(e,t,r[0],i):u.IsEqual(n,"Mapped")?GT(e,t,r[0],r[1],r[2],r[3],i):u.IsEqual(n,"Module")?Fc(e,t,r[0],i):u.IsEqual(n,"NonNullable")?qT(e,t,r[0],i):u.IsEqual(n,"Pick")?ow(e,t,r[0],r[1],i):u.IsEqual(n,"Parameters")?XT(e,t,r[0],i):u.IsEqual(n,"Partial")?nw(e,t,r[0],i):u.IsEqual(n,"Omit")?VT(e,t,r[0],r[1],i):u.IsEqual(n,"ReadonlyObject")?pw(e,t,r[0],i):u.IsEqual(n,"Record")?dC(e,t,r[0],r[1],i):u.IsEqual(n,"Required")?Cw(e,t,r[0],i):u.IsEqual(n,"ReturnType")?vw(e,t,r[0],i):u.IsEqual(n,"TemplateLiteral")?Pv(e,t,r[0],i):u.IsEqual(n,"Uncapitalize")?Kk(e,t,r[0],i):u.IsEqual(n,"Uppercase")?Vk(e,t,r[0],i):u.IsEqual(n,"With")?kw(e,t,r[0],r[1]):U(n,r,i)}function Qj(e,t,n){let r=xe(n)?hw(e,t,n,n.$ref):le(n)?tn(M(e,t,n.items),as(n)):ks(n)?Mc(e,t,n.target,n.arguments):nt(n)?cr(vn(e,t,n.parameters),M(e,t,n.instanceType),QS(n)):rt(n)?mr(vn(e,t,n.parameters),M(e,t,n.returnType),eb(n)):Ke(n)?ao(M(e,t,n.if),M(e,t,n.then),M(e,t,n.else),sb(n)):z(n)?Ft(vn(e,t,n.allOf),cb(n)):V(n)?q(Ka(e,t,n.properties),ib(n)):Se(n)?cC(St(n),M(e,t,Ae(n))):vi(n)?ho(M(e,t,n.items)):re(n)?We(Li(e,t,n.items),jb(n)):F(n)?J(vn(e,t,n.anyOf),Mb(n)):n;return Jj(n,r)}function M(e,t,n){return yi(n)?Zj(e,t,n.action,n.parameters,n.options):Qj(e,t,n)}function Nn(e,t){return M(e,Pe([],[]),t)}function eq(e){return C.Update(e,{"~immutable":!0},{})}function tl(e,t){return C.Update(eq(e),{},t)}function Tw(e,t,n,r){let i=M(e,t,n);return tl(i,r)}function wE(e,t={}){return U("AddImmutable",[e],t)}function ms(e,t={}){return tl(e,t)}function LE(e,t={}){return U("Evaluate",[e],t)}function $t(e,t={}){return Kp(e,t)}function RE(e,t={}){return U("Module",[e],t)}function ww(e,t={}){return Fc({},Pe([],[]),e,t)}function tq(e,t){let n=hs(e,t);return u.IsEqual(n,Oa)?1:u.IsEqual(n,Ya)?1:0}function Lw(e,t,n=[]){return u.ShiftLeft(t,(r,i)=>u.IsEqual(tq(e,r),1)?Lw(e,i,[...n,r]):[...n,e,...t],()=>[...n,e])}function Rw(e,t=[]){return u.ShiftLeft(e,(n,r)=>Rw(r,Lw(n,t)),()=>t)}function Aw(e){return Rw(e)}function Pw(...e){let[t,n,r]=ee.Match(e,{2:(s,a)=>u.IsString(s)?[{},s,a]:[s,a,{}],3:(s,a,l)=>[s,a,l],1:(s)=>[{},s,{}]}),i=Tv(n),o=u.IsArray(i)&&u.IsEqual(i.length,2)?M(t,Pe([],[]),i[0]):be();return C.Update(o,{},r)}var Hc={};Bt(Hc,{Any:()=>us,Array:()=>tn,BigInt:()=>La,Boolean:()=>Hd,Call:()=>Mk,Capitalize:()=>Uk,Codec:()=>Nd,Conditional:()=>Wk,Constructor:()=>cr,ConstructorParameters:()=>Yk,Cyclic:()=>pr,Decode:()=>Cb,DecodeBuilder:()=>Fd,Dependent:()=>ao,Encode:()=>Eb,EncodeBuilder:()=>Od,Enum:()=>db,Evaluate:()=>$t,Exclude:()=>Zk,Extends:()=>Pt,ExtendsResult:()=>W,Extract:()=>eT,Function:()=>mr,Generic:()=>xi,Identifier:()=>Ra,Immutable:()=>vb,Index:()=>iT,Infer:()=>wa,InstanceType:()=>RT,Instantiate:()=>Nn,Integer:()=>mo,Interface:()=>pk,Intersect:()=>Ft,IsAny:()=>je,IsArray:()=>le,IsBigInt:()=>pn,IsBoolean:()=>Vt,IsCall:()=>ks,IsCodec:()=>Kt,IsConstructor:()=>nt,IsCyclic:()=>Te,IsDependent:()=>Ke,IsEnum:()=>st,IsEnumValue:()=>ub,IsFunction:()=>rt,IsGeneric:()=>ls,IsIdentifier:()=>Lb,IsImmutable:()=>lo,IsInfer:()=>ot,IsInteger:()=>It,IsIntersect:()=>z,IsKind:()=>_,IsLiteral:()=>ae,IsNever:()=>fn,IsNull:()=>gr,IsNumber:()=>_e,IsObject:()=>V,IsOptional:()=>ht,IsParameter:()=>$b,IsReadonly:()=>co,IsRecord:()=>Se,IsRef:()=>xe,IsRefine:()=>Dd,IsRest:()=>vi,IsSchema:()=>Ge,IsString:()=>ct,IsSymbol:()=>yr,IsTemplateLiteral:()=>Le,IsThis:()=>Zd,IsTuple:()=>re,IsUndefined:()=>Jn,IsUnion:()=>F,IsUnknown:()=>it,IsUnsafe:()=>Md,IsVoid:()=>gn,KeyOf:()=>PT,Literal:()=>ne,Lowercase:()=>Bk,Mapped:()=>_T,Module:()=>ww,Never:()=>be,NonNullable:()=>jT,Null:()=>fs,Number:()=>hn,Object:()=>q,Omit:()=>zT,Optional:()=>nb,Parameter:()=>fo,Parameters:()=>WT,Partial:()=>YT,Pick:()=>rw,Readonly:()=>kb,ReadonlyObject:()=>fh,ReadonlyType:()=>sw,Record:()=>ys,RecordKey:()=>Ei,RecordPattern:()=>St,RecordValue:()=>Ae,Ref:()=>pt,Refine:()=>Tb,Required:()=>bw,Rest:()=>ho,ReturnType:()=>Ew,Script:()=>Pw,String:()=>Wt,Symbol:()=>ps,TemplateLiteral:()=>Mv,This:()=>Jd,Tuple:()=>We,Uncapitalize:()=>Gk,Undefined:()=>xs,Union:()=>J,Unknown:()=>dt,Unsafe:()=>ob,Uppercase:()=>jk,Void:()=>Qd,With:()=>Dc});var _c=Hc;function nl(e){return u.HasPropertyKey(e,"~refine")&&u.IsArray(e["~refine"])&&u.Every(e["~refine"],0,(t)=>u.IsObject(t)&&u.HasPropertyKey(t,"check")&&u.HasPropertyKey(t,"error")&&u.IsFunction(t.check)&&u.IsFunction(t.error))}function Rt(e){return u.IsObject(e)&&!u.IsArray(e)}function Ri(e){return u.IsBoolean(e)}function Y(e){return Rt(e)||Ri(e)}function As(e){return u.HasPropertyKey(e,"additionalItems")&&Y(e.additionalItems)}function Dn(e){return u.HasPropertyKey(e,"additionalProperties")&&Y(e.additionalProperties)}function rl(e){return u.HasPropertyKey(e,"allOf")&&u.IsArray(e.allOf)&&e.allOf.every((t)=>Y(t))}function $w(e){return u.HasPropertyKey(e,"$anchor")&&u.IsString(e.$anchor)}function il(e){return u.HasPropertyKey(e,"anyOf")&&u.IsArray(e.anyOf)&&e.anyOf.every((t)=>Y(t))}function Uc(e){return u.HasPropertyKey(e,"const")}function Cr(e){return u.HasPropertyKey(e,"contains")&&Y(e.contains)}function Tn(e){return u.HasPropertyKey(e,"default")}function ol(e){return u.HasPropertyKey(e,"dependencies")&&u.IsObject(e.dependencies)&&Object.values(e.dependencies).every((t)=>Y(t)||u.IsArray(t)&&t.every((n)=>u.IsString(n)))}function sl(e){return u.HasPropertyKey(e,"dependentRequired")&&u.IsObject(e.dependentRequired)&&Object.values(e.dependentRequired).every((t)=>u.IsArray(t)&&t.every((n)=>u.IsString(n)))}function Ps(e){return u.HasPropertyKey(e,"dependentSchemas")&&u.IsObject(e.dependentSchemas)&&Object.values(e.dependentSchemas).every((t)=>Y(t))}function Ai(e){return u.HasPropertyKey(e,"$dynamicAnchor")&&u.IsString(e.$dynamicAnchor)}function al(e){return u.HasPropertyKey(e,"$dynamicRef")&&u.IsString(e.$dynamicRef)}function ll(e){return u.HasPropertyKey(e,"else")&&Y(e.else)}function Bc(e){return u.HasPropertyKey(e,"enum")&&u.IsArray(e.enum)}function ul(e){return u.HasPropertyKey(e,"exclusiveMaximum")&&(u.IsNumber(e.exclusiveMaximum)||u.IsBigInt(e.exclusiveMaximum))}function Zn(e){return u.HasPropertyKey(e,"exclusiveMinimum")&&(u.IsNumber(e.exclusiveMinimum)||u.IsBigInt(e.exclusiveMinimum))}function Io(e){return u.HasPropertyKey(e,"format")&&u.IsString(e.format)}function Yt(e){return u.HasPropertyKey(e,"$id")&&u.IsString(e.$id)}function dl(e){return u.HasPropertyKey(e,"if")&&Y(e.if)}function zr(e){return u.HasPropertyKey(e,"items")&&(Y(e.items)||u.IsArray(e.items)&&e.items.every((t)=>Y(t)))}function cl(e){return zr(e)&&u.IsArray(e.items)}function ml(e){return u.HasPropertyKey(e,"maximum")&&(u.IsNumber(e.maximum)||u.IsBigInt(e.maximum))}function fl(e){return u.HasPropertyKey(e,"maxContains")&&u.IsNumber(e.maxContains)}function $s(e){return u.HasPropertyKey(e,"maxItems")&&u.IsNumber(e.maxItems)}function pl(e){return u.HasPropertyKey(e,"maxLength")&&u.IsNumber(e.maxLength)}function hl(e){return u.HasPropertyKey(e,"maxProperties")&&u.IsNumber(e.maxProperties)}function Qn(e){return u.HasPropertyKey(e,"minimum")&&(u.IsNumber(e.minimum)||u.IsBigInt(e.minimum))}function Kr(e){return u.HasPropertyKey(e,"minContains")&&u.IsNumber(e.minContains)}function Pi(e){return u.HasPropertyKey(e,"minItems")&&u.IsNumber(e.minItems)}function So(e){return u.HasPropertyKey(e,"minLength")&&u.IsNumber(e.minLength)}function bo(e){return u.HasPropertyKey(e,"minProperties")&&u.IsNumber(e.minProperties)}function gl(e){return u.HasPropertyKey(e,"multipleOf")&&(u.IsNumber(e.multipleOf)||u.IsBigInt(e.multipleOf))}function yl(e){return u.HasPropertyKey(e,"not")&&Y(e.not)}function xl(e){return u.HasPropertyKey(e,"oneOf")&&u.IsArray(e.oneOf)&&e.oneOf.every((t)=>Y(t))}function Co(e){return u.HasPropertyKey(e,"pattern")&&(u.IsString(e.pattern)||e.pattern instanceof RegExp)}function Vr(e){return u.HasPropertyKey(e,"patternProperties")&&u.IsObject(e.patternProperties)&&Object.values(e.patternProperties).every((t)=>Y(t))}function er(e){return u.HasPropertyKey(e,"prefixItems")&&u.IsArray(e.prefixItems)&&e.prefixItems.every((t)=>Y(t))}function Wr(e){return u.HasPropertyKey(e,"properties")&&u.IsObject(e.properties)&&Object.values(e.properties).every((t)=>Y(t))}function Ms(e){return u.HasPropertyKey(e,"propertyNames")&&(u.IsObject(e.propertyNames)||Y(e.propertyNames))}function nq(e){return u.HasPropertyKey(e,"$recursiveAnchor")&&u.IsBoolean(e.$recursiveAnchor)}function Il(e){return nq(e)&&u.IsEqual(e.$recursiveAnchor,!0)}function Sl(e){return u.HasPropertyKey(e,"$recursiveRef")&&u.IsString(e.$recursiveRef)}function bl(e){return u.HasPropertyKey(e,"$ref")&&u.IsString(e.$ref)}function tr(e){return u.HasPropertyKey(e,"required")&&u.IsArray(e.required)&&e.required.every((t)=>u.IsString(t))}function Cl(e){return u.HasPropertyKey(e,"then")&&Y(e.then)}function El(e){return u.HasPropertyKey(e,"type")&&(u.IsString(e.type)||u.IsArray(e.type)&&e.type.every((t)=>u.IsString(t)))}function $i(e){return u.HasPropertyKey(e,"uniqueItems")&&u.IsBoolean(e.uniqueItems)}function Mi(e){return u.HasPropertyKey(e,"unevaluatedItems")&&Y(e.unevaluatedItems)}function Oi(e){return u.HasPropertyKey(e,"unevaluatedProperties")&&Y(e.unevaluatedProperties)}function rq(e){return Mi(e)||Oi(e)||u.Some(u.Keys(e),(t)=>Gc(e[t]))}function iq(e){return u.Some(e,(t)=>Gc(t))}function Gc(e){return u.IsArray(e)?iq(e):u.IsObject(e)?rq(e):!1}function Mw(e,t){return Gc(t)||u.Some(u.Keys(e),(n)=>Gc(e[n]))}class Ih{constructor(e){this.hasUnevaluated=e}UseUnevaluated(){return this.hasUnevaluated}Push(){return y.Call(y.Member("context","Push"),[])}Pop(){return y.Call(y.Member("context","Pop"),[])}AddIndex(e){return y.Call(y.Member("context","AddIndex"),[e])}AddKey(e){return y.Call(y.Member("context","AddKey"),[e])}Merge(e){return y.Call(y.Member("context","Merge"),[e])}}class Ht{constructor(){let e=new Set,t=new Set;this.stack=[{indices:e,keys:t}]}Push(){let e=new Set,t=new Set;return this.stack.push({indices:e,keys:t}),!0}Pop(){return this.stack.pop(),!0}AddIndex(e){return this.GetIndices().add(e),!0}AddKey(e){return this.GetKeys().add(e),!0}GetIndices(){return this.stack[this.stack.length-1].indices}GetKeys(){return this.stack[this.stack.length-1].keys}Merge(e){for(let t of e)t.GetIndices().forEach((n)=>this.GetIndices().add(n)),t.GetKeys().forEach((n)=>this.GetKeys().add(n));return!0}}class _t extends Ht{constructor(){super();this.errors=[]}AtCapacity(){return this.errors.length>=He.Get().maxErrors}AddError(e,t,n,r){return this.AddErrorObject({keyword:e,schemaPath:t,instancePath:n,params:r})}AddErrors(e){return e.forEach((t)=>this.AddErrorObject(t)),!1}GetErrors(){return this.errors}AddErrorObject(e){if(!this.AtCapacity())this.errors.push(e);return!1}}var jc={identifier:"External",variables:[]};function Hn(e){let t=`External[${jc.variables.length}]`;return jc.variables.push(e),t}function Ow(){jc.variables=[]}function Fw(){return{...jc}}function Nw(e,t,n,r){let i=Hn(n["~refine"].map((o)=>o));return y.Every(i,y.Constant(0),["refinement","_"],y.Call(y.Member("refinement","check"),[r]))}function Dw(e,t,n,r){return u.Every(n["~refine"],0,(i,o)=>i.check(r))}function Hw(e,t,n,r,i,o){return u.EveryAll(i["~refine"],0,(s,a)=>s.check(o)||t.AddError("~refine",n,r,{index:a,message:s.error(o)}))}var vl="urn:typebox:root";function Xr(e,t){return URL.canParse(e,t)?new URL(e,t):u.IsEqual(t,vl)?new URL(`${t}:${e}`):new URL(`${t.slice(0,t.lastIndexOf(":"))}:${e}`)}function Fi(e,t){let n=Rt(t)&&Yt(t)?Xr(t.$id,vl).href:vl;return{context:e,schema:t,lexicalSchema:t,lexicalBase:n,resourceBase:n,referenceBase:n,ids:[],useResourceBaseForReference:!0,recursiveAnchor:void 0,dynamicAnchors:[],resourceEntries:new Map,pendingResource:!0,enteredResource:!1}}function Sh(e,t,n=!0){if(Ri(t))return e;if(Array.isArray(t))return t.reduce((i,o)=>Sh(i,o,!1),e);if(!Rt(t))return e;if(!n&&Yt(t))return e;let r=!n&&Ai(t)?[...e,t]:e;return Object.keys(t).reduce((i,o)=>Sh(i,t[o],!1),r)}function kl(e,t){return e.resourceEntries.get(t)}function _w(e,t){return e.enteredResource||kl(e,t)!==void 0}function oq(e){return!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e.$id)}function sq(e,t){return Yt(t)?[...e.ids,t]:e.ids}function aq(e,t){return e.recursiveAnchor??(Il(t)?t:void 0)}function lq(e,t){let n=Yt(t)?Sh(e.dynamicAnchors,t):e.dynamicAnchors;return Ai(t)?[...n,t]:n}function uq(e,t){return Yt(t)?!1:e.pendingResource}function Uw(e,t){let n=kl(e,t);if(n)return n.base;return Yt(t)?Xr(t.$id,e.lexicalBase).href:e.lexicalBase}function Bw(e,t){let n=kl(e,t);if(n)return n.base;return Yt(t)&&e.pendingResource?Xr(t.$id,e.resourceBase).href:e.resourceBase}function Gw(e,t){return Yt(t)?!oq(t):e.useResourceBaseForReference}function dq(e,t){let n=_w(e,t),r=Gw(e,t);return n||r?Bw(e,t):Uw(e,t)}function cq(e,t){let n=kl(e,t);if(n)return n.root;return Yt(t)?t:e.lexicalSchema}function mq(e,t){return Rt(t)&&(Yt(t)||Ai(t)||u.IsUndefined(e.recursiveAnchor)&&Il(t)||!u.IsUndefined(kl(e,t)))}function Eo(e,t){return mq(e,t)?{...e,ids:sq(e,t),dynamicAnchors:lq(e,t),recursiveAnchor:aq(e,t),pendingResource:uq(e,t),lexicalBase:Uw(e,t),resourceBase:Bw(e,t),useResourceBaseForReference:Gw(e,t),referenceBase:dq(e,t),lexicalSchema:cq(e,t),enteredResource:_w(e,t)}:e}var fq=0;function Ce(){return`var_${fq++}`}function Ch(e){return zr(e)&&u.IsArray(e.items)}function pq(e,t,n,r){let[i,o]=[Ce(),Ce()],s=Jt(e,t,n.additionalItems,i),a=y.IsLessThan(o,y.Constant(n.items.length)),l=t.AddIndex(o);return y.Every(r,y.Constant(0),[i,o],y.Or(a,y.And(s,l)))}function hq(e,t,n,r){let[i,o]=[Ce(),Ce()],s=Jt(e,t,n.additionalItems,i),a=y.IsLessThan(o,y.Constant(n.items.length));return y.Every(r,y.Constant(0),[i,o],y.Or(a,s))}function jw(e,t,n,r){if(!Ch(n))return y.Constant(!0);return t.UseUnevaluated()?pq(e,t,n,r):hq(e,t,n,r)}function qw(e,t,n,r){if(!Ch(n))return!0;return u.Every(r,0,(o,s)=>u.IsLessThan(s,n.items.length)||wn(e,t,n.additionalItems,o)&&t.AddIndex(s))}function zw(e,t,n,r,i,o){if(!Ch(i))return!0;return u.Every(o,0,(a,l)=>{let d=`${n}/additionalItems`,c=`${r}/${l}`;return u.IsLessThan(l,i.items.length)||Ln(e,t,d,c,i.additionalItems,a)&&t.AddIndex(l)})}function nr(e){return new RegExp(e,"u")}function gq(e,t){return!e.UseUnevaluated()&&(u.IsEqual(t,!0)||u.IsObject(t)&&u.IsEqual(u.Keys(t).length,0))}function yq(e){return`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`}function Eh(e){let t=[];if(Vr(e))t.push(...u.Keys(e.patternProperties));if(Wr(e))t.push(...u.Keys(e.properties).map(yq));return u.IsEqual(t.length,0)?"(?!)":`(${t.join("|")})`}function xq(e,t,n){return tr(t)&&Wr(t)&&!Vr(t)&&u.IsEqual(t.additionalProperties,!1)&&u.IsEqual(u.Keys(t.properties).length,t.required.length)}function Iq(e,t,n){return y.IsEqual(y.Member(y.Call(y.Member("Object","getOwnPropertyNames"),[n]),"length"),y.Constant(t.required.length))}function Sq(e,t,n,r){let[i,o]=[Ce(),Ce()],s=Hn(nr(Eh(n))),a=Jt(e,t,n.additionalProperties,`${r}[${i}]`),l=y.Call(y.Member(s,"test"),[i]),d=t.AddKey(i),c=t.UseUnevaluated()?y.Or(l,y.And(a,d)):y.Or(l,a);return y.Every(y.Keys(r),y.Constant(0),[i,o],c)}function Kw(e,t,n,r){if(gq(t,n.additionalProperties))return y.Constant(!0);return xq(t,n,r)?Iq(t,n,r):Sq(e,t,n,r)}function Vw(e,t,n,r){let i=nr(Eh(n));return u.Every(u.Keys(r),0,(s,a)=>i.test(s)||wn(e,t,n.additionalProperties,r[s])&&t.AddKey(s))}function Ww(e,t,n,r,i,o){let s=nr(Eh(i)),a=[];return u.EveryAll(u.Keys(o),0,(d,c)=>{let m=`${n}/additionalProperties`,p=`${r}/${d}`,h=s.test(d)||Ln(e,t,m,p,i.additionalProperties,o[d])&&t.AddKey(d);if(!h)a.push(d);return h})||t.AddError("additionalProperties",n,r,{additionalProperties:a})}function Ni(e,t,n,r,i){let o=y.ConstDeclaration("results","[]"),s=n.map((c,m)=>y.ConstDeclaration(`context_${m}`,y.New("CheckContext",[]))),a=n.map((c,m)=>y.ConstDeclaration(`condition_${m}`,y.Call(y.ArrowFunction(["context"],he(e,t,c,r)),[`context_${m}`]))),l=n.map((c,m)=>y.If(`condition_${m}`,y.Call(y.Member("results","push"),[`context_${m}`]))),d=y.Return(y.And(i,t.Merge("results")));return y.Call(y.ArrowFunction([],y.Statements([o,...s,...a,...l,d])),[])}function bq(e,t,n,r){return Ni(e,t,n.allOf,r,y.IsEqual(y.Member("results","length"),y.Constant(n.allOf.length)))}function Cq(e,t,n,r){return y.ReduceAnd(n.allOf.map((i)=>he(e,t,i,r)))}function Xw(e,t,n,r){return t.UseUnevaluated()?bq(e,t,n,r):Cq(e,t,n,r)}function Yw(e,t,n,r){let i=n.allOf.reduce((o,s)=>{let a=new Ht;return ce(e,a,s,r)?[...o,a]:o},[]);return u.IsEqual(i.length,n.allOf.length)&&t.Merge(i)}function Jw(e,t,n,r,i,o){let s=[],a=i.allOf.reduce((d,c,m)=>{let p=`${n}/allOf/${m}`,h=new _t,x=Re(e,h,p,r,c,o);if(!x)s.push(h);return x?[...d,h]:d},[]),l=u.IsEqual(a.length,i.allOf.length)&&t.Merge(a);if(!l)s.forEach((d)=>t.AddErrors(d.GetErrors()));return l}function Eq(e,t,n,r){return Ni(e,t,n.anyOf,r,y.IsGreaterThan(y.Member("results","length"),y.Constant(0)))}function vq(e,t,n,r){return y.ReduceOr(n.anyOf.map((i)=>he(e,t,i,r)))}function Zw(e,t,n,r){return t.UseUnevaluated()?Eq(e,t,n,r):vq(e,t,n,r)}function Qw(e,t,n,r){let i=n.anyOf.reduce((o,s)=>{let a=new Ht;return ce(e,a,s,r)?[...o,a]:o},[]);return u.IsGreaterThan(i.length,0)&&t.Merge(i)}function eL(e,t,n,r,i,o){let s=[],a=i.anyOf.reduce((d,c,m)=>{let p=new _t,h=`${n}/anyOf/${m}`,x=Re(e,p,h,r,c,o);if(!x)s.push(p);return x?[...d,p]:d},[]),l=u.IsGreaterThan(a.length,0)&&t.Merge(a);if(!l)s.forEach((d)=>t.AddErrors(d.GetErrors()));return l||t.AddError("anyOf",n,r,{})}function tL(e,t,n,r){return n?y.Constant(!0):y.Constant(!1)}function vh(e,t,n,r){return n}function nL(e,t,n,r,i,o){return vh(e,t,i,o)||t.AddError("boolean",n,r,{})}function rL(e,t,n,r){return u.IsValueLike(n.const)?y.IsEqual(r,y.Constant(n.const)):y.IsDeepEqual(r,Hn(n.const))}function kh(e,t,n,r){return u.IsValueLike(n.const)?u.IsEqual(r,n.const):u.IsDeepEqual(r,n.const)}function iL(e,t,n,r,i,o){return kh(e,t,i,o)||t.AddError("const",n,r,{allowedValue:i.const})}function oL(e){return!(Kr(e)&&u.IsEqual(e.minContains,0))}function kq(e,t,n,r){let[i,o]=[Ce(),Ce()],s=y.Not(y.IsEqual(y.Member(r,"length"),y.Constant(0))),a=y.SomeAll(r,[i,o],y.And(he(e,t,n.contains,i),t.AddIndex(o)));return y.And(s,a)}function Tq(e,t,n,r){let[i]=[Ce()],o=y.Not(y.IsEqual(y.Member(r,"length"),y.Constant(0))),s=y.Some(r,[i,"_"],he(e,t,n.contains,i));return y.And(o,s)}function sL(e,t,n,r){if(!oL(n))return y.Constant(!0);return t.UseUnevaluated()?kq(e,t,n,r):Tq(e,t,n,r)}function Th(e,t,n,r){if(!oL(n))return!0;return!u.IsEqual(r.length,0)&&u.SomeAll(r,(i,o)=>ce(e,t,n.contains,i)&&t.AddIndex(o))}function aL(e,t,n,r,i,o){return Th(e,t,i,o)||t.AddError("contains",n,r,{minContains:1})}function lL(e,t,n,r){let i=y.IsEqual(y.Member(y.Keys(r),"length"),y.Constant(0)),o=y.ReduceAnd(u.Entries(n.dependencies).map(([s,a])=>{let l=y.Not(y.HasPropertyKey(r,y.Constant(s))),d=he(e,t,a,r),c=(m)=>y.ReduceAnd(m.map((p)=>y.HasPropertyKey(r,y.Constant(p))));return y.Or(l,u.IsArray(a)?c(a):d)}));return y.Or(i,o)}function uL(e,t,n,r){let i=u.IsEqual(u.Keys(r).length,0),o=u.Every(u.Entries(n.dependencies),0,([s,a])=>!u.HasPropertyKey(r,s)||(u.IsArray(a)?a.every((l)=>u.HasPropertyKey(r,l)):ce(e,t,a,r)));return i||o}function dL(e,t,n,r,i,o){let s=u.IsEqual(u.Keys(o).length,0),a=u.EveryAll(u.Entries(i.dependencies),0,([l,d])=>{let c=`${n}/dependencies/${l}`;return!u.HasPropertyKey(o,l)||(u.IsArray(d)?d.every((m)=>u.HasPropertyKey(o,m)||t.AddError("dependencies",n,r,{property:l,dependencies:d})):Re(e,t,c,r,d,o))});return s||a}function cL(e,t,n,r){let i=y.IsEqual(y.Member(y.Keys(r),"length"),y.Constant(0)),o=y.ReduceAnd(u.Entries(n.dependentRequired).map(([s,a])=>{let l=y.Not(y.HasPropertyKey(r,y.Constant(s))),d=y.ReduceAnd(a.map((c)=>y.HasPropertyKey(r,y.Constant(c))));return y.Or(l,d)}));return y.Or(i,o)}function mL(e,t,n,r){let i=u.IsEqual(u.Keys(r).length,0),o=u.Every(u.Entries(n.dependentRequired),0,([s,a])=>!u.HasPropertyKey(r,s)||a.every((l)=>u.HasPropertyKey(r,l)));return i||o}function fL(e,t,n,r,i,o){let s=u.IsEqual(u.Keys(o).length,0),a=u.EveryAll(u.Entries(i.dependentRequired),0,([l,d])=>!u.HasPropertyKey(o,l)||u.EveryAll(d,0,(c)=>u.HasPropertyKey(o,c)||t.AddError("dependentRequired",n,r,{property:l,dependencies:d})));return s||a}function pL(e,t,n,r){let i=y.IsEqual(y.Member(y.Keys(r),"length"),y.Constant(0)),o=y.ReduceAnd(u.Entries(n.dependentSchemas).map(([s,a])=>{let l=y.Not(y.HasPropertyKey(r,y.Constant(s))),d=he(e,t,a,r);return y.Or(l,d)}));return y.Or(i,o)}function hL(e,t,n,r){let i=u.IsEqual(u.Keys(r).length,0),o=u.Every(u.Entries(n.dependentSchemas),0,([s,a])=>!u.HasPropertyKey(r,s)||ce(e,t,a,r));return i||o}function gL(e,t,n,r,i,o){let s=u.IsEqual(u.Keys(o).length,0),a=u.EveryAll(u.Entries(i.dependentSchemas),0,([l,d])=>{let c=`${n}/dependentSchemas/${l}`;return!u.HasPropertyKey(o,l)||Re(e,t,c,r,d,o)});return s||a}var on={};Bt(on,{DynamicRef:()=>az,RecursiveRef:()=>iz,Ref:()=>nz});var Fs={};Bt(Fs,{Delete:()=>Oq,Get:()=>$q,Has:()=>Pq,Indices:()=>Tl,Set:()=>Mq});function yL(e){if(e.length===0)throw Error("Cannot set root")}function xL(e){if(!u.IsObject(e))throw Error("Cannot set value")}function wq(e){if(u.IsUnsafePropertyKey(e))throw Error("Pointer contains unsafe property key")}function IL(e){for(let t of e)wq(t)}function Lq(e){return/^(0|[1-9]\d*)$/.test(e)}function SL(e){return[e.slice(0,e.length-1),e.slice(e.length-1)[0]]}function Rq(e,t){return u.IsObject(t)&&u.HasPropertyKey(t,e)}function Aq(e,t){return u.IsObject(t)&&!u.IsUnsafePropertyKey(e)?t[e]:void 0}function wh(e,t){return e.reduce((n,r)=>Aq(r,n),t)}function Tl(e){if(u.IsEqual(e.length,0))return[];let t=e.split("/").map((n)=>n.replace(/~1/g,"/").replace(/~0/g,"~"));return t.length>0&&t[0]===""?t.slice(1):t}function Pq(e,t){let n=e;return Tl(t).every((r)=>{if(!Rq(r,n))return!1;return n=n[r],!0})}function $q(e,t){let n=Tl(t);return wh(n,e)}function Mq(e,t,n){let r=Tl(t);yL(r),IL(r);let[i,o]=SL(r),s=wh(i,e);return xL(s),s[o]=n,e}function Oq(e,t){let n=Tl(t);yL(n),IL(n);let[r,i]=SL(n),o=wh(r,e);if(xL(o),u.IsArray(o)&&Lq(i))o.splice(+i,1);else delete o[i];return e}function Ah(e,t){return Rt(e)&&Yt(e)?Xr(e.$id,t.href):t}function Ph(e){return Xr(e,vl)}function Lh(e){return e.href.split("#")[0]}function Fq(e,t,n){return Rh(e,Ph(t),n)}function Nq(e,t){return t.$ref.startsWith("#")||e.enteredResource?e.lexicalSchema:e.schema}function Dq(e){return e.startsWith("#/")}function bL(e,t){if(u.IsObject(e)&&Ai(e)&&u.IsEqual(e.$dynamicAnchor,t))return e;if(u.IsObject(e))for(let n of u.Keys(e)){let r=bL(e[n],t);if(r)return r}return}function Rh(e,t,n){if(u.IsEqual(e,n))return t.href;let r=Ah(e,t);if(u.IsArray(e))for(let i of e){let o=Rh(i,r,n);if(!u.IsUndefined(o))return o}else if(u.IsObject(e))for(let i of u.Keys(e)){let o=Rh(e[i],r,n);if(!u.IsUndefined(o))return o}return}function CL(e,t){if(t.href.endsWith("#"))return e;if(!t.hash.startsWith("#"))return;let n=decodeURIComponent(t.hash.slice(1));if(!n.startsWith("/"))return;return Fs.Get(e,n)}function Hq(e,t,n){if(!Yt(e))return;if(u.IsEqual(e.$id,n.hash))return e;let r=new URL(n.href,t.href);if(u.IsEqual(t.pathname,r.pathname))return n.hash.startsWith("#")?CL(e,n):e;return}function _q(e,t,n){if(!$w(e))return;let r=new URL(`#${e.$anchor}`,t.href),i=new URL(n.href,t.href);return u.IsEqual(r.href,i.href)?e:void 0}function Uq(e,t,n){if(!Ai(e))return;let r=new URL(`#${e.$dynamicAnchor}`,t.href),i=new URL(n.href,t.href);return u.IsEqual(r.href,i.href)?e:void 0}function Bq(e,t,n){if(!Rt(e))return;return Hq(e,t,n)??_q(e,t,n)??Uq(e,t,n)??CL(e,n)}function Gq(e,t,n){if(!u.IsArray(e))return;return e.reduce((r,i)=>{let o=qc(i,t,n);return!u.IsUndefined(o)?o:r},void 0)}function jq(e,t,n){if(!u.IsObject(e))return;return u.Keys(e).reduce((r,i)=>{if(u.IsEqual(i,"const")||u.IsEqual(i,"enum"))return r;let o=qc(e[i],t,n);return!u.IsUndefined(o)?o:r},void 0)}function qc(e,t,n){let r=Ah(e,t);return Bq(e,r,n)??Gq(e,r,n)??jq(e,r,n)}function qq(e,t,n,r){let i=zc(e,t,n,r);return Rt(i)&&Yt(i)?i:void 0}function zq(e,t,n){if(!t.$ref.startsWith("#"))return;if(!Rt(e.schema)||u.HasPropertyKey(e.schema,"$schema"))return;let r=Fq(e.lexicalSchema,e.referenceBase,n);if(u.IsUndefined(r)||u.IsEqual(r,e.referenceBase))return;return{target:n,base:r,root:e.lexicalSchema}}function Kq(e,t,n){let r=e.context[t];if(!Rt(r))return;return{target:n,base:t,root:r}}function Vq(e,t,n,r,i){let o=i?Kq(e,r,n):void 0;return u.IsUndefined(o)?zq(e,t,n):o}function Wq(e,t,n){if(Yt(n))return;let r=qq(e.context,e.schema,e.referenceBase,t);if(!r||e.ids.includes(r))return;return{resource:r}}function Xq(e,t){return u.HasPropertyKey(e,t)?e[t]:void 0}function Yq(e,t,n){return qc(e,t,n)}function Jq(e,t,n){let r=Lh(n);if(!u.HasPropertyKey(e,r)||u.IsEqual(r,Lh(t)))return;let i=e[r],o=Ah(i,new URL(r));return u.IsEqual(n.hash,"")?i:qc(i,o,n)}function zc(e,t,n,r){let i=Ph(n),o=Xr(r,i.href);return Xq(e,r)??Yq(t,i,o)??Jq(e,i,o)}function Zq(e,t){if(!t)return e;let n=new Map(e.resourceEntries);return n.set(t.target,{base:t.base,root:t.root}),{...e,resourceEntries:n}}function Qq(e,t){return t?Eo(e,t.resource):e}function EL(e,t,n,r){let i=Zq({...e,pendingResource:t},n);return Qq(i,r)}function ez(e,t,n){let r=Lh(Xr(t.$ref,e.referenceBase)),i=!u.IsEqual(r,e.resourceBase),o=Vq(e,t,n,r,i),s=i?Wq(e,r,n):void 0;return{schema:n,stack:EL(e,!0,o,s)}}function tz(e,t){return{schema:t,stack:EL(e,!u.IsUndefined(t))}}function nz(e,t){let n=zc(e.context,Nq(e,t),e.referenceBase,t.$ref);return Rt(n)?ez(e,t,n):tz(e,n)}function rz(e){return Rt(e.lexicalSchema)&&Il(e.lexicalSchema)}function iz(e,t){let n=rz(e)?e.recursiveAnchor:e.lexicalSchema;return zc(e.context,n,e.lexicalBase,t.$recursiveRef)}function vL(e,t){return Xr(t.$dynamicRef,Ph(e.lexicalBase).href).hash}function kL(e,t){return e.dynamicAnchors.find((n)=>u.IsEqual(n.$dynamicAnchor,t))??bL(e.schema,t)}function oz(e,t,n){if(!Rt(n)||!Ai(n))return n;let r=vL(e,t);return Dq(r)?n:kL(e,n.$dynamicAnchor)}function sz(e,t){let n=vL(e,t);return kL(e,decodeURIComponent(n.slice(1)))}function az(e,t){let n=t.$dynamicRef.startsWith("#")?e.lexicalSchema:e.schema,r=zc(e.context,n,e.lexicalBase,t.$dynamicRef);return u.IsUndefined(r)?sz(e,t):oz(e,t,r)}function TL(e,t,n,r){let i=on.DynamicRef(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Yr(o,t,i,r)}function wL(e,t,n,r){let i=on.DynamicRef(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Y(i)&&ce(o,t,i,r)}function LL(e,t,n,r,i,o){let s=on.DynamicRef(e,i)??!1,a=s?{...e,pendingResource:!0}:e;return Y(s)&&Re(a,t,"#",r,s,o)}function RL(e,t,n,r){return y.ReduceOr(n.enum.map((i)=>{if(u.IsValueLike(i))return y.IsEqual(r,y.Constant(i));let o=Hn(i);return y.IsDeepEqual(r,o)}))}function Mh(e,t,n,r){return u.Some(n.enum,(i)=>u.IsValueLike(i)?u.IsEqual(r,i):u.IsDeepEqual(r,i))}function AL(e,t,n,r,i,o){return Mh(e,t,i,o)||t.AddError("enum",n,r,{allowedValues:i.enum})}function PL(e,t,n,r){return y.IsLessThan(r,y.Constant(n.exclusiveMaximum))}function Oh(e,t,n,r){return u.IsLessThan(r,n.exclusiveMaximum)}function $L(e,t,n,r,i,o){return Oh(e,t,i,o)||t.AddError("exclusiveMaximum",n,r,{comparison:"<",limit:i.exclusiveMaximum})}function ML(e,t,n,r){return y.IsGreaterThan(r,y.Constant(n.exclusiveMinimum))}function Fh(e,t,n,r){return u.IsGreaterThan(r,n.exclusiveMinimum)}function OL(e,t,n,r,i,o){return Fh(e,t,i,o)||t.AddError("exclusiveMinimum",n,r,{comparison:">",limit:i.exclusiveMinimum})}var vo={};Bt(vo,{Clear:()=>aR,Entries:()=>Jz,Get:()=>e8,Has:()=>Qz,IsDate:()=>Ns,IsDateTime:()=>Kc,IsDuration:()=>Vc,IsEmail:()=>Wc,IsHostname:()=>nm,IsIPv4:()=>om,IsIPv6:()=>sm,IsIdnEmail:()=>rm,IsIdnHostname:()=>im,IsIri:()=>lm,IsIriReference:()=>am,IsJsonPointer:()=>dm,IsJsonPointerUriFragment:()=>um,IsRegex:()=>cm,IsRelativeJsonPointer:()=>mm,IsTime:()=>Ds,IsUri:()=>hm,IsUriReference:()=>fm,IsUriTemplate:()=>pm,IsUrl:()=>gm,IsUuid:()=>ym,Reset:()=>lR,Set:()=>Zz,Test:()=>t8});var lz=[0,31,28,31,30,31,30,31,31,30,31,30,31],uz=/^(\d\d\d\d)-(\d\d)-(\d\d)$/;function dz(e){return e%4===0&&(e%100!==0||e%400===0)}function Ns(e){let t=uz.exec(e);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r===2&&dz(n)?29:lz[r])}var cz=/^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;function Ds(e,t=!0){let n=cz.exec(e);if(!n)return!1;if(t&&!n[4]&&!n[5])return!1;let r=+n[1],i=+n[2],o=+n[3];if(r>23||i>59||o>60)return!1;if(n[5]){let c=+n[6],m=+n[7];if(c>23||m>59)return!1}if(o<60)return!0;let s=n[5]==="-"?-1:1,a=+(n[6]||0),l=+(n[7]||0);return((r*60+i-s*(a*60+l))%1440+1440)%1440===1439}function Kc(e){let t=e.split(/T/i);return t.length===2&&Ns(t[0])&&Ds(t[1])}var mz=/^P((\d+Y(\d+M(\d+D)?)?|\d+M(\d+D)?|\d+D)(T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S))?|T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S)|\d+W)$/;function Vc(e){return mz.test(e)}var fz=/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;function Wc(e){return fz.test(e)}var FL=/^(?!-).*(?<!-)$/,NL=/^(?!..--)/,DL=/^[a-zA-Z0-9-]*$/;var Hs=/[^\p{ASCII}]/u;var pz=/[0-9]/,HL=/[\u{0660}-\u{0669}]/u,hz=/[\u{06f0}-\u{06f9}]/u,gz=/[\u{002e}\u{002c}\u{003a}\u{002f}]/u,yz=/[\u{002d}\u{002b}]/u,Nh=/\p{Mn}/u,xz=/\p{Mc}/u;var _L=/[\p{Mn}\p{Mc}\p{Me}]/u,Dh=/\p{L}/u,Iz=/\p{Nd}/u,UL=/\p{Script=Greek}/u,Xc=/\p{Script=Hebrew}/u,BL=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,GL=/[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u,Hh=/[\u{094d}\u{09cd}\u{0a4d}\u{0acd}\u{0b4d}\u{0bcd}\u{0c4d}\u{0ccd}\u{0d3b}\u{0d3c}\u{0d4d}\u{0dca}\u{1b44}\u{1baa}\u{1bab}\u{a9c0}\u{11046}\u{1107f}\u{110b9}\u{11133}\u{11134}\u{111c0}\u{11235}\u{1134d}\u{11442}\u{114c2}\u{115bf}\u{1163f}\u{116b6}\u{11c3f}\u{11d44}\u{11d45}]/u,jL=/[\u{0640}\u{07fa}\u{302e}\u{302f}\u{3031}\u{3032}\u{3033}\u{3034}\u{3035}\u{303b}]/u,Sz=/[\u{00b7}\u{0375}\u{05f3}\u{05f4}\u{200c}\u{200d}\u{30fb}]/u,bz=/[\u{00df}\u{03c2}\u{06fd}\u{06fe}\u{0f0b}\u{3007}]/u,qL=new RegExp([pz,hz].map((e)=>e.source).join("|"),"u"),zL=new RegExp([Dh,yz,gz,Iz,Nh,xz,Sz,bz].map((e)=>e.source).join("|"),"u");function KL(e){return FL.test(e)&&NL.test(e)&&DL.test(e)}var rr=36,Ll=1,Rl=26,Ez=38,vz=700,WL=72,XL=128;function _h(){throw null}function Yc(e){return e.toLowerCase().startsWith("xn--")}function YL(e,t,n){e=n?Math.floor(e/vz):e>>1,e+=Math.floor(e/t);let r=0;while(e>(rr-Ll)*Rl>>1)e=Math.floor(e/(rr-Ll)),r+=rr;return r+Math.floor((rr-Ll+1)*e/(e+Ez))}function Jc(e){let t=[],n=XL,r=0,i=WL,o=e.lastIndexOf("-");if(o>0)for(let a=0;a<o;a++){let l=e.charCodeAt(a);if(l>=128)_h();t.push(l)}let s=o<0?0:o+1;while(s<e.length){let a=r,l=1,d=rr;while(!0){if(s>=e.length)_h();let m=e.charCodeAt(s++),p;if(m>=97&&m<=122)p=m-97;else if(m>=48&&m<=57)p=m-48+26;else _h();r+=p*l;let h=d<=i?Ll:d>=i+Rl?Rl:d-i;if(p<h)break;l*=rr-h,d+=rr}let c=t.length+1;i=YL(r-a,c,a===0),n+=Math.floor(r/c),r%=c,t.splice(r,0,n),r++}return String.fromCodePoint(...t)}function VL(e){return e<26?String.fromCharCode(e+97):String.fromCharCode(e-26+48)}var kz=new RegExp(Hs.source,"gu");function JL(e){let t=e.replace(kz,""),n=t.length,r=n>0?[t,"-"]:[],i=Array.from(e,(d)=>d.codePointAt(0)),o=XL,s=0,a=WL,l=n;while(l<i.length){let d=1/0;for(let c of i)if(c>=o&&c<d)d=c;s+=(d-o)*(l+1),o=d;for(let c of i){if(c<o)s++;if(c===o){let m=s;for(let p=rr;;p+=rr){let h=p<=a?Ll:p>=a+Rl?Rl:p-a;if(m<h)break;let x=h+(m-h)%(rr-h);r.push(VL(x)),m=Math.floor((m-h)/(rr-h))}r.push(VL(m)),a=YL(s,l+1,l===n),s=0,l++}}s++,o++}return r.join("")}var Tz=/^(?:R|AL|AN|EN|ES|CS|ET|ON|BN|NSM)$/,ZL=/^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/,wz=/^(?:R|AL|AN)$/;function QL(e){if(Yc(e))try{return Zc(Jc(e.slice(4).toLowerCase()))}catch{return!1}return Zc(e)}function eR(e){let t=String.fromCodePoint(e);return qL.test(t)?"EN":HL.test(t)?"AN":Nh.test(t)?"NSM":Xc.test(t)?"R":GL.test(t)?"AL":Dh.test(t)?"L":"ON"}function Zc(e){for(let t of e)if(wz.test(eR(t.codePointAt(0))))return!0;return!1}function Qc(e){let t=!1,n=ZL,r=!1,i=!1,o=!0;for(let s of e){let a=eR(s.codePointAt(0));if(o){if(a!=="L"&&a!=="R"&&a!=="AL")return!1;t=a==="R"||a==="AL",n=t?Tz:ZL,o=!1}if(!n.test(a))return!1;if(a==="EN")r=!0;else if(a==="AN")i=!0}if(t&&r&&i)return!1;return!0}function Lz(e){return Hs.test(e)&&JL(e).length+4>63}function Rz(e){if(e[0]==="-"||e[e.length-1]==="-")return!0;return e.slice(2).join("").startsWith("--")}function em(e){if(Lz(e))return!1;if(Zc(e)&&!Qc(e))return!1;let t=[...e],n=t.map((o)=>o.codePointAt(0)),r=n.length;if(Rz(t))return!1;if(_L.test(t[0]))return!1;let i=!1;for(let o=0;o<r;o++){let s=n[o],a=t[o];if(jL.test(a))return!1;if(!zL.test(a))return!1;if(BL.test(a))i=!0;let l=n[o-1],d=n[o+1];switch(s){case 183:if(l!==108||d!==108)return!1;break;case 885:if(!d||!UL.test(t[o+1]))return!1;break;case 1523:case 1524:if(!l||!Xc.test(t[o-1]))return!1;break;case 8204:if(!l||l<128&&!Hh.test(t[o-1]))return!1;break;case 8205:if(!l||!Hh.test(t[o-1]))return!1;break;case 12539:break}}if(e.includes("・")&&!i)return!1;return!0}function tm(e){if(!Yc(e))return!1;try{let t=e.slice(4).toLowerCase();if(t.lastIndexOf("-")===0)return!1;let n=Jc(t);if(!Hs.test(n))return!1;return em(n)}catch{return!1}}function Az(e){return e.length>0&&e.length<=63}function Pz(e){return Az(e)&&(tm(e)||KL(e))}function iR(e){if(e.length===0||e.length>253)return!1;if(e.charCodeAt(e.length-1)===46)return!1;return e.split(".").every((t)=>Pz(t))}function $z(e){return e.length>0&&e.length<=63}function Mz(e){return $z(e)&&(tm(e)||em(e))}function Oz(e){return e.replace(/[\uff01-\uff5e]/g,(t)=>String.fromCharCode(t.charCodeAt(0)-65248)).normalize("NFC").replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu,"").replace(/[\u002E\u3002\uFF0E\uFF61]/g,".")}function oR(e){if(e.length===0||e.includes(" "))return!1;let t=Oz(e);if(t.length>253)return!1;let n=t.split("."),r=n.some((i)=>QL(i));return n.every((i)=>Mz(i)&&(!r||Qc(i)))}function nm(e){return iR(e)}var Fz=/^(?:[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+(?:\.[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+)*|"(?:[^"\\]|\\.)*")@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-)(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-))*$/iu;function rm(e){return Fz.test(e.normalize("NFC"))}function im(e){return oR(e)}var Nz=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function om(e){return Nz.test(e)}var Dz=/^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;function sm(e){return Dz.test(e)}var Hz=/[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/,_z=/^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;function am(e){return!Hz.test(e)&&!_z.test(e)&&URL.canParse(e,"http://example.com")}var Uz=/\[[vV][0-9a-fA-F]+\.[^\]]+\]/,Bz=/[\x00-\x20<>\^`{|}\\]/,Gz=/%(?![0-9a-fA-F]{2})/;function jz(e){return e.length<2048?e.replace(Uz,"[::1]"):e}function lm(e){if(Bz.test(e))return!1;if(Gz.test(e))return!1;return URL.canParse(jz(e))}var qz=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function um(e){return qz.test(e)}var zz=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function dm(e){return zz.test(e)}function cm(e){try{return new RegExp(e,"u"),!0}catch{return!1}}var Kz=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function mm(e){return Kz.test(e)}var Vz=/^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function fm(e){return Vz.test(e)}var Wz=/^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?)*\})*$/i;function pm(e){return Wz.test(e)}var Xz=/^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function hm(e){return Xz.test(e)}function gm(e){return URL.canParse(e)}var Yz=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function ym(e){return Yz.test(e)}var Ne=new Map;function aR(){Ne.clear()}function Jz(){return[...Ne.entries()]}function Zz(e,t){Ne.set(e,t)}function Qz(e){return Ne.has(e)}function e8(e){return Ne.get(e)}function t8(e,t){return Ne.get(e)?.(t)??!0}function lR(){aR(),Ne.set("date-time",Kc),Ne.set("date",Ns),Ne.set("duration",Vc),Ne.set("email",Wc),Ne.set("hostname",nm),Ne.set("idn-email",rm),Ne.set("idn-hostname",im),Ne.set("ipv4",om),Ne.set("ipv6",sm),Ne.set("iri-reference",am),Ne.set("iri",lm),Ne.set("json-pointer-uri-fragment",um),Ne.set("json-pointer",dm),Ne.set("regex",cm),Ne.set("relative-json-pointer",mm),Ne.set("time",Ds),Ne.set("uri-reference",fm),Ne.set("uri-template",pm),Ne.set("uri",hm),Ne.set("url",gm),Ne.set("uuid",ym)}lR();function uR(e,t,n,r){return y.Call(y.Member("Format","Test"),[y.Constant(n.format),r])}function Bh(e,t,n,r){return vo.Test(n.format,r)}function dR(e,t,n,r,i,o){return Bh(e,t,i,o)||t.AddError("format",n,r,{format:i.format})}function cR(e,t,n,r){let i=Cl(n)?n.then:!0,o=ll(n)?n.else:!0;return y.Ternary(he(e,t,n.if,r),he(e,t,i,r),he(e,t,o,r))}function mR(e,t,n,r){let i=Cl(n)?n.then:!0,o=ll(n)?n.else:!0;return ce(e,t,n.if,r)?ce(e,t,i,r):ce(e,t,o,r)}function fR(e,t,n,r,i,o){let s=Cl(i)?i.then:!0,a=ll(i)?i.else:!0,l=new _t,d=Re(e,l,`${n}/if`,r,i.if,o)?Re(e,l,`${n}/then`,r,s,o)||t.AddError("if",n,r,{failingKeyword:"then"}):Re(e,t,`${n}/else`,r,a,o)||t.AddError("if",n,r,{failingKeyword:"else"});if(d)t.Merge([l]);return d}function n8(e,t,n,r){return y.ReduceAnd(n.items.map((i,o)=>{let s=y.IsLessEqualThan(y.Member(r,"length"),y.Constant(o)),a=Jt(e,t,i,`${r}[${o}]`),l=t.AddIndex(y.Constant(o));return y.Or(s,y.And(a,l))}))}function r8(e,t,n,r){return y.ReduceAnd(n.items.map((i,o)=>{let s=y.IsLessEqualThan(y.Member(r,"length"),y.Constant(o)),a=Jt(e,t,i,`${r}[${o}]`);return y.Or(s,a)}))}function i8(e,t,n,r){return t.UseUnevaluated()?n8(e,t,n,r):r8(e,t,n,r)}function o8(e,t,n,r){return u.Every(n.items,0,(i,o)=>u.IsLessEqualThan(r.length,o)||wn(e,t,i,r[o])&&t.AddIndex(o))}function s8(e,t,n,r,i,o){return u.EveryAll(i.items,0,(s,a)=>{let l=`${n}/items/${a}`,d=`${r}/${a}`;return u.IsLessEqualThan(o.length,a)||Ln(e,t,l,d,s,o[a])&&t.AddIndex(a)})}function a8(e,t,n,r){let i=er(n)?n.prefixItems.length:0,o=Jt(e,t,n.items,"element"),s=t.AddIndex("index");return y.Every(r,y.Constant(i),["element","index"],y.And(o,s))}function l8(e,t,n,r){let i=er(n)?n.prefixItems.length:0,o=Jt(e,t,n.items,"element");return y.Every(r,y.Constant(i),["element","index"],o)}function u8(e,t,n,r){return t.UseUnevaluated()?a8(e,t,n,r):l8(e,t,n,r)}function d8(e,t,n,r){let i=er(n)?n.prefixItems.length:0;return u.Every(r,i,(o,s)=>wn(e,t,n.items,o)&&t.AddIndex(s))}function c8(e,t,n,r,i,o){let s=er(i)?i.prefixItems.length:0;return u.EveryAll(o,s,(a,l)=>{let d=`${n}/items`,c=`${r}/${l}`;return Ln(e,t,d,c,i.items,a)&&t.AddIndex(l)})}function pR(e,t,n,r){return cl(n)?i8(e,t,n,r):u8(e,t,n,r)}function hR(e,t,n,r){return cl(n)?o8(e,t,n,r):d8(e,t,n,r)}function gR(e,t,n,r,i,o){return cl(i)?s8(e,t,n,r,i,o):c8(e,t,n,r,i,o)}function yR(e){return Cr(e)}function xR(e,t,n,r){if(!yR(n))return y.Constant(!0);let[i]=[Ce()],o=y.Counted(r,[i,"_"],he(e,t,n.contains,i));return y.IsLessEqualThan(o,y.Constant(n.maxContains))}function Gh(e,t,n,r){if(!yR(n))return!0;let i=u.Counted(r,(o)=>ce(e,t,n.contains,o));return u.IsLessEqualThan(i,n.maxContains)}function IR(e,t,n,r,i,o){let s=Kr(i)?i.minContains:1;return Gh(e,t,i,o)||t.AddError("contains",n,r,{minContains:s,maxContains:i.maxContains})}function SR(e,t,n,r){return y.IsLessEqualThan(r,y.Constant(n.maximum))}function jh(e,t,n,r){return u.IsLessEqualThan(r,n.maximum)}function bR(e,t,n,r,i,o){return jh(e,t,i,o)||t.AddError("maximum",n,r,{comparison:"<=",limit:i.maximum})}function CR(e,t,n,r){return y.IsLessEqualThan(y.Member(r,"length"),y.Constant(n.maxItems))}function qh(e,t,n,r){return u.IsLessEqualThan(r.length,n.maxItems)}function ER(e,t,n,r,i,o){return qh(e,t,i,o)||t.AddError("maxItems",n,r,{limit:i.maxItems})}function vR(e,t,n,r){return y.IsMaxLength(r,y.Constant(n.maxLength))}function zh(e,t,n,r){return u.IsMaxLength(r,n.maxLength)}function kR(e,t,n,r,i,o){return zh(e,t,i,o)||t.AddError("maxLength",n,r,{limit:i.maxLength})}function TR(e,t,n,r){return y.IsLessEqualThan(y.Member(y.Keys(r),"length"),y.Constant(n.maxProperties))}function Kh(e,t,n,r){return u.IsLessEqualThan(u.Keys(r).length,n.maxProperties)}function wR(e,t,n,r,i,o){return Kh(e,t,i,o)||t.AddError("maxProperties",n,r,{limit:i.maxProperties})}function LR(e){return Cr(e)}function m8(e,t,n,r){let[i,o]=[Ce(),Ce()],s=y.Counted(r,[i,o],y.And(he(e,t,n.contains,i),t.AddIndex(o)));return y.IsGreaterEqualThan(s,y.Constant(n.minContains))}function f8(e,t,n,r){let[i]=[Ce()],o=y.Counted(r,[i,"_"],he(e,t,n.contains,i));return y.IsGreaterEqualThan(o,y.Constant(n.minContains))}function RR(e,t,n,r){if(!LR(n))return y.Constant(!0);return t.UseUnevaluated()?m8(e,t,n,r):f8(e,t,n,r)}function Vh(e,t,n,r){if(!LR(n))return!0;let i=u.Counted(r,(o,s)=>ce(e,t,n.contains,o)&&t.AddIndex(s));return u.IsGreaterEqualThan(i,n.minContains)}function AR(e,t,n,r,i,o){return Vh(e,t,i,o)||t.AddError("contains",n,r,{minContains:i.minContains})}function PR(e,t,n,r){return y.IsGreaterEqualThan(r,y.Constant(n.minimum))}function Wh(e,t,n,r){return u.IsGreaterEqualThan(r,n.minimum)}function $R(e,t,n,r,i,o){return Wh(e,t,i,o)||t.AddError("minimum",n,r,{comparison:">=",limit:i.minimum})}function MR(e,t,n,r){return y.IsGreaterEqualThan(y.Member(r,"length"),y.Constant(n.minItems))}function Xh(e,t,n,r){return u.IsGreaterEqualThan(r.length,n.minItems)}function OR(e,t,n,r,i,o){return Xh(e,t,i,o)||t.AddError("minItems",n,r,{limit:i.minItems})}function FR(e,t,n,r){return y.IsMinLength(r,y.Constant(n.minLength))}function Yh(e,t,n,r){return u.IsMinLength(r,n.minLength)}function NR(e,t,n,r,i,o){return Yh(e,t,i,o)||t.AddError("minLength",n,r,{limit:i.minLength})}function DR(e,t,n,r){return y.IsGreaterEqualThan(y.Member(y.Keys(r),"length"),y.Constant(n.minProperties))}function Jh(e,t,n,r){return u.IsGreaterEqualThan(u.Keys(r).length,n.minProperties)}function HR(e,t,n,r,i,o){return Jh(e,t,i,o)||t.AddError("minProperties",n,r,{limit:i.minProperties})}function _R(e,t,n,r){return y.MultipleOf(r,y.Constant(n.multipleOf))}function Zh(e,t,n,r){return u.IsMultipleOf(r,n.multipleOf)}function UR(e,t,n,r,i,o){return Zh(e,t,i,o)||t.AddError("multipleOf",n,r,{multipleOf:i.multipleOf})}function p8(e,t,n,r){return Ni(e,t,[n.not],r,y.Not(y.IsEqual(y.Member("results","length"),y.Constant(1))))}function h8(e,t,n,r){return y.Not(he(e,t,n.not,r))}function BR(e,t,n,r){return t.UseUnevaluated()?p8(e,t,n,r):h8(e,t,n,r)}function Qh(e,t,n,r){let i=new Ht;return!ce(e,i,n.not,r)&&t.Merge([i])}function GR(e,t,n,r,i,o){return Qh(e,t,i,o)||t.AddError("not",n,r,{})}function g8(e,t,n,r){return Ni(e,t,n.oneOf,r,y.IsEqual(y.Member("results","length"),y.Constant(1)))}function y8(e,t,n,r){let[i]=[Ce()],o=y.ArrayLiteral(n.oneOf.map((a)=>he(e,t,a,r))),s=y.Counted(o,[i,"_"],y.IsEqual(i,y.Constant(!0)));return y.IsEqual(s,y.Constant(1))}function jR(e,t,n,r){return t.UseUnevaluated()?g8(e,t,n,r):y8(e,t,n,r)}function qR(e,t,n,r){let i=n.oneOf.reduce((o,s)=>{let a=new Ht;return ce(e,a,s,r)?[...o,a]:o},[]);return u.IsEqual(i.length,1)&&t.Merge(i)}function zR(e,t,n,r,i,o){let s=[],a=[],l=i.oneOf.reduce((c,m,p)=>{let h=new _t,x=`${n}/oneOf/${p}`,I=Re(e,h,x,r,m,o);if(I)a.push(p);if(!I)s.push(h);return I?[...c,h]:c},[]),d=u.IsEqual(l.length,1)&&t.Merge(l);if(!d&&u.IsEqual(a.length,0))s.forEach((c)=>t.AddErrors(c.GetErrors()));return d||t.AddError("oneOf",n,r,{passingSchemas:a})}function KR(e,t,n,r){let i=Hn(u.IsString(n.pattern)?nr(n.pattern):n.pattern);return y.Call(y.Member(i,"test"),[r])}function eg(e,t,n,r){return(u.IsString(n.pattern)?nr(n.pattern):n.pattern).test(r)}function VR(e,t,n,r,i,o){return eg(e,t,i,o)||t.AddError("pattern",n,r,{pattern:i.pattern})}function WR(e,t,n,r){return y.ReduceAnd(u.Entries(n.patternProperties).map(([i,o])=>{let[s,a]=[Ce(),Ce()],l=Hn(nr(i)),d=y.Not(y.Call(y.Member(l,"test"),[s])),c=Jt(e,t,o,a),m=t.AddKey(s),p=t.UseUnevaluated()?y.Or(d,y.And(c,m)):y.Or(d,c);return y.Every(y.Entries(r),y.Constant(0),[`[${s}, ${a}]`,"_"],p)}))}function XR(e,t,n,r){return u.Every(u.Entries(n.patternProperties),0,([i,o])=>{let s=nr(i);return u.Every(u.Entries(r),0,([a,l])=>!s.test(a)||wn(e,t,o,l)&&t.AddKey(a))})}function YR(e,t,n,r,i,o){return u.EveryAll(u.Entries(i.patternProperties),0,([s,a])=>{let l=`${n}/patternProperties/${s}`,d=nr(s);return u.EveryAll(u.Entries(o),0,([c,m])=>{let p=`${r}/${c}`;return!d.test(c)||Ln(e,t,l,p,a,m)&&t.AddKey(c)})})}function JR(e,t,n,r){return y.ReduceAnd(n.prefixItems.map((i,o)=>{let s=y.IsLessEqualThan(y.Member(r,"length"),y.Constant(o)),a=Jt(e,t,i,`${r}[${o}]`),l=t.AddIndex(y.Constant(o)),d=t.UseUnevaluated()?y.And(a,l):a;return y.Or(s,d)}))}function ZR(e,t,n,r){return u.IsEqual(r.length,0)||u.Every(n.prefixItems,0,(i,o)=>u.IsLessEqualThan(r.length,o)||wn(e,t,i,r[o])&&t.AddIndex(o))}function QR(e,t,n,r,i,o){return u.IsEqual(o.length,0)||u.EveryAll(i.prefixItems,0,(s,a)=>{let l=`${n}/prefixItems/${a}`,d=`${r}/${a}`;return u.IsLessEqualThan(o.length,a)||Ln(e,t,l,d,s,o[a])&&t.AddIndex(a)})}function xm(e,t){return e.includes(t)||He.Get().exactOptionalPropertyTypes}function eA(e,t){return y.IsUndefined(y.Member(e,t))}function tg(e,t){return u.IsUndefined(e[t])}function tA(e,t,n,r){let i=tr(n)?n.required:[],o=u.Entries(n.properties).map(([s,a])=>{let l=y.Not(y.HasPropertyKey(r,y.Constant(s))),d=Jt(e,t,a,y.Member(r,s)),c=t.AddKey(y.Constant(s)),m=t.UseUnevaluated()?y.And(d,c):d,p=i.includes(s)?m:y.Or(l,m);return xm(i,s)?p:y.Or(eA(r,s),p)});return y.ReduceAnd(o)}function nA(e,t,n,r){let i=tr(n)?n.required:[];return u.Every(u.Entries(n.properties),0,([s,a])=>{let l=!u.HasPropertyKey(r,s)||wn(e,t,a,r[s])&&t.AddKey(s);return xm(i,s)?l:tg(r,s)||l})}function rA(e,t,n,r,i,o){let s=tr(i)?i.required:[];return u.EveryAll(u.Entries(i.properties),0,([l,d])=>{let c=`${n}/properties/${l}`,m=`${r}/${l}`,p=()=>!u.HasPropertyKey(o,l)||Ln(e,t,c,m,d,o[l])&&t.AddKey(l);return xm(s,l)?p():tg(o,l)||p()})}function iA(e,t,n,r){let[i,o]=[Ce(),Ce()];return y.Every(y.Keys(r),y.Constant(0),[i,o],he(e,t,n.propertyNames,i))}function oA(e,t,n,r){return u.Every(u.Keys(r),0,(i,o)=>ce(e,t,n.propertyNames,i))}function sA(e,t,n,r,i,o){let s=[];return u.EveryAll(u.Keys(o),0,(l,d)=>{let c=`${r}/${l}`,m=`${n}/propertyNames`,p=Re(e,t,m,c,i.propertyNames,l);if(!p)s.push(l);return p})||t.AddError("propertyNames",n,r,{propertyNames:s})}function aA(e,t,n,r){let i=on.RecursiveRef(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Yr(o,t,i,r)}function lA(e,t,n,r){let i=on.RecursiveRef(e,n)??!1,o=i?{...e,pendingResource:!0}:e;return Y(i)&&ce(o,t,i,r)}function uA(e,t,n,r,i,o){let s=on.RecursiveRef(e,i)??!1,a=s?{...e,pendingResource:!0}:e;return Y(s)&&Re(a,t,"#",r,s,o)}function x8(e,t,n,r){let i=y.ArrowFunction(["context","value"],Yr(e,t,n,"value")),o=y.ArrowFunction(["context","value"],y.Statements([y.ConstDeclaration("nextContext",y.New("CheckContext",[])),y.ConstDeclaration("result",y.Call(i,["nextContext","value"])),y.If("result",t.Merge("[nextContext]")),y.Return("result")]));return y.Call(o,["context",r])}function I8(e,t,n,r){return Yr(e,t,n,r)}function dA(e,t,n,r){let i=on.Ref(e,n),o=i.schema??!1;return t.UseUnevaluated()?x8(i.stack,t,o,r):I8(i.stack,t,o,r)}function cA(e,t,n,r){let i=on.Ref(e,n),o=i.schema??!1,s=new Ht,a=Y(o)&&ce(i.stack,s,o,r);if(a)t.Merge([s]);return a}function mA(e,t,n,r,i,o){let s=on.Ref(e,i),a=s.schema??!1,l=new _t,d=Y(a)&&Re(s.stack,l,"#",r,a,o);if(d)t.Merge([l]);if(!d)t.AddErrors(l.GetErrors());return d}function fA(e,t,n,r){return y.ReduceAnd(n.required.map((i)=>y.HasPropertyKey(r,y.Constant(i))))}function pA(e,t,n,r){return u.Every(n.required,0,(i)=>u.HasPropertyKey(r,i))}function hA(e,t,n,r,i,o){let s=[];return u.EveryAll(i.required,0,(l)=>{let d=u.HasPropertyKey(o,l);if(!d)s.push(l);return d})||t.AddError("required",n,r,{requiredProperties:s})}function gA(e,t,n,r){return u.IsEqual(n,"object")?y.IsObjectNotArray(r):u.IsEqual(n,"array")?y.IsArray(r):u.IsEqual(n,"boolean")?y.IsBoolean(r):u.IsEqual(n,"integer")?y.IsInteger(r):u.IsEqual(n,"number")?y.IsNumber(r):u.IsEqual(n,"null")?y.IsNull(r):u.IsEqual(n,"string")?y.IsString(r):u.IsEqual(n,"bigint")?y.IsBigInt(r):u.IsEqual(n,"constructor")?y.IsConstructor(r):u.IsEqual(n,"function")?y.IsFunction(r):u.IsEqual(n,"symbol")?y.IsSymbol(r):u.IsEqual(n,"undefined")?y.IsUndefined(r):u.IsEqual(n,"void")?y.IsUndefined(r):y.Constant(!0)}function ng(e,t,n,r,i){return u.IsEqual(n,"object")?u.IsObjectNotArray(i):u.IsEqual(n,"array")?u.IsArray(i):u.IsEqual(n,"boolean")?u.IsBoolean(i):u.IsEqual(n,"integer")?u.IsInteger(i):u.IsEqual(n,"number")?u.IsNumber(i):u.IsEqual(n,"null")?u.IsNull(i):u.IsEqual(n,"string")?u.IsString(i):u.IsEqual(n,"bigint")?u.IsBigInt(i):u.IsEqual(n,"constructor")?u.IsConstructor(i):u.IsEqual(n,"function")?u.IsFunction(i):u.IsEqual(n,"symbol")?u.IsSymbol(i):u.IsEqual(n,"undefined")?u.IsUndefined(i):u.IsEqual(n,"void")?u.IsUndefined(i):!0}function S8(e,t,n,r){return y.ReduceOr(n.map((i)=>gA(e,t,i,r)))}function yA(e,t,n,r,i){return u.Some(n,(o)=>ng(e,t,o,r,i))}function xA(e,t,n,r){return u.IsArray(n.type)?S8(e,t,n.type,r):gA(e,t,n.type,r)}function IA(e,t,n,r){return u.IsArray(n.type)?yA(e,t,n.type,n,r):ng(e,t,n.type,n,r)}function SA(e,t,n,r,i,o){return(u.IsArray(i.type)?yA(e,t,i.type,i,o):ng(e,t,i.type,i,o))||t.AddError("type",n,r,{type:i.type})}function bA(e,t,n,r){let[i,o]=[Ce(),Ce()],s=y.Call(y.Member("context","GetIndices"),[]),a=y.Call(y.Member("indices","has"),[i]),l=he(e,t,n.unevaluatedItems,o),d=y.Call(y.Member("context","AddIndex"),[i]),c=y.Every(r,y.Constant(0),[o,i],y.And(y.Or(a,l),d));return y.Call(y.ArrowFunction(["context"],y.Statements([y.ConstDeclaration("indices",s),y.Return(c)])),["context"])}function CA(e,t,n,r){let i=t.GetIndices();return u.Every(r,0,(o,s)=>(i.has(s)||ce(e,t,n.unevaluatedItems,o))&&t.AddIndex(s))}function EA(e,t,n,r,i,o){let s=t.GetIndices(),a=[];return u.EveryAll(o,0,(d,c)=>{let m=new _t,p=(s.has(c)||Re(e,m,n,r,i.unevaluatedItems,d))&&t.AddIndex(c);if(!p)a.push(c);return p})||t.AddError("unevaluatedItems",n,r,{unevaluatedItems:a})}function vA(e,t,n,r){let[i,o]=[Ce(),Ce()],s=y.Call(y.Member("context","GetKeys"),[]),a=y.Call(y.Member("keys","has"),[i]),l=y.Call(y.Member("context","AddKey"),[i]),d=he(e,t,n.unevaluatedProperties,o),c=y.Every(y.Entries(r),y.Constant(0),[`[${i}, ${o}]`,"_"],y.Or(a,y.And(d,l)));return y.Call(y.ArrowFunction(["context"],y.Statements([y.ConstDeclaration("keys",s),y.Return(c)])),["context"])}function kA(e,t,n,r){let i=t.GetKeys();return u.Every(u.Entries(r),0,([o,s])=>i.has(o)||ce(e,t,n.unevaluatedProperties,s)&&t.AddKey(o))}function TA(e,t,n,r,i,o){let s=t.GetKeys(),a=[];return u.EveryAll(u.Entries(o),0,([d,c])=>{let m=new _t,p=s.has(d)||Re(e,m,n,r,i.unevaluatedProperties,c)&&t.AddKey(d);if(!p)a.push(d);return p})||t.AddError("unevaluatedProperties",n,r,{unevaluatedProperties:a})}function rg(e){return!u.IsEqual(e.uniqueItems,!1)}function wA(e,t,n,r){if(!rg(n))return y.Constant(!0);let i=y.Member(y.New("Set",[y.Call(y.Member(r,"map"),[y.Member("Hashing","Hash")])]),"size"),o=y.Member(r,"length");return y.IsEqual(i,o)}function LA(e,t,n,r){if(!rg(n))return!0;let i=new Set(r.map(Gr.Hash)).size,o=r.length;return u.IsEqual(i,o)}function RA(e,t,n,r,i,o){if(!rg(i))return!0;let s=new Set,a=o.reduce((d,c,m)=>{let p=Gr.Hash(c);if(s.has(p))return[...d,m];return s.add(p),d},[]);return u.IsEqual(a.length,0)||t.AddError("uniqueItems",n,r,{duplicateItems:a})}function Al(e,t){return El(e)&&(u.IsArray(e.type)&&u.IsGreaterThan(e.type.length,0)&&u.Every(e.type,0,(n)=>u.IsEqual(n,t))||u.IsEqual(e.type,t))}function b8(e){return Al(e,"object")}function C8(e){return Rt(e)&&(Dn(e)||ol(e)||sl(e)||Ps(e)||Wr(e)||Vr(e)||Ms(e)||bo(e)||hl(e)||tr(e)||Oi(e))}function E8(e){return Al(e,"array")}function v8(e){return Rt(e)&&(As(e)||zr(e)||Cr(e)||fl(e)||$s(e)||Kr(e)||Pi(e)||er(e)||Mi(e)||$i(e))}function k8(e){return Al(e,"string")}function T8(e){return Rt(e)&&(So(e)||pl(e)||Io(e)||Co(e))}function w8(e){return Al(e,"number")||Al(e,"bigint")}function L8(e){return Rt(e)&&(Qn(e)||ml(e)||ul(e)||Zn(e)||gl(e))}function Jt(e,t,n,r){return t.UseUnevaluated()?y.And(y.And(t.Push(),he(e,t,n,r)),t.Pop()):he(e,t,n,r)}function he(e,t,n,r){let i=Eo(e,n),o=[];if(Ri(n))return tL(i,t,n,r);if(El(n))o.push(xA(i,t,n,r));if(C8(n)){let a=[];if(tr(n))a.push(fA(i,t,n,r));if(Dn(n))a.push(Kw(i,t,n,r));if(ol(n))a.push(lL(i,t,n,r));if(sl(n))a.push(cL(i,t,n,r));if(Ps(n))a.push(pL(i,t,n,r));if(Vr(n))a.push(WR(i,t,n,r));if(Wr(n))a.push(tA(i,t,n,r));if(Ms(n))a.push(iA(i,t,n,r));if(bo(n))a.push(DR(i,t,n,r));if(hl(n))a.push(TR(i,t,n,r));let l=y.ReduceAnd(a),d=y.Or(y.Not(y.IsObjectNotArray(r)),l);o.push(b8(n)?l:d)}if(v8(n)){let a=[];if(As(n))a.push(jw(i,t,n,r));if(Cr(n))a.push(sL(i,t,n,r));if(zr(n))a.push(pR(i,t,n,r));if(fl(n))a.push(xR(i,t,n,r));if($s(n))a.push(CR(i,t,n,r));if(Kr(n))a.push(RR(i,t,n,r));if(Pi(n))a.push(MR(i,t,n,r));if(er(n))a.push(JR(i,t,n,r));if($i(n))a.push(wA(i,t,n,r));let l=y.ReduceAnd(a),d=y.Or(y.Not(y.IsArray(r)),l);o.push(E8(n)?l:d)}if(T8(n)){let a=[];if(pl(n))a.push(vR(i,t,n,r));if(So(n))a.push(FR(i,t,n,r));if(Io(n))a.push(uR(i,t,n,r));if(Co(n))a.push(KR(i,t,n,r));let l=y.ReduceAnd(a),d=y.Or(y.Not(y.IsString(r)),l);o.push(k8(n)?l:d)}if(L8(n)){let a=[];if(ul(n))a.push(PL(i,t,n,r));if(Zn(n))a.push(ML(i,t,n,r));if(ml(n))a.push(SR(i,t,n,r));if(Qn(n))a.push(PR(i,t,n,r));if(gl(n))a.push(_R(i,t,n,r));let l=y.ReduceAnd(a),d=y.Or(y.Not(y.Or(y.IsNumber(r),y.IsBigInt(r))),l);o.push(w8(n)?l:d)}if(bl(n))o.push(dA(i,t,n,r));if(Sl(n))o.push(aA(i,t,n,r));if(al(n))o.push(TL(i,t,n,r));if(Uc(n))o.push(rL(i,t,n,r));if(Bc(n))o.push(RL(i,t,n,r));if(dl(n))o.push(cR(i,t,n,r));if(yl(n))o.push(BR(i,t,n,r));if(rl(n))o.push(Xw(i,t,n,r));if(il(n))o.push(Zw(i,t,n,r));if(xl(n))o.push(jR(i,t,n,r));if(Mi(n))o.push(y.Or(y.Not(y.IsArray(r)),bA(i,t,n,r)));if(Oi(n))o.push(y.Or(y.Not(y.IsObject(r)),vA(i,t,n,r)));if(nl(n))o.push(Nw(i,t,n,r));return y.ReduceAnd(o)}function wn(e,t,n,r){return t.Push()&&ce(e,t,n,r)&&t.Pop()}function ce(e,t,n,r){let i=Eo(e,n);return Ri(n)?vh(i,t,n,r):(!El(n)||IA(i,t,n,r))&&(!(u.IsObject(r)&&!u.IsArray(r))||(!tr(n)||pA(i,t,n,r))&&(!Dn(n)||Vw(i,t,n,r))&&(!ol(n)||uL(i,t,n,r))&&(!sl(n)||mL(i,t,n,r))&&(!Ps(n)||hL(i,t,n,r))&&(!Vr(n)||XR(i,t,n,r))&&(!Wr(n)||nA(i,t,n,r))&&(!Ms(n)||oA(i,t,n,r))&&(!bo(n)||Jh(i,t,n,r))&&(!hl(n)||Kh(i,t,n,r)))&&(!u.IsArray(r)||(!As(n)||qw(i,t,n,r))&&(!Cr(n)||Th(i,t,n,r))&&(!zr(n)||hR(i,t,n,r))&&(!fl(n)||Gh(i,t,n,r))&&(!$s(n)||qh(i,t,n,r))&&(!Kr(n)||Vh(i,t,n,r))&&(!Pi(n)||Xh(i,t,n,r))&&(!er(n)||ZR(i,t,n,r))&&(!$i(n)||LA(i,t,n,r)))&&(!u.IsString(r)||(!pl(n)||zh(i,t,n,r))&&(!So(n)||Yh(i,t,n,r))&&(!Io(n)||Bh(i,t,n,r))&&(!Co(n)||eg(i,t,n,r)))&&(!(u.IsNumber(r)||u.IsBigInt(r))||(!ul(n)||Oh(i,t,n,r))&&(!Zn(n)||Fh(i,t,n,r))&&(!ml(n)||jh(i,t,n,r))&&(!Qn(n)||Wh(i,t,n,r))&&(!gl(n)||Zh(i,t,n,r)))&&(!bl(n)||cA(i,t,n,r))&&(!Sl(n)||lA(i,t,n,r))&&(!al(n)||wL(i,t,n,r))&&(!Uc(n)||kh(i,t,n,r))&&(!Bc(n)||Mh(i,t,n,r))&&(!dl(n)||mR(i,t,n,r))&&(!yl(n)||Qh(i,t,n,r))&&(!rl(n)||Yw(i,t,n,r))&&(!il(n)||Qw(i,t,n,r))&&(!xl(n)||qR(i,t,n,r))&&(!Mi(n)||(!u.IsArray(r)||CA(i,t,n,r)))&&(!Oi(n)||(!u.IsObject(r)||kA(i,t,n,r)))&&(!nl(n)||Dw(i,t,n,r))}function Ln(e,t,n,r,i,o){return t.Push()&&Re(e,t,n,r,i,o)&&t.Pop()}function Re(e,t,n,r,i,o){if(t.AtCapacity())return!1;let s=Eo(e,i);return Ri(i)?nL(s,t,n,r,i,o):!!(+(!El(i)||SA(s,t,n,r,i,o))&+(!(u.IsObject(o)&&!u.IsArray(o))||!!(+(!tr(i)||hA(s,t,n,r,i,o))&+(!Dn(i)||Ww(s,t,n,r,i,o))&+(!ol(i)||dL(s,t,n,r,i,o))&+(!sl(i)||fL(s,t,n,r,i,o))&+(!Ps(i)||gL(s,t,n,r,i,o))&+(!Vr(i)||YR(s,t,n,r,i,o))&+(!Wr(i)||rA(s,t,n,r,i,o))&+(!Ms(i)||sA(s,t,n,r,i,o))&+(!bo(i)||HR(s,t,n,r,i,o))&+(!hl(i)||wR(s,t,n,r,i,o))))&+(!u.IsArray(o)||!!(+(!As(i)||zw(s,t,n,r,i,o))&+(!Cr(i)||aL(s,t,n,r,i,o))&+(!zr(i)||gR(s,t,n,r,i,o))&+(!fl(i)||IR(s,t,n,r,i,o))&+(!$s(i)||ER(s,t,n,r,i,o))&+(!Kr(i)||AR(s,t,n,r,i,o))&+(!Pi(i)||OR(s,t,n,r,i,o))&+(!er(i)||QR(s,t,n,r,i,o))&+(!$i(i)||RA(s,t,n,r,i,o))))&+(!u.IsString(o)||!!(+(!pl(i)||kR(s,t,n,r,i,o))&+(!So(i)||NR(s,t,n,r,i,o))&+(!Io(i)||dR(s,t,n,r,i,o))&+(!Co(i)||VR(s,t,n,r,i,o))))&+(!(u.IsNumber(o)||u.IsBigInt(o))||!!(+(!ul(i)||$L(s,t,n,r,i,o))&+(!Zn(i)||OL(s,t,n,r,i,o))&+(!ml(i)||bR(s,t,n,r,i,o))&+(!Qn(i)||$R(s,t,n,r,i,o))&+(!gl(i)||UR(s,t,n,r,i,o))))&+(!bl(i)||mA(s,t,n,r,i,o))&+(!Sl(i)||uA(s,t,n,r,i,o))&+(!al(i)||LL(s,t,n,r,i,o))&+(!Uc(i)||iL(s,t,n,r,i,o))&+(!Bc(i)||AL(s,t,n,r,i,o))&+(!dl(i)||fR(s,t,n,r,i,o))&+(!yl(i)||GR(s,t,n,r,i,o))&+(!rl(i)||Jw(s,t,n,r,i,o))&+(!il(i)||eL(s,t,n,r,i,o))&+(!xl(i)||zR(s,t,n,r,i,o))&+(!Mi(i)||(!u.IsArray(o)||EA(s,t,n,r,i,o)))&+(!Oi(i)||(!u.IsObject(o)||TA(s,t,n,r,i,o))))&&(!nl(i)||Hw(s,t,n,r,i,o))}var AA=[0],Im=new Map,Pl=new Map;function R8(){return`${AA[0]++}`}function A8(e,t){if(!Im.has(e))Im.set(e,new Map);let n=Im.get(e);if(n.has(t))return n.get(t);let r=R8();return n.set(t,r),r}function P8(e,t,n,r){return e.UseUnevaluated()?y.Call(`check_${n}`,["context",r]):y.Call(`check_${n}`,[r])}function $8(e,t,n,r){let i=he(e,t,n,"value");return t.UseUnevaluated()?y.ConstDeclaration(`check_${r}`,y.ArrowFunction(["context","value"],i)):y.ConstDeclaration(`check_${r}`,y.ArrowFunction(["value"],i))}function PA(){AA[0]=0,Im.clear(),Pl.clear()}function $A(){return[...Pl.values()]}function Yr(e,t,n,r){let i=A8(n,e.lexicalBase),o=P8(t,n,i,r);if(Pl.has(i))return o;return Pl.set(i,""),Pl.set(i,$8(e,t,n,i)),o}function M8(e){let t=e.Functions().join(`;
|
|
1531
|
+
`),n=e.UseUnevaluated()?["const context = new CheckContext({}, {})",`return ${e.Entry()}`]:[`return ${e.Entry()}`];return`${t}; return (value) => { ${n.join("; ")} }`}function O8(e,t){return ds.Evaluate("CheckContext","Guard","Format","Hashing",e.External().identifier,t)(Ht,u,vo,Gr,e.External().variables)}function F8(e){let t=Fi(e.Context(),e.Schema()),n=new Ht;return(r)=>ce(t,n,e.Schema(),r)}function N8(e,t){return ds.CanEvaluate()?O8(e,t):F8(e)}class MA{constructor(e,t,n){this.isAccelerated=e,this.code=t,this.check=n}IsAccelerated(){return this.isAccelerated}Code(){return this.code}Check(e){return this.check(e)}}class OA{constructor(e,t,n,r,i,o){this.context=e,this.schema=t,this.external=n,this.functions=r,this.entry=i,this.useUnevaluated=o}Context(){return this.context}Schema(){return this.schema}UseUnevaluated(){return this.useUnevaluated}External(){return this.external}Functions(){return this.functions}Entry(){return this.entry}Evaluate(){let e=M8(this),t=N8(this,e);return new MA(ds.CanEvaluate(),e,t)}}function Sm(...e){let[t,n]=ee.Match(e,{2:(l,d)=>[l,d],1:(l)=>[{},l]});Ow(),PA();let r=Fi(t,n),i=new Ih(Mw(t,n)),o=Yr(r,i,n,"value"),s=$A(),a=Fw();return new OA(t,n,a,s,o,i.UseUnevaluated())}function bm(...e){let[t,n,r]=ee.Match(e,{3:(c,m,p)=>[c,m,p],2:(c,m)=>[{},c,m]}),i=Fi(t,n),o=new _t,s=Re(i,o,"#","",n,r),a=o.GetErrors(),l=Sb(),d=a.map((c)=>({...c,message:l(c)}));return[s,d]}function og(...e){let[t,n,r]=ee.Match(e,{3:(s,a,l)=>[s,a,l],2:(s,a)=>[{},s,a]}),i=Fi(t,n),o=new Ht;return ce(i,o,n,r)}function ve(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[{},i,o]});return og(t,n,r)}function ir(...e){let[t,n,r]=ee.Match(e,{3:(s,a,l)=>[s,a,l],2:(s,a)=>[{},s,a]}),[i,o]=bm(t,n,r);return o}class ko extends Error{constructor(e,t,n){super(e);Object.defineProperty(this,"cause",{value:{source:e,errors:n,value:t},writable:!1,configurable:!1,enumerable:!1})}}function FA(e,t,n){if(!u.IsArray(n))return n;return n.map((r)=>bt(e,t.items,r))}function NA(e,t,n){return bt({...e,...t.$defs},pt(t.$ref),n)}function _8(e,t){let n=u.HasPropertyKey(t,"unevaluatedProperties")?{additionalProperties:t.unevaluatedProperties}:{},r=Nn(e,t),i=$t(r);return V(i)?Dc(i,n):i}function DA(e,t,n){let r=_8(e,t);return bt(e,r,n)}function Cm(e){return u.HasPropertyKey(e,"additionalProperties")?e.additionalProperties:void 0}function HA(e,t,n){if(!u.IsObject(n)||u.IsArray(n))return n;let r=Cm(t);for(let i of u.Keys(n)){if(u.HasPropertyKey(t.properties,i)){n[i]=bt(e,t.properties[i],n[i]);continue}if(u.IsBoolean(r)&&u.IsEqual(r,!0)||Ge(r)&&ve(e,r,n[i])){n[i]=bt(e,r,n[i]);continue}delete n[i]}return n}function _A(e,t,n){if(!u.IsObject(n))return n;let r=Cm(t),[i,o]=[new RegExp(St(t)),Ae(t)];for(let s of u.Keys(n)){if(i.test(s)){n[s]=bt(e,o,n[s]);continue}if(u.IsBoolean(r)&&u.IsEqual(r,!0)||Ge(r)&&ve(e,r,n[s])){n[s]=bt(e,r,n[s]);continue}delete n[s]}return n}function UA(e,t,n){return u.HasPropertyKey(e,t.$ref)?bt(e,e[t.$ref],n):n}function BA(e,t,n){if(!u.IsArray(n))return n;let r=Math.min(n.length,t.items.length);for(let i=0;i<r;i++)n[i]=bt(e,t.items[i],n[i]);return u.IsGreaterThan(n.length,r)?n.slice(0,r):n}function Ye(e){return oo(e)}function GA(e,t,n){for(let r of t.anyOf){let i=bt(e,r,Ye(n));if(ve(e,r,i))return i}return n}function bt(e,t,n){return le(t)?FA(e,t,n):Te(t)?NA(e,t,n):z(t)?DA(e,t,n):V(t)?HA(e,t,n):Se(t)?_A(e,t,n):xe(t)?UA(e,t,n):re(t)?BA(e,t,n):F(t)?GA(e,t,n):n}function U8(e,t){for(let n of Ad.Keys(e)){if(Ad.HasPropertyKey(t,n))continue;t[n]=e[n]}return t}function B8(e){let t={};for(let n of Ad.Keys(e))t[n]=$l(e[n]);return t}function G8(e){return sg(Aw(e))}function sg(e){return e.map((t)=>$l(t))}function $l(e){let t=le(e)?tn($l(e.items),as(e)):z(e)?Ft(sg(e.allOf)):F(e)?J(G8(e.anyOf)):V(e)?q(B8(e.properties)):Se(e)?ys(Ei(e),$l(Ae(e))):re(e)?We(sg(e.items)):e;return U8(e,t)}function _s(e){return $l(e)}function _n(...e){let[t,n,r]=ee.Match(e,{3:(o,s,a)=>[o,s,a],2:(o,s)=>[{},o,s]}),i=He.Get().unionPrioritySort?_s(n):n;return bt(t,i,r)}var fe={};Bt(fe,{Fail:()=>$e,IsOk:()=>ag,Ok:()=>G,TryArray:()=>j8,TryBigInt:()=>lg,TryBoolean:()=>t5,TryNull:()=>s5,TryNumber:()=>d5,TryString:()=>c5,TryUndefined:()=>g5});function ag(e){return u.IsObject(e)&&u.HasPropertyKey(e,"value")}function G(e){return{value:e}}function $e(){return}function j8(e){return u.IsArray(e)?G(e):G([e])}function q8(e){return u.IsEqual(e,!0)?G(BigInt(1)):G(BigInt(0))}var z8=/^-?(0|[1-9]\d*)n$/,K8=/^-?(0|[1-9]\d*)\.\d+$/,V8=/^-?(0|[1-9]\d*)$/;function W8(e){return z8.test(e)}function X8(e){return K8.test(e)}function Y8(e){return V8.test(e)}function J8(e){let t=e.toLowerCase();return W8(e)?G(BigInt(e.slice(0,e.length-1))):X8(e)?G(BigInt(e.split(".")[0])):Y8(e)?G(BigInt(e)):u.IsEqual(t,"false")?G(BigInt(0)):u.IsEqual(t,"true")?G(BigInt(1)):$e()}function lg(e){return u.IsBigInt(e)?G(e):u.IsBoolean(e)?q8(e):u.IsNumber(e)?G(BigInt(Math.trunc(e))):u.IsNull(e)?G(BigInt(0)):u.IsString(e)?J8(e):u.IsUndefined(e)?G(BigInt(0)):$e()}function Z8(e){return u.IsEqual(e,BigInt(0))?G(!1):u.IsEqual(e,BigInt(1))?G(!0):$e()}function Q8(e){return u.IsEqual(e,0)?G(!1):u.IsEqual(e,1)?G(!0):$e()}function e5(e){return u.IsEqual(e.toLowerCase(),"false")?G(!1):u.IsEqual(e.toLowerCase(),"true")?G(!0):u.IsEqual(e,"0")?G(!1):u.IsEqual(e,"1")?G(!0):$e()}function t5(e){return u.IsBigInt(e)?Z8(e):u.IsBoolean(e)?G(e):u.IsNumber(e)?Q8(e):u.IsNull(e)?G(!1):u.IsString(e)?e5(e):u.IsUndefined(e)?G(!1):$e()}function n5(e){return u.IsEqual(e,BigInt(0))?G(null):$e()}function r5(e){return u.IsEqual(e,!1)?G(null):$e()}function i5(e){return u.IsEqual(e,0)?G(null):$e()}function o5(e){let t=e.toLowerCase();return u.IsEqual(t,"undefined")||u.IsEqual(t,"null")||u.IsEqual(e,"")||u.IsEqual(e,"0")?G(null):$e()}function s5(e){return u.IsBigInt(e)?n5(e):u.IsBoolean(e)?r5(e):u.IsNumber(e)?i5(e):u.IsNull(e)?G(null):u.IsString(e)?o5(e):u.IsUndefined(e)?G(null):$e()}var jA=BigInt(Number.MAX_SAFE_INTEGER),qA=BigInt(Number.MIN_SAFE_INTEGER);function a5(e){return e<=jA&&e>=qA?G(Number(e)):$e()}function l5(e){return G(e?1:0)}function u5(e){let t=+e;if(u.IsNumber(t))return G(t);let n=e.toLowerCase();if(u.IsEqual(n,"false"))return G(0);if(u.IsEqual(n,"true"))return G(1);let r=lg(e);if(ag(r))return r.value<=jA&&r.value>=qA?G(Number(r.value)):$e();return $e()}function d5(e){return u.IsBigInt(e)?a5(e):u.IsBoolean(e)?l5(e):u.IsNumber(e)?G(e):u.IsNull(e)?G(0):u.IsString(e)?u5(e):u.IsUndefined(e)?G(0):$e()}function c5(e){return u.IsBigInt(e)?G(e.toString()):u.IsBoolean(e)?G(e.toString()):u.IsNumber(e)?G(e.toString()):u.IsNull(e)?G("null"):u.IsString(e)?G(e):u.IsUndefined(e)?G(""):$e()}function m5(e){return u.IsEqual(e,BigInt(0))?G(void 0):$e()}function f5(e){return u.IsEqual(e,!1)?G(void 0):$e()}function p5(e){return u.IsEqual(e,0)?G(void 0):$e()}function h5(e){let t=e.toLowerCase();return u.IsEqual(t,"undefined")||u.IsEqual(t,"null")||u.IsEqual(e,"")||u.IsEqual(e,"0")?G(void 0):$e()}function g5(e){return u.IsBigInt(e)?m5(e):u.IsBoolean(e)?f5(e):u.IsNumber(e)?p5(e):u.IsNull(e)?G(void 0):u.IsString(e)?h5(e):u.IsUndefined(e)?G(e):$e()}function zA(e,t,n){return fe.TryArray(n).value.map((i)=>Je(e,t.items,i))}function KA(e,t,n){let r=fe.TryBigInt(n);return fe.IsOk(r)?r.value:n}function VA(e,t,n){let r=fe.TryBoolean(n);return fe.IsOk(r)?r.value:n}function WA(e,t,n){return Je({...e,...t.$defs},pt(t.$ref),n)}function XA(e,t,n){return Je(e,$t(t),n)}function YA(e,t,n){let r=fe.TryNumber(n);return fe.IsOk(r)?Math.trunc(r.value):n}function JA(e,t,n){let r=Nn(e,t),i=$t(r);return Je(e,i,n)}function y5(e,t,n){let r=fe.TryBigInt(n);return fe.IsOk(r)&&u.IsEqual(t.const,r.value)?r.value:n}function x5(e,t,n){let r=fe.TryBoolean(n);return fe.IsOk(r)&&u.IsEqual(t.const,r.value)?r.value:n}function I5(e,t,n){let r=fe.TryNumber(n);return fe.IsOk(r)&&u.IsEqual(t.const,r.value)?r.value:n}function S5(e,t,n){let r=fe.TryString(n);return fe.IsOk(r)&&u.IsEqual(t.const,r.value)?r.value:n}function ZA(e,t,n){if(u.IsEqual(t.const,n))return n;return Ab(t)?y5(e,t,n):Pb(t)?x5(e,t,n):Bd(t)?I5(e,t,n):Gd(t)?S5(e,t,n):Ve()}function QA(e,t,n){let r=fe.TryNull(n);return fe.IsOk(r)?r.value:n}function e1(e,t,n){let r=fe.TryNumber(n);return fe.IsOk(r)?r.value:n}function Em(e,t,n,r){let i=u.Keys(r);for(let[o,s]of t)for(let a of i)if(!o.test(a))r[a]=Je(e,n,r[a]);return r}function Ml(e,t,n){return ht(e)&&u.IsUndefined(n[t])}function b5(e,t,n){let r=u.EntriesRegExp(t.properties),i=u.Keys(n);for(let[o,s]of r)for(let a of i){if(!o.test(a)||Ml(s,a,n))continue;n[a]=Je(e,s,n[a])}return u.HasPropertyKey(t,"additionalProperties")&&u.IsObject(t.additionalProperties)?Em(e,r,t.additionalProperties,n):n}function t1(e,t,n){return u.IsObjectNotArray(n)?b5(e,t,n):n}function C5(e,t,n){let r=u.EntriesRegExp(t.patternProperties),i=u.Keys(n);for(let[o,s]of r)for(let a of i)if(o.test(a))n[a]=Je(e,s,n[a]);return u.HasPropertyKey(t,"additionalProperties")&&u.IsObject(t.additionalProperties)?Em(e,r,t.additionalProperties,n):n}function n1(e,t,n){return u.IsObjectNotArray(n)?C5(e,t,n):n}function r1(e,t,n){return u.HasPropertyKey(e,t.$ref)?Je(e,e[t.$ref],n):n}function i1(e,t,n){let r=fe.TryString(n);return fe.IsOk(r)?r.value:n}function o1(e,t,n){return Je(e,$t(t),n)}function s1(e,t,n){if(!u.IsArray(n))return n;for(let r=0;r<Math.min(t.items.length,n.length);r++)n[r]=Je(e,t.items[r],n[r]);return n}function a1(e,t,n){let r=fe.TryUndefined(n);return fe.IsOk(r)?r.value:n}function l1(e,t,n){if(t.anyOf.some((s)=>ve(e,s,n)))return n;let o=t.anyOf.map((s)=>Je(e,s,Ye(n))).find((s)=>ve(e,t,s));return u.IsUndefined(o)?n:o}function u1(e,t,n){let r=fe.TryUndefined(n);return fe.IsOk(r)?void 0:n}function Je(e,t,n){return le(t)?zA(e,t,n):pn(t)?KA(e,t,n):Vt(t)?VA(e,t,n):Te(t)?WA(e,t,n):st(t)?XA(e,t,n):It(t)?YA(e,t,n):z(t)?JA(e,t,n):ae(t)?ZA(e,t,n):gr(t)?QA(e,t,n):_e(t)?e1(e,t,n):V(t)?t1(e,t,n):Se(t)?n1(e,t,n):xe(t)?r1(e,t,n):ct(t)?i1(e,t,n):Le(t)?o1(e,t,n):re(t)?s1(e,t,n):Jn(t)?a1(e,t,n):F(t)?l1(e,t,n):gn(t)?u1(e,t,n):n}function Er(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[{},i,o]});return Je(t,n,r)}function d1(e,t,n){if(!u.IsArray(n))return n;for(let r=0;r<n.length;r++)n[r]=Ct(e,t.items,n[r]);return n}function c1(e,t,n){return Ct({...e,...t.$defs},pt(t.$ref),n)}function m1(e,t){if(!u.IsUndefined(t))return t;return u.IsFunction(e.default)?e.default():Ye(e.default)}function f1(e,t,n){let r=Nn(e,t),i=$t(r);return Ct(e,i,n)}function p1(e,t,n){if(!u.IsObject(n))return n;let r=u.Keys(t.properties);for(let i of r){let o=Ct(e,t.properties[i],n[i]);if(u.IsUndefined(o)&&(ht(t.properties[i])||!u.HasPropertyKey(t.properties[i],"default")))continue;n[i]=o}if(!Dn(t)||u.IsBoolean(t.additionalProperties))return n;for(let i of u.Keys(n)){if(r.includes(i))continue;n[i]=Ct(e,t.additionalProperties,n[i])}return n}function h1(e,t,n){if(!u.IsObject(n))return n;let[r,i]=[new RegExp(St(t)),Ae(t)];for(let o of u.Keys(n)){if(!(r.test(o)&&Tn(i)))continue;n[o]=Ct(e,i,n[o])}if(!Dn(t))return n;for(let o of u.Keys(n)){if(r.test(o))continue;n[o]=Ct(e,t.additionalProperties,n[o])}return n}function g1(e,t,n){return u.HasPropertyKey(e,t.$ref)?Ct(e,e[t.$ref],n):n}function y1(e,t,n){if(!u.IsArray(n))return n;let[r,i]=[t.items,Math.max(t.items.length,n.length)];for(let o=0;o<i;o++)if(o<r.length)n[o]=Ct(e,r[o],n[o]);return n}function x1(e,t,n){for(let r of t.anyOf){let i=Ct(e,r,Ye(n));if(ve(e,r,i))return i}return n}function Ct(e,t,n){let r=Tn(t)?m1(t,n):n;return le(t)?d1(e,t,r):Te(t)?c1(e,t,r):z(t)?f1(e,t,r):V(t)?p1(e,t,r):Se(t)?h1(e,t,r):xe(t)?g1(e,t,r):re(t)?y1(e,t,r):F(t)?x1(e,t,r):r}function Jr(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[{},i,o]});return Ct(t,n,r)}function Us(e){return(...t)=>{let[n,r,i]=ee.Match(t,{3:(o,s,a)=>[o,s,a],2:(o,s)=>[{},o,s]});return e.reduce((o,s)=>s(n,r,o),i)}}function E5(e,t,n){return t["~codec"].decode(n)}function v5(e,t,n){return t["~codec"].encode(n)}function De(e,t,n,r){if(!Kt(n))return r;return u.IsEqual(e,"Decode")?E5(t,n,r):v5(t,n,r)}function k5(e,t,n,r){if(!u.IsArray(r))return r;for(let i=0;i<r.length;i++)r[i]=Be(e,t,n.items,r[i]);return De(e,t,n,r)}function T5(e,t,n,r){let i=De(e,t,n,r);if(!u.IsArray(i))return i;for(let o=0;o<i.length;o++)i[o]=Be(e,t,n.items,i[o]);return i}function I1(e,t,n,r){return u.IsEqual(e,"Decode")?k5(e,t,n,r):T5(e,t,n,r)}function S1(e,t,n,r){return r=Be(e,{...t,...n.$defs},pt(n.$ref),r),De(e,t,n,r)}function b1(e){return e.reduce((t,n)=>({...t,...n}),{})}function C1(e,t){for(let n of t)if(!u.IsDeepEqual(e,n))return n;return e}function w5(e,t,n,r){if(u.IsEqual(n.allOf.length,0))return De(e,t,n,r);let i=n.allOf.map((a)=>Be(e,t,a,_n(a,Ye(r)))),s=i.every((a)=>u.IsObject(a))?b1(i):C1(r,i);return De(e,t,n,s)}function L5(e,t,n,r){if(u.IsEqual(n.allOf.length,0))return De(e,t,n,r);let i=De(e,t,n,r),o=n.allOf.map((a)=>Be(e,t,a,_n(a,Ye(i))));if(o.every((a)=>u.IsObject(a)))return b1(o);return C1(i,o)}function E1(e,t,n,r){return u.IsEqual(e,"Decode")?w5(e,t,n,r):L5(e,t,n,r)}function R5(e,t,n,r){if(!u.IsObjectNotArray(r))return r;for(let i of u.Keys(n.properties)){if(!u.HasPropertyKey(r,i)||Ml(n.properties[i],i,r))continue;r[i]=Be(e,t,n.properties[i],r[i])}return De(e,t,n,r)}function A5(e,t,n,r){let i=De(e,t,n,r);if(!u.IsObjectNotArray(i))return i;for(let o of u.Keys(n.properties)){if(!u.HasPropertyKey(i,o)||Ml(n.properties[o],o,i))continue;i[o]=Be(e,t,n.properties[o],i[o])}return i}function v1(e,t,n,r){return u.IsEqual(e,"Decode")?R5(e,t,n,r):A5(e,t,n,r)}function P5(e,t,n,r){if(!u.IsObjectNotArray(r))return r;let i=new RegExp(St(n));for(let o of u.Keys(r)){if(!i.test(o))continue;r[o]=Be(e,t,Ae(n),r[o])}return De(e,t,n,r)}function $5(e,t,n,r){let i=De(e,t,n,r);if(!u.IsObjectNotArray(i))return i;let o=new RegExp(St(n));for(let s of u.Keys(i)){if(!o.test(s))continue;i[s]=Be(e,t,Ae(n),i[s])}return i}function k1(e,t,n,r){return u.IsEqual(e,"Decode")?P5(e,t,n,r):$5(e,t,n,r)}function T1(e,t,n,r){return u.HasPropertyKey(t,n.$ref)?Be(e,t,t[n.$ref],r):r}function w1(e,t,n,r){return u.IsEqual(e,"Decode")?De(e,t,n,T1(e,t,n,r)):T1(e,t,n,De(e,t,n,r))}function M5(e,t,n,r){if(!u.IsArray(r))return r;for(let i=0;i<Math.min(n.items.length,r.length);i++)r[i]=Be(e,t,n.items[i],r[i]);return De(e,t,n,r)}function O5(e,t,n,r){let i=De(e,t,n,r);if(!u.IsArray(i))return r;for(let o=0;o<Math.min(n.items.length,i.length);o++)i[o]=Be(e,t,n.items[o],i[o]);return i}function L1(e,t,n,r){return u.IsEqual(e,"Decode")?M5(e,t,n,r):O5(e,t,n,r)}function F5(e,t,n,r){for(let i of n.anyOf){if(!ve(t,i,r))continue;let o=Be(e,t,i,r);return De(e,t,n,o)}return r}function N5(e,t,n,r){let i=De(e,t,n,r);for(let o of n.anyOf){let s=Be(e,t,o,Ye(i));if(!ve(t,o,s))continue;return s}return i}function R1(e,t,n,r){return u.IsEqual(e,"Decode")?F5(e,t,n,r):N5(e,t,n,r)}function Be(e,t,n,r){return le(n)?I1(e,t,n,r):Te(n)?S1(e,t,n,r):z(n)?E1(e,t,n,r):V(n)?v1(e,t,n,r):Se(n)?k1(e,t,n,r):xe(n)?w1(e,t,n,r):re(n)?L1(e,t,n,r):F(n)?R1(e,t,n,r):De(e,t,n,r)}class A1 extends ko{constructor(e,t){super("Decode",e,t)}}function D5(e,t,n){if(!ve(e,t,n))throw new A1(n,ir(e,t,n));return n}function H5(e,t,n){let r=He.Get().unionPrioritySort?_s(t):t;return Be("Decode",e,r,n)}var _5=Us([(e,t,n)=>Ye(n),(e,t,n)=>Jr(e,t,n),(e,t,n)=>Er(e,t,n),(e,t,n)=>_n(e,t,n),(e,t,n)=>D5(e,t,n),(e,t,n)=>H5(e,t,n)]);function ug(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[{},i,o]});return _5(t,n,r)}class P1 extends ko{constructor(e,t){super("Encode",e,t)}}function U5(e,t,n){if(!ve(e,t,n))throw new P1(n,ir(e,t,n));return n}function B5(e,t,n){let r=He.Get().unionPrioritySort?_s(t):t;return Be("Encode",e,r,n)}var G5=Us([(e,t,n)=>Ye(n),(e,t,n)=>B5(e,t,n),(e,t,n)=>Jr(e,t,n),(e,t,n)=>Er(e,t,n),(e,t,n)=>_n(e,t,n),(e,t,n)=>U5(e,t,n)]);function dg(...e){let[t,n,r]=ee.Match(e,{3:(i,o,s)=>[i,o,s],2:(i,o)=>[{},i,o]});return G5(t,n,r)}function j5(e,t){return Kt(t)||Di(e,t.items)}function q5(e,t){return Kt(t)||$1({...e,...t.$defs},pt(t.$ref))}function z5(e,t){return Kt(t)||t.allOf.some((n)=>Di(e,n))}function K5(e,t){return Kt(t)||u.Keys(t.properties).some((n)=>Di(e,t.properties[n]))}function V5(e,t){return Kt(t)||Di(e,Ae(t))}function $1(e,t){if(cg.has(t.$ref))return!1;return cg.add(t.$ref),Kt(t)||u.HasPropertyKey(e,t.$ref)&&Di(e,e[t.$ref])}function W5(e,t){return Kt(t)||t.items.some((n)=>Di(e,n))}function X5(e,t){return Kt(t)||t.anyOf.some((n)=>Di(e,n))}function Di(e,t){return le(t)?j5(e,t):Te(t)?q5(e,t):z(t)?z5(e,t):V(t)?K5(e,t):Se(t)?V5(e,t):xe(t)?$1(e,t):re(t)?W5(e,t):F(t)?X5(e,t):Kt(t)}var cg=new Set;function mg(...e){let[t,n]=ee.Match(e,{2:(r,i)=>[r,i],1:(r)=>[{},r]});return cg.clear(),Di(t,n)}class or extends Error{constructor(e,t){super(t);this.type=e}}function M1(e,t){return u.IsFunction(t.default)?t.default(t):u.IsObject(t.default)?Ye(t.default):t.default}function O1(e,t){if($i(t)&&!Tn(t))throw new or(t,"Arrays with uniqueItems constraints must specify a default annotation");let n=Pi(t)?t.minItems:0;return Array.from({length:n},()=>Ze(e,t.items))}function F1(e,t){return Zn(t)?BigInt(t.exclusiveMinimum)+BigInt(1):Qn(t)?BigInt(t.minimum):BigInt(0)}function N1(e,t){return!1}function D1(e,t){let n=Ze(e,t.instanceType);return class{constructor(){Object.assign(this,n)}}}function H1(e,t){return Ze({...e,...t.$defs},pt(t.$ref))}function _1(e,t){return Ze(e,$t(t))}function U1(e,t){let n=Ze(e,t.returnType);return()=>n}function B1(e,t){return Zn(t)&&u.IsNumber(t.exclusiveMinimum)?t.exclusiveMinimum+1:Qn(t)?t.minimum:0}function G1(e,t){let n=Nn(e,t),r=$t(n);return Ze(e,r)}function j1(e,t){return t.const}function q1(e,t){throw new or(t,"Cannot create TNever types")}function z1(e,t){return null}function K1(e,t){return Zn(t)&&u.IsNumber(t.exclusiveMinimum)?t.exclusiveMinimum+1:Qn(t)?t.minimum:0}function V1(e,t){return(u.IsUndefined(t.required)?[]:t.required).reduce((r,i)=>({...r,[i]:Ze(e,t.properties[i])}),{})}function W1(e,t){if(bo(t)&&!Tn(t))throw new or(t,"Record with the minProperties constraint must have a default annotation");return{}}function X1(e,t){return u.HasPropertyKey(e,t.$ref)?Ze(e,e[t.$ref]):(()=>{throw new or(t,"Unable to deref Ref")})()}function Y1(e,t){if((Co(t)||Io(t))&&!Tn(t))throw Error("Strings with format or pattern constraints must specify default");let r=So(t)?t.minLength:0;return"".padEnd(r)}function J1(e,t){return Symbol()}function Z1(e,t){let n=Pa(t.pattern);if(ct(n))throw new or(t,"Unable to create TemplateLiteral due to infinite type expansion");return Ze(e,n)}function Q1(e,t){return Array.from({length:t.minItems},(n,r)=>Ze(e,t.items[r]))}function eP(e,t){return}function tP(e,t){if(u.IsEqual(t.anyOf.length,0))throw Error("Unable to create Union with no variants");return Ze(e,t.anyOf[0])}function nP(e,t){return}function Ze(e,t){return Tn(t)?M1(e,t):le(t)?O1(e,t):pn(t)?F1(e,t):Vt(t)?N1(e,t):nt(t)?D1(e,t):Te(t)?H1(e,t):st(t)?_1(e,t):rt(t)?U1(e,t):It(t)?B1(e,t):z(t)?G1(e,t):ae(t)?j1(e,t):fn(t)?q1(e,t):gr(t)?z1(e,t):_e(t)?K1(e,t):V(t)?V1(e,t):Se(t)?W1(e,t):xe(t)?X1(e,t):ct(t)?Y1(e,t):yr(t)?J1(e,t):Le(t)?Z1(e,t):re(t)?Q1(e,t):Jn(t)?eP(e,t):F(t)?tP(e,t):gn(t)?nP(e,t):void 0}function vr(...e){let[t,n]=ee.Match(e,{2:(r,i)=>[r,i],1:(r)=>[{},r]});return Ze(t,n)}class Ol extends ko{constructor(e,t){super("Parse",e,t)}}function Y5(e,t,n){if(!ve(e,t,n))throw new Ol(n,ir(e,t,n));return n}var fg=Us([(e,t,n)=>Ye(n),(e,t,n)=>Jr(e,t,n),(e,t,n)=>Er(e,t,n),(e,t,n)=>_n(e,t,n),(e,t,n)=>Y5(e,t,n)]);function J5(...e){let[t,n,r]=ee.Match(e,{3:(o,s,a)=>[o,s,a],2:(o,s)=>[{},o,s]});if(ve(t,n,r))return r;if(He.Get().correctiveParse)return fg(t,n,r);throw new Ol(r,ir(t,n,r))}var Q5=q({type:ne("insert"),path:Wt(),value:dt()}),eK=Object({type:ne("update"),path:Wt(),value:dt()}),tK=q({type:ne("delete"),path:Wt()}),s9e=J([Q5,eK,tK]);class vm{constructor(e,t){this.hasCodec=mg(e,t),this.buildResult=Sm(e,t),this.evaluateResult=this.buildResult.Evaluate()}IsAccelerated(){return this.evaluateResult.IsAccelerated()}Context(){return this.buildResult.Context()}Type(){return this.buildResult.Schema()}Code(){return this.evaluateResult.Code()}Check(e){return this.evaluateResult.Check(e)}Parse(e){if(this.Check(e))return e;if(He.Get().correctiveParse)return fg(this.Context(),this.Type(),e);throw new Ol(e,this.Errors(e))}Errors(e){if(this.IsAccelerated()&&this.Check(e))return[];return ir(this.Context(),this.Type(),e)}Clean(e){return _n(this.Context(),this.Type(),e)}Convert(e){return Er(this.Context(),this.Type(),e)}Create(){return vr(this.Context(),this.Type())}Default(e){return Jr(this.Context(),this.Type(),e)}Decode(e){return this.hasCodec?ug(this.Context(),this.Type(),e):this.Parse(e)}Encode(e){return this.hasCodec?dg(this.Context(),this.Type(),e):this.Parse(e)}}function pg(...e){let[t,n]=ee.Match(e,{2:(r,i)=>[r,i],1:(r)=>[{},r]});return new vm(t,n)}var iK=pg(_c.Object({dark:_c.String(),light:_c.String()}));function tYe(e){return iK.Check(e)}var oK={dark:"pierre-dark-soft",light:"pierre-light"},oP=oK;function nYe(){return oP}function rYe(e){oP={dark:e.dark,light:e.light}}
|
|
1532
|
+
export{Ut as a,vy as b,ky as c,Wm as d,Pr as e,ni as f,kx as g,Tx as h,On as i,Ef as j,sr as k,jn as l,kf as m,Cn as n,Vo as o,uI as p,Hr as q,pI as r,_f as s,pF as t,ze as u,ad as v,to as w,ur as x,JI as y,ND as z,_c as A,J5 as B,pg as C,tYe as D,oK as E,nYe as F,rYe as G};
|