shadow-claw 1.41.0 → 1.41.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/.well-known/mcp/server-card.json +1 -1
- package/.well-known/mcp.json +1 -1
- package/README.md +2 -2
- package/dist/cli/build/build.js +1 -1
- package/dist/cli/{chunk-bQQkVCw-.js → chunk-63s8NnIS.js} +15 -16
- package/dist/cli/chunk-BATVgkFY.js +17 -0
- package/dist/cli/chunk-Cmdxoq9q.js +13 -0
- package/dist/cli/cli.js +1 -1
- package/dist/cli/prerender/dsd-shell/prerender-dsd-shell.js +1 -1
- package/dist/public/.well-known/mcp/server-card.json +1 -1
- package/dist/public/.well-known/mcp.json +1 -1
- package/dist/public/AGENTS.md +6 -1
- package/dist/public/README.md +2 -2
- package/dist/public/docs/README.md +1 -0
- package/dist/public/docs/example/article/index.html +1 -1
- package/dist/public/docs/guides/publishing-to-github-pages.md +46 -0
- package/dist/public/docs/publishing/index.html +1 -1
- package/dist/public/docs/skill-creator/index.html +1 -1
- package/dist/public/docs/subsystems/theming.md +242 -0
- package/dist/public/e2e/README.md +1 -0
- package/dist/public/index.html +1 -1
- package/dist/public/llms.txt +2 -2
- package/dist/public/main/index.html +1 -1
- package/dist/public/main/memory/index.html +1 -1
- package/dist/public/service-worker.js +1 -1
- package/package.json +1 -1
- package/src/cli/build/build.ts +18 -11
- package/src/cli/prerender/dsd-shell/prerender-dsd-shell.ts +6 -0
- package/src/cli/prerender/pretty-paths/prerender-pretty-paths.ts +22 -0
- package/src/cli/prerender/utils/insert-before-closing-head.test.ts +22 -1
- package/src/cli/prerender/utils/insert-before-closing-head.ts +19 -3
- package/src/cli/site-config/apply.ts +13 -14
- package/dist/cli/chunk-BvVUnHTq.js +0 -14
- package/dist/cli/chunk-DTES-dE6.js +0 -17
|
@@ -14,6 +14,11 @@ import { fileURLToPath } from "node:url";
|
|
|
14
14
|
|
|
15
15
|
import { resolveCustomElementScripts } from "./custom-elements/resolve-custom-element-scripts.js";
|
|
16
16
|
import { sanitizeEmbeddedCustomElementScripts } from "./custom-elements/sanitize-embedded-custom-element-scripts.js";
|
|
17
|
+
import {
|
|
18
|
+
findClosingHeadIndex,
|
|
19
|
+
insertBeforeClosingHead,
|
|
20
|
+
} from "../prerender/utils/insert-before-closing-head.js";
|
|
21
|
+
import { applySidebarVisibilityToTemplate } from "../prerender/dsd-shell/prerender-dsd-shell.js";
|
|
17
22
|
|
|
18
23
|
export interface SiteConfigSite {
|
|
19
24
|
title?: string;
|
|
@@ -115,19 +120,7 @@ export function escapeHtml(str: string): string {
|
|
|
115
120
|
.replace(/'/g, "'");
|
|
116
121
|
}
|
|
117
122
|
|
|
118
|
-
export
|
|
119
|
-
html: string,
|
|
120
|
-
contentToInsert: string,
|
|
121
|
-
): string {
|
|
122
|
-
const headMatch = /<\/head>/i.exec(html);
|
|
123
|
-
if (headMatch) {
|
|
124
|
-
const headIndex = headMatch.index;
|
|
125
|
-
return (
|
|
126
|
-
html.slice(0, headIndex) + contentToInsert + "\n" + html.slice(headIndex)
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
return `${contentToInsert}\n${html}`;
|
|
130
|
-
}
|
|
123
|
+
export { insertBeforeClosingHead, findClosingHeadIndex };
|
|
131
124
|
|
|
132
125
|
const FLATTENED_STYLESHEET_PREFIXES = [
|
|
133
126
|
"pages/resources/",
|
|
@@ -367,7 +360,9 @@ export function patchIndexHtml(
|
|
|
367
360
|
`<link\\s+[^>]*href=["'](?:${rawHrefPattern}|${escapedHrefPattern})["'][^>]*>`,
|
|
368
361
|
"iu",
|
|
369
362
|
);
|
|
370
|
-
const
|
|
363
|
+
const closingHeadIdx = findClosingHeadIndex(next);
|
|
364
|
+
const headContent =
|
|
365
|
+
closingHeadIdx !== -1 ? next.slice(0, closingHeadIdx) : next;
|
|
371
366
|
const headWithoutScripts = headContent.replace(
|
|
372
367
|
/<script\b[\s\S]*?<\/script>/gi,
|
|
373
368
|
"",
|
|
@@ -452,6 +447,10 @@ export function patchIndexHtml(
|
|
|
452
447
|
}
|
|
453
448
|
}
|
|
454
449
|
|
|
450
|
+
if (config.sidebar) {
|
|
451
|
+
next = applySidebarVisibilityToTemplate(next, config.sidebar);
|
|
452
|
+
}
|
|
453
|
+
|
|
455
454
|
return next;
|
|
456
455
|
}
|
|
457
456
|
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./chunk-uAI_Zi6n.js";import{C as t,S as n,_ as r,a as i,b as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,o as p,p as m,r as h,x as g,y as ee}from"./chunk-DTES-dE6.js";import{n as _}from"./chunk-kF1oe5Yi.js";import*as v from"node:fs";import y,{join as b,posix as x,resolve as te,win32 as S}from"node:path";import{fileURLToPath as C}from"node:url";import w,{chdir as ne,env as re,exit as ie}from"node:process";import{execSync as ae}from"node:child_process";import{copyFile as T,cp as E,lstat as oe,mkdir as D,readFile as O,readdir as se,readlink as ce,realpath as le,rm as ue,stat as de,writeFile as k}from"node:fs/promises";import{chmodSync as fe,lstatSync as pe,lstatSync as me,readdir as he,readdirSync as ge,readlinkSync as _e,realpathSync as ve,renameSync as ye,rmSync as be,rmdirSync as xe,statSync as Se,unlinkSync as Ce}from"fs";import{EventEmitter as we}from"node:events";import Te from"node:stream";import{StringDecoder as Ee}from"node:string_decoder";import{basename as A,parse as j,resolve as M}from"path";import{inspect as De}from"util";import Oe from"fs/promises";import{setTimeout as ke}from"timers/promises";import{tmpdir as Ae}from"os";var je=(e,t,n)=>{let r=e instanceof RegExp?Me(e,n):e,i=t instanceof RegExp?Me(t,n):t,a=r!==null&&i!=null&&Ne(r,i,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+r.length,a[1]),post:n.slice(a[1]+i.length)}},Me=(e,t)=>{let n=t.match(e);return n?n[0]:null},Ne=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i<a&&(a=i,o=l),l=n.indexOf(t,u+1);u=c<l&&c>=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},Pe=`\0SLASH`+Math.random()+`\0`,Fe=`\0OPEN`+Math.random()+`\0`,Ie=`\0CLOSE`+Math.random()+`\0`,Le=`\0COMMA`+Math.random()+`\0`,Re=`\0PERIOD`+Math.random()+`\0`,ze=new RegExp(Pe,`g`),Be=new RegExp(Fe,`g`),Ve=new RegExp(Ie,`g`),He=new RegExp(Le,`g`),Ue=new RegExp(Re,`g`),We=/\\\\/g,Ge=/\\{/g,Ke=/\\}/g,qe=/\\,/g,Je=/\\./g,Ye=1e5;function Xe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Ze(e){return e.replace(We,Pe).replace(Ge,Fe).replace(Ke,Ie).replace(qe,Le).replace(Je,Re)}function Qe(e){return e.replace(ze,`\\`).replace(Be,`{`).replace(Ve,`}`).replace(He,`,`).replace(Ue,`.`)}function $e(e){if(!e)return[``];let t=[],n=je(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:i,post:a}=n,o=r.split(`,`);o[o.length-1]+=`{`+i+`}`;let s=$e(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function et(e,t={}){if(!e)return[];let{max:n=Ye}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),at(Ze(e),n,!0).map(Qe)}function tt(e){return`{`+e+`}`}function nt(e){return/^-?0\d/.test(e)}function rt(e,t){return e<=t}function it(e,t){return e>=t}function at(e,t,n){let r=[],i=je(`{`,`}`,e);if(!i)return[e];let a=i.pre,o=i.post.length?at(i.post,t,!1):[``];if(/\$$/.test(i.pre))for(let e=0;e<o.length&&e<t;e++){let t=a+`{`+i.body+`}`+o[e];r.push(t)}else{let s=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),l=s||c,u=i.body.indexOf(`,`)>=0;if(!l&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+`{`+i.body+Ie+i.post,at(e,t,!0)):[e];let d;if(l)d=i.body.split(/\.\./);else if(d=$e(i.body),d.length===1&&d[0]!==void 0&&(d=at(d[0],t,!1).map(tt),d.length===1))return o.map(e=>i.pre+d[0]+e);let f;if(l&&d[0]!==void 0&&d[1]!==void 0){let e=Xe(d[0]),t=Xe(d[1]),n=Math.max(d[0].length,d[1].length),r=d.length===3&&d[2]!==void 0?Math.abs(Xe(d[2])):1,i=rt;t<e&&(r*=-1,i=it);let a=d.some(nt);f=[];for(let o=e;i(o,t);o+=r){let e;if(c)e=String.fromCharCode(o),e===`\\`&&(e=``);else if(e=String(o),a){let t=n-e.length;if(t>0){let n=Array(t+1).join(`0`);e=o<0?`-`+n+e.slice(1):n+e}}f.push(e)}}else{f=[];for(let e=0;e<d.length;e++)f.push.apply(f,at(d[e],t,!1))}for(let e=0;e<f.length;e++)for(let i=0;i<o.length&&r.length<t;i++){let t=a+f[e]+o[i];(!n||l||t)&&r.push(t)}}return r}var ot=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},st={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},ct=e=>e.replace(/[[\]\\-]/g,`\\$&`),lt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),ut=e=>e.join(``),dt=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;t:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1){l=!0,a++;continue}if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c){c=!0,a++;continue}if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(st))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue t}}if(c=!1,d){t>d?r.push(ct(d)+`-`+ct(t)):t===d&&r.push(ct(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(ct(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(ct(t)),a++}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l)return[lt(r[0].length===2?r[0].slice(-1):r[0]),!1,u-n,!1];let f=`[`+(l?`^`:``)+ut(r)+`]`,p=`[`+(l?``:`^`)+ut(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},ft=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^\/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,`$1$2`).replace(/\\([^\/])/g,`$1`):t?e.replace(/\[([^\/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,`$1$2`).replace(/\\([^\/{}])/g,`$1`),pt=new Set([`!`,`?`,`+`,`*`,`@`]),mt=e=>pt.has(e),ht=`(?!(?:^|/)\\.\\.?(?:$|/))`,gt=`(?!\\.)`,_t=new Set([`[`,`.`]),vt=new Set([`..`,`.`]),yt=new Set(`().*{}+?[]^$\\!`),bt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),xt=`[^/]`,St=xt+`*?`,Ct=xt+`+?`,wt=class e{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.type?this.#l=this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#l=this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...t){for(let n of t)if(n!==``){if(typeof n!=`string`&&!(n instanceof e&&n.#i===this))throw Error(`invalid part: `+n);this.#r.push(n)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let t=this.#i;for(let n=0;n<this.#a;n++){let r=t.#r[n];if(!(r instanceof e&&r.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(t){let n=new e(this.type,t);for(let e of this.#r)n.copyIn(e);return n}static#f(t,n,r,i){let a=!1,o=!1,s=-1,c=!1;if(n.type===null){let l=r,u=``;for(;l<t.length;){let r=t.charAt(l++);if(a||r===`\\`){a=!a,u+=r;continue}if(o){l===s+1?(r===`^`||r===`!`)&&(c=!0):r===`]`&&!(l===s+2&&c)&&(o=!1),u+=r;continue}else if(r===`[`){o=!0,s=l,c=!1,u+=r;continue}if(!i.noext&&mt(r)&&t.charAt(l)===`(`){n.push(u),u=``;let a=new e(r,n);l=e.#f(t,a,l,i),n.push(a);continue}u+=r}return n.push(u),l}let l=r+1,u=new e(null,n),d=[],f=``;for(;l<t.length;){let r=t.charAt(l++);if(a||r===`\\`){a=!a,f+=r;continue}if(o){l===s+1?(r===`^`||r===`!`)&&(c=!0):r===`]`&&!(l===s+2&&c)&&(o=!1),f+=r;continue}else if(r===`[`){o=!0,s=l,c=!1,f+=r;continue}if(mt(r)&&t.charAt(l)===`(`){u.push(f),f=``;let n=new e(r,u);u.push(n),l=e.#f(t,n,l,i);continue}if(r===`|`){u.push(f),f=``,d.push(u),u=new e(null,n);continue}if(r===`)`)return f===``&&n.#r.length===0&&(n.#u=!0),u.push(f),f=``,n.push(...d,u),l;f+=r}return n.type=null,n.#t=void 0,n.#r=[t.substring(r-1)],l}static fromGlob(t,n={}){let r=new e(null,void 0,n);return e.#f(t,r,0,n),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(t){let n=t??!!this.#c.dot;if(this.#e===this&&this.#d(),!this.type){let r=this.isStart()&&this.isEnd()&&!this.#r.some(e=>typeof e!=`string`),i=this.#r.map(n=>{let[i,a,o,s]=typeof n==`string`?e.#m(n,this.#t,r):n.toRegExpSource(t);return this.#t=this.#t||o,this.#n=this.#n||s,i}).join(``),a=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&vt.has(this.#r[0]))){let e=_t,r=n&&e.has(i.charAt(0))||i.startsWith(`\\.`)&&e.has(i.charAt(2))||i.startsWith(`\\.\\.`)&&e.has(i.charAt(4)),o=!n&&!t&&e.has(i.charAt(0));a=r?ht:o?gt:``}let o=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(o=`(?:$|\\/)`),[a+i+o,ft(i),this.#t=!!this.#t,this.#n]}let r=this.type===`*`||this.type===`+`,i=this.type===`!`?`(?:(?!(?:`:`(?:`,a=this.#p(n);if(this.isStart()&&this.isEnd()&&!a&&this.type!==`!`){let e=this.toString();return this.#r=[e],this.type=null,this.#t=void 0,[e,ft(this.toString()),!1,!1]}let o=!r||t||n||!gt?``:this.#p(!0);o===a&&(o=``),o&&(a=`(?:${a})(?:${o})*?`);let s=``;if(this.type===`!`&&this.#u)s=(this.isStart()&&!n?gt:``)+Ct;else{let e=this.type===`!`?`))`+(this.isStart()&&!n&&!t?gt:``)+St+`)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&o?`)`:this.type===`*`&&o?`)?`:`)${this.type}`;s=i+a+e}return[s,ft(a),this.#t=!!this.#t,this.#n]}#p(e){return this.#r.map(t=>{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#m(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(r){r=!1,i+=(yt.has(c)?`\\`:``)+c;continue}if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?Ct:St,t=!0;continue}else o=!1;if(c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=dt(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}if(c===`?`){i+=xt,t=!0;continue}i+=bt(c)}return[i,ft(e),!!t,a]}},Tt=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),N=(e,t,n={})=>(ot(t),!n.nocomment&&t.charAt(0)===`#`?!1:new en(t,n).match(e)),Et=/^\*+([^+@!?\*\[\(]*)$/,Dt=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),Ot=e=>t=>t.endsWith(e),kt=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),At=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),jt=/^\*+\.\*+$/,Mt=e=>!e.startsWith(`.`)&&e.includes(`.`),Nt=e=>e!==`.`&&e!==`..`&&e.includes(`.`),Pt=/^\.\*+$/,Ft=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),It=/^\*+$/,Lt=e=>e.length!==0&&!e.startsWith(`.`),Rt=e=>e.length!==0&&e!==`.`&&e!==`..`,zt=/^\?+([^+@!?\*\[\(]*)?$/,Bt=([e,t=``])=>{let n=Wt([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Vt=([e,t=``])=>{let n=Gt([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Ht=([e,t=``])=>{let n=Gt([e]);return t?e=>n(e)&&e.endsWith(t):n},Ut=([e,t=``])=>{let n=Wt([e]);return t?e=>n(e)&&e.endsWith(t):n},Wt=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},Gt=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},Kt=typeof process==`object`&&process?typeof process.env==`object`&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,qt={win32:{sep:`\\`},posix:{sep:`/`}};N.sep=Kt===`win32`?qt.win32.sep:qt.posix.sep;var P=Symbol(`globstar **`);N.GLOBSTAR=P;var Jt=`[^/]*?`,Yt=`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`,Xt=`(?:(?!(?:\\/|^)\\.).)*?`;N.filter=(e,t={})=>n=>N(n,e,t);var F=(e,t={})=>Object.assign({},e,t);N.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return N;let t=N;return Object.assign((n,r,i={})=>t(n,r,F(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,F(e,n))}static defaults(n){return t.defaults(F(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,F(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,F(e,r))}},unescape:(n,r={})=>t.unescape(n,F(e,r)),escape:(n,r={})=>t.escape(n,F(e,r)),filter:(n,r={})=>t.filter(n,F(e,r)),defaults:n=>t.defaults(F(e,n)),makeRe:(n,r={})=>t.makeRe(n,F(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,F(e,r)),match:(n,r,i={})=>t.match(n,r,F(e,i)),sep:t.sep,GLOBSTAR:P})};var Zt=(e,t={})=>(ot(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:et(e,{max:t.braceExpandMax}));N.braceExpand=Zt,N.makeRe=(e,t={})=>new en(e,t).makeRe(),N.match=(e,t,n={})=>{let r=new en(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};var Qt=/[?*]|[+@!]\(.*?\)|\[|\]/,$t=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),en=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,t={}){ot(e),t||={},this.options=t,this.pattern=e,this.platform=t.platform||Kt,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!Qt.test(e[2]))&&!Qt.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)e[t][n]===`**`&&(e[t][n]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];n===1&&r===``&&e[0]===``||(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];e===1&&r===``&&n[0]===``||(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(r){e[t]=[],e[n]=r;break}}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=this.options;if(this.isWindows){let n=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),r=!n&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),i=typeof t[0]==`string`&&/^[a-z]:$/i.test(t[0]),a=!i&&t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]),o=r?3:n?0:void 0,s=a?3:i?0:void 0;if(typeof o==`number`&&typeof s==`number`){let[n,r]=[e[o],t[s]];n.toLowerCase()===r.toLowerCase()&&(t[s]=n,s>o?t=t.slice(s):o>s&&(e=e.slice(o)))}}let{optimizationLevel:i=1}=this.options;i>=2&&(e=this.levelTwoFileOptimize(e)),this.debug(`matchOne`,this,{file:e,pattern:t}),this.debug(`matchOne`,e.length,t.length);for(var a=0,o=0,s=e.length,c=t.length;a<s&&o<c;a++,o++){this.debug(`matchOne loop`);var l=t[o],u=e[a];if(this.debug(t,l,u),l===!1)return!1;if(l===P){this.debug(`GLOBSTAR`,[t,l,u]);var d=a,f=o+1;if(f===c){for(this.debug(`** at the end`);a<s;a++)if(e[a]===`.`||e[a]===`..`||!r.dot&&e[a].charAt(0)===`.`)return!1;return!0}for(;d<s;){var p=e[d];if(this.debug(`
|
|
2
|
-
globstar while`,e,d,t,f,p),this.matchOne(e.slice(d),t.slice(f),n))return this.debug(`globstar found match!`,d,s,p),!0;if(p===`.`||p===`..`||!r.dot&&p.charAt(0)===`.`){this.debug(`dot detected!`,e,d,t,f);break}this.debug(`globstar swallow a segment, and continue`),d++}return!!(n&&(this.debug(`
|
|
3
|
-
>>> no match, partial?`,e,d,t,f),d===s))}let i;if(typeof l==`string`?(i=u===l,this.debug(`string match`,l,u,i)):(i=l.test(u),this.debug(`pattern match`,l,u,i)),!i)return!1}if(a===s&&o===c)return!0;if(a===s)return n;if(o===c)return a===s-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return Zt(this.pattern,this.options)}parse(e){ot(e);let t=this.options;if(e===`**`)return P;if(e===``)return``;let n,r=null;(n=e.match(It))?r=t.dot?Rt:Lt:(n=e.match(Et))?r=(t.nocase?t.dot?At:kt:t.dot?Ot:Dt)(n[1]):(n=e.match(zt))?r=(t.nocase?t.dot?Vt:Bt:t.dot?Ht:Ut)(n):(n=e.match(jt))?r=t.dot?Nt:Mt:(n=e.match(Pt))&&(r=Ft);let i=wt.fromGlob(e,this.options).toMMPattern();return r&&typeof i==`object`&&Reflect.defineProperty(i,"test",{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?Jt:t.dot?Yt:Xt,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?$t(e):e===P?P:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e!==P||a===P||(a===void 0?i!==void 0&&i!==P?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==P&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=P))});let i=t.filter(e=>e!==P);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].join(``))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^\/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e=0;e<i.length;e++){let o=i[e],s=r;if(n.matchBase&&o.length===1&&(s=[a]),this.matchOne(s,o,t))return n.flipNegate?!0:!this.negate}return!n.flipNegate&&this.negate}static defaults(e){return N.defaults(e).Minimatch}};N.AST=wt,N.Minimatch=en,N.escape=Tt,N.unescape=ft;var tn=typeof performance==`object`&&performance&&typeof performance.now==`function`?performance:Date,nn=new Set,rn=typeof process==`object`&&process?process:{},an=(e,t,n,r)=>{typeof rn.emitWarning==`function`?rn.emitWarning(e,t,n,r):console.error(`[${n}] ${t}: ${e}`)},on=globalThis.AbortController,sn=globalThis.AbortSignal;if(typeof on>`u`){sn=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},on=class{constructor(){t()}signal=new sn;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(let t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e=rn.env?.LRU_CACHE_IGNORE_AC_WARNING!==`1`,t=()=>{e&&(e=!1,an("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.",`NO_ABORT_CONTROLLER`,`ENOTSUP`,t))}}var cn=e=>!nn.has(e),ln=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),un=e=>ln(e)?e<=2**8?Uint8Array:e<=2**16?Uint16Array:e<=2**32?Uint32Array:e<=2**53-1?dn:null:null,dn=class extends Array{constructor(e){super(e),this.fill(0)}},fn=class e{heap;length;static#e=!1;static create(t){let n=un(t);if(!n)return[];e.#e=!0;let r=new e(t,n);return e.#e=!1,r}constructor(t,n){if(!e.#e)throw TypeError(`instantiate Stack using Stack.create(n)`);this.heap=new n(t),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},pn=class e{#e;#t;#n;#r;#i;#a;#o;#s;get perf(){return this.#s}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E;static unsafeExposeInternals(e){return{starts:e.#b,ttls:e.#x,autopurgeTimers:e.#S,sizes:e.#y,keyMap:e.#u,keyList:e.#d,valList:e.#f,next:e.#p,prev:e.#m,get head(){return e.#h},get tail(){return e.#g},free:e.#_,isBackgroundFetch:t=>e.#V(t),backgroundFetch:(t,n,r,i)=>e.#B(t,n,r,i),moveToTail:t=>e.#U(t),indexes:t=>e.#I(t),rindexes:t=>e.#L(t),isStale:t=>e.#j(t)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#l}get size(){return this.#c}get fetchMethod(){return this.#a}get memoMethod(){return this.#o}get dispose(){return this.#n}get onInsert(){return this.#r}get disposeAfter(){return this.#i}constructor(t){let{max:n=0,ttl:r,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:s,allowStale:c,dispose:l,onInsert:u,disposeAfter:d,noDisposeOnSet:f,noUpdateTTL:p,maxSize:m=0,maxEntrySize:h=0,sizeCalculation:g,fetchMethod:ee,memoMethod:_,noDeleteOnFetchRejection:v,noDeleteOnStaleGet:y,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:x,ignoreFetchAbort:te,perf:S}=t;if(S!==void 0&&typeof S?.now!=`function`)throw TypeError(`perf option must have a now() method if specified`);if(this.#s=S??tn,n!==0&&!ln(n))throw TypeError(`max option must be a nonnegative integer`);let C=n?un(n):Array;if(!C)throw Error(`invalid max value: `+n);if(this.#e=n,this.#t=m,this.maxEntrySize=h||this.#t,this.sizeCalculation=g,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw TypeError(`cannot set sizeCalculation without setting maxSize or maxEntrySize`);if(typeof this.sizeCalculation!=`function`)throw TypeError(`sizeCalculation set to non-function`)}if(_!==void 0&&typeof _!=`function`)throw TypeError(`memoMethod must be a function if defined`);if(this.#o=_,ee!==void 0&&typeof ee!=`function`)throw TypeError(`fetchMethod must be a function if specified`);if(this.#a=ee,this.#w=!!ee,this.#u=new Map,this.#d=Array(n).fill(void 0),this.#f=Array(n).fill(void 0),this.#p=new C(n),this.#m=new C(n),this.#h=0,this.#g=0,this.#_=fn.create(n),this.#c=0,this.#l=0,typeof l==`function`&&(this.#n=l),typeof u==`function`&&(this.#r=u),typeof d==`function`?(this.#i=d,this.#v=[]):(this.#i=void 0,this.#v=void 0),this.#C=!!this.#n,this.#E=!!this.#r,this.#T=!!this.#i,this.noDisposeOnSet=!!f,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!v,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!x,this.ignoreFetchAbort=!!te,this.maxEntrySize!==0){if(this.#t!==0&&!ln(this.#t))throw TypeError(`maxSize must be a positive integer if specified`);if(!ln(this.maxEntrySize))throw TypeError(`maxEntrySize must be a positive integer if specified`);this.#M()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!y,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!s,this.ttlResolution=ln(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=r||0,this.ttl){if(!ln(this.ttl))throw TypeError(`ttl must be a positive integer if specified`);this.#D()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw TypeError(`At least one of max, maxSize, or ttl is required`);if(!this.ttlAutopurge&&!this.#e&&!this.#t){let t=`LRU_CACHE_UNBOUNDED`;cn(t)&&(nn.add(t),an(`TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.`,`UnboundedCacheWarning`,t,e))}}getRemainingTTL(e){return this.#u.has(e)?1/0:0}#D(){let e=new dn(this.#e),t=new dn(this.#e);this.#x=e,this.#b=t;let n=this.ttlAutopurge?Array(this.#e):void 0;this.#S=n,this.#A=(r,i,a=this.#s.now())=>{if(t[r]=i===0?0:a,e[r]=i,n?.[r]&&(clearTimeout(n[r]),n[r]=void 0),i!==0&&n){let e=setTimeout(()=>{this.#j(r)&&this.#W(this.#d[r],`expire`)},i+1);e.unref&&e.unref(),n[r]=e}},this.#O=n=>{t[n]=e[n]===0?0:this.#s.now()},this.#k=(n,a)=>{if(e[a]){let o=e[a],s=t[a];if(!o||!s)return;n.ttl=o,n.start=s,n.now=r||i(),n.remainingTTL=o-(n.now-s)}};let r=0,i=()=>{let e=this.#s.now();if(this.ttlResolution>0){r=e;let t=setTimeout(()=>r=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=n=>{let a=this.#u.get(n);if(a===void 0)return 0;let o=e[a],s=t[a];return!o||!s?1/0:o-((r||i())-s)},this.#j=n=>{let a=t[n],o=e[n];return!!o&&!!a&&(r||i())-a>o}}#O=()=>{};#k=()=>{};#A=()=>{};#j=()=>!1;#M(){let e=new dn(this.#e);this.#l=0,this.#y=e,this.#N=t=>{this.#l-=e[t],e[t]=0},this.#F=(e,t,n,r)=>{if(this.#V(t))return 0;if(!ln(n))if(r){if(typeof r!=`function`)throw TypeError(`sizeCalculation must be a function`);if(n=r(t,e),!ln(n))throw TypeError(`sizeCalculation return invalid (expect positive integer)`)}else throw TypeError(`invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.`);return n},this.#P=(t,n,r)=>{if(e[t]=n,this.#t){let n=this.#t-e[t];for(;this.#l>n;)this.#z(!0)}this.#l+=e[t],r&&(r.entrySize=n,r.totalCalculatedSize=this.#l)}}#N=e=>{};#P=(e,t,n)=>{};#F=(e,t,n,r)=>{if(n||r)throw TypeError(`cannot set size without setting maxSize or maxEntrySize on cache`);return 0};*#I({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#g;!(!this.#R(t)||((e||!this.#j(t))&&(yield t),t===this.#h));)t=this.#m[t]}*#L({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#h;!(!this.#R(t)||((e||!this.#j(t))&&(yield t),t===this.#g));)t=this.#p[t]}#R(e){return e!==void 0&&this.#u.get(this.#d[e])===e}*entries(){for(let e of this.#I())this.#f[e]!==void 0&&this.#d[e]!==void 0&&!this.#V(this.#f[e])&&(yield[this.#d[e],this.#f[e]])}*rentries(){for(let e of this.#L())this.#f[e]!==void 0&&this.#d[e]!==void 0&&!this.#V(this.#f[e])&&(yield[this.#d[e],this.#f[e]])}*keys(){for(let e of this.#I()){let t=this.#d[e];t!==void 0&&!this.#V(this.#f[e])&&(yield t)}}*rkeys(){for(let e of this.#L()){let t=this.#d[e];t!==void 0&&!this.#V(this.#f[e])&&(yield t)}}*values(){for(let e of this.#I())this.#f[e]!==void 0&&!this.#V(this.#f[e])&&(yield this.#f[e])}*rvalues(){for(let e of this.#L())this.#f[e]!==void 0&&!this.#V(this.#f[e])&&(yield this.#f[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]=`LRUCache`;find(e,t={}){for(let n of this.#I()){let r=this.#f[n],i=this.#V(r)?r.__staleWhileFetching:r;if(i!==void 0&&e(i,this.#d[n],this))return this.get(this.#d[n],t)}}forEach(e,t=this){for(let n of this.#I()){let r=this.#f[n],i=this.#V(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#d[n],this)}}rforEach(e,t=this){for(let n of this.#L()){let r=this.#f[n],i=this.#V(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#d[n],this)}}purgeStale(){let e=!1;for(let t of this.#L({allowStale:!0}))this.#j(t)&&(this.#W(this.#d[t],`expire`),e=!0);return e}info(e){let t=this.#u.get(e);if(t===void 0)return;let n=this.#f[t],r=this.#V(n)?n.__staleWhileFetching:n;if(r===void 0)return;let i={value:r};if(this.#x&&this.#b){let e=this.#x[t],n=this.#b[t];e&&n&&(i.ttl=e-(this.#s.now()-n),i.start=Date.now())}return this.#y&&(i.size=this.#y[t]),i}dump(){let e=[];for(let t of this.#I({allowStale:!0})){let n=this.#d[t],r=this.#f[t],i=this.#V(r)?r.__staleWhileFetching:r;if(i===void 0||n===void 0)continue;let a={value:i};if(this.#x&&this.#b){a.ttl=this.#x[t];let e=this.#s.now()-this.#b[t];a.start=Math.floor(Date.now()-e)}this.#y&&(a.size=this.#y[t]),e.unshift([n,a])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let e=Date.now()-n.start;n.start=this.#s.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(t===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:i,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:s}=n,{noUpdateTTL:c=this.noUpdateTTL}=n,l=this.#F(e,t,n.size||0,o);if(this.maxEntrySize&&l>this.maxEntrySize)return s&&(s.set=`miss`,s.maxEntrySizeExceeded=!0),this.#W(e,`set`),this;let u=this.#c===0?void 0:this.#u.get(e);if(u===void 0)u=this.#c===0?this.#g:this.#_.length===0?this.#c===this.#e?this.#z(!1):this.#c:this.#_.pop(),this.#d[u]=e,this.#f[u]=t,this.#u.set(e,u),this.#p[this.#g]=u,this.#m[u]=this.#g,this.#g=u,this.#c++,this.#P(u,l,s),s&&(s.set=`add`),c=!1,this.#E&&this.#r?.(t,e,`add`);else{this.#U(u);let n=this.#f[u];if(t!==n){if(this.#w&&this.#V(n)){n.__abortController.abort(Error(`replaced`));let{__staleWhileFetching:t}=n;t!==void 0&&!a&&(this.#C&&this.#n?.(t,e,`set`),this.#T&&this.#v?.push([t,e,`set`]))}else a||(this.#C&&this.#n?.(n,e,`set`),this.#T&&this.#v?.push([n,e,`set`]));if(this.#N(u),this.#P(u,l,s),this.#f[u]=t,s){s.set=`replace`;let e=n&&this.#V(n)?n.__staleWhileFetching:n;e!==void 0&&(s.oldValue=e)}}else s&&(s.set=`update`);this.#E&&this.onInsert?.(t,e,t===n?`update`:`replace`)}if(r!==0&&!this.#x&&this.#D(),this.#x&&(c||this.#A(u,r,i),s&&this.#k(s,u)),!a&&this.#T&&this.#v){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}return this}pop(){try{for(;this.#c;){let e=this.#f[this.#h];if(this.#z(!0),this.#V(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#T&&this.#v){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}}}#z(e){let t=this.#h,n=this.#d[t],r=this.#f[t];return this.#w&&this.#V(r)?r.__abortController.abort(Error(`evicted`)):(this.#C||this.#T)&&(this.#C&&this.#n?.(r,n,`evict`),this.#T&&this.#v?.push([r,n,`evict`])),this.#N(t),this.#S?.[t]&&(clearTimeout(this.#S[t]),this.#S[t]=void 0),e&&(this.#d[t]=void 0,this.#f[t]=void 0,this.#_.push(t)),this.#c===1?(this.#h=this.#g=0,this.#_.length=0):this.#h=this.#p[t],this.#u.delete(n),this.#c--,t}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=t,i=this.#u.get(e);if(i!==void 0){let e=this.#f[i];if(this.#V(e)&&e.__staleWhileFetching===void 0)return!1;if(this.#j(i))r&&(r.has=`stale`,this.#k(r,i));else return n&&this.#O(i),r&&(r.has=`hit`,this.#k(r,i)),!0}else r&&(r.has=`miss`);return!1}peek(e,t={}){let{allowStale:n=this.allowStale}=t,r=this.#u.get(e);if(r===void 0||!n&&this.#j(r))return;let i=this.#f[r];return this.#V(i)?i.__staleWhileFetching:i}#B(e,t,n,r){let i=t===void 0?void 0:this.#f[t];if(this.#V(i))return i;let a=new on,{signal:o}=n;o?.addEventListener(`abort`,()=>a.abort(o.reason),{signal:a.signal});let s={signal:a.signal,options:n,context:r},c=(r,i=!1)=>{let{aborted:o}=a.signal,c=n.ignoreFetchAbort&&r!==void 0,l=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&r!==void 0);if(n.status&&(o&&!i?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,c&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),o&&!c&&!i)return u(a.signal.reason,l);let d=f,p=this.#f[t];return(p===f||c&&i&&p===void 0)&&(r===void 0?d.__staleWhileFetching===void 0?this.#W(e,`fetch`):this.#f[t]=d.__staleWhileFetching:(n.status&&(n.status.fetchUpdated=!0),this.set(e,r,s.options))),r},l=e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),u(e,!1)),u=(r,i)=>{let{aborted:o}=a.signal,s=o&&n.allowStaleOnFetchAbort,c=s||n.allowStaleOnFetchRejection,l=c||n.noDeleteOnFetchRejection,u=f;if(this.#f[t]===f&&(!l||!i&&u.__staleWhileFetching===void 0?this.#W(e,`fetch`):s||(this.#f[t]=u.__staleWhileFetching)),c)return n.status&&u.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),u.__staleWhileFetching;if(u.__returned===u)throw r},d=(t,r)=>{let o=this.#a?.(e,i,s);o&&o instanceof Promise&&o.then(e=>t(e===void 0?void 0:e),r),a.signal.addEventListener(`abort`,()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>c(e,!0)))})};n.status&&(n.status.fetchDispatched=!0);let f=new Promise(d).then(c,l),p=Object.assign(f,{__abortController:a,__staleWhileFetching:i,__returned:void 0});return t===void 0?(this.set(e,p,{...s.options,status:void 0}),t=this.#u.get(e)):this.#f[t]=p,p}#V(e){if(!this.#w)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty(`__staleWhileFetching`)&&t.__abortController instanceof on}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:s=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:h=!1,status:g,signal:ee}=t;if(!this.#w)return g&&(g.fetch=`get`),this.get(e,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:g});let _={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:a,noDisposeOnSet:o,size:s,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:p,ignoreFetchAbort:f,status:g,signal:ee},v=this.#u.get(e);if(v===void 0){g&&(g.fetch=`miss`);let t=this.#B(e,v,_,m);return t.__returned=t}else{let t=this.#f[v];if(this.#V(t)){let e=n&&t.__staleWhileFetching!==void 0;return g&&(g.fetch=`inflight`,e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let i=this.#j(v);if(!h&&!i)return g&&(g.fetch=`hit`),this.#U(v),r&&this.#O(v),g&&this.#k(g,v),t;let a=this.#B(e,v,_,m),o=a.__staleWhileFetching!==void 0&&n;return g&&(g.fetch=i?`stale`:`refresh`,o&&i&&(g.returnedStale=!0)),o?a.__staleWhileFetching:a.__returned=a}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw Error(`fetch() returned undefined`);return n}memo(e,t={}){let n=this.#o;if(!n)throw Error(`no memoMethod provided to constructor`);let{context:r,forceRefresh:i,...a}=t,o=this.get(e,a);if(!i&&o!==void 0)return o;let s=n(e,o,{options:a,context:r});return this.set(e,s,a),s}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:a}=t,o=this.#u.get(e);if(o!==void 0){let t=this.#f[o],s=this.#V(t);return a&&this.#k(a,o),this.#j(o)?(a&&(a.get=`stale`),s?(a&&n&&t.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?t.__staleWhileFetching:void 0):(i||this.#W(e,`expire`),a&&n&&(a.returnedStale=!0),n?t:void 0)):(a&&(a.get=`hit`),s?t.__staleWhileFetching:(this.#U(o),r&&this.#O(o),t))}else a&&(a.get=`miss`)}#H(e,t){this.#m[t]=e,this.#p[e]=t}#U(e){e!==this.#g&&(e===this.#h?this.#h=this.#p[e]:this.#H(this.#m[e],this.#p[e]),this.#H(this.#g,e),this.#g=e)}delete(e){return this.#W(e,`delete`)}#W(e,t){let n=!1;if(this.#c!==0){let r=this.#u.get(e);if(r!==void 0)if(this.#S?.[r]&&(clearTimeout(this.#S?.[r]),this.#S[r]=void 0),n=!0,this.#c===1)this.#G(t);else{this.#N(r);let n=this.#f[r];if(this.#V(n)?n.__abortController.abort(Error(`deleted`)):(this.#C||this.#T)&&(this.#C&&this.#n?.(n,e,t),this.#T&&this.#v?.push([n,e,t])),this.#u.delete(e),this.#d[r]=void 0,this.#f[r]=void 0,r===this.#g)this.#g=this.#m[r];else if(r===this.#h)this.#h=this.#p[r];else{let e=this.#m[r];this.#p[e]=this.#p[r];let t=this.#p[r];this.#m[t]=this.#m[r]}this.#c--,this.#_.push(r)}}if(this.#T&&this.#v?.length){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}return n}clear(){return this.#G(`delete`)}#G(e){for(let t of this.#L({allowStale:!0})){let n=this.#f[t];if(this.#V(n))n.__abortController.abort(Error(`deleted`));else{let r=this.#d[t];this.#C&&this.#n?.(n,r,e),this.#T&&this.#v?.push([n,r,e])}}if(this.#u.clear(),this.#f.fill(void 0),this.#d.fill(void 0),this.#x&&this.#b){this.#x.fill(0),this.#b.fill(0);for(let e of this.#S??[])e!==void 0&&clearTimeout(e);this.#S?.fill(void 0)}if(this.#y&&this.#y.fill(0),this.#h=0,this.#g=0,this.#_.length=0,this.#l=0,this.#c=0,this.#T&&this.#v){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}}},mn=typeof process==`object`&&process?process:{stdout:null,stderr:null},hn=e=>!!e&&typeof e==`object`&&(e instanceof Xn||e instanceof Te||gn(e)||_n(e)),gn=e=>!!e&&typeof e==`object`&&e instanceof we&&typeof e.pipe==`function`&&e.pipe!==Te.Writable.prototype.pipe,_n=e=>!!e&&typeof e==`object`&&e instanceof we&&typeof e.write==`function`&&typeof e.end==`function`,vn=Symbol(`EOF`),yn=Symbol(`maybeEmitEnd`),bn=Symbol(`emittedEnd`),xn=Symbol(`emittingEnd`),Sn=Symbol(`emittedError`),Cn=Symbol(`closed`),wn=Symbol(`read`),Tn=Symbol(`flush`),En=Symbol(`flushChunk`),I=Symbol(`encoding`),Dn=Symbol(`decoder`),L=Symbol(`flowing`),On=Symbol(`paused`),kn=Symbol(`resume`),R=Symbol(`buffer`),z=Symbol(`pipes`),B=Symbol(`bufferLength`),An=Symbol(`bufferPush`),jn=Symbol(`bufferShift`),V=Symbol(`objectMode`),H=Symbol(`destroyed`),Mn=Symbol(`error`),Nn=Symbol(`emitData`),Pn=Symbol(`emitEnd`),Fn=Symbol(`emitEnd2`),In=Symbol(`async`),Ln=Symbol(`abort`),Rn=Symbol(`aborted`),zn=Symbol(`signal`),Bn=Symbol(`dataListeners`),U=Symbol(`discarded`),Vn=e=>Promise.resolve().then(e),Hn=e=>e(),Un=e=>e===`end`||e===`finish`||e===`prefinish`,Wn=e=>e instanceof ArrayBuffer||!!e&&typeof e==`object`&&e.constructor&&e.constructor.name===`ArrayBuffer`&&e.byteLength>=0,Gn=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),Kn=class{src;dest;opts;ondrain;constructor(e,t,n){this.src=e,this.dest=t,this.opts=n,this.ondrain=()=>e[kn](),this.dest.on(`drain`,this.ondrain)}unpipe(){this.dest.removeListener(`drain`,this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},qn=class extends Kn{unpipe(){this.src.removeListener(`error`,this.proxyErrors),super.unpipe()}constructor(e,t,n){super(e,t,n),this.proxyErrors=e=>this.dest.emit(`error`,e),e.on(`error`,this.proxyErrors)}},Jn=e=>!!e.objectMode,Yn=e=>!e.objectMode&&!!e.encoding&&e.encoding!==`buffer`,Xn=class extends we{[L]=!1;[On]=!1;[z]=[];[R]=[];[V];[I];[In];[Dn];[vn]=!1;[bn]=!1;[xn]=!1;[Cn]=!1;[Sn]=null;[B]=0;[H]=!1;[zn];[Rn]=!1;[Bn]=0;[U]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding==`string`)throw TypeError(`Encoding and objectMode may not be used together`);Jn(t)?(this[V]=!0,this[I]=null):Yn(t)?(this[I]=t.encoding,this[V]=!1):(this[V]=!1,this[I]=null),this[In]=!!t.async,this[Dn]=this[I]?new Ee(this[I]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[R]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[z]});let{signal:n}=t;n&&(this[zn]=n,n.aborted?this[Ln]():n.addEventListener(`abort`,()=>this[Ln]()))}get bufferLength(){return this[B]}get encoding(){return this[I]}set encoding(e){throw Error(`Encoding must be set at instantiation time`)}setEncoding(e){throw Error(`Encoding must be set at instantiation time`)}get objectMode(){return this[V]}set objectMode(e){throw Error(`objectMode must be set at instantiation time`)}get async(){return this[In]}set async(e){this[In]=this[In]||!!e}[Ln](){this[Rn]=!0,this.emit(`abort`,this[zn]?.reason),this.destroy(this[zn]?.reason)}get aborted(){return this[Rn]}set aborted(e){}write(e,t,n){if(this[Rn])return!1;if(this[vn])throw Error(`write after end`);if(this[H])return this.emit(`error`,Object.assign(Error(`Cannot call write after a stream was destroyed`),{code:`ERR_STREAM_DESTROYED`})),!0;typeof t==`function`&&(n=t,t=`utf8`),t||=`utf8`;let r=this[In]?Vn:Hn;if(!this[V]&&!Buffer.isBuffer(e)){if(Gn(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(Wn(e))e=Buffer.from(e);else if(typeof e!=`string`)throw Error(`Non-contiguous data written to non-objectMode stream`)}return this[V]?(this[L]&&this[B]!==0&&this[Tn](!0),this[L]?this.emit(`data`,e):this[An](e),this[B]!==0&&this.emit(`readable`),n&&r(n),this[L]):e.length?(typeof e==`string`&&!(t===this[I]&&!this[Dn]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[I]&&(e=this[Dn].write(e)),this[L]&&this[B]!==0&&this[Tn](!0),this[L]?this.emit(`data`,e):this[An](e),this[B]!==0&&this.emit(`readable`),n&&r(n),this[L]):(this[B]!==0&&this.emit(`readable`),n&&r(n),this[L])}read(e){if(this[H])return null;if(this[U]=!1,this[B]===0||e===0||e&&e>this[B])return this[yn](),null;this[V]&&(e=null),this[R].length>1&&!this[V]&&(this[R]=[this[I]?this[R].join(``):Buffer.concat(this[R],this[B])]);let t=this[wn](e||null,this[R][0]);return this[yn](),t}[wn](e,t){if(this[V])this[jn]();else{let n=t;e===n.length||e===null?this[jn]():typeof n==`string`?(this[R][0]=n.slice(e),t=n.slice(0,e),this[B]-=e):(this[R][0]=n.subarray(e),t=n.subarray(0,e),this[B]-=e)}return this.emit(`data`,t),!this[R].length&&!this[vn]&&this.emit(`drain`),t}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=`utf8`),e!==void 0&&this.write(e,t),n&&this.once(`end`,n),this[vn]=!0,this.writable=!1,(this[L]||!this[On])&&this[yn](),this}[kn](){this[H]||(!this[Bn]&&!this[z].length&&(this[U]=!0),this[On]=!1,this[L]=!0,this.emit(`resume`),this[R].length?this[Tn]():this[vn]?this[yn]():this.emit(`drain`))}resume(){return this[kn]()}pause(){this[L]=!1,this[On]=!0,this[U]=!1}get destroyed(){return this[H]}get flowing(){return this[L]}get paused(){return this[On]}[An](e){this[V]?this[B]+=1:this[B]+=e.length,this[R].push(e)}[jn](){return this[V]?--this[B]:this[B]-=this[R][0].length,this[R].shift()}[Tn](e=!1){do;while(this[En](this[jn]())&&this[R].length);!e&&!this[R].length&&!this[vn]&&this.emit(`drain`)}[En](e){return this.emit(`data`,e),this[L]}pipe(e,t){if(this[H])return e;this[U]=!1;let n=this[bn];return t||={},e===mn.stdout||e===mn.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,n?t.end&&e.end():(this[z].push(t.proxyErrors?new qn(this,e,t):new Kn(this,e,t)),this[In]?Vn(()=>this[kn]()):this[kn]()),e}unpipe(e){let t=this[z].find(t=>t.dest===e);t&&(this[z].length===1?(this[L]&&this[Bn]===0&&(this[L]=!1),this[z]=[]):this[z].splice(this[z].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let n=super.on(e,t);if(e===`data`)this[U]=!1,this[Bn]++,!this[z].length&&!this[L]&&this[kn]();else if(e===`readable`&&this[B]!==0)super.emit(`readable`);else if(Un(e)&&this[bn])super.emit(e),this.removeAllListeners(e);else if(e===`error`&&this[Sn]){let e=t;this[In]?Vn(()=>e.call(this,this[Sn])):e.call(this,this[Sn])}return n}removeListener(e,t){return this.off(e,t)}off(e,t){let n=super.off(e,t);return e===`data`&&(this[Bn]=this.listeners(`data`).length,this[Bn]===0&&!this[U]&&!this[z].length&&(this[L]=!1)),n}removeAllListeners(e){let t=super.removeAllListeners(e);return(e===`data`||e===void 0)&&(this[Bn]=0,!this[U]&&!this[z].length&&(this[L]=!1)),t}get emittedEnd(){return this[bn]}[yn](){!this[xn]&&!this[bn]&&!this[H]&&this[R].length===0&&this[vn]&&(this[xn]=!0,this.emit(`end`),this.emit(`prefinish`),this.emit(`finish`),this[Cn]&&this.emit(`close`),this[xn]=!1)}emit(e,...t){let n=t[0];if(e!==`error`&&e!==`close`&&e!==H&&this[H])return!1;if(e===`data`)return!this[V]&&!n?!1:this[In]?(Vn(()=>this[Nn](n)),!0):this[Nn](n);if(e===`end`)return this[Pn]();if(e===`close`){if(this[Cn]=!0,!this[bn]&&!this[H])return!1;let e=super.emit(`close`);return this.removeAllListeners(`close`),e}else if(e===`error`){this[Sn]=n,super.emit(Mn,n);let e=!this[zn]||this.listeners(`error`).length?super.emit(`error`,n):!1;return this[yn](),e}else if(e===`resume`){let e=super.emit(`resume`);return this[yn](),e}else if(e===`finish`||e===`prefinish`){let t=super.emit(e);return this.removeAllListeners(e),t}let r=super.emit(e,...t);return this[yn](),r}[Nn](e){for(let t of this[z])t.dest.write(e)===!1&&this.pause();let t=!this[U]&&super.emit(`data`,e);return this[yn](),t}[Pn](){return this[bn]?!1:(this[bn]=!0,this.readable=!1,this[In]?(Vn(()=>this[Fn]()),!0):this[Fn]())}[Fn](){if(this[Dn]){let e=this[Dn].end();if(e){for(let t of this[z])t.dest.write(e);this[U]||super.emit(`data`,e)}}for(let e of this[z])e.end();let e=super.emit(`end`);return this.removeAllListeners(`end`),e}async collect(){let e=Object.assign([],{dataLength:0});this[V]||(e.dataLength=0);let t=this.promise();return this.on(`data`,t=>{e.push(t),this[V]||(e.dataLength+=t.length)}),await t,e}async concat(){if(this[V])throw Error(`cannot concat in objectMode`);let e=await this.collect();return this[I]?e.join(``):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(H,()=>t(Error(`stream destroyed`))),this.on(`error`,e=>t(e)),this.on(`end`,()=>e())})}[Symbol.asyncIterator](){this[U]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[vn])return t();let r,i,a=e=>{this.off(`data`,o),this.off(`end`,s),this.off(H,c),t(),i(e)},o=e=>{this.off(`error`,a),this.off(`end`,s),this.off(H,c),this.pause(),r({value:e,done:!!this[vn]})},s=()=>{this.off(`error`,a),this.off(`data`,o),this.off(H,c),t(),r({done:!0,value:void 0})},c=()=>a(Error(`stream destroyed`));return new Promise((e,t)=>{i=t,r=e,this.once(H,c),this.once(`error`,a),this.once(`end`,s),this.once(`data`,o)})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[U]=!1;let e=!1,t=()=>(this.pause(),this.off(Mn,t),this.off(H,t),this.off(`end`,t),e=!0,{done:!0,value:void 0});return this.once(`end`,t),this.once(Mn,t),this.once(H,t),{next:()=>{if(e)return t();let n=this.read();return n===null?t():{done:!1,value:n}},throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[H])return e?this.emit(`error`,e):this.emit(H),this;this[H]=!0,this[U]=!0,this[R].length=0,this[B]=0;let t=this;return typeof t.close==`function`&&!this[Cn]&&t.close(),e?this.emit(`error`,e):this.emit(H),this}static get isStream(){return hn}},Zn={lstatSync:pe,readdir:he,readdirSync:ge,readlinkSync:_e,realpathSync:ve.native,promises:{lstat:oe,readdir:se,readlink:ce,realpath:le}},Qn=e=>!e||e===Zn||e===v?Zn:{...Zn,...e,promises:{...Zn.promises,...e.promises||{}}},$n=/^\\\\\?\\([a-z]:)\\?$/i,er=e=>e.replace(/\//g,`\\`).replace($n,`$1\\`),tr=/[\\\/]/,W=0,nr=1,rr=2,ir=4,ar=6,or=8,sr=10,cr=12,G=15,lr=~G,ur=16,dr=32,fr=64,K=128,pr=256,mr=512,hr=fr|K|mr,gr=1023,_r=e=>e.isFile()?or:e.isDirectory()?ir:e.isSymbolicLink()?sr:e.isCharacterDevice()?rr:e.isBlockDevice()?ar:e.isSocket()?cr:e.isFIFO()?nr:W,vr=new pn({max:2**12}),yr=e=>{let t=vr.get(e);if(t)return t;let n=e.normalize(`NFKD`);return vr.set(e,n),n},br=new pn({max:2**12}),xr=e=>{let t=br.get(e);if(t)return t;let n=yr(e.toLowerCase());return br.set(e,n),n},Sr=class extends pn{constructor(){super({max:256})}},Cr=class extends pn{constructor(e=16*1024){super({maxSize:e,sizeCalculation:e=>e.length+1})}},wr=Symbol(`PathScurry setAsCwd`),q=class{name;root;roots;parent;nocase;isCWD=!1;#e;#t;get dev(){return this.#t}#n;get mode(){return this.#n}#r;get nlink(){return this.#r}#i;get uid(){return this.#i}#a;get gid(){return this.#a}#o;get rdev(){return this.#o}#s;get blksize(){return this.#s}#c;get ino(){return this.#c}#l;get size(){return this.#l}#u;get blocks(){return this.#u}#d;get atimeMs(){return this.#d}#f;get mtimeMs(){return this.#f}#p;get ctimeMs(){return this.#p}#m;get birthtimeMs(){return this.#m}#h;get atime(){return this.#h}#g;get mtime(){return this.#g}#_;get ctime(){return this.#_}#v;get birthtime(){return this.#v}#y;#b;#x;#S;#C;#w;#T;#E;#D;#O;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=W,n,r,i,a,o){this.name=e,this.#y=i?xr(e):yr(e),this.#T=t&gr,this.nocase=i,this.roots=r,this.root=n||this,this.#E=a,this.#x=o.fullpath,this.#C=o.relative,this.#w=o.relativePosix,this.parent=o.parent,this.parent?this.#e=this.parent.#e:this.#e=Qn(o.fs)}depth(){return this.#b===void 0?this.parent?this.#b=this.parent.depth()+1:this.#b=0:this.#b}childrenCache(){return this.#E}resolve(e){if(!e)return this;let t=this.getRootString(e),n=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#k(n):this.#k(n)}#k(e){let t=this;for(let n of e)t=t.child(n);return t}children(){let e=this.#E.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#E.set(this,t),this.#T&=~ur,t}child(e,t){if(e===``||e===`.`)return this;if(e===`..`)return this.parent||this;let n=this.children(),r=this.nocase?xr(e):yr(e);for(let e of n)if(e.#y===r)return e;let i=this.parent?this.sep:``,a=this.#x?this.#x+i+e:void 0,o=this.newChild(e,W,{...t,parent:this,fullpath:a});return this.canReaddir()||(o.#T|=K),n.push(o),o}relative(){if(this.isCWD)return``;if(this.#C!==void 0)return this.#C;let e=this.name,t=this.parent;if(!t)return this.#C=this.name;let n=t.relative();return n+(!n||!t.parent?``:this.sep)+e}relativePosix(){if(this.sep===`/`)return this.relative();if(this.isCWD)return``;if(this.#w!==void 0)return this.#w;let e=this.name,t=this.parent;if(!t)return this.#w=this.fullpathPosix();let n=t.relativePosix();return n+(!n||!t.parent?``:`/`)+e}fullpath(){if(this.#x!==void 0)return this.#x;let e=this.name,t=this.parent;if(!t)return this.#x=this.name;let n=t.fullpath()+(t.parent?this.sep:``)+e;return this.#x=n}fullpathPosix(){if(this.#S!==void 0)return this.#S;if(this.sep===`/`)return this.#S=this.fullpath();if(!this.parent){let e=this.fullpath().replace(/\\/g,`/`);return/^[a-z]:\//i.test(e)?this.#S=`//?/${e}`:this.#S=e}let e=this.parent,t=e.fullpathPosix(),n=t+(!t||!e.parent?``:`/`)+this.name;return this.#S=n}isUnknown(){return(this.#T&G)===W}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?`Unknown`:this.isDirectory()?`Directory`:this.isFile()?`File`:this.isSymbolicLink()?`SymbolicLink`:this.isFIFO()?`FIFO`:this.isCharacterDevice()?`CharacterDevice`:this.isBlockDevice()?`BlockDevice`:this.isSocket()?`Socket`:`Unknown`}isFile(){return(this.#T&G)===or}isDirectory(){return(this.#T&G)===ir}isCharacterDevice(){return(this.#T&G)===rr}isBlockDevice(){return(this.#T&G)===ar}isFIFO(){return(this.#T&G)===nr}isSocket(){return(this.#T&G)===cr}isSymbolicLink(){return(this.#T&sr)===sr}lstatCached(){return this.#T&dr?this:void 0}readlinkCached(){return this.#D}realpathCached(){return this.#O}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#D)return!0;if(!this.parent)return!1;let e=this.#T&G;return!(e!==W&&e!==sr||this.#T&pr||this.#T&K)}calledReaddir(){return!!(this.#T&ur)}isENOENT(){return!!(this.#T&K)}isNamed(e){return this.nocase?this.#y===xr(e):this.#y===yr(e)}async readlink(){let e=this.#D;if(e)return e;if(this.canReadlink()&&this.parent)try{let e=await this.#e.promises.readlink(this.fullpath()),t=(await this.parent.realpath())?.resolve(e);if(t)return this.#D=t}catch(e){this.#L(e.code);return}}readlinkSync(){let e=this.#D;if(e)return e;if(this.canReadlink()&&this.parent)try{let e=this.#e.readlinkSync(this.fullpath()),t=this.parent.realpathSync()?.resolve(e);if(t)return this.#D=t}catch(e){this.#L(e.code);return}}#A(e){this.#T|=ur;for(let t=e.provisional;t<e.length;t++){let n=e[t];n&&n.#j()}}#j(){this.#T&K||(this.#T=(this.#T|K)&lr,this.#M())}#M(){let e=this.children();e.provisional=0;for(let t of e)t.#j()}#N(){this.#T|=mr,this.#P()}#P(){if(this.#T&fr)return;let e=this.#T;(e&G)===ir&&(e&=lr),this.#T=e|fr,this.#M()}#F(e=``){e===`ENOTDIR`||e===`EPERM`?this.#P():e===`ENOENT`?this.#j():this.children().provisional=0}#I(e=``){e===`ENOTDIR`?this.parent.#P():e===`ENOENT`&&this.#j()}#L(e=``){let t=this.#T;t|=pr,e===`ENOENT`&&(t|=K),(e===`EINVAL`||e===`UNKNOWN`)&&(t&=lr),this.#T=t,e===`ENOTDIR`&&this.parent&&this.parent.#P()}#R(e,t){return this.#B(e,t)||this.#z(e,t)}#z(e,t){let n=_r(e),r=this.newChild(e.name,n,{parent:this}),i=r.#T&G;return i!==ir&&i!==sr&&i!==W&&(r.#T|=fr),t.unshift(r),t.provisional++,r}#B(e,t){for(let n=t.provisional;n<t.length;n++){let r=t[n];if((this.nocase?xr(e.name):yr(e.name))===r.#y)return this.#V(e,r,n,t)}}#V(e,t,n,r){let i=t.name;return t.#T=t.#T&lr|_r(e),i!==e.name&&(t.name=e.name),n!==r.provisional&&(n===r.length-1?r.pop():r.splice(n,1),r.unshift(t)),r.provisional++,t}async lstat(){if((this.#T&K)===0)try{return this.#H(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#I(e.code)}}lstatSync(){if((this.#T&K)===0)try{return this.#H(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#I(e.code)}}#H(e){let{atime:t,atimeMs:n,birthtime:r,birthtimeMs:i,blksize:a,blocks:o,ctime:s,ctimeMs:c,dev:l,gid:u,ino:d,mode:f,mtime:p,mtimeMs:m,nlink:h,rdev:g,size:ee,uid:_}=e;this.#h=t,this.#d=n,this.#v=r,this.#m=i,this.#s=a,this.#u=o,this.#_=s,this.#p=c,this.#t=l,this.#a=u,this.#c=d,this.#n=f,this.#g=p,this.#f=m,this.#r=h,this.#o=g,this.#l=ee,this.#i=_;let v=_r(e);this.#T=this.#T&lr|v|dr,v!==W&&v!==ir&&v!==sr&&(this.#T|=fr)}#U=[];#W=!1;#G(e){this.#W=!1;let t=this.#U.slice();this.#U.length=0,t.forEach(t=>t(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let n=this.children();if(this.calledReaddir()){let r=n.slice(0,n.provisional);t?e(null,r):queueMicrotask(()=>e(null,r));return}if(this.#U.push(e),this.#W)return;this.#W=!0;let r=this.fullpath();this.#e.readdir(r,{withFileTypes:!0},(e,t)=>{if(e)this.#F(e.code),n.provisional=0;else{for(let e of t)this.#R(e,n);this.#A(n)}this.#G(n.slice(0,n.provisional))})}#K;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#K)await this.#K;else{let n=()=>{};this.#K=new Promise(e=>n=e);try{for(let n of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#R(n,e);this.#A(e)}catch(t){this.#F(t.code),e.provisional=0}this.#K=void 0,n()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let n of this.#e.readdirSync(t,{withFileTypes:!0}))this.#R(n,e);this.#A(e)}catch(t){this.#F(t.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#T&hr)return!1;let e=G&this.#T;return e===W||e===ir||e===sr}shouldWalk(e,t){return(this.#T&ir)===ir&&!(this.#T&hr)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#O)return this.#O;if(!((mr|pr|K)&this.#T))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#O=this.resolve(e)}catch{this.#N()}}realpathSync(){if(this.#O)return this.#O;if(!((mr|pr|K)&this.#T))try{let e=this.#e.realpathSync(this.fullpath());return this.#O=this.resolve(e)}catch{this.#N()}}[wr](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),n=[],r=this;for(;r&&r.parent;)t.add(r),r.#C=n.join(this.sep),r.#w=n.join(`/`),r=r.parent,n.push(`..`);for(r=e;r&&r.parent&&!t.has(r);)r.#C=void 0,r.#w=void 0,r=r.parent}},Tr=class e extends q{sep=`\\`;splitSep=tr;constructor(e,t=W,n,r,i,a,o){super(e,t,n,r,i,a,o)}newChild(t,n=W,r={}){return new e(t,n,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(e){return S.parse(e).root}getRoot(e){if(e=er(e.toUpperCase()),e===this.root.name)return this.root;for(let[t,n]of Object.entries(this.roots))if(this.sameRoot(e,t))return this.roots[e]=n;return this.roots[e]=new Or(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,`\\`).replace($n,`$1\\`),e===t}},Er=class e extends q{splitSep=`/`;sep=`/`;constructor(e,t=W,n,r,i,a,o){super(e,t,n,r,i,a,o)}getRootString(e){return e.startsWith(`/`)?`/`:``}getRoot(e){return this.root}newChild(t,n=W,r={}){return new e(t,n,this.root,this.roots,this.nocase,this.childrenCache(),r)}},Dr=class{root;rootPath;roots;cwd;#e;#t;#n;nocase;#r;constructor(e=process.cwd(),t,n,{nocase:r,childrenCacheSize:i=16*1024,fs:a=Zn}={}){this.#r=Qn(a),(e instanceof URL||e.startsWith(`file://`))&&(e=C(e));let o=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(o),this.#e=new Sr,this.#t=new Sr,this.#n=new Cr(i);let s=o.substring(this.rootPath.length).split(n);if(s.length===1&&!s[0]&&s.pop(),r===void 0)throw TypeError(`must provide nocase setting to PathScurryBase ctor`);this.nocase=r,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let c=this.root,l=s.length-1,u=t.sep,d=this.rootPath,f=!1;for(let e of s){let t=l--;c=c.child(e,{relative:Array(t).fill(`..`).join(u),relativePosix:Array(t).fill(`..`).join(`/`),fullpath:d+=(f?``:u)+e}),f=!0}this.cwd=c}depth(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#n}resolve(...e){let t=``;for(let n=e.length-1;n>=0;n--){let r=e[n];if(!(!r||r===`.`)&&(t=t?`${r}/${t}`:r,this.isAbsolute(r)))break}let n=this.#e.get(t);if(n!==void 0)return n;let r=this.cwd.resolve(t).fullpath();return this.#e.set(t,r),r}resolvePosix(...e){let t=``;for(let n=e.length-1;n>=0;n--){let r=e[n];if(!(!r||r===`.`)&&(t=t?`${r}/${t}`:r,this.isAbsolute(r)))break}let n=this.#t.get(t);if(n!==void 0)return n;let r=this.cwd.resolve(t).fullpathPosix();return this.#t.set(t,r),r}relative(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:n}=t;if(e.canReaddir()){let t=await e.readdir();return n?t:t.map(e=>e.name)}else return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:n=!0}=t;return e.canReaddir()?n?e.readdirSync():e.readdirSync().map(e=>e.name):[]}async lstat(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e==`string`&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof q||(t=e.withFileTypes,e=this.cwd);let n=await e.readlink();return t?n:n?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof q||(t=e.withFileTypes,e=this.cwd);let n=e.readlinkSync();return t?n:n?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof q||(t=e.withFileTypes,e=this.cwd);let n=await e.realpath();return t?n:n?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof q||(t=e.withFileTypes,e=this.cwd);let n=e.realpathSync();return t?n:n?.fullpath()}async walk(e=this.cwd,t={}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:r=!1,filter:i,walkFilter:a}=t,o=[];(!i||i(e))&&o.push(n?e:e.fullpath());let s=new Set,c=(e,t)=>{s.add(e),e.readdirCB((e,l)=>{if(e)return t(e);let u=l.length;if(!u)return t();let d=()=>{--u===0&&t()};for(let e of l)(!i||i(e))&&o.push(n?e:e.fullpath()),r&&e.isSymbolicLink()?e.realpath().then(e=>e?.isUnknown()?e.lstat():e).then(e=>e?.shouldWalk(s,a)?c(e,d):d()):e.shouldWalk(s,a)?c(e,d):d()},!0)},l=e;return new Promise((e,t)=>{c(l,n=>{if(n)return t(n);e(o)})})}walkSync(e=this.cwd,t={}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:r=!1,filter:i,walkFilter:a}=t,o=[];(!i||i(e))&&o.push(n?e:e.fullpath());let s=new Set([e]);for(let e of s){let t=e.readdirSync();for(let e of t){(!i||i(e))&&o.push(n?e:e.fullpath());let t=e;if(e.isSymbolicLink()){if(!(r&&(t=e.realpathSync())))continue;t.isUnknown()&&t.lstatSync()}t.shouldWalk(s,a)&&s.add(t)}}return o}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e==`string`?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:r=!1,filter:i,walkFilter:a}=t;(!i||i(e))&&(yield n?e:e.fullpath());let o=new Set([e]);for(let e of o){let t=e.readdirSync();for(let e of t){(!i||i(e))&&(yield n?e:e.fullpath());let t=e;if(e.isSymbolicLink()){if(!(r&&(t=e.realpathSync())))continue;t.isUnknown()&&t.lstatSync()}t.shouldWalk(o,a)&&o.add(t)}}}stream(e=this.cwd,t={}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:r=!1,filter:i,walkFilter:a}=t,o=new Xn({objectMode:!0});(!i||i(e))&&o.write(n?e:e.fullpath());let s=new Set,c=[e],l=0,u=()=>{let e=!1;for(;!e;){let t=c.shift();if(!t){l===0&&o.end();return}l++,s.add(t);let d=(t,p,m=!1)=>{if(t)return o.emit(`error`,t);if(r&&!m){let e=[];for(let t of p)t.isSymbolicLink()&&e.push(t.realpath().then(e=>e?.isUnknown()?e.lstat():e));if(e.length){Promise.all(e).then(()=>d(null,p,!0));return}}for(let t of p)t&&(!i||i(t))&&(o.write(n?t:t.fullpath())||(e=!0));l--;for(let e of p){let t=e.realpathCached()||e;t.shouldWalk(s,a)&&c.push(t)}e&&!o.flowing?o.once(`drain`,u):f||u()},f=!0;t.readdirCB(d,!0),f=!1}};return u(),o}streamSync(e=this.cwd,t={}){typeof e==`string`?e=this.cwd.resolve(e):e instanceof q||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:r=!1,filter:i,walkFilter:a}=t,o=new Xn({objectMode:!0}),s=new Set;(!i||i(e))&&o.write(n?e:e.fullpath());let c=[e],l=0,u=()=>{let e=!1;for(;!e;){let t=c.shift();if(!t){l===0&&o.end();return}l++,s.add(t);let u=t.readdirSync();for(let t of u)(!i||i(t))&&(o.write(n?t:t.fullpath())||(e=!0));l--;for(let e of u){let t=e;if(e.isSymbolicLink()){if(!(r&&(t=e.realpathSync())))continue;t.isUnknown()&&t.lstatSync()}t.shouldWalk(s,a)&&c.push(t)}}e&&!o.flowing&&o.once(`drain`,u)};return u(),o}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e==`string`?this.cwd.resolve(e):e,this.cwd[wr](t)}},Or=class extends Dr{sep=`\\`;constructor(e=process.cwd(),t={}){let{nocase:n=!0}=t;super(e,S,`\\`,{...t,nocase:n}),this.nocase=n;for(let e=this.cwd;e;e=e.parent)e.nocase=this.nocase}parseRootPath(e){return S.parse(e).root.toUpperCase()}newRoot(e){return new Tr(this.rootPath,ir,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith(`/`)||e.startsWith(`\\`)||/^[a-z]:(\/|\\)/i.test(e)}},kr=class extends Dr{sep=`/`;constructor(e=process.cwd(),t={}){let{nocase:n=!1}=t;super(e,x,`/`,{...t,nocase:n}),this.nocase=n}parseRootPath(e){return`/`}newRoot(e){return new Er(this.rootPath,ir,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith(`/`)}},Ar=class extends kr{constructor(e=process.cwd(),t={}){let{nocase:n=!0}=t;super(e,{...t,nocase:n})}};process.platform;var jr=process.platform===`win32`?Or:process.platform===`darwin`?Ar:kr,Mr=e=>e.length>=1,Nr=e=>e.length>=1,Pr=Symbol.for(`nodejs.util.inspect.custom`),Fr=class e{#e;#t;#n;length;#r;#i;#a;#o;#s;#c;#l=!0;constructor(e,t,n,r){if(!Mr(e))throw TypeError(`empty pattern list`);if(!Nr(t))throw TypeError(`empty glob list`);if(t.length!==e.length)throw TypeError(`mismatched pattern list and glob list lengths`);if(this.length=e.length,n<0||n>=this.length)throw TypeError(`index out of range`);if(this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#n===0){if(this.isUNC()){let[e,t,n,r,...i]=this.#e,[a,o,s,c,...l]=this.#t;i[0]===``&&(i.shift(),l.shift());let u=[e,t,n,r,``].join(`/`),d=[a,o,s,c,``].join(`/`);this.#e=[u,...i],this.#t=[d,...l],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[e,...t]=this.#e,[n,...r]=this.#t;t[0]===``&&(t.shift(),r.shift());let i=e+`/`,a=n+`/`;this.#e=[i,...t],this.#t=[a,...r],this.length=this.#e.length}}}[Pr](){return`Pattern <`+this.#t.slice(this.#n).join(`/`)+`>`}pattern(){return this.#e[this.#n]}isString(){return typeof this.#e[this.#n]==`string`}isGlobstar(){return this.#e[this.#n]===P}isRegExp(){return this.#e[this.#n]instanceof RegExp}globString(){return this.#a=this.#a||(this.#n===0?this.isAbsolute()?this.#t[0]+this.#t.slice(1).join(`/`):this.#t.join(`/`):this.#t.slice(this.#n).join(`/`))}hasMore(){return this.length>this.#n+1}rest(){return this.#i===void 0?this.hasMore()?(this.#i=new e(this.#e,this.#t,this.#n+1,this.#r),this.#i.#c=this.#c,this.#i.#s=this.#s,this.#i.#o=this.#o,this.#i):this.#i=null:this.#i}isUNC(){let e=this.#e;return this.#s===void 0?this.#s=this.#r===`win32`&&this.#n===0&&e[0]===``&&e[1]===``&&typeof e[2]==`string`&&!!e[2]&&typeof e[3]==`string`&&!!e[3]:this.#s}isDrive(){let e=this.#e;return this.#o===void 0?this.#o=this.#r===`win32`&&this.#n===0&&this.length>1&&typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]):this.#o}isAbsolute(){let e=this.#e;return this.#c===void 0?this.#c=e[0]===``&&e.length>1||this.isDrive()||this.isUNC():this.#c}root(){let e=this.#e[0];return typeof e==`string`&&this.isAbsolute()&&this.#n===0?e:``}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#l)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#l?!1:(this.#l=!1,!0)}},Ir=typeof process==`object`&&process&&typeof process.platform==`string`?process.platform:`linux`,Lr=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:n,noext:r,noglobstar:i,platform:a=Ir}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=a,this.mmopts={dot:!0,nobrace:t,nocase:n,noext:r,noglobstar:i,optimizationLevel:2,platform:a,nocomment:!0,nonegate:!0};for(let t of e)this.add(t)}add(e){let t=new en(e,this.mmopts);for(let e=0;e<t.set.length;e++){let n=t.set[e],r=t.globParts[e];if(!n||!r)throw Error(`invalid pattern object`);for(;n[0]===`.`&&r[0]===`.`;)n.shift(),r.shift();let i=new Fr(n,r,0,this.platform),a=new en(i.globString(),this.mmopts),o=r[r.length-1]===`**`,s=i.isAbsolute();s?this.absolute.push(a):this.relative.push(a),o&&(s?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(e){let t=e.fullpath(),n=`${t}/`,r=e.relative()||`.`,i=`${r}/`;for(let e of this.relative)if(e.match(r)||e.match(i))return!0;for(let e of this.absolute)if(e.match(t)||e.match(n))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+`/`,n=(e.relative()||`.`)+`/`;for(let e of this.relativeChildren)if(e.match(n))return!0;for(let e of this.absoluteChildren)if(e.match(t))return!0;return!1}},Rr=class e{store;constructor(e=new Map){this.store=e}copy(){return new e(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let n=e.fullpath(),r=this.store.get(n);r?r.add(t.globString()):this.store.set(n,new Set([t.globString()]))}},zr=class{store=new Map;add(e,t,n){let r=(t?2:0)|!!n,i=this.store.get(e);this.store.set(e,i===void 0?r:r&i)}entries(){return[...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},Br=class{store=new Map;add(e,t){if(!e.canReaddir())return;let n=this.store.get(e);n?n.find(e=>e.globString()===t.globString())||n.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw Error(`attempting to walk unknown path`);return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},Vr=class e{hasWalkedCache;matches=new zr;subwalks=new Br;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new Rr}processPatterns(e,t){this.patterns=t;let n=t.map(t=>[e,t]);for(let[e,t]of n){this.hasWalkedCache.storeWalked(e,t);let n=t.root(),r=t.isAbsolute()&&this.opts.absolute!==!1;if(n){e=e.resolve(n===`/`&&this.opts.root!==void 0?this.opts.root:n);let r=t.rest();if(r)t=r;else{this.matches.add(e,!0,!1);continue}}if(e.isENOENT())continue;let i,a,o=!1;for(;typeof(i=t.pattern())==`string`&&(a=t.rest());)e=e.resolve(i),t=a,o=!0;if(i=t.pattern(),a=t.rest(),o){if(this.hasWalkedCache.hasWalked(e,t))continue;this.hasWalkedCache.storeWalked(e,t)}if(typeof i==`string`){let t=i===`..`||i===``||i===`.`;this.matches.add(e.resolve(i),r,t);continue}else if(i===P){(!e.isSymbolicLink()||this.follow||t.checkFollowGlobstar())&&this.subwalks.add(e,t);let n=a?.pattern(),i=a?.rest();if(!a||(n===``||n===`.`)&&!i)this.matches.add(e,r,n===``||n===`.`);else if(n===`..`){let t=e.parent||e;i?this.hasWalkedCache.hasWalked(t,i)||this.subwalks.add(t,i):this.matches.add(t,r,!0)}}else i instanceof RegExp&&this.subwalks.add(e,t)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new e(this.opts,this.hasWalkedCache)}filterEntries(e,t){let n=this.subwalks.get(e),r=this.child();for(let e of t)for(let t of n){let n=t.isAbsolute(),i=t.pattern(),a=t.rest();i===P?r.testGlobstar(e,t,a,n):i instanceof RegExp?r.testRegExp(e,i,a,n):r.testString(e,i,a,n)}return r}testGlobstar(e,t,n,r){if((this.dot||!e.name.startsWith(`.`))&&(t.hasMore()||this.matches.add(e,r,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,t):e.isSymbolicLink()&&(n&&t.checkFollowGlobstar()?this.subwalks.add(e,n):t.markFollowGlobstar()&&this.subwalks.add(e,t)))),n){let t=n.pattern();if(typeof t==`string`&&t!==`..`&&t!==``&&t!==`.`)this.testString(e,t,n.rest(),r);else if(t===`..`){let t=e.parent||e;this.subwalks.add(t,n)}else t instanceof RegExp&&this.testRegExp(e,t,n.rest(),r)}}testRegExp(e,t,n,r){t.test(e.name)&&(n?this.subwalks.add(e,n):this.matches.add(e,r,!1))}testString(e,t,n,r){e.isNamed(t)&&(n?this.subwalks.add(e,n):this.matches.add(e,r,!1))}},Hr=(e,t)=>typeof e==`string`?new Lr([e],t):Array.isArray(e)?new Lr(e,t):e,Ur=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#t;#n;signal;maxDepth;includeChildMatches;constructor(e,t,n){if(this.patterns=e,this.path=t,this.opts=n,this.#n=!n.posix&&n.platform===`win32`?`\\`:`/`,this.includeChildMatches=n.includeChildMatches!==!1,(n.ignore||!this.includeChildMatches)&&(this.#t=Hr(n.ignore??[],n),!this.includeChildMatches&&typeof this.#t.add!=`function`))throw Error(`cannot ignore child matches, ignore lacks add() method.`);this.maxDepth=n.maxDepth||1/0,n.signal&&(this.signal=n.signal,this.signal.addEventListener(`abort`,()=>{this.#e.length=0}))}#r(e){return this.seen.has(e)||!!this.#t?.ignored?.(e)}#i(e){return!!this.#t?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||await e.realpath(),!n)return;e=n}let r=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let e=await r.realpath();e&&(e.isUnknown()||this.opts.stat)&&await e.lstat()}return this.matchCheckTest(r,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#r(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||e.realpathSync(),!n)return;e=n}let r=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let e=r.realpathSync();e&&(e?.isUnknown()||this.opts.stat)&&e.lstatSync()}return this.matchCheckTest(r,t)}matchFinish(e,t){if(this.#r(e))return;if(!this.includeChildMatches&&this.#t?.add){let t=`${e.relativePosix()}/**`;this.#t.add(t)}let n=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let r=this.opts.mark&&e.isDirectory()?this.#n:``;if(this.opts.withFileTypes)this.matchEmit(e);else if(n){let t=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(t+r)}else{let t=this.opts.posix?e.relativePosix():e.relative(),n=this.opts.dotRelative&&!t.startsWith(`..`+this.#n)?`.`+this.#n:``;this.matchEmit(t?n+t+r:`.`+r)}}async match(e,t,n){let r=await this.matchCheck(e,n);r&&this.matchFinish(r,t)}matchSync(e,t,n){let r=this.matchCheckSync(e,n);r&&this.matchFinish(r,t)}walkCB(e,t,n){this.signal?.aborted&&n(),this.walkCB2(e,t,new Vr(this.opts),n)}walkCB2(e,t,n,r){if(this.#i(e))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2(e,t,n,r));return}n.processPatterns(e,t);let i=1,a=()=>{--i===0&&r()};for(let[e,t,r]of n.matches.entries())this.#r(e)||(i++,this.match(e,t,r).then(()=>a()));for(let e of n.subwalkTargets()){if(this.maxDepth!==1/0&&e.depth()>=this.maxDepth)continue;i++;let t=e.readdirCached();e.calledReaddir()?this.walkCB3(e,t,n,a):e.readdirCB((t,r)=>this.walkCB3(e,r,n,a),!0)}a()}walkCB3(e,t,n,r){n=n.filterEntries(e,t);let i=1,a=()=>{--i===0&&r()};for(let[e,t,r]of n.matches.entries())this.#r(e)||(i++,this.match(e,t,r).then(()=>a()));for(let[e,t]of n.subwalks.entries())i++,this.walkCB2(e,t,n.child(),a);a()}walkCBSync(e,t,n){this.signal?.aborted&&n(),this.walkCB2Sync(e,t,new Vr(this.opts),n)}walkCB2Sync(e,t,n,r){if(this.#i(e))return r();if(this.signal?.aborted&&r(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,n,r));return}n.processPatterns(e,t);let i=1,a=()=>{--i===0&&r()};for(let[e,t,r]of n.matches.entries())this.#r(e)||this.matchSync(e,t,r);for(let e of n.subwalkTargets()){if(this.maxDepth!==1/0&&e.depth()>=this.maxDepth)continue;i++;let t=e.readdirSync();this.walkCB3Sync(e,t,n,a)}a()}walkCB3Sync(e,t,n,r){n=n.filterEntries(e,t);let i=1,a=()=>{--i===0&&r()};for(let[e,t,r]of n.matches.entries())this.#r(e)||this.matchSync(e,t,r);for(let[e,t]of n.subwalks.entries())i++,this.walkCB2Sync(e,t,n.child(),a);a()}},Wr=class extends Ur{matches=new Set;constructor(e,t,n){super(e,t,n)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Gr=class extends Ur{results;constructor(e,t,n){super(e,t,n),this.results=new Xn({signal:this.signal,objectMode:!0}),this.results.on(`drain`,()=>this.resume()),this.results.on(`resume`,()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},Kr=typeof process==`object`&&process&&typeof process.platform==`string`?process.platform:`linux`,qr=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw TypeError(`glob options required`);if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith(`file://`))&&(t.cwd=C(t.cwd)):this.cwd=``,this.cwd=t.cwd||``,this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth==`number`?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error(`cannot set absolute and withFileTypes:true`);if(typeof e==`string`&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(e=>e.replace(/\\/g,`/`))),this.matchBase){if(t.noglobstar)throw TypeError(`base matching requires globstar`);e=e.map(e=>e.includes(`/`)?e:`./**/${e}`)}if(this.pattern=e,this.platform=t.platform||Kr,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw Error(`nocase option contradicts provided scurry option`)}else{let e=t.platform===`win32`?Or:t.platform===`darwin`?Ar:t.platform?kr:jr;this.scurry=new e(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let n=this.platform===`darwin`||this.platform===`win32`,r={braceExpandMax:1e4,...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:n,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},[i,a]=this.pattern.map(e=>new en(e,r)).reduce((e,t)=>(e[0].push(...t.set),e[1].push(...t.globParts),e),[[],[]]);this.patterns=i.map((e,t)=>{let n=a[t];if(!n)throw Error(`invalid pattern object`);return new Fr(e,n,0,this.platform)})}async walk(){return[...await new Wr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth===1/0?1/0:this.maxDepth+this.scurry.cwd.depth(),platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new Wr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth===1/0?1/0:this.maxDepth+this.scurry.cwd.depth(),platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new Gr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth===1/0?1/0:this.maxDepth+this.scurry.cwd.depth(),platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new Gr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth===1/0?1/0:this.maxDepth+this.scurry.cwd.depth(),platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}},Jr=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let n of e)if(new en(n,t).hasMagic())return!0;return!1};function Yr(e,t={}){return new qr(e,t).streamSync()}function Xr(e,t={}){return new qr(e,t).stream()}function Zr(e,t={}){return new qr(e,t).walkSync()}async function Qr(e,t={}){return new qr(e,t).walk()}function $r(e,t={}){return new qr(e,t).iterateSync()}function ei(e,t={}){return new qr(e,t).iterate()}var ti=Yr,ni=Object.assign(Xr,{sync:Yr}),ri=$r,ii=Object.assign(ei,{sync:$r}),ai=Object.assign(Zr,{stream:Yr,iterate:$r}),oi=Object.assign(Qr,{glob:Qr,globSync:Zr,sync:ai,globStream:Xr,stream:ni,globStreamSync:Yr,streamSync:ti,globIterate:ei,iterate:ii,globIterateSync:$r,iterateSync:ri,Glob:qr,hasMagic:Jr,escape:Tt,unescape:ft});oi.glob=oi;const si=(e,t)=>e===void 0||typeof e===t,ci=e=>!!e&&typeof e==`object`&&si(e.preserveRoot,`boolean`)&&si(e.tmp,`string`)&&si(e.maxRetries,`number`)&&si(e.retryDelay,`number`)&&si(e.backoff,`number`)&&si(e.maxBackoff,`number`)&&(si(e.glob,`boolean`)||e.glob&&typeof e.glob==`object`)&&si(e.filter,`function`),li=e=>{if(!ci(e))throw Error(`invalid rimraf options`)},ui=e=>{li(e);let{glob:t,...n}=e;if(!t)return n;let r=t===!0?e.signal?{signal:e.signal}:{}:e.signal?{signal:e.signal,...t}:t;return{...n,glob:{...r,absolute:!0,withFileTypes:!1}}},di=(e={})=>ui(e),fi=(e={})=>ui(e),pi=(e,t={})=>{let n=typeof e;if(n!==`string`){let t=e&&n===`object`&&e.constructor,r=`The "path" argument must be of type string. Received ${t&&t.name?`an instance of ${t.name}`:n===`object`?De(e):`type ${n} ${e}`}`;throw Object.assign(TypeError(r),{path:e,code:`ERR_INVALID_ARG_TYPE`})}if(/\0/.test(e))throw Object.assign(TypeError(`path must be a string without null bytes`),{path:e,code:`ERR_INVALID_ARG_VALUE`});e=M(e);let{root:r}=j(e);if(e===r&&t.preserveRoot!==!1)throw Object.assign(Error(`refusing to remove root directory without preserveRoot:false`),{path:e,code:`ERR_PRESERVE_ROOT`});if(process.platform===`win32`){let t=/[*|"<>?:]/,{root:n}=j(e);if(t.test(e.substring(n.length)))throw Object.assign(Error(`Illegal characters in path.`),{path:e,code:`EINVAL`})}return e},mi=e=>ge(e,{withFileTypes:!0}),hi={chmod:Oe.chmod,mkdir:Oe.mkdir,readdir:e=>Oe.readdir(e,{withFileTypes:!0}),rename:Oe.rename,rm:Oe.rm,rmdir:Oe.rmdir,stat:Oe.stat,lstat:Oe.lstat,unlink:Oe.unlink},{readdir:gi}=hi,_i=e=>gi(e).catch(e=>e),vi=e=>{try{return mi(e)}catch(e){return e}},yi=e=>!!e&&typeof e==`object`,bi=(e,t)=>t in e&&typeof e[t]==`string`,xi=e=>yi(e)&&bi(e,`code`)&&bi(e,`path`),J=e=>yi(e)&&bi(e,`code`)?e.code:null,Y=async(e,t)=>e.catch(e=>{if(J(e)!==`ENOENT`)throw t??e}),X=(e,t)=>{try{return e()}catch(e){if(J(e)===`ENOENT`)return;throw t??e}},{lstat:Si,rmdir:Ci,unlink:wi}=hi,Ti=async(e,t)=>(t?.signal?.throwIfAborted(),await Y(Si(e).then(n=>Di(e,t,n)))??!0),Ei=(e,t)=>(t?.signal?.throwIfAborted(),X(()=>Oi(e,t,me(e)))??!0),Di=async(e,t,n)=>{t?.signal?.throwIfAborted();let r=n.isDirectory()?await _i(e):null;if(!Array.isArray(r)){if(r){if(J(r)===`ENOENT`)return!0;if(J(r)!==`ENOTDIR`)throw r}return t.filter&&!await t.filter(e,n)?!1:(await Y(wi(e)),!0)}return!(await Promise.all(r.map(n=>Di(M(e,n.name),t,n)))).every(e=>e===!0)||t.preserveRoot===!1&&e===j(e).root||t.filter&&!await t.filter(e,n)?!1:(await Y(Ci(e)),!0)},Oi=(e,t,n)=>{t?.signal?.throwIfAborted();let r=n.isDirectory()?vi(e):null;if(!Array.isArray(r)){if(r){if(J(r)===`ENOENT`)return!0;if(J(r)!==`ENOTDIR`)throw r}return t.filter&&!t.filter(e,n)?!1:(X(()=>Ce(e)),!0)}let i=!0;for(let n of r){let r=M(e,n.name);i=Oi(r,t,n)&&i}return t.preserveRoot===!1&&e===j(e).root||!i||t.filter&&!t.filter(e,n)?!1:(X(()=>xe(e)),!0)},{chmod:ki}=hi,Ai=e=>async t=>{try{await Y(e(t));return}catch(n){if(J(n)===`EPERM`){if(!await Y(ki(t,438).then(()=>!0),n))return;await e(t);return}throw n}},ji=e=>t=>{try{X(()=>e(t));return}catch(n){if(J(n)===`EPERM`){if(!X(()=>(fe(t,438),!0),n))return;e(t);return}throw n}},Mi=new Set([`EMFILE`,`ENFILE`,`EBUSY`]),Ni=e=>{let t=async(n,r,i=1,a=0)=>{let o=r.maxBackoff||200,s=r.backoff||1.2,c=r.maxRetries||10,l=0;for(;;)try{return await e(n)}catch(e){if(xi(e)&&e.path===n&&Mi.has(e.code)){if(i=Math.ceil(i*s),a=i+a,a<o)return await ke(i),t(n,r,i,a);if(l<c){l++;continue}}throw e}};return t},Pi=e=>(t,n)=>{let r=n.maxRetries||10,i=0;for(;;)try{return e(t)}catch(e){if(xi(e)&&e.path===t&&Mi.has(e.code)&&i<r){i++;continue}throw e}},{stat:Fi}=hi,Ii=e=>{try{return Se(e).isDirectory()}catch{return!1}},Li=e=>Fi(e).then(e=>e.isDirectory(),()=>!1),Ri=async e=>{let{root:t}=j(e),n=Ae(),{root:r}=j(n);if(t.toLowerCase()===r.toLowerCase())return n;let i=M(t,`/temp`);return await Li(i)?i:t},zi=e=>{let{root:t}=j(e),n=Ae(),{root:r}=j(n);if(t.toLowerCase()===r.toLowerCase())return n;let i=M(t,`/temp`);return Ii(i)?i:t},Bi=async()=>Ae(),Vi=()=>Ae(),Hi=process.platform===`win32`?Ri:Bi,Ui=process.platform===`win32`?zi:Vi,{lstat:Wi,rename:Gi,unlink:Ki,rmdir:qi}=hi,Ji=e=>`.${A(e)}.${Math.random()}`,Yi=Ai(Ki),Xi=ji(Ce),Zi=async(e,t)=>(t?.signal?.throwIfAborted(),await Y(Wi(e).then(n=>Qi(e,t,n)))??!0),Qi=async(e,t,n)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return Qi(e,{...t,tmp:await Hi(e)},n);if(e===t.tmp&&j(e).root!==e)throw Error(`cannot delete temp directory used for deletion`);let r=n.isDirectory()?await _i(e):null;if(!Array.isArray(r)){if(r){if(J(r)===`ENOENT`)return!0;if(J(r)!==`ENOTDIR`)throw r}return t.filter&&!await t.filter(e,n)?!1:(await Y($i(e,t.tmp,Yi)),!0)}return!(await Promise.all(r.map(n=>Qi(M(e,n.name),t,n)))).every(e=>e===!0)||t.preserveRoot===!1&&e===j(e).root||t.filter&&!await t.filter(e,n)?!1:(await Y($i(e,t.tmp,qi)),!0)},$i=async(e,t,n)=>{let r=M(t,Ji(e));return await Gi(e,r),await n(r)},ea=(e,t)=>(t?.signal?.throwIfAborted(),X(()=>ta(e,t,me(e)))??!0),ta=(e,t,n)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return ta(e,{...t,tmp:Ui(e)},n);let r=t.tmp;if(e===t.tmp&&j(e).root!==e)throw Error(`cannot delete temp directory used for deletion`);let i=n.isDirectory()?vi(e):null;if(!Array.isArray(i)){if(i){if(J(i)===`ENOENT`)return!0;if(J(i)!==`ENOTDIR`)throw i}return t.filter&&!t.filter(e,n)?!1:(X(()=>na(e,r,Xi)),!0)}let a=!0;for(let n of i){let r=M(e,n.name);a=ta(r,t,n)&&a}return!a||t.preserveRoot===!1&&e===j(e).root||t.filter&&!t.filter(e,n)?!1:(X(()=>na(e,r,xe)),!0)},na=(e,t,n)=>{let r=M(t,Ji(e));return ye(e,r),n(r)},{unlink:ra,rmdir:ia,lstat:aa}=hi,oa=Ni(Ai(ra)),sa=Pi(ji(Ce)),ca=Ni(Ai(ia)),la=Pi(ji(xe)),ua=async(e,{filter:t,...n})=>{n?.signal?.throwIfAborted();try{return await ca(e,n),!0}catch(t){if(J(t)===`ENOTEMPTY`)return Zi(e,n);throw t}},da=(e,{filter:t,...n})=>{n?.signal?.throwIfAborted();try{return la(e,n),!0}catch(t){if(J(t)===`ENOTEMPTY`)return ea(e,n);throw t}},fa=Symbol(`start`),pa=Symbol(`child`),ma=Symbol(`finish`),ha=async(e,t)=>(t?.signal?.throwIfAborted(),await Y(aa(e).then(n=>_a(e,t,n,fa)))??!0),ga=(e,t)=>(t?.signal?.throwIfAborted(),X(()=>va(e,t,me(e),fa))??!0),_a=async(e,t,n,r=fa)=>{t?.signal?.throwIfAborted();let i=n.isDirectory()?await _i(e):null;if(!Array.isArray(i)){if(i){if(J(i)===`ENOENT`)return!0;if(J(i)!==`ENOTDIR`)throw i}return t.filter&&!await t.filter(e,n)?!1:(await Y(oa(e,t)),!0)}let a=r===fa?pa:r,o=(await Promise.all(i.map(n=>_a(M(e,n.name),t,n,a)))).every(e=>e===!0);if(r===fa)return _a(e,t,n,ma);if(r===ma){if(t.preserveRoot===!1&&e===j(e).root||!o||t.filter&&!await t.filter(e,n))return!1;await Y(ua(e,t))}return!0},va=(e,t,n,r=fa)=>{let i=n.isDirectory()?vi(e):null;if(!Array.isArray(i)){if(i){if(J(i)===`ENOENT`)return!0;if(J(i)!==`ENOTDIR`)throw i}return t.filter&&!t.filter(e,n)?!1:(X(()=>sa(e,t)),!0)}let a=!0;for(let n of i){let i=r===fa?pa:r,o=M(e,n.name);a=va(o,t,n,i)&&a}if(r===fa)return va(e,t,n,ma);if(r===ma){if(t.preserveRoot===!1&&e===j(e).root||!a||t.filter&&!t.filter(e,n))return!1;X(()=>da(e,t))}return!0},ya=process.platform===`win32`?ha:Ti,ba=process.platform===`win32`?ga:Ei,{rm:xa}=hi,Sa=async(e,t)=>(await xa(e,{...t,force:!0,recursive:!0}),!0),Ca=(e,t)=>(be(e,{...t,force:!0,recursive:!0}),!0),[wa=0,Ta=0]=process.version.replace(/^v/,``).split(`.`).map(e=>parseInt(e,10)),Ea=wa>14||wa===14&&Ta>=14,Da=!Ea||process.platform===`win32`?()=>!1:e=>!e?.signal&&!e?.filter,Oa=!Ea||process.platform===`win32`?()=>!1:e=>!e?.signal&&!e?.filter,ka=e=>async(t,n)=>{let r=di(n);return r.glob&&(t=await oi(t,r.glob)),Array.isArray(t)?!!(await Promise.all(t.map(t=>e(pi(t,r),r)))).reduce((e,t)=>e&&t,!0):!!await e(pi(t,r),r)},Aa=e=>(t,n)=>{let r=fi(n);return r.glob&&(t=Zr(t,r.glob)),Array.isArray(t)?!!t.map(t=>e(pi(t,r),r)).reduce((e,t)=>e&&t,!0):!!e(pi(t,r),r)},ja=Aa(Ca),Ma=Object.assign(ka(Sa),{sync:ja}),Na=Aa(ba),Pa=Object.assign(ka(ya),{sync:Na}),Fa=Aa(ga),Ia=Object.assign(ka(ha),{sync:Fa}),La=Aa(Ei),Ra=Object.assign(ka(Ti),{sync:La}),za=Aa(ea),Ba=Object.assign(ka(Zi),{sync:za}),Va=Aa((e,t)=>Oa(t)?Ca(e,t):ba(e,t)),Ha=ka((e,t)=>Da(t)?Sa(e,t):ya(e,t)),Ua=Object.assign(Ha,{rimraf:Ha,sync:Va,rimrafSync:Va,manual:Pa,manualSync:Na,native:Ma,nativeSync:ja,posix:Ra,posixSync:La,windows:Ia,windowsSync:Fa,moveRemove:Ba,moveRemoveSync:za});Ua.rimraf=Ua;async function Wa(e,t,{baseDir:n=``,readdirImpl:r=se,cpImpl:i=E,joinImpl:a=b}={}){for(let o of e){let e=n?a(n,o):o;try{let n=await r(e,{withFileTypes:!0});for(let r of n){let n=a(e,r.name),o=a(t,r.name);r.isDirectory()?await i(n,o,{recursive:!0,force:!0}):r.isFile()&&await i(n,o,{force:!0})}}catch{}}}async function Ga(e,t,n={},{statImpl:r=de,cpImpl:i=E}={}){let a=Array.isArray(e)?e:[e];for(let e of a)try{return await r(e),await i(e,t,n),!0}catch{}return!1}async function Ka(e,{statImpl:t=de}={}){for(let n of e)try{return await t(n),n}catch{}return null}function qa({contentRoot:e=``,toolchainRoot:t=``,distPublicDir:n=`dist/public`}={}){let r=[{sources:[`pages/resources/README.md`,`pages/deps/README.md`,`resources/README.md`,`deps/README.md`,`pages/README.md`,`README.md`],dest:`dist/public/README.md`},{sources:[`pages/resources/docs`,`pages/deps/docs`,`resources/docs`,`deps/docs`,`pages/docs`,`docs`],dest:`dist/public/docs`,opts:{recursive:!0}},{sources:[`pages/resources/AGENTS.md`,`pages/deps/AGENTS.md`,`resources/AGENTS.md`,`deps/AGENTS.md`,`pages/AGENTS.md`,`AGENTS.md`],dest:`dist/public/AGENTS.md`},{sources:[`pages/resources/llms.txt`,`pages/deps/llms.txt`,`resources/llms.txt`,`deps/llms.txt`,`pages/llms.txt`,`llms.txt`],dest:`dist/public/llms.txt`},{sources:[`pages/resources/robots.txt`,`pages/deps/robots.txt`,`resources/robots.txt`,`deps/robots.txt`,`pages/robots.txt`,`robots.txt`],dest:`dist/public/robots.txt`},{sources:[`pages/resources/sitemap.xml`,`pages/deps/sitemap.xml`,`resources/sitemap.xml`,`deps/sitemap.xml`,`pages/sitemap.xml`,`pages/main/sitemap.xml`,`sitemap.xml`],dest:`dist/public/sitemap.xml`},{sources:[`pages/resources/sitemap.txt`,`pages/deps/sitemap.txt`,`resources/sitemap.txt`,`deps/sitemap.txt`,`pages/sitemap.txt`,`pages/main/sitemap.txt`,`sitemap.txt`],dest:`dist/public/sitemap.txt`},{sources:[`pages/resources/404.html`,`pages/deps/404.html`,`resources/404.html`,`deps/404.html`,`pages/404.html`,`pages/main/404.html`,`404.html`],dest:`dist/public/404.html`},{sources:[`pages/resources/manifest.json`,`pages/deps/manifest.json`,`resources/manifest.json`,`deps/manifest.json`,`pages/manifest.json`,`pages/main/manifest.json`,`manifest.json`],dest:`dist/public/manifest.json`},{sources:[`pages/resources/assets/icons/favicon.svg`,`pages/deps/assets/icons/favicon.svg`,`resources/assets/icons/favicon.svg`,`deps/assets/icons/favicon.svg`,`pages/resources/assets/favicon.svg`,`pages/resources/favicon.svg`,`pages/deps/favicon.svg`,`resources/favicon.svg`,`deps/favicon.svg`,`pages/favicon.svg`,`pages/main/favicon.svg`,`assets/icons/favicon.svg`],dest:`dist/public/favicon.svg`},{sources:[`pages/resources/assets/icons/favicon.ico`,`pages/deps/assets/icons/favicon.ico`,`resources/assets/icons/favicon.ico`,`deps/assets/icons/favicon.ico`,`pages/resources/assets/favicon.ico`,`pages/resources/favicon.ico`,`pages/deps/favicon.ico`,`resources/favicon.ico`,`deps/favicon.ico`,`pages/favicon.ico`,`pages/main/favicon.ico`,`assets/icons/favicon.ico`],dest:`dist/public/favicon.ico`}];return!e&&!t&&n===`dist/public`?r:r.map(r=>{let i=n?r.dest.replace(/^dist\/public/,n):r.dest,a=[];if(e)for(let t of r.sources)a.push(y.join(e,t));if(t&&t!==e)for(let e of r.sources)a.push(y.join(t,e));return!e&&!t&&a.push(...r.sources),{sources:a,dest:i,...r.opts?{opts:r.opts}:{}}})}function Ja(e){let t=[`pages/resources/routes.json`,`pages/deps/routes.json`,`resources/routes.json`,`deps/routes.json`,`pages/routes.json`,`routes.json`];return e?t.map(t=>y.join(e,t)):t}function Ya(e){return e?[y.join(e,`shadow-claw-config.json`),y.join(e,`shadow-claw.config.json`),y.join(e,`shadowclaw.config.json`),y.join(e,`pages/shadow-claw-config.json`),y.join(e,`pages/shadow-claw.config.json`),y.join(e,`site-config.json`),y.join(e,`pages/site-config.json`)]:[`shadow-claw-config.json`,`shadow-claw.config.json`,`shadowclaw.config.json`,`site-config.json`]}function Xa(e={}){let t=e.PRERENDER_PAGES||`all`;return{isProduction:e.NODE_ENV===`production`,copyAllAssets:e.COPY_ALL_ASSETS===`true`,prerenderPages:t,prerenderMainMemory:e.PRERENDER_MAIN_MEMORY!==`false`&&t!==`none`&&t!==`0`}}function Za(e){return e.replace(/^\/+|\/+$/g,``)}function Qa(e){let t=Za(e);if(t.startsWith(`pages/main/`))return t.slice(11);if(t.startsWith(`pages/br:main/`)||t.startsWith(`pages/br-main/`))return t.slice(14);if(t.startsWith(`main/`))return t.slice(5);if(t.startsWith(`pages/`)){let e=t.split(`/`);if(e.length>=3)return e.slice(2).join(`/`)}return t}function $a(e,t){let r=`<script id="shadow-claw-static-routing" type="application/json">${n(t)}<\/script>`;return/id="shadow-claw-static-routing"/iu.test(e)?e.replace(/<script\s+id="shadow-claw-static-routing"[\s\S]*?<\/script>/iu,()=>r):g(e,` ${r}`)}async function eo(e={}){let n=y.resolve(e.publicDir||`dist/public`),c=y.resolve(e.routesPath||`pages/routes.json`),g=y.resolve(e.sourcePath||`pages/main`),_=y.resolve(e.indexPath||y.join(n,`index.html`)),v=t(e.prerenderPages===void 0?w.env.PRERENDER_PAGES??1:e.prerenderPages),b;try{b=await O(c,`utf8`)}catch(e){if(e?.code===`ENOENT`)return{count:0,skipped:!0,reason:`No routes.json found`};throw e}let x;try{x=JSON.parse(b)}catch(e){return console.warn(`Failed to parse ${c}:`,e),{count:0,skipped:!0,reason:`Invalid JSON in routes.json`}}if(!x||typeof x!=`object`)return{count:0,skipped:!0,reason:`Invalid routes.json`};x.routes||={};let te={...x.routes||{}},S=new Set;async function C(e,t){if(!e.subRoutes)return;let n=Array.isArray(e.subRoutes)?e.subRoutes:Object.values(e.subRoutes);for(let e of n){let n=y.resolve(y.dirname(t),e);if(typeof e==`string`&&e.startsWith(`pages/`)&&(n=y.resolve(e)),!S.has(n)){S.add(n);try{let e=await O(n,`utf8`),t=JSON.parse(e);t.routes&&Object.assign(te,t.routes),await C(t,n)}catch(e){console.warn(`Failed to read subRoute: ${n}`,e?.message)}}}}await C(x,c),Object.assign(x.routes,te),Array.isArray(x.subRoutes)&&delete x.subRoutes;let ne=Object.entries(te);if(ne.length===0)return{count:0,skipped:!0,reason:`Empty routes table`};let re=JSON.stringify(x,null,2),ie=y.join(n,`static-routing.json`);await D(n,{recursive:!0}),await k(ie,re,`utf8`);let ae=JSON.stringify(x),T=y.join(n,`components/shadow-claw/shadow-claw.html`),oe=y.join(n,`components/shadow-claw-pages/shadow-claw-pages.html`),ce=y.join(n,`components/shadow-claw-page-header/shadow-claw-page-header.html`),le=y.join(n,`components/shadow-claw/shadow-claw.css`),ue=y.join(n,`components/shadow-claw-pages/shadow-claw-pages.css`),fe=y.join(n,`components/shadow-claw-page-header/shadow-claw-page-header.css`),[pe,me,he,ge,_e,ve,ye,be]=await Promise.all([O(_,`utf8`),O(T,`utf8`),O(oe,`utf8`).catch(()=>``),O(ce,`utf8`).catch(()=>``),p(g),O(le,`utf8`).catch(()=>``),O(ue,`utf8`).catch(()=>``),O(fe,`utf8`).catch(()=>``)]),xe=(await Promise.all(_e.map(async e=>{let t=typeof e.inlineContent==`string`?e.inlineContent:await O(e.absolutePath,`utf8`);return{...e,content:t}}))).filter(e=>!(e.displayPath.endsWith(`.md`)&&/^---\r?\n[\s\S]*?slug:\s*"shadow-claw--purge-pages"[\s\S]*?---/mu.test(e.content||``)));await k(_,await s(l($a(pe,ae)),n),`utf8`);let Se=d(me),Ce=d(he),we=d(ge),Te=xe.map(e=>({displayPath:e.displayPath,content:e.content})),Ee=y.join(n,`static-main-manifest.json`),A={};try{A=JSON.parse(await O(Ee,`utf8`))}catch{}let j={pages:Te,...Array.isArray(A.skills)?{skills:A.skills}:{},...Array.isArray(A.tools)?{tools:A.tools}:{},...A.skillsPurgeId?{skillsPurgeId:A.skillsPurgeId}:{},...A.preRenderedStaticPages?{preRenderedStaticPages:A.preRenderedStaticPages}:{},...A.purgeId?{purgeId:A.purgeId}:{}};await k(Ee,JSON.stringify(j,null,2),`utf8`);try{if((await de(g)).isDirectory()){let e=y.join(n,`static-main`);await D(e,{recursive:!0}),await E(g,e,{recursive:!0});let t=y.join(n,`files/main`);await D(t,{recursive:!0}),await E(g,t,{recursive:!0})}}catch{}let M=[];for(let[e,t]of ne){if(!t||!t.prettyPath)continue;let c=Qa(e),d=xe.find(e=>e.displayPath===c);if(!d)try{let e=y.join(g,c);d={absolutePath:e,displayPath:c,content:await O(e,`utf8`)}}catch{console.warn(`Could not find page file for route: ${e} (${c})`);continue}let p=xe.filter(e=>e.displayPath!==d.displayPath),_=[],b=[];v===`all`?(_=[d,...p],b=_.map(e=>({displayPath:e.displayPath,content:e.content}))):typeof v==`number`&&(v===0?(_=[],b=[]):(_=[d,...p.slice(0,v-1)],b=_.map(e=>({displayPath:e.displayPath,content:e.content}))));let x=ee(d.content||``),te=x.data&&x.data.title?x.data.title:``,S=await r(d.content||``,d.displayPath),C;C=v===0?i(Se,ve):u(Se,h(Ce,_,S,we,te,ye,be),ve);let w=await s(l($a(a(f(o(pe,C)),JSON.stringify({pages:b,...Array.isArray(A.skills)?{skills:A.skills}:{},...Array.isArray(A.tools)?{tools:A.tools}:{},...A.skillsPurgeId?{skillsPurgeId:A.skillsPurgeId}:{},...A.preRenderedStaticPages?{preRenderedStaticPages:A.preRenderedStaticPages}:{},...A.purgeId?{purgeId:A.purgeId}:{}})),ae)),n),ne=Za(t.prettyPath),re;re=ne.endsWith(`.html`)?ne:y.join(ne,`index.html`);let ie=y.join(n,re),T=y.dirname(ie);if(await D(T,{recursive:!0}),await k(ie,w,`utf8`),d&&d.absolutePath)try{let e=y.dirname(d.absolutePath),t=await se(e,{withFileTypes:!0});for(let n of t)n.isFile()&&!m(n.name)&&n.name!==`routes.json`&&await E(y.join(e,n.name),y.join(T,n.name))}catch(t){console.warn(`Failed to copy co-located assets for ${e}:`,t)}M.push(re.replace(/\\/g,`/`))}return(e.silent??w.env.NODE_ENV===`test`)||console.log(`Prerendered ${M.length} pretty path page${M.length===1?``:`s`} from ${c} (prerender-pages: ${v}).`),{count:M.length,generatedPaths:M,skipped:!1}}async function to(){let e=w.argv.slice(2).filter(e=>!e.startsWith(`--`)),t=w.argv.slice(2).filter(e=>e.startsWith(`--`)),n;for(let e of t)e.startsWith(`--prerender-pages=`)?n=e.slice(18):e.startsWith(`--pages=`)&&(n=e.slice(8));let r=e[0]||`dist/public`;await eo({publicDir:r,routesPath:e[1]||`pages/routes.json`,sourcePath:e[2]||`pages/main`,indexPath:e[3]||y.join(r,`index.html`),prerenderPages:n})}w.argv[1]&&y.resolve(w.argv[1])===y.resolve(C(import.meta.url))&&to().catch(e=>{console.error(e),w.exit(1)});function no(e={},t={}){let n=e.customElements;return{rawScripts:(typeof n==`object`&&!Array.isArray(n)?n.scripts:n)||e.scripts||t.scripts||[],allowedDomains:(typeof n==`object`&&!Array.isArray(n)?n.allowedDomains:void 0)||e.allowedCustomElementDomains||[]}}function ro(e,t){if(!e.startsWith(`http://`)&&!e.startsWith(`https://`)&&!e.startsWith(`//`)||!t||Array.isArray(t)&&t.length===0)return!0;try{let n=new URL(e,`https://localhost`).hostname.toLowerCase();return(Array.isArray(t)?t:String(t).split(/[\n,]+/)).some(e=>{let t=e.trim().toLowerCase();return n===t||n.endsWith(`.`+t)||t===`*`})}catch{return!1}}function io(e,t){let n=JSON.parse(JSON.stringify(e));return n.customElements&&typeof n.customElements==`object`&&Array.isArray(n.customElements.scripts)&&(n.customElements.scripts=n.customElements.scripts.filter(e=>{let n=typeof e==`string`?e:e?.src;return n?ro(n,t):!1})),n}function Z(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function ao(e,t){let n=/<\/head>/i.exec(e);if(n){let r=n.index;return e.slice(0,r)+t+`
|
|
4
|
-
`+e.slice(r)}return`${t}\n${e}`}const oo=[`pages/resources/`,`pages/deps/`,`resources/`,`deps/`,`pages/assets/`,`pages/main/assets/`];function so(e){for(let t of oo)if(e.startsWith(t))return e.slice(t.length);return e}async function co(e){try{return JSON.parse(await O(e,`utf8`))}catch{return null}}async function lo(e){try{return await O(e,`utf8`)}catch{return null}}async function uo(e,t){await k(e,t,`utf8`)}function fo(e){return!Array.isArray(e)||e.length===0?``:`<nav slot="sidebar" class="sidebar-custom-sections" aria-label="Site Navigation">\n${e.map((e,t)=>{if(e.html)return e.html;let n=e.title?`sidebar-${e.title.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}`:`sidebar-section-${t+1}`,r=e.headerHref?`<a href="${Z(e.headerHref)}" class="sidebar-link">${Z(e.title||``)}</a>`:`<span>${Z(e.title||``)}</span>`,i=e.title?` <div class="sidebar-section-header">${r}</div>`:``,a=(e.items||[]).map(e=>{let t=e.title||e.label||``,n=e.href||`#`,r=e.target?` target="${Z(e.target)}"`:``,i=e.rel?` rel="${Z(e.rel)}"`:e.target===`_blank`?` rel="noopener noreferrer"`:``,a=e.active?` active`:``,o=e.active?` aria-current="page"`:``;return` <div class="sidebar-item"><a href="${Z(n)}"${r}${i} class="sidebar-link${a}"${o}>${Z(t)}</a></div>`}).join(`
|
|
5
|
-
`);return[` <section class="sidebar-section" id="${n}">`,i,a,` </section>`].filter(Boolean).join(`
|
|
6
|
-
`)}).join(`
|
|
7
|
-
`)}\n</nav>`}function po(e,t,n){let r=e,i=t.site||{};i.title&&(r=r.replace(/<title>[^<]*<\/title>/iu,`<title>${Z(i.title)}</title>`)),i.description&&(r=r.replace(/<meta\s+name="description"\s+content="[^"]*"\s*\/?>/iu,`<meta name="description" content="${Z(i.description)}" />`)),i.themeColor&&(r=r.replace(/<meta\s+name="theme-color"\s+content="[^"]*"\s*\/?>/iu,`<meta name="theme-color" content="${Z(i.themeColor)}" />`)),i.lang&&(r=r.replace(/<html\s+lang="[^"]*"/iu,`<html lang="${i.lang}"`));let a=t.branding||{};if(a.faviconPath){let e=a.faviconPath.replace(/^pages\/main\//,``),t=e.endsWith(`.svg`)?`image/svg+xml`:e.endsWith(`.png`)?`image/png`:`image/x-icon`,n=`<link href="${Z(e)}" rel="icon" type="${t}" />`,i=!1;r=r.replace(/<link\b[^>]*\brel=["']?(?:shortcut\s+)?icon["']?[^>]*\/?>/giu,()=>i?``:(i=!0,n)),i||(r=ao(r,` ${n}`))}if(a.appleTouchIconPath){let e=`<link href="${Z(a.appleTouchIconPath.replace(/^pages\/main\//,``))}" rel="apple-touch-icon" />`,t=!1;r=r.replace(/<link\b[^>]*\brel=["']?apple-touch-icon["']?[^>]*\/?>/giu,()=>t?``:(t=!0,e)),t||(r=ao(r,` ${e}`))}if(a.titleText||a.siteUrl||a.logoSlotHtml){let e=a.titleText||`ShadowClaw`,t=a.siteUrl||``,n=a.logoSlotHtml||``;r=r.replace(/<a\b[^>]*\bslot="header-title-link"[^>]*>[\s\S]*?<\/a>/iu,[`<a`,` aria-label="${Z(e)}"`,` class="header-title-link"`,t?` href="${Z(t)}"`:``,` slot="header-title-link"`,` >`,n?` ${n}`:``,` <span class="header-title">${Z(e)}</span>`,` </a>`].filter(Boolean).join(`
|
|
8
|
-
`))}if(a.repoUrl){let e=a.repoLabel||`Project on GitHub`;r=r.replace(/<a\b[^>]*\bslot="header-actions-logo"[^>]*>[\s\S]*?<\/a>/iu,[`<a`,` aria-label="${Z(e)}"`,` class="header-actions-logo-link"`,` href="${Z(a.repoUrl)}"`,` slot="header-actions-logo"`,` >`,` <svg aria-hidden="true" focusable="false" viewBox="0 0 496 512" xmlns="http://www.w3.org/2000/svg">`,` <path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8z" fill="var(--shadow-claw-bg-primary-reverse, currentColor)"></path>`,` </svg>`,` </a>`].join(`
|
|
9
|
-
`))}a.siteUrl&&!a.siteUrl.includes(`xt-ml.github.io`)&&(r=r.replace(/\s*<meta\s+http-equiv="origin-trial"\s+content="[^"]*"\s*\/?>\s*/iu,`
|
|
10
|
-
`));let o=t.theme||{};if(o.stylesheet){let e=so(o.stylesheet),t=`<link rel="stylesheet" href="${Z(e)}" />`,n=Z(e).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),a=RegExp(`<link\\s+[^>]*href=["'](?:${i}|${n})["'][^>]*>`,`iu`),s=r.slice(0,Math.max(0,r.indexOf(`</head>`))).replace(/<script\b[\s\S]*?<\/script>/gi,``);a.test(s)||(r=/<link\s+rel="stylesheet"\s+href="index\.css"\s*\/?>/iu.test(r)?r.replace(/(<link\s+rel="stylesheet"\s+href="index\.css"\s*\/?>)/iu,`$1\n ${t}`):ao(r,` ${t}`))}let{allowedDomains:s}=no(t,o),c=io(t,s),l=`<script id="shadow-claw-site-config" type="application/json">${JSON.stringify(c).replace(/</g,`\\u003c`).replace(/>/g,`\\u003e`).replace(/\//g,`\\u002f`)}<\/script>`;r=r.includes(`<script id="shadow-claw-site-config"`)?r.replace(/<script\s+id="shadow-claw-site-config"[\s\S]*?<\/script>/iu,()=>l):r.includes(`<script src="theme-init.js">`)?r.replace(`<script src="theme-init.js">`,`${l}\n <script src="theme-init.js">`):/<script\b[^>]*>\s*var\s+ShadowClawThemeInit\b/iu.test(r)?r.replace(/(<script\b[^>]*>\s*var\s+ShadowClawThemeInit\b)/iu,`${l}\n $1`):ao(r,` ${l}`);let u=n||t.sidebar?.slotHtml||(t.sidebar?.sections?fo(t.sidebar.sections):``);if(u){let e=u.trim();/\bslot="sidebar(?:-nav|-content|-footer)?"/iu.test(e)||(e=`<div slot="sidebar" class="sidebar-custom-sections">\n${e}\n</div>`);let t=r.match(/<[^>]+?\bslot="sidebar(?:-nav|-content|-footer)?"[^>]*>[\s\S]*?<\/[^>]+>/iu);t&&(r=r.replace(t[0],``)),r.includes(`</shadow-claw>`)?r=r.replace(`</shadow-claw>`,` ${e}\n</shadow-claw>`):r.includes(`<shadow-claw></shadow-claw>`)&&(r=r.replace(`<shadow-claw></shadow-claw>`,`<shadow-claw>\n ${e}\n</shadow-claw>`))}return r}function mo(e){let t=(e.src||``).replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),n=e.type||(t.endsWith(`.svg`)?`image/svg+xml`:t.endsWith(`.png`)?`image/png`:`image/x-icon`),r=(e.purpose||`any`).trim();return n===`image/svg+xml`||t.endsWith(`.svg`)?[{...e,src:t,type:n,purpose:`any`}]:r.includes(`any`)&&r.includes(`maskable`)?[{...e,src:t,type:n,purpose:`any`},{...e,src:t,type:n,purpose:`maskable`}]:[{...e,src:t,type:n,purpose:r}]}function ho(e,t){let n=typeof e==`string`?JSON.parse(e):e,r=t.pwa||{},i=t.site||{},a=w.env.PAGES_ORIGIN;if((r.name||i.title)&&(n.name=r.name||i.title),(r.shortName||i.title)&&(n.short_name=r.shortName||i.title),i.description&&(n.description=i.description),r.backgroundColor&&(n.background_color=r.backgroundColor),(r.themeColor||i.themeColor)&&(n.theme_color=r.themeColor||i.themeColor),r.startUrl?n.start_url=r.startUrl:a?n.start_url=a:n.start_url||=`./`,r.icons&&Array.isArray(r.icons)){let e=r.icons.flatMap(mo),t=Array.isArray(n.icons)?n.icons.flatMap(mo):[],i=new Set(e.map(e=>e.src));n.icons=[...e,...t.filter(e=>!i.has(e.src))]}else Array.isArray(n.icons)&&(n.icons=n.icons.flatMap(mo));return r.screenshots&&Array.isArray(r.screenshots)&&(n.screenshots=r.screenshots.map(e=>{let t=(e.src||``).replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``);return{...e,src:t}})),JSON.stringify(n,null,2)}function go(e,t){if(!t)return e;if(/<loc>/i.test(e))return e.replace(/<loc>[^<]*<\/loc>/giu,`<loc>${Z(t)}</loc>`);let n=t.endsWith(`/`)?t:t+`/`;return e.split(`
|
|
11
|
-
`).map(e=>{let t=e.trim();if(!t)return e;if(t.startsWith(`http://`)||t.startsWith(`https://`))try{let e=new URL(t),r=new URL(n);return e.protocol=r.protocol,e.host=r.host,e.pathname=(r.pathname.endsWith(`/`)?r.pathname.slice(0,-1):r.pathname)+e.pathname,e.toString()}catch{return n}else if(t.startsWith(`/`))try{return new URL(t,n).toString()}catch{return e}return e}).join(`
|
|
12
|
-
`)}function _o(e,t,n){let r=e,i=t.site||{};if(i.title&&(r=r.replace(/<title>[^<]*<\/title>/iu,`<title>${Z(i.title)} - Not Found</title>`)),n){let e=n.endsWith(`/`)?n:n+`/`;r=r.replace(/l\.replace\(["']\/shadow-claw\/["']\)/gu,`l.replace("${Z(e)}")`)}return r}function vo(e){let t=y.resolve(e),n=t.split(y.sep),r=n[n.length-1],i=n[n.length-2];return(r===`resources`||r===`deps`)&&i===`pages`?y.resolve(t,`../..`):r===`resources`||r===`deps`||r===`pages`?y.resolve(t,`..`):t}function yo(e){let t=y.resolve(e),n=y.basename(t);return n===`resources`||n===`deps`||n===`pages`?y.resolve(t,`..`):t}function Q(e,t,n){if(!e||typeof e!=`string`)return[];if(y.isAbsolute(e))return[e];let r=e.replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),i=vo(t);return[y.resolve(t,`resources`,r),y.resolve(t,`deps`,r),y.resolve(t,`main`,r),y.resolve(i,`pages`,`resources`,r),y.resolve(i,`pages`,`resources`,e),y.resolve(i,`pages`,`deps`,r),y.resolve(i,`pages`,`deps`,e),y.resolve(i,`resources`,r),y.resolve(i,`resources`,e),y.resolve(i,`deps`,r),y.resolve(i,`deps`,e),y.resolve(n,`pages`,`resources`,r),y.resolve(n,`pages`,`deps`,r),y.resolve(n,`resources`,r),y.resolve(n,`deps`,r),y.resolve(n,`pages`,e),y.resolve(n,`pages`,r),y.resolve(n,`pages`,`main`,r),y.resolve(i,`pages`,e),y.resolve(i,`pages`,r),y.resolve(i,`pages`,`main`,r),y.resolve(i,`pages`,`main`,e),y.resolve(t,e),y.resolve(t,r),y.resolve(n,e),y.resolve(n,r),y.resolve(i,e),y.resolve(i,r)]}async function bo(e){for(let t of e)if(t)try{return await de(t),t}catch{}return null}async function xo(e,t,n){let r=n?y.dirname(y.resolve(n)):w.cwd(),i=yo(r),a=vo(r),o=[y.resolve(r,`resources`),y.resolve(r,`deps`),y.resolve(i,`resources`),y.resolve(i,`deps`),y.resolve(i,`pages`,`resources`),y.resolve(i,`pages`,`deps`),y.resolve(a,`resources`),y.resolve(a,`deps`),y.resolve(a,`pages`,`resources`),y.resolve(a,`pages`,`deps`)];for(let e of o)try{let n=await se(e,{withFileTypes:!0});for(let r of n){let n=y.join(e,r.name),i=y.join(t,r.name);r.isDirectory()?await E(n,i,{recursive:!0,force:!0}):r.isFile()&&(await D(y.dirname(i),{recursive:!0}),await T(n,i))}}catch{}let s=await bo([...e.pages?.notFoundPath?Q(e.pages.notFoundPath,r,i):[],...e.branding?.notFoundPath?Q(e.branding.notFoundPath,r,i):[],...e.notFoundPath?Q(e.notFoundPath,r,i):[],...Q(`404.html`,r,i)]);if(s)try{await T(s,y.join(t,`404.html`)),console.log(` Copied custom 404.html: ${s}`)}catch(e){console.warn(` Warning: Could not copy custom 404.html: ${e.message}`)}let c=await bo([...e.pwa?.manifestPath?Q(e.pwa.manifestPath,r,i):[],...e.manifestPath?Q(e.manifestPath,r,i):[],...Q(`manifest.json`,r,i)]);if(c)try{await T(c,y.join(t,`manifest.json`)),console.log(` Copied custom manifest.json: ${c}`)}catch(e){console.warn(` Warning: Could not copy custom manifest.json: ${e.message}`)}let l=!1;if(e.sitemapPath){let n=await bo(Q(e.sitemapPath,r,i));if(n)try{let e=y.basename(n);await T(n,y.join(t,e)),console.log(` Copied custom sitemap: ${n} → ${e}`),l=!0}catch(e){console.warn(` Warning: Could not copy custom sitemap: ${e.message}`)}}if(!l){let e=await bo(Q(`sitemap.xml`,r,i));if(e)try{await T(e,y.join(t,`sitemap.xml`)),console.log(` Copied custom sitemap.xml: ${e}`)}catch(e){console.warn(` Warning: Could not copy custom sitemap.xml: ${e.message}`)}let n=await bo(Q(`sitemap.txt`,r,i));if(n)try{await T(n,y.join(t,`sitemap.txt`)),console.log(` Copied custom sitemap.txt: ${n}`)}catch(e){console.warn(` Warning: Could not copy custom sitemap.txt: ${e.message}`)}}let u=e.overwriteAssets===!0||e.branding?.overwriteAssets===!0,d=Array.isArray(e.assets)?e.assets:[e.assetsDir,e.assets].filter(Boolean),f=Array.from(new Set([...d.flatMap(e=>Q(e,r,i)),...Q(`assets`,r,i)].filter(e=>e&&typeof e==`string`))),p=y.join(t,`assets`);if(u)try{await ue(p,{recursive:!0,force:!0}),await D(p,{recursive:!0}),console.log(` Cleared dist public assets for complete template asset overwrite.`)}catch{}let m=new Set,h=[...f].reverse();for(let e of h)if(!m.has(e))try{let t=await de(e);if(m.add(e),t.isDirectory())await E(e,p,{recursive:!0,force:!0}),console.log(` Copied custom assets: ${e} → ${p}`);else if(t.isFile()){let t=y.basename(e);await D(p,{recursive:!0}),await T(e,y.join(p,t)),console.log(` Copied custom asset file: ${e} → ${p}`)}}catch{}}async function So(e,t,n){let r=e.theme||{};if(!r.stylesheet)return;let i=n?y.dirname(y.resolve(n)):w.cwd(),a=yo(i),o=await bo(Q(r.stylesheet,i,a));if(!o)return;let s=r.stylesheet.replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),c=y.join(t,s);try{await D(y.dirname(c),{recursive:!0}),await T(o,c),console.log(` Copied theme stylesheet: ${o} → ${c}`)}catch(e){console.warn(` Warning: Could not copy theme stylesheet ${o}: ${e.message}`)}}async function Co(e,t,n){let r=(e.customElements&&typeof e.customElements==`object`&&!Array.isArray(e.customElements)?e.customElements?.scripts:void 0)||e.scripts||[];if(!Array.isArray(r)||r.length===0)return;let i=n?y.dirname(y.resolve(n)):w.cwd(),a=yo(i);for(let e of r){let n=typeof e==`string`?e:e?.src;if(!n||n.startsWith(`http://`)||n.startsWith(`https://`)||n.startsWith(`//`))continue;let r=await bo(Q(n,i,a));if(r){let e=n.replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),i=y.join(t,e);try{await D(y.dirname(i),{recursive:!0}),await T(r,i),console.log(` Copied custom script: ${r} → ${i}`)}catch(e){console.warn(` Warning: Could not copy custom script ${r}: ${e.message}`)}}}}async function wo(e,t,n){let r=e.branding||{},i=e.pwa||{},a=n?y.dirname(y.resolve(n)):w.cwd(),o=yo(a),s=[],c=await bo(Q(i.manifestPath||e.manifestPath||`manifest.json`,a,o));if(c){let e=await co(c);e&&Array.isArray(e.icons)&&(s=e.icons.map(e=>e?.src).filter(Boolean))}let l=[r.faviconPath,r.appleTouchIconPath,`assets/icons/favicon.svg`,`assets/icons/favicon.ico`,`favicon.svg`,`favicon.ico`,`pages/resources/assets/icons/favicon.svg`,`pages/resources/assets/icons/favicon.ico`,`pages/resources/favicon.svg`,`pages/deps/favicon.svg`,`pages/main/favicon.svg`,...Array.isArray(i.icons)?i.icons.map(e=>e.src):[],...s].filter(e=>!!e&&typeof e==`string`&&!e.startsWith(`http://`)&&!e.startsWith(`https://`)&&!e.startsWith(`//`));if(l.length===0)return;let u=new Set,d=new Set;for(let e of l){if(u.has(e))continue;u.add(e);let n=await bo(Q(e,a,o));if(n){let r=e.replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),i=y.join(t,r);if(d.has(i))continue;d.add(i);try{await D(y.dirname(i),{recursive:!0}),await T(n,i),console.log(` Copied branding asset: ${n} → ${i}`)}catch(e){console.warn(` Warning: Could not copy branding asset ${n}: ${e.message}`)}}}}async function To(e,t){let n=await co(t);if(!n)return console.log(`No site-config.json found — skipping site configuration.`),{applied:!1};console.log(`Applying site-config.json...`);let r=w.env.PAGES_ORIGIN||``,i=w.env.PAGES_BASE_PATH||``;await xo(n,e,t);let a=t?y.dirname(y.resolve(t)):w.cwd(),o=yo(a),s;if(n.sidebar?.slotHtml)s=n.sidebar.slotHtml;else if(n.sidebar?.sections)s=fo(n.sidebar.sections);else{let e=await bo([n.sidebar?.slotPath,`pages/main/sidebar.html`,`pages/sidebar.html`,`sidebar.html`,`resources/sidebar.html`].filter(Boolean).flatMap(e=>Q(e,a,o)));e&&(s=await lo(e)??void 0,console.log(` Found slotted sidebar: ${e}`))}let c=y.join(e,`index.html`),l=await lo(c);l&&(await uo(c,po(l,n,s)),console.log(` Patched index.html`));let u=y.join(e,`manifest.json`),d=await lo(u);d&&(await uo(u,ho(d,n)),console.log(` Patched manifest.json`));let f=y.join(e,`sitemap.xml`),p=await lo(f);p&&(await uo(f,go(p,r)),console.log(` Patched sitemap.xml`));let m=y.join(e,`sitemap.txt`),h=await lo(m);h&&(await uo(m,go(h,r)),console.log(` Patched sitemap.txt`));let g=y.join(e,`404.html`),ee=await lo(g);return ee&&(await uo(g,_o(ee,n,i)),console.log(` Patched 404.html`)),await So(n,e,t),await Co(n,e,t),await wo(n,e,t),console.log(`Site configuration applied successfully.`),{applied:!0}}async function Eo(){let[e,t]=w.argv.slice(2);(!e||!t)&&(console.error(`Usage: node bin/site-config/apply.mjs <distPublicDir> <siteConfigPath>`),w.exit(1)),await To(e,t)}w.argv[1]&&y.resolve(w.argv[1])===y.resolve(C(import.meta.url))&&Eo().catch(e=>{console.error(`site-config/apply.ts failed:`,e),w.exit(1)});async function Do(t,{writeFileImpl:n=k}={}){await n(b(t||b(e(import.meta.url),`dist`,`public`),`.nojekyll`),``,`utf-8`)}w.argv[1]&&y.resolve(w.argv[1])===y.resolve(C(import.meta.url))&&await Do();const Oo=e(import.meta.url);async function $(e){try{return await de(e),!0}catch{return!1}}async function ko(e={}){let t=e.quiet??(process.env.NODE_ENV===`test`&&!process.env.VERBOSE),n=e.stdio??(process.env.NODE_ENV===`test`&&!process.env.VERBOSE?`pipe`:`inherit`),r=(...e)=>{t||console.log(...e)};async function i(e,r={}){!t&&!r.quiet&&console.log(`> ${e}`),ae(e,{stdio:r.stdio??n,...r})}let a=te(e.contentRoot||re.SHADOWCLAW_CONTENT_ROOT||process.cwd()),o=te(e.toolchainRoot||Oo),s=a===o,{isProduction:l,copyAllAssets:u,prerenderPages:d,prerenderMainMemory:f}=Xa({...re,...e.isProduction===void 0?{}:{NODE_ENV:e.isProduction?`production`:`development`},...e.copyAllAssets===void 0?{}:{COPY_ALL_ASSETS:String(e.copyAllAssets)},...e.prerenderPages===void 0?{}:{PRERENDER_PAGES:String(e.prerenderPages)},...e.prerenderMainMemory===void 0?{}:{PRERENDER_MAIN_MEMORY:String(e.prerenderMainMemory)}});if(s){if(ne(Oo),await Ua(`dist/public`),await D(`dist/public/assets`,{recursive:!0}),u)await E(`assets`,`dist/public`,{recursive:!0});else{await E(`assets/icons`,`dist/public/assets/icons`,{recursive:!0}),await E(`assets/screenshots`,`dist/public/assets/screenshots`,{recursive:!0});try{await E(`assets/fonts`,`dist/public/assets/fonts`,{recursive:!0})}catch{}}await Wa([`pages/resources`,`pages/deps`,`resources`,`deps`,`pages/assets`,`pages/main/assets`],`dist/public`);for(let e of qa())await Ga(e.sources,e.dest,e.opts||{});try{await E(`e2e/README.md`,`dist/public/e2e/README.md`)}catch{}try{await E(`pages`,`dist/public/pages`,{recursive:!0})}catch{}try{await E(`pages/main`,`dist/public/files/main`,{recursive:!0})}catch{}try{await E(`pages/main`,`dist/public/static-main`,{recursive:!0})}catch{}try{await E(`.agents/skills`,`dist/public/.agents/skills`,{recursive:!0})}catch{}try{await E(`.agents/tools`,`dist/public/.agents/tools`,{recursive:!0})}catch{}try{await E(`.agents/scripts`,`dist/public/.agents/scripts`,{recursive:!0})}catch{}if(await $(`.agents/skills`))try{let{generateSkillsIndex:e}=await import(`./chunk-BT2f5jvi.js`);await e(Oo)}catch(e){console.warn(`Notice: Failed to auto-generate agent-skills index:`,e)}if(await $(`.well-known`))try{await E(`.well-known`,`dist/public/.well-known`,{recursive:!0,force:!0})}catch{}await i(`npm run -s rolldown`),f?await c({indexPath:`dist/public/index.html`,sourcePath:`pages/main`,prerenderPages:d}):await c({indexPath:`dist/public/index.html`,noSeed:!0});let t=await Ka(Ya())||`pages/site-config.json`;try{await To(`dist/public`,t)}catch{}try{let e=JSON.parse(await O(`package.json`,`utf8`));if(e.version){let t=`dist/public/index.html`;await k(t,(await O(t,`utf8`)).replace(/<meta\s+name="version"[^>]*>/,`<meta name="version" content="${e.version}" />`),`utf8`);for(let t of[`.well-known/mcp.json`,`.well-known/mcp/server-card.json`]){let n=b(`dist/public`,t);if(await $(n))try{let t=JSON.parse(await O(n,`utf8`));t.version!==e.version&&(t.version=e.version,await k(n,JSON.stringify(t,null,2)+`
|
|
13
|
-
`,`utf8`))}catch{}}}}catch{}if(l){r(`Running production post-build steps...`);let t=e.pagesOrigin||re.PAGES_ORIGIN,n=e.basePath||(re.PAGES_BASE_PATH??`/shadow-claw/`);if(r(` PAGES_ORIGIN : ${t||`(relative ./)`}`),r(` PAGES_BASE_PATH: ${n}`),t)try{let e=`dist/public/manifest.json`,n=await O(e,`utf8`),r=JSON.parse(n);r.start_url&&(r.start_url=t,await k(e,JSON.stringify(r,null,2),`utf8`))}catch{}try{let e=`dist/public/index.html`,t=await O(e,`utf8`);t=t.replace(/<base\s+href="[^"]*"\s*\/?>/i,`<base href="${n}" />`),await k(e,t,`utf8`)}catch{}await Do(`dist/public`);let a=``;try{a=ae(`npm run -s build:pkg:get:meta`,{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{}a&&await i(`npm run -s build:pkg:meta "${a}"`)}await eo({publicDir:`dist/public`,routesPath:await Ka(Ja())||`pages/routes.json`,sourcePath:`pages/main`,prerenderPages:d}),await i(`npm run -s build:service-worker`);let n=`dist/public/service-worker.js`;await $(n)&&await _(n,{logImpl:()=>{}}),r(`Build completed successfully.`);return}let p=te(a,e.outDir||`dist/public`);await D(p,{recursive:!0}),await D(b(p,`assets`),{recursive:!0});let m=b(o,`dist/public`);await $(b(m,`index.js`))||(r(`Building ShadowClaw core toolchain...`),await Ua(b(o,`dist/public`)),await Ua(b(o,`dist-electron`)),await i(`npm run -s rolldown`,{cwd:o})),await E(m,p,{recursive:!0,filter:e=>!(e.includes(`/assets/cache/`)||e.includes(`\\assets\\cache\\`)||e.includes(`/.cache/`)||e.includes(`\\.cache\\`))});let h=b(a,`assets`);await $(h)&&(u?await E(h,p,{recursive:!0,force:!0}):(await $(b(h,`icons`))&&await E(b(h,`icons`),b(p,`assets/icons`),{recursive:!0,force:!0}),await $(b(h,`screenshots`))&&await E(b(h,`screenshots`),b(p,`assets/screenshots`),{recursive:!0,force:!0}),await $(b(h,`fonts`))&&await E(b(h,`fonts`),b(p,`assets/fonts`),{recursive:!0,force:!0}))),await Wa([`pages/resources`,`pages/deps`,`resources`,`deps`,`pages/assets`,`pages/main/assets`],p,{baseDir:a});let g=qa({contentRoot:a,toolchainRoot:o,distPublicDir:p});for(let e of g)await Ga(e.sources,e.dest,e.opts||{});let ee=b(a,`pages`);await $(ee)&&await E(ee,b(p,`pages`),{recursive:!0,force:!0});let v=b(a,`pages/main`);await $(v)&&(await E(v,b(p,`files/main`),{recursive:!0,force:!0}),await E(v,b(p,`static-main`),{recursive:!0,force:!0}));let y=b(a,`.agents/skills`);await $(y)&&await E(y,b(p,`.agents/skills`),{recursive:!0,force:!0});let x=b(o,`.agents/skills`);a!==o&&await $(x)&&await E(x,b(p,`.agents/skills`),{recursive:!0,force:!1,errorOnExist:!1});let S=b(a,`.agents/tools`);if(await $(S))await E(S,b(p,`.agents/tools`),{recursive:!0,force:!0});else{let e=b(o,`.agents/tools`);await $(e)&&await E(e,b(p,`.agents/tools`),{recursive:!0,force:!0})}let C=b(a,`.agents/scripts`);if(await $(C))await E(C,b(p,`.agents/scripts`),{recursive:!0,force:!0});else{let e=b(o,`.agents/scripts`);await $(e)&&await E(e,b(p,`.agents/scripts`),{recursive:!0,force:!0})}let w=b(o,`.well-known`);await $(w)&&await E(w,b(p,`.well-known`),{recursive:!0,force:!0});let ie=b(a,`.well-known`);if(a!==o&&await $(ie)&&await E(ie,b(p,`.well-known`),{recursive:!0,force:!0}),await $(b(p,`.agents/skills`)))try{let{generateSkillsIndex:e}=await import(`./chunk-BT2f5jvi.js`);if(await e(p,{metadataRoot:a,outDir:`.well-known/agent-skills`,toolchainRoot:o,includeBundled:!0}),await $(y))try{await e(a,{toolchainRoot:o,includeBundled:!0})}catch{}}catch(e){console.warn(`Notice: Failed to auto-generate agent-skills index:`,e)}let T=b(p,`index.html`);f&&await $(v)?await c({indexPath:T,sourcePath:v,prerenderPages:d}):await c({indexPath:T,noSeed:!0});let oe=await Ka(Ya(a))||b(a,`pages/site-config.json`);try{await To(p,oe)}catch{}let se=l?e.basePath||re.PAGES_BASE_PATH||`/`:e.basePath||`/`;try{let e=await O(T,`utf8`);e=e.replace(/<base\s+href="[^"]*"\s*\/?>/i,`<base href="${se}" />`);let t=``;try{let e=await Ka([b(a,`package.json`),b(o,`package.json`)]);e&&(t=JSON.parse(await O(e,`utf8`)).version||``)}catch{}if(t){e=e.replace(/<meta\s+name="version"[^>]*>/,`<meta name="version" content="${t}" />`);for(let e of[`.well-known/mcp.json`,`.well-known/mcp/server-card.json`]){let n=b(p,e);if(await $(n))try{let e=JSON.parse(await O(n,`utf8`));e.version!==t&&(e.version=t,await k(n,JSON.stringify(e,null,2)+`
|
|
14
|
-
`,`utf8`))}catch{}}}await k(T,e,`utf8`)}catch{}if(l){r(`Running production post-build steps...`);let t=e.pagesOrigin||re.PAGES_ORIGIN;if(r(` PAGES_ORIGIN : ${t||`(relative ./)`}`),r(` PAGES_BASE_PATH: ${se}`),t)try{let e=b(p,`manifest.json`),n=await O(e,`utf8`),r=JSON.parse(n);r.start_url&&(r.start_url=t,await k(e,JSON.stringify(r,null,2),`utf8`))}catch{}await k(b(p,`.nojekyll`),``,`utf8`);let n=``;try{n=ae(`git rev-parse HEAD`,{cwd:a,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{try{n=ae(`git rev-parse HEAD`,{cwd:o,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{}}n&&await k(T,(await O(T,`utf8`)).replace(/<meta\s+name="revision"[^>]*>/,`<meta name="revision" content="${n}" />`),`utf8`)}await eo({publicDir:p,routesPath:await Ka(Ja(a))||b(a,`pages/routes.json`),sourcePath:await $(v)?v:b(o,`pages/main`),prerenderPages:d});let ce=b(p,`service-worker.js`);await $(ce)&&await _(ce,{logImpl:()=>{}}),r(`Build completed successfully.`)}process.argv[1]&&te(process.argv[1])===te(C(import.meta.url))&&ko().catch(e=>{console.error(e),ie(1)});export{ko as t};
|