@fnet/cli 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fnet/index.js +10 -10
- package/dist/fnode/index.js +6 -6
- package/package.json +1 -1
package/dist/fnet/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{a as K0,b as J0}from"./index.qt2n23jk.js";import{c as b,d as l6,e as P}from"./index.aqy4k3s3.js";var i6=l6((H3,p6)=>{p6.exports=c6;function c6($,Q,Z){if($ instanceof RegExp)$=m6($,Z);if(Q instanceof RegExp)Q=m6(Q,Z);var X=d6($,Q,Z);return X&&{start:X[0],end:X[1],pre:Z.slice(0,X[0]),body:Z.slice(X[0]+$.length,X[1]),post:Z.slice(X[1]+Q.length)}}function m6($,Q){var Z=Q.match($);return Z?Z[0]:null}c6.range=d6;function d6($,Q,Z){var X,q,J,Y,V,W=Z.indexOf($),H=Z.indexOf(Q,W+1),_=W;if(W>=0&&H>0){if($===Q)return[W,H];X=[],J=Z.length;while(_>=0&&!V){if(_==W)X.push(_),W=Z.indexOf($,_+1);else if(X.length==1)V=[X.pop(),H];else{if(q=X.pop(),q<J)J=q,Y=H;H=Z.indexOf(Q,_+1)}_=W<H&&W>=0?W:H}if(X.length)V=[J,Y]}return V}});var $5=l6((K3,e6)=>{var n6=i6();e6.exports=R7;var r6="\x00SLASH"+Math.random()+"\x00",s6="\x00OPEN"+Math.random()+"\x00",T$="\x00CLOSE"+Math.random()+"\x00",o6="\x00COMMA"+Math.random()+"\x00",a6="\x00PERIOD"+Math.random()+"\x00";function F$($){return parseInt($,10)==$?parseInt($,10):$.charCodeAt(0)}function L7($){return $.split("\\\\").join(r6).split("\\{").join(s6).split("\\}").join(T$).split("\\,").join(o6).split("\\.").join(a6)}function B7($){return $.split(r6).join("\\").split(s6).join("{").split(T$).join("}").split(o6).join(",").split(a6).join(".")}function t6($){if(!$)return[""];var Q=[],Z=n6("{","}",$);if(!Z)return $.split(",");var{pre:X,body:q,post:J}=Z,Y=X.split(",");Y[Y.length-1]+="{"+q+"}";var V=t6(J);if(J.length)Y[Y.length-1]+=V.shift(),Y.push.apply(Y,V);return Q.push.apply(Q,Y),Q}function R7($){if(!$)return[];if($.substr(0,2)==="{}")$="\\{\\}"+$.substr(2);return f0(L7($),!0).map(B7)}function C7($){return"{"+$+"}"}function I7($){return/^-?0\d/.test($)}function F7($,Q){return $<=Q}function T7($,Q){return $>=Q}function f0($,Q){var Z=[],X=n6("{","}",$);if(!X)return[$];var q=X.pre,J=X.post.length?f0(X.post,!1):[""];if(/\$$/.test(X.pre))for(var Y=0;Y<J.length;Y++){var V=q+"{"+X.body+"}"+J[Y];Z.push(V)}else{var W=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(X.body),H=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(X.body),_=W||H,K=X.body.indexOf(",")>=0;if(!_&&!K){if(X.post.match(/,.*\}/))return $=X.pre+"{"+X.body+T$+X.post,f0($);return[$]}var G;if(_)G=X.body.split(/\.\./);else if(G=t6(X.body),G.length===1){if(G=f0(G[0],!1).map(C7),G.length===1)return J.map(function(P1){return X.pre+G[0]+P1})}var M;if(_){var O=F$(G[0]),z=F$(G[1]),U=Math.max(G[0].length,G[1].length),A=G.length==3?Math.abs(F$(G[2])):1,L=F7,R=z<O;if(R)A*=-1,L=T7;var T=G.some(I7);M=[];for(var c=O;L(c,z);c+=A){var D;if(H){if(D=String.fromCharCode(c),D==="\\")D=""}else if(D=String(c),T){var t=U-D.length;if(t>0){var S0=Array(t+1).join("0");if(c<0)D="-"+S0+D.slice(1);else D=S0+D}}M.push(D)}}else{M=[];for(var e=0;e<G.length;e++)M.push.apply(M,f0(G[e],!1))}for(var e=0;e<M.length;e++)for(var Y=0;Y<J.length;Y++){var V=q+M[e]+J[Y];if(!Q||_||V)Z.push(V)}}return Z}});import M2 from"yargs";import b1 from"chalk";import{promisify as E1}from"util";import k1 from"tree-kill";var Y6=E1(k1),C0=!1;async function u8($,Q){if(C0)return;if(C0=!0,!$.killed&&$.pid)try{if(await Y6($.pid,"SIGTERM").catch(()=>{}),await new Promise((X)=>setTimeout(X,500)),!$.killed)await Y6($.pid,"SIGKILL").catch(()=>{})}catch(X){}await new Promise((X)=>setTimeout(X,100));let Z=Q==="SIGINT"?130:Q==="SIGTERM"?143:1;process.exit(Z)}function f8($){["SIGINT","SIGTERM","SIGQUIT"].forEach((Q)=>{process.once(Q,async()=>{await u8($,Q)})}),process.on("uncaughtException",async(Q)=>{await u8($)}),process.on("unhandledRejection",async(Q)=>{await u8($)}),$.on("close",(Q)=>{if(!C0)process.exit(Q)})}function V6(){process.on("uncaughtException",($)=>{if(!C0)C0=!0,setTimeout(()=>process.exit(1),500)}),process.on("unhandledRejection",($)=>{if(!C0)C0=!0,setTimeout(()=>process.exit(1),500)})}import q8 from"path";import{spawn as W6}from"child_process";import J8 from"fs";import u0 from"chalk";import y1 from"@fnet/config";function m($,{name:Q,bin:Z,preArgs:X=[],createContext:q}){if(typeof Z==="function")Z=Z();return $.command(`${Q||Z} [commands..]`,`${Z} ${X.join(" ")}`,(J)=>{return J.help(!1).version(!1)},async(J)=>{try{let Y=await q(J),{projectDir:V}=Y,W=(G)=>{if(!G.includes(" "))return G;if(process.platform==="win32")return`"${G.replace(/(["^])/g,"^$1")}"`;else return`"${G.replace(/(["\\$`])/g,"\\$1")}"`},H=process.argv.slice(3).map(W),_={...process.env},K=W6(Z,[...X,...H],{cwd:V,stdio:"inherit",shell:!0,detached:!0,env:_});f8(K)}catch(Y){console.error(Y.message),process.exit(1)}})}function H6($,{name:Q,preArgs:Z=[],createContext:X}){return $.command(`${Q} <config> <command> [options..]`,"Run a command with a config context",(q)=>{return q.positional("config",{type:"string"}).positional("command",{type:"string"}).help(!1).version(!1)},async(q)=>{try{let J=await X(q),{projectDir:Y}=J,V=q.config,H=(await y1({name:V,dir:Y,transferEnv:!1,optional:!0,tags:J.tags}))?.data?.env||void 0,_=q.command,K=process.argv.slice(5),G=W6(_,[...Z,...K],{cwd:J8.existsSync(Y)?Y:process.cwd(),stdio:"inherit",shell:!0,detached:!0,env:{...process.env,...H}});f8(G)}catch(J){console.error(J.message),process.exit(1)}})}function K6($,{name:Q,projectType:Z="auto"}){return $.command(`${Q} group [options..]`,"Run a command group.",(X)=>{return X.positional("group",{type:"string"}).option("ftag",{type:"array"}).help(!1).version(!1)},async(X)=>{try{let{runCommandGroup:q}=await import("./index.44a1c2n0.js");await q({projectType:Z,group:X.group,tags:X.ftag,args:X,argv:process.argv})}catch(q){console.error(q.message),process.exit(1)}})}function _6($,{name:Q,createContext:Z}){return $.command(`${Q} [options]`,"Install the project as a binary",(X)=>{return X.option("name",{alias:"n",describe:"Name to use for the installed binary",type:"string"}).option("force",{alias:"f",describe:"Force overwrite if binary already exists",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Automatically answer yes to all prompts",type:"boolean",default:!1})},async(X)=>{try{let q=await Z(X),{projectDir:J}=q;console.log(u0.blue("Compiling project..."));let Y=q8.join(J,".bin");if(!J8.existsSync(Y))J8.mkdirSync(Y,{recursive:!0});let V=q8.basename(q8.dirname(J)),W=q.project?.projectFileParsed?.features?.cli?.bin,H=X.name||W||V;console.log(u0.blue(`Using binary name: ${H}`));let _=q8.join(Y,H),{spawn:K}=await import("child_process"),G=K("bun",["build","./dist/cli/esm/index.js","--compile",`--outfile=${_}`],{cwd:J,stdio:"inherit",shell:!0});if(await new Promise((z,U)=>{G.on("close",(A)=>{if(A===0)z();else U(Error(`Compilation failed with code ${A}`))}),G.on("error",(A)=>{U(A)})}),process.platform!=="win32")J8.chmodSync(_,493);console.log(u0.green(`Binary compiled successfully: ${_}`)),console.log(u0.blue("Installing binary..."));let M=["install",_];if(X.name)M.push("--name",X.name);if(X.force)M.push("--force");if(X.yes)M.push("--yes");let O=K("fbin",M,{stdio:"inherit",shell:!0});await new Promise((z,U)=>{O.on("close",(A)=>{if(A===0)z();else U(Error(`Installation failed with code ${A}`))}),O.on("error",(A)=>{U(A)})})}catch(q){console.error(u0.red(`Failed to install binary: ${q.message}`)),process.exit(1)}})}import q0 from"path";import I0 from"fs";import g8 from"@fnet/yaml";import D1 from"yaml";async function j($){if($.id)return{id:$.id,buildId:$.buildId,mode:$.mode,protocol:$.protocol||"ac:",templateDir:K0("./template/fnet/node"),coreDir:K0("./template/fnet/core"),projectDir:q0.resolve(process.cwd(),`./.output/${$.id}`),tags:$.ftag,dev:$.dev};else try{let Q=await v1({tags:$.ftag});return{buildId:$.buildId,mode:$.mode,protocol:$.protocol||"src:",templateDir:K0("./template/fnet/node"),coreDir:K0("./template/fnet/core"),projectDir:q0.resolve(Q.projectDir,"./.workspace"),projectSrcDir:q0.resolve(Q.projectDir,"./src"),project:Q,tags:$.ftag,dev:$.dev}}catch(Q){return console.warn(`Warning: Could not load project: ${Q.message}`),{projectDir:process.cwd(),tags:$.ftag}}}async function v1({tags:$}){let Q=x1(process.cwd());if(!I0.existsSync(Q))throw Error("fnet.yaml file not found in current directory.");let{raw:Z,parsed:X}=await g8({file:Q,tags:$}),q=q0.dirname(Q);X.features=X.features||{};let J=X.features;J.runtime=J.runtime||{},J.runtime.type=J.runtime.type||"node";let Y;if(typeof X.flows==="object")Y=X.flows;else{let K="flow.main.yaml";if(I0.existsSync(q0.join(q,"fnet","flows.yaml")))K=q0.join("fnet","flows.yaml");let G=X.main||K,M=q0.resolve(q,G);if(!I0.existsSync(M))Y={main:{steps:[]}};else{let{parsed:O}=await g8({file:M,tags:$});Y=O}}let W={workflowAtom:{doc:{...X,content:Y}},projectDir:q,projectFilePath:Q,projectFileContent:Z,projectFileParsed:X,runtime:J.runtime},H=q0.resolve(q,"fnet/targets.yaml");if(I0.existsSync(H)){let{raw:K,parsed:G}=await g8({file:H,tags:$}),M=D1.parseDocument(K);W.devops={filePath:H,fileContent:K,yamlDocument:M,doc:{...G},type:"workflow.deploy",save:async()=>{I0.writeFileSync(W.devops.filePath,M.toString())}}}let _=q0.resolve(q,"readme.md");if(I0.existsSync(_)){let K=I0.readFileSync(_,"utf8");W.readme={filePath:_,fileContent:K,doc:{content:K,"content-type":"markdown"},type:"wiki"}}return W}function x1($){return q0.resolve($,"fnet.yaml")}import u1 from"path";import G6 from"fs";import f1 from"os";import g1 from"@flownet/lib-render-templates-dir";import h8 from"@fnet/shelljs";var h1={command:"create",describe:"Initialize a new fnet project",builder:($)=>{return $.option("name",{type:"string",describe:"Project name"}).option("vscode",{type:"boolean",default:!0,alias:"vs",describe:"Open in VS Code after creation"}).option("runtime",{type:"string",default:"node",choices:["node"],describe:"Runtime environment"})},handler:async($)=>{try{let Q=process.cwd(),Z=K0("./template/fnet/project"),X=u1.resolve(Q,$.name);if(!G6.existsSync(X))G6.mkdirSync(X);await g1({dir:Z,outDir:X,context:$,copyUnmatchedAlso:!0,platform:f1.platform()});let q=await h8("fnet build",{cwd:X});if(q.code!==0)throw Error("Failed to build project.");if(J0("git")){if(q=await h8("git init --initial-branch=main",{cwd:X}),q.code!==0)throw Error("Failed to initialize git.")}if(J0("code")&&$.vscode){if(q=await h8(`cd ${X} && code .`),q.code!==0)throw Error("Failed to open vscode.")}console.log("Creating project succeeded!"),process.exit(0)}catch(Q){console.error("Initialization failed!",Q.message),process.exit(1)}}},z6=h1;import m1 from"os";import l1 from"@flownet/lib-render-templates-dir";import c1 from"@fnet/shelljs";var d1={command:"project",describe:"Manage fnet project",builder:($)=>{return $.option("update",{type:"boolean",default:!1,alias:"-u",describe:"Update project files"})},handler:async($)=>{try{let Q=K0("./template/fnet/project"),Z=process.cwd(),X=await j($);if($.update){if(await l1({dir:Q,outDir:Z,context:{name:X.project.projectFileParsed.name,runtime:"node"},copyUnmatchedAlso:!0,platform:m1.platform()}),(await c1("fnet build",{cwd:Z})).code!==0)throw Error("Failed to build project.");console.log("Updating project succeeded!")}process.exit(0)}catch(Q){console.error("Project failed.",Q.message),process.exit(1)}}},U6=d1;import I from"fs";import w from"path";import K1 from"yaml";import _1 from"@fnet/shelljs";import X8 from"nunjucks";import G1 from"lodash.clonedeep";import lQ from"isobject";import{randomUUID as z1}from"crypto";import{Api as Y8}from"@flownet/lib-atom-api-js";class M6{init({config:$,accessToken:Q}){return new Promise((Z,X)=>{if(Y8.set_api_url($.data.url),Q){Y8.set_req_token(Q),Z(Q);return}fetch(`${$.data.issuer}/protocol/openid-connect/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams($.data.grant.params)}).then(async(q)=>{if(!q.ok)throw Error(await q.text());return q.json()}).then((q)=>{Y8.set_req_token(q.access_token),Z(q.access_token)}).catch((q)=>{Y8.set_req_token(),X(q)})})}}import N0 from"lodash.merge";import V8 from"fs";import $0 from"path";import b0 from"@flownet/lib-parse-imports-js";import p1 from"lodash.merge";function S({feature:$,features:Q,packageDevDependencies:Z}){let{name:X,packages:q,options:J,extraCheck:Y,explicit:V}=$,W=`${X}_enabled`,H=Q.rollup_output||{},_=Object.keys(H),K=J||{},G=Q[X]?.options;if(G)K=p1(K,G);let M=!Q[X]||Q[X]?.enabled===!1;_.forEach((z)=>{let U=Q.rollup_output[z];if(!U)return;if(Reflect.has(U,X)){if(M||!U[X]||U[X]?.enabled===!1){delete U[X];return}if(U[X]===!0)U[X]={enabled:!0,options:K}}else if(!M&&!V&&Q[W]!==!1)U[X]={enabled:!0};else return;U[X]=U[X]||{},U[X].options={...K,...U[X].options}});let O=_.some((z)=>Q.rollup_output[z][X]?.enabled===!0);if(Y)O=Y()&&O;if(Q[W]=O,O)q.forEach((z)=>Z.push({package:z[0],version:z[1]}))}function m8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"workbox",packages:[["rollup-plugin-workbox","^8"]],options:{generate:{swDest:"dist/app/esm/sw.js",globDirectory:"dist/app/esm",globPatterns:["**/*.{html,js,css,png,jpg}"],skipWaiting:!0,clientsClaim:!0}},explicit:!0},features:X,packageDevDependencies:Z})}function l8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"gzip",packages:[["rollup-plugin-gzip","^4"]],explicit:!0},features:X,packageDevDependencies:Z})}function c8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"nunjucks",packages:[["@fnet/rollup-plugin-nunjucks","0.1.8"]]},features:X,packageDevDependencies:Z})}function d8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"polyfill",packages:[["rollup-plugin-node-polyfills","^0.2"]]},features:X,packageDevDependencies:Z})}function p8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"visualizer",packages:[["rollup-plugin-visualizer","^5"]],expilicit:!0},features:X,packageDevDependencies:Z})}function i8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"analyzer",packages:[["rollup-plugin-analyzer","^3"]],options:{summaryOnly:!0,limit:12},explicit:!0},features:X,packageDevDependencies:Z})}function n8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"string",packages:[["rollup-plugin-string","^3"]]},features:X,packageDevDependencies:Z})}function r8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"image",packages:[["@rollup/plugin-image","^3"]]},features:X,packageDevDependencies:Z})}function s8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;if(X.runtime.type==="bun")return;S({feature:{name:"json",packages:[["@rollup/plugin-json","^6"]]},features:X,packageDevDependencies:Z})}function o8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"terser",packages:[["@rollup/plugin-terser","^0.4"]]},features:X,packageDevDependencies:Z})}function a8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"wasm",packages:[["@rollup/plugin-wasm","^6"]]},features:X,packageDevDependencies:Z})}function t8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;if(X.runtime.type==="bun")return;let q={};if(X.app?.enabled===!0){if(q.targets=q.targets||[],q.targets.push({src:"./src/app/index.html",dest:X.app.dir}),!Reflect.has(X.app,"copy")){if(!Reflect.has(X,"copy"))X.copy=!0}}S({feature:{name:"copy",packages:[["rollup-plugin-copy","^3"],["chokidar","^3"]],options:q},features:X,packageDevDependencies:Z})}function e8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features,q=X.css&&X.css.enabled!==!1,J=[];if(q)J.push(["rollup-plugin-postcss","^4"]),J.push(["sass","^1.66"]),(X.css?.options?.plugins||[]).forEach((V)=>{switch(V.name){case"postcss-import":J.push(["postcss-import","^15"]);break;case"postcss-url":J.push(["postcss-url","^10"]);break;case"postcss-preset-env":J.push(["postcss-preset-env","^9"]);break;case"autoprefixer":J.push(["autoprefixer","^10"]);break;case"cssnano":J.push(["cssnano","^6"]);break}});S({feature:{name:"css",packages:J},features:X,packageDevDependencies:Z})}function $$({dir:$,name:Q="index"}){let Z=$0.resolve($,`./${Q}.tsx`);if(!V8.existsSync(Z))Z=$0.resolve($,`./${Q}.ts`);if(!V8.existsSync(Z))Z=$0.resolve($,`./${Q}.jsx`);if(!V8.existsSync(Z))Z=$0.resolve($,`./${Q}.js`);if(!V8.existsSync(Z))return{};let X=Z,q=$0.extname(Z);return{file:X,ext:q,ts:q===".ts"||q===".tsx",name:Q}}async function Q$($){let{atom:Q,context:Z,setProgress:X}=$;X("Initializing features..."),Q.doc.features=Q.doc.features||{};let q=Q.doc.features;q.project=q.project||{},q.project.format=q.project.format||q.project_format||"esm",q.project_format=q.project.format,q.dts_enabled=q.dts===!0||typeof q.dts<"u"&&q.dts!==!1;let J=$0.resolve(Z.project.projectDir),Y=$$({dir:$0.resolve(J,"./app")});if(Y.file){X("Parsing app entry imports...");let z=await b0({file:Y.file,recursive:!0}),U=z.all.some((A)=>A.usesJSX===!0&&A.type==="local");q.app_uses_jsx=U,q.app_has_entry=!0,z=await b0({file:Y.file}),U=z.all.some((A)=>A.usesJSX===!0&&A.type==="local"),q.app_entry_uses_jsx=U,q.app_entry_is_ts=Y.ts,q.app_entry_ext=Y.ext}let V=$$({dir:$0.resolve(J,"./cli")});if(V.file){X("Parsing cli entry imports...");let z=await b0({file:V.file,recursive:!0}),U=z.all.some((A)=>A.usesJSX===!0&&A.type==="local");q.cli_uses_jsx=U,q.cli_has_entry=!0,z=await b0({file:V.file}),U=z.all.some((A)=>A.usesJSX===!0&&A.type==="local"),q.cli_entry_uses_jsx=U,q.cli_entry_is_ts=V.ts,q.cli_entry_ext=V.ext}if(Q.type==="workflow.lib"){let z=$$({dir:$0.resolve(J,"./src")});if(z.file){X("Parsing src entry imports...");let U=await b0({file:z.file,recursive:!0}),A=U.all.some((L)=>L.usesJSX===!0&&L.type==="local");q.src_uses_jsx=A,q.src_has_entry=!0,U=await b0({file:z.file}),A=U.all.some((L)=>L.usesJSX===!0&&L.type==="local"),q.src_entry_uses_jsx=A,q.src_entry_is_ts=z.ts,q.src_entry_ext=z.ext}}let W=Reflect.has(q,"app_entry_uses_jsx")?q.app_entry_uses_jsx===!0:q.src_entry_uses_jsx===!0,H=Reflect.has(q,"cli_entry_uses_jsx")?q.cli_entry_uses_jsx===!0:q.src_entry_uses_jsx===!0;if(q.form_enabled=W||H||q.form===!0||q.form?.enabled===!0,q.multiple_enabled=q.multiple_enabled||q.multiple===!0||q.multiple?.enabled===!0,q.app===!1)q.app={enabled:!1};else if(q.app===!0)q.app={enabled:!0,extend:q.app_has_entry===!0,export:!0,react:W};else q.app={enabled:!0,extend:q.app_has_entry===!0,export:!0,react:W,...q.app||{}};if(q.app.enabled=q.app.enabled===!0&&(Q.doc.features.form_enabled===!0||q.app.extend===!0||q.app.enabled===!0),q.app.format=q.app.format||"esm",q.app.folder=q.app.folder||q.app.format||"default",q.cli===!1)q.cli={enabled:!1};else if(q.cli===!0)q.cli={enabled:!0,extend:q.cli_has_entry===!0,export:!0,react:H};else q.cli={enabled:!0,extend:q.cli_has_entry===!0,export:!0,react:H,...q.cli||{}};if(q.cli.enabled=q.cli.enabled===!0&&(Q.doc.features.form_enabled===!1||q.cli.extend===!0||q.cli.enabled===!0),q.cli.format=q.cli.format||"esm",q.cli.folder=q.cli.folder||q.cli.folder||"esm",q.cli.node_options=q.cli.node?.options||q.cli.node_options||"",q.cli.bin=q.cli.bin||Q.doc.name,q.cli.installable=q.cli.installable===!0,q.cli.enabled)Q.doc["npm::bin"]=q.cli.bin;q.json=q.cli.enabled||q.json;let _={cjs:{format:"cjs",context:q.form_enabled?"window":"global",babel:q.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!0,enabled:q.cjs!==!1,copy:!1},esm:{format:"esm",context:q.form_enabled?"window":"global",babel:q.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!1,enabled:q.esm!==!1,copy:!0},iife:{format:"iife",context:q.form_enabled?"window":"global",babel:!0,browser:!0,replace:!0,enabled:q.iife===!0,terser:!0,copy:!1}},K={targets:{browsers:"last 9 versions, not dead",node:"18"}},G={};if(q.webos===!0)_.webos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,input:"./src/app/index.js",output_dir:"./dist/app/webos",copy:!1,babel_options:{targets:{chrome:"79"}}};if(q.electron===!0)_.electron={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/electron"};if(q.nextjs===!0)_.nextjs={format:"esm",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/nextjs"};if(q.ios===!0)_.ios={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/ios"};if(q.macos===!0)_.macos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/macos"};if(q.app.enabled===!0)q.app.dir=`./dist/app/${q.app.folder}`,q.app.output={file:`./dist/app/${q.app.folder}/index.js`,dir:`./dist/app/${q.app.folder}/`,...q.app.output||{}},q.app.input={file:"./src/app/index.js",dir:"./src/app/",...q.app.input||{}},_.app={format:q.app.format,browser:!0,babel:!0,context:"window",replace:!0,input:q.app.input.file,output_dir:q.app.dir,terser:!0,output_exports:q.app.export===!1?"none":"auto",browsersync:!0};if(q.cli.enabled===!0)q.cli.dir=`./dist/cli/${q.cli.folder}`,q.cli.output={file:`./dist/cli/${q.cli.folder}/index.js`,dir:`./dist/cli/${q.cli.folder}/`,...q.cli.output||{}},q.cli.input={file:"./src/cli/index.js",dir:"./src/cli/",...q.cli.input||{}},_.cli={format:q.cli.format,context:"global",babel:q.src_uses_jsx===!0||q.cli_uses_jsx===!0||!1,browser:!1,replace:!0,enabled:!0,input:q.cli.input.file,output_dir:q.cli.dir,banner:"#!/usr/bin/env bun",terser:!0,output_exports:q.cli.export===!1?"none":"auto"};let M={server:".",startPath:`${$0.normalize(q.app.dir||".")}`,files:[$0.normalize("./dist/**/*")],cors:!0,open:!1};if(q.babel_options=N0(K,q.babel_options||q.babel?.options),q.browsersync_options=N0(M,q.browsersync_options||q.browsersync?.options||{}),q.replace_options=N0(G,q.replace_options||q.replace?.options||{}),Reflect.has(q.browsersync_options,"proxy"))delete q.browsersync_options.server;q.rollup=q.rollup||{},q.rollup_output=N0(_,q.rollup_output||q.rollup?.output||{}),q.preact_enabled=q.preact===!0||q.preact&&q.preact?.enabled!==!1;let O=Object.keys(_);for(let z of O){let U=_[z];if(!U)continue;if(q.rollup[z]===!1){delete q.rollup_output[z];continue}if(U.babel_options=U.babel_options||q.babel_options,U.browsersync_options=N0(q.browsersync_options,U.browsersync_options),U.replace_options=N0(q.replace_options,U.replace_options),q.preact_enabled)U.alias_enabled=!0,U.alias=U.alias||{},U.alias.entries=U.alias.entries||{},U.alias.entries.react="preact/compat",U.alias.entries["react-dom"]="preact/compat";if(q.form_enabled||q.babel)U.babel=!0}O=Object.keys(q.rollup_output),q.babel_enabled=O.some((z)=>q.rollup_output[z].babel===!0),q.browser_enabled=O.some((z)=>q.rollup_output[z].babel===!0),q.browsersync_enabled=q.browsersync!==!1&&O.some((z)=>q.rollup_output[z].browsersync===!0),q.browsersync_enabled=q.browsersync_enabled&&q.app.enabled,q.dependency_auto_enabled=q.dependency_auto!==!1&&q.dependency_auto?.enabled!==!1,q.npm_install_flags=q.npm_install_flags||"",q.react_version=q.react_version||q.react?.version||18,e8($),t8($),a8($),o8($),s8($),n8($),r8($),i8($),p8($),d8($),c8($),m8($),l8($)}import i1 from"@fnet/npm-list-versions";async function Z$({atom:$,packageDependencies:Q,packageDevDependencies:Z,setProgress:X}){X("Initializing dependencies");let q=$.doc.dependencies||[];if(q.filter((J)=>!J.dev).forEach((J)=>Q.push(J)),q.filter((J)=>J.dev).forEach((J)=>Z.push(J)),$.type==="workflow")Q.push({package:"get-value",version:"^3"}),Q.push({package:"set-value",version:"^4"});if($.doc.features.form_enabled){if($.doc.features.dependency_auto_enabled){let J="^18.2";if(X("Fetching React versions"),J=`^${(await i1({name:"react",groupBy:{major:!0}})).find((W)=>W[0]===$.doc.features.react_version.toString())[0]}`,Q.push({package:"react",version:J}),Q.push({package:"react-dom",version:J}),$.type==="workflow")Q.push({package:"@fnet/react-app",version:"^0.1"}),Q.push({package:"@fnet/react-app-state",version:"^0.1"})}}if($.doc.features.preact_enabled)Q.push({package:"preact",version:"^10"});if($.doc.features.cli.enabled===!0){if(Q.push({package:"@fnet/args",version:"^0.1"}),$.doc.features.cli.fargs&&$.doc.features.cli.fargs?.enabled!==!1)Q.push({package:"@fnet/config",version:"0.2.21"});if($.doc.features.cli.mcp&&$.doc.features.cli.mcp.enabled!==!1)Q.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),Q.push({package:"express",version:"^4.18"})}if($.doc.features.render&&$.doc.features.render.enabled!==!1)Z.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"});if(Z.push({package:"@babel/core",version:"^7"}),Z.push({package:"@rollup/plugin-commonjs",version:"^28"}),Z.push({package:"@rollup/plugin-node-resolve",version:"^16"}),Z.push({package:"@rollup/plugin-replace",version:"^6"}),Z.push({package:"rollup",version:"^4"}),$.doc.features.dts_enabled)Z.push({package:"rollup-plugin-dts",version:"^6"});if(Z.push({package:"rollup-plugin-peer-deps-external",version:"^2"}),Z.push({package:"@rollup/plugin-alias",version:"^5"}),Z.push({package:"fs-extra",version:"^11"}),$.doc.features.babel_enabled)Z.push({package:"@rollup/plugin-babel",version:"^6"}),Z.push({package:"@babel/preset-env",version:"^7"}),Z.push({package:"@babel/preset-react",version:"^7"}),$.doc.features.babel?.options?.plugins?.forEach((J)=>{switch(J[0]){case"@babel/plugin-proposal-decorators":Z.push({package:"@babel/plugin-proposal-decorators",version:"^7"});break;case"@babel/plugin-proposal-class-properties":Z.push({package:"@babel/plugin-proposal-class-properties",version:"^7"});break;case"@babel/plugin-proposal-private-methods":Z.push({package:"@babel/plugin-proposal-private-methods",version:"^7"});break;case"@babel/plugin-proposal-private-property-in-object":Z.push({package:"@babel/plugin-proposal-private-property-in-object",version:"^7"});break;case"@babel/plugin-proposal-optional-chaining":Z.push({package:"@babel/plugin-proposal-optional-chaining",version:"^7"});break}});if(Z.push({package:"@fnet/rollup-plugin-delete",version:"0.1.10"}),$.doc.features.browsersync_enabled)Z.push({package:"@fnet/rollup-plugin-browsersync",version:"0.1.11"})}import n1 from"@fnet/npm-list-versions";async function X$({atom:$,packageDependencies:Q,packageDevDependencies:Z,setProgress:X}){X("Initializing dependencies for Bun");let q=$.doc.dependencies||[];if(q.filter((J)=>!J.dev).forEach((J)=>Q.push(J)),q.filter((J)=>J.dev).forEach((J)=>Z.push(J)),$.type==="workflow")Q.push({package:"get-value",version:"^3"}),Q.push({package:"set-value",version:"^4"});if($.doc.features.form_enabled){if($.doc.features.dependency_auto_enabled){let J="^18.2";if(X("Fetching React versions"),J=`^${(await n1({name:"react",groupBy:{major:!0}})).find((W)=>W[0]===$.doc.features.react_version.toString())[0]}`,Q.push({package:"react",version:J}),Q.push({package:"react-dom",version:J}),$.type==="workflow")Q.push({package:"@fnet/react-app",version:"^0.1"}),Q.push({package:"@fnet/react-app-state",version:"^0.1"})}}if($.doc.features.preact_enabled)Q.push({package:"preact",version:"^10"});if($.doc.features.cli.enabled===!0){if(Q.push({package:"@fnet/args",version:"^0.1"}),$.doc.features.cli.fargs&&$.doc.features.cli.fargs?.enabled!==!1)Q.push({package:"@fnet/config",version:"0.2.21"});if($.doc.features.cli.mcp&&$.doc.features.cli.mcp.enabled!==!1)Q.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),Q.push({package:"express",version:"^4.18"})}if($.doc.features.render&&$.doc.features.render.enabled!==!1)Z.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"})}import O6 from"fs";import A6 from"path";import r1 from"@flownet/lib-render-templates-dir";async function q$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){if($.doc.features.app.enabled!==!0)return;await Q({message:"Creating app folder"});let q={atom:$,packageDependencies:X,ts:Date.now()},J=Z.templateDir,Y=A6.resolve(Z.projectDir,"src/app");if(!O6.existsSync(Y))O6.mkdirSync(Y,{recursive:!0});let V=["index.js.njk"];if($.doc.features.app.html!==!1)V.push("index.html.njk");await r1({pattern:V,dir:A6.resolve(J,"src/app"),outDir:Y,context:q})}import B6 from"nunjucks";import _0 from"fs";import O0 from"path";import a1 from"@flownet/lib-parse-imports-js";import s1 from"@fnet/npm-pick-versions";import o1 from"object-hash";import W8 from"fs";import L6 from"path";async function P0({projectDir:$,name:Q,setProgress:Z,count:X=1}){let q,Y=o1(["npm-pick-versions",Q,X]),V=L6.join($,".cache"),W=L6.join(V,Y+".json");if(W8.existsSync(W)){if(Z)Z(`Picking npm version of ${Q} from cache ...`);q=JSON.parse(W8.readFileSync(W,"utf8"))}else{if(Z)Z(`Picking npm version of ${Q} ...`);q=await s1({name:Q,count:X}),W8.mkdirSync(V,{recursive:!0}),W8.writeFileSync(W,JSON.stringify(q),"utf8")}return q}async function J$({atom:$,context:Q,packageDependencies:Z,packageDevDependencies:X,setProgress:q}){await q({message:"Creating package.json."}),Z.filter((U)=>U.dev===!0).forEach((U)=>{if(!X.find((L)=>L.package===U.package))X.push(U);let A=Z.findIndex((L)=>L.package===U.package);Z.splice(A,1)});let Y=Z.find((U)=>U.package==="react"),V=Z.find((U)=>U.package==="react-dom");if(Y&&!V)Z.push({package:"react-dom",version:Y.version});else if(Y&&V)V.version=Y.version;if(Y&&$.doc.features.react_version>=17){if(!Z.find((U)=>U.package==="@emotion/react"))Z.push({package:"@emotion/react",version:"^11"});if(!Z.find((U)=>U.package==="@emotion/styled"))Z.push({package:"@emotion/styled",version:"^11"})}let W=[];if($.doc.features.app.enabled===!0)W.push({file:O0.resolve(Q.projectDir,"src/app/index.js"),dev:$.doc.features.app.dev!==!1});if($.doc.features.cli.enabled===!0)W.push({file:O0.resolve(Q.projectDir,"src/cli/index.js"),dev:$.doc.features.cli.dev!==!1});for await(let U of W){let A=U.file;if(!_0.existsSync(A))throw Error(`App file not found: ${A}`);let R=(await a1({file:A,recursive:!0,verbose:!1})).all;for await(let T of R){if(T.type!=="npm")continue;if(Z.find((t)=>t.package===T.package))continue;if(X.find((t)=>t.package===T.package))continue;let c=await P0({name:T.package,projectDir:Q.projectDir,setProgress:q});(U.dev===!0?X:Z).push({package:T.package,subpath:T.subpath,version:c.minorRange,type:"npm"})}}let H={atom:$,packageDependencies:Z,packageDevDependencies:X},_=Q.templateDir,G=B6.compile(_0.readFileSync(O0.resolve(_,"package.json.njk"),"utf8"),B6.configure(_)).render(H),M=Q.projectDir,O=O0.resolve(M,"package.json");_0.writeFileSync(O,G,"utf8");let z=O0.resolve(Q.project.projectDir,"fnet");if(_0.existsSync(z)){let U=O0.resolve(Q.projectDir,"fnet");if(!_0.existsSync(U))_0.mkdirSync(U);let A=_0.readdirSync(z);for(let L of A){let R=O0.resolve(z,L);if(!_0.lstatSync(R).isFile())continue;let T=O0.resolve(U,L);_0.copyFileSync(R,T)}}}import R6 from"fs";import C6 from"path";import t1 from"@flownet/lib-render-templates-dir";async function Y$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){if($.doc.features.cli.enabled!==!0)return;await Q({message:"Creating cli."});let q={atom:$,packageDependencies:X},J=Z.templateDir,Y=C6.resolve(Z.projectDir,"src/cli");if(!R6.existsSync(Y))R6.mkdirSync(Y,{recursive:!0});await t1({pattern:["index.js.njk"],dir:C6.resolve(J,"src/cli"),outDir:Y,context:q})}import V$ from"fs";import W$ from"path";import I6 from"nunjucks";import e1 from"@flownet/lib-parse-imports-js";async function H$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating rollup file."});let q={atom:$,packageDependencies:X},J=W$.resolve(Z.projectDir,"src","default/index.js");if(!V$.existsSync(J))throw Error(`Entry file not found: ${J}`);let V=(await e1({file:J,recursive:!0})).all.filter((z)=>z.type==="node").map((z)=>z.path),W=$.doc.features.rollup_output,H=Object.keys(W);for(let z=0;z<H.length;z++){let U=H[z],A=W[U];if(A.browser===!0){if(V.length>0){A.globals_enabled=!0,A.globals=A.globals||[],A.globals=A.globals.concat(V.map((L)=>{return{key:L,value:L}})),A.alias_enabled=!0,A.alias=A.alias||{},A.alias.entries=A.alias.entries||{};for(let L=0;L<V.length;L++){let R=V[L];A.alias.entries[R]=`node:${R}`,A.alias.entries[`node:${R}`]=R}A.external_enabled=!0,A.external=A.external||[],A.external=A.external.concat(V)}}}let _=Z.templateDir,G=I6.compile(V$.readFileSync(W$.resolve(_,"rollup.config.mjs.njk"),"utf8"),I6.configure(_)).render(q),M=Z.projectDir,O=W$.resolve(M,"rollup.config.mjs");V$.writeFileSync(O,G,"utf8")}import K$ from"fs";import F6 from"path";import T6 from"nunjucks";async function _$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating build.js file."});let q={atom:$,packageDependencies:X},J=Z.templateDir,V=T6.compile(K$.readFileSync(F6.resolve(J,"build.js.njk"),"utf8"),T6.configure(J)).render(q),W=Z.projectDir,H=F6.resolve(W,"build.js");K$.writeFileSync(H,V,"utf8"),K$.chmodSync(H,"755")}import G$ from"fs";import z$ from"path";import $7 from"nunjucks";import Q7 from"ajv/dist/2020.js";import Z7 from"ajv/dist/standalone/index.js";import X7 from"ajv-formats";async function U$({atom:$,setProgress:Q,context:Z,njEnv:X}){if($.doc.features.cli.enabled!==!0)return;await Q({message:"Creating input args."});let q={},J=[];if($.doc.input)q=$.doc.input;else q={type:"object",properties:{},required:[]};if($.doc.features.cli.fargs&&$.doc.features.cli.fargs?.enabled!==!1){let A=$.doc.features.cli.fargs,L={type:"string",description:"Config name to load args",hidden:!1},R={type:"array",description:"Tags to filter the config",hidden:!1};if(Reflect.has(A,"default"))L.default=A.default}let V={imports:J,atom:$},W=Z.templateDir,_=$7.compile(G$.readFileSync(z$.resolve(W,"src/default/input.args.js.njk"),"utf8"),X).render(V),K=Z.projectDir,G=z$.resolve(K,"src/default/input.args.js");G$.writeFileSync(G,_,"utf8");let M=new Q7({allErrors:!0,useDefaults:!0,formats:{},strict:!1,code:{esm:!0,lines:!0,optimize:!1,source:!0}});X7(M);let O=M.compile(q),U=Z7(M,O)+`
|
|
4
|
-
export { schema31 as schema };`;G$.writeFileSync(z$.resolve(K,"src/default/validate_input.js"),U,"utf8")}import j6 from"fs";import w6 from"path";import S6 from"nunjucks";async function M$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating .gitignore"});let q={atom:$,packageDependencies:X},J=Z.templateDir,V=S6.compile(j6.readFileSync(w6.resolve(J,".gitignore.njk"),"utf8"),S6.configure(J)).render(q),W=Z.projectDir,H=w6.resolve(W,".gitignore");j6.writeFileSync(H,V,"utf8")}import N6 from"fs";import b6 from"path";import P6 from"nunjucks";async function O$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating tsconfig.json."});let q={atom:$,packageDependencies:X},J=Z.templateDir,V=P6.compile(N6.readFileSync(b6.resolve(J,"tsconfig.json.njk"),"utf8"),P6.configure(J)).render(q),W=Z.projectDir,H=b6.resolve(W,"tsconfig.json");N6.writeFileSync(H,V,"utf8")}import H8 from"nunjucks";import A0 from"fs";import F0 from"path";import E6 from"@fnet/yaml";async function A$({atom:$,context:Q,setProgress:Z,Atom:X}){if(await Z({message:"Creating readme.md"}),Q.project?.readme){let Y=Q.projectDir,V={content:Q.project.readme.doc.content},W=F0.resolve(Q.project.projectDir,"fnet/how-to.md");if(A0.existsSync(W)){let z=A0.readFileSync(W,"utf8");V.howto=z}let H=F0.resolve(Q.project.projectDir,"fnet/input.yaml");if(A0.existsSync(H)){let z=await E6({file:H,tags:Q.tags});V.input=z.content}let _=F0.resolve(Q.project.projectDir,"fnet/output.yaml");if(A0.existsSync(_)){let z=await E6({file:_,tags:Q.tags});V.output=z.content}let K=Q.templateDir,M=H8.compile(A0.readFileSync(F0.resolve(K,"readme.md.njk"),"utf8"),H8.configure(K)).render(V),O=F0.resolve(Y,"readme.md");A0.writeFileSync(O,M,"utf8")}else if($.id){let Y=await X.first({type:"wiki",parent_id:$.id});if(!Y||Y.doc?.["content-type"]!=="markdown")return;let{content:V,...W}=Y.doc,H={content:V},_=Q.templateDir,G=H8.compile(A0.readFileSync(F0.resolve(_,"readme.md.njk"),"utf8"),H8.configure(_)).render(H),M=Q.projectDir,O=F0.resolve(M,"readme.md");A0.writeFileSync(O,G,"utf8")}}import q7 from"path";import k6 from"@fnet/shelljs";async function L$({setProgress:$,context:Q}){let Z=Q.projectDir;await $({message:"Prettifiying source files."});let X=q7.join("src","**","*");if(J0("bun")){let q=await k6(`prettier --write ${X} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:Z});if(q.code!==0)throw Error(q.stderr)}else{let q=await k6(`prettier --write ${X} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:Z});if(q.code!==0)throw Error(q.stderr)}}import J7 from"@fnet/shelljs";async function B$({atom:$,setProgress:Q,context:Z}){if(!$.doc.features.dts_enabled)return;let X=Z.projectDir;if(await Q({message:"Creating .d.ts"}),(await J7("tsc",{cwd:X})).code!==0)throw Error("Couldnt create .d.ts files.")}import y6 from"@fnet/shelljs";async function R$({setProgress:$,atom:Q,context:Z}){let X=Z.projectDir;if(await $({message:"Installing npm packages."}),J0("bun")){if((await y6(`bun install ${Q.doc.features.npm_install_flags}`,{cwd:X})).code!==0)throw Error("Couldnt install npm packages.")}else if((await y6(`npm install ${Q.doc.features.npm_install_flags}`,{cwd:X})).code!==0)throw Error("Couldnt install npm packages.")}import D6 from"fs";import Y7 from"path";import{spawn as V7}from"child_process";async function v6($){let{projectDir:Q,scriptName:Z,args:X=[],env:q=process.env,shell:J=!0,detached:Y=!0,onSpawn:V}=$;if(!Q||!Z)throw Error("projectDir and scriptName are required");let W=Y7.resolve(Q,"package.json");if(!D6.existsSync(W))throw Error(`package.json not found at ${W}`);let H=JSON.parse(D6.readFileSync(W,"utf8")),_=H.scripts?.[Z];if(!_){let M=Object.keys(H.scripts||{}).join(", ");throw Error(`Script '${Z}' not found. Available: ${M}`)}let K=X.length>0?`${_} ${X.join(" ")}`:_,G=V7(K,[],{cwd:Q,shell:J,detached:Y,env:{...q}});if(V)V(G);return new Promise((M,O)=>{G.on("error",(z)=>{O(Error(`Failed to start '${Z}': ${z.message}`))}),G.on("close",(z)=>{M({subprocess:G,exitCode:z})})})}async function C$({setProgress:$,context:Q}){let Z=Q.projectDir;await $({message:"Building main project."});let X=Q.dev?"build:dev":"build";await v6({projectDir:Z,scriptName:X,shell:!0,detached:!0,env:{...process.env}})}var x6=async($)=>{let{atom:Q,packageDependencies:Z,context:X,deploymentProjectTarget:q,setProgress:J,deploymentProject:Y,yamlTarget:V}=$;if(q.enabled!==!0)return;let W=q.type;try{if(W==="lib")await(await import("./index.3rmtt0x7.js")).default({...$});else if(W==="red")await(await import("./index.t8b8gd46.js")).default({...$});else if(W==="npm")await(await import("./index.8m14r891.js")).default({...$});else if(W==="gcs")await(await import("./index.knj6ydvb.js")).default({...$});else if(W==="gitlab")await(await import("./index.899ypy57.js")).default({...$});else if(W==="fnet-package")await(await import("./index.nnfg65pt.js")).default({...$});else if(W==="fnet-form")await(await import("./index.jkdwz7zj.js")).default({...$});else if(W==="fnet-node")await(await import("./index.zna4hmc3.js")).default({...$});else if(W==="fnet-flow")await(await import("./index.efd8jxdg.js")).default({...$});else if(W==="nextjs")await(await import("./index.a203h4q3.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="webos")await(await import("./index.z27pg13j.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="electron")await(await import("./index.75sm2tte.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="docker")await(await import("./index.mhsc3fmv.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="ios")await(await import("./index.exfvnegm.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="macos")await(await import("./index.11tp336m.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="rust")await(await import("./index.csbtwe06.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="pypi")await(await import("./index.f1f463rw.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else{console.warn(`No deployer found for type: ${W}`);return}}catch(H){throw console.error(`Error during deployment for type "${W}":`,H),H}};import{Atom as H0}from"@flownet/lib-atom-api-js";import cQ from"@flownet/lib-parse-node-url";import H7 from"bpmn-moddle";import f6 from"dagre";import K7 from"lodash.clonedeep";var u6={name:"ATOM",uri:"http://atom.org/bpmn",prefix:"atom",types:[{name:"AtomExtension",extends:["bpmn:BaseElement"],properties:[{name:"atom",type:"atom:Atom",isMany:!1}]},{name:"Atom",properties:[{name:"type",type:"String",isAttr:!0}]}]};function _7($){let{nodes:Q,nodeIndex:Z,root:X}=$;Q.forEach((q)=>{let J=[],Y=[],V=(K)=>{if(K.context.next){if(J.push({from:K,to:K.context.next,type:"bpmn:SequenceFlow"}),K===q)Y.push({to:K.context.next,type:"bpmn:SequenceFlow",next:!0})}K.childs.forEach((G)=>{if(K===q){if(q.type==="switch")Y.push({to:G,type:"bpmn:SequenceFlow"})}V(G)})};V(q);let W=J.filter((K)=>K.to.parent.indexKey===q.parent.indexKey).map((K)=>{return{...K,from:q.indexKey,to:K.to.indexKey}}),H=J.filter((K)=>K.to.parent.indexKey!==q.parent.indexKey&&!K.to.indexKey.startsWith(q.indexKey+"/")).map((K)=>{return{...K,from:q.indexKey,to:K.to.indexKey}}),_=Y.map((K)=>{return{...K,to:K.to.indexKey}});if(q.bpmn=q.bpmn||{},q.bpmn.edges=I$(W,"to"),q.bpmn.outside=I$(H,"to"),q.bpmn.starts=I$(_,"to"),q.bpmn.type=G7(q),q.bpmn.width=120,q.bpmn.height=80,q.type==="return")q.bpmn.width=36,q.bpmn.height=36})}function G7($){if($.type==="call")return"bpmn:ServiceTask";else if($.type==="form")return"bpmn:UserTask";else if($.type==="return")return"bpmn:EndEvent";else return"bpmn:Task"}function I$($,Q){return $.filter((Z,X,q)=>{return q.map((J)=>J[Q]).indexOf(Z[Q])===X})}function g6($){let{nodes:Q,nodeIndex:Z,root:X}=$,q=$.targetNodes||X.childs;q.forEach((J)=>{let Y=J.type==="workflow"||J.type==="subworkflow",V=!Y&&J.childs.filter((W)=>!W.virtual).length>0;if(V)J.bpmn.type="bpmn:SubProcess";if(Y||V){let W=J.childs.filter((z)=>z.module!==!0)[0];J.childs.filter((z)=>z.module===!0).forEach((z)=>{let U=G0({...$,parent:J,bpmnType:"bpmn:IntermediateCatchEvent",type:"inter",definitions:[{type:"bpmn:SignalEventDefinition"}]});U.bpmn.edges=[{from:U.indexKey,to:z.indexKey,type:"bpmn:SequenceFlow"}]});let _=J.childs.find((z)=>z.name==="try"&&J.type==="tryexcept"),K=J.childs.filter((z)=>z.name==="except"&&J.type==="tryexcept");if(_&&K.length)K.forEach((z)=>{let U=G0({location:J.childs.indexOf(z),...$,parent:J,bpmnType:"bpmn:BoundaryEvent",type:"boundary",attrs:{attachedToRef:_},definitions:[{type:"bpmn:ErrorEventDefinition"}]});U.bpmn.edges=[{from:U.indexKey,to:z.indexKey,type:"bpmn:SequenceFlow"}]});let G=J.childs.find((z)=>z.type==="raise");if(G){let z=G0({...$,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:"ERROR",definitions:[{type:"bpmn:ErrorEventDefinition"}]});G.bpmn.edges=[{from:G.indexKey,to:z.indexKey,type:"bpmn:SequenceFlow"}]}if(W)if(J.bpmn.starts.length>1){let z=G0({...$,parent:J,bpmnType:"bpmn:StartEvent",type:"start"}),U=G0({...$,parent:J,bpmnType:"bpmn:ExclusiveGateway",type:"switch"});z.bpmn.edges=[{from:z.indexKey,to:U.indexKey,type:"bpmn:SequenceFlow"}],U.bpmn.edges=J.bpmn.starts.map((L)=>{return{...L,from:U.indexKey}});let A=U.bpmn.edges.find((L)=>L.next===!0);if(A){let L=G0({...$,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:A.to});A.to=L.indexKey}}else{let z=G0({...$,parent:J,bpmnType:"bpmn:StartEvent",type:"start"});z.bpmn.edges.push({from:z.indexKey,to:W.indexKey,type:"bpmn:SequenceFlow"})}J.childs.filter((z)=>z.virtual!==!0&&z.bpmn.outside.length&&z.bpmn.type!=="bpmn:EndEvent").forEach((z)=>{z.bpmn.outside.forEach((U)=>{let A=q.indexOf(J),L=G0({...$,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:U.to,location:A+1});z.bpmn.edges.push({from:z.indexKey,to:L.indexKey,type:"bpmn:SequenceFlow"})})}),J.childs.filter((z)=>z.virtual!==!0&&z.bpmn.edges.length>1).forEach((z)=>{let U=q.indexOf(z),A=G0({...$,parent:J,bpmnType:"bpmn:ExclusiveGateway",type:"switch",location:U+1});A.bpmn.edges=z.bpmn.edges.map((L)=>{return{...L,from:A.indexKey}}),z.bpmn.edges=[{from:z.indexKey,to:A.indexKey,type:"bpmn:SequenceFlow"}],z.bpmn.outside=[]})}g6({...$,targetNodes:J.childs})})}function G0($){let{parent:Q,nodes:Z,nodeIndex:X,bpmnType:q,type:J,name:Y,outside:V,location:W,definitions:H,attrs:_}=$,K=Q.childs.filter((M)=>M.type===`v${J}`).length,G={indexKey:`${Q.indexKey}/_${J}${K}`,pathKey:`${Q.pathKey}._${J}${K}`,type:`v${J}`,name:Y,bpmn:{edges:[],outside:[],type:q,width:36,height:36,fill:"#c8e6c9",stroke:"#205022",definitions:H,attrs:_},virtual:!0,childs:[]};return Q.childs.splice(W||0,0,G),Z.push(G),X[G.indexKey]=G,G}function h6($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:J,nodeIndex:Y,diagrams:V,nodes:W}=$;z7($),U7($),M7($),O7($)}function z7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:J,nodeIndex:Y,nodes:V}=$,W=Z.get("flowElements");Z.$nodes=Z.$nodes||[],Q.childs.forEach((H)=>{let _=q.create(H.bpmn.type,{id:`node.${H.pathKey}`,name:H.definition?.title||H.name});if(J[_.id]=_,_.$isNode=!0,_.$node=H,H.$flow=_,Z.$nodes.push(_),W.push(_),H.bpmn.attrs)Object.keys(H.bpmn.attrs).forEach((G)=>{if(G==="attachedToRef")_.set(G,H.bpmn.attrs[G].$flow)});if(H.bpmn.definitions){let K=H.bpmn.definitions.map((G)=>{let M=q.create(G.type);return Object.keys(G.attrs||{}).forEach((z)=>{M.set(z,G.attrs[z])}),M});_.eventDefinitions=K}})}function U7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:J,nodeIndex:Y}=$,V=Z.get("flowElements");Z.$edges=Z.$edges||[],Q.childs.forEach((W)=>{W.bpmn.edges.forEach((_)=>{let K=W,G=Y[_.to],M=`edge.${K.pathKey}_${G.pathKey}`;if(J[M])return;let O=J[`node.${K.pathKey}`],z=J[`node.${G.pathKey}`],U=q.create(_.type,{id:M,sourceRef:O,targetRef:z});J[U.id]=U,U.$is_edge=!0,O.get("outgoing").push(U),z.get("incoming").push(U),Z.$edges.push({from:O,to:z,flow:U}),V.push(U)})})}function M7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:J,nodeIndex:Y}=$,V=120,W=80,H=160,_=160,K=new f6.graphlib.Graph;K.setDefaultEdgeLabel(()=>({})),K.setGraph({rankdir:"TB",nodesep:120,ranksep:80,xranker:"longest-path"}),Z.$nodes.forEach((G)=>{K.setNode(G.id,{width:G.$node?.bpmn.width||120,height:G.$node?.bpmn.height||80,label:G.id})}),Z.$edges.forEach((G)=>{K.setEdge(G.from.id,G.to.id)}),f6.layout(K),Z.$nodes.forEach((G)=>{let M=K.node(G.id),O=M.width,z=M.height,U=q.create("bpmndi:BPMNShape",{id:`shape.${G.id}`,bpmnElement:G,bounds:q.create("dc:Bounds",{x:160+M.x-M.width/2,y:160+M.y-M.height/2,width:O,height:z}),label:q.create("bpmndi:BPMNLabel")});if(G.$node.bpmn.fill)U.set("bioc:fill",G.$node.bpmn.fill);if(G.$node.bpmn.stroke)U.set("bioc:stroke",G.$node.bpmn.stroke);X.get("planeElement").push(U)}),Z.$edges.forEach((G)=>{let M=K.edge(G.from.id,G.to.id),O=q.create("bpmndi:BPMNEdge",{id:`edge.${G.from.id}_${G.to.id}`,bpmnElement:G.flow,label:q.create("bpmndi:BPMNLabel")});M.points.forEach((U)=>{let A=q.create("dc:Point",{x:160+U.x,y:160+U.y});O.get("waypoint").push(A)}),X.get("planeElement").push(O)})}function O7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:J,nodeIndex:Y,diagrams:V}=$;Q.childs.filter((H)=>H.bpmn.type==="bpmn:SubProcess").forEach((H)=>{let _=J[`node.${H.pathKey}`],K=q.create("bpmndi:BPMNDiagram",{id:`diagram_${H.pathKey}`});J[K.id]=K,V.push(K);let G=q.create("bpmndi:BPMNPlane",{id:`plane_${H.pathKey}`});J[G.id]=G,K.plane=G,G.bpmnElement=_,h6({...$,targetNode:H,targetFlowElementsContainer:_,targetPlaneElement:G})})}async function A7($){let Q=$.root,Z=Q.context.index,X=Object.keys(Z).map((H)=>Z[H]);_7({nodes:X,nodeIndex:Z,root:Q}),g6({nodes:X,nodeIndex:Z,root:Q});let q=void 0,J=new H7({atom:u6}),Y={},V=J.create("bpmn:Definitions",{id:"definitions_0"});Y[V.id]=V;for await(let H of Q.childs){let _=V.get("rootElements"),K=V.get("diagrams"),G=J.create("bpmn:Process",{id:`process_${H.pathKey}`,name:H.name,documentation:[J.create("bpmn:Documentation",{text:`Workflow - ${H.name}`})]});Y[G.id]=G,G.isExecutable=!0,_.push(G);let M=J.create("bpmndi:BPMNDiagram",{id:`diagram_${H.pathKey}`});Y[M.id]=M,K.push(M);let O=J.create("bpmndi:BPMNPlane",{id:`plane_${H.pathKey}`});Y[O.id]=O,M.plane=O,O.bpmnElement=G,h6({targetNode:H,targetFlowElementsContainer:G,targetPlaneElement:O,moddle:J,elementIndex:Y,nodeIndex:Z,nodes:X,diagrams:K})}let W=await J.toXML(V,{format:!0});return{diagramXML:q||W.xml}}async function K8($={}){return await A7(K7($))}import dQ from"@fnet/config";import pQ from"@flownet/lib-parse-imports-js";import U1 from"@fnet/expression";import iQ from"@fnet/yaml";import nQ from"chalk";var W5=b($5(),1);var g0=($)=>{if(typeof $!=="string")throw TypeError("invalid pattern");if($.length>65536)throw TypeError("pattern is too long")};var j7={"[: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]},h0=($)=>$.replace(/[[\]\\-]/g,"\\$&"),w7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Q5=($)=>$.join(""),Z5=($,Q)=>{let Z=Q;if($.charAt(Z)!=="[")throw Error("not in a brace expression");let X=[],q=[],J=Z+1,Y=!1,V=!1,W=!1,H=!1,_=Z,K="";$:while(J<$.length){let z=$.charAt(J);if((z==="!"||z==="^")&&J===Z+1){H=!0,J++;continue}if(z==="]"&&Y&&!W){_=J+1;break}if(Y=!0,z==="\\"){if(!W){W=!0,J++;continue}}if(z==="["&&!W){for(let[U,[A,L,R]]of Object.entries(j7))if($.startsWith(U,J)){if(K)return["$.",!1,$.length-Z,!0];if(J+=U.length,R)q.push(A);else X.push(A);V=V||L;continue $}}if(W=!1,K){if(z>K)X.push(h0(K)+"-"+h0(z));else if(z===K)X.push(h0(z));K="",J++;continue}if($.startsWith("-]",J+1)){X.push(h0(z+"-")),J+=2;continue}if($.startsWith("-",J+1)){K=z,J+=2;continue}X.push(h0(z)),J++}if(_<J)return["",!1,0,!1];if(!X.length&&!q.length)return["$.",!1,$.length-Z,!0];if(q.length===0&&X.length===1&&/^\\?.$/.test(X[0])&&!H){let z=X[0].length===2?X[0].slice(-1):X[0];return[w7(z),!1,_-Z,!1]}let G="["+(H?"^":"")+Q5(X)+"]",M="["+(H?"":"^")+Q5(q)+"]";return[X.length&&q.length?"("+G+"|"+M+")":X.length?G:M,V,_-Z,!0]};var Q0=($,{windowsPathsNoEscape:Q=!1}={})=>{return Q?$.replace(/\[([^\/\\])\]/g,"$1"):$.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var S7=new Set(["!","?","+","*","@"]),X5=($)=>S7.has($),N7="(?!(?:^|/)\\.\\.?(?:$|/))",_8="(?!\\.)",b7=new Set(["[","."]),P7=new Set(["..","."]),E7=new Set("().*{}+?[]^$\\!"),k7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),j$="[^/]",q5=j$+"*?",J5=j$+"+?";class f{type;#Q;#$;#Z=!1;#X=[];#J;#C;#R;#H=!1;#G;#W;#_=!1;constructor($,Q,Z={}){if(this.type=$,$)this.#$=!0;if(this.#J=Q,this.#Q=this.#J?this.#J.#Q:this,this.#G=this.#Q===this?Z:this.#Q.#G,this.#R=this.#Q===this?[]:this.#Q.#R,$==="!"&&!this.#Q.#H)this.#R.push(this);this.#C=this.#J?this.#J.#X.length:0}get hasMagic(){if(this.#$!==void 0)return this.#$;for(let $ of this.#X){if(typeof $==="string")continue;if($.type||$.hasMagic)return this.#$=!0}return this.#$}toString(){if(this.#W!==void 0)return this.#W;if(!this.type)return this.#W=this.#X.map(($)=>String($)).join("");else return this.#W=this.type+"("+this.#X.map(($)=>String($)).join("|")+")"}#q(){if(this!==this.#Q)throw Error("should only call on root");if(this.#H)return this;this.toString(),this.#H=!0;let $;while($=this.#R.pop()){if($.type!=="!")continue;let Q=$,Z=Q.#J;while(Z){for(let X=Q.#C+1;!Z.type&&X<Z.#X.length;X++)for(let q of $.#X){if(typeof q==="string")throw Error("string part in extglob AST??");q.copyIn(Z.#X[X])}Q=Z,Z=Q.#J}}return this}push(...$){for(let Q of $){if(Q==="")continue;if(typeof Q!=="string"&&!(Q instanceof f&&Q.#J===this))throw Error("invalid part: "+Q);this.#X.push(Q)}}toJSON(){let $=this.type===null?this.#X.slice().map((Q)=>typeof Q==="string"?Q:Q.toJSON()):[this.type,...this.#X.map((Q)=>Q.toJSON())];if(this.isStart()&&!this.type)$.unshift([]);if(this.isEnd()&&(this===this.#Q||this.#Q.#H&&this.#J?.type==="!"))$.push({});return $}isStart(){if(this.#Q===this)return!0;if(!this.#J?.isStart())return!1;if(this.#C===0)return!0;let $=this.#J;for(let Q=0;Q<this.#C;Q++){let Z=$.#X[Q];if(!(Z instanceof f&&Z.type==="!"))return!1}return!0}isEnd(){if(this.#Q===this)return!0;if(this.#J?.type==="!")return!0;if(!this.#J?.isEnd())return!1;if(!this.type)return this.#J?.isEnd();let $=this.#J?this.#J.#X.length:0;return this.#C===$-1}copyIn($){if(typeof $==="string")this.push($);else this.push($.clone(this))}clone($){let Q=new f(this.type,$);for(let Z of this.#X)Q.copyIn(Z);return Q}static#O($,Q,Z,X){let q=!1,J=!1,Y=-1,V=!1;if(Q.type===null){let G=Z,M="";while(G<$.length){let O=$.charAt(G++);if(q||O==="\\"){q=!q,M+=O;continue}if(J){if(G===Y+1){if(O==="^"||O==="!")V=!0}else if(O==="]"&&!(G===Y+2&&V))J=!1;M+=O;continue}else if(O==="["){J=!0,Y=G,V=!1,M+=O;continue}if(!X.noext&&X5(O)&&$.charAt(G)==="("){Q.push(M),M="";let z=new f(O,Q);G=f.#O($,z,G,X),Q.push(z);continue}M+=O}return Q.push(M),G}let W=Z+1,H=new f(null,Q),_=[],K="";while(W<$.length){let G=$.charAt(W++);if(q||G==="\\"){q=!q,K+=G;continue}if(J){if(W===Y+1){if(G==="^"||G==="!")V=!0}else if(G==="]"&&!(W===Y+2&&V))J=!1;K+=G;continue}else if(G==="["){J=!0,Y=W,V=!1,K+=G;continue}if(X5(G)&&$.charAt(W)==="("){H.push(K),K="";let M=new f(G,H);H.push(M),W=f.#O($,M,W,X);continue}if(G==="|"){H.push(K),K="",_.push(H),H=new f(null,Q);continue}if(G===")"){if(K===""&&Q.#X.length===0)Q.#_=!0;return H.push(K),K="",Q.push(..._,H),W}K+=G}return Q.type=null,Q.#$=void 0,Q.#X=[$.substring(Z-1)],W}static fromGlob($,Q={}){let Z=new f(null,void 0,Q);return f.#O($,Z,0,Q),Z}toMMPattern(){if(this!==this.#Q)return this.#Q.toMMPattern();let $=this.toString(),[Q,Z,X,q]=this.toRegExpSource();if(!(X||this.#$||this.#G.nocase&&!this.#G.nocaseMagicOnly&&$.toUpperCase()!==$.toLowerCase()))return Z;let Y=(this.#G.nocase?"i":"")+(q?"u":"");return Object.assign(new RegExp(`^${Q}$`,Y),{_src:Q,_glob:$})}get options(){return this.#G}toRegExpSource($){let Q=$??!!this.#G.dot;if(this.#Q===this)this.#q();if(!this.type){let V=this.isStart()&&this.isEnd(),W=this.#X.map((G)=>{let[M,O,z,U]=typeof G==="string"?f.#U(G,this.#$,V):G.toRegExpSource($);return this.#$=this.#$||z,this.#Z=this.#Z||U,M}).join(""),H="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&P7.has(this.#X[0]))){let M=b7,O=Q&&M.has(W.charAt(0))||W.startsWith("\\.")&&M.has(W.charAt(2))||W.startsWith("\\.\\.")&&M.has(W.charAt(4)),z=!Q&&!$&&M.has(W.charAt(0));H=O?N7:z?_8:""}}}let _="";if(this.isEnd()&&this.#Q.#H&&this.#J?.type==="!")_="(?:$|\\/)";return[H+W+_,Q0(W),this.#$=!!this.#$,this.#Z]}let Z=this.type==="*"||this.type==="+",X=this.type==="!"?"(?:(?!(?:":"(?:",q=this.#M(Q);if(this.isStart()&&this.isEnd()&&!q&&this.type!=="!"){let V=this.toString();return this.#X=[V],this.type=null,this.#$=void 0,[V,Q0(this.toString()),!1,!1]}let J=!Z||$||Q||!_8?"":this.#M(!0);if(J===q)J="";if(J)q=`(?:${q})(?:${J})*?`;let Y="";if(this.type==="!"&&this.#_)Y=(this.isStart()&&!Q?_8:"")+J5;else{let V=this.type==="!"?"))"+(this.isStart()&&!Q&&!$?_8:"")+q5+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&J?")":this.type==="*"&&J?")?":`)${this.type}`;Y=X+q+V}return[Y,Q0(q),this.#$=!!this.#$,this.#Z]}#M($){return this.#X.map((Q)=>{if(typeof Q==="string")throw Error("string type in extglob ast??");let[Z,X,q,J]=Q.toRegExpSource($);return this.#Z=this.#Z||J,Z}).filter((Q)=>!(this.isStart()&&this.isEnd())||!!Q).join("|")}static#U($,Q,Z=!1){let X=!1,q="",J=!1;for(let Y=0;Y<$.length;Y++){let V=$.charAt(Y);if(X){X=!1,q+=(E7.has(V)?"\\":"")+V;continue}if(V==="\\"){if(Y===$.length-1)q+="\\\\";else X=!0;continue}if(V==="["){let[W,H,_,K]=Z5($,Y);if(_){q+=W,J=J||H,Y+=_-1,Q=Q||K;continue}}if(V==="*"){if(Z&&$==="*")q+=J5;else q+=q5;Q=!0;continue}if(V==="?"){q+=j$,Q=!0;continue}q+=k7(V)}return[q,Q0($),!!Q,J]}}var E0=($,{windowsPathsNoEscape:Q=!1}={})=>{return Q?$.replace(/[?*()[\]]/g,"[$&]"):$.replace(/[?*()[\]\\]/g,"\\$&")};var d=($,Q,Z={})=>{if(g0(Q),!Z.nocomment&&Q.charAt(0)==="#")return!1;return new s(Q,Z).match($)},y7=/^\*+([^+@!?\*\[\(]*)$/,D7=($)=>(Q)=>!Q.startsWith(".")&&Q.endsWith($),v7=($)=>(Q)=>Q.endsWith($),x7=($)=>{return $=$.toLowerCase(),(Q)=>!Q.startsWith(".")&&Q.toLowerCase().endsWith($)},u7=($)=>{return $=$.toLowerCase(),(Q)=>Q.toLowerCase().endsWith($)},f7=/^\*+\.\*+$/,g7=($)=>!$.startsWith(".")&&$.includes("."),h7=($)=>$!=="."&&$!==".."&&$.includes("."),m7=/^\.\*+$/,l7=($)=>$!=="."&&$!==".."&&$.startsWith("."),c7=/^\*+$/,d7=($)=>$.length!==0&&!$.startsWith("."),p7=($)=>$.length!==0&&$!=="."&&$!=="..",i7=/^\?+([^+@!?\*\[\(]*)?$/,n7=([$,Q=""])=>{let Z=H5([$]);if(!Q)return Z;return Q=Q.toLowerCase(),(X)=>Z(X)&&X.toLowerCase().endsWith(Q)},r7=([$,Q=""])=>{let Z=K5([$]);if(!Q)return Z;return Q=Q.toLowerCase(),(X)=>Z(X)&&X.toLowerCase().endsWith(Q)},s7=([$,Q=""])=>{let Z=K5([$]);return!Q?Z:(X)=>Z(X)&&X.endsWith(Q)},o7=([$,Q=""])=>{let Z=H5([$]);return!Q?Z:(X)=>Z(X)&&X.endsWith(Q)},H5=([$])=>{let Q=$.length;return(Z)=>Z.length===Q&&!Z.startsWith(".")},K5=([$])=>{let Q=$.length;return(Z)=>Z.length===Q&&Z!=="."&&Z!==".."},_5=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Y5={win32:{sep:"\\"},posix:{sep:"/"}},a7=_5==="win32"?Y5.win32.sep:Y5.posix.sep;d.sep=a7;var g=Symbol("globstar **");d.GLOBSTAR=g;var t7="[^/]",e7=t7+"*?",$9="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Q9="(?:(?!(?:\\/|^)\\.).)*?",Z9=($,Q={})=>(Z)=>d(Z,$,Q);d.filter=Z9;var r=($,Q={})=>Object.assign({},$,Q),X9=($)=>{if(!$||typeof $!=="object"||!Object.keys($).length)return d;let Q=d;return Object.assign((X,q,J={})=>Q(X,q,r($,J)),{Minimatch:class extends Q.Minimatch{constructor(q,J={}){super(q,r($,J))}static defaults(q){return Q.defaults(r($,q)).Minimatch}},AST:class extends Q.AST{constructor(q,J,Y={}){super(q,J,r($,Y))}static fromGlob(q,J={}){return Q.AST.fromGlob(q,r($,J))}},unescape:(X,q={})=>Q.unescape(X,r($,q)),escape:(X,q={})=>Q.escape(X,r($,q)),filter:(X,q={})=>Q.filter(X,r($,q)),defaults:(X)=>Q.defaults(r($,X)),makeRe:(X,q={})=>Q.makeRe(X,r($,q)),braceExpand:(X,q={})=>Q.braceExpand(X,r($,q)),match:(X,q,J={})=>Q.match(X,q,r($,J)),sep:Q.sep,GLOBSTAR:g})};d.defaults=X9;var G5=($,Q={})=>{if(g0($),Q.nobrace||!/\{(?:(?!\{).)*\}/.test($))return[$];return W5.default($)};d.braceExpand=G5;var q9=($,Q={})=>new s($,Q).makeRe();d.makeRe=q9;var J9=($,Q,Z={})=>{let X=new s(Q,Z);if($=$.filter((q)=>X.match(q)),X.options.nonull&&!$.length)$.push(Q);return $};d.match=J9;var V5=/[?*]|[+@!]\(.*?\)|\[|\]/,Y9=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class s{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor($,Q={}){if(g0($),Q=Q||{},this.options=Q,this.pattern=$,this.platform=Q.platform||_5,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!Q.windowsPathsNoEscape||Q.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!Q.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!Q.nonegate,this.comment=!1,this.empty=!1,this.partial=!!Q.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=Q.windowsNoMagicRoot!==void 0?Q.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let $ of this.set)for(let Q of $)if(typeof Q!=="string")return!0;return!1}debug(...$){}make(){let $=this.pattern,Q=this.options;if(!Q.nocomment&&$.charAt(0)==="#"){this.comment=!0;return}if(!$){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],Q.debug)this.debug=(...q)=>console.error(...q);this.debug(this.pattern,this.globSet);let Z=this.globSet.map((q)=>this.slashSplit(q));this.globParts=this.preprocess(Z),this.debug(this.pattern,this.globParts);let X=this.globParts.map((q,J,Y)=>{if(this.isWindows&&this.windowsNoMagicRoot){let V=q[0]===""&&q[1]===""&&(q[2]==="?"||!V5.test(q[2]))&&!V5.test(q[3]),W=/^[a-z]:/i.test(q[0]);if(V)return[...q.slice(0,4),...q.slice(4).map((H)=>this.parse(H))];else if(W)return[q[0],...q.slice(1).map((H)=>this.parse(H))]}return q.map((V)=>this.parse(V))});if(this.debug(this.pattern,X),this.set=X.filter((q)=>q.indexOf(!1)===-1),this.isWindows)for(let q=0;q<this.set.length;q++){let J=this.set[q];if(J[0]===""&&J[1]===""&&this.globParts[q][2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]))J[2]="?"}this.debug(this.pattern,this.set)}preprocess($){if(this.options.noglobstar){for(let Z=0;Z<$.length;Z++)for(let X=0;X<$[Z].length;X++)if($[Z][X]==="**")$[Z][X]="*"}let{optimizationLevel:Q=1}=this.options;if(Q>=2)$=this.firstPhasePreProcess($),$=this.secondPhasePreProcess($);else if(Q>=1)$=this.levelOneOptimize($);else $=this.adjascentGlobstarOptimize($);return $}adjascentGlobstarOptimize($){return $.map((Q)=>{let Z=-1;while((Z=Q.indexOf("**",Z+1))!==-1){let X=Z;while(Q[X+1]==="**")X++;if(X!==Z)Q.splice(Z,X-Z)}return Q})}levelOneOptimize($){return $.map((Q)=>{return Q=Q.reduce((Z,X)=>{let q=Z[Z.length-1];if(X==="**"&&q==="**")return Z;if(X===".."){if(q&&q!==".."&&q!=="."&&q!=="**")return Z.pop(),Z}return Z.push(X),Z},[]),Q.length===0?[""]:Q})}levelTwoFileOptimize($){if(!Array.isArray($))$=this.slashSplit($);let Q=!1;do{if(Q=!1,!this.preserveMultipleSlashes){for(let X=1;X<$.length-1;X++){let q=$[X];if(X===1&&q===""&&$[0]==="")continue;if(q==="."||q==="")Q=!0,$.splice(X,1),X--}if($[0]==="."&&$.length===2&&($[1]==="."||$[1]===""))Q=!0,$.pop()}let Z=0;while((Z=$.indexOf("..",Z+1))!==-1){let X=$[Z-1];if(X&&X!=="."&&X!==".."&&X!=="**")Q=!0,$.splice(Z-1,2),Z-=2}}while(Q);return $.length===0?[""]:$}firstPhasePreProcess($){let Q=!1;do{Q=!1;for(let Z of $){let X=-1;while((X=Z.indexOf("**",X+1))!==-1){let J=X;while(Z[J+1]==="**")J++;if(J>X)Z.splice(X+1,J-X);let Y=Z[X+1],V=Z[X+2],W=Z[X+3];if(Y!=="..")continue;if(!V||V==="."||V===".."||!W||W==="."||W==="..")continue;Q=!0,Z.splice(X,1);let H=Z.slice(0);H[X]="**",$.push(H),X--}if(!this.preserveMultipleSlashes){for(let J=1;J<Z.length-1;J++){let Y=Z[J];if(J===1&&Y===""&&Z[0]==="")continue;if(Y==="."||Y==="")Q=!0,Z.splice(J,1),J--}if(Z[0]==="."&&Z.length===2&&(Z[1]==="."||Z[1]===""))Q=!0,Z.pop()}let q=0;while((q=Z.indexOf("..",q+1))!==-1){let J=Z[q-1];if(J&&J!=="."&&J!==".."&&J!=="**"){Q=!0;let V=q===1&&Z[q+1]==="**"?["."]:[];if(Z.splice(q-1,2,...V),Z.length===0)Z.push("");q-=2}}}}while(Q);return $}secondPhasePreProcess($){for(let Q=0;Q<$.length-1;Q++)for(let Z=Q+1;Z<$.length;Z++){let X=this.partsMatch($[Q],$[Z],!this.preserveMultipleSlashes);if(X){$[Q]=[],$[Z]=X;break}}return $.filter((Q)=>Q.length)}partsMatch($,Q,Z=!1){let X=0,q=0,J=[],Y="";while(X<$.length&&q<Q.length)if($[X]===Q[q])J.push(Y==="b"?Q[q]:$[X]),X++,q++;else if(Z&&$[X]==="**"&&Q[q]===$[X+1])J.push($[X]),X++;else if(Z&&Q[q]==="**"&&$[X]===Q[q+1])J.push(Q[q]),q++;else if($[X]==="*"&&Q[q]&&(this.options.dot||!Q[q].startsWith("."))&&Q[q]!=="**"){if(Y==="b")return!1;Y="a",J.push($[X]),X++,q++}else if(Q[q]==="*"&&$[X]&&(this.options.dot||!$[X].startsWith("."))&&$[X]!=="**"){if(Y==="a")return!1;Y="b",J.push(Q[q]),X++,q++}else return!1;return $.length===Q.length&&J}parseNegate(){if(this.nonegate)return;let $=this.pattern,Q=!1,Z=0;for(let X=0;X<$.length&&$.charAt(X)==="!";X++)Q=!Q,Z++;if(Z)this.pattern=$.slice(Z);this.negate=Q}matchOne($,Q,Z=!1){let X=this.options;if(this.isWindows){let O=typeof $[0]==="string"&&/^[a-z]:$/i.test($[0]),z=!O&&$[0]===""&&$[1]===""&&$[2]==="?"&&/^[a-z]:$/i.test($[3]),U=typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0]),A=!U&&Q[0]===""&&Q[1]===""&&Q[2]==="?"&&typeof Q[3]==="string"&&/^[a-z]:$/i.test(Q[3]),L=z?3:O?0:void 0,R=A?3:U?0:void 0;if(typeof L==="number"&&typeof R==="number"){let[T,c]=[$[L],Q[R]];if(T.toLowerCase()===c.toLowerCase()){if(Q[R]=T,R>L)Q=Q.slice(R);else if(L>R)$=$.slice(L)}}}let{optimizationLevel:q=1}=this.options;if(q>=2)$=this.levelTwoFileOptimize($);this.debug("matchOne",this,{file:$,pattern:Q}),this.debug("matchOne",$.length,Q.length);for(var J=0,Y=0,V=$.length,W=Q.length;J<V&&Y<W;J++,Y++){this.debug("matchOne loop");var H=Q[Y],_=$[J];if(this.debug(Q,H,_),H===!1)return!1;if(H===g){this.debug("GLOBSTAR",[Q,H,_]);var K=J,G=Y+1;if(G===W){this.debug("** at the end");for(;J<V;J++)if($[J]==="."||$[J]===".."||!X.dot&&$[J].charAt(0)===".")return!1;return!0}while(K<V){var M=$[K];if(this.debug(`
|
|
5
|
-
globstar while`,$,
|
|
6
|
-
>>> no match, partial?`,$,K,Q,G),K===V)return!0}return!1}let O;if(typeof H==="string")O=_===H,this.debug("string match",H,_,O);else O=H.test(_),this.debug("pattern match",H,_,O);if(!O)return!1}if(J===V&&Y===W)return!0;else if(J===V)return Z;else if(Y===W)return J===V-1&&$[J]==="";else throw Error("wtf?")}braceExpand(){return G5(this.pattern,this.options)}parse($){g0($);let Q=this.options;if($==="**")return g;if($==="")return"";let Z,X=null;if(Z=$.match(c7))X=Q.dot?p7:d7;else if(Z=$.match(y7))X=(Q.nocase?Q.dot?u7:x7:Q.dot?v7:D7)(Z[1]);else if(Z=$.match(i7))X=(Q.nocase?Q.dot?r7:n7:Q.dot?s7:o7)(Z);else if(Z=$.match(f7))X=Q.dot?h7:g7;else if(Z=$.match(m7))X=l7;let q=f.fromGlob($,this.options).toMMPattern();if(X&&typeof q==="object")Reflect.defineProperty(q,"test",{value:X});return q}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let $=this.set;if(!$.length)return this.regexp=!1,this.regexp;let Q=this.options,Z=Q.noglobstar?e7:Q.dot?$9:Q9,X=new Set(Q.nocase?["i"]:[]),q=$.map((V)=>{let W=V.map((H)=>{if(H instanceof RegExp)for(let _ of H.flags.split(""))X.add(_);return typeof H==="string"?Y9(H):H===g?g:H._src});return W.forEach((H,_)=>{let K=W[_+1],G=W[_-1];if(H!==g||G===g)return;if(G===void 0)if(K!==void 0&&K!==g)W[_+1]="(?:\\/|"+Z+"\\/)?"+K;else W[_]=Z;else if(K===void 0)W[_-1]=G+"(?:\\/|"+Z+")?";else if(K!==g)W[_-1]=G+"(?:\\/|\\/"+Z+"\\/)"+K,W[_+1]=g}),W.filter((H)=>H!==g).join("/")}).join("|"),[J,Y]=$.length>1?["(?:",")"]:["",""];if(q="^"+J+q+Y+"$",this.negate)q="^(?!"+q+").+$";try{this.regexp=new RegExp(q,[...X].join(""))}catch(V){this.regexp=!1}return this.regexp}slashSplit($){if(this.preserveMultipleSlashes)return $.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test($))return["",...$.split(/\/+/)];else return $.split(/\/+/)}match($,Q=this.partial){if(this.debug("match",$,this.pattern),this.comment)return!1;if(this.empty)return $==="";if($==="/"&&Q)return!0;let Z=this.options;if(this.isWindows)$=$.split("\\").join("/");let X=this.slashSplit($);this.debug(this.pattern,"split",X);let q=this.set;this.debug(this.pattern,"set",q);let J=X[X.length-1];if(!J)for(let Y=X.length-2;!J&&Y>=0;Y--)J=X[Y];for(let Y=0;Y<q.length;Y++){let V=q[Y],W=X;if(Z.matchBase&&V.length===1)W=[J];if(this.matchOne(W,V,Q)){if(Z.flipNegate)return!0;return!this.negate}}if(Z.flipNegate)return!1;return this.negate}static defaults($){return d.defaults($).Minimatch}}d.AST=f;d.Minimatch=s;d.escape=E0;d.unescape=Q0;import{fileURLToPath as f9}from"url";var k0=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,U5=new Set,w$=typeof process==="object"&&!!process?process:{},M5=($,Q,Z,X)=>{typeof w$.emitWarning==="function"?w$.emitWarning($,Q,Z,X):console.error(`[${Z}] ${Q}: ${$}`)},G8=globalThis.AbortController,z5=globalThis.AbortSignal;if(typeof G8>"u"){z5=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(X,q){this._onabort.push(q)}},G8=class{constructor(){Q()}signal=new z5;abort(X){if(this.signal.aborted)return;this.signal.reason=X,this.signal.aborted=!0;for(let q of this.signal._onabort)q(X);this.signal.onabort?.(X)}};let $=w$.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Q=()=>{if(!$)return;$=!1,M5("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",Q)}}var V9=($)=>!U5.has($),w3=Symbol("type"),L0=($)=>$&&$===Math.floor($)&&$>0&&isFinite($),O5=($)=>!L0($)?null:$<=Math.pow(2,8)?Uint8Array:$<=Math.pow(2,16)?Uint16Array:$<=Math.pow(2,32)?Uint32Array:$<=Number.MAX_SAFE_INTEGER?m0:null;class m0 extends Array{constructor($){super($);this.fill(0)}}class y0{heap;length;static#Q=!1;static create($){let Q=O5($);if(!Q)return[];y0.#Q=!0;let Z=new y0($,Q);return y0.#Q=!1,Z}constructor($,Q){if(!y0.#Q)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new Q($),this.length=0}push($){this.heap[this.length++]=$}pop(){return this.heap[--this.length]}}class l0{#Q;#$;#Z;#X;#J;#C;#R;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#H;#G;#W;#_;#q;#O;#M;#U;#A;#T;#B;#F;#V;#I;#K;#j;#L;#P;static unsafeExposeInternals($){return{starts:$.#V,ttls:$.#I,sizes:$.#F,keyMap:$.#W,keyList:$.#_,valList:$.#q,next:$.#O,prev:$.#M,get head(){return $.#U},get tail(){return $.#A},free:$.#T,isBackgroundFetch:(Q)=>$.#z(Q),backgroundFetch:(Q,Z,X,q)=>$.#v(Q,Z,X,q),moveToTail:(Q)=>$.#f(Q),indexes:(Q)=>$.#N(Q),rindexes:(Q)=>$.#b(Q),isStale:(Q)=>$.#S(Q)}}get max(){return this.#Q}get maxSize(){return this.#$}get calculatedSize(){return this.#G}get size(){return this.#H}get fetchMethod(){return this.#C}get memoMethod(){return this.#R}get dispose(){return this.#Z}get onInsert(){return this.#X}get disposeAfter(){return this.#J}constructor($){let{max:Q=0,ttl:Z,ttlResolution:X=1,ttlAutopurge:q,updateAgeOnGet:J,updateAgeOnHas:Y,allowStale:V,dispose:W,onInsert:H,disposeAfter:_,noDisposeOnSet:K,noUpdateTTL:G,maxSize:M=0,maxEntrySize:O=0,sizeCalculation:z,fetchMethod:U,memoMethod:A,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:T,allowStaleOnFetchAbort:c,ignoreFetchAbort:D}=$;if(Q!==0&&!L0(Q))throw TypeError("max option must be a nonnegative integer");let t=Q?O5(Q):Array;if(!t)throw Error("invalid max value: "+Q);if(this.#Q=Q,this.#$=M,this.maxEntrySize=O||this.#$,this.sizeCalculation=z,this.sizeCalculation){if(!this.#$&&!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(A!==void 0&&typeof A!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#R=A,U!==void 0&&typeof U!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#C=U,this.#j=!!U,this.#W=new Map,this.#_=Array(Q).fill(void 0),this.#q=Array(Q).fill(void 0),this.#O=new t(Q),this.#M=new t(Q),this.#U=0,this.#A=0,this.#T=y0.create(Q),this.#H=0,this.#G=0,typeof W==="function")this.#Z=W;if(typeof H==="function")this.#X=H;if(typeof _==="function")this.#J=_,this.#B=[];else this.#J=void 0,this.#B=void 0;if(this.#K=!!this.#Z,this.#P=!!this.#X,this.#L=!!this.#J,this.noDisposeOnSet=!!K,this.noUpdateTTL=!!G,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!T,this.allowStaleOnFetchAbort=!!c,this.ignoreFetchAbort=!!D,this.maxEntrySize!==0){if(this.#$!==0){if(!L0(this.#$))throw TypeError("maxSize must be a positive integer if specified")}if(!L0(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#h()}if(this.allowStale=!!V,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!J,this.updateAgeOnHas=!!Y,this.ttlResolution=L0(X)||X===0?X:1,this.ttlAutopurge=!!q,this.ttl=Z||0,this.ttl){if(!L0(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#Y()}if(this.#Q===0&&this.ttl===0&&this.#$===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Q&&!this.#$){if(V9("LRU_CACHE_UNBOUNDED"))U5.add("LRU_CACHE_UNBOUNDED"),M5("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",l0)}}getRemainingTTL($){return this.#W.has($)?1/0:0}#Y(){let $=new m0(this.#Q),Q=new m0(this.#Q);this.#I=$,this.#V=Q,this.#E=(q,J,Y=k0.now())=>{if(Q[q]=J!==0?Y:0,$[q]=J,J!==0&&this.ttlAutopurge){let V=setTimeout(()=>{if(this.#S(q))this.#k(this.#_[q],"expire")},J+1);if(V.unref)V.unref()}},this.#y=(q)=>{Q[q]=$[q]!==0?k0.now():0},this.#w=(q,J)=>{if($[J]){let Y=$[J],V=Q[J];if(!Y||!V)return;q.ttl=Y,q.start=V,q.now=Z||X();let W=q.now-V;q.remainingTTL=Y-W}};let Z=0,X=()=>{let q=k0.now();if(this.ttlResolution>0){Z=q;let J=setTimeout(()=>Z=0,this.ttlResolution);if(J.unref)J.unref()}return q};this.getRemainingTTL=(q)=>{let J=this.#W.get(q);if(J===void 0)return 0;let Y=$[J],V=Q[J];if(!Y||!V)return 1/0;let W=(Z||X())-V;return Y-W},this.#S=(q)=>{let J=Q[q],Y=$[q];return!!Y&&!!J&&(Z||X())-J>Y}}#y=()=>{};#w=()=>{};#E=()=>{};#S=()=>!1;#h(){let $=new m0(this.#Q);this.#G=0,this.#F=$,this.#D=(Q)=>{this.#G-=$[Q],$[Q]=0},this.#m=(Q,Z,X,q)=>{if(this.#z(Z))return 0;if(!L0(X))if(q){if(typeof q!=="function")throw TypeError("sizeCalculation must be a function");if(X=q(Z,Q),!L0(X))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 X},this.#x=(Q,Z,X)=>{if($[Q]=Z,this.#$){let q=this.#$-$[Q];while(this.#G>q)this.#u(!0)}if(this.#G+=$[Q],X)X.entrySize=Z,X.totalCalculatedSize=this.#G}}#D=($)=>{};#x=($,Q,Z)=>{};#m=($,Q,Z,X)=>{if(Z||X)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#N({allowStale:$=this.allowStale}={}){if(this.#H)for(let Q=this.#A;;){if(!this.#l(Q))break;if($||!this.#S(Q))yield Q;if(Q===this.#U)break;else Q=this.#M[Q]}}*#b({allowStale:$=this.allowStale}={}){if(this.#H)for(let Q=this.#U;;){if(!this.#l(Q))break;if($||!this.#S(Q))yield Q;if(Q===this.#A)break;else Q=this.#O[Q]}}#l($){return $!==void 0&&this.#W.get(this.#_[$])===$}*entries(){for(let $ of this.#N())if(this.#q[$]!==void 0&&this.#_[$]!==void 0&&!this.#z(this.#q[$]))yield[this.#_[$],this.#q[$]]}*rentries(){for(let $ of this.#b())if(this.#q[$]!==void 0&&this.#_[$]!==void 0&&!this.#z(this.#q[$]))yield[this.#_[$],this.#q[$]]}*keys(){for(let $ of this.#N()){let Q=this.#_[$];if(Q!==void 0&&!this.#z(this.#q[$]))yield Q}}*rkeys(){for(let $ of this.#b()){let Q=this.#_[$];if(Q!==void 0&&!this.#z(this.#q[$]))yield Q}}*values(){for(let $ of this.#N())if(this.#q[$]!==void 0&&!this.#z(this.#q[$]))yield this.#q[$]}*rvalues(){for(let $ of this.#b())if(this.#q[$]!==void 0&&!this.#z(this.#q[$]))yield this.#q[$]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find($,Q={}){for(let Z of this.#N()){let X=this.#q[Z],q=this.#z(X)?X.__staleWhileFetching:X;if(q===void 0)continue;if($(q,this.#_[Z],this))return this.get(this.#_[Z],Q)}}forEach($,Q=this){for(let Z of this.#N()){let X=this.#q[Z],q=this.#z(X)?X.__staleWhileFetching:X;if(q===void 0)continue;$.call(Q,q,this.#_[Z],this)}}rforEach($,Q=this){for(let Z of this.#b()){let X=this.#q[Z],q=this.#z(X)?X.__staleWhileFetching:X;if(q===void 0)continue;$.call(Q,q,this.#_[Z],this)}}purgeStale(){let $=!1;for(let Q of this.#b({allowStale:!0}))if(this.#S(Q))this.#k(this.#_[Q],"expire"),$=!0;return $}info($){let Q=this.#W.get($);if(Q===void 0)return;let Z=this.#q[Q],X=this.#z(Z)?Z.__staleWhileFetching:Z;if(X===void 0)return;let q={value:X};if(this.#I&&this.#V){let J=this.#I[Q],Y=this.#V[Q];if(J&&Y){let V=J-(k0.now()-Y);q.ttl=V,q.start=Date.now()}}if(this.#F)q.size=this.#F[Q];return q}dump(){let $=[];for(let Q of this.#N({allowStale:!0})){let Z=this.#_[Q],X=this.#q[Q],q=this.#z(X)?X.__staleWhileFetching:X;if(q===void 0||Z===void 0)continue;let J={value:q};if(this.#I&&this.#V){J.ttl=this.#I[Q];let Y=k0.now()-this.#V[Q];J.start=Math.floor(Date.now()-Y)}if(this.#F)J.size=this.#F[Q];$.unshift([Z,J])}return $}load($){this.clear();for(let[Q,Z]of $){if(Z.start){let X=Date.now()-Z.start;Z.start=k0.now()-X}this.set(Q,Z.value,Z)}}set($,Q,Z={}){if(Q===void 0)return this.delete($),this;let{ttl:X=this.ttl,start:q,noDisposeOnSet:J=this.noDisposeOnSet,sizeCalculation:Y=this.sizeCalculation,status:V}=Z,{noUpdateTTL:W=this.noUpdateTTL}=Z,H=this.#m($,Q,Z.size||0,Y);if(this.maxEntrySize&&H>this.maxEntrySize){if(V)V.set="miss",V.maxEntrySizeExceeded=!0;return this.#k($,"set"),this}let _=this.#H===0?void 0:this.#W.get($);if(_===void 0){if(_=this.#H===0?this.#A:this.#T.length!==0?this.#T.pop():this.#H===this.#Q?this.#u(!1):this.#H,this.#_[_]=$,this.#q[_]=Q,this.#W.set($,_),this.#O[this.#A]=_,this.#M[_]=this.#A,this.#A=_,this.#H++,this.#x(_,H,V),V)V.set="add";if(W=!1,this.#P)this.#X?.(Q,$,"add")}else{this.#f(_);let K=this.#q[_];if(Q!==K){if(this.#j&&this.#z(K)){K.__abortController.abort(Error("replaced"));let{__staleWhileFetching:G}=K;if(G!==void 0&&!J){if(this.#K)this.#Z?.(G,$,"set");if(this.#L)this.#B?.push([G,$,"set"])}}else if(!J){if(this.#K)this.#Z?.(K,$,"set");if(this.#L)this.#B?.push([K,$,"set"])}if(this.#D(_),this.#x(_,H,V),this.#q[_]=Q,V){V.set="replace";let G=K&&this.#z(K)?K.__staleWhileFetching:K;if(G!==void 0)V.oldValue=G}}else if(V)V.set="update";if(this.#P)this.onInsert?.(Q,$,Q===K?"update":"replace")}if(X!==0&&!this.#I)this.#Y();if(this.#I){if(!W)this.#E(_,X,q);if(V)this.#w(V,_)}if(!J&&this.#L&&this.#B){let K=this.#B,G;while(G=K?.shift())this.#J?.(...G)}return this}pop(){try{while(this.#H){let $=this.#q[this.#U];if(this.#u(!0),this.#z($)){if($.__staleWhileFetching)return $.__staleWhileFetching}else if($!==void 0)return $}}finally{if(this.#L&&this.#B){let $=this.#B,Q;while(Q=$?.shift())this.#J?.(...Q)}}}#u($){let Q=this.#U,Z=this.#_[Q],X=this.#q[Q];if(this.#j&&this.#z(X))X.__abortController.abort(Error("evicted"));else if(this.#K||this.#L){if(this.#K)this.#Z?.(X,Z,"evict");if(this.#L)this.#B?.push([X,Z,"evict"])}if(this.#D(Q),$)this.#_[Q]=void 0,this.#q[Q]=void 0,this.#T.push(Q);if(this.#H===1)this.#U=this.#A=0,this.#T.length=0;else this.#U=this.#O[Q];return this.#W.delete(Z),this.#H--,Q}has($,Q={}){let{updateAgeOnHas:Z=this.updateAgeOnHas,status:X}=Q,q=this.#W.get($);if(q!==void 0){let J=this.#q[q];if(this.#z(J)&&J.__staleWhileFetching===void 0)return!1;if(!this.#S(q)){if(Z)this.#y(q);if(X)X.has="hit",this.#w(X,q);return!0}else if(X)X.has="stale",this.#w(X,q)}else if(X)X.has="miss";return!1}peek($,Q={}){let{allowStale:Z=this.allowStale}=Q,X=this.#W.get($);if(X===void 0||!Z&&this.#S(X))return;let q=this.#q[X];return this.#z(q)?q.__staleWhileFetching:q}#v($,Q,Z,X){let q=Q===void 0?void 0:this.#q[Q];if(this.#z(q))return q;let J=new G8,{signal:Y}=Z;Y?.addEventListener("abort",()=>J.abort(Y.reason),{signal:J.signal});let V={signal:J.signal,options:Z,context:X},W=(O,z=!1)=>{let{aborted:U}=J.signal,A=Z.ignoreFetchAbort&&O!==void 0;if(Z.status)if(U&&!z){if(Z.status.fetchAborted=!0,Z.status.fetchError=J.signal.reason,A)Z.status.fetchAbortIgnored=!0}else Z.status.fetchResolved=!0;if(U&&!A&&!z)return _(J.signal.reason);let L=G;if(this.#q[Q]===G)if(O===void 0)if(L.__staleWhileFetching)this.#q[Q]=L.__staleWhileFetching;else this.#k($,"fetch");else{if(Z.status)Z.status.fetchUpdated=!0;this.set($,O,V.options)}return O},H=(O)=>{if(Z.status)Z.status.fetchRejected=!0,Z.status.fetchError=O;return _(O)},_=(O)=>{let{aborted:z}=J.signal,U=z&&Z.allowStaleOnFetchAbort,A=U||Z.allowStaleOnFetchRejection,L=A||Z.noDeleteOnFetchRejection,R=G;if(this.#q[Q]===G){if(!L||R.__staleWhileFetching===void 0)this.#k($,"fetch");else if(!U)this.#q[Q]=R.__staleWhileFetching}if(A){if(Z.status&&R.__staleWhileFetching!==void 0)Z.status.returnedStale=!0;return R.__staleWhileFetching}else if(R.__returned===R)throw O},K=(O,z)=>{let U=this.#C?.($,q,V);if(U&&U instanceof Promise)U.then((A)=>O(A===void 0?void 0:A),z);J.signal.addEventListener("abort",()=>{if(!Z.ignoreFetchAbort||Z.allowStaleOnFetchAbort){if(O(void 0),Z.allowStaleOnFetchAbort)O=(A)=>W(A,!0)}})};if(Z.status)Z.status.fetchDispatched=!0;let G=new Promise(K).then(W,H),M=Object.assign(G,{__abortController:J,__staleWhileFetching:q,__returned:void 0});if(Q===void 0)this.set($,M,{...V.options,status:void 0}),Q=this.#W.get($);else this.#q[Q]=M;return M}#z($){if(!this.#j)return!1;let Q=$;return!!Q&&Q instanceof Promise&&Q.hasOwnProperty("__staleWhileFetching")&&Q.__abortController instanceof G8}async fetch($,Q={}){let{allowStale:Z=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:q=this.noDeleteOnStaleGet,ttl:J=this.ttl,noDisposeOnSet:Y=this.noDisposeOnSet,size:V=0,sizeCalculation:W=this.sizeCalculation,noUpdateTTL:H=this.noUpdateTTL,noDeleteOnFetchRejection:_=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:K=this.allowStaleOnFetchRejection,ignoreFetchAbort:G=this.ignoreFetchAbort,allowStaleOnFetchAbort:M=this.allowStaleOnFetchAbort,context:O,forceRefresh:z=!1,status:U,signal:A}=Q;if(!this.#j){if(U)U.fetch="get";return this.get($,{allowStale:Z,updateAgeOnGet:X,noDeleteOnStaleGet:q,status:U})}let L={allowStale:Z,updateAgeOnGet:X,noDeleteOnStaleGet:q,ttl:J,noDisposeOnSet:Y,size:V,sizeCalculation:W,noUpdateTTL:H,noDeleteOnFetchRejection:_,allowStaleOnFetchRejection:K,allowStaleOnFetchAbort:M,ignoreFetchAbort:G,status:U,signal:A},R=this.#W.get($);if(R===void 0){if(U)U.fetch="miss";let T=this.#v($,R,L,O);return T.__returned=T}else{let T=this.#q[R];if(this.#z(T)){let e=Z&&T.__staleWhileFetching!==void 0;if(U){if(U.fetch="inflight",e)U.returnedStale=!0}return e?T.__staleWhileFetching:T.__returned=T}let c=this.#S(R);if(!z&&!c){if(U)U.fetch="hit";if(this.#f(R),X)this.#y(R);if(U)this.#w(U,R);return T}let D=this.#v($,R,L,O),S0=D.__staleWhileFetching!==void 0&&Z;if(U){if(U.fetch=c?"stale":"refresh",S0&&c)U.returnedStale=!0}return S0?D.__staleWhileFetching:D.__returned=D}}async forceFetch($,Q={}){let Z=await this.fetch($,Q);if(Z===void 0)throw Error("fetch() returned undefined");return Z}memo($,Q={}){let Z=this.#R;if(!Z)throw Error("no memoMethod provided to constructor");let{context:X,forceRefresh:q,...J}=Q,Y=this.get($,J);if(!q&&Y!==void 0)return Y;let V=Z($,Y,{options:J,context:X});return this.set($,V,J),V}get($,Q={}){let{allowStale:Z=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:q=this.noDeleteOnStaleGet,status:J}=Q,Y=this.#W.get($);if(Y!==void 0){let V=this.#q[Y],W=this.#z(V);if(J)this.#w(J,Y);if(this.#S(Y)){if(J)J.get="stale";if(!W){if(!q)this.#k($,"expire");if(J&&Z)J.returnedStale=!0;return Z?V:void 0}else{if(J&&Z&&V.__staleWhileFetching!==void 0)J.returnedStale=!0;return Z?V.__staleWhileFetching:void 0}}else{if(J)J.get="hit";if(W)return V.__staleWhileFetching;if(this.#f(Y),X)this.#y(Y);return V}}else if(J)J.get="miss"}#c($,Q){this.#M[Q]=$,this.#O[$]=Q}#f($){if($!==this.#A){if($===this.#U)this.#U=this.#O[$];else this.#c(this.#M[$],this.#O[$]);this.#c(this.#A,$),this.#A=$}}delete($){return this.#k($,"delete")}#k($,Q){let Z=!1;if(this.#H!==0){let X=this.#W.get($);if(X!==void 0)if(Z=!0,this.#H===1)this.#g(Q);else{this.#D(X);let q=this.#q[X];if(this.#z(q))q.__abortController.abort(Error("deleted"));else if(this.#K||this.#L){if(this.#K)this.#Z?.(q,$,Q);if(this.#L)this.#B?.push([q,$,Q])}if(this.#W.delete($),this.#_[X]=void 0,this.#q[X]=void 0,X===this.#A)this.#A=this.#M[X];else if(X===this.#U)this.#U=this.#O[X];else{let J=this.#M[X];this.#O[J]=this.#O[X];let Y=this.#O[X];this.#M[Y]=this.#M[X]}this.#H--,this.#T.push(X)}}if(this.#L&&this.#B?.length){let X=this.#B,q;while(q=X?.shift())this.#J?.(...q)}return Z}clear(){return this.#g("delete")}#g($){for(let Q of this.#b({allowStale:!0})){let Z=this.#q[Q];if(this.#z(Z))Z.__abortController.abort(Error("deleted"));else{let X=this.#_[Q];if(this.#K)this.#Z?.(Z,X,$);if(this.#L)this.#B?.push([Z,X,$])}}if(this.#W.clear(),this.#q.fill(void 0),this.#_.fill(void 0),this.#I&&this.#V)this.#I.fill(0),this.#V.fill(0);if(this.#F)this.#F.fill(0);if(this.#U=0,this.#A=0,this.#T.length=0,this.#G=0,this.#H=0,this.#L&&this.#B){let Q=this.#B,Z;while(Z=Q?.shift())this.#J?.(...Z)}}}import{posix as L9,win32 as x$}from"path";import{fileURLToPath as B9}from"url";import{lstatSync as R9,readdir as C9,readdirSync as I9,readlinkSync as F9,realpathSync as T9}from"fs";import*as j9 from"fs";import{lstat as S9,readdir as N9,readlink as b9,realpath as P9}from"fs/promises";import{EventEmitter as k$}from"events";import C5 from"stream";import{StringDecoder as W9}from"string_decoder";var A5=typeof process==="object"&&process?process:{stdout:null,stderr:null},H9=($)=>!!$&&typeof $==="object"&&($ instanceof j0||$ instanceof C5||K9($)||_9($)),K9=($)=>!!$&&typeof $==="object"&&$ instanceof k$&&typeof $.pipe==="function"&&$.pipe!==C5.Writable.prototype.pipe,_9=($)=>!!$&&typeof $==="object"&&$ instanceof k$&&typeof $.write==="function"&&typeof $.end==="function",z0=Symbol("EOF"),U0=Symbol("maybeEmitEnd"),B0=Symbol("emittedEnd"),z8=Symbol("emittingEnd"),c0=Symbol("emittedError"),U8=Symbol("closed"),L5=Symbol("read"),M8=Symbol("flush"),B5=Symbol("flushChunk"),Z0=Symbol("encoding"),D0=Symbol("decoder"),v=Symbol("flowing"),d0=Symbol("paused"),v0=Symbol("resume"),x=Symbol("buffer"),p=Symbol("pipes"),u=Symbol("bufferLength"),S$=Symbol("bufferPush"),O8=Symbol("bufferShift"),l=Symbol("objectMode"),E=Symbol("destroyed"),N$=Symbol("error"),b$=Symbol("emitData"),R5=Symbol("emitEnd"),P$=Symbol("emitEnd2"),Y0=Symbol("async"),E$=Symbol("abort"),A8=Symbol("aborted"),p0=Symbol("signal"),T0=Symbol("dataListeners"),n=Symbol("discarded"),i0=($)=>Promise.resolve().then($),G9=($)=>$(),z9=($)=>$==="end"||$==="finish"||$==="prefinish",U9=($)=>$ instanceof ArrayBuffer||!!$&&typeof $==="object"&&$.constructor&&$.constructor.name==="ArrayBuffer"&&$.byteLength>=0,M9=($)=>!Buffer.isBuffer($)&&ArrayBuffer.isView($);class y${src;dest;opts;ondrain;constructor($,Q,Z){this.src=$,this.dest=Q,this.opts=Z,this.ondrain=()=>$[v0](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors($){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class I5 extends y${unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor($,Q,Z){super($,Q,Z);this.proxyErrors=(X)=>Q.emit("error",X),$.on("error",this.proxyErrors)}}var O9=($)=>!!$.objectMode,A9=($)=>!$.objectMode&&!!$.encoding&&$.encoding!=="buffer";class j0 extends k${[v]=!1;[d0]=!1;[p]=[];[x]=[];[l];[Z0];[Y0];[D0];[z0]=!1;[B0]=!1;[z8]=!1;[U8]=!1;[c0]=null;[u]=0;[E]=!1;[p0];[A8]=!1;[T0]=0;[n]=!1;writable=!0;readable=!0;constructor(...$){let Q=$[0]||{};super();if(Q.objectMode&&typeof Q.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(O9(Q))this[l]=!0,this[Z0]=null;else if(A9(Q))this[Z0]=Q.encoding,this[l]=!1;else this[l]=!1,this[Z0]=null;if(this[Y0]=!!Q.async,this[D0]=this[Z0]?new W9(this[Z0]):null,Q&&Q.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[x]});if(Q&&Q.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[p]});let{signal:Z}=Q;if(Z)if(this[p0]=Z,Z.aborted)this[E$]();else Z.addEventListener("abort",()=>this[E$]())}get bufferLength(){return this[u]}get encoding(){return this[Z0]}set encoding($){throw Error("Encoding must be set at instantiation time")}setEncoding($){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[l]}set objectMode($){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[Y0]}set["async"]($){this[Y0]=this[Y0]||!!$}[E$](){this[A8]=!0,this.emit("abort",this[p0]?.reason),this.destroy(this[p0]?.reason)}get aborted(){return this[A8]}set aborted($){}write($,Q,Z){if(this[A8])return!1;if(this[z0])throw Error("write after end");if(this[E])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Q==="function")Z=Q,Q="utf8";if(!Q)Q="utf8";let X=this[Y0]?i0:G9;if(!this[l]&&!Buffer.isBuffer($)){if(M9($))$=Buffer.from($.buffer,$.byteOffset,$.byteLength);else if(U9($))$=Buffer.from($);else if(typeof $!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[l]){if(this[v]&&this[u]!==0)this[M8](!0);if(this[v])this.emit("data",$);else this[S$]($);if(this[u]!==0)this.emit("readable");if(Z)X(Z);return this[v]}if(!$.length){if(this[u]!==0)this.emit("readable");if(Z)X(Z);return this[v]}if(typeof $==="string"&&!(Q===this[Z0]&&!this[D0]?.lastNeed))$=Buffer.from($,Q);if(Buffer.isBuffer($)&&this[Z0])$=this[D0].write($);if(this[v]&&this[u]!==0)this[M8](!0);if(this[v])this.emit("data",$);else this[S$]($);if(this[u]!==0)this.emit("readable");if(Z)X(Z);return this[v]}read($){if(this[E])return null;if(this[n]=!1,this[u]===0||$===0||$&&$>this[u])return this[U0](),null;if(this[l])$=null;if(this[x].length>1&&!this[l])this[x]=[this[Z0]?this[x].join(""):Buffer.concat(this[x],this[u])];let Q=this[L5]($||null,this[x][0]);return this[U0](),Q}[L5]($,Q){if(this[l])this[O8]();else{let Z=Q;if($===Z.length||$===null)this[O8]();else if(typeof Z==="string")this[x][0]=Z.slice($),Q=Z.slice(0,$),this[u]-=$;else this[x][0]=Z.subarray($),Q=Z.subarray(0,$),this[u]-=$}if(this.emit("data",Q),!this[x].length&&!this[z0])this.emit("drain");return Q}end($,Q,Z){if(typeof $==="function")Z=$,$=void 0;if(typeof Q==="function")Z=Q,Q="utf8";if($!==void 0)this.write($,Q);if(Z)this.once("end",Z);if(this[z0]=!0,this.writable=!1,this[v]||!this[d0])this[U0]();return this}[v0](){if(this[E])return;if(!this[T0]&&!this[p].length)this[n]=!0;if(this[d0]=!1,this[v]=!0,this.emit("resume"),this[x].length)this[M8]();else if(this[z0])this[U0]();else this.emit("drain")}resume(){return this[v0]()}pause(){this[v]=!1,this[d0]=!0,this[n]=!1}get destroyed(){return this[E]}get flowing(){return this[v]}get paused(){return this[d0]}[S$]($){if(this[l])this[u]+=1;else this[u]+=$.length;this[x].push($)}[O8](){if(this[l])this[u]-=1;else this[u]-=this[x][0].length;return this[x].shift()}[M8]($=!1){do;while(this[B5](this[O8]())&&this[x].length);if(!$&&!this[x].length&&!this[z0])this.emit("drain")}[B5]($){return this.emit("data",$),this[v]}pipe($,Q){if(this[E])return $;this[n]=!1;let Z=this[B0];if(Q=Q||{},$===A5.stdout||$===A5.stderr)Q.end=!1;else Q.end=Q.end!==!1;if(Q.proxyErrors=!!Q.proxyErrors,Z){if(Q.end)$.end()}else if(this[p].push(!Q.proxyErrors?new y$(this,$,Q):new I5(this,$,Q)),this[Y0])i0(()=>this[v0]());else this[v0]();return $}unpipe($){let Q=this[p].find((Z)=>Z.dest===$);if(Q){if(this[p].length===1){if(this[v]&&this[T0]===0)this[v]=!1;this[p]=[]}else this[p].splice(this[p].indexOf(Q),1);Q.unpipe()}}addListener($,Q){return this.on($,Q)}on($,Q){let Z=super.on($,Q);if($==="data"){if(this[n]=!1,this[T0]++,!this[p].length&&!this[v])this[v0]()}else if($==="readable"&&this[u]!==0)super.emit("readable");else if(z9($)&&this[B0])super.emit($),this.removeAllListeners($);else if($==="error"&&this[c0]){let X=Q;if(this[Y0])i0(()=>X.call(this,this[c0]));else X.call(this,this[c0])}return Z}removeListener($,Q){return this.off($,Q)}off($,Q){let Z=super.off($,Q);if($==="data"){if(this[T0]=this.listeners("data").length,this[T0]===0&&!this[n]&&!this[p].length)this[v]=!1}return Z}removeAllListeners($){let Q=super.removeAllListeners($);if($==="data"||$===void 0){if(this[T0]=0,!this[n]&&!this[p].length)this[v]=!1}return Q}get emittedEnd(){return this[B0]}[U0](){if(!this[z8]&&!this[B0]&&!this[E]&&this[x].length===0&&this[z0]){if(this[z8]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[U8])this.emit("close");this[z8]=!1}}emit($,...Q){let Z=Q[0];if($!=="error"&&$!=="close"&&$!==E&&this[E])return!1;else if($==="data")return!this[l]&&!Z?!1:this[Y0]?(i0(()=>this[b$](Z)),!0):this[b$](Z);else if($==="end")return this[R5]();else if($==="close"){if(this[U8]=!0,!this[B0]&&!this[E])return!1;let q=super.emit("close");return this.removeAllListeners("close"),q}else if($==="error"){this[c0]=Z,super.emit(N$,Z);let q=!this[p0]||this.listeners("error").length?super.emit("error",Z):!1;return this[U0](),q}else if($==="resume"){let q=super.emit("resume");return this[U0](),q}else if($==="finish"||$==="prefinish"){let q=super.emit($);return this.removeAllListeners($),q}let X=super.emit($,...Q);return this[U0](),X}[b$]($){for(let Z of this[p])if(Z.dest.write($)===!1)this.pause();let Q=this[n]?!1:super.emit("data",$);return this[U0](),Q}[R5](){if(this[B0])return!1;return this[B0]=!0,this.readable=!1,this[Y0]?(i0(()=>this[P$]()),!0):this[P$]()}[P$](){if(this[D0]){let Q=this[D0].end();if(Q){for(let Z of this[p])Z.dest.write(Q);if(!this[n])super.emit("data",Q)}}for(let Q of this[p])Q.end();let $=super.emit("end");return this.removeAllListeners("end"),$}async collect(){let $=Object.assign([],{dataLength:0});if(!this[l])$.dataLength=0;let Q=this.promise();return this.on("data",(Z)=>{if($.push(Z),!this[l])$.dataLength+=Z.length}),await Q,$}async concat(){if(this[l])throw Error("cannot concat in objectMode");let $=await this.collect();return this[Z0]?$.join(""):Buffer.concat($,$.dataLength)}async promise(){return new Promise(($,Q)=>{this.on(E,()=>Q(Error("stream destroyed"))),this.on("error",(Z)=>Q(Z)),this.on("end",()=>$())})}[Symbol.asyncIterator](){this[n]=!1;let $=!1,Q=async()=>{return this.pause(),$=!0,{value:void 0,done:!0}};return{next:()=>{if($)return Q();let X=this.read();if(X!==null)return Promise.resolve({done:!1,value:X});if(this[z0])return Q();let q,J,Y=(_)=>{this.off("data",V),this.off("end",W),this.off(E,H),Q(),J(_)},V=(_)=>{this.off("error",Y),this.off("end",W),this.off(E,H),this.pause(),q({value:_,done:!!this[z0]})},W=()=>{this.off("error",Y),this.off("data",V),this.off(E,H),Q(),q({done:!0,value:void 0})},H=()=>Y(Error("stream destroyed"));return new Promise((_,K)=>{J=K,q=_,this.once(E,H),this.once("error",Y),this.once("end",W),this.once("data",V)})},throw:Q,return:Q,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[n]=!1;let $=!1,Q=()=>{return this.pause(),this.off(N$,Q),this.off(E,Q),this.off("end",Q),$=!0,{done:!0,value:void 0}},Z=()=>{if($)return Q();let X=this.read();return X===null?Q():{done:!1,value:X}};return this.once("end",Q),this.once(N$,Q),this.once(E,Q),{next:Z,throw:Q,return:Q,[Symbol.iterator](){return this}}}destroy($){if(this[E]){if($)this.emit("error",$);else this.emit(E);return this}this[E]=!0,this[n]=!0,this[x].length=0,this[u]=0;let Q=this;if(typeof Q.close==="function"&&!this[U8])Q.close();if($)this.emit("error",$);else this.emit(E);return this}static get isStream(){return H9}}var w9=T9.native,r0={lstatSync:R9,readdir:C9,readdirSync:I9,readlinkSync:F9,realpathSync:w9,promises:{lstat:S9,readdir:N9,readlink:b9,realpath:P9}},S5=($)=>!$||$===r0||$===j9?r0:{...r0,...$,promises:{...r0.promises,...$.promises||{}}},N5=/^\\\\\?\\([a-z]:)\\?$/i,E9=($)=>$.replace(/\//g,"\\").replace(N5,"$1\\"),k9=/[\\\/]/,a=0,b5=1,P5=2,V0=4,E5=6,k5=8,w0=10,y5=12,o=15,n0=~o,D$=16,F5=32,s0=64,X0=128,L8=256,R8=512,T5=s0|X0|R8,y9=1023,v$=($)=>$.isFile()?k5:$.isDirectory()?V0:$.isSymbolicLink()?w0:$.isCharacterDevice()?P5:$.isBlockDevice()?E5:$.isSocket()?y5:$.isFIFO()?b5:a,j5=new Map,o0=($)=>{let Q=j5.get($);if(Q)return Q;let Z=$.normalize("NFKD");return j5.set($,Z),Z},w5=new Map,B8=($)=>{let Q=w5.get($);if(Q)return Q;let Z=o0($.toLowerCase());return w5.set($,Z),Z};class u$ extends l0{constructor(){super({max:256})}}class D5 extends l0{constructor($=16384){super({maxSize:$,sizeCalculation:(Q)=>Q.length+1})}}var v5=Symbol("PathScurry setAsCwd");class i{name;root;roots;parent;nocase;isCWD=!1;#Q;#$;get dev(){return this.#$}#Z;get mode(){return this.#Z}#X;get nlink(){return this.#X}#J;get uid(){return this.#J}#C;get gid(){return this.#C}#R;get rdev(){return this.#R}#H;get blksize(){return this.#H}#G;get ino(){return this.#G}#W;get size(){return this.#W}#_;get blocks(){return this.#_}#q;get atimeMs(){return this.#q}#O;get mtimeMs(){return this.#O}#M;get ctimeMs(){return this.#M}#U;get birthtimeMs(){return this.#U}#A;get atime(){return this.#A}#T;get mtime(){return this.#T}#B;get ctime(){return this.#B}#F;get birthtime(){return this.#F}#V;#I;#K;#j;#L;#P;#Y;#y;#w;#E;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor($,Q=a,Z,X,q,J,Y){if(this.name=$,this.#V=q?B8($):o0($),this.#Y=Q&y9,this.nocase=q,this.roots=X,this.root=Z||this,this.#y=J,this.#K=Y.fullpath,this.#L=Y.relative,this.#P=Y.relativePosix,this.parent=Y.parent,this.parent)this.#Q=this.parent.#Q;else this.#Q=S5(Y.fs)}depth(){if(this.#I!==void 0)return this.#I;if(!this.parent)return this.#I=0;return this.#I=this.parent.depth()+1}childrenCache(){return this.#y}resolve($){if(!$)return this;let Q=this.getRootString($),X=$.substring(Q.length).split(this.splitSep);return Q?this.getRoot(Q).#S(X):this.#S(X)}#S($){let Q=this;for(let Z of $)Q=Q.child(Z);return Q}children(){let $=this.#y.get(this);if($)return $;let Q=Object.assign([],{provisional:0});return this.#y.set(this,Q),this.#Y&=~D$,Q}child($,Q){if($===""||$===".")return this;if($==="..")return this.parent||this;let Z=this.children(),X=this.nocase?B8($):o0($);for(let V of Z)if(V.#V===X)return V;let q=this.parent?this.sep:"",J=this.#K?this.#K+q+$:void 0,Y=this.newChild($,a,{...Q,parent:this,fullpath:J});if(!this.canReaddir())Y.#Y|=X0;return Z.push(Y),Y}relative(){if(this.isCWD)return"";if(this.#L!==void 0)return this.#L;let $=this.name,Q=this.parent;if(!Q)return this.#L=this.name;let Z=Q.relative();return Z+(!Z||!Q.parent?"":this.sep)+$}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#P!==void 0)return this.#P;let $=this.name,Q=this.parent;if(!Q)return this.#P=this.fullpathPosix();let Z=Q.relativePosix();return Z+(!Z||!Q.parent?"":"/")+$}fullpath(){if(this.#K!==void 0)return this.#K;let $=this.name,Q=this.parent;if(!Q)return this.#K=this.name;let X=Q.fullpath()+(!Q.parent?"":this.sep)+$;return this.#K=X}fullpathPosix(){if(this.#j!==void 0)return this.#j;if(this.sep==="/")return this.#j=this.fullpath();if(!this.parent){let X=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(X))return this.#j=`//?/${X}`;else return this.#j=X}let $=this.parent,Q=$.fullpathPosix(),Z=Q+(!Q||!$.parent?"":"/")+this.name;return this.#j=Z}isUnknown(){return(this.#Y&o)===a}isType($){return this[`is${$}`]()}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.#Y&o)===k5}isDirectory(){return(this.#Y&o)===V0}isCharacterDevice(){return(this.#Y&o)===P5}isBlockDevice(){return(this.#Y&o)===E5}isFIFO(){return(this.#Y&o)===b5}isSocket(){return(this.#Y&o)===y5}isSymbolicLink(){return(this.#Y&w0)===w0}lstatCached(){return this.#Y&F5?this:void 0}readlinkCached(){return this.#w}realpathCached(){return this.#E}readdirCached(){let $=this.children();return $.slice(0,$.provisional)}canReadlink(){if(this.#w)return!0;if(!this.parent)return!1;let $=this.#Y&o;return!($!==a&&$!==w0||this.#Y&L8||this.#Y&X0)}calledReaddir(){return!!(this.#Y&D$)}isENOENT(){return!!(this.#Y&X0)}isNamed($){return!this.nocase?this.#V===o0($):this.#V===B8($)}async readlink(){let $=this.#w;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Q=await this.#Q.promises.readlink(this.fullpath()),Z=(await this.parent.realpath())?.resolve(Q);if(Z)return this.#w=Z}catch(Q){this.#u(Q.code);return}}readlinkSync(){let $=this.#w;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Q=this.#Q.readlinkSync(this.fullpath()),Z=this.parent.realpathSync()?.resolve(Q);if(Z)return this.#w=Z}catch(Q){this.#u(Q.code);return}}#h($){this.#Y|=D$;for(let Q=$.provisional;Q<$.length;Q++){let Z=$[Q];if(Z)Z.#D()}}#D(){if(this.#Y&X0)return;this.#Y=(this.#Y|X0)&n0,this.#x()}#x(){let $=this.children();$.provisional=0;for(let Q of $)Q.#D()}#m(){this.#Y|=R8,this.#N()}#N(){if(this.#Y&s0)return;let $=this.#Y;if(($&o)===V0)$&=n0;this.#Y=$|s0,this.#x()}#b($=""){if($==="ENOTDIR"||$==="EPERM")this.#N();else if($==="ENOENT")this.#D();else this.children().provisional=0}#l($=""){if($==="ENOTDIR")this.parent.#N();else if($==="ENOENT")this.#D()}#u($=""){let Q=this.#Y;if(Q|=L8,$==="ENOENT")Q|=X0;if($==="EINVAL"||$==="UNKNOWN")Q&=n0;if(this.#Y=Q,$==="ENOTDIR"&&this.parent)this.parent.#N()}#v($,Q){return this.#c($,Q)||this.#z($,Q)}#z($,Q){let Z=v$($),X=this.newChild($.name,Z,{parent:this}),q=X.#Y&o;if(q!==V0&&q!==w0&&q!==a)X.#Y|=s0;return Q.unshift(X),Q.provisional++,X}#c($,Q){for(let Z=Q.provisional;Z<Q.length;Z++){let X=Q[Z];if((this.nocase?B8($.name):o0($.name))!==X.#V)continue;return this.#f($,X,Z,Q)}}#f($,Q,Z,X){let q=Q.name;if(Q.#Y=Q.#Y&n0|v$($),q!==$.name)Q.name=$.name;if(Z!==X.provisional){if(Z===X.length-1)X.pop();else X.splice(Z,1);X.unshift(Q)}return X.provisional++,Q}async lstat(){if((this.#Y&X0)===0)try{return this.#k(await this.#Q.promises.lstat(this.fullpath())),this}catch($){this.#l($.code)}}lstatSync(){if((this.#Y&X0)===0)try{return this.#k(this.#Q.lstatSync(this.fullpath())),this}catch($){this.#l($.code)}}#k($){let{atime:Q,atimeMs:Z,birthtime:X,birthtimeMs:q,blksize:J,blocks:Y,ctime:V,ctimeMs:W,dev:H,gid:_,ino:K,mode:G,mtime:M,mtimeMs:O,nlink:z,rdev:U,size:A,uid:L}=$;this.#A=Q,this.#q=Z,this.#F=X,this.#U=q,this.#H=J,this.#_=Y,this.#B=V,this.#M=W,this.#$=H,this.#C=_,this.#G=K,this.#Z=G,this.#T=M,this.#O=O,this.#X=z,this.#R=U,this.#W=A,this.#J=L;let R=v$($);if(this.#Y=this.#Y&n0|R|F5,R!==a&&R!==V0&&R!==w0)this.#Y|=s0}#g=[];#p=!1;#i($){this.#p=!1;let Q=this.#g.slice();this.#g.length=0,Q.forEach((Z)=>Z(null,$))}readdirCB($,Q=!1){if(!this.canReaddir()){if(Q)$(null,[]);else queueMicrotask(()=>$(null,[]));return}let Z=this.children();if(this.calledReaddir()){let q=Z.slice(0,Z.provisional);if(Q)$(null,q);else queueMicrotask(()=>$(null,q));return}if(this.#g.push($),this.#p)return;this.#p=!0;let X=this.fullpath();this.#Q.readdir(X,{withFileTypes:!0},(q,J)=>{if(q)this.#b(q.code),Z.provisional=0;else{for(let Y of J)this.#v(Y,Z);this.#h(Z)}this.#i(Z.slice(0,Z.provisional));return})}#d;async readdir(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Q=this.fullpath();if(this.#d)await this.#d;else{let Z=()=>{};this.#d=new Promise((X)=>Z=X);try{for(let X of await this.#Q.promises.readdir(Q,{withFileTypes:!0}))this.#v(X,$);this.#h($)}catch(X){this.#b(X.code),$.provisional=0}this.#d=void 0,Z()}return $.slice(0,$.provisional)}readdirSync(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Q=this.fullpath();try{for(let Z of this.#Q.readdirSync(Q,{withFileTypes:!0}))this.#v(Z,$);this.#h($)}catch(Z){this.#b(Z.code),$.provisional=0}return $.slice(0,$.provisional)}canReaddir(){if(this.#Y&T5)return!1;let $=o&this.#Y;if(!($===a||$===V0||$===w0))return!1;return!0}shouldWalk($,Q){return(this.#Y&V0)===V0&&!(this.#Y&T5)&&!$.has(this)&&(!Q||Q(this))}async realpath(){if(this.#E)return this.#E;if((R8|L8|X0)&this.#Y)return;try{let $=await this.#Q.promises.realpath(this.fullpath());return this.#E=this.resolve($)}catch($){this.#m()}}realpathSync(){if(this.#E)return this.#E;if((R8|L8|X0)&this.#Y)return;try{let $=this.#Q.realpathSync(this.fullpath());return this.#E=this.resolve($)}catch($){this.#m()}}[v5]($){if($===this)return;$.isCWD=!1,this.isCWD=!0;let Q=new Set([]),Z=[],X=this;while(X&&X.parent)Q.add(X),X.#L=Z.join(this.sep),X.#P=Z.join("/"),X=X.parent,Z.push("..");X=$;while(X&&X.parent&&!Q.has(X))X.#L=void 0,X.#P=void 0,X=X.parent}}class C8 extends i{sep="\\";splitSep=k9;constructor($,Q=a,Z,X,q,J,Y){super($,Q,Z,X,q,J,Y)}newChild($,Q=a,Z={}){return new C8($,Q,this.root,this.roots,this.nocase,this.childrenCache(),Z)}getRootString($){return x$.parse($).root}getRoot($){if($=E9($.toUpperCase()),$===this.root.name)return this.root;for(let[Q,Z]of Object.entries(this.roots))if(this.sameRoot($,Q))return this.roots[$]=Z;return this.roots[$]=new a0($,this).root}sameRoot($,Q=this.root.name){return $=$.toUpperCase().replace(/\//g,"\\").replace(N5,"$1\\"),$===Q}}class I8 extends i{splitSep="/";sep="/";constructor($,Q=a,Z,X,q,J,Y){super($,Q,Z,X,q,J,Y)}getRootString($){return $.startsWith("/")?"/":""}getRoot($){return this.root}newChild($,Q=a,Z={}){return new I8($,Q,this.root,this.roots,this.nocase,this.childrenCache(),Z)}}class f${root;rootPath;roots;cwd;#Q;#$;#Z;nocase;#X;constructor($=process.cwd(),Q,Z,{nocase:X,childrenCacheSize:q=16384,fs:J=r0}={}){if(this.#X=S5(J),$ instanceof URL||$.startsWith("file://"))$=B9($);let Y=Q.resolve($);this.roots=Object.create(null),this.rootPath=this.parseRootPath(Y),this.#Q=new u$,this.#$=new u$,this.#Z=new D5(q);let V=Y.substring(this.rootPath.length).split(Z);if(V.length===1&&!V[0])V.pop();if(X===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=X,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let W=this.root,H=V.length-1,_=Q.sep,K=this.rootPath,G=!1;for(let M of V){let O=H--;W=W.child(M,{relative:Array(O).fill("..").join(_),relativePosix:Array(O).fill("..").join("/"),fullpath:K+=(G?"":_)+M}),G=!0}this.cwd=W}depth($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.depth()}childrenCache(){return this.#Z}resolve(...$){let Q="";for(let q=$.length-1;q>=0;q--){let J=$[q];if(!J||J===".")continue;if(Q=Q?`${J}/${Q}`:J,this.isAbsolute(J))break}let Z=this.#Q.get(Q);if(Z!==void 0)return Z;let X=this.cwd.resolve(Q).fullpath();return this.#Q.set(Q,X),X}resolvePosix(...$){let Q="";for(let q=$.length-1;q>=0;q--){let J=$[q];if(!J||J===".")continue;if(Q=Q?`${J}/${Q}`:J,this.isAbsolute(J))break}let Z=this.#$.get(Q);if(Z!==void 0)return Z;let X=this.cwd.resolve(Q).fullpathPosix();return this.#$.set(Q,X),X}relative($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relative()}relativePosix($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relativePosix()}basename($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.name}dirname($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return($.parent||$).fullpath()}async readdir($=this.cwd,Q={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z}=Q;if(!$.canReaddir())return[];else{let X=await $.readdir();return Z?X:X.map((q)=>q.name)}}readdirSync($=this.cwd,Q={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z=!0}=Q;if(!$.canReaddir())return[];else if(Z)return $.readdirSync();else return $.readdirSync().map((X)=>X.name)}async lstat($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstat()}lstatSync($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstatSync()}async readlink($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$.withFileTypes,$=this.cwd;let Z=await $.readlink();return Q?Z:Z?.fullpath()}readlinkSync($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$.withFileTypes,$=this.cwd;let Z=$.readlinkSync();return Q?Z:Z?.fullpath()}async realpath($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$.withFileTypes,$=this.cwd;let Z=await $.realpath();return Q?Z:Z?.fullpath()}realpathSync($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$.withFileTypes,$=this.cwd;let Z=$.realpathSync();return Q?Z:Z?.fullpath()}async walk($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:J}=Q,Y=[];if(!q||q($))Y.push(Z?$:$.fullpath());let V=new Set,W=(_,K)=>{V.add(_),_.readdirCB((G,M)=>{if(G)return K(G);let O=M.length;if(!O)return K();let z=()=>{if(--O===0)K()};for(let U of M){if(!q||q(U))Y.push(Z?U:U.fullpath());if(X&&U.isSymbolicLink())U.realpath().then((A)=>A?.isUnknown()?A.lstat():A).then((A)=>A?.shouldWalk(V,J)?W(A,z):z());else if(U.shouldWalk(V,J))W(U,z);else z()}},!0)},H=$;return new Promise((_,K)=>{W(H,(G)=>{if(G)return K(G);_(Y)})})}walkSync($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:J}=Q,Y=[];if(!q||q($))Y.push(Z?$:$.fullpath());let V=new Set([$]);for(let W of V){let H=W.readdirSync();for(let _ of H){if(!q||q(_))Y.push(Z?_:_.fullpath());let K=_;if(_.isSymbolicLink()){if(!(X&&(K=_.realpathSync())))continue;if(K.isUnknown())K.lstatSync()}if(K.shouldWalk(V,J))V.add(K)}}return Y}[Symbol.asyncIterator](){return this.iterate()}iterate($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;return this.stream($,Q)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:J}=Q;if(!q||q($))yield Z?$:$.fullpath();let Y=new Set([$]);for(let V of Y){let W=V.readdirSync();for(let H of W){if(!q||q(H))yield Z?H:H.fullpath();let _=H;if(H.isSymbolicLink()){if(!(X&&(_=H.realpathSync())))continue;if(_.isUnknown())_.lstatSync()}if(_.shouldWalk(Y,J))Y.add(_)}}}stream($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:J}=Q,Y=new j0({objectMode:!0});if(!q||q($))Y.write(Z?$:$.fullpath());let V=new Set,W=[$],H=0,_=()=>{let K=!1;while(!K){let G=W.shift();if(!G){if(H===0)Y.end();return}H++,V.add(G);let M=(z,U,A=!1)=>{if(z)return Y.emit("error",z);if(X&&!A){let L=[];for(let R of U)if(R.isSymbolicLink())L.push(R.realpath().then((T)=>T?.isUnknown()?T.lstat():T));if(L.length){Promise.all(L).then(()=>M(null,U,!0));return}}for(let L of U)if(L&&(!q||q(L))){if(!Y.write(Z?L:L.fullpath()))K=!0}H--;for(let L of U){let R=L.realpathCached()||L;if(R.shouldWalk(V,J))W.push(R)}if(K&&!Y.flowing)Y.once("drain",_);else if(!O)_()},O=!0;G.readdirCB(M,!0),O=!1}};return _(),Y}streamSync($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:J}=Q,Y=new j0({objectMode:!0}),V=new Set;if(!q||q($))Y.write(Z?$:$.fullpath());let W=[$],H=0,_=()=>{let K=!1;while(!K){let G=W.shift();if(!G){if(H===0)Y.end();return}H++,V.add(G);let M=G.readdirSync();for(let O of M)if(!q||q(O)){if(!Y.write(Z?O:O.fullpath()))K=!0}H--;for(let O of M){let z=O;if(O.isSymbolicLink()){if(!(X&&(z=O.realpathSync())))continue;if(z.isUnknown())z.lstatSync()}if(z.shouldWalk(V,J))W.push(z)}}if(K&&!Y.flowing)Y.once("drain",_)};return _(),Y}chdir($=this.cwd){let Q=this.cwd;this.cwd=typeof $==="string"?this.cwd.resolve($):$,this.cwd[v5](Q)}}class a0 extends f${sep="\\";constructor($=process.cwd(),Q={}){let{nocase:Z=!0}=Q;super($,x$,"\\",{...Q,nocase:Z});this.nocase=Z;for(let X=this.cwd;X;X=X.parent)X.nocase=this.nocase}parseRootPath($){return x$.parse($).root.toUpperCase()}newRoot($){return new C8(this.rootPath,V0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")||$.startsWith("\\")||/^[a-z]:(\/|\\)/i.test($)}}class t0 extends f${sep="/";constructor($=process.cwd(),Q={}){let{nocase:Z=!1}=Q;super($,L9,"/",{...Q,nocase:Z});this.nocase=Z}parseRootPath($){return"/"}newRoot($){return new I8(this.rootPath,V0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")}}class F8 extends t0{constructor($=process.cwd(),Q={}){let{nocase:Z=!0}=Q;super($,{...Q,nocase:Z})}}var f3=process.platform==="win32"?C8:I8,x5=process.platform==="win32"?a0:process.platform==="darwin"?F8:t0;var D9=($)=>$.length>=1,v9=($)=>$.length>=1;class x0{#Q;#$;#Z;length;#X;#J;#C;#R;#H;#G;#W=!0;constructor($,Q,Z,X){if(!D9($))throw TypeError("empty pattern list");if(!v9(Q))throw TypeError("empty glob list");if(Q.length!==$.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=$.length,Z<0||Z>=this.length)throw TypeError("index out of range");if(this.#Q=$,this.#$=Q,this.#Z=Z,this.#X=X,this.#Z===0){if(this.isUNC()){let[q,J,Y,V,...W]=this.#Q,[H,_,K,G,...M]=this.#$;if(W[0]==="")W.shift(),M.shift();let O=[q,J,Y,V,""].join("/"),z=[H,_,K,G,""].join("/");this.#Q=[O,...W],this.#$=[z,...M],this.length=this.#Q.length}else if(this.isDrive()||this.isAbsolute()){let[q,...J]=this.#Q,[Y,...V]=this.#$;if(J[0]==="")J.shift(),V.shift();let W=q+"/",H=Y+"/";this.#Q=[W,...J],this.#$=[H,...V],this.length=this.#Q.length}}}pattern(){return this.#Q[this.#Z]}isString(){return typeof this.#Q[this.#Z]==="string"}isGlobstar(){return this.#Q[this.#Z]===g}isRegExp(){return this.#Q[this.#Z]instanceof RegExp}globString(){return this.#C=this.#C||(this.#Z===0?this.isAbsolute()?this.#$[0]+this.#$.slice(1).join("/"):this.#$.join("/"):this.#$.slice(this.#Z).join("/"))}hasMore(){return this.length>this.#Z+1}rest(){if(this.#J!==void 0)return this.#J;if(!this.hasMore())return this.#J=null;return this.#J=new x0(this.#Q,this.#$,this.#Z+1,this.#X),this.#J.#G=this.#G,this.#J.#H=this.#H,this.#J.#R=this.#R,this.#J}isUNC(){let $=this.#Q;return this.#H!==void 0?this.#H:this.#H=this.#X==="win32"&&this.#Z===0&&$[0]===""&&$[1]===""&&typeof $[2]==="string"&&!!$[2]&&typeof $[3]==="string"&&!!$[3]}isDrive(){let $=this.#Q;return this.#R!==void 0?this.#R:this.#R=this.#X==="win32"&&this.#Z===0&&this.length>1&&typeof $[0]==="string"&&/^[a-z]:$/i.test($[0])}isAbsolute(){let $=this.#Q;return this.#G!==void 0?this.#G:this.#G=$[0]===""&&$.length>1||this.isDrive()||this.isUNC()}root(){let $=this.#Q[0];return typeof $==="string"&&this.isAbsolute()&&this.#Z===0?$:""}checkFollowGlobstar(){return!(this.#Z===0||!this.isGlobstar()||!this.#W)}markFollowGlobstar(){if(this.#Z===0||!this.isGlobstar()||!this.#W)return!1;return this.#W=!1,!0}}var x9=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class e0{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor($,{nobrace:Q,nocase:Z,noext:X,noglobstar:q,platform:J=x9}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=J,this.mmopts={dot:!0,nobrace:Q,nocase:Z,noext:X,noglobstar:q,optimizationLevel:2,platform:J,nocomment:!0,nonegate:!0};for(let Y of $)this.add(Y)}add($){let Q=new s($,this.mmopts);for(let Z=0;Z<Q.set.length;Z++){let X=Q.set[Z],q=Q.globParts[Z];if(!X||!q)throw Error("invalid pattern object");while(X[0]==="."&&q[0]===".")X.shift(),q.shift();let J=new x0(X,q,0,this.platform),Y=new s(J.globString(),this.mmopts),V=q[q.length-1]==="**",W=J.isAbsolute();if(W)this.absolute.push(Y);else this.relative.push(Y);if(V)if(W)this.absoluteChildren.push(Y);else this.relativeChildren.push(Y)}}ignored($){let Q=$.fullpath(),Z=`${Q}/`,X=$.relative()||".",q=`${X}/`;for(let J of this.relative)if(J.match(X)||J.match(q))return!0;for(let J of this.absolute)if(J.match(Q)||J.match(Z))return!0;return!1}childrenIgnored($){let Q=$.fullpath()+"/",Z=($.relative()||".")+"/";for(let X of this.relativeChildren)if(X.match(Z))return!0;for(let X of this.absoluteChildren)if(X.match(Q))return!0;return!1}}class g${store;constructor($=new Map){this.store=$}copy(){return new g$(new Map(this.store))}hasWalked($,Q){return this.store.get($.fullpath())?.has(Q.globString())}storeWalked($,Q){let Z=$.fullpath(),X=this.store.get(Z);if(X)X.add(Q.globString());else this.store.set(Z,new Set([Q.globString()]))}}class u5{store=new Map;add($,Q,Z){let X=(Q?2:0)|(Z?1:0),q=this.store.get($);this.store.set($,q===void 0?X:X&q)}entries(){return[...this.store.entries()].map(([$,Q])=>[$,!!(Q&2),!!(Q&1)])}}class f5{store=new Map;add($,Q){if(!$.canReaddir())return;let Z=this.store.get($);if(Z){if(!Z.find((X)=>X.globString()===Q.globString()))Z.push(Q)}else this.store.set($,[Q])}get($){let Q=this.store.get($);if(!Q)throw Error("attempting to walk unknown path");return Q}entries(){return this.keys().map(($)=>[$,this.store.get($)])}keys(){return[...this.store.keys()].filter(($)=>$.canReaddir())}}class $8{hasWalkedCache;matches=new u5;subwalks=new f5;patterns;follow;dot;opts;constructor($,Q){this.opts=$,this.follow=!!$.follow,this.dot=!!$.dot,this.hasWalkedCache=Q?Q.copy():new g$}processPatterns($,Q){this.patterns=Q;let Z=Q.map((X)=>[$,X]);for(let[X,q]of Z){this.hasWalkedCache.storeWalked(X,q);let J=q.root(),Y=q.isAbsolute()&&this.opts.absolute!==!1;if(J){X=X.resolve(J==="/"&&this.opts.root!==void 0?this.opts.root:J);let _=q.rest();if(!_){this.matches.add(X,!0,!1);continue}else q=_}if(X.isENOENT())continue;let V,W,H=!1;while(typeof(V=q.pattern())==="string"&&(W=q.rest()))X=X.resolve(V),q=W,H=!0;if(V=q.pattern(),W=q.rest(),H){if(this.hasWalkedCache.hasWalked(X,q))continue;this.hasWalkedCache.storeWalked(X,q)}if(typeof V==="string"){let _=V===".."||V===""||V===".";this.matches.add(X.resolve(V),Y,_);continue}else if(V===g){if(!X.isSymbolicLink()||this.follow||q.checkFollowGlobstar())this.subwalks.add(X,q);let _=W?.pattern(),K=W?.rest();if(!W||(_===""||_===".")&&!K)this.matches.add(X,Y,_===""||_===".");else if(_===".."){let G=X.parent||X;if(!K)this.matches.add(G,Y,!0);else if(!this.hasWalkedCache.hasWalked(G,K))this.subwalks.add(G,K)}}else if(V instanceof RegExp)this.subwalks.add(X,q)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new $8(this.opts,this.hasWalkedCache)}filterEntries($,Q){let Z=this.subwalks.get($),X=this.child();for(let q of Q)for(let J of Z){let Y=J.isAbsolute(),V=J.pattern(),W=J.rest();if(V===g)X.testGlobstar(q,J,W,Y);else if(V instanceof RegExp)X.testRegExp(q,V,W,Y);else X.testString(q,V,W,Y)}return X}testGlobstar($,Q,Z,X){if(this.dot||!$.name.startsWith(".")){if(!Q.hasMore())this.matches.add($,X,!1);if($.canReaddir()){if(this.follow||!$.isSymbolicLink())this.subwalks.add($,Q);else if($.isSymbolicLink()){if(Z&&Q.checkFollowGlobstar())this.subwalks.add($,Z);else if(Q.markFollowGlobstar())this.subwalks.add($,Q)}}}if(Z){let q=Z.pattern();if(typeof q==="string"&&q!==".."&&q!==""&&q!==".")this.testString($,q,Z.rest(),X);else if(q===".."){let J=$.parent||$;this.subwalks.add(J,Z)}else if(q instanceof RegExp)this.testRegExp($,q,Z.rest(),X)}}testRegExp($,Q,Z,X){if(!Q.test($.name))return;if(!Z)this.matches.add($,X,!1);else this.subwalks.add($,Z)}testString($,Q,Z,X){if(!$.isNamed(Q))return;if(!Z)this.matches.add($,X,!1);else this.subwalks.add($,Z)}}var u9=($,Q)=>typeof $==="string"?new e0([$],Q):Array.isArray($)?new e0($,Q):$;class h${path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Q=[];#$;#Z;signal;maxDepth;includeChildMatches;constructor($,Q,Z){if(this.patterns=$,this.path=Q,this.opts=Z,this.#Z=!Z.posix&&Z.platform==="win32"?"\\":"/",this.includeChildMatches=Z.includeChildMatches!==!1,Z.ignore||!this.includeChildMatches){if(this.#$=u9(Z.ignore??[],Z),!this.includeChildMatches&&typeof this.#$.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=Z.maxDepth||1/0,Z.signal)this.signal=Z.signal,this.signal.addEventListener("abort",()=>{this.#Q.length=0})}#X($){return this.seen.has($)||!!this.#$?.ignored?.($)}#J($){return!!this.#$?.childrenIgnored?.($)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let $=void 0;while(!this.paused&&($=this.#Q.shift()))$()}onResume($){if(this.signal?.aborted)return;if(!this.paused)$();else this.#Q.push($)}async matchCheck($,Q){if(Q&&this.opts.nodir)return;let Z;if(this.opts.realpath){if(Z=$.realpathCached()||await $.realpath(),!Z)return;$=Z}let q=$.isUnknown()||this.opts.stat?await $.lstat():$;if(this.opts.follow&&this.opts.nodir&&q?.isSymbolicLink()){let J=await q.realpath();if(J&&(J.isUnknown()||this.opts.stat))await J.lstat()}return this.matchCheckTest(q,Q)}matchCheckTest($,Q){return $&&(this.maxDepth===1/0||$.depth()<=this.maxDepth)&&(!Q||$.canReaddir())&&(!this.opts.nodir||!$.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!$.isSymbolicLink()||!$.realpathCached()?.isDirectory())&&!this.#X($)?$:void 0}matchCheckSync($,Q){if(Q&&this.opts.nodir)return;let Z;if(this.opts.realpath){if(Z=$.realpathCached()||$.realpathSync(),!Z)return;$=Z}let q=$.isUnknown()||this.opts.stat?$.lstatSync():$;if(this.opts.follow&&this.opts.nodir&&q?.isSymbolicLink()){let J=q.realpathSync();if(J&&(J?.isUnknown()||this.opts.stat))J.lstatSync()}return this.matchCheckTest(q,Q)}matchFinish($,Q){if(this.#X($))return;if(!this.includeChildMatches&&this.#$?.add){let q=`${$.relativePosix()}/**`;this.#$.add(q)}let Z=this.opts.absolute===void 0?Q:this.opts.absolute;this.seen.add($);let X=this.opts.mark&&$.isDirectory()?this.#Z:"";if(this.opts.withFileTypes)this.matchEmit($);else if(Z){let q=this.opts.posix?$.fullpathPosix():$.fullpath();this.matchEmit(q+X)}else{let q=this.opts.posix?$.relativePosix():$.relative(),J=this.opts.dotRelative&&!q.startsWith(".."+this.#Z)?"."+this.#Z:"";this.matchEmit(!q?"."+X:J+q+X)}}async match($,Q,Z){let X=await this.matchCheck($,Z);if(X)this.matchFinish(X,Q)}matchSync($,Q,Z){let X=this.matchCheckSync($,Z);if(X)this.matchFinish(X,Q)}walkCB($,Q,Z){if(this.signal?.aborted)Z();this.walkCB2($,Q,new $8(this.opts),Z)}walkCB2($,Q,Z,X){if(this.#J($))return X();if(this.signal?.aborted)X();if(this.paused){this.onResume(()=>this.walkCB2($,Q,Z,X));return}Z.processPatterns($,Q);let q=1,J=()=>{if(--q===0)X()};for(let[Y,V,W]of Z.matches.entries()){if(this.#X(Y))continue;q++,this.match(Y,V,W).then(()=>J())}for(let Y of Z.subwalkTargets()){if(this.maxDepth!==1/0&&Y.depth()>=this.maxDepth)continue;q++;let V=Y.readdirCached();if(Y.calledReaddir())this.walkCB3(Y,V,Z,J);else Y.readdirCB((W,H)=>this.walkCB3(Y,H,Z,J),!0)}J()}walkCB3($,Q,Z,X){Z=Z.filterEntries($,Q);let q=1,J=()=>{if(--q===0)X()};for(let[Y,V,W]of Z.matches.entries()){if(this.#X(Y))continue;q++,this.match(Y,V,W).then(()=>J())}for(let[Y,V]of Z.subwalks.entries())q++,this.walkCB2(Y,V,Z.child(),J);J()}walkCBSync($,Q,Z){if(this.signal?.aborted)Z();this.walkCB2Sync($,Q,new $8(this.opts),Z)}walkCB2Sync($,Q,Z,X){if(this.#J($))return X();if(this.signal?.aborted)X();if(this.paused){this.onResume(()=>this.walkCB2Sync($,Q,Z,X));return}Z.processPatterns($,Q);let q=1,J=()=>{if(--q===0)X()};for(let[Y,V,W]of Z.matches.entries()){if(this.#X(Y))continue;this.matchSync(Y,V,W)}for(let Y of Z.subwalkTargets()){if(this.maxDepth!==1/0&&Y.depth()>=this.maxDepth)continue;q++;let V=Y.readdirSync();this.walkCB3Sync(Y,V,Z,J)}J()}walkCB3Sync($,Q,Z,X){Z=Z.filterEntries($,Q);let q=1,J=()=>{if(--q===0)X()};for(let[Y,V,W]of Z.matches.entries()){if(this.#X(Y))continue;this.matchSync(Y,V,W)}for(let[Y,V]of Z.subwalks.entries())q++,this.walkCB2Sync(Y,V,Z.child(),J);J()}}class T8 extends h${matches=new Set;constructor($,Q,Z){super($,Q,Z)}matchEmit($){this.matches.add($)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise(($,Q)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)Q(this.signal.reason);else $(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class j8 extends h${results;constructor($,Q,Z){super($,Q,Z);this.results=new j0({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit($){if(this.results.write($),!this.results.flowing)this.pause()}stream(){let $=this.path;if($.isUnknown())$.lstat().then(()=>{this.walkCB($,this.patterns,()=>this.results.end())});else this.walkCB($,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var g9=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class W0{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($,Q){if(!Q)throw TypeError("glob options required");if(this.withFileTypes=!!Q.withFileTypes,this.signal=Q.signal,this.follow=!!Q.follow,this.dot=!!Q.dot,this.dotRelative=!!Q.dotRelative,this.nodir=!!Q.nodir,this.mark=!!Q.mark,!Q.cwd)this.cwd="";else if(Q.cwd instanceof URL||Q.cwd.startsWith("file://"))Q.cwd=f9(Q.cwd);if(this.cwd=Q.cwd||"",this.root=Q.root,this.magicalBraces=!!Q.magicalBraces,this.nobrace=!!Q.nobrace,this.noext=!!Q.noext,this.realpath=!!Q.realpath,this.absolute=Q.absolute,this.includeChildMatches=Q.includeChildMatches!==!1,this.noglobstar=!!Q.noglobstar,this.matchBase=!!Q.matchBase,this.maxDepth=typeof Q.maxDepth==="number"?Q.maxDepth:1/0,this.stat=!!Q.stat,this.ignore=Q.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof $==="string")$=[$];if(this.windowsPathsNoEscape=!!Q.windowsPathsNoEscape||Q.allowWindowsEscape===!1,this.windowsPathsNoEscape)$=$.map((V)=>V.replace(/\\/g,"/"));if(this.matchBase){if(Q.noglobstar)throw TypeError("base matching requires globstar");$=$.map((V)=>V.includes("/")?V:`./**/${V}`)}if(this.pattern=$,this.platform=Q.platform||g9,this.opts={...Q,platform:this.platform},Q.scurry){if(this.scurry=Q.scurry,Q.nocase!==void 0&&Q.nocase!==Q.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let V=Q.platform==="win32"?a0:Q.platform==="darwin"?F8:Q.platform?t0:x5;this.scurry=new V(this.cwd,{nocase:Q.nocase,fs:Q.fs})}this.nocase=this.scurry.nocase;let Z=this.platform==="darwin"||this.platform==="win32",X={...Q,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:Z,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},q=this.pattern.map((V)=>new s(V,X)),[J,Y]=q.reduce((V,W)=>{return V[0].push(...W.set),V[1].push(...W.globParts),V},[[],[]]);this.patterns=J.map((V,W)=>{let H=Y[W];if(!H)throw Error("invalid pattern object");return new x0(V,H,0,this.platform)})}async walk(){return[...await new T8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new T8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new j8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new j8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,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()}}var m$=($,Q={})=>{if(!Array.isArray($))$=[$];for(let Z of $)if(new s(Z,Q).hasMagic())return!0;return!1};function w8($,Q={}){return new W0($,Q).streamSync()}function m5($,Q={}){return new W0($,Q).stream()}function S8($,Q={}){return new W0($,Q).walkSync()}async function g5($,Q={}){return new W0($,Q).walk()}function N8($,Q={}){return new W0($,Q).iterateSync()}function l5($,Q={}){return new W0($,Q).iterate()}var h9=w8,m9=Object.assign(m5,{sync:w8}),l9=N8,c9=Object.assign(l5,{sync:N8}),d9=Object.assign(S8,{stream:w8,iterate:N8}),h5=Object.assign(g5,{glob:g5,globSync:S8,sync:d9,globStream:m5,stream:m9,globStreamSync:w8,streamSync:h9,globIterate:l5,iterate:c9,globIterateSync:N8,iterateSync:l9,Glob:W0,hasMagic:m$,escape:E0,unescape:Q0});h5.glob=h5;import p9 from"path";var c5=({dir:$,pattern:Q="*",nodir:Z=!1,dot:X=!0,ignore:q=[],absolute:J=!1,matchBase:Y=!1,follow:V=!1})=>{if($=$||process.cwd(),$=p9.resolve($),Q&&!Array.isArray(Q))Q=[Q];else Q=Q||["*"];if(q&&!Array.isArray(q))q=[q];else q=q||[];return S8(Q,{cwd:$,nodir:Z,dot:X,ignore:q,absolute:J,matchBase:Y,follow:V})};import i5 from"@fnet/expression";import d5 from"lodash.clonedeep";import i9 from"@fnet/key-value-transformer";import n9 from"@fnet/expression";async function y({node:$,initNode:Q,extra:Z=!0}){if(Reflect.has($.definition,"modules")&&!Array.isArray($.definition.modules)){let X=$.definition.modules;$.definition.modules=[],Object.keys(X).forEach((q)=>{let J={...X[q]};if(typeof J.export==="boolean")J.export=J.export===!0?q:!1;else if(typeof J.export==="string")J.export=J.export;else delete J.export;$.definition.modules.push({[q]:J})})}if(Z){let X=[],q=await i9({data:$.definition,callback:(J,Y,V)=>{let W=n9({expression:J});if(W?.processor==="m"){let H=V.slice(0,-1);H.push(W.statement);let _=H.join("_");return X.push({[_]:Y}),[W.statement,`m::${_}`]}return[J,Y]}});if(X.length>0)$.definition=q,$.definition.modules=$.definition.modules||[],$.definition.modules=$.definition.modules.concat(X)}$.hasModules=$.definition.modules?.length>0;for(let X=0;X<$.definition.modules?.length;X++){let q=$.definition.modules[X],J=Object.keys(q)[0],Y={name:J,childs:[],parent:$,definition:q[J],module:!0,blockAutoJumpToParent:!0,blockAutoJumpToSibling:!1,index:$.childs.length,context:{}};$.childs.push(Y),await Q({node:Y})}}async function N({node:$,transformExpression:Q}){let Z=$.context.transform;if(Reflect.has(Z,"export"))Z.export=await Q(Z.export);if(Reflect.has(Z,"return"))$.hasReturn=!0,Z.return=await Q(Z.return);if(Reflect.has(Z,"output"))Z.output=await Q(Z.output);if(Reflect.has(Z,"assign"))for(let X=0;X<Z.assign?.length;X++){let q=Z.assign[X],J=Object.keys(q)[0],Y=q[J],V={key:await Q(J),value:await Q(Y)};Z.assign[X]=V}}async function r9({node:$}){if(!$.definition.hasOwnProperty("switch"))return!1;return!0}async function s9({node:$,initNode:Q}){$.type="switch";let Z=$.definition.switch||[];if(!Z.every((Y)=>Y.hasOwnProperty("condition")||Y.hasOwnProperty("default")))throw Error("Switch must have condition or default");if(Z.filter((Y)=>Y.hasOwnProperty("condition")).length===0)throw Error("Switch must have at least one condition");let J=Z.filter((Y)=>Y.hasOwnProperty("default"));if(J.length>1)throw Error("Switch must have only one default");if(J.length===1&&!Z[Z.length-1].hasOwnProperty("default"))throw Error("Switch default must be the last child");$.hasDefaultCondition=J.length===1,await y({node:$,initNode:Q,extra:!1}),$.blockAutoJumpToParent=!1,$.blockAutoJumpToSibling=!0;for(let Y=0;Y<$.definition.switch.length;Y++){let V=$.definition.switch[Y],W=`${Y}`;if(V.hasOwnProperty("default"))W="default",V=V.default;let H={name:V.condition||W,childs:[],parent:$,definition:V,index:$.childs.length,context:{}};$.childs.push(H),await Q({node:H})}$.resolve=p5}async function p5({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||d5($.definition);let q=$.context.transform;for(let J of $.childs)if(J.context.transform=J.context.transform||d5(J.definition),J.definition.hasOwnProperty("condition"))J.context.transform.condition=await X(J.definition.condition);await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var Q8={hits:r9,init:s9,resolve:p5};async function o9({node:$}){if(Object.keys($.definition).map((q)=>i5({expression:q})).filter((q)=>q?.processor==="if").length===1)return!0;if($.definition.if&&typeof $.definition.if==="object")return!0;return!1}async function a9($){let{node:Q}=$,X=Object.keys(Q.definition).map((W)=>i5({expression:W})),q=[],J=X.find((W)=>W?.processor==="if");if(J){let W=Q.definition[J.expression];q.push({name:`${Q.name}_if`,definition:W,processor:J}),delete Q.definition[J.expression]}else if(Q.definition.if){let{condition:W,...H}=Q.definition.if;q.push({name:`${Q.name}_if`,definition:H,processor:{expression:`if::${W}`,statement:W}}),delete Q.definition.if}let Y=X.filter((W)=>W?.processor==="elseif"),V=0;for(let W of Y){let H=Q.definition[W.expression];q.push({name:`${Q.name}_elseif_${V++}`,definition:H,processor:W}),delete Q.definition[W.expression]}if(Q.definition.elseif){let{condition:W,...H}=Q.definition.elseif;q.push({name:`${Q.name}_elseif_${V++}`,definition:H,processor:{expression:`elseif::${W}`,statement:W}}),delete Q.definition.elseif}Q.definition.switch=[];for(let W of q)Q.definition.switch.push({condition:W.processor.statement,...W.definition});if(Q.definition?.else){let W=Q.definition.else;Q.definition.switch.push({default:W}),delete Q.definition.else}await Q8.init($)}var l$={hits:o9,init:a9};import n5 from"lodash.clonedeep";async function t9({node:$}){return $.definition.hasOwnProperty("try")&&$.definition.hasOwnProperty("except")}async function e9({node:$,initNode:Q}){if($.type="tryexcept",await y({node:$,initNode:Q,extra:!1}),$.blockAutoJumpToParent=!1,$.blockAutoJumpToSibling=!0,$.definition.try){let X={name:"try",childs:[],parent:$,definition:$.definition.try,index:$.childs.length,context:{}};$.childs.push(X),await Q({node:X})}if($.definition.except){let X={name:"except",childs:[],parent:$,definition:$.definition.except,index:$.childs.length,context:{}};$.childs.push(X),await Q({node:X})}$.resolve=r5}async function r5({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||n5($.definition);let q=$.context.transform;if($.context.try=$.childs.find((J)=>J.name==="try"),$.context.except=$.childs.find((J)=>J.name==="except"),$.context.except){let J=$.context.except;if(J.context.transform=J.context.transform||n5(J.definition),!J.context.transform.hasOwnProperty("as"))J.context.transform.as="error"}await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var c$={hits:t9,init:e9,resolve:r5};import $Q from"lodash.clonedeep";async function QQ({node:$}){return $.definition.hasOwnProperty("assign")}async function ZQ({node:$,initNode:Q}){$.type="assign",await y({node:$,initNode:Q}),$.resolve=s5}async function s5({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||$Q($.definition);let q=$.context.transform;await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var d$={hits:QQ,init:ZQ,resolve:s5};import XQ from"lodash.clonedeep";async function qQ({node:$}){return $.definition.hasOwnProperty("for")}async function JQ({node:$,initNode:Q}){if($.type="for",await y({node:$,initNode:Q,extra:!1}),$.blockAutoJumpToParent=!0,$.blockAutoJumpToSibling=!1,!$.definition.for.hasOwnProperty("steps")){let{value:Z,in:X,...q}=$.definition.for,J={};if(Z!==void 0)J.value=Z;if(X!==void 0)J.in=X;$.definition.for=J,$.definition.for.steps=[{[`${$.name}_step`]:q}]}if(!Array.isArray($.definition.for.steps))$.definition.for.steps=[{[`${$.name}_step`]:$.definition.for.steps}];for(let Z=0;Z<$.definition.for.steps.length;Z++){let X=$.definition.for.steps[Z],q=Object.keys(X)[0],J={name:q,childs:[],parent:$,definition:X[q],index:$.childs.length,context:{}};$.childs.push(J),await Q({node:J})}$.resolve=o5}async function o5({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||XQ($.definition);let q=$.context.transform;q.for.in=await X($.definition.for.in),await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var p$={hits:qQ,init:JQ,resolve:o5};async function YQ({node:$}){return!1}async function VQ({node:$,initNode:Q}){}async function WQ({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X,transformValue:q}){}var i$={hits:YQ,init:VQ,resolve:WQ};import HQ from"lodash.clonedeep";async function KQ({node:$}){return $.definition.hasOwnProperty("raise")}async function _Q({node:$,initNode:Q}){$.type="raise",$.resolve=a5}async function a5({node:$,resolveTypeCommon:Q,transformExpression:Z}){$.context.transform=$.context.transform||HQ($.definition);let X=$.context.transform;X.raise=await Z(X.raise),await Q({node:$})}var n$={hits:KQ,init:_Q,resolve:a5};import GQ from"lodash.clonedeep";async function zQ({node:$}){return $.definition.hasOwnProperty("return")}async function UQ({node:$,initNode:Q}){$.type="return",$.resolve=t5}async function t5({node:$,resolveTypeCommon:Q,transformExpression:Z}){$.context.transform=$.context.transform||GQ($.definition);let X=$.context.transform;$.hasReturn=!0,X.return=await Z(X.return),await Q({node:$})}var r$={hits:zQ,init:UQ,resolve:t5};import MQ from"lodash.clonedeep";async function OQ({node:$}){return $.definition.hasOwnProperty("call")}async function AQ({node:$,initNode:Q}){$.type="call",await y({node:$,initNode:Q}),$.resolve=e5}async function e5({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||MQ($.definition);let q=$.context.transform,J=q.from||q.import||q.call;if($.target?.atom?.doc?.type==="function"){if(Reflect.has(q,"from"))J=q.from,q.from=await X($.target.atom.name);else if(Reflect.has(q,"import"))J=q.import,q.import=await X($.target.atom.name);else if(Reflect.has(q,"call"))q.call=await X($.target.atom.name),J=q.call}else if(Reflect.has(q,"from")||Reflect.has(q,"import")){if(q.call.startsWith("use:e::")){let V=q.call.substring(7);q.libExp=await X(`e::LIBRARY.${V}`)}}if(q.args)q.args=await X(q.args);if(q.new)q.new=await X(q.new);if(q.context)q.context=await X(q.context);if(q.result){if(typeof q.result==="string")q.result=[{[q.result]:"e::result"}];for(let V=0;V<q.result?.length;V++){let W=q.result[V],H=Object.keys(W)[0],_=W[H],K={key:await X(H),value:await X(_)};q.result[V]=K}}let Y=$.workflow.parent;$.context.lib=Y.context.libs.find((V)=>V.name===J),await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var Z8={hits:OQ,init:AQ,resolve:e5};import LQ from"lodash.clonedeep";async function BQ({node:$}){return $.definition.hasOwnProperty("steps")}async function RQ({node:$,initNode:Q}){if(!$.type)$.type="steps";let Z=$.definition.steps||[];for await(let X of Z){let q=Object.keys(X)[0],J={name:q,childs:[],parent:$,definition:X[q],index:$.childs.length,context:{}};$.childs.push(J),await Q({node:J})}$.resolve=$1}async function $1({node:$,transformExpression:Q}){$.context.next=$.childs[0],$.context.transform=$.context.transform||LQ($.definition),await N({node:$,transformExpression:Q})}var s$={hits:BQ,init:RQ,resolve:$1};import CQ from"lodash.clonedeep";async function IQ({node:$}){return $.definition.hasOwnProperty("form")}async function FQ({node:$,initNode:Q}){$.type="form",await y({node:$,initNode:Q}),$.resolve=Q1}async function Q1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||CQ($.definition);let q=$.context.transform;if(q.props)q.props=await X(q.props);let J=$.workflow.parent;$.context.lib=J.context.libs.find((Y)=>Y.name===q.form),await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var o$={hits:IQ,init:FQ,resolve:Q1};import TQ from"lodash.clonedeep";async function jQ({node:$}){return $.definition.hasOwnProperty("signal")}async function wQ({node:$,initNode:Q}){$.type="signal",$.resolve=Z1}async function Z1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X,transformValue:q}){$.context.transform=$.context.transform||TQ($.definition),await Q({node:$}),Z({node:$})}var a$={hits:jQ,init:wQ,resolve:Z1};import SQ from"lodash.clonedeep";async function NQ({node:$}){return $.definition.hasOwnProperty("wait")}async function bQ({node:$,initNode:Q}){$.type="wait",$.resolve=X1}async function X1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X,transformValue:q}){$.context.transform=$.context.transform||SQ($.definition),await Q({node:$}),Z({node:$})}var t$={hits:NQ,init:bQ,resolve:X1};import PQ from"lodash.clonedeep";async function EQ({node:$}){return $.definition.hasOwnProperty("next")}async function kQ({node:$,initNode:Q}){$.type="next",$.resolve=q1}async function q1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||PQ($.definition);let q=$.context.transform;q.next=await X(q.next),await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var e$={hits:EQ,init:kQ,resolve:q1};import yQ from"lodash.clonedeep";async function DQ({node:$}){return $.definition.hasOwnProperty("modules")}async function vQ({node:$,initNode:Q}){$.type="modules",await y({node:$,initNode:Q}),$.resolve=J1}async function J1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||yQ($.definition);let q=$.context.transform;await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var $6={hits:DQ,init:vQ,resolve:J1};function Q6({node:$}){let Q=$.definition;if($.hasReturn)return;if(Q.next==="end");else if(Q.next==="stop");else if(Q.next==="none");else if(Q.next){let Z=$.parent;while(Z.parent){let X=Z.childs.find((q)=>q.name===Q.next);if(X){$.context.next=X;break}Z=Z.parent}}else{if($.module===!0)return;let Z=$.parent,X=$.index+1;while(Z.parent)if(Z.blockAutoJumpToParent&&Z.blockAutoJumpToSibling)break;else if(!Reflect.has(Z,"blockAutoJumpToParent")&&!Reflect.has(Z,"blockAutoJumpToSibling")){let q=Z.childs.find((J)=>J.index===X);if(q){$.context.next=q;break}else{X=Z.index+1,Z=Z.parent;continue}}else if(Z.blockAutoJumpToParent){let q=Z.childs.find((J)=>J.index===X);if(q)$.context.next=q;break}else if(!Z.blockAutoJumpToParent){X=Z.index+1,Z=Z.parent;continue}}}class Y1{#Q;#$;#Z;#X;constructor({key:$,npm:Q,master:Z,extras:X}){this.#Q=$,this.#$=Q,this.#Z=Z,this.#X=X}hits({node:$}){return $.definition.hasOwnProperty(this.#Q)}async init($){let{node:Q}=$,Z=this.#Q,X=Q.definition,q=typeof X[Z];if(X.call=`npm:${this.#$}`,q!=="object")X.args={...X.args,[`${this.#Z}`]:X[Z]};else X.args=X[Z];if(delete X[Z],this.#X)for(let J in this.#X)X[J]=this.#X[J];console.log(`[npm-block] ${this.#Q} --> ${this.#$}`),await Z8.init($)}}function h($){return new Y1($)}import xQ from"lodash.clonedeep";async function uQ({node:$}){return $.definition.hasOwnProperty("new")}async function fQ({node:$,initNode:Q}){$.type="new",await y({node:$,initNode:Q}),$.resolve=V1}async function V1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||xQ($.definition);let q=$.context.transform,J=q.from||q.import;if($.target?.atom?.doc?.type==="function"){if(Reflect.has(q,"from"))J=q.from,q.from=await X($.target.atom.name);else if(Reflect.has(q,"import"))J=q.import,q.import=await X($.target.atom.name)}if(q.args)q.args=await X(q.args);if(q.new)q.new=await X(q.new);if(q.result){if(typeof q.result==="string")q.result=[{[q.result]:"e::result"}];for(let V=0;V<q.result?.length;V++){let W=q.result[V],H=Object.keys(W)[0],_=W[H],K={key:await X(H),value:await X(_)};q.result[V]=K}}let Y=$.workflow.parent;$.context.lib=Y.context.libs.find((V)=>V.name===J),await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var Z6={hits:uQ,init:fQ,resolve:V1};import gQ from"lodash.clonedeep";async function hQ({node:$}){return $.definition.hasOwnProperty("output")}async function mQ({node:$,initNode:Q}){$.type="output",await y({node:$,initNode:Q}),$.resolve=W1}async function W1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||gQ($.definition),await N({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var X6={hits:hQ,init:mQ,resolve:W1};var H1=({path:$})=>{if(!$)throw Error("Path is required");let Q=/^@([^\/]+\/[^\/]+)(?:\/(.+))?$/,Z=/^([^\/]+)(?:\/(.+))?$/,X;if(X=$.match(Q))return{path:$,package:"@"+X[1],subpath:X[2]||null};else if(X=$.match(Z))return{path:$,package:X[1],subpath:X[2]||null};return null};class M1{#Q;#$;#Z;#X;#J;#C;#R;#H;#G;#W;#_;#q;#O;#M;#U;#A;#T;#B;#F;#V;#I;#K=[];constructor($){this.#Q=new M6,this.#$=$,this.#C=[],this.#R=[],this.#H={},this._expire_ttl=3600,this._expire_ttl_short=300,this.#K.push(h({key:"config",npm:"@fnet/config",master:"name"})),this.#K.push(h({key:"yaml",npm:"@fnet/yaml",master:"file"})),this.#K.push(h({key:"prompt",npm:"@fnet/prompt",master:"message"})),this.#K.push(h({key:"html-link",npm:"@flownet/lib-load-browser-link-url",master:"src"})),this.#K.push(h({key:"html-script",npm:"@flownet/lib-load-browser-script-url",master:"src"})),this.#K.push(h({key:"http-server",npm:"@fnet/node-express",master:"server_port"})),this.#K.push(h({key:"shell",npm:"@fnet/shell-flow",master:"commands"})),this.#K.push(h({key:"list-files",npm:"@fnet/list-files",master:"pattern"})),this.#K.push(h({key:"up-list-files",npm:"@fnet/up-list-files",master:"pattern"})),this.#K.push(h({key:"auto-conda-env",npm:"@fnet/auto-conda-env",master:"envDir"})),this.#K.push(h({key:"ollama-chat",npm:"@fnet/ollama-chat",master:"model"})),this.#K.push(h({key:"ai",npm:"@fnet/ai",master:"prompt",extras:{subtype:"flow"}})),this.#K.push(h({key:"invoke",npm:"@fnet/invoke",master:"method",extras:{}})),this.#K.push(h({key:"fetch",npm:"@fnet/fetch",master:"url",extras:{}})),this.#K.push(h({key:"filemap",npm:"@fnet/filemap",master:"target",extras:{}})),this.#V={packageDependencies:this.#C,packageDevDependencies:this.#R,setProgress:this.setProgress.bind(this),context:this.#$,Atom:H0,registerToPackageManager:this.registerToPackageManager.bind(this)},this.#I={initNode:this.initNode.bind(this),cloneDeep:G1,resolveTypeCommon:this.resolveTypeCommon.bind(this),resolveNextBlock:Q6,transformExpression:this.transformExpression.bind(this),transformValue:this.transformValue.bind(this)}}async _cache_set($,Q,Z){}async init(){this.#_=this.#$.buildId||z1(),this.#V.buildId=this.#_,this.#U=this.#$.mode,this.#A=["all","deploy","build","file"].includes(this.#U),this.#T=["all","deploy","build"].includes(this.#U),this.#B=["all","deploy"].includes(this.#U),this.#F=["all","deploy","build","file","bpmn"].includes(this.#U),this.#O=this.#$.protocol,this.#q="BUILD:"+this.#_,this.#M=(await dQ({optional:!0,name:"atom",dir:this.#$.projectDir,tags:this.#$.tags}))?.data;try{await this.setProgress({message:"Initialization started."});let $=this.#V.context.project;await this.initAuth(),await this.initWorkflow(),this.transformWorkflow({workflow:this.#X});let Q=await this.initNodeTree({workflow:this.#X});if(await this.initNodeTreeIndex({root:Q}),await this.initNodeCalls({root:Q}),await this.initNodeCallLibs({root:Q}),await this.initNodeForms({root:Q}),await this.initNodeFormLibs({root:Q}),await this.initEntryFiles({root:Q,features:this.#Z.doc.features}),await this.initFeaturesFromNodes({childs:Q.childs,features:this.#Z.doc.features}),await Q$(this.#V),$.runtime.type==="bun")await X$(this.#V);else await Z$(this.#V);await this.initAtomLibsAndDeps({libs:Q.context.libs,packageDependencies:this.#C}),await this.resolveNodeTree({root:Q}),this.#W=Q}catch($){throw await this._cache_set(this.#q,{status:"FAILED",message:$?.message||$}),$}}async initAuth(){if(!this.#$.id)return;this.#G=await this.#Q.init({config:this.#M}),this.#V.atomAccessToken=this.#G}async initWorkflow(){let $=this.#$.id;this.#Z=this.#$.project?.workflowAtom||await H0.get({id:$}),this.#X=typeof this.#Z.doc.content==="string"?(await iQ({content:this.#Z.doc.content,tags:this.#$.tags})).parsed:this.#Z.doc.content;let Q=this.#Z.doc.bundleName;Q=Q||(this.#Z.doc.name||"").toUpperCase().replace(/[^A-Z0-9]/g,"_"),this.#Z.doc.bundleName=Q,this.#Z.type=this.#Z.type||"workflow",this.#V.atom=this.#Z,this.#Z.doc.features=this.#Z.doc.features||{}}#j($){if(console.log("filePath",$),I.statSync($).isDirectory())I.readdirSync($).forEach((Q)=>{let Z=w.join($,Q);this.#j(Z)}),I.rmSync($);else I.unlinkSync($)}#L($,Q){let Z=I.existsSync($),X=Z&&I.statSync($);if(Z&&X.isDirectory())I.mkdirSync(Q,{recursive:!0}),I.readdirSync($).forEach((J)=>{this.#L(w.join($,J),w.join(Q,J))});else I.copyFileSync($,Q)}async initWorkflowDir(){this.setProgress({message:"Initializing library directory."});let $=this.#$.projectDir,Q=this.#$.coreDir;this.setProgress({message:"Cleaning project directory."});let Z=c5({dir:$,ignore:[".cache","node_modules",".conda",".bin",".dev"],absolute:!0});for(let V of Z)I.rmSync(V,{recursive:!0,force:!0});if(this.setProgress({message:"Creating project directory."}),!I.existsSync($))I.mkdirSync($,{recursive:!0});let X=w.join($,"src");if(!I.existsSync(X))I.mkdirSync(X,{recursive:!0});let q=w.join(X,"core");this.#L(Q,q);let J=w.join(X,"default","blocks");if(!I.existsSync(J))I.mkdirSync(J,{recursive:!0});let Y=w.join($,".dev");if(!I.existsSync(Y))I.mkdirSync(Y,{recursive:!0})}async initNunjucks(){this.setProgress({message:"Initializing nunjucks."});let $=this.#$.templateDir;this.#J=X8.configure($,{watch:!1,dev:!0}),this.#V.njEnv=this.#J}transformWorkflow({workflow:$}){for(let Q of Object.values($))Q.steps=Q.steps||[],Q.steps=Q.steps.filter((Z)=>Object.keys(Z).length>0),Q.steps=Q.steps.map((Z)=>this.transformStep({step:Z}))}transformStep({step:$}){if(Array.isArray($))throw Error("Step must be an object.");let[Q,Z]=Object.entries($)[0];if(Z.hasOwnProperty("onerror")){let{onerror:X,...q}=Z;$[Q]={try:q,except:X}}if($[Q].hasOwnProperty("steps")){let X=$[Q].steps;if(!Array.isArray(X))throw Error("Steps must be an array.");$[Q].steps=X.map((q)=>this.transformStep({step:q}))}return $}async initNodeTree({workflow:$}){let Q=Object.keys($),Z={definition:$,name:void 0,type:"root",parent:void 0,childs:[],blockAutoJumpToParent:!0,blockAutoJumpToSibling:!0,index:0,depth:0,context:{libs:[],atom:this.#Z}};Q.forEach((X)=>{let q={name:X,type:X==="main"?"workflow":"subworkflow",childs:[],parent:Z,definition:$[X],index:Z.childs.length,depth:Z.depth+1,context:{},blockAutoJumpToParent:!0,blockAutoJumpToSibling:!1};Z.childs.push(q)});for await(let X of Z.childs)await this.initNode({node:X});return Z}async initNode({node:$}){let Q={...this.#I,node:$};if($.workflow=$.parent.workflow||$,$.depth=$.parent.depth+1,await c$.hits(Q))await c$.init(Q);else if(await p$.hits(Q))await p$.init(Q);else if(await Q8.hits(Q))await Q8.init(Q);else if(await l$.hits(Q))await l$.init(Q);else if(await i$.hits(Q))await i$.init(Q);else if(await Z8.hits(Q))await Z8.init(Q);else if(await Z6.hits(Q))await Z6.init(Q);else if(await n$.hits(Q))await n$.init(Q);else if(await o$.hits(Q))await o$.init(Q);else if(await a$.hits(Q))await a$.init(Q);else if(await t$.hits(Q))await t$.init(Q);else if(await s$.hits(Q))await s$.init(Q);else if(await e$.hits(Q))await e$.init(Q);else if(await $6.hits(Q))await $6.init(Q);else if(await r$.hits(Q))await r$.init(Q);else if(this.#K.find((Z)=>Z.hits(Q)))await this.#K.find((Z)=>Z.hits(Q)).init(Q);else if(await d$.hits(Q))await d$.init(Q);else if(await X6.hits(Q))await X6.init(Q);else throw Error("Undefined step type.")}async initNodeTreeIndex({root:$}){let Q={};$.indexKey="/";for await(let Z of $.childs)await this.initNodeIndex({node:Z,index:Q});return $.context.index=Q,Q}async initNodeIndex({node:$,index:Q}){let Z=w.join($.parent.indexKey,$.name);$.indexKey=Z,Q[Z]=$;let X=[],q=$;while(q?.parent)X.push(q.index),q=q.parent;X.reverse(),$.codeKey=`B_${X.join("_")}_${$.type}`,$.pathKey=`${X.join(".")}`,$.typeId=z1();for await(let J of $.childs)await this.initNodeIndex({node:J,index:Q})}async initNodeCalls({root:$}){let Q=$.context.index,Z=[];for await(let X of Object.keys(Q)){let q=Q[X];if(q.type!=="call"&&q.type!=="new")continue;Z.push(q)}return $.context.calls=Z,Z}async initNodeCallLibs({root:$}){let Q=[],Z=$.context.calls;for await(let X of Z){let q=X.definition.from||X.definition.import||X.definition.call,J=await this.findNodeCallTarget({refNode:X,curNode:X.parent})||{name:q,type:"atom",definition:X.definition},Y=Q.find((V)=>V.name===J.name&&V.type===J.type);if(!Y)Q.push(J);X.target=Y||J}return $.context.callLibs=Q,$.context.libs=[...$.context.libs,...Q],Q}async findNodeCallTarget({refNode:$,curNode:Q}){if(!Q)return;let Z=$.definition.call,X=Q.childs.find((q)=>q.name===Z&&q.type==="subworkflow");if(X)return X;else return await this.findNodeCallTarget({refNode:$,curNode:Q.parent})}async initNodeForms({root:$}){let Q=$.context.index,Z=[];for await(let X of Object.keys(Q)){let q=Q[X];if(q.type!=="form")continue;Z.push(q)}return $.context.forms=Z,Z}async initNodeFormLibs({root:$}){let Q=[],Z=$.context.forms;for await(let X of Z){let q=X.definition.from||X.definition.import||X.definition.form,J=await this.findNodeCallTarget({refNode:X,curNode:X.parent})||{name:q,type:"atom"},Y=Q.find((V)=>V.name===J.name&&V.type===J.type);if(!Y)Q.push(J);X.target=Y||J}return $.context.formLibs=Q,$.context.libs=[...$.context.libs,...Q],Q}async initFeaturesFromNodes({childs:$,features:Q}){for await(let Z of $){if(Z.type==="form"&&!Reflect.has(Q,"form"))Q.form=!0;await this.initFeaturesFromNodes({childs:Z.childs,features:Q})}}async initEntryFiles({root:$,features:Q}){for await(let Z of $.childs){let X;if(Z.name==="main")X="index.js";else if(Z.name==="cli")X="cli.js";else if(Z.name==="app")X="app.js";else if(Z.name==="api")X="api.js";else continue;Q[`${Z.name}_default_entry_file`]=X,Z.entryFile=X}}async findNodeFormTarget({refNode:$,curNode:Q}){if(!Q)return;let Z=$.definition.form,X=Q.childs.find((q)=>q.name===Z&&q.type==="subworkflow");if(X)return X;else return await this.findNodeFormTarget({refNode:$,curNode:Q.parent})}async initAtomLibsAndDeps({libs:$,packageDependencies:Q}){let Z=$.filter((X)=>X.type==="atom");for(let X=0;X<Z.length;X++){let q=Z[X],J=await this.findAtomLibrary({url:q.name,libRef:q});q.atom=J,J.doc.dependencies?.filter((V)=>typeof V.repo>"u"||V.repo==="npm")?.forEach((V)=>{let W=Q.find((H)=>H.package===V.package);if(W){if(typeof V.path==="string"){if(!(W.path||[]).some((H)=>H===V.path))W.path=W.path||[],W.path.push(V.path)}else if(Array.isArray(V.path))V.path.forEach((H)=>{if(!(W.path||[]).some((_)=>_===H))W.path=W.path||[],W.path.push(H)})}else Q.push(V)})}Q.sort((X,q)=>X.package?.localeCompare(q.package))}async findAtomLibrary({url:$,libRef:Q}){let Z=cQ({url:$});if(!Z)throw Error(`Invalid package name: ${$}`);if(!Z.protocol)Z.protocol=this.#O;if(Z.protocol==="src:"){let X=w.resolve(this.#$.projectSrcDir,`${Z.pathname}.js`),q=[],Y=(await pQ({file:X,recursive:!0})).all;for await(let W of Y){if(W.type!=="npm")continue;if(q.find((_)=>_.package===W.package))continue;let H=await P0({name:W.package,projectDir:this.#$.projectDir,setProgress:this.#V.setProgress});q.push({package:W.package,subpath:W.subpath,version:H.minorRange,type:"npm"})}return{name:Z.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:q},protocol:Z.protocol}}else if(Z.protocol==="npm:"){let X=H1({path:Z.pathname}),q=await P0({name:X.package,subpath:X.subpath,projectDir:this.#$.projectDir,setProgress:this.#V.setProgress});return{name:Z.pathname,doc:{type:"workflow.lib",subtype:Q?.definition?.subtype==="flow"?"workflow":null,"content-type":"javascript",language:"js",dependencies:[{package:X.package,version:q.minorRange,type:"npm"}]},protocol:Z.protocol}}else if(Z.protocol==="use:")return{name:Z.pathname,doc:{type:"function",dependencies:[]},protocol:Z.protocol};else if(Z.protocol==="node:")return{name:Z.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:[]},protocol:Z.protocol};else if(Z.protocol==="ac:"){let X=Z.pathname.split("/");if(X.length===1)return await H0.first({where:{name:$,parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"workflow.lib"}});if(X.length===2){let q=await H0.first({where:{name:X[0],parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"folder"}});return await H0.first({where:{name:X[1],parent_id:q.id,type:"workflow.lib"}})}}}async resolveNodeTree({root:$}){for await(let Q of $.childs)await this.resolveTypeWorkflow({node:Q})}async resolveTypeWorkflow({node:$}){$.context.transform=$.context.transform||G1($.definition);let Q=$.context.transform;for(let Z=0;Z<Q.params?.length;Z++){let X=Q.params[Z];if(typeof X==="string")Q.params[Z]={key:X,hasDefault:!1};else{let q=Object.keys(X)[0];Q.params[Z]={key:q,hasDefault:!0,default:X[q],type:typeof X[q]}}}$.context.next=$.childs[0];for await(let Z of $.childs)await this.resolveType({node:Z})}async resolveType({node:$}){let Q={...this.#I,node:$};if(typeof $.resolve==="function")await $.resolve(Q);for await(let Z of $.childs)await this.resolveType({node:Z})}async resolveTypeCommon({node:$}){let Q=$.context.transform;if(Q.hasOwnProperty("page"))Q.page=await this.transformExpression(Q.page);if(Q.hasOwnProperty("print"))Q.print=await this.transformExpression(Q.print);if(Q.hasOwnProperty("sleep"))Q.sleep=await this.transformExpression(Q.sleep);if(Q.hasOwnProperty("assert"))Q.assert=await this.transformExpression(Q.assert)}async createAtomLibFiles({root:$}){await this.setProgress({message:"Creating external lib files."}),this.#Z.typesDir="./types";let Z=$.context.libs.filter((X)=>X.type==="atom");for(let X=0;X<Z.length;X++){let J=Z[X].atom,Y=this.#$.projectDir;if(J.protocol==="src:"){let V=w.resolve(this.#$.projectSrcDir,`${J.fileName||J.name}.js`),W=w.relative(`${this.#$.projectDir}/src/default/blocks`,V);if(!I.existsSync(V)){I.mkdirSync(w.dirname(V),{recursive:!0});let H=`export default async (input)=>{
|
|
7
|
-
`;H+="}",I.writeFileSync(V,H,"utf8")}J.relativePath=W.split(w.sep).join("/"),this.#Z.typesDir=`./types/${w.basename(Y)}/src`}else if(J.protocol==="npm:")J.relativePath=J.name;else if(J.protocol==="node:")J.relativePath=J.name;else if(J.protocol==="use:");else{let V=`${Y}/src/libs/${J.id}.js`,W=J.doc.contents?.find((H)=>H.format==="esm")||J.doc;I.writeFileSync(w.normalize(V),W.content,"utf8")}}}async createEngine({root:$}){await this.setProgress({message:"Creating engine file."});let Q=this.#$.templateDir,Z=X8.compile(I.readFileSync(w.resolve(Q,"src/default/engine.js.njk"),"utf8"),this.#J);for(let X=0;X<$.childs.length;X++){let q=$.childs[X];if(!q.entryFile)continue;let J=Z.render({flow:q,ui:{package:"@fnet/react-app"}}),Y=this.#$.projectDir,V=w.resolve(Y,`src/default/${q.entryFile}`);I.writeFileSync(V,J,"utf8")}}async createNodeTree({root:$}){await this.setProgress({message:"Creating block files."});for await(let Q of $.childs)await this.createTypeWorkflow({node:Q})}async createTypeWorkflow({node:$}){let Q=this.#$.templateDir,X=X8.compile(I.readFileSync(w.resolve(Q,"src/default/workflow.js.njk"),"utf8"),this.#J).render($),q=this.#$.projectDir,J=w.resolve(q,`src/default/${$.codeKey}.js`);I.writeFileSync(J,X,"utf8");for await(let Y of $.childs)await this.createType({node:Y})}async createType({node:$}){switch($.type){case"assign":case"steps":case"return":case"call":case"new":case"form":case"raise":case"switch":case"next":case"tryexcept":case"for":case"signal":case"wait":case"modules":case"output":this.createBlockFromTemplate({node:$});break;default:break}for await(let Q of $.childs)await this.createType({node:Q})}createBlockFromTemplate({node:$}){let Q=this.getBlockTemplate({node:$});$.context.render=Q.render($),this.createStepFile({node:$})}getBlockTemplate({node:$}){let Q=this.#H[$.type];if(Q)return Q;let Z=this.#$.templateDir;return Q=X8.compile(I.readFileSync(w.resolve(Z,`src/default/blocks/${$.type}.js.njk`),"utf8"),this.#J),this.#H[$.type]=Q,Q}createStepFile({node:$}){let Q=this.#$.projectDir,Z=`${$.codeKey}.js`,X=w.resolve(Q,`src/default/blocks/${Z}`);I.writeFileSync(X,$.context.render,"utf8"),$.context.fileName=Z,$.context.filePath=X}async transformExpression($){let Q=await this.transformValue($);return Q=JSON.stringify(Q),Q=this.replaceSpecialPattern(Q),Q}async transformValue($){if(Array.isArray($))for(let Q=0;Q<$.length;Q++)$[Q]=await this.transformValue($[Q]);else if(lQ($)){let Q=Object.keys($);for(let Z=0;Z<Q.length;Z++){let X=Q[Z],q=U1({expression:X});if(q)if(q.processor==="e"){let J=$[X].replace(/(\r\n|\n|\r)/g,"");$[q.statement]=`$::${J}::`,delete $[X]}else $[X]=await this.transformValue($[X]);else $[X]=await this.transformValue($[X])}}else if(typeof $==="string"){let Q=U1({expression:$});if(Q){let{processor:Z,statement:X}=Q;switch(Z){case"v":$=`$::v.${X}::`;break;case"e":$=`$::${X}::`;break;case"m":$=`$::c.module?.${X}||flow.module?.${X}::`;break;case"f":$=`$::c.form.${X}::`;break;case"for":$=`$::caller.for.${X}::`;break}}}return $}replaceSpecialPattern($){let Q=/"\$::(.*?)::"/g;return $.replace(Q,"$1")}replaceExpressionLegacy($){let Q=/(?<outer>"\${(?<inner>[^{]*)}")/g;return $.replaceAll(Q,"$2")}async createProjectYaml(){await this.setProgress({message:"Creating fnet.yaml"});let{content:Z,...X}=this.#Z.doc,q=this.#$.projectDir,J=w.resolve(q,"fnet.yaml");I.writeFileSync(J,K1.stringify(X),"utf8")}async createProjectMainYaml(){await this.setProgress({message:"Creating flow.main.yaml"});let Z={content:K1.stringify(this.#X)},X=this.#$.templateDir,J=X8.compile(I.readFileSync(w.resolve(X,"flow.main.yaml.njk"),"utf8"),this.#J).render(Z),Y=this.#$.projectDir,V=w.resolve(Y,"flow.main.yaml");I.writeFileSync(V,J,"utf8")}async runPrettifier(){let $=this.#$.projectDir;if(J0("bun")){let Q=await _1("prettier --write .",{cwd:w.resolve($,"src")});if(Q.code!==0)throw Error(Q.stderr)}else{let Q=await _1("prettier --write .",{cwd:w.resolve($,"src")});if(Q.code!==0)throw Error(Q.stderr)}}async deploy(){if(await this.setProgress({message:"Deploying."}),this.#$.project?.devops){let $=[this.#$.project?.devops];for(let Q=0;Q<$.length;Q++){let Z=$[Q];if(await this.deployProject({deploymentProject:Z}),Z.isDirty===!0)await Z.save()}}else if(this.#Z.id){let $=await H0.list({type:"workflow.deploy",parent_id:this.#Z.id});for(let Q=0;Q<$.length;Q++){let Z=$[Q];if(await this.deployProject({deploymentProject:Z}),Z.isDirty===!0)Z=await H0.update(Z,{id:Z.id})}}}async deployProject($){let{deploymentProject:Q}=$,{yamlDocument:Z}=Q;if(Q.doc.targets&&Array.isArray(Q.doc.targets))throw Error("Deployment project targets are deprecated. Please update targets in the yaml file.");let X=Object.keys(Q.doc||{}),q=Z||{};for(let J=0;J<X.length;J++){let Y=Q.doc[X[J]];Y.name=X[J];let V=q.get(X[J]);await x6({...this.#V,deploymentProject:Q,deploymentProjectTarget:Y,yamlTarget:V})}}async registerToPackageManager($){let{target:Q,packageJSON:Z}=$;if(!this.#$.id)return;let X=await H0.first({name:Q.params.name,parent_id:this.#M.env.ATOM_PACKAGES_ID});if(!X)X=await H0.create({parent_id:this.#M.env.ATOM_PACKAGES_ID,doc:{name:Q.params.name,type:"pm",versions:[{v:Z.version}]}});else X.doc.versions.splice(0,0,{v:Z.version}),await H0.update(X,{id:X.id})}async setProgress($){let Q=typeof $==="string"?$:$?.message;console.log(nQ.blue(Q)),await this._cache_set(this.#q,{status:"IN_PROGRESS",message:Q})}async build(){if(this.#F&&!this.#A)return await this.createNetwork();try{let $=this.#F?await K8({root:this.#W}):void 0;if(this.#A){let Q=this.#V.context.project;if(await this.initWorkflowDir(),await this.initNunjucks(),this.#F){let Z=this.#$.project?.projectDir||this.#$.projectDir;if(Z=w.resolve(Z,"fnet"),I.existsSync(Z)){if(I.existsSync(w.resolve(Z,"flow.bpmn")))I.unlinkSync(w.resolve(Z,"flow.bpmn"));I.writeFileSync(w.resolve(Z,"flows.bpmn"),$.diagramXML,"utf8")}}if(await this.createAtomLibFiles({root:this.#W}),await this.createEngine({root:this.#W}),await this.createNodeTree({root:this.#W}),await this.createProjectYaml(),await A$(this.#V),await O$(this.#V),await M$(this.#V),await U$(this.#V),await Y$(this.#V),await q$(this.#V),Q.runtime.type==="bun")await _$(this.#V);else await H$(this.#V);if(await J$(this.#V),await L$(this.#V),await B$(this.#V),this.#T){if(await R$(this.#V),await C$(this.#V),this.#B)await this.deploy()}}await this._cache_set(this.#q,{status:"COMPLETED",data:{network:$}})}catch($){throw await this._cache_set(this.#q,{status:"FAILED",message:$.message||$}),$}}async createNetwork(){try{let $=await K8({root:this.#W});await this._cache_set(this.#q,{status:"COMPLETED",data:{...$}})}catch($){throw await this._cache_set(this.#q,{status:"FAILED",message:$.message||$}),$}}}var R0=M1;var rQ={command:"build",describe:"Build flownet project",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"],describe:"Build mode"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("dev",{type:"boolean",default:!1,describe:"Development mode"})},handler:async($)=>{try{let Q=await j($),Z=new R0(Q);await Z.init(),await Z.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Q){console.error("Building workflow failed!",Q.message),process.exit(1)}}},O1=rQ;var sQ={command:"build:dev",describe:"Build flownet project",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"],describe:"Build mode"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("dev",{type:"boolean",default:!1,describe:"Development mode"})},handler:async($)=>{try{$.dev=!0;let Q=await j($),Z=new R0(Q);await Z.init(),await Z.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Q){console.error("Building workflow failed!",Q.message),process.exit(1)}}},A1=sQ;var oQ={command:"deploy",describe:"Build and deploy flownet project",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"})},handler:async($)=>{try{let Q=await j({...$,mode:"all"}),Z=new R0(Q);await Z.init(),await Z.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Q){console.error("Building workflow failed!",Q.message),process.exit(1)}}},L1=oQ;var aQ={command:"file",describe:"Just create files",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"})},handler:async($)=>{try{let Q=await j({...$,mode:"file"}),Z=new R0(Q);await Z.init(),await Z.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Q){console.error("Building workflow failed!",Q.message),process.exit(1)}}},B1=aQ;import R1 from"path";import b8 from"fs";import tQ from"@fnet/prompt";var eQ={command:"input [name]",describe:"Create or modify an input config file",builder:($)=>{return $.positional("name",{type:"string",demandOption:!1,describe:"Input name"})},handler:async($)=>{try{let Q=await j($),{project:Z}=Q,{projectDir:X,projectFileParsed:q}=Z,J=q.input;if(!J)throw Error("Config schema not found in project file.");if(!Reflect.has($,"name")){let{inputName:K}=await tQ({type:"input",name:"inputName",message:"Input name:",initial:"dev"});$.name=K}let Y=R1.resolve(X,".fnet");if(!b8.existsSync(Y))b8.mkdirSync(Y);let V=R1.resolve(Y,`${$.name}.fnet`),W=b8.existsSync(V),H=(await import("@fnet/object-from-schema")).default,_=await H({schema:J,format:"yaml",ref:W?V:void 0});b8.writeFileSync(V,_)}catch(Q){console.error(Q.message),process.exit(1)}}},C1=eQ;import F from"path";import C from"fs";import E8 from"os";import{spawn as k8}from"child_process";import B from"chalk";import M0 from"@fnet/prompt";import P8 from"chalk";import I1 from"@fnet/prompt";async function $2($){let{items:Q,message:Z,nameField:X="name",valueField:q="name",initialValue:J=null,allowAbort:Y=!0}=$;if(!Q||Q.length===0)return console.log(P8.yellow("No items available for selection.")),null;if(Q.length===1&&!Y){let K=Q[0],G=typeof K==="string"?K:K[q];return console.log(P8.blue(`Only one option available: ${typeof K==="string"?K:K[X]}`)),G}let V=Q.map((K)=>{if(typeof K==="string")return{name:K,value:K,message:K};else return{name:K[q],value:K[q],message:K[X]||K[q]}});if(Y)V.push({name:"cancel",value:null,message:P8.yellow("Cancel")});let W=null;if(J){let K=V.findIndex((G)=>G.name===J);if(K!==-1)W=K}let H="selectedItem",{[H]:_}=await I1({type:"select",name:H,message:Z,choices:V,initial:W});if(_==="cancel")return null;return _}async function Q2($){let{items:Q,message:Z,nameField:X="name",valueField:q="name",initialValues:J=[],allowAbort:Y=!0}=$;if(!Q||Q.length===0)return console.log(P8.yellow("No items available for selection.")),null;let V=Q.map((K)=>{if(typeof K==="string")return{name:K,value:K,message:K};else return{name:K[q],value:K[q],message:K[X]||K[q]}}),W=[];if(J&&J.length>0)W=V.map((K,G)=>J.includes(K.name)?G:-1).filter((K)=>K!==-1);let H="selectedItems",_=await I1({type:"multiselect",name:H,message:Z,choices:V,initial:W,hint:"(Use space to select, enter to confirm)",validate:(K)=>{if(K.length===0&&!Y)return"Please select at least one item";return!0}});if(Y&&_[H].length===0)return null;return _[H]}var q6={promptForSelection:$2,promptForMultipleSelection:Q2};var k=F.join(E8.homedir(),".fnet","express");async function T1($){$.command(["$0 [project-name]","create [project-name]"],"Create a new express project",(Q)=>{return Q.positional("project-name",{describe:"Name of the project",type:"string"}).option("yes",{alias:"y",describe:"Skip all prompts and use defaults",type:"boolean",default:!1}).option("runtime",{describe:"Runtime to use (node)",type:"string",choices:["node"],default:"node"})},async(Q)=>{await Z2(Q)}).command("list","List express projects",(Q)=>{return Q.option("today",{describe:"Show only projects created today",type:"boolean",default:!1}).option("type",{describe:"Filter by project type (fnode or fnet)",type:"string",choices:["fnode","fnet"]}).option("all",{describe:"Show all projects regardless of type",type:"boolean",default:!1,alias:"a"}).option("name",{describe:"Filter by project name",type:"string"})},async(Q)=>{await X2(Q)}).command("open [project-name]","Open an express project",(Q)=>{return Q.positional("project-name",{describe:"Name of the project to open",type:"string"}).option("latest",{describe:"Open the most recent project",type:"boolean",default:!1})},async(Q)=>{await q2(Q)}).command("move [project-name] [destination]","Move an express project to a real project location",(Q)=>{return Q.positional("project-name",{describe:"Name of the project to move",type:"string"}).positional("destination",{describe:"Destination directory",type:"string"}).option("latest",{describe:"Move the most recent project",type:"boolean",default:!1})},async(Q)=>{await J2(Q)}).command("remove [project-name]","Remove an express project",(Q)=>{return Q.positional("project-name",{describe:"Name of the project to remove",type:"string"}).option("latest",{describe:"Remove the most recent project",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Skip confirmation prompt",type:"boolean",default:!1})},async(Q)=>{await V2(Q)}).command("enter [project-name]","Enter the directory of an express project in the active terminal",(Q)=>{return Q.positional("project-name",{describe:"Name of the project to enter",type:"string"}).option("latest",{describe:"Enter the most recent project directory",type:"boolean",default:!1})},async(Q)=>{await W2(Q)}).demandCommand(1,"You need to specify a command").help()}async function Z2($){try{if(!C.existsSync(k))C.mkdirSync(k,{recursive:!0});let Q=new Date().toISOString().slice(0,10).replace(/-/g,""),Z=F.join(k,Q);if(!C.existsSync(Z))C.mkdirSync(Z,{recursive:!0});let X=$.projectName,q,J=$.runtime;if(!$.yes){if(!X){let G=C.readdirSync(Z).filter((U)=>U.startsWith("fnet-")).map((U)=>parseInt(U.replace("fnet-",""),10)).filter((U)=>!isNaN(U)),O=`fnet-${G.length>0?Math.max(...G)+1:1}`;X=(await M0([{type:"input",name:"projectName",message:"Enter project name:",default:O}])).projectName}J=(await M0({type:"select",name:"runtime",message:"Select runtime:",choices:["node"],initial:J||"node"})).runtime}else{if(!X){let _=C.readdirSync(Z).filter((G)=>G.startsWith("fnet-")).map((G)=>parseInt(G.replace("fnet-",""),10)).filter((G)=>!isNaN(G));X=`fnet-${_.length>0?Math.max(..._)+1:1}`}if(!J)J="node"}if(q=F.join(Z,X),C.existsSync(q)){let _=1;while(C.existsSync(F.join(Z,`${X}-${_}`)))_++;X=`${X}-${_}`,q=F.join(Z,X)}if(!$.yes){if(!(await M0([{type:"confirm",name:"proceed",message:`Create express project "${X}" in ${q}?`,default:!0}])).proceed){console.log(B.yellow("Project creation cancelled."));return}}console.log(B.blue(`Creating express project "${X}" in ${q}...`));let Y=F.dirname(q),W=["create","--name",F.basename(q)];if(W.push("--runtime",J),$.yes)W.push("--yes");if(!C.existsSync(Y))C.mkdirSync(Y,{recursive:!0});let H=k8("fnet",W,{stdio:"inherit",shell:!0,cwd:Y});return new Promise((_,K)=>{H.on("close",(G)=>{if(G===0)if(console.log(B.green(`
|
|
3
|
+
import{a as K0,b as J0}from"./index.qt2n23jk.js";import{c as N,d as i6,e as P}from"./index.aqy4k3s3.js";var o6=i6((_3,s6)=>{s6.exports=n6;function n6($,Q,Z){if($ instanceof RegExp)$=p6($,Z);if(Q instanceof RegExp)Q=p6(Q,Z);var X=r6($,Q,Z);return X&&{start:X[0],end:X[1],pre:Z.slice(0,X[0]),body:Z.slice(X[0]+$.length,X[1]),post:Z.slice(X[1]+Q.length)}}function p6($,Q){var Z=Q.match($);return Z?Z[0]:null}n6.range=r6;function r6($,Q,Z){var X,q,J,Y,V,W=Z.indexOf($),H=Z.indexOf(Q,W+1),K=W;if(W>=0&&H>0){if($===Q)return[W,H];X=[],J=Z.length;while(K>=0&&!V){if(K==W)X.push(K),W=Z.indexOf($,K+1);else if(X.length==1)V=[X.pop(),H];else{if(q=X.pop(),q<J)J=q,Y=H;H=Z.indexOf(Q,K+1)}K=W<H&&W>=0?W:H}if(X.length)V=[J,Y]}return V}});var q5=i6((G3,X5)=>{var a6=o6();X5.exports=I7;var t6="\x00SLASH"+Math.random()+"\x00",e6="\x00OPEN"+Math.random()+"\x00",b$="\x00CLOSE"+Math.random()+"\x00",$5="\x00COMMA"+Math.random()+"\x00",Q5="\x00PERIOD"+Math.random()+"\x00";function S$($){return parseInt($,10)==$?parseInt($,10):$.charCodeAt(0)}function R7($){return $.split("\\\\").join(t6).split("\\{").join(e6).split("\\}").join(b$).split("\\,").join($5).split("\\.").join(Q5)}function C7($){return $.split(t6).join("\\").split(e6).join("{").split(b$).join("}").split($5).join(",").split(Q5).join(".")}function Z5($){if(!$)return[""];var Q=[],Z=a6("{","}",$);if(!Z)return $.split(",");var{pre:X,body:q,post:J}=Z,Y=X.split(",");Y[Y.length-1]+="{"+q+"}";var V=Z5(J);if(J.length)Y[Y.length-1]+=V.shift(),Y.push.apply(Y,V);return Q.push.apply(Q,Y),Q}function I7($){if(!$)return[];if($.substr(0,2)==="{}")$="\\{\\}"+$.substr(2);return g0(R7($),!0).map(C7)}function F7($){return"{"+$+"}"}function T7($){return/^-?0\d/.test($)}function j7($,Q){return $<=Q}function w7($,Q){return $>=Q}function g0($,Q){var Z=[],X=a6("{","}",$);if(!X)return[$];var q=X.pre,J=X.post.length?g0(X.post,!1):[""];if(/\$$/.test(X.pre))for(var Y=0;Y<J.length;Y++){var V=q+"{"+X.body+"}"+J[Y];Z.push(V)}else{var W=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(X.body),H=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(X.body),K=W||H,_=X.body.indexOf(",")>=0;if(!K&&!_){if(X.post.match(/,.*\}/))return $=X.pre+"{"+X.body+b$+X.post,g0($);return[$]}var G;if(K)G=X.body.split(/\.\./);else if(G=Z5(X.body),G.length===1){if(G=g0(G[0],!1).map(F7),G.length===1)return J.map(function(y1){return X.pre+G[0]+y1})}var M;if(K){var O=S$(G[0]),z=S$(G[1]),U=Math.max(G[0].length,G[1].length),A=G.length==3?Math.abs(S$(G[2])):1,L=j7,R=z<O;if(R)A*=-1,L=w7;var T=G.some(T7);M=[];for(var l=O;L(l,z);l+=A){var y;if(H){if(y=String.fromCharCode(l),y==="\\")y=""}else if(y=String(l),T){var t=U-y.length;if(t>0){var S0=Array(t+1).join("0");if(l<0)y="-"+S0+y.slice(1);else y=S0+y}}M.push(y)}}else{M=[];for(var e=0;e<G.length;e++)M.push.apply(M,g0(G[e],!1))}for(var e=0;e<M.length;e++)for(var Y=0;Y<J.length;Y++){var V=q+M[e]+J[Y];if(!Q||K||V)Z.push(V)}}return Z}});import A2 from"yargs";import D1 from"chalk";import{promisify as v1}from"util";import x1 from"tree-kill";var K6=v1(x1),C0=!1;async function u8($,Q){if(C0)return;if(C0=!0,!$.killed&&$.pid)try{if(await K6($.pid,"SIGTERM").catch(()=>{}),await new Promise((X)=>setTimeout(X,500)),!$.killed)await K6($.pid,"SIGKILL").catch(()=>{})}catch(X){}await new Promise((X)=>setTimeout(X,100));let Z=Q==="SIGINT"?130:Q==="SIGTERM"?143:1;process.exit(Z)}function f8($){["SIGINT","SIGTERM","SIGQUIT"].forEach((Q)=>{process.once(Q,async()=>{await u8($,Q)})}),process.on("uncaughtException",async(Q)=>{await u8($)}),process.on("unhandledRejection",async(Q)=>{await u8($)}),$.on("close",(Q)=>{if(!C0)process.exit(Q)})}function _6(){process.on("uncaughtException",($)=>{if(!C0)C0=!0,setTimeout(()=>process.exit(1),500)}),process.on("unhandledRejection",($)=>{if(!C0)C0=!0,setTimeout(()=>process.exit(1),500)})}import f0 from"path";import{spawn as G6}from"child_process";import J8 from"fs";import u0 from"chalk";import u1 from"@fnet/config";function m($,{name:Q,bin:Z,preArgs:X=[],createContext:q}){if(typeof Z==="function")Z=Z();return $.command(`${Q||Z} [commands..]`,`${Z} ${X.join(" ")}`,(J)=>{return J.help(!1).version(!1)},async(J)=>{try{let Y=await q(J),{projectDir:V}=Y,W=(O)=>{if(!O.includes(" "))return O;if(process.platform==="win32")return`"${O.replace(/(["^])/g,"^$1")}"`;else return`"${O.replace(/(["\\$`])/g,"\\$1")}"`},H=process.argv.slice(3).map(W),K={...process.env},_=f0.join(V,"node_modules");K.NODE_PATH=_;let G=K.NODE_OPTIONS||"";K.NODE_OPTIONS=`${G} --preserve-symlinks`.trim();let M=G6(Z,[...X,...H],{cwd:V,stdio:"inherit",shell:!0,detached:!0,env:K});f8(M)}catch(Y){console.error(Y.message),process.exit(1)}})}function z6($,{name:Q,preArgs:Z=[],createContext:X}){return $.command(`${Q} <config> <command> [options..]`,"Run a command with a config context",(q)=>{return q.positional("config",{type:"string"}).positional("command",{type:"string"}).help(!1).version(!1)},async(q)=>{try{let J=await X(q),{projectDir:Y}=J,V=q.config,H=(await u1({name:V,dir:Y,transferEnv:!1,optional:!0,tags:J.tags}))?.data?.env||void 0,K=q.command,_=process.argv.slice(5),G=G6(K,[...Z,..._],{cwd:J8.existsSync(Y)?Y:process.cwd(),stdio:"inherit",shell:!0,detached:!0,env:{...process.env,...H}});f8(G)}catch(J){console.error(J.message),process.exit(1)}})}function U6($,{name:Q,projectType:Z="auto"}){return $.command(`${Q} group [options..]`,"Run a command group.",(X)=>{return X.positional("group",{type:"string"}).option("ftag",{type:"array"}).help(!1).version(!1)},async(X)=>{try{let{runCommandGroup:q}=await import("./index.44a1c2n0.js");await q({projectType:Z,group:X.group,tags:X.ftag,args:X,argv:process.argv})}catch(q){console.error(q.message),process.exit(1)}})}function M6($,{name:Q,createContext:Z}){return $.command(`${Q} [options]`,"Install the project as a binary",(X)=>{return X.option("name",{alias:"n",describe:"Name to use for the installed binary",type:"string"}).option("force",{alias:"f",describe:"Force overwrite if binary already exists",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Automatically answer yes to all prompts",type:"boolean",default:!1})},async(X)=>{try{let q=await Z(X),{projectDir:J}=q;console.log(u0.blue("Compiling project..."));let Y=f0.join(J,".bin");if(!J8.existsSync(Y))J8.mkdirSync(Y,{recursive:!0});let V=f0.basename(f0.dirname(J)),W=q.project?.projectFileParsed?.features?.cli?.bin,H=X.name||W||V;console.log(u0.blue(`Using binary name: ${H}`));let K=f0.join(Y,H),{spawn:_}=await import("child_process"),G=_("bun",["build","./dist/cli/esm/index.js","--compile",`--outfile=${K}`],{cwd:J,stdio:"inherit",shell:!0});if(await new Promise((z,U)=>{G.on("close",(A)=>{if(A===0)z();else U(Error(`Compilation failed with code ${A}`))}),G.on("error",(A)=>{U(A)})}),process.platform!=="win32")J8.chmodSync(K,493);console.log(u0.green(`Binary compiled successfully: ${K}`)),console.log(u0.blue("Installing binary..."));let M=["install",K];if(X.name)M.push("--name",X.name);if(X.force)M.push("--force");if(X.yes)M.push("--yes");let O=_("fbin",M,{stdio:"inherit",shell:!0});await new Promise((z,U)=>{O.on("close",(A)=>{if(A===0)z();else U(Error(`Installation failed with code ${A}`))}),O.on("error",(A)=>{U(A)})})}catch(q){console.error(u0.red(`Failed to install binary: ${q.message}`)),process.exit(1)}})}import q0 from"path";import I0 from"fs";import g8 from"@fnet/yaml";import f1 from"yaml";async function w($){if($.id)return{id:$.id,buildId:$.buildId,mode:$.mode,protocol:$.protocol||"ac:",templateDir:K0("./template/fnet/node"),coreDir:K0("./template/fnet/core"),projectDir:q0.resolve(process.cwd(),`./.output/${$.id}`),tags:$.ftag,dev:$.dev};else try{let Q=await g1({tags:$.ftag});return{buildId:$.buildId,mode:$.mode,protocol:$.protocol||"src:",templateDir:K0("./template/fnet/node"),coreDir:K0("./template/fnet/core"),projectDir:q0.resolve(Q.projectDir,"./.workspace"),projectSrcDir:q0.resolve(Q.projectDir,"./src"),project:Q,tags:$.ftag,dev:$.dev}}catch(Q){return console.warn(`Warning: Could not load project: ${Q.message}`),{projectDir:process.cwd(),tags:$.ftag}}}async function g1({tags:$}){let Q=h1(process.cwd());if(!I0.existsSync(Q))throw Error("fnet.yaml file not found in current directory.");let{raw:Z,parsed:X}=await g8({file:Q,tags:$}),q=q0.dirname(Q);X.features=X.features||{};let J=X.features;J.runtime=J.runtime||{},J.runtime.type=J.runtime.type||"node";let Y;if(typeof X.flows==="object")Y=X.flows;else{let _="flow.main.yaml";if(I0.existsSync(q0.join(q,"fnet","flows.yaml")))_=q0.join("fnet","flows.yaml");let G=X.main||_,M=q0.resolve(q,G);if(!I0.existsSync(M))Y={main:{steps:[]}};else{let{parsed:O}=await g8({file:M,tags:$});Y=O}}let W={workflowAtom:{doc:{...X,content:Y}},projectDir:q,projectFilePath:Q,projectFileContent:Z,projectFileParsed:X,runtime:J.runtime},H=q0.resolve(q,"fnet/targets.yaml");if(I0.existsSync(H)){let{raw:_,parsed:G}=await g8({file:H,tags:$}),M=f1.parseDocument(_);W.devops={filePath:H,fileContent:_,yamlDocument:M,doc:{...G},type:"workflow.deploy",save:async()=>{I0.writeFileSync(W.devops.filePath,M.toString())}}}let K=q0.resolve(q,"readme.md");if(I0.existsSync(K)){let _=I0.readFileSync(K,"utf8");W.readme={filePath:K,fileContent:_,doc:{content:_,"content-type":"markdown"},type:"wiki"}}return W}function h1($){return q0.resolve($,"fnet.yaml")}import m1 from"path";import O6 from"fs";import c1 from"os";import l1 from"@flownet/lib-render-templates-dir";import h8 from"@fnet/shelljs";var d1={command:"create",describe:"Initialize a new fnet project",builder:($)=>{return $.option("name",{type:"string",describe:"Project name"}).option("vscode",{type:"boolean",default:!0,alias:"vs",describe:"Open in VS Code after creation"}).option("runtime",{type:"string",default:"node",choices:["node"],describe:"Runtime environment"})},handler:async($)=>{try{let Q=process.cwd(),Z=K0("./template/fnet/project"),X=m1.resolve(Q,$.name);if(!O6.existsSync(X))O6.mkdirSync(X);await l1({dir:Z,outDir:X,context:$,copyUnmatchedAlso:!0,platform:c1.platform()});let q=await h8("fnet build",{cwd:X});if(q.code!==0)throw Error("Failed to build project.");if(J0("git")){if(q=await h8("git init --initial-branch=main",{cwd:X}),q.code!==0)throw Error("Failed to initialize git.")}if(J0("code")&&$.vscode){if(q=await h8(`cd ${X} && code .`),q.code!==0)throw Error("Failed to open vscode.")}console.log("Creating project succeeded!"),process.exit(0)}catch(Q){console.error("Initialization failed!",Q.message),process.exit(1)}}},A6=d1;import p1 from"os";import i1 from"@flownet/lib-render-templates-dir";import n1 from"@fnet/shelljs";var r1={command:"project",describe:"Manage fnet project",builder:($)=>{return $.option("update",{type:"boolean",default:!1,alias:"-u",describe:"Update project files"})},handler:async($)=>{try{let Q=K0("./template/fnet/project"),Z=process.cwd(),X=await w($);if($.update){if(await i1({dir:Q,outDir:Z,context:{name:X.project.projectFileParsed.name,runtime:"node"},copyUnmatchedAlso:!0,platform:p1.platform()}),(await n1("fnet build",{cwd:Z})).code!==0)throw Error("Failed to build project.");console.log("Updating project succeeded!")}process.exit(0)}catch(Q){console.error("Project failed.",Q.message),process.exit(1)}}},L6=r1;import I from"fs";import j from"path";import U1 from"yaml";import M1 from"@fnet/shelljs";import q8 from"nunjucks";import O1 from"lodash.clonedeep";import dQ from"isobject";import{randomUUID as A1}from"crypto";import{Api as Y8}from"@flownet/lib-atom-api-js";class B6{init({config:$,accessToken:Q}){return new Promise((Z,X)=>{if(Y8.set_api_url($.data.url),Q){Y8.set_req_token(Q),Z(Q);return}fetch(`${$.data.issuer}/protocol/openid-connect/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams($.data.grant.params)}).then(async(q)=>{if(!q.ok)throw Error(await q.text());return q.json()}).then((q)=>{Y8.set_req_token(q.access_token),Z(q.access_token)}).catch((q)=>{Y8.set_req_token(),X(q)})})}}import b0 from"lodash.merge";import V8 from"fs";import $0 from"path";import N0 from"@flownet/lib-parse-imports-js";import s1 from"lodash.merge";function S({feature:$,features:Q,packageDevDependencies:Z}){let{name:X,packages:q,options:J,extraCheck:Y,explicit:V}=$,W=`${X}_enabled`,H=Q.rollup_output||{},K=Object.keys(H),_=J||{},G=Q[X]?.options;if(G)_=s1(_,G);let M=!Q[X]||Q[X]?.enabled===!1;K.forEach((z)=>{let U=Q.rollup_output[z];if(!U)return;if(Reflect.has(U,X)){if(M||!U[X]||U[X]?.enabled===!1){delete U[X];return}if(U[X]===!0)U[X]={enabled:!0,options:_}}else if(!M&&!V&&Q[W]!==!1)U[X]={enabled:!0};else return;U[X]=U[X]||{},U[X].options={..._,...U[X].options}});let O=K.some((z)=>Q.rollup_output[z][X]?.enabled===!0);if(Y)O=Y()&&O;if(Q[W]=O,O)q.forEach((z)=>Z.push({package:z[0],version:z[1]}))}function m8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"workbox",packages:[["rollup-plugin-workbox","^8"]],options:{generate:{swDest:"dist/app/esm/sw.js",globDirectory:"dist/app/esm",globPatterns:["**/*.{html,js,css,png,jpg}"],skipWaiting:!0,clientsClaim:!0}},explicit:!0},features:X,packageDevDependencies:Z})}function c8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"gzip",packages:[["rollup-plugin-gzip","^4"]],explicit:!0},features:X,packageDevDependencies:Z})}function l8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"nunjucks",packages:[["@fnet/rollup-plugin-nunjucks","0.1.8"]]},features:X,packageDevDependencies:Z})}function d8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"polyfill",packages:[["rollup-plugin-node-polyfills","^0.2"]]},features:X,packageDevDependencies:Z})}function p8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"visualizer",packages:[["rollup-plugin-visualizer","^5"]],expilicit:!0},features:X,packageDevDependencies:Z})}function i8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"analyzer",packages:[["rollup-plugin-analyzer","^3"]],options:{summaryOnly:!0,limit:12},explicit:!0},features:X,packageDevDependencies:Z})}function n8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"string",packages:[["rollup-plugin-string","^3"]]},features:X,packageDevDependencies:Z})}function r8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"image",packages:[["@rollup/plugin-image","^3"]]},features:X,packageDevDependencies:Z})}function s8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;if(X.runtime.type==="bun")return;S({feature:{name:"json",packages:[["@rollup/plugin-json","^6"]]},features:X,packageDevDependencies:Z})}function o8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"terser",packages:[["@rollup/plugin-terser","^0.4"]]},features:X,packageDevDependencies:Z})}function a8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;S({feature:{name:"wasm",packages:[["@rollup/plugin-wasm","^6"]]},features:X,packageDevDependencies:Z})}function t8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features;if(X.runtime.type==="bun")return;let q={};if(X.app?.enabled===!0){if(q.targets=q.targets||[],q.targets.push({src:"./src/app/index.html",dest:X.app.dir}),!Reflect.has(X.app,"copy")){if(!Reflect.has(X,"copy"))X.copy=!0}}S({feature:{name:"copy",packages:[["rollup-plugin-copy","^3"],["chokidar","^3"]],options:q},features:X,packageDevDependencies:Z})}function e8($){let{atom:Q,packageDevDependencies:Z}=$,X=Q.doc.features,q=X.css&&X.css.enabled!==!1,J=[];if(q)J.push(["rollup-plugin-postcss","^4"]),J.push(["sass","^1.66"]),(X.css?.options?.plugins||[]).forEach((V)=>{switch(V.name){case"postcss-import":J.push(["postcss-import","^15"]);break;case"postcss-url":J.push(["postcss-url","^10"]);break;case"postcss-preset-env":J.push(["postcss-preset-env","^9"]);break;case"autoprefixer":J.push(["autoprefixer","^10"]);break;case"cssnano":J.push(["cssnano","^6"]);break}});S({feature:{name:"css",packages:J},features:X,packageDevDependencies:Z})}function $$({dir:$,name:Q="index"}){let Z=$0.resolve($,`./${Q}.tsx`);if(!V8.existsSync(Z))Z=$0.resolve($,`./${Q}.ts`);if(!V8.existsSync(Z))Z=$0.resolve($,`./${Q}.jsx`);if(!V8.existsSync(Z))Z=$0.resolve($,`./${Q}.js`);if(!V8.existsSync(Z))return{};let X=Z,q=$0.extname(Z);return{file:X,ext:q,ts:q===".ts"||q===".tsx",name:Q}}async function Q$($){let{atom:Q,context:Z,setProgress:X}=$;X("Initializing features..."),Q.doc.features=Q.doc.features||{};let q=Q.doc.features;q.project=q.project||{},q.project.format=q.project.format||q.project_format||"esm",q.project_format=q.project.format,q.dts_enabled=q.dts===!0||typeof q.dts<"u"&&q.dts!==!1;let J=$0.resolve(Z.project.projectDir),Y=$$({dir:$0.resolve(J,"./app")});if(Y.file){X("Parsing app entry imports...");let z=await N0({file:Y.file,recursive:!0}),U=z.all.some((A)=>A.usesJSX===!0&&A.type==="local");q.app_uses_jsx=U,q.app_has_entry=!0,z=await N0({file:Y.file}),U=z.all.some((A)=>A.usesJSX===!0&&A.type==="local"),q.app_entry_uses_jsx=U,q.app_entry_is_ts=Y.ts,q.app_entry_ext=Y.ext}let V=$$({dir:$0.resolve(J,"./cli")});if(V.file){X("Parsing cli entry imports...");let z=await N0({file:V.file,recursive:!0}),U=z.all.some((A)=>A.usesJSX===!0&&A.type==="local");q.cli_uses_jsx=U,q.cli_has_entry=!0,z=await N0({file:V.file}),U=z.all.some((A)=>A.usesJSX===!0&&A.type==="local"),q.cli_entry_uses_jsx=U,q.cli_entry_is_ts=V.ts,q.cli_entry_ext=V.ext}if(Q.type==="workflow.lib"){let z=$$({dir:$0.resolve(J,"./src")});if(z.file){X("Parsing src entry imports...");let U=await N0({file:z.file,recursive:!0}),A=U.all.some((L)=>L.usesJSX===!0&&L.type==="local");q.src_uses_jsx=A,q.src_has_entry=!0,U=await N0({file:z.file}),A=U.all.some((L)=>L.usesJSX===!0&&L.type==="local"),q.src_entry_uses_jsx=A,q.src_entry_is_ts=z.ts,q.src_entry_ext=z.ext}}let W=Reflect.has(q,"app_entry_uses_jsx")?q.app_entry_uses_jsx===!0:q.src_entry_uses_jsx===!0,H=Reflect.has(q,"cli_entry_uses_jsx")?q.cli_entry_uses_jsx===!0:q.src_entry_uses_jsx===!0;if(q.form_enabled=W||H||q.form===!0||q.form?.enabled===!0,q.multiple_enabled=q.multiple_enabled||q.multiple===!0||q.multiple?.enabled===!0,q.app===!1)q.app={enabled:!1};else if(q.app===!0)q.app={enabled:!0,extend:q.app_has_entry===!0,export:!0,react:W};else q.app={enabled:!0,extend:q.app_has_entry===!0,export:!0,react:W,...q.app||{}};if(q.app.enabled=q.app.enabled===!0&&(Q.doc.features.form_enabled===!0||q.app.extend===!0||q.app.enabled===!0),q.app.format=q.app.format||"esm",q.app.folder=q.app.folder||q.app.format||"default",q.cli===!1)q.cli={enabled:!1};else if(q.cli===!0)q.cli={enabled:!0,extend:q.cli_has_entry===!0,export:!0,react:H};else q.cli={enabled:!0,extend:q.cli_has_entry===!0,export:!0,react:H,...q.cli||{}};if(q.cli.enabled=q.cli.enabled===!0&&(Q.doc.features.form_enabled===!1||q.cli.extend===!0||q.cli.enabled===!0),q.cli.format=q.cli.format||"esm",q.cli.folder=q.cli.folder||q.cli.folder||"esm",q.cli.node_options=q.cli.node?.options||q.cli.node_options||"",q.cli.bin=q.cli.bin||Q.doc.name,q.cli.installable=q.cli.installable===!0,q.cli.enabled)Q.doc["npm::bin"]=q.cli.bin;q.json=q.cli.enabled||q.json;let K={cjs:{format:"cjs",context:q.form_enabled?"window":"global",babel:q.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!0,enabled:q.cjs!==!1,copy:!1},esm:{format:"esm",context:q.form_enabled?"window":"global",babel:q.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!1,enabled:q.esm!==!1,copy:!0},iife:{format:"iife",context:q.form_enabled?"window":"global",babel:!0,browser:!0,replace:!0,enabled:q.iife===!0,terser:!0,copy:!1}},_={targets:{browsers:"last 9 versions, not dead",node:"18"}},G={};if(q.webos===!0)K.webos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,input:"./src/app/index.js",output_dir:"./dist/app/webos",copy:!1,babel_options:{targets:{chrome:"79"}}};if(q.electron===!0)K.electron={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/electron"};if(q.nextjs===!0)K.nextjs={format:"esm",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/nextjs"};if(q.ios===!0)K.ios={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/ios"};if(q.macos===!0)K.macos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/macos"};if(q.app.enabled===!0)q.app.dir=`./dist/app/${q.app.folder}`,q.app.output={file:`./dist/app/${q.app.folder}/index.js`,dir:`./dist/app/${q.app.folder}/`,...q.app.output||{}},q.app.input={file:"./src/app/index.js",dir:"./src/app/",...q.app.input||{}},K.app={format:q.app.format,browser:!0,babel:!0,context:"window",replace:!0,input:q.app.input.file,output_dir:q.app.dir,terser:!0,output_exports:q.app.export===!1?"none":"auto",browsersync:!0};if(q.cli.enabled===!0)q.cli.dir=`./dist/cli/${q.cli.folder}`,q.cli.output={file:`./dist/cli/${q.cli.folder}/index.js`,dir:`./dist/cli/${q.cli.folder}/`,...q.cli.output||{}},q.cli.input={file:"./src/cli/index.js",dir:"./src/cli/",...q.cli.input||{}},K.cli={format:q.cli.format,context:"global",babel:q.src_uses_jsx===!0||q.cli_uses_jsx===!0||!1,browser:!1,replace:!0,enabled:!0,input:q.cli.input.file,output_dir:q.cli.dir,banner:"#!/usr/bin/env bun",terser:!0,output_exports:q.cli.export===!1?"none":"auto"};let M={server:".",startPath:`${$0.normalize(q.app.dir||".")}`,files:[$0.normalize("./dist/**/*")],cors:!0,open:!1};if(q.babel_options=b0(_,q.babel_options||q.babel?.options),q.browsersync_options=b0(M,q.browsersync_options||q.browsersync?.options||{}),q.replace_options=b0(G,q.replace_options||q.replace?.options||{}),Reflect.has(q.browsersync_options,"proxy"))delete q.browsersync_options.server;q.rollup=q.rollup||{},q.rollup_output=b0(K,q.rollup_output||q.rollup?.output||{}),q.preact_enabled=q.preact===!0||q.preact&&q.preact?.enabled!==!1;let O=Object.keys(K);for(let z of O){let U=K[z];if(!U)continue;if(q.rollup[z]===!1){delete q.rollup_output[z];continue}if(U.babel_options=U.babel_options||q.babel_options,U.browsersync_options=b0(q.browsersync_options,U.browsersync_options),U.replace_options=b0(q.replace_options,U.replace_options),q.preact_enabled)U.alias_enabled=!0,U.alias=U.alias||{},U.alias.entries=U.alias.entries||{},U.alias.entries.react="preact/compat",U.alias.entries["react-dom"]="preact/compat";if(q.form_enabled||q.babel)U.babel=!0}O=Object.keys(q.rollup_output),q.babel_enabled=O.some((z)=>q.rollup_output[z].babel===!0),q.browser_enabled=O.some((z)=>q.rollup_output[z].babel===!0),q.browsersync_enabled=q.browsersync!==!1&&O.some((z)=>q.rollup_output[z].browsersync===!0),q.browsersync_enabled=q.browsersync_enabled&&q.app.enabled,q.dependency_auto_enabled=q.dependency_auto!==!1&&q.dependency_auto?.enabled!==!1,q.npm_install_flags=q.npm_install_flags||"",q.react_version=q.react_version||q.react?.version||18,e8($),t8($),a8($),o8($),s8($),n8($),r8($),i8($),p8($),d8($),l8($),m8($),c8($)}import o1 from"@fnet/npm-list-versions";async function Z$({atom:$,packageDependencies:Q,packageDevDependencies:Z,setProgress:X}){X("Initializing dependencies");let q=$.doc.dependencies||[];if(q.filter((J)=>!J.dev).forEach((J)=>Q.push(J)),q.filter((J)=>J.dev).forEach((J)=>Z.push(J)),$.type==="workflow")Q.push({package:"get-value",version:"^3"}),Q.push({package:"set-value",version:"^4"});if($.doc.features.form_enabled){if($.doc.features.dependency_auto_enabled){let J="^18.2";if(X("Fetching React versions"),J=`^${(await o1({name:"react",groupBy:{major:!0}})).find((W)=>W[0]===$.doc.features.react_version.toString())[0]}`,Q.push({package:"react",version:J}),Q.push({package:"react-dom",version:J}),$.type==="workflow")Q.push({package:"@fnet/react-app",version:"^0.1"}),Q.push({package:"@fnet/react-app-state",version:"^0.1"})}}if($.doc.features.preact_enabled)Q.push({package:"preact",version:"^10"});if($.doc.features.cli.enabled===!0){if(Q.push({package:"@fnet/args",version:"^0.1"}),$.doc.features.cli.fargs&&$.doc.features.cli.fargs?.enabled!==!1)Q.push({package:"@fnet/config",version:"0.2.21"});if($.doc.features.cli.mcp&&$.doc.features.cli.mcp.enabled!==!1)Q.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),Q.push({package:"express",version:"^4.18"})}if($.doc.features.render&&$.doc.features.render.enabled!==!1)Z.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"});if(Z.push({package:"@babel/core",version:"^7"}),Z.push({package:"@rollup/plugin-commonjs",version:"^28"}),Z.push({package:"@rollup/plugin-node-resolve",version:"^16"}),Z.push({package:"@rollup/plugin-replace",version:"^6"}),Z.push({package:"rollup",version:"^4"}),$.doc.features.dts_enabled)Z.push({package:"rollup-plugin-dts",version:"^6"});if(Z.push({package:"rollup-plugin-peer-deps-external",version:"^2"}),Z.push({package:"@rollup/plugin-alias",version:"^5"}),Z.push({package:"fs-extra",version:"^11"}),$.doc.features.babel_enabled)Z.push({package:"@rollup/plugin-babel",version:"^6"}),Z.push({package:"@babel/preset-env",version:"^7"}),Z.push({package:"@babel/preset-react",version:"^7"}),$.doc.features.babel?.options?.plugins?.forEach((J)=>{switch(J[0]){case"@babel/plugin-proposal-decorators":Z.push({package:"@babel/plugin-proposal-decorators",version:"^7"});break;case"@babel/plugin-proposal-class-properties":Z.push({package:"@babel/plugin-proposal-class-properties",version:"^7"});break;case"@babel/plugin-proposal-private-methods":Z.push({package:"@babel/plugin-proposal-private-methods",version:"^7"});break;case"@babel/plugin-proposal-private-property-in-object":Z.push({package:"@babel/plugin-proposal-private-property-in-object",version:"^7"});break;case"@babel/plugin-proposal-optional-chaining":Z.push({package:"@babel/plugin-proposal-optional-chaining",version:"^7"});break}});if(Z.push({package:"@fnet/rollup-plugin-delete",version:"0.1.10"}),$.doc.features.browsersync_enabled)Z.push({package:"@fnet/rollup-plugin-browsersync",version:"0.1.11"})}import a1 from"@fnet/npm-list-versions";async function X$({atom:$,packageDependencies:Q,packageDevDependencies:Z,setProgress:X}){X("Initializing dependencies for Bun");let q=$.doc.dependencies||[];if(q.filter((J)=>!J.dev).forEach((J)=>Q.push(J)),q.filter((J)=>J.dev).forEach((J)=>Z.push(J)),$.type==="workflow")Q.push({package:"get-value",version:"^3"}),Q.push({package:"set-value",version:"^4"});if($.doc.features.form_enabled){if($.doc.features.dependency_auto_enabled){let J="^18.2";if(X("Fetching React versions"),J=`^${(await a1({name:"react",groupBy:{major:!0}})).find((W)=>W[0]===$.doc.features.react_version.toString())[0]}`,Q.push({package:"react",version:J}),Q.push({package:"react-dom",version:J}),$.type==="workflow")Q.push({package:"@fnet/react-app",version:"^0.1"}),Q.push({package:"@fnet/react-app-state",version:"^0.1"})}}if($.doc.features.preact_enabled)Q.push({package:"preact",version:"^10"});if($.doc.features.cli.enabled===!0){if(Q.push({package:"@fnet/args",version:"^0.1"}),$.doc.features.cli.fargs&&$.doc.features.cli.fargs?.enabled!==!1)Q.push({package:"@fnet/config",version:"0.2.21"});if($.doc.features.cli.mcp&&$.doc.features.cli.mcp.enabled!==!1)Q.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),Q.push({package:"express",version:"^4.18"})}if($.doc.features.render&&$.doc.features.render.enabled!==!1)Z.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"})}import R6 from"fs";import C6 from"path";import t1 from"@flownet/lib-render-templates-dir";async function q$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){if($.doc.features.app.enabled!==!0)return;await Q({message:"Creating app folder"});let q={atom:$,packageDependencies:X,ts:Date.now()},J=Z.templateDir,Y=C6.resolve(Z.projectDir,"src/app");if(!R6.existsSync(Y))R6.mkdirSync(Y,{recursive:!0});let V=["index.js.njk"];if($.doc.features.app.html!==!1)V.push("index.html.njk");await t1({pattern:V,dir:C6.resolve(J,"src/app"),outDir:Y,context:q})}import F6 from"nunjucks";import _0 from"fs";import O0 from"path";import Q7 from"@flownet/lib-parse-imports-js";import e1 from"@fnet/npm-pick-versions";import $7 from"object-hash";import W8 from"fs";import I6 from"path";async function P0({projectDir:$,name:Q,setProgress:Z,count:X=1}){let q,Y=$7(["npm-pick-versions",Q,X]),V=I6.join($,".cache"),W=I6.join(V,Y+".json");if(W8.existsSync(W)){if(Z)Z(`Picking npm version of ${Q} from cache ...`);q=JSON.parse(W8.readFileSync(W,"utf8"))}else{if(Z)Z(`Picking npm version of ${Q} ...`);q=await e1({name:Q,count:X}),W8.mkdirSync(V,{recursive:!0}),W8.writeFileSync(W,JSON.stringify(q),"utf8")}return q}async function J$({atom:$,context:Q,packageDependencies:Z,packageDevDependencies:X,setProgress:q}){await q({message:"Creating package.json."}),Z.filter((U)=>U.dev===!0).forEach((U)=>{if(!X.find((L)=>L.package===U.package))X.push(U);let A=Z.findIndex((L)=>L.package===U.package);Z.splice(A,1)});let Y=Z.find((U)=>U.package==="react"),V=Z.find((U)=>U.package==="react-dom");if(Y&&!V)Z.push({package:"react-dom",version:Y.version});else if(Y&&V)V.version=Y.version;if(Y&&$.doc.features.react_version>=17){if(!Z.find((U)=>U.package==="@emotion/react"))Z.push({package:"@emotion/react",version:"^11"});if(!Z.find((U)=>U.package==="@emotion/styled"))Z.push({package:"@emotion/styled",version:"^11"})}let W=[];if($.doc.features.app.enabled===!0)W.push({file:O0.resolve(Q.projectDir,"src/app/index.js"),dev:$.doc.features.app.dev!==!1});if($.doc.features.cli.enabled===!0)W.push({file:O0.resolve(Q.projectDir,"src/cli/index.js"),dev:$.doc.features.cli.dev!==!1});for await(let U of W){let A=U.file;if(!_0.existsSync(A))throw Error(`App file not found: ${A}`);let R=(await Q7({file:A,recursive:!0,verbose:!1})).all;for await(let T of R){if(T.type!=="npm")continue;if(Z.find((t)=>t.package===T.package))continue;if(X.find((t)=>t.package===T.package))continue;let l=await P0({name:T.package,projectDir:Q.projectDir,setProgress:q});(U.dev===!0?X:Z).push({package:T.package,subpath:T.subpath,version:l.minorRange,type:"npm"})}}let H={atom:$,packageDependencies:Z,packageDevDependencies:X},K=Q.templateDir,G=F6.compile(_0.readFileSync(O0.resolve(K,"package.json.njk"),"utf8"),F6.configure(K)).render(H),M=Q.projectDir,O=O0.resolve(M,"package.json");_0.writeFileSync(O,G,"utf8");let z=O0.resolve(Q.project.projectDir,"fnet");if(_0.existsSync(z)){let U=O0.resolve(Q.projectDir,"fnet");if(!_0.existsSync(U))_0.mkdirSync(U);let A=_0.readdirSync(z);for(let L of A){let R=O0.resolve(z,L);if(!_0.lstatSync(R).isFile())continue;let T=O0.resolve(U,L);_0.copyFileSync(R,T)}}}import T6 from"fs";import j6 from"path";import Z7 from"@flownet/lib-render-templates-dir";async function Y$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){if($.doc.features.cli.enabled!==!0)return;await Q({message:"Creating cli."});let q={atom:$,packageDependencies:X},J=Z.templateDir,Y=j6.resolve(Z.projectDir,"src/cli");if(!T6.existsSync(Y))T6.mkdirSync(Y,{recursive:!0});await Z7({pattern:["index.js.njk"],dir:j6.resolve(J,"src/cli"),outDir:Y,context:q})}import V$ from"fs";import W$ from"path";import w6 from"nunjucks";import X7 from"@flownet/lib-parse-imports-js";async function H$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating rollup file."});let q={atom:$,packageDependencies:X},J=W$.resolve(Z.projectDir,"src","default/index.js");if(!V$.existsSync(J))throw Error(`Entry file not found: ${J}`);let V=(await X7({file:J,recursive:!0})).all.filter((z)=>z.type==="node").map((z)=>z.path),W=$.doc.features.rollup_output,H=Object.keys(W);for(let z=0;z<H.length;z++){let U=H[z],A=W[U];if(A.browser===!0){if(V.length>0){A.globals_enabled=!0,A.globals=A.globals||[],A.globals=A.globals.concat(V.map((L)=>{return{key:L,value:L}})),A.alias_enabled=!0,A.alias=A.alias||{},A.alias.entries=A.alias.entries||{};for(let L=0;L<V.length;L++){let R=V[L];A.alias.entries[R]=`node:${R}`,A.alias.entries[`node:${R}`]=R}A.external_enabled=!0,A.external=A.external||[],A.external=A.external.concat(V)}}}let K=Z.templateDir,G=w6.compile(V$.readFileSync(W$.resolve(K,"rollup.config.mjs.njk"),"utf8"),w6.configure(K)).render(q),M=Z.projectDir,O=W$.resolve(M,"rollup.config.mjs");V$.writeFileSync(O,G,"utf8")}import K$ from"fs";import S6 from"path";import b6 from"nunjucks";async function _$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating build.js file."});let q={atom:$,packageDependencies:X},J=Z.templateDir,V=b6.compile(K$.readFileSync(S6.resolve(J,"build.js.njk"),"utf8"),b6.configure(J)).render(q),W=Z.projectDir,H=S6.resolve(W,"build.js");K$.writeFileSync(H,V,"utf8"),K$.chmodSync(H,"755")}import G$ from"fs";import z$ from"path";import q7 from"nunjucks";import J7 from"ajv/dist/2020.js";import Y7 from"ajv/dist/standalone/index.js";import V7 from"ajv-formats";async function U$({atom:$,setProgress:Q,context:Z,njEnv:X}){if($.doc.features.cli.enabled!==!0)return;await Q({message:"Creating input args."});let q={},J=[];if($.doc.input)q=$.doc.input;else q={type:"object",properties:{},required:[]};if($.doc.features.cli.fargs&&$.doc.features.cli.fargs?.enabled!==!1){let A=$.doc.features.cli.fargs,L={type:"string",description:"Config name to load args",hidden:!1},R={type:"array",description:"Tags to filter the config",hidden:!1};if(Reflect.has(A,"default"))L.default=A.default}let V={imports:J,atom:$},W=Z.templateDir,K=q7.compile(G$.readFileSync(z$.resolve(W,"src/default/input.args.js.njk"),"utf8"),X).render(V),_=Z.projectDir,G=z$.resolve(_,"src/default/input.args.js");G$.writeFileSync(G,K,"utf8");let M=new J7({allErrors:!0,useDefaults:!0,formats:{},strict:!1,code:{esm:!0,lines:!0,optimize:!1,source:!0}});V7(M);let O=M.compile(q),U=Y7(M,O)+`
|
|
4
|
+
export { schema31 as schema };`;G$.writeFileSync(z$.resolve(_,"src/default/validate_input.js"),U,"utf8")}import N6 from"fs";import P6 from"path";import E6 from"nunjucks";async function M$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating .gitignore"});let q={atom:$,packageDependencies:X},J=Z.templateDir,V=E6.compile(N6.readFileSync(P6.resolve(J,".gitignore.njk"),"utf8"),E6.configure(J)).render(q),W=Z.projectDir,H=P6.resolve(W,".gitignore");N6.writeFileSync(H,V,"utf8")}import k6 from"fs";import D6 from"path";import y6 from"nunjucks";async function O$({atom:$,setProgress:Q,context:Z,packageDependencies:X}){await Q({message:"Creating tsconfig.json."});let q={atom:$,packageDependencies:X},J=Z.templateDir,V=y6.compile(k6.readFileSync(D6.resolve(J,"tsconfig.json.njk"),"utf8"),y6.configure(J)).render(q),W=Z.projectDir,H=D6.resolve(W,"tsconfig.json");k6.writeFileSync(H,V,"utf8")}import H8 from"nunjucks";import A0 from"fs";import F0 from"path";import v6 from"@fnet/yaml";async function A$({atom:$,context:Q,setProgress:Z,Atom:X}){if(await Z({message:"Creating readme.md"}),Q.project?.readme){let Y=Q.projectDir,V={content:Q.project.readme.doc.content},W=F0.resolve(Q.project.projectDir,"fnet/how-to.md");if(A0.existsSync(W)){let z=A0.readFileSync(W,"utf8");V.howto=z}let H=F0.resolve(Q.project.projectDir,"fnet/input.yaml");if(A0.existsSync(H)){let z=await v6({file:H,tags:Q.tags});V.input=z.content}let K=F0.resolve(Q.project.projectDir,"fnet/output.yaml");if(A0.existsSync(K)){let z=await v6({file:K,tags:Q.tags});V.output=z.content}let _=Q.templateDir,M=H8.compile(A0.readFileSync(F0.resolve(_,"readme.md.njk"),"utf8"),H8.configure(_)).render(V),O=F0.resolve(Y,"readme.md");A0.writeFileSync(O,M,"utf8")}else if($.id){let Y=await X.first({type:"wiki",parent_id:$.id});if(!Y||Y.doc?.["content-type"]!=="markdown")return;let{content:V,...W}=Y.doc,H={content:V},K=Q.templateDir,G=H8.compile(A0.readFileSync(F0.resolve(K,"readme.md.njk"),"utf8"),H8.configure(K)).render(H),M=Q.projectDir,O=F0.resolve(M,"readme.md");A0.writeFileSync(O,G,"utf8")}}import W7 from"path";import x6 from"@fnet/shelljs";async function L$({setProgress:$,context:Q}){let Z=Q.projectDir;await $({message:"Prettifiying source files."});let X=W7.join("src","**","*");if(J0("bun")){let q=await x6(`prettier --write ${X} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:Z});if(q.code!==0)throw Error(q.stderr)}else{let q=await x6(`prettier --write ${X} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:Z});if(q.code!==0)throw Error(q.stderr)}}import H7 from"@fnet/shelljs";async function B$({atom:$,setProgress:Q,context:Z}){if(!$.doc.features.dts_enabled)return;let X=Z.projectDir;if(await Q({message:"Creating .d.ts"}),(await H7("tsc",{cwd:X})).code!==0)throw Error("Couldnt create .d.ts files.")}import u6 from"@fnet/shelljs";async function R$({setProgress:$,atom:Q,context:Z}){let X=Z.projectDir;if(await $({message:"Installing npm packages."}),J0("bun")){if((await u6(`bun install ${Q.doc.features.npm_install_flags}`,{cwd:X})).code!==0)throw Error("Couldnt install npm packages.")}else if((await u6(`npm install ${Q.doc.features.npm_install_flags}`,{cwd:X})).code!==0)throw Error("Couldnt install npm packages.")}import f6 from"fs";import K7 from"path";import{spawn as _7}from"child_process";async function g6($){let{projectDir:Q,scriptName:Z,args:X=[],env:q=process.env,shell:J=!0,detached:Y=!0,onSpawn:V}=$;if(!Q||!Z)throw Error("projectDir and scriptName are required");let W=K7.resolve(Q,"package.json");if(!f6.existsSync(W))throw Error(`package.json not found at ${W}`);let H=JSON.parse(f6.readFileSync(W,"utf8")),K=H.scripts?.[Z];if(!K){let M=Object.keys(H.scripts||{}).join(", ");throw Error(`Script '${Z}' not found. Available: ${M}`)}let _=X.length>0?`${K} ${X.join(" ")}`:K,G=_7(_,[],{cwd:Q,shell:J,detached:Y,env:{...q}});if(V)V(G);return new Promise((M,O)=>{G.on("error",(z)=>{O(Error(`Failed to start '${Z}': ${z.message}`))}),G.on("close",(z)=>{M({subprocess:G,exitCode:z})})})}async function C$({setProgress:$,context:Q}){let Z=Q.projectDir;await $({message:"Building main project."});let X=Q.dev?"build:dev":"build";await g6({projectDir:Z,scriptName:X,shell:!0,detached:!0,env:{...process.env}})}var h6=async($)=>{let{atom:Q,packageDependencies:Z,context:X,deploymentProjectTarget:q,setProgress:J,deploymentProject:Y,yamlTarget:V}=$;if(q.enabled!==!0)return;let W=q.type;try{if(W==="lib")await(await import("./index.3rmtt0x7.js")).default({...$});else if(W==="red")await(await import("./index.t8b8gd46.js")).default({...$});else if(W==="npm")await(await import("./index.8m14r891.js")).default({...$});else if(W==="gcs")await(await import("./index.knj6ydvb.js")).default({...$});else if(W==="gitlab")await(await import("./index.899ypy57.js")).default({...$});else if(W==="fnet-package")await(await import("./index.nnfg65pt.js")).default({...$});else if(W==="fnet-form")await(await import("./index.jkdwz7zj.js")).default({...$});else if(W==="fnet-node")await(await import("./index.zna4hmc3.js")).default({...$});else if(W==="fnet-flow")await(await import("./index.efd8jxdg.js")).default({...$});else if(W==="nextjs")await(await import("./index.a203h4q3.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="webos")await(await import("./index.z27pg13j.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="electron")await(await import("./index.75sm2tte.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="docker")await(await import("./index.mhsc3fmv.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="ios")await(await import("./index.exfvnegm.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="macos")await(await import("./index.11tp336m.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="rust")await(await import("./index.csbtwe06.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else if(W==="pypi")await(await import("./index.f1f463rw.js")).default({atom:Q,target:q,onProgress:J,projectDir:X.projectDir,dependencies:Z,context:X,yamlTarget:V}),Y.isDirty=!0;else{console.warn(`No deployer found for type: ${W}`);return}}catch(H){throw console.error(`Error during deployment for type "${W}":`,H),H}};import{Atom as H0}from"@flownet/lib-atom-api-js";import pQ from"@flownet/lib-parse-node-url";import c6 from"bpmn-moddle";import m6 from"dagre";import T$ from"lodash.clonedeep";var I$={name:"ATOM",uri:"http://atom.org/bpmn",prefix:"atom",types:[{name:"AtomExtension",extends:["bpmn:BaseElement"],properties:[{name:"atom",type:"atom:Atom",isMany:!1}]},{name:"Atom",properties:[{name:"type",type:"String",isAttr:!0}]}]};function l6($){let{nodes:Q,nodeIndex:Z,root:X}=$;Q.forEach((q)=>{let J=[],Y=[],V=(_)=>{if(_.context.next){if(J.push({from:_,to:_.context.next,type:"bpmn:SequenceFlow"}),_===q)Y.push({to:_.context.next,type:"bpmn:SequenceFlow",next:!0})}_.childs.forEach((G)=>{if(_===q){if(q.type==="switch")Y.push({to:G,type:"bpmn:SequenceFlow"})}V(G)})};V(q);let W=J.filter((_)=>_.to.parent.indexKey===q.parent.indexKey).map((_)=>{return{..._,from:q.indexKey,to:_.to.indexKey}}),H=J.filter((_)=>_.to.parent.indexKey!==q.parent.indexKey&&!_.to.indexKey.startsWith(q.indexKey+"/")).map((_)=>{return{..._,from:q.indexKey,to:_.to.indexKey}}),K=Y.map((_)=>{return{..._,to:_.to.indexKey}});if(q.bpmn=q.bpmn||{},q.bpmn.edges=F$(W,"to"),q.bpmn.outside=F$(H,"to"),q.bpmn.starts=F$(K,"to"),q.bpmn.type=z7(q),q.bpmn.width=120,q.bpmn.height=80,q.type==="return")q.bpmn.width=36,q.bpmn.height=36})}function z7($){if($.type==="call")return"bpmn:ServiceTask";else if($.type==="form")return"bpmn:UserTask";else if($.type==="return")return"bpmn:EndEvent";else return"bpmn:Task"}function F$($,Q){return $.filter((Z,X,q)=>{return q.map((J)=>J[Q]).indexOf(Z[Q])===X})}function j$($){let{nodes:Q,nodeIndex:Z,root:X}=$,q=$.targetNodes||X.childs;q.forEach((J)=>{let Y=J.type==="workflow"||J.type==="subworkflow",V=!Y&&J.childs.filter((W)=>!W.virtual).length>0;if(V)J.bpmn.type="bpmn:SubProcess";if(Y||V){let W=J.childs.filter((z)=>z.module!==!0)[0];J.childs.filter((z)=>z.module===!0).forEach((z)=>{let U=G0({...$,parent:J,bpmnType:"bpmn:IntermediateCatchEvent",type:"inter",definitions:[{type:"bpmn:SignalEventDefinition"}]});U.bpmn.edges=[{from:U.indexKey,to:z.indexKey,type:"bpmn:SequenceFlow"}]});let K=J.childs.find((z)=>z.name==="try"&&J.type==="tryexcept"),_=J.childs.filter((z)=>z.name==="except"&&J.type==="tryexcept");if(K&&_.length)_.forEach((z)=>{let U=G0({location:J.childs.indexOf(z),...$,parent:J,bpmnType:"bpmn:BoundaryEvent",type:"boundary",attrs:{attachedToRef:K},definitions:[{type:"bpmn:ErrorEventDefinition"}]});U.bpmn.edges=[{from:U.indexKey,to:z.indexKey,type:"bpmn:SequenceFlow"}]});let G=J.childs.find((z)=>z.type==="raise");if(G){let z=G0({...$,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:"ERROR",definitions:[{type:"bpmn:ErrorEventDefinition"}]});G.bpmn.edges=[{from:G.indexKey,to:z.indexKey,type:"bpmn:SequenceFlow"}]}if(W)if(J.bpmn.starts.length>1){let z=G0({...$,parent:J,bpmnType:"bpmn:StartEvent",type:"start"}),U=G0({...$,parent:J,bpmnType:"bpmn:ExclusiveGateway",type:"switch"});z.bpmn.edges=[{from:z.indexKey,to:U.indexKey,type:"bpmn:SequenceFlow"}],U.bpmn.edges=J.bpmn.starts.map((L)=>{return{...L,from:U.indexKey}});let A=U.bpmn.edges.find((L)=>L.next===!0);if(A){let L=G0({...$,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:A.to});A.to=L.indexKey}}else{let z=G0({...$,parent:J,bpmnType:"bpmn:StartEvent",type:"start"});z.bpmn.edges.push({from:z.indexKey,to:W.indexKey,type:"bpmn:SequenceFlow"})}J.childs.filter((z)=>z.virtual!==!0&&z.bpmn.outside.length&&z.bpmn.type!=="bpmn:EndEvent").forEach((z)=>{z.bpmn.outside.forEach((U)=>{let A=q.indexOf(J),L=G0({...$,parent:J,bpmnType:"bpmn:EndEvent",type:"end",name:U.to,location:A+1});z.bpmn.edges.push({from:z.indexKey,to:L.indexKey,type:"bpmn:SequenceFlow"})})}),J.childs.filter((z)=>z.virtual!==!0&&z.bpmn.edges.length>1).forEach((z)=>{let U=q.indexOf(z),A=G0({...$,parent:J,bpmnType:"bpmn:ExclusiveGateway",type:"switch",location:U+1});A.bpmn.edges=z.bpmn.edges.map((L)=>{return{...L,from:A.indexKey}}),z.bpmn.edges=[{from:z.indexKey,to:A.indexKey,type:"bpmn:SequenceFlow"}],z.bpmn.outside=[]})}j$({...$,targetNodes:J.childs})})}function G0($){let{parent:Q,nodes:Z,nodeIndex:X,bpmnType:q,type:J,name:Y,outside:V,location:W,definitions:H,attrs:K}=$,_=Q.childs.filter((M)=>M.type===`v${J}`).length,G={indexKey:`${Q.indexKey}/_${J}${_}`,pathKey:`${Q.pathKey}._${J}${_}`,type:`v${J}`,name:Y,bpmn:{edges:[],outside:[],type:q,width:36,height:36,fill:"#c8e6c9",stroke:"#205022",definitions:H,attrs:K},virtual:!0,childs:[]};return Q.childs.splice(W||0,0,G),Z.push(G),X[G.indexKey]=G,G}function w$($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:J,nodeIndex:Y,diagrams:V,nodes:W}=$;U7($),M7($),O7($),A7($)}function U7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:J,nodeIndex:Y,nodes:V}=$,W=Z.get("flowElements");Z.$nodes=Z.$nodes||[],Q.childs.forEach((H)=>{let K=q.create(H.bpmn.type,{id:`node.${H.pathKey}`,name:H.definition?.title||H.name});if(J[K.id]=K,K.$isNode=!0,K.$node=H,H.$flow=K,Z.$nodes.push(K),W.push(K),H.bpmn.attrs)Object.keys(H.bpmn.attrs).forEach((G)=>{if(G==="attachedToRef")K.set(G,H.bpmn.attrs[G].$flow)});if(H.bpmn.definitions){let _=H.bpmn.definitions.map((G)=>{let M=q.create(G.type);return Object.keys(G.attrs||{}).forEach((z)=>{M.set(z,G.attrs[z])}),M});K.eventDefinitions=_}})}function M7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:J,nodeIndex:Y}=$,V=Z.get("flowElements");Z.$edges=Z.$edges||[],Q.childs.forEach((W)=>{W.bpmn.edges.forEach((K)=>{let _=W,G=Y[K.to],M=`edge.${_.pathKey}_${G.pathKey}`;if(J[M])return;let O=J[`node.${_.pathKey}`],z=J[`node.${G.pathKey}`],U=q.create(K.type,{id:M,sourceRef:O,targetRef:z});J[U.id]=U,U.$is_edge=!0,O.get("outgoing").push(U),z.get("incoming").push(U),Z.$edges.push({from:O,to:z,flow:U}),V.push(U)})})}function O7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:J,nodeIndex:Y}=$,V=120,W=80,H=160,K=160,_=new m6.graphlib.Graph;_.setDefaultEdgeLabel(()=>({})),_.setGraph({rankdir:"TB",nodesep:120,ranksep:80,xranker:"longest-path"}),Z.$nodes.forEach((G)=>{_.setNode(G.id,{width:G.$node?.bpmn.width||120,height:G.$node?.bpmn.height||80,label:G.id})}),Z.$edges.forEach((G)=>{_.setEdge(G.from.id,G.to.id)}),m6.layout(_),Z.$nodes.forEach((G)=>{let M=_.node(G.id),O=M.width,z=M.height,U=q.create("bpmndi:BPMNShape",{id:`shape.${G.id}`,bpmnElement:G,bounds:q.create("dc:Bounds",{x:160+M.x-M.width/2,y:160+M.y-M.height/2,width:O,height:z}),label:q.create("bpmndi:BPMNLabel")});if(G.$node.bpmn.fill)U.set("bioc:fill",G.$node.bpmn.fill);if(G.$node.bpmn.stroke)U.set("bioc:stroke",G.$node.bpmn.stroke);X.get("planeElement").push(U)}),Z.$edges.forEach((G)=>{let M=_.edge(G.from.id,G.to.id),O=q.create("bpmndi:BPMNEdge",{id:`edge.${G.from.id}_${G.to.id}`,bpmnElement:G.flow,label:q.create("bpmndi:BPMNLabel")});M.points.forEach((U)=>{let A=q.create("dc:Point",{x:160+U.x,y:160+U.y});O.get("waypoint").push(A)}),X.get("planeElement").push(O)})}function A7($){let{targetNode:Q,targetFlowElementsContainer:Z,targetPlaneElement:X,moddle:q,elementIndex:J,nodeIndex:Y,diagrams:V}=$;Q.childs.filter((H)=>H.bpmn.type==="bpmn:SubProcess").forEach((H)=>{let K=J[`node.${H.pathKey}`],_=q.create("bpmndi:BPMNDiagram",{id:`diagram_${H.pathKey}`});J[_.id]=_,V.push(_);let G=q.create("bpmndi:BPMNPlane",{id:`plane_${H.pathKey}`});J[G.id]=G,_.plane=G,G.bpmnElement=K,w$({...$,targetNode:H,targetFlowElementsContainer:K,targetPlaneElement:G})})}async function L7($){let Q=$.root,Z=Q.context.index,X=Object.keys(Z).map((H)=>Z[H]);l6({nodes:X,nodeIndex:Z,root:Q}),j$({nodes:X,nodeIndex:Z,root:Q});let q=void 0,J=new c6({atom:I$}),Y={},V=J.create("bpmn:Definitions",{id:"definitions_0"});Y[V.id]=V;for await(let H of Q.childs){let K=V.get("rootElements"),_=V.get("diagrams"),G=J.create("bpmn:Process",{id:`process_${H.pathKey}`,name:H.name,documentation:[J.create("bpmn:Documentation",{text:`Workflow - ${H.name}`})]});Y[G.id]=G,G.isExecutable=!0,K.push(G);let M=J.create("bpmndi:BPMNDiagram",{id:`diagram_${H.pathKey}`});Y[M.id]=M,_.push(M);let O=J.create("bpmndi:BPMNPlane",{id:`plane_${H.pathKey}`});Y[O.id]=O,M.plane=O,O.bpmnElement=G,w$({targetNode:H,targetFlowElementsContainer:G,targetPlaneElement:O,moddle:J,elementIndex:Y,nodeIndex:Z,nodes:X,diagrams:_})}let W=await J.toXML(V,{format:!0});return{diagramXML:q||W.xml}}async function B7($){let{root:Q,flowName:Z}=$,X=T$(Q),q=X.childs.find((T)=>T.name===Z);if(!q)throw Error(`Flow "${Z}" not found`);let J={...X,childs:[q]},Y=J.context.index,V=Object.keys(Y).map((T)=>Y[T]);l6({nodes:V,nodeIndex:Y,root:J}),j$({nodes:V,nodeIndex:Y,root:J});let W=new c6({atom:I$}),H={},K=W.create("bpmn:Definitions",{id:`definitions_${Z}`});H[K.id]=K;let _=K.get("rootElements"),G=K.get("diagrams"),M=W.create("bpmn:Process",{id:`process_${q.pathKey}`,name:q.name,documentation:[W.create("bpmn:Documentation",{text:`Workflow - ${q.name}`})]});H[M.id]=M,M.isExecutable=!0,_.push(M);let O=W.create("bpmndi:BPMNDiagram",{id:`diagram_${q.pathKey}`});H[O.id]=O,G.push(O);let z=W.create("bpmndi:BPMNPlane",{id:`plane_${q.pathKey}`});return H[z.id]=z,O.plane=z,z.bpmnElement=M,w$({targetNode:q,targetFlowElementsContainer:M,targetPlaneElement:z,moddle:W,elementIndex:H,nodeIndex:Y,nodes:V,diagrams:G}),{diagramXML:(await W.toXML(K,{format:!0})).xml,flowName:q.name}}async function K8($={}){return await L7(T$($))}async function d6($={}){let Q=T$($),{root:Z}=Q,X=[];for(let q of Z.childs){let J=await B7({root:Z,flowName:q.name});X.push(J)}return X}import iQ from"@fnet/config";import nQ from"@flownet/lib-parse-imports-js";import L1 from"@fnet/expression";import rQ from"@fnet/yaml";import sQ from"chalk";var G5=N(q5(),1);var h0=($)=>{if(typeof $!=="string")throw TypeError("invalid pattern");if($.length>65536)throw TypeError("pattern is too long")};var S7={"[: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]},m0=($)=>$.replace(/[[\]\\-]/g,"\\$&"),b7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),J5=($)=>$.join(""),Y5=($,Q)=>{let Z=Q;if($.charAt(Z)!=="[")throw Error("not in a brace expression");let X=[],q=[],J=Z+1,Y=!1,V=!1,W=!1,H=!1,K=Z,_="";$:while(J<$.length){let z=$.charAt(J);if((z==="!"||z==="^")&&J===Z+1){H=!0,J++;continue}if(z==="]"&&Y&&!W){K=J+1;break}if(Y=!0,z==="\\"){if(!W){W=!0,J++;continue}}if(z==="["&&!W){for(let[U,[A,L,R]]of Object.entries(S7))if($.startsWith(U,J)){if(_)return["$.",!1,$.length-Z,!0];if(J+=U.length,R)q.push(A);else X.push(A);V=V||L;continue $}}if(W=!1,_){if(z>_)X.push(m0(_)+"-"+m0(z));else if(z===_)X.push(m0(z));_="",J++;continue}if($.startsWith("-]",J+1)){X.push(m0(z+"-")),J+=2;continue}if($.startsWith("-",J+1)){_=z,J+=2;continue}X.push(m0(z)),J++}if(K<J)return["",!1,0,!1];if(!X.length&&!q.length)return["$.",!1,$.length-Z,!0];if(q.length===0&&X.length===1&&/^\\?.$/.test(X[0])&&!H){let z=X[0].length===2?X[0].slice(-1):X[0];return[b7(z),!1,K-Z,!1]}let G="["+(H?"^":"")+J5(X)+"]",M="["+(H?"":"^")+J5(q)+"]";return[X.length&&q.length?"("+G+"|"+M+")":X.length?G:M,V,K-Z,!0]};var Q0=($,{windowsPathsNoEscape:Q=!1}={})=>{return Q?$.replace(/\[([^\/\\])\]/g,"$1"):$.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var N7=new Set(["!","?","+","*","@"]),V5=($)=>N7.has($),P7="(?!(?:^|/)\\.\\.?(?:$|/))",_8="(?!\\.)",E7=new Set(["[","."]),k7=new Set(["..","."]),D7=new Set("().*{}+?[]^$\\!"),y7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),N$="[^/]",W5=N$+"*?",H5=N$+"+?";class f{type;#Q;#$;#Z=!1;#X=[];#J;#C;#R;#H=!1;#G;#W;#_=!1;constructor($,Q,Z={}){if(this.type=$,$)this.#$=!0;if(this.#J=Q,this.#Q=this.#J?this.#J.#Q:this,this.#G=this.#Q===this?Z:this.#Q.#G,this.#R=this.#Q===this?[]:this.#Q.#R,$==="!"&&!this.#Q.#H)this.#R.push(this);this.#C=this.#J?this.#J.#X.length:0}get hasMagic(){if(this.#$!==void 0)return this.#$;for(let $ of this.#X){if(typeof $==="string")continue;if($.type||$.hasMagic)return this.#$=!0}return this.#$}toString(){if(this.#W!==void 0)return this.#W;if(!this.type)return this.#W=this.#X.map(($)=>String($)).join("");else return this.#W=this.type+"("+this.#X.map(($)=>String($)).join("|")+")"}#q(){if(this!==this.#Q)throw Error("should only call on root");if(this.#H)return this;this.toString(),this.#H=!0;let $;while($=this.#R.pop()){if($.type!=="!")continue;let Q=$,Z=Q.#J;while(Z){for(let X=Q.#C+1;!Z.type&&X<Z.#X.length;X++)for(let q of $.#X){if(typeof q==="string")throw Error("string part in extglob AST??");q.copyIn(Z.#X[X])}Q=Z,Z=Q.#J}}return this}push(...$){for(let Q of $){if(Q==="")continue;if(typeof Q!=="string"&&!(Q instanceof f&&Q.#J===this))throw Error("invalid part: "+Q);this.#X.push(Q)}}toJSON(){let $=this.type===null?this.#X.slice().map((Q)=>typeof Q==="string"?Q:Q.toJSON()):[this.type,...this.#X.map((Q)=>Q.toJSON())];if(this.isStart()&&!this.type)$.unshift([]);if(this.isEnd()&&(this===this.#Q||this.#Q.#H&&this.#J?.type==="!"))$.push({});return $}isStart(){if(this.#Q===this)return!0;if(!this.#J?.isStart())return!1;if(this.#C===0)return!0;let $=this.#J;for(let Q=0;Q<this.#C;Q++){let Z=$.#X[Q];if(!(Z instanceof f&&Z.type==="!"))return!1}return!0}isEnd(){if(this.#Q===this)return!0;if(this.#J?.type==="!")return!0;if(!this.#J?.isEnd())return!1;if(!this.type)return this.#J?.isEnd();let $=this.#J?this.#J.#X.length:0;return this.#C===$-1}copyIn($){if(typeof $==="string")this.push($);else this.push($.clone(this))}clone($){let Q=new f(this.type,$);for(let Z of this.#X)Q.copyIn(Z);return Q}static#O($,Q,Z,X){let q=!1,J=!1,Y=-1,V=!1;if(Q.type===null){let G=Z,M="";while(G<$.length){let O=$.charAt(G++);if(q||O==="\\"){q=!q,M+=O;continue}if(J){if(G===Y+1){if(O==="^"||O==="!")V=!0}else if(O==="]"&&!(G===Y+2&&V))J=!1;M+=O;continue}else if(O==="["){J=!0,Y=G,V=!1,M+=O;continue}if(!X.noext&&V5(O)&&$.charAt(G)==="("){Q.push(M),M="";let z=new f(O,Q);G=f.#O($,z,G,X),Q.push(z);continue}M+=O}return Q.push(M),G}let W=Z+1,H=new f(null,Q),K=[],_="";while(W<$.length){let G=$.charAt(W++);if(q||G==="\\"){q=!q,_+=G;continue}if(J){if(W===Y+1){if(G==="^"||G==="!")V=!0}else if(G==="]"&&!(W===Y+2&&V))J=!1;_+=G;continue}else if(G==="["){J=!0,Y=W,V=!1,_+=G;continue}if(V5(G)&&$.charAt(W)==="("){H.push(_),_="";let M=new f(G,H);H.push(M),W=f.#O($,M,W,X);continue}if(G==="|"){H.push(_),_="",K.push(H),H=new f(null,Q);continue}if(G===")"){if(_===""&&Q.#X.length===0)Q.#_=!0;return H.push(_),_="",Q.push(...K,H),W}_+=G}return Q.type=null,Q.#$=void 0,Q.#X=[$.substring(Z-1)],W}static fromGlob($,Q={}){let Z=new f(null,void 0,Q);return f.#O($,Z,0,Q),Z}toMMPattern(){if(this!==this.#Q)return this.#Q.toMMPattern();let $=this.toString(),[Q,Z,X,q]=this.toRegExpSource();if(!(X||this.#$||this.#G.nocase&&!this.#G.nocaseMagicOnly&&$.toUpperCase()!==$.toLowerCase()))return Z;let Y=(this.#G.nocase?"i":"")+(q?"u":"");return Object.assign(new RegExp(`^${Q}$`,Y),{_src:Q,_glob:$})}get options(){return this.#G}toRegExpSource($){let Q=$??!!this.#G.dot;if(this.#Q===this)this.#q();if(!this.type){let V=this.isStart()&&this.isEnd(),W=this.#X.map((G)=>{let[M,O,z,U]=typeof G==="string"?f.#U(G,this.#$,V):G.toRegExpSource($);return this.#$=this.#$||z,this.#Z=this.#Z||U,M}).join(""),H="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&k7.has(this.#X[0]))){let M=E7,O=Q&&M.has(W.charAt(0))||W.startsWith("\\.")&&M.has(W.charAt(2))||W.startsWith("\\.\\.")&&M.has(W.charAt(4)),z=!Q&&!$&&M.has(W.charAt(0));H=O?P7:z?_8:""}}}let K="";if(this.isEnd()&&this.#Q.#H&&this.#J?.type==="!")K="(?:$|\\/)";return[H+W+K,Q0(W),this.#$=!!this.#$,this.#Z]}let Z=this.type==="*"||this.type==="+",X=this.type==="!"?"(?:(?!(?:":"(?:",q=this.#M(Q);if(this.isStart()&&this.isEnd()&&!q&&this.type!=="!"){let V=this.toString();return this.#X=[V],this.type=null,this.#$=void 0,[V,Q0(this.toString()),!1,!1]}let J=!Z||$||Q||!_8?"":this.#M(!0);if(J===q)J="";if(J)q=`(?:${q})(?:${J})*?`;let Y="";if(this.type==="!"&&this.#_)Y=(this.isStart()&&!Q?_8:"")+H5;else{let V=this.type==="!"?"))"+(this.isStart()&&!Q&&!$?_8:"")+W5+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&J?")":this.type==="*"&&J?")?":`)${this.type}`;Y=X+q+V}return[Y,Q0(q),this.#$=!!this.#$,this.#Z]}#M($){return this.#X.map((Q)=>{if(typeof Q==="string")throw Error("string type in extglob ast??");let[Z,X,q,J]=Q.toRegExpSource($);return this.#Z=this.#Z||J,Z}).filter((Q)=>!(this.isStart()&&this.isEnd())||!!Q).join("|")}static#U($,Q,Z=!1){let X=!1,q="",J=!1;for(let Y=0;Y<$.length;Y++){let V=$.charAt(Y);if(X){X=!1,q+=(D7.has(V)?"\\":"")+V;continue}if(V==="\\"){if(Y===$.length-1)q+="\\\\";else X=!0;continue}if(V==="["){let[W,H,K,_]=Y5($,Y);if(K){q+=W,J=J||H,Y+=K-1,Q=Q||_;continue}}if(V==="*"){if(Z&&$==="*")q+=H5;else q+=W5;Q=!0;continue}if(V==="?"){q+=N$,Q=!0;continue}q+=y7(V)}return[q,Q0($),!!Q,J]}}var E0=($,{windowsPathsNoEscape:Q=!1}={})=>{return Q?$.replace(/[?*()[\]]/g,"[$&]"):$.replace(/[?*()[\]\\]/g,"\\$&")};var d=($,Q,Z={})=>{if(h0(Q),!Z.nocomment&&Q.charAt(0)==="#")return!1;return new s(Q,Z).match($)},v7=/^\*+([^+@!?\*\[\(]*)$/,x7=($)=>(Q)=>!Q.startsWith(".")&&Q.endsWith($),u7=($)=>(Q)=>Q.endsWith($),f7=($)=>{return $=$.toLowerCase(),(Q)=>!Q.startsWith(".")&&Q.toLowerCase().endsWith($)},g7=($)=>{return $=$.toLowerCase(),(Q)=>Q.toLowerCase().endsWith($)},h7=/^\*+\.\*+$/,m7=($)=>!$.startsWith(".")&&$.includes("."),c7=($)=>$!=="."&&$!==".."&&$.includes("."),l7=/^\.\*+$/,d7=($)=>$!=="."&&$!==".."&&$.startsWith("."),p7=/^\*+$/,i7=($)=>$.length!==0&&!$.startsWith("."),n7=($)=>$.length!==0&&$!=="."&&$!=="..",r7=/^\?+([^+@!?\*\[\(]*)?$/,s7=([$,Q=""])=>{let Z=z5([$]);if(!Q)return Z;return Q=Q.toLowerCase(),(X)=>Z(X)&&X.toLowerCase().endsWith(Q)},o7=([$,Q=""])=>{let Z=U5([$]);if(!Q)return Z;return Q=Q.toLowerCase(),(X)=>Z(X)&&X.toLowerCase().endsWith(Q)},a7=([$,Q=""])=>{let Z=U5([$]);return!Q?Z:(X)=>Z(X)&&X.endsWith(Q)},t7=([$,Q=""])=>{let Z=z5([$]);return!Q?Z:(X)=>Z(X)&&X.endsWith(Q)},z5=([$])=>{let Q=$.length;return(Z)=>Z.length===Q&&!Z.startsWith(".")},U5=([$])=>{let Q=$.length;return(Z)=>Z.length===Q&&Z!=="."&&Z!==".."},M5=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",K5={win32:{sep:"\\"},posix:{sep:"/"}},e7=M5==="win32"?K5.win32.sep:K5.posix.sep;d.sep=e7;var g=Symbol("globstar **");d.GLOBSTAR=g;var $9="[^/]",Q9=$9+"*?",Z9="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",X9="(?:(?!(?:\\/|^)\\.).)*?",q9=($,Q={})=>(Z)=>d(Z,$,Q);d.filter=q9;var r=($,Q={})=>Object.assign({},$,Q),J9=($)=>{if(!$||typeof $!=="object"||!Object.keys($).length)return d;let Q=d;return Object.assign((X,q,J={})=>Q(X,q,r($,J)),{Minimatch:class extends Q.Minimatch{constructor(q,J={}){super(q,r($,J))}static defaults(q){return Q.defaults(r($,q)).Minimatch}},AST:class extends Q.AST{constructor(q,J,Y={}){super(q,J,r($,Y))}static fromGlob(q,J={}){return Q.AST.fromGlob(q,r($,J))}},unescape:(X,q={})=>Q.unescape(X,r($,q)),escape:(X,q={})=>Q.escape(X,r($,q)),filter:(X,q={})=>Q.filter(X,r($,q)),defaults:(X)=>Q.defaults(r($,X)),makeRe:(X,q={})=>Q.makeRe(X,r($,q)),braceExpand:(X,q={})=>Q.braceExpand(X,r($,q)),match:(X,q,J={})=>Q.match(X,q,r($,J)),sep:Q.sep,GLOBSTAR:g})};d.defaults=J9;var O5=($,Q={})=>{if(h0($),Q.nobrace||!/\{(?:(?!\{).)*\}/.test($))return[$];return G5.default($)};d.braceExpand=O5;var Y9=($,Q={})=>new s($,Q).makeRe();d.makeRe=Y9;var V9=($,Q,Z={})=>{let X=new s(Q,Z);if($=$.filter((q)=>X.match(q)),X.options.nonull&&!$.length)$.push(Q);return $};d.match=V9;var _5=/[?*]|[+@!]\(.*?\)|\[|\]/,W9=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class s{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor($,Q={}){if(h0($),Q=Q||{},this.options=Q,this.pattern=$,this.platform=Q.platform||M5,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!Q.windowsPathsNoEscape||Q.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!Q.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!Q.nonegate,this.comment=!1,this.empty=!1,this.partial=!!Q.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=Q.windowsNoMagicRoot!==void 0?Q.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let $ of this.set)for(let Q of $)if(typeof Q!=="string")return!0;return!1}debug(...$){}make(){let $=this.pattern,Q=this.options;if(!Q.nocomment&&$.charAt(0)==="#"){this.comment=!0;return}if(!$){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],Q.debug)this.debug=(...q)=>console.error(...q);this.debug(this.pattern,this.globSet);let Z=this.globSet.map((q)=>this.slashSplit(q));this.globParts=this.preprocess(Z),this.debug(this.pattern,this.globParts);let X=this.globParts.map((q,J,Y)=>{if(this.isWindows&&this.windowsNoMagicRoot){let V=q[0]===""&&q[1]===""&&(q[2]==="?"||!_5.test(q[2]))&&!_5.test(q[3]),W=/^[a-z]:/i.test(q[0]);if(V)return[...q.slice(0,4),...q.slice(4).map((H)=>this.parse(H))];else if(W)return[q[0],...q.slice(1).map((H)=>this.parse(H))]}return q.map((V)=>this.parse(V))});if(this.debug(this.pattern,X),this.set=X.filter((q)=>q.indexOf(!1)===-1),this.isWindows)for(let q=0;q<this.set.length;q++){let J=this.set[q];if(J[0]===""&&J[1]===""&&this.globParts[q][2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]))J[2]="?"}this.debug(this.pattern,this.set)}preprocess($){if(this.options.noglobstar){for(let Z=0;Z<$.length;Z++)for(let X=0;X<$[Z].length;X++)if($[Z][X]==="**")$[Z][X]="*"}let{optimizationLevel:Q=1}=this.options;if(Q>=2)$=this.firstPhasePreProcess($),$=this.secondPhasePreProcess($);else if(Q>=1)$=this.levelOneOptimize($);else $=this.adjascentGlobstarOptimize($);return $}adjascentGlobstarOptimize($){return $.map((Q)=>{let Z=-1;while((Z=Q.indexOf("**",Z+1))!==-1){let X=Z;while(Q[X+1]==="**")X++;if(X!==Z)Q.splice(Z,X-Z)}return Q})}levelOneOptimize($){return $.map((Q)=>{return Q=Q.reduce((Z,X)=>{let q=Z[Z.length-1];if(X==="**"&&q==="**")return Z;if(X===".."){if(q&&q!==".."&&q!=="."&&q!=="**")return Z.pop(),Z}return Z.push(X),Z},[]),Q.length===0?[""]:Q})}levelTwoFileOptimize($){if(!Array.isArray($))$=this.slashSplit($);let Q=!1;do{if(Q=!1,!this.preserveMultipleSlashes){for(let X=1;X<$.length-1;X++){let q=$[X];if(X===1&&q===""&&$[0]==="")continue;if(q==="."||q==="")Q=!0,$.splice(X,1),X--}if($[0]==="."&&$.length===2&&($[1]==="."||$[1]===""))Q=!0,$.pop()}let Z=0;while((Z=$.indexOf("..",Z+1))!==-1){let X=$[Z-1];if(X&&X!=="."&&X!==".."&&X!=="**")Q=!0,$.splice(Z-1,2),Z-=2}}while(Q);return $.length===0?[""]:$}firstPhasePreProcess($){let Q=!1;do{Q=!1;for(let Z of $){let X=-1;while((X=Z.indexOf("**",X+1))!==-1){let J=X;while(Z[J+1]==="**")J++;if(J>X)Z.splice(X+1,J-X);let Y=Z[X+1],V=Z[X+2],W=Z[X+3];if(Y!=="..")continue;if(!V||V==="."||V===".."||!W||W==="."||W==="..")continue;Q=!0,Z.splice(X,1);let H=Z.slice(0);H[X]="**",$.push(H),X--}if(!this.preserveMultipleSlashes){for(let J=1;J<Z.length-1;J++){let Y=Z[J];if(J===1&&Y===""&&Z[0]==="")continue;if(Y==="."||Y==="")Q=!0,Z.splice(J,1),J--}if(Z[0]==="."&&Z.length===2&&(Z[1]==="."||Z[1]===""))Q=!0,Z.pop()}let q=0;while((q=Z.indexOf("..",q+1))!==-1){let J=Z[q-1];if(J&&J!=="."&&J!==".."&&J!=="**"){Q=!0;let V=q===1&&Z[q+1]==="**"?["."]:[];if(Z.splice(q-1,2,...V),Z.length===0)Z.push("");q-=2}}}}while(Q);return $}secondPhasePreProcess($){for(let Q=0;Q<$.length-1;Q++)for(let Z=Q+1;Z<$.length;Z++){let X=this.partsMatch($[Q],$[Z],!this.preserveMultipleSlashes);if(X){$[Q]=[],$[Z]=X;break}}return $.filter((Q)=>Q.length)}partsMatch($,Q,Z=!1){let X=0,q=0,J=[],Y="";while(X<$.length&&q<Q.length)if($[X]===Q[q])J.push(Y==="b"?Q[q]:$[X]),X++,q++;else if(Z&&$[X]==="**"&&Q[q]===$[X+1])J.push($[X]),X++;else if(Z&&Q[q]==="**"&&$[X]===Q[q+1])J.push(Q[q]),q++;else if($[X]==="*"&&Q[q]&&(this.options.dot||!Q[q].startsWith("."))&&Q[q]!=="**"){if(Y==="b")return!1;Y="a",J.push($[X]),X++,q++}else if(Q[q]==="*"&&$[X]&&(this.options.dot||!$[X].startsWith("."))&&$[X]!=="**"){if(Y==="a")return!1;Y="b",J.push(Q[q]),X++,q++}else return!1;return $.length===Q.length&&J}parseNegate(){if(this.nonegate)return;let $=this.pattern,Q=!1,Z=0;for(let X=0;X<$.length&&$.charAt(X)==="!";X++)Q=!Q,Z++;if(Z)this.pattern=$.slice(Z);this.negate=Q}matchOne($,Q,Z=!1){let X=this.options;if(this.isWindows){let O=typeof $[0]==="string"&&/^[a-z]:$/i.test($[0]),z=!O&&$[0]===""&&$[1]===""&&$[2]==="?"&&/^[a-z]:$/i.test($[3]),U=typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0]),A=!U&&Q[0]===""&&Q[1]===""&&Q[2]==="?"&&typeof Q[3]==="string"&&/^[a-z]:$/i.test(Q[3]),L=z?3:O?0:void 0,R=A?3:U?0:void 0;if(typeof L==="number"&&typeof R==="number"){let[T,l]=[$[L],Q[R]];if(T.toLowerCase()===l.toLowerCase()){if(Q[R]=T,R>L)Q=Q.slice(R);else if(L>R)$=$.slice(L)}}}let{optimizationLevel:q=1}=this.options;if(q>=2)$=this.levelTwoFileOptimize($);this.debug("matchOne",this,{file:$,pattern:Q}),this.debug("matchOne",$.length,Q.length);for(var J=0,Y=0,V=$.length,W=Q.length;J<V&&Y<W;J++,Y++){this.debug("matchOne loop");var H=Q[Y],K=$[J];if(this.debug(Q,H,K),H===!1)return!1;if(H===g){this.debug("GLOBSTAR",[Q,H,K]);var _=J,G=Y+1;if(G===W){this.debug("** at the end");for(;J<V;J++)if($[J]==="."||$[J]===".."||!X.dot&&$[J].charAt(0)===".")return!1;return!0}while(_<V){var M=$[_];if(this.debug(`
|
|
5
|
+
globstar while`,$,_,Q,G,M),this.matchOne($.slice(_),Q.slice(G),Z))return this.debug("globstar found match!",_,V,M),!0;else{if(M==="."||M===".."||!X.dot&&M.charAt(0)==="."){this.debug("dot detected!",$,_,Q,G);break}this.debug("globstar swallow a segment, and continue"),_++}}if(Z){if(this.debug(`
|
|
6
|
+
>>> no match, partial?`,$,_,Q,G),_===V)return!0}return!1}let O;if(typeof H==="string")O=K===H,this.debug("string match",H,K,O);else O=H.test(K),this.debug("pattern match",H,K,O);if(!O)return!1}if(J===V&&Y===W)return!0;else if(J===V)return Z;else if(Y===W)return J===V-1&&$[J]==="";else throw Error("wtf?")}braceExpand(){return O5(this.pattern,this.options)}parse($){h0($);let Q=this.options;if($==="**")return g;if($==="")return"";let Z,X=null;if(Z=$.match(p7))X=Q.dot?n7:i7;else if(Z=$.match(v7))X=(Q.nocase?Q.dot?g7:f7:Q.dot?u7:x7)(Z[1]);else if(Z=$.match(r7))X=(Q.nocase?Q.dot?o7:s7:Q.dot?a7:t7)(Z);else if(Z=$.match(h7))X=Q.dot?c7:m7;else if(Z=$.match(l7))X=d7;let q=f.fromGlob($,this.options).toMMPattern();if(X&&typeof q==="object")Reflect.defineProperty(q,"test",{value:X});return q}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let $=this.set;if(!$.length)return this.regexp=!1,this.regexp;let Q=this.options,Z=Q.noglobstar?Q9:Q.dot?Z9:X9,X=new Set(Q.nocase?["i"]:[]),q=$.map((V)=>{let W=V.map((H)=>{if(H instanceof RegExp)for(let K of H.flags.split(""))X.add(K);return typeof H==="string"?W9(H):H===g?g:H._src});return W.forEach((H,K)=>{let _=W[K+1],G=W[K-1];if(H!==g||G===g)return;if(G===void 0)if(_!==void 0&&_!==g)W[K+1]="(?:\\/|"+Z+"\\/)?"+_;else W[K]=Z;else if(_===void 0)W[K-1]=G+"(?:\\/|"+Z+")?";else if(_!==g)W[K-1]=G+"(?:\\/|\\/"+Z+"\\/)"+_,W[K+1]=g}),W.filter((H)=>H!==g).join("/")}).join("|"),[J,Y]=$.length>1?["(?:",")"]:["",""];if(q="^"+J+q+Y+"$",this.negate)q="^(?!"+q+").+$";try{this.regexp=new RegExp(q,[...X].join(""))}catch(V){this.regexp=!1}return this.regexp}slashSplit($){if(this.preserveMultipleSlashes)return $.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test($))return["",...$.split(/\/+/)];else return $.split(/\/+/)}match($,Q=this.partial){if(this.debug("match",$,this.pattern),this.comment)return!1;if(this.empty)return $==="";if($==="/"&&Q)return!0;let Z=this.options;if(this.isWindows)$=$.split("\\").join("/");let X=this.slashSplit($);this.debug(this.pattern,"split",X);let q=this.set;this.debug(this.pattern,"set",q);let J=X[X.length-1];if(!J)for(let Y=X.length-2;!J&&Y>=0;Y--)J=X[Y];for(let Y=0;Y<q.length;Y++){let V=q[Y],W=X;if(Z.matchBase&&V.length===1)W=[J];if(this.matchOne(W,V,Q)){if(Z.flipNegate)return!0;return!this.negate}}if(Z.flipNegate)return!1;return this.negate}static defaults($){return d.defaults($).Minimatch}}d.AST=f;d.Minimatch=s;d.escape=E0;d.unescape=Q0;import{fileURLToPath as h9}from"url";var k0=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,L5=new Set,P$=typeof process==="object"&&!!process?process:{},B5=($,Q,Z,X)=>{typeof P$.emitWarning==="function"?P$.emitWarning($,Q,Z,X):console.error(`[${Z}] ${Q}: ${$}`)},G8=globalThis.AbortController,A5=globalThis.AbortSignal;if(typeof G8>"u"){A5=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(X,q){this._onabort.push(q)}},G8=class{constructor(){Q()}signal=new A5;abort(X){if(this.signal.aborted)return;this.signal.reason=X,this.signal.aborted=!0;for(let q of this.signal._onabort)q(X);this.signal.onabort?.(X)}};let $=P$.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Q=()=>{if(!$)return;$=!1,B5("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",Q)}}var H9=($)=>!L5.has($),b3=Symbol("type"),L0=($)=>$&&$===Math.floor($)&&$>0&&isFinite($),R5=($)=>!L0($)?null:$<=Math.pow(2,8)?Uint8Array:$<=Math.pow(2,16)?Uint16Array:$<=Math.pow(2,32)?Uint32Array:$<=Number.MAX_SAFE_INTEGER?c0:null;class c0 extends Array{constructor($){super($);this.fill(0)}}class D0{heap;length;static#Q=!1;static create($){let Q=R5($);if(!Q)return[];D0.#Q=!0;let Z=new D0($,Q);return D0.#Q=!1,Z}constructor($,Q){if(!D0.#Q)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new Q($),this.length=0}push($){this.heap[this.length++]=$}pop(){return this.heap[--this.length]}}class l0{#Q;#$;#Z;#X;#J;#C;#R;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#H;#G;#W;#_;#q;#O;#M;#U;#A;#T;#B;#F;#V;#I;#K;#j;#L;#P;static unsafeExposeInternals($){return{starts:$.#V,ttls:$.#I,sizes:$.#F,keyMap:$.#W,keyList:$.#_,valList:$.#q,next:$.#O,prev:$.#M,get head(){return $.#U},get tail(){return $.#A},free:$.#T,isBackgroundFetch:(Q)=>$.#z(Q),backgroundFetch:(Q,Z,X,q)=>$.#v(Q,Z,X,q),moveToTail:(Q)=>$.#f(Q),indexes:(Q)=>$.#b(Q),rindexes:(Q)=>$.#N(Q),isStale:(Q)=>$.#S(Q)}}get max(){return this.#Q}get maxSize(){return this.#$}get calculatedSize(){return this.#G}get size(){return this.#H}get fetchMethod(){return this.#C}get memoMethod(){return this.#R}get dispose(){return this.#Z}get onInsert(){return this.#X}get disposeAfter(){return this.#J}constructor($){let{max:Q=0,ttl:Z,ttlResolution:X=1,ttlAutopurge:q,updateAgeOnGet:J,updateAgeOnHas:Y,allowStale:V,dispose:W,onInsert:H,disposeAfter:K,noDisposeOnSet:_,noUpdateTTL:G,maxSize:M=0,maxEntrySize:O=0,sizeCalculation:z,fetchMethod:U,memoMethod:A,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:T,allowStaleOnFetchAbort:l,ignoreFetchAbort:y}=$;if(Q!==0&&!L0(Q))throw TypeError("max option must be a nonnegative integer");let t=Q?R5(Q):Array;if(!t)throw Error("invalid max value: "+Q);if(this.#Q=Q,this.#$=M,this.maxEntrySize=O||this.#$,this.sizeCalculation=z,this.sizeCalculation){if(!this.#$&&!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(A!==void 0&&typeof A!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#R=A,U!==void 0&&typeof U!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#C=U,this.#j=!!U,this.#W=new Map,this.#_=Array(Q).fill(void 0),this.#q=Array(Q).fill(void 0),this.#O=new t(Q),this.#M=new t(Q),this.#U=0,this.#A=0,this.#T=D0.create(Q),this.#H=0,this.#G=0,typeof W==="function")this.#Z=W;if(typeof H==="function")this.#X=H;if(typeof K==="function")this.#J=K,this.#B=[];else this.#J=void 0,this.#B=void 0;if(this.#K=!!this.#Z,this.#P=!!this.#X,this.#L=!!this.#J,this.noDisposeOnSet=!!_,this.noUpdateTTL=!!G,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!T,this.allowStaleOnFetchAbort=!!l,this.ignoreFetchAbort=!!y,this.maxEntrySize!==0){if(this.#$!==0){if(!L0(this.#$))throw TypeError("maxSize must be a positive integer if specified")}if(!L0(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#h()}if(this.allowStale=!!V,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!J,this.updateAgeOnHas=!!Y,this.ttlResolution=L0(X)||X===0?X:1,this.ttlAutopurge=!!q,this.ttl=Z||0,this.ttl){if(!L0(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#Y()}if(this.#Q===0&&this.ttl===0&&this.#$===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Q&&!this.#$){if(H9("LRU_CACHE_UNBOUNDED"))L5.add("LRU_CACHE_UNBOUNDED"),B5("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",l0)}}getRemainingTTL($){return this.#W.has($)?1/0:0}#Y(){let $=new c0(this.#Q),Q=new c0(this.#Q);this.#I=$,this.#V=Q,this.#E=(q,J,Y=k0.now())=>{if(Q[q]=J!==0?Y:0,$[q]=J,J!==0&&this.ttlAutopurge){let V=setTimeout(()=>{if(this.#S(q))this.#k(this.#_[q],"expire")},J+1);if(V.unref)V.unref()}},this.#D=(q)=>{Q[q]=$[q]!==0?k0.now():0},this.#w=(q,J)=>{if($[J]){let Y=$[J],V=Q[J];if(!Y||!V)return;q.ttl=Y,q.start=V,q.now=Z||X();let W=q.now-V;q.remainingTTL=Y-W}};let Z=0,X=()=>{let q=k0.now();if(this.ttlResolution>0){Z=q;let J=setTimeout(()=>Z=0,this.ttlResolution);if(J.unref)J.unref()}return q};this.getRemainingTTL=(q)=>{let J=this.#W.get(q);if(J===void 0)return 0;let Y=$[J],V=Q[J];if(!Y||!V)return 1/0;let W=(Z||X())-V;return Y-W},this.#S=(q)=>{let J=Q[q],Y=$[q];return!!Y&&!!J&&(Z||X())-J>Y}}#D=()=>{};#w=()=>{};#E=()=>{};#S=()=>!1;#h(){let $=new c0(this.#Q);this.#G=0,this.#F=$,this.#y=(Q)=>{this.#G-=$[Q],$[Q]=0},this.#m=(Q,Z,X,q)=>{if(this.#z(Z))return 0;if(!L0(X))if(q){if(typeof q!=="function")throw TypeError("sizeCalculation must be a function");if(X=q(Z,Q),!L0(X))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 X},this.#x=(Q,Z,X)=>{if($[Q]=Z,this.#$){let q=this.#$-$[Q];while(this.#G>q)this.#u(!0)}if(this.#G+=$[Q],X)X.entrySize=Z,X.totalCalculatedSize=this.#G}}#y=($)=>{};#x=($,Q,Z)=>{};#m=($,Q,Z,X)=>{if(Z||X)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#b({allowStale:$=this.allowStale}={}){if(this.#H)for(let Q=this.#A;;){if(!this.#c(Q))break;if($||!this.#S(Q))yield Q;if(Q===this.#U)break;else Q=this.#M[Q]}}*#N({allowStale:$=this.allowStale}={}){if(this.#H)for(let Q=this.#U;;){if(!this.#c(Q))break;if($||!this.#S(Q))yield Q;if(Q===this.#A)break;else Q=this.#O[Q]}}#c($){return $!==void 0&&this.#W.get(this.#_[$])===$}*entries(){for(let $ of this.#b())if(this.#q[$]!==void 0&&this.#_[$]!==void 0&&!this.#z(this.#q[$]))yield[this.#_[$],this.#q[$]]}*rentries(){for(let $ of this.#N())if(this.#q[$]!==void 0&&this.#_[$]!==void 0&&!this.#z(this.#q[$]))yield[this.#_[$],this.#q[$]]}*keys(){for(let $ of this.#b()){let Q=this.#_[$];if(Q!==void 0&&!this.#z(this.#q[$]))yield Q}}*rkeys(){for(let $ of this.#N()){let Q=this.#_[$];if(Q!==void 0&&!this.#z(this.#q[$]))yield Q}}*values(){for(let $ of this.#b())if(this.#q[$]!==void 0&&!this.#z(this.#q[$]))yield this.#q[$]}*rvalues(){for(let $ of this.#N())if(this.#q[$]!==void 0&&!this.#z(this.#q[$]))yield this.#q[$]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find($,Q={}){for(let Z of this.#b()){let X=this.#q[Z],q=this.#z(X)?X.__staleWhileFetching:X;if(q===void 0)continue;if($(q,this.#_[Z],this))return this.get(this.#_[Z],Q)}}forEach($,Q=this){for(let Z of this.#b()){let X=this.#q[Z],q=this.#z(X)?X.__staleWhileFetching:X;if(q===void 0)continue;$.call(Q,q,this.#_[Z],this)}}rforEach($,Q=this){for(let Z of this.#N()){let X=this.#q[Z],q=this.#z(X)?X.__staleWhileFetching:X;if(q===void 0)continue;$.call(Q,q,this.#_[Z],this)}}purgeStale(){let $=!1;for(let Q of this.#N({allowStale:!0}))if(this.#S(Q))this.#k(this.#_[Q],"expire"),$=!0;return $}info($){let Q=this.#W.get($);if(Q===void 0)return;let Z=this.#q[Q],X=this.#z(Z)?Z.__staleWhileFetching:Z;if(X===void 0)return;let q={value:X};if(this.#I&&this.#V){let J=this.#I[Q],Y=this.#V[Q];if(J&&Y){let V=J-(k0.now()-Y);q.ttl=V,q.start=Date.now()}}if(this.#F)q.size=this.#F[Q];return q}dump(){let $=[];for(let Q of this.#b({allowStale:!0})){let Z=this.#_[Q],X=this.#q[Q],q=this.#z(X)?X.__staleWhileFetching:X;if(q===void 0||Z===void 0)continue;let J={value:q};if(this.#I&&this.#V){J.ttl=this.#I[Q];let Y=k0.now()-this.#V[Q];J.start=Math.floor(Date.now()-Y)}if(this.#F)J.size=this.#F[Q];$.unshift([Z,J])}return $}load($){this.clear();for(let[Q,Z]of $){if(Z.start){let X=Date.now()-Z.start;Z.start=k0.now()-X}this.set(Q,Z.value,Z)}}set($,Q,Z={}){if(Q===void 0)return this.delete($),this;let{ttl:X=this.ttl,start:q,noDisposeOnSet:J=this.noDisposeOnSet,sizeCalculation:Y=this.sizeCalculation,status:V}=Z,{noUpdateTTL:W=this.noUpdateTTL}=Z,H=this.#m($,Q,Z.size||0,Y);if(this.maxEntrySize&&H>this.maxEntrySize){if(V)V.set="miss",V.maxEntrySizeExceeded=!0;return this.#k($,"set"),this}let K=this.#H===0?void 0:this.#W.get($);if(K===void 0){if(K=this.#H===0?this.#A:this.#T.length!==0?this.#T.pop():this.#H===this.#Q?this.#u(!1):this.#H,this.#_[K]=$,this.#q[K]=Q,this.#W.set($,K),this.#O[this.#A]=K,this.#M[K]=this.#A,this.#A=K,this.#H++,this.#x(K,H,V),V)V.set="add";if(W=!1,this.#P)this.#X?.(Q,$,"add")}else{this.#f(K);let _=this.#q[K];if(Q!==_){if(this.#j&&this.#z(_)){_.__abortController.abort(Error("replaced"));let{__staleWhileFetching:G}=_;if(G!==void 0&&!J){if(this.#K)this.#Z?.(G,$,"set");if(this.#L)this.#B?.push([G,$,"set"])}}else if(!J){if(this.#K)this.#Z?.(_,$,"set");if(this.#L)this.#B?.push([_,$,"set"])}if(this.#y(K),this.#x(K,H,V),this.#q[K]=Q,V){V.set="replace";let G=_&&this.#z(_)?_.__staleWhileFetching:_;if(G!==void 0)V.oldValue=G}}else if(V)V.set="update";if(this.#P)this.onInsert?.(Q,$,Q===_?"update":"replace")}if(X!==0&&!this.#I)this.#Y();if(this.#I){if(!W)this.#E(K,X,q);if(V)this.#w(V,K)}if(!J&&this.#L&&this.#B){let _=this.#B,G;while(G=_?.shift())this.#J?.(...G)}return this}pop(){try{while(this.#H){let $=this.#q[this.#U];if(this.#u(!0),this.#z($)){if($.__staleWhileFetching)return $.__staleWhileFetching}else if($!==void 0)return $}}finally{if(this.#L&&this.#B){let $=this.#B,Q;while(Q=$?.shift())this.#J?.(...Q)}}}#u($){let Q=this.#U,Z=this.#_[Q],X=this.#q[Q];if(this.#j&&this.#z(X))X.__abortController.abort(Error("evicted"));else if(this.#K||this.#L){if(this.#K)this.#Z?.(X,Z,"evict");if(this.#L)this.#B?.push([X,Z,"evict"])}if(this.#y(Q),$)this.#_[Q]=void 0,this.#q[Q]=void 0,this.#T.push(Q);if(this.#H===1)this.#U=this.#A=0,this.#T.length=0;else this.#U=this.#O[Q];return this.#W.delete(Z),this.#H--,Q}has($,Q={}){let{updateAgeOnHas:Z=this.updateAgeOnHas,status:X}=Q,q=this.#W.get($);if(q!==void 0){let J=this.#q[q];if(this.#z(J)&&J.__staleWhileFetching===void 0)return!1;if(!this.#S(q)){if(Z)this.#D(q);if(X)X.has="hit",this.#w(X,q);return!0}else if(X)X.has="stale",this.#w(X,q)}else if(X)X.has="miss";return!1}peek($,Q={}){let{allowStale:Z=this.allowStale}=Q,X=this.#W.get($);if(X===void 0||!Z&&this.#S(X))return;let q=this.#q[X];return this.#z(q)?q.__staleWhileFetching:q}#v($,Q,Z,X){let q=Q===void 0?void 0:this.#q[Q];if(this.#z(q))return q;let J=new G8,{signal:Y}=Z;Y?.addEventListener("abort",()=>J.abort(Y.reason),{signal:J.signal});let V={signal:J.signal,options:Z,context:X},W=(O,z=!1)=>{let{aborted:U}=J.signal,A=Z.ignoreFetchAbort&&O!==void 0;if(Z.status)if(U&&!z){if(Z.status.fetchAborted=!0,Z.status.fetchError=J.signal.reason,A)Z.status.fetchAbortIgnored=!0}else Z.status.fetchResolved=!0;if(U&&!A&&!z)return K(J.signal.reason);let L=G;if(this.#q[Q]===G)if(O===void 0)if(L.__staleWhileFetching)this.#q[Q]=L.__staleWhileFetching;else this.#k($,"fetch");else{if(Z.status)Z.status.fetchUpdated=!0;this.set($,O,V.options)}return O},H=(O)=>{if(Z.status)Z.status.fetchRejected=!0,Z.status.fetchError=O;return K(O)},K=(O)=>{let{aborted:z}=J.signal,U=z&&Z.allowStaleOnFetchAbort,A=U||Z.allowStaleOnFetchRejection,L=A||Z.noDeleteOnFetchRejection,R=G;if(this.#q[Q]===G){if(!L||R.__staleWhileFetching===void 0)this.#k($,"fetch");else if(!U)this.#q[Q]=R.__staleWhileFetching}if(A){if(Z.status&&R.__staleWhileFetching!==void 0)Z.status.returnedStale=!0;return R.__staleWhileFetching}else if(R.__returned===R)throw O},_=(O,z)=>{let U=this.#C?.($,q,V);if(U&&U instanceof Promise)U.then((A)=>O(A===void 0?void 0:A),z);J.signal.addEventListener("abort",()=>{if(!Z.ignoreFetchAbort||Z.allowStaleOnFetchAbort){if(O(void 0),Z.allowStaleOnFetchAbort)O=(A)=>W(A,!0)}})};if(Z.status)Z.status.fetchDispatched=!0;let G=new Promise(_).then(W,H),M=Object.assign(G,{__abortController:J,__staleWhileFetching:q,__returned:void 0});if(Q===void 0)this.set($,M,{...V.options,status:void 0}),Q=this.#W.get($);else this.#q[Q]=M;return M}#z($){if(!this.#j)return!1;let Q=$;return!!Q&&Q instanceof Promise&&Q.hasOwnProperty("__staleWhileFetching")&&Q.__abortController instanceof G8}async fetch($,Q={}){let{allowStale:Z=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:q=this.noDeleteOnStaleGet,ttl:J=this.ttl,noDisposeOnSet:Y=this.noDisposeOnSet,size:V=0,sizeCalculation:W=this.sizeCalculation,noUpdateTTL:H=this.noUpdateTTL,noDeleteOnFetchRejection:K=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:_=this.allowStaleOnFetchRejection,ignoreFetchAbort:G=this.ignoreFetchAbort,allowStaleOnFetchAbort:M=this.allowStaleOnFetchAbort,context:O,forceRefresh:z=!1,status:U,signal:A}=Q;if(!this.#j){if(U)U.fetch="get";return this.get($,{allowStale:Z,updateAgeOnGet:X,noDeleteOnStaleGet:q,status:U})}let L={allowStale:Z,updateAgeOnGet:X,noDeleteOnStaleGet:q,ttl:J,noDisposeOnSet:Y,size:V,sizeCalculation:W,noUpdateTTL:H,noDeleteOnFetchRejection:K,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:M,ignoreFetchAbort:G,status:U,signal:A},R=this.#W.get($);if(R===void 0){if(U)U.fetch="miss";let T=this.#v($,R,L,O);return T.__returned=T}else{let T=this.#q[R];if(this.#z(T)){let e=Z&&T.__staleWhileFetching!==void 0;if(U){if(U.fetch="inflight",e)U.returnedStale=!0}return e?T.__staleWhileFetching:T.__returned=T}let l=this.#S(R);if(!z&&!l){if(U)U.fetch="hit";if(this.#f(R),X)this.#D(R);if(U)this.#w(U,R);return T}let y=this.#v($,R,L,O),S0=y.__staleWhileFetching!==void 0&&Z;if(U){if(U.fetch=l?"stale":"refresh",S0&&l)U.returnedStale=!0}return S0?y.__staleWhileFetching:y.__returned=y}}async forceFetch($,Q={}){let Z=await this.fetch($,Q);if(Z===void 0)throw Error("fetch() returned undefined");return Z}memo($,Q={}){let Z=this.#R;if(!Z)throw Error("no memoMethod provided to constructor");let{context:X,forceRefresh:q,...J}=Q,Y=this.get($,J);if(!q&&Y!==void 0)return Y;let V=Z($,Y,{options:J,context:X});return this.set($,V,J),V}get($,Q={}){let{allowStale:Z=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:q=this.noDeleteOnStaleGet,status:J}=Q,Y=this.#W.get($);if(Y!==void 0){let V=this.#q[Y],W=this.#z(V);if(J)this.#w(J,Y);if(this.#S(Y)){if(J)J.get="stale";if(!W){if(!q)this.#k($,"expire");if(J&&Z)J.returnedStale=!0;return Z?V:void 0}else{if(J&&Z&&V.__staleWhileFetching!==void 0)J.returnedStale=!0;return Z?V.__staleWhileFetching:void 0}}else{if(J)J.get="hit";if(W)return V.__staleWhileFetching;if(this.#f(Y),X)this.#D(Y);return V}}else if(J)J.get="miss"}#l($,Q){this.#M[Q]=$,this.#O[$]=Q}#f($){if($!==this.#A){if($===this.#U)this.#U=this.#O[$];else this.#l(this.#M[$],this.#O[$]);this.#l(this.#A,$),this.#A=$}}delete($){return this.#k($,"delete")}#k($,Q){let Z=!1;if(this.#H!==0){let X=this.#W.get($);if(X!==void 0)if(Z=!0,this.#H===1)this.#g(Q);else{this.#y(X);let q=this.#q[X];if(this.#z(q))q.__abortController.abort(Error("deleted"));else if(this.#K||this.#L){if(this.#K)this.#Z?.(q,$,Q);if(this.#L)this.#B?.push([q,$,Q])}if(this.#W.delete($),this.#_[X]=void 0,this.#q[X]=void 0,X===this.#A)this.#A=this.#M[X];else if(X===this.#U)this.#U=this.#O[X];else{let J=this.#M[X];this.#O[J]=this.#O[X];let Y=this.#O[X];this.#M[Y]=this.#M[X]}this.#H--,this.#T.push(X)}}if(this.#L&&this.#B?.length){let X=this.#B,q;while(q=X?.shift())this.#J?.(...q)}return Z}clear(){return this.#g("delete")}#g($){for(let Q of this.#N({allowStale:!0})){let Z=this.#q[Q];if(this.#z(Z))Z.__abortController.abort(Error("deleted"));else{let X=this.#_[Q];if(this.#K)this.#Z?.(Z,X,$);if(this.#L)this.#B?.push([Z,X,$])}}if(this.#W.clear(),this.#q.fill(void 0),this.#_.fill(void 0),this.#I&&this.#V)this.#I.fill(0),this.#V.fill(0);if(this.#F)this.#F.fill(0);if(this.#U=0,this.#A=0,this.#T.length=0,this.#G=0,this.#H=0,this.#L&&this.#B){let Q=this.#B,Z;while(Z=Q?.shift())this.#J?.(...Z)}}}import{posix as R9,win32 as h$}from"path";import{fileURLToPath as C9}from"url";import{lstatSync as I9,readdir as F9,readdirSync as T9,readlinkSync as j9,realpathSync as w9}from"fs";import*as S9 from"fs";import{lstat as N9,readdir as P9,readlink as E9,realpath as k9}from"fs/promises";import{EventEmitter as x$}from"events";import j5 from"stream";import{StringDecoder as K9}from"string_decoder";var C5=typeof process==="object"&&process?process:{stdout:null,stderr:null},_9=($)=>!!$&&typeof $==="object"&&($ instanceof j0||$ instanceof j5||G9($)||z9($)),G9=($)=>!!$&&typeof $==="object"&&$ instanceof x$&&typeof $.pipe==="function"&&$.pipe!==j5.Writable.prototype.pipe,z9=($)=>!!$&&typeof $==="object"&&$ instanceof x$&&typeof $.write==="function"&&typeof $.end==="function",z0=Symbol("EOF"),U0=Symbol("maybeEmitEnd"),B0=Symbol("emittedEnd"),z8=Symbol("emittingEnd"),d0=Symbol("emittedError"),U8=Symbol("closed"),I5=Symbol("read"),M8=Symbol("flush"),F5=Symbol("flushChunk"),Z0=Symbol("encoding"),y0=Symbol("decoder"),v=Symbol("flowing"),p0=Symbol("paused"),v0=Symbol("resume"),x=Symbol("buffer"),p=Symbol("pipes"),u=Symbol("bufferLength"),E$=Symbol("bufferPush"),O8=Symbol("bufferShift"),c=Symbol("objectMode"),E=Symbol("destroyed"),k$=Symbol("error"),D$=Symbol("emitData"),T5=Symbol("emitEnd"),y$=Symbol("emitEnd2"),Y0=Symbol("async"),v$=Symbol("abort"),A8=Symbol("aborted"),i0=Symbol("signal"),T0=Symbol("dataListeners"),n=Symbol("discarded"),n0=($)=>Promise.resolve().then($),U9=($)=>$(),M9=($)=>$==="end"||$==="finish"||$==="prefinish",O9=($)=>$ instanceof ArrayBuffer||!!$&&typeof $==="object"&&$.constructor&&$.constructor.name==="ArrayBuffer"&&$.byteLength>=0,A9=($)=>!Buffer.isBuffer($)&&ArrayBuffer.isView($);class u${src;dest;opts;ondrain;constructor($,Q,Z){this.src=$,this.dest=Q,this.opts=Z,this.ondrain=()=>$[v0](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors($){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class w5 extends u${unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor($,Q,Z){super($,Q,Z);this.proxyErrors=(X)=>Q.emit("error",X),$.on("error",this.proxyErrors)}}var L9=($)=>!!$.objectMode,B9=($)=>!$.objectMode&&!!$.encoding&&$.encoding!=="buffer";class j0 extends x${[v]=!1;[p0]=!1;[p]=[];[x]=[];[c];[Z0];[Y0];[y0];[z0]=!1;[B0]=!1;[z8]=!1;[U8]=!1;[d0]=null;[u]=0;[E]=!1;[i0];[A8]=!1;[T0]=0;[n]=!1;writable=!0;readable=!0;constructor(...$){let Q=$[0]||{};super();if(Q.objectMode&&typeof Q.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(L9(Q))this[c]=!0,this[Z0]=null;else if(B9(Q))this[Z0]=Q.encoding,this[c]=!1;else this[c]=!1,this[Z0]=null;if(this[Y0]=!!Q.async,this[y0]=this[Z0]?new K9(this[Z0]):null,Q&&Q.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[x]});if(Q&&Q.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[p]});let{signal:Z}=Q;if(Z)if(this[i0]=Z,Z.aborted)this[v$]();else Z.addEventListener("abort",()=>this[v$]())}get bufferLength(){return this[u]}get encoding(){return this[Z0]}set encoding($){throw Error("Encoding must be set at instantiation time")}setEncoding($){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[c]}set objectMode($){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[Y0]}set["async"]($){this[Y0]=this[Y0]||!!$}[v$](){this[A8]=!0,this.emit("abort",this[i0]?.reason),this.destroy(this[i0]?.reason)}get aborted(){return this[A8]}set aborted($){}write($,Q,Z){if(this[A8])return!1;if(this[z0])throw Error("write after end");if(this[E])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Q==="function")Z=Q,Q="utf8";if(!Q)Q="utf8";let X=this[Y0]?n0:U9;if(!this[c]&&!Buffer.isBuffer($)){if(A9($))$=Buffer.from($.buffer,$.byteOffset,$.byteLength);else if(O9($))$=Buffer.from($);else if(typeof $!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[c]){if(this[v]&&this[u]!==0)this[M8](!0);if(this[v])this.emit("data",$);else this[E$]($);if(this[u]!==0)this.emit("readable");if(Z)X(Z);return this[v]}if(!$.length){if(this[u]!==0)this.emit("readable");if(Z)X(Z);return this[v]}if(typeof $==="string"&&!(Q===this[Z0]&&!this[y0]?.lastNeed))$=Buffer.from($,Q);if(Buffer.isBuffer($)&&this[Z0])$=this[y0].write($);if(this[v]&&this[u]!==0)this[M8](!0);if(this[v])this.emit("data",$);else this[E$]($);if(this[u]!==0)this.emit("readable");if(Z)X(Z);return this[v]}read($){if(this[E])return null;if(this[n]=!1,this[u]===0||$===0||$&&$>this[u])return this[U0](),null;if(this[c])$=null;if(this[x].length>1&&!this[c])this[x]=[this[Z0]?this[x].join(""):Buffer.concat(this[x],this[u])];let Q=this[I5]($||null,this[x][0]);return this[U0](),Q}[I5]($,Q){if(this[c])this[O8]();else{let Z=Q;if($===Z.length||$===null)this[O8]();else if(typeof Z==="string")this[x][0]=Z.slice($),Q=Z.slice(0,$),this[u]-=$;else this[x][0]=Z.subarray($),Q=Z.subarray(0,$),this[u]-=$}if(this.emit("data",Q),!this[x].length&&!this[z0])this.emit("drain");return Q}end($,Q,Z){if(typeof $==="function")Z=$,$=void 0;if(typeof Q==="function")Z=Q,Q="utf8";if($!==void 0)this.write($,Q);if(Z)this.once("end",Z);if(this[z0]=!0,this.writable=!1,this[v]||!this[p0])this[U0]();return this}[v0](){if(this[E])return;if(!this[T0]&&!this[p].length)this[n]=!0;if(this[p0]=!1,this[v]=!0,this.emit("resume"),this[x].length)this[M8]();else if(this[z0])this[U0]();else this.emit("drain")}resume(){return this[v0]()}pause(){this[v]=!1,this[p0]=!0,this[n]=!1}get destroyed(){return this[E]}get flowing(){return this[v]}get paused(){return this[p0]}[E$]($){if(this[c])this[u]+=1;else this[u]+=$.length;this[x].push($)}[O8](){if(this[c])this[u]-=1;else this[u]-=this[x][0].length;return this[x].shift()}[M8]($=!1){do;while(this[F5](this[O8]())&&this[x].length);if(!$&&!this[x].length&&!this[z0])this.emit("drain")}[F5]($){return this.emit("data",$),this[v]}pipe($,Q){if(this[E])return $;this[n]=!1;let Z=this[B0];if(Q=Q||{},$===C5.stdout||$===C5.stderr)Q.end=!1;else Q.end=Q.end!==!1;if(Q.proxyErrors=!!Q.proxyErrors,Z){if(Q.end)$.end()}else if(this[p].push(!Q.proxyErrors?new u$(this,$,Q):new w5(this,$,Q)),this[Y0])n0(()=>this[v0]());else this[v0]();return $}unpipe($){let Q=this[p].find((Z)=>Z.dest===$);if(Q){if(this[p].length===1){if(this[v]&&this[T0]===0)this[v]=!1;this[p]=[]}else this[p].splice(this[p].indexOf(Q),1);Q.unpipe()}}addListener($,Q){return this.on($,Q)}on($,Q){let Z=super.on($,Q);if($==="data"){if(this[n]=!1,this[T0]++,!this[p].length&&!this[v])this[v0]()}else if($==="readable"&&this[u]!==0)super.emit("readable");else if(M9($)&&this[B0])super.emit($),this.removeAllListeners($);else if($==="error"&&this[d0]){let X=Q;if(this[Y0])n0(()=>X.call(this,this[d0]));else X.call(this,this[d0])}return Z}removeListener($,Q){return this.off($,Q)}off($,Q){let Z=super.off($,Q);if($==="data"){if(this[T0]=this.listeners("data").length,this[T0]===0&&!this[n]&&!this[p].length)this[v]=!1}return Z}removeAllListeners($){let Q=super.removeAllListeners($);if($==="data"||$===void 0){if(this[T0]=0,!this[n]&&!this[p].length)this[v]=!1}return Q}get emittedEnd(){return this[B0]}[U0](){if(!this[z8]&&!this[B0]&&!this[E]&&this[x].length===0&&this[z0]){if(this[z8]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[U8])this.emit("close");this[z8]=!1}}emit($,...Q){let Z=Q[0];if($!=="error"&&$!=="close"&&$!==E&&this[E])return!1;else if($==="data")return!this[c]&&!Z?!1:this[Y0]?(n0(()=>this[D$](Z)),!0):this[D$](Z);else if($==="end")return this[T5]();else if($==="close"){if(this[U8]=!0,!this[B0]&&!this[E])return!1;let q=super.emit("close");return this.removeAllListeners("close"),q}else if($==="error"){this[d0]=Z,super.emit(k$,Z);let q=!this[i0]||this.listeners("error").length?super.emit("error",Z):!1;return this[U0](),q}else if($==="resume"){let q=super.emit("resume");return this[U0](),q}else if($==="finish"||$==="prefinish"){let q=super.emit($);return this.removeAllListeners($),q}let X=super.emit($,...Q);return this[U0](),X}[D$]($){for(let Z of this[p])if(Z.dest.write($)===!1)this.pause();let Q=this[n]?!1:super.emit("data",$);return this[U0](),Q}[T5](){if(this[B0])return!1;return this[B0]=!0,this.readable=!1,this[Y0]?(n0(()=>this[y$]()),!0):this[y$]()}[y$](){if(this[y0]){let Q=this[y0].end();if(Q){for(let Z of this[p])Z.dest.write(Q);if(!this[n])super.emit("data",Q)}}for(let Q of this[p])Q.end();let $=super.emit("end");return this.removeAllListeners("end"),$}async collect(){let $=Object.assign([],{dataLength:0});if(!this[c])$.dataLength=0;let Q=this.promise();return this.on("data",(Z)=>{if($.push(Z),!this[c])$.dataLength+=Z.length}),await Q,$}async concat(){if(this[c])throw Error("cannot concat in objectMode");let $=await this.collect();return this[Z0]?$.join(""):Buffer.concat($,$.dataLength)}async promise(){return new Promise(($,Q)=>{this.on(E,()=>Q(Error("stream destroyed"))),this.on("error",(Z)=>Q(Z)),this.on("end",()=>$())})}[Symbol.asyncIterator](){this[n]=!1;let $=!1,Q=async()=>{return this.pause(),$=!0,{value:void 0,done:!0}};return{next:()=>{if($)return Q();let X=this.read();if(X!==null)return Promise.resolve({done:!1,value:X});if(this[z0])return Q();let q,J,Y=(K)=>{this.off("data",V),this.off("end",W),this.off(E,H),Q(),J(K)},V=(K)=>{this.off("error",Y),this.off("end",W),this.off(E,H),this.pause(),q({value:K,done:!!this[z0]})},W=()=>{this.off("error",Y),this.off("data",V),this.off(E,H),Q(),q({done:!0,value:void 0})},H=()=>Y(Error("stream destroyed"));return new Promise((K,_)=>{J=_,q=K,this.once(E,H),this.once("error",Y),this.once("end",W),this.once("data",V)})},throw:Q,return:Q,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[n]=!1;let $=!1,Q=()=>{return this.pause(),this.off(k$,Q),this.off(E,Q),this.off("end",Q),$=!0,{done:!0,value:void 0}},Z=()=>{if($)return Q();let X=this.read();return X===null?Q():{done:!1,value:X}};return this.once("end",Q),this.once(k$,Q),this.once(E,Q),{next:Z,throw:Q,return:Q,[Symbol.iterator](){return this}}}destroy($){if(this[E]){if($)this.emit("error",$);else this.emit(E);return this}this[E]=!0,this[n]=!0,this[x].length=0,this[u]=0;let Q=this;if(typeof Q.close==="function"&&!this[U8])Q.close();if($)this.emit("error",$);else this.emit(E);return this}static get isStream(){return _9}}var b9=w9.native,s0={lstatSync:I9,readdir:F9,readdirSync:T9,readlinkSync:j9,realpathSync:b9,promises:{lstat:N9,readdir:P9,readlink:E9,realpath:k9}},E5=($)=>!$||$===s0||$===S9?s0:{...s0,...$,promises:{...s0.promises,...$.promises||{}}},k5=/^\\\\\?\\([a-z]:)\\?$/i,D9=($)=>$.replace(/\//g,"\\").replace(k5,"$1\\"),y9=/[\\\/]/,a=0,D5=1,y5=2,V0=4,v5=6,x5=8,w0=10,u5=12,o=15,r0=~o,f$=16,S5=32,o0=64,X0=128,L8=256,R8=512,b5=o0|X0|R8,v9=1023,g$=($)=>$.isFile()?x5:$.isDirectory()?V0:$.isSymbolicLink()?w0:$.isCharacterDevice()?y5:$.isBlockDevice()?v5:$.isSocket()?u5:$.isFIFO()?D5:a,N5=new Map,a0=($)=>{let Q=N5.get($);if(Q)return Q;let Z=$.normalize("NFKD");return N5.set($,Z),Z},P5=new Map,B8=($)=>{let Q=P5.get($);if(Q)return Q;let Z=a0($.toLowerCase());return P5.set($,Z),Z};class m$ extends l0{constructor(){super({max:256})}}class f5 extends l0{constructor($=16384){super({maxSize:$,sizeCalculation:(Q)=>Q.length+1})}}var g5=Symbol("PathScurry setAsCwd");class i{name;root;roots;parent;nocase;isCWD=!1;#Q;#$;get dev(){return this.#$}#Z;get mode(){return this.#Z}#X;get nlink(){return this.#X}#J;get uid(){return this.#J}#C;get gid(){return this.#C}#R;get rdev(){return this.#R}#H;get blksize(){return this.#H}#G;get ino(){return this.#G}#W;get size(){return this.#W}#_;get blocks(){return this.#_}#q;get atimeMs(){return this.#q}#O;get mtimeMs(){return this.#O}#M;get ctimeMs(){return this.#M}#U;get birthtimeMs(){return this.#U}#A;get atime(){return this.#A}#T;get mtime(){return this.#T}#B;get ctime(){return this.#B}#F;get birthtime(){return this.#F}#V;#I;#K;#j;#L;#P;#Y;#D;#w;#E;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor($,Q=a,Z,X,q,J,Y){if(this.name=$,this.#V=q?B8($):a0($),this.#Y=Q&v9,this.nocase=q,this.roots=X,this.root=Z||this,this.#D=J,this.#K=Y.fullpath,this.#L=Y.relative,this.#P=Y.relativePosix,this.parent=Y.parent,this.parent)this.#Q=this.parent.#Q;else this.#Q=E5(Y.fs)}depth(){if(this.#I!==void 0)return this.#I;if(!this.parent)return this.#I=0;return this.#I=this.parent.depth()+1}childrenCache(){return this.#D}resolve($){if(!$)return this;let Q=this.getRootString($),X=$.substring(Q.length).split(this.splitSep);return Q?this.getRoot(Q).#S(X):this.#S(X)}#S($){let Q=this;for(let Z of $)Q=Q.child(Z);return Q}children(){let $=this.#D.get(this);if($)return $;let Q=Object.assign([],{provisional:0});return this.#D.set(this,Q),this.#Y&=~f$,Q}child($,Q){if($===""||$===".")return this;if($==="..")return this.parent||this;let Z=this.children(),X=this.nocase?B8($):a0($);for(let V of Z)if(V.#V===X)return V;let q=this.parent?this.sep:"",J=this.#K?this.#K+q+$:void 0,Y=this.newChild($,a,{...Q,parent:this,fullpath:J});if(!this.canReaddir())Y.#Y|=X0;return Z.push(Y),Y}relative(){if(this.isCWD)return"";if(this.#L!==void 0)return this.#L;let $=this.name,Q=this.parent;if(!Q)return this.#L=this.name;let Z=Q.relative();return Z+(!Z||!Q.parent?"":this.sep)+$}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#P!==void 0)return this.#P;let $=this.name,Q=this.parent;if(!Q)return this.#P=this.fullpathPosix();let Z=Q.relativePosix();return Z+(!Z||!Q.parent?"":"/")+$}fullpath(){if(this.#K!==void 0)return this.#K;let $=this.name,Q=this.parent;if(!Q)return this.#K=this.name;let X=Q.fullpath()+(!Q.parent?"":this.sep)+$;return this.#K=X}fullpathPosix(){if(this.#j!==void 0)return this.#j;if(this.sep==="/")return this.#j=this.fullpath();if(!this.parent){let X=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(X))return this.#j=`//?/${X}`;else return this.#j=X}let $=this.parent,Q=$.fullpathPosix(),Z=Q+(!Q||!$.parent?"":"/")+this.name;return this.#j=Z}isUnknown(){return(this.#Y&o)===a}isType($){return this[`is${$}`]()}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.#Y&o)===x5}isDirectory(){return(this.#Y&o)===V0}isCharacterDevice(){return(this.#Y&o)===y5}isBlockDevice(){return(this.#Y&o)===v5}isFIFO(){return(this.#Y&o)===D5}isSocket(){return(this.#Y&o)===u5}isSymbolicLink(){return(this.#Y&w0)===w0}lstatCached(){return this.#Y&S5?this:void 0}readlinkCached(){return this.#w}realpathCached(){return this.#E}readdirCached(){let $=this.children();return $.slice(0,$.provisional)}canReadlink(){if(this.#w)return!0;if(!this.parent)return!1;let $=this.#Y&o;return!($!==a&&$!==w0||this.#Y&L8||this.#Y&X0)}calledReaddir(){return!!(this.#Y&f$)}isENOENT(){return!!(this.#Y&X0)}isNamed($){return!this.nocase?this.#V===a0($):this.#V===B8($)}async readlink(){let $=this.#w;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Q=await this.#Q.promises.readlink(this.fullpath()),Z=(await this.parent.realpath())?.resolve(Q);if(Z)return this.#w=Z}catch(Q){this.#u(Q.code);return}}readlinkSync(){let $=this.#w;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Q=this.#Q.readlinkSync(this.fullpath()),Z=this.parent.realpathSync()?.resolve(Q);if(Z)return this.#w=Z}catch(Q){this.#u(Q.code);return}}#h($){this.#Y|=f$;for(let Q=$.provisional;Q<$.length;Q++){let Z=$[Q];if(Z)Z.#y()}}#y(){if(this.#Y&X0)return;this.#Y=(this.#Y|X0)&r0,this.#x()}#x(){let $=this.children();$.provisional=0;for(let Q of $)Q.#y()}#m(){this.#Y|=R8,this.#b()}#b(){if(this.#Y&o0)return;let $=this.#Y;if(($&o)===V0)$&=r0;this.#Y=$|o0,this.#x()}#N($=""){if($==="ENOTDIR"||$==="EPERM")this.#b();else if($==="ENOENT")this.#y();else this.children().provisional=0}#c($=""){if($==="ENOTDIR")this.parent.#b();else if($==="ENOENT")this.#y()}#u($=""){let Q=this.#Y;if(Q|=L8,$==="ENOENT")Q|=X0;if($==="EINVAL"||$==="UNKNOWN")Q&=r0;if(this.#Y=Q,$==="ENOTDIR"&&this.parent)this.parent.#b()}#v($,Q){return this.#l($,Q)||this.#z($,Q)}#z($,Q){let Z=g$($),X=this.newChild($.name,Z,{parent:this}),q=X.#Y&o;if(q!==V0&&q!==w0&&q!==a)X.#Y|=o0;return Q.unshift(X),Q.provisional++,X}#l($,Q){for(let Z=Q.provisional;Z<Q.length;Z++){let X=Q[Z];if((this.nocase?B8($.name):a0($.name))!==X.#V)continue;return this.#f($,X,Z,Q)}}#f($,Q,Z,X){let q=Q.name;if(Q.#Y=Q.#Y&r0|g$($),q!==$.name)Q.name=$.name;if(Z!==X.provisional){if(Z===X.length-1)X.pop();else X.splice(Z,1);X.unshift(Q)}return X.provisional++,Q}async lstat(){if((this.#Y&X0)===0)try{return this.#k(await this.#Q.promises.lstat(this.fullpath())),this}catch($){this.#c($.code)}}lstatSync(){if((this.#Y&X0)===0)try{return this.#k(this.#Q.lstatSync(this.fullpath())),this}catch($){this.#c($.code)}}#k($){let{atime:Q,atimeMs:Z,birthtime:X,birthtimeMs:q,blksize:J,blocks:Y,ctime:V,ctimeMs:W,dev:H,gid:K,ino:_,mode:G,mtime:M,mtimeMs:O,nlink:z,rdev:U,size:A,uid:L}=$;this.#A=Q,this.#q=Z,this.#F=X,this.#U=q,this.#H=J,this.#_=Y,this.#B=V,this.#M=W,this.#$=H,this.#C=K,this.#G=_,this.#Z=G,this.#T=M,this.#O=O,this.#X=z,this.#R=U,this.#W=A,this.#J=L;let R=g$($);if(this.#Y=this.#Y&r0|R|S5,R!==a&&R!==V0&&R!==w0)this.#Y|=o0}#g=[];#p=!1;#i($){this.#p=!1;let Q=this.#g.slice();this.#g.length=0,Q.forEach((Z)=>Z(null,$))}readdirCB($,Q=!1){if(!this.canReaddir()){if(Q)$(null,[]);else queueMicrotask(()=>$(null,[]));return}let Z=this.children();if(this.calledReaddir()){let q=Z.slice(0,Z.provisional);if(Q)$(null,q);else queueMicrotask(()=>$(null,q));return}if(this.#g.push($),this.#p)return;this.#p=!0;let X=this.fullpath();this.#Q.readdir(X,{withFileTypes:!0},(q,J)=>{if(q)this.#N(q.code),Z.provisional=0;else{for(let Y of J)this.#v(Y,Z);this.#h(Z)}this.#i(Z.slice(0,Z.provisional));return})}#d;async readdir(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Q=this.fullpath();if(this.#d)await this.#d;else{let Z=()=>{};this.#d=new Promise((X)=>Z=X);try{for(let X of await this.#Q.promises.readdir(Q,{withFileTypes:!0}))this.#v(X,$);this.#h($)}catch(X){this.#N(X.code),$.provisional=0}this.#d=void 0,Z()}return $.slice(0,$.provisional)}readdirSync(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Q=this.fullpath();try{for(let Z of this.#Q.readdirSync(Q,{withFileTypes:!0}))this.#v(Z,$);this.#h($)}catch(Z){this.#N(Z.code),$.provisional=0}return $.slice(0,$.provisional)}canReaddir(){if(this.#Y&b5)return!1;let $=o&this.#Y;if(!($===a||$===V0||$===w0))return!1;return!0}shouldWalk($,Q){return(this.#Y&V0)===V0&&!(this.#Y&b5)&&!$.has(this)&&(!Q||Q(this))}async realpath(){if(this.#E)return this.#E;if((R8|L8|X0)&this.#Y)return;try{let $=await this.#Q.promises.realpath(this.fullpath());return this.#E=this.resolve($)}catch($){this.#m()}}realpathSync(){if(this.#E)return this.#E;if((R8|L8|X0)&this.#Y)return;try{let $=this.#Q.realpathSync(this.fullpath());return this.#E=this.resolve($)}catch($){this.#m()}}[g5]($){if($===this)return;$.isCWD=!1,this.isCWD=!0;let Q=new Set([]),Z=[],X=this;while(X&&X.parent)Q.add(X),X.#L=Z.join(this.sep),X.#P=Z.join("/"),X=X.parent,Z.push("..");X=$;while(X&&X.parent&&!Q.has(X))X.#L=void 0,X.#P=void 0,X=X.parent}}class C8 extends i{sep="\\";splitSep=y9;constructor($,Q=a,Z,X,q,J,Y){super($,Q,Z,X,q,J,Y)}newChild($,Q=a,Z={}){return new C8($,Q,this.root,this.roots,this.nocase,this.childrenCache(),Z)}getRootString($){return h$.parse($).root}getRoot($){if($=D9($.toUpperCase()),$===this.root.name)return this.root;for(let[Q,Z]of Object.entries(this.roots))if(this.sameRoot($,Q))return this.roots[$]=Z;return this.roots[$]=new t0($,this).root}sameRoot($,Q=this.root.name){return $=$.toUpperCase().replace(/\//g,"\\").replace(k5,"$1\\"),$===Q}}class I8 extends i{splitSep="/";sep="/";constructor($,Q=a,Z,X,q,J,Y){super($,Q,Z,X,q,J,Y)}getRootString($){return $.startsWith("/")?"/":""}getRoot($){return this.root}newChild($,Q=a,Z={}){return new I8($,Q,this.root,this.roots,this.nocase,this.childrenCache(),Z)}}class c${root;rootPath;roots;cwd;#Q;#$;#Z;nocase;#X;constructor($=process.cwd(),Q,Z,{nocase:X,childrenCacheSize:q=16384,fs:J=s0}={}){if(this.#X=E5(J),$ instanceof URL||$.startsWith("file://"))$=C9($);let Y=Q.resolve($);this.roots=Object.create(null),this.rootPath=this.parseRootPath(Y),this.#Q=new m$,this.#$=new m$,this.#Z=new f5(q);let V=Y.substring(this.rootPath.length).split(Z);if(V.length===1&&!V[0])V.pop();if(X===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=X,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let W=this.root,H=V.length-1,K=Q.sep,_=this.rootPath,G=!1;for(let M of V){let O=H--;W=W.child(M,{relative:Array(O).fill("..").join(K),relativePosix:Array(O).fill("..").join("/"),fullpath:_+=(G?"":K)+M}),G=!0}this.cwd=W}depth($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.depth()}childrenCache(){return this.#Z}resolve(...$){let Q="";for(let q=$.length-1;q>=0;q--){let J=$[q];if(!J||J===".")continue;if(Q=Q?`${J}/${Q}`:J,this.isAbsolute(J))break}let Z=this.#Q.get(Q);if(Z!==void 0)return Z;let X=this.cwd.resolve(Q).fullpath();return this.#Q.set(Q,X),X}resolvePosix(...$){let Q="";for(let q=$.length-1;q>=0;q--){let J=$[q];if(!J||J===".")continue;if(Q=Q?`${J}/${Q}`:J,this.isAbsolute(J))break}let Z=this.#$.get(Q);if(Z!==void 0)return Z;let X=this.cwd.resolve(Q).fullpathPosix();return this.#$.set(Q,X),X}relative($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relative()}relativePosix($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relativePosix()}basename($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.name}dirname($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return($.parent||$).fullpath()}async readdir($=this.cwd,Q={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z}=Q;if(!$.canReaddir())return[];else{let X=await $.readdir();return Z?X:X.map((q)=>q.name)}}readdirSync($=this.cwd,Q={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z=!0}=Q;if(!$.canReaddir())return[];else if(Z)return $.readdirSync();else return $.readdirSync().map((X)=>X.name)}async lstat($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstat()}lstatSync($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstatSync()}async readlink($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$.withFileTypes,$=this.cwd;let Z=await $.readlink();return Q?Z:Z?.fullpath()}readlinkSync($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$.withFileTypes,$=this.cwd;let Z=$.readlinkSync();return Q?Z:Z?.fullpath()}async realpath($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$.withFileTypes,$=this.cwd;let Z=await $.realpath();return Q?Z:Z?.fullpath()}realpathSync($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$.withFileTypes,$=this.cwd;let Z=$.realpathSync();return Q?Z:Z?.fullpath()}async walk($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:J}=Q,Y=[];if(!q||q($))Y.push(Z?$:$.fullpath());let V=new Set,W=(K,_)=>{V.add(K),K.readdirCB((G,M)=>{if(G)return _(G);let O=M.length;if(!O)return _();let z=()=>{if(--O===0)_()};for(let U of M){if(!q||q(U))Y.push(Z?U:U.fullpath());if(X&&U.isSymbolicLink())U.realpath().then((A)=>A?.isUnknown()?A.lstat():A).then((A)=>A?.shouldWalk(V,J)?W(A,z):z());else if(U.shouldWalk(V,J))W(U,z);else z()}},!0)},H=$;return new Promise((K,_)=>{W(H,(G)=>{if(G)return _(G);K(Y)})})}walkSync($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:J}=Q,Y=[];if(!q||q($))Y.push(Z?$:$.fullpath());let V=new Set([$]);for(let W of V){let H=W.readdirSync();for(let K of H){if(!q||q(K))Y.push(Z?K:K.fullpath());let _=K;if(K.isSymbolicLink()){if(!(X&&(_=K.realpathSync())))continue;if(_.isUnknown())_.lstatSync()}if(_.shouldWalk(V,J))V.add(_)}}return Y}[Symbol.asyncIterator](){return this.iterate()}iterate($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;return this.stream($,Q)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:J}=Q;if(!q||q($))yield Z?$:$.fullpath();let Y=new Set([$]);for(let V of Y){let W=V.readdirSync();for(let H of W){if(!q||q(H))yield Z?H:H.fullpath();let K=H;if(H.isSymbolicLink()){if(!(X&&(K=H.realpathSync())))continue;if(K.isUnknown())K.lstatSync()}if(K.shouldWalk(Y,J))Y.add(K)}}}stream($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:J}=Q,Y=new j0({objectMode:!0});if(!q||q($))Y.write(Z?$:$.fullpath());let V=new Set,W=[$],H=0,K=()=>{let _=!1;while(!_){let G=W.shift();if(!G){if(H===0)Y.end();return}H++,V.add(G);let M=(z,U,A=!1)=>{if(z)return Y.emit("error",z);if(X&&!A){let L=[];for(let R of U)if(R.isSymbolicLink())L.push(R.realpath().then((T)=>T?.isUnknown()?T.lstat():T));if(L.length){Promise.all(L).then(()=>M(null,U,!0));return}}for(let L of U)if(L&&(!q||q(L))){if(!Y.write(Z?L:L.fullpath()))_=!0}H--;for(let L of U){let R=L.realpathCached()||L;if(R.shouldWalk(V,J))W.push(R)}if(_&&!Y.flowing)Y.once("drain",K);else if(!O)K()},O=!0;G.readdirCB(M,!0),O=!1}};return K(),Y}streamSync($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof i))Q=$,$=this.cwd;let{withFileTypes:Z=!0,follow:X=!1,filter:q,walkFilter:J}=Q,Y=new j0({objectMode:!0}),V=new Set;if(!q||q($))Y.write(Z?$:$.fullpath());let W=[$],H=0,K=()=>{let _=!1;while(!_){let G=W.shift();if(!G){if(H===0)Y.end();return}H++,V.add(G);let M=G.readdirSync();for(let O of M)if(!q||q(O)){if(!Y.write(Z?O:O.fullpath()))_=!0}H--;for(let O of M){let z=O;if(O.isSymbolicLink()){if(!(X&&(z=O.realpathSync())))continue;if(z.isUnknown())z.lstatSync()}if(z.shouldWalk(V,J))W.push(z)}}if(_&&!Y.flowing)Y.once("drain",K)};return K(),Y}chdir($=this.cwd){let Q=this.cwd;this.cwd=typeof $==="string"?this.cwd.resolve($):$,this.cwd[g5](Q)}}class t0 extends c${sep="\\";constructor($=process.cwd(),Q={}){let{nocase:Z=!0}=Q;super($,h$,"\\",{...Q,nocase:Z});this.nocase=Z;for(let X=this.cwd;X;X=X.parent)X.nocase=this.nocase}parseRootPath($){return h$.parse($).root.toUpperCase()}newRoot($){return new C8(this.rootPath,V0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")||$.startsWith("\\")||/^[a-z]:(\/|\\)/i.test($)}}class e0 extends c${sep="/";constructor($=process.cwd(),Q={}){let{nocase:Z=!1}=Q;super($,R9,"/",{...Q,nocase:Z});this.nocase=Z}parseRootPath($){return"/"}newRoot($){return new I8(this.rootPath,V0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")}}class F8 extends e0{constructor($=process.cwd(),Q={}){let{nocase:Z=!0}=Q;super($,{...Q,nocase:Z})}}var h3=process.platform==="win32"?C8:I8,h5=process.platform==="win32"?t0:process.platform==="darwin"?F8:e0;var x9=($)=>$.length>=1,u9=($)=>$.length>=1;class x0{#Q;#$;#Z;length;#X;#J;#C;#R;#H;#G;#W=!0;constructor($,Q,Z,X){if(!x9($))throw TypeError("empty pattern list");if(!u9(Q))throw TypeError("empty glob list");if(Q.length!==$.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=$.length,Z<0||Z>=this.length)throw TypeError("index out of range");if(this.#Q=$,this.#$=Q,this.#Z=Z,this.#X=X,this.#Z===0){if(this.isUNC()){let[q,J,Y,V,...W]=this.#Q,[H,K,_,G,...M]=this.#$;if(W[0]==="")W.shift(),M.shift();let O=[q,J,Y,V,""].join("/"),z=[H,K,_,G,""].join("/");this.#Q=[O,...W],this.#$=[z,...M],this.length=this.#Q.length}else if(this.isDrive()||this.isAbsolute()){let[q,...J]=this.#Q,[Y,...V]=this.#$;if(J[0]==="")J.shift(),V.shift();let W=q+"/",H=Y+"/";this.#Q=[W,...J],this.#$=[H,...V],this.length=this.#Q.length}}}pattern(){return this.#Q[this.#Z]}isString(){return typeof this.#Q[this.#Z]==="string"}isGlobstar(){return this.#Q[this.#Z]===g}isRegExp(){return this.#Q[this.#Z]instanceof RegExp}globString(){return this.#C=this.#C||(this.#Z===0?this.isAbsolute()?this.#$[0]+this.#$.slice(1).join("/"):this.#$.join("/"):this.#$.slice(this.#Z).join("/"))}hasMore(){return this.length>this.#Z+1}rest(){if(this.#J!==void 0)return this.#J;if(!this.hasMore())return this.#J=null;return this.#J=new x0(this.#Q,this.#$,this.#Z+1,this.#X),this.#J.#G=this.#G,this.#J.#H=this.#H,this.#J.#R=this.#R,this.#J}isUNC(){let $=this.#Q;return this.#H!==void 0?this.#H:this.#H=this.#X==="win32"&&this.#Z===0&&$[0]===""&&$[1]===""&&typeof $[2]==="string"&&!!$[2]&&typeof $[3]==="string"&&!!$[3]}isDrive(){let $=this.#Q;return this.#R!==void 0?this.#R:this.#R=this.#X==="win32"&&this.#Z===0&&this.length>1&&typeof $[0]==="string"&&/^[a-z]:$/i.test($[0])}isAbsolute(){let $=this.#Q;return this.#G!==void 0?this.#G:this.#G=$[0]===""&&$.length>1||this.isDrive()||this.isUNC()}root(){let $=this.#Q[0];return typeof $==="string"&&this.isAbsolute()&&this.#Z===0?$:""}checkFollowGlobstar(){return!(this.#Z===0||!this.isGlobstar()||!this.#W)}markFollowGlobstar(){if(this.#Z===0||!this.isGlobstar()||!this.#W)return!1;return this.#W=!1,!0}}var f9=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class $8{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor($,{nobrace:Q,nocase:Z,noext:X,noglobstar:q,platform:J=f9}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=J,this.mmopts={dot:!0,nobrace:Q,nocase:Z,noext:X,noglobstar:q,optimizationLevel:2,platform:J,nocomment:!0,nonegate:!0};for(let Y of $)this.add(Y)}add($){let Q=new s($,this.mmopts);for(let Z=0;Z<Q.set.length;Z++){let X=Q.set[Z],q=Q.globParts[Z];if(!X||!q)throw Error("invalid pattern object");while(X[0]==="."&&q[0]===".")X.shift(),q.shift();let J=new x0(X,q,0,this.platform),Y=new s(J.globString(),this.mmopts),V=q[q.length-1]==="**",W=J.isAbsolute();if(W)this.absolute.push(Y);else this.relative.push(Y);if(V)if(W)this.absoluteChildren.push(Y);else this.relativeChildren.push(Y)}}ignored($){let Q=$.fullpath(),Z=`${Q}/`,X=$.relative()||".",q=`${X}/`;for(let J of this.relative)if(J.match(X)||J.match(q))return!0;for(let J of this.absolute)if(J.match(Q)||J.match(Z))return!0;return!1}childrenIgnored($){let Q=$.fullpath()+"/",Z=($.relative()||".")+"/";for(let X of this.relativeChildren)if(X.match(Z))return!0;for(let X of this.absoluteChildren)if(X.match(Q))return!0;return!1}}class l${store;constructor($=new Map){this.store=$}copy(){return new l$(new Map(this.store))}hasWalked($,Q){return this.store.get($.fullpath())?.has(Q.globString())}storeWalked($,Q){let Z=$.fullpath(),X=this.store.get(Z);if(X)X.add(Q.globString());else this.store.set(Z,new Set([Q.globString()]))}}class m5{store=new Map;add($,Q,Z){let X=(Q?2:0)|(Z?1:0),q=this.store.get($);this.store.set($,q===void 0?X:X&q)}entries(){return[...this.store.entries()].map(([$,Q])=>[$,!!(Q&2),!!(Q&1)])}}class c5{store=new Map;add($,Q){if(!$.canReaddir())return;let Z=this.store.get($);if(Z){if(!Z.find((X)=>X.globString()===Q.globString()))Z.push(Q)}else this.store.set($,[Q])}get($){let Q=this.store.get($);if(!Q)throw Error("attempting to walk unknown path");return Q}entries(){return this.keys().map(($)=>[$,this.store.get($)])}keys(){return[...this.store.keys()].filter(($)=>$.canReaddir())}}class Q8{hasWalkedCache;matches=new m5;subwalks=new c5;patterns;follow;dot;opts;constructor($,Q){this.opts=$,this.follow=!!$.follow,this.dot=!!$.dot,this.hasWalkedCache=Q?Q.copy():new l$}processPatterns($,Q){this.patterns=Q;let Z=Q.map((X)=>[$,X]);for(let[X,q]of Z){this.hasWalkedCache.storeWalked(X,q);let J=q.root(),Y=q.isAbsolute()&&this.opts.absolute!==!1;if(J){X=X.resolve(J==="/"&&this.opts.root!==void 0?this.opts.root:J);let K=q.rest();if(!K){this.matches.add(X,!0,!1);continue}else q=K}if(X.isENOENT())continue;let V,W,H=!1;while(typeof(V=q.pattern())==="string"&&(W=q.rest()))X=X.resolve(V),q=W,H=!0;if(V=q.pattern(),W=q.rest(),H){if(this.hasWalkedCache.hasWalked(X,q))continue;this.hasWalkedCache.storeWalked(X,q)}if(typeof V==="string"){let K=V===".."||V===""||V===".";this.matches.add(X.resolve(V),Y,K);continue}else if(V===g){if(!X.isSymbolicLink()||this.follow||q.checkFollowGlobstar())this.subwalks.add(X,q);let K=W?.pattern(),_=W?.rest();if(!W||(K===""||K===".")&&!_)this.matches.add(X,Y,K===""||K===".");else if(K===".."){let G=X.parent||X;if(!_)this.matches.add(G,Y,!0);else if(!this.hasWalkedCache.hasWalked(G,_))this.subwalks.add(G,_)}}else if(V instanceof RegExp)this.subwalks.add(X,q)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new Q8(this.opts,this.hasWalkedCache)}filterEntries($,Q){let Z=this.subwalks.get($),X=this.child();for(let q of Q)for(let J of Z){let Y=J.isAbsolute(),V=J.pattern(),W=J.rest();if(V===g)X.testGlobstar(q,J,W,Y);else if(V instanceof RegExp)X.testRegExp(q,V,W,Y);else X.testString(q,V,W,Y)}return X}testGlobstar($,Q,Z,X){if(this.dot||!$.name.startsWith(".")){if(!Q.hasMore())this.matches.add($,X,!1);if($.canReaddir()){if(this.follow||!$.isSymbolicLink())this.subwalks.add($,Q);else if($.isSymbolicLink()){if(Z&&Q.checkFollowGlobstar())this.subwalks.add($,Z);else if(Q.markFollowGlobstar())this.subwalks.add($,Q)}}}if(Z){let q=Z.pattern();if(typeof q==="string"&&q!==".."&&q!==""&&q!==".")this.testString($,q,Z.rest(),X);else if(q===".."){let J=$.parent||$;this.subwalks.add(J,Z)}else if(q instanceof RegExp)this.testRegExp($,q,Z.rest(),X)}}testRegExp($,Q,Z,X){if(!Q.test($.name))return;if(!Z)this.matches.add($,X,!1);else this.subwalks.add($,Z)}testString($,Q,Z,X){if(!$.isNamed(Q))return;if(!Z)this.matches.add($,X,!1);else this.subwalks.add($,Z)}}var g9=($,Q)=>typeof $==="string"?new $8([$],Q):Array.isArray($)?new $8($,Q):$;class d${path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Q=[];#$;#Z;signal;maxDepth;includeChildMatches;constructor($,Q,Z){if(this.patterns=$,this.path=Q,this.opts=Z,this.#Z=!Z.posix&&Z.platform==="win32"?"\\":"/",this.includeChildMatches=Z.includeChildMatches!==!1,Z.ignore||!this.includeChildMatches){if(this.#$=g9(Z.ignore??[],Z),!this.includeChildMatches&&typeof this.#$.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=Z.maxDepth||1/0,Z.signal)this.signal=Z.signal,this.signal.addEventListener("abort",()=>{this.#Q.length=0})}#X($){return this.seen.has($)||!!this.#$?.ignored?.($)}#J($){return!!this.#$?.childrenIgnored?.($)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let $=void 0;while(!this.paused&&($=this.#Q.shift()))$()}onResume($){if(this.signal?.aborted)return;if(!this.paused)$();else this.#Q.push($)}async matchCheck($,Q){if(Q&&this.opts.nodir)return;let Z;if(this.opts.realpath){if(Z=$.realpathCached()||await $.realpath(),!Z)return;$=Z}let q=$.isUnknown()||this.opts.stat?await $.lstat():$;if(this.opts.follow&&this.opts.nodir&&q?.isSymbolicLink()){let J=await q.realpath();if(J&&(J.isUnknown()||this.opts.stat))await J.lstat()}return this.matchCheckTest(q,Q)}matchCheckTest($,Q){return $&&(this.maxDepth===1/0||$.depth()<=this.maxDepth)&&(!Q||$.canReaddir())&&(!this.opts.nodir||!$.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!$.isSymbolicLink()||!$.realpathCached()?.isDirectory())&&!this.#X($)?$:void 0}matchCheckSync($,Q){if(Q&&this.opts.nodir)return;let Z;if(this.opts.realpath){if(Z=$.realpathCached()||$.realpathSync(),!Z)return;$=Z}let q=$.isUnknown()||this.opts.stat?$.lstatSync():$;if(this.opts.follow&&this.opts.nodir&&q?.isSymbolicLink()){let J=q.realpathSync();if(J&&(J?.isUnknown()||this.opts.stat))J.lstatSync()}return this.matchCheckTest(q,Q)}matchFinish($,Q){if(this.#X($))return;if(!this.includeChildMatches&&this.#$?.add){let q=`${$.relativePosix()}/**`;this.#$.add(q)}let Z=this.opts.absolute===void 0?Q:this.opts.absolute;this.seen.add($);let X=this.opts.mark&&$.isDirectory()?this.#Z:"";if(this.opts.withFileTypes)this.matchEmit($);else if(Z){let q=this.opts.posix?$.fullpathPosix():$.fullpath();this.matchEmit(q+X)}else{let q=this.opts.posix?$.relativePosix():$.relative(),J=this.opts.dotRelative&&!q.startsWith(".."+this.#Z)?"."+this.#Z:"";this.matchEmit(!q?"."+X:J+q+X)}}async match($,Q,Z){let X=await this.matchCheck($,Z);if(X)this.matchFinish(X,Q)}matchSync($,Q,Z){let X=this.matchCheckSync($,Z);if(X)this.matchFinish(X,Q)}walkCB($,Q,Z){if(this.signal?.aborted)Z();this.walkCB2($,Q,new Q8(this.opts),Z)}walkCB2($,Q,Z,X){if(this.#J($))return X();if(this.signal?.aborted)X();if(this.paused){this.onResume(()=>this.walkCB2($,Q,Z,X));return}Z.processPatterns($,Q);let q=1,J=()=>{if(--q===0)X()};for(let[Y,V,W]of Z.matches.entries()){if(this.#X(Y))continue;q++,this.match(Y,V,W).then(()=>J())}for(let Y of Z.subwalkTargets()){if(this.maxDepth!==1/0&&Y.depth()>=this.maxDepth)continue;q++;let V=Y.readdirCached();if(Y.calledReaddir())this.walkCB3(Y,V,Z,J);else Y.readdirCB((W,H)=>this.walkCB3(Y,H,Z,J),!0)}J()}walkCB3($,Q,Z,X){Z=Z.filterEntries($,Q);let q=1,J=()=>{if(--q===0)X()};for(let[Y,V,W]of Z.matches.entries()){if(this.#X(Y))continue;q++,this.match(Y,V,W).then(()=>J())}for(let[Y,V]of Z.subwalks.entries())q++,this.walkCB2(Y,V,Z.child(),J);J()}walkCBSync($,Q,Z){if(this.signal?.aborted)Z();this.walkCB2Sync($,Q,new Q8(this.opts),Z)}walkCB2Sync($,Q,Z,X){if(this.#J($))return X();if(this.signal?.aborted)X();if(this.paused){this.onResume(()=>this.walkCB2Sync($,Q,Z,X));return}Z.processPatterns($,Q);let q=1,J=()=>{if(--q===0)X()};for(let[Y,V,W]of Z.matches.entries()){if(this.#X(Y))continue;this.matchSync(Y,V,W)}for(let Y of Z.subwalkTargets()){if(this.maxDepth!==1/0&&Y.depth()>=this.maxDepth)continue;q++;let V=Y.readdirSync();this.walkCB3Sync(Y,V,Z,J)}J()}walkCB3Sync($,Q,Z,X){Z=Z.filterEntries($,Q);let q=1,J=()=>{if(--q===0)X()};for(let[Y,V,W]of Z.matches.entries()){if(this.#X(Y))continue;this.matchSync(Y,V,W)}for(let[Y,V]of Z.subwalks.entries())q++,this.walkCB2Sync(Y,V,Z.child(),J);J()}}class T8 extends d${matches=new Set;constructor($,Q,Z){super($,Q,Z)}matchEmit($){this.matches.add($)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise(($,Q)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)Q(this.signal.reason);else $(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class j8 extends d${results;constructor($,Q,Z){super($,Q,Z);this.results=new j0({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit($){if(this.results.write($),!this.results.flowing)this.pause()}stream(){let $=this.path;if($.isUnknown())$.lstat().then(()=>{this.walkCB($,this.patterns,()=>this.results.end())});else this.walkCB($,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var m9=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class W0{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($,Q){if(!Q)throw TypeError("glob options required");if(this.withFileTypes=!!Q.withFileTypes,this.signal=Q.signal,this.follow=!!Q.follow,this.dot=!!Q.dot,this.dotRelative=!!Q.dotRelative,this.nodir=!!Q.nodir,this.mark=!!Q.mark,!Q.cwd)this.cwd="";else if(Q.cwd instanceof URL||Q.cwd.startsWith("file://"))Q.cwd=h9(Q.cwd);if(this.cwd=Q.cwd||"",this.root=Q.root,this.magicalBraces=!!Q.magicalBraces,this.nobrace=!!Q.nobrace,this.noext=!!Q.noext,this.realpath=!!Q.realpath,this.absolute=Q.absolute,this.includeChildMatches=Q.includeChildMatches!==!1,this.noglobstar=!!Q.noglobstar,this.matchBase=!!Q.matchBase,this.maxDepth=typeof Q.maxDepth==="number"?Q.maxDepth:1/0,this.stat=!!Q.stat,this.ignore=Q.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof $==="string")$=[$];if(this.windowsPathsNoEscape=!!Q.windowsPathsNoEscape||Q.allowWindowsEscape===!1,this.windowsPathsNoEscape)$=$.map((V)=>V.replace(/\\/g,"/"));if(this.matchBase){if(Q.noglobstar)throw TypeError("base matching requires globstar");$=$.map((V)=>V.includes("/")?V:`./**/${V}`)}if(this.pattern=$,this.platform=Q.platform||m9,this.opts={...Q,platform:this.platform},Q.scurry){if(this.scurry=Q.scurry,Q.nocase!==void 0&&Q.nocase!==Q.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let V=Q.platform==="win32"?t0:Q.platform==="darwin"?F8:Q.platform?e0:h5;this.scurry=new V(this.cwd,{nocase:Q.nocase,fs:Q.fs})}this.nocase=this.scurry.nocase;let Z=this.platform==="darwin"||this.platform==="win32",X={...Q,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:Z,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},q=this.pattern.map((V)=>new s(V,X)),[J,Y]=q.reduce((V,W)=>{return V[0].push(...W.set),V[1].push(...W.globParts),V},[[],[]]);this.patterns=J.map((V,W)=>{let H=Y[W];if(!H)throw Error("invalid pattern object");return new x0(V,H,0,this.platform)})}async walk(){return[...await new T8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new T8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new j8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new j8(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,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()}}var p$=($,Q={})=>{if(!Array.isArray($))$=[$];for(let Z of $)if(new s(Z,Q).hasMagic())return!0;return!1};function w8($,Q={}){return new W0($,Q).streamSync()}function p5($,Q={}){return new W0($,Q).stream()}function S8($,Q={}){return new W0($,Q).walkSync()}async function l5($,Q={}){return new W0($,Q).walk()}function b8($,Q={}){return new W0($,Q).iterateSync()}function i5($,Q={}){return new W0($,Q).iterate()}var c9=w8,l9=Object.assign(p5,{sync:w8}),d9=b8,p9=Object.assign(i5,{sync:b8}),i9=Object.assign(S8,{stream:w8,iterate:b8}),d5=Object.assign(l5,{glob:l5,globSync:S8,sync:i9,globStream:p5,stream:l9,globStreamSync:w8,streamSync:c9,globIterate:i5,iterate:p9,globIterateSync:b8,iterateSync:d9,Glob:W0,hasMagic:p$,escape:E0,unescape:Q0});d5.glob=d5;import n9 from"path";var n5=({dir:$,pattern:Q="*",nodir:Z=!1,dot:X=!0,ignore:q=[],absolute:J=!1,matchBase:Y=!1,follow:V=!1})=>{if($=$||process.cwd(),$=n9.resolve($),Q&&!Array.isArray(Q))Q=[Q];else Q=Q||["*"];if(q&&!Array.isArray(q))q=[q];else q=q||[];return S8(Q,{cwd:$,nodir:Z,dot:X,ignore:q,absolute:J,matchBase:Y,follow:V})};import o5 from"@fnet/expression";import r5 from"lodash.clonedeep";import r9 from"@fnet/key-value-transformer";import s9 from"@fnet/expression";async function D({node:$,initNode:Q,extra:Z=!0}){if(Reflect.has($.definition,"modules")&&!Array.isArray($.definition.modules)){let X=$.definition.modules;$.definition.modules=[],Object.keys(X).forEach((q)=>{let J={...X[q]};if(typeof J.export==="boolean")J.export=J.export===!0?q:!1;else if(typeof J.export==="string")J.export=J.export;else delete J.export;$.definition.modules.push({[q]:J})})}if(Z){let X=[],q=await r9({data:$.definition,callback:(J,Y,V)=>{let W=s9({expression:J});if(W?.processor==="m"){let H=V.slice(0,-1);H.push(W.statement);let K=H.join("_");return X.push({[K]:Y}),[W.statement,`m::${K}`]}return[J,Y]}});if(X.length>0)$.definition=q,$.definition.modules=$.definition.modules||[],$.definition.modules=$.definition.modules.concat(X)}$.hasModules=$.definition.modules?.length>0;for(let X=0;X<$.definition.modules?.length;X++){let q=$.definition.modules[X],J=Object.keys(q)[0],Y={name:J,childs:[],parent:$,definition:q[J],module:!0,blockAutoJumpToParent:!0,blockAutoJumpToSibling:!1,index:$.childs.length,context:{}};$.childs.push(Y),await Q({node:Y})}}async function b({node:$,transformExpression:Q}){let Z=$.context.transform;if(Reflect.has(Z,"export"))Z.export=await Q(Z.export);if(Reflect.has(Z,"return"))$.hasReturn=!0,Z.return=await Q(Z.return);if(Reflect.has(Z,"output"))Z.output=await Q(Z.output);if(Reflect.has(Z,"assign"))for(let X=0;X<Z.assign?.length;X++){let q=Z.assign[X],J=Object.keys(q)[0],Y=q[J],V={key:await Q(J),value:await Q(Y)};Z.assign[X]=V}}async function o9({node:$}){if(!$.definition.hasOwnProperty("switch"))return!1;return!0}async function a9({node:$,initNode:Q}){$.type="switch";let Z=$.definition.switch||[];if(!Z.every((Y)=>Y.hasOwnProperty("condition")||Y.hasOwnProperty("default")))throw Error("Switch must have condition or default");if(Z.filter((Y)=>Y.hasOwnProperty("condition")).length===0)throw Error("Switch must have at least one condition");let J=Z.filter((Y)=>Y.hasOwnProperty("default"));if(J.length>1)throw Error("Switch must have only one default");if(J.length===1&&!Z[Z.length-1].hasOwnProperty("default"))throw Error("Switch default must be the last child");$.hasDefaultCondition=J.length===1,await D({node:$,initNode:Q,extra:!1}),$.blockAutoJumpToParent=!1,$.blockAutoJumpToSibling=!0;for(let Y=0;Y<$.definition.switch.length;Y++){let V=$.definition.switch[Y],W=`${Y}`;if(V.hasOwnProperty("default"))W="default",V=V.default;let H={name:V.condition||W,childs:[],parent:$,definition:V,index:$.childs.length,context:{}};$.childs.push(H),await Q({node:H})}$.resolve=s5}async function s5({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||r5($.definition);let q=$.context.transform;for(let J of $.childs)if(J.context.transform=J.context.transform||r5(J.definition),J.definition.hasOwnProperty("condition"))J.context.transform.condition=await X(J.definition.condition);await b({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var Z8={hits:o9,init:a9,resolve:s5};async function t9({node:$}){if(Object.keys($.definition).map((q)=>o5({expression:q})).filter((q)=>q?.processor==="if").length===1)return!0;if($.definition.if&&typeof $.definition.if==="object")return!0;return!1}async function e9($){let{node:Q}=$,X=Object.keys(Q.definition).map((W)=>o5({expression:W})),q=[],J=X.find((W)=>W?.processor==="if");if(J){let W=Q.definition[J.expression];q.push({name:`${Q.name}_if`,definition:W,processor:J}),delete Q.definition[J.expression]}else if(Q.definition.if){let{condition:W,...H}=Q.definition.if;q.push({name:`${Q.name}_if`,definition:H,processor:{expression:`if::${W}`,statement:W}}),delete Q.definition.if}let Y=X.filter((W)=>W?.processor==="elseif"),V=0;for(let W of Y){let H=Q.definition[W.expression];q.push({name:`${Q.name}_elseif_${V++}`,definition:H,processor:W}),delete Q.definition[W.expression]}if(Q.definition.elseif){let{condition:W,...H}=Q.definition.elseif;q.push({name:`${Q.name}_elseif_${V++}`,definition:H,processor:{expression:`elseif::${W}`,statement:W}}),delete Q.definition.elseif}Q.definition.switch=[];for(let W of q)Q.definition.switch.push({condition:W.processor.statement,...W.definition});if(Q.definition?.else){let W=Q.definition.else;Q.definition.switch.push({default:W}),delete Q.definition.else}await Z8.init($)}var i$={hits:t9,init:e9};import a5 from"lodash.clonedeep";async function $Q({node:$}){return $.definition.hasOwnProperty("try")&&$.definition.hasOwnProperty("except")}async function QQ({node:$,initNode:Q}){if($.type="tryexcept",await D({node:$,initNode:Q,extra:!1}),$.blockAutoJumpToParent=!1,$.blockAutoJumpToSibling=!0,$.definition.try){let X={name:"try",childs:[],parent:$,definition:$.definition.try,index:$.childs.length,context:{}};$.childs.push(X),await Q({node:X})}if($.definition.except){let X={name:"except",childs:[],parent:$,definition:$.definition.except,index:$.childs.length,context:{}};$.childs.push(X),await Q({node:X})}$.resolve=t5}async function t5({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||a5($.definition);let q=$.context.transform;if($.context.try=$.childs.find((J)=>J.name==="try"),$.context.except=$.childs.find((J)=>J.name==="except"),$.context.except){let J=$.context.except;if(J.context.transform=J.context.transform||a5(J.definition),!J.context.transform.hasOwnProperty("as"))J.context.transform.as="error"}await b({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var n$={hits:$Q,init:QQ,resolve:t5};import ZQ from"lodash.clonedeep";async function XQ({node:$}){return $.definition.hasOwnProperty("assign")}async function qQ({node:$,initNode:Q}){$.type="assign",await D({node:$,initNode:Q}),$.resolve=e5}async function e5({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||ZQ($.definition);let q=$.context.transform;await b({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var r$={hits:XQ,init:qQ,resolve:e5};import JQ from"lodash.clonedeep";async function YQ({node:$}){return $.definition.hasOwnProperty("for")}async function VQ({node:$,initNode:Q}){if($.type="for",await D({node:$,initNode:Q,extra:!1}),$.blockAutoJumpToParent=!0,$.blockAutoJumpToSibling=!1,!$.definition.for.hasOwnProperty("steps")){let{value:Z,in:X,...q}=$.definition.for,J={};if(Z!==void 0)J.value=Z;if(X!==void 0)J.in=X;$.definition.for=J,$.definition.for.steps=[{[`${$.name}_step`]:q}]}if(!Array.isArray($.definition.for.steps))$.definition.for.steps=[{[`${$.name}_step`]:$.definition.for.steps}];for(let Z=0;Z<$.definition.for.steps.length;Z++){let X=$.definition.for.steps[Z],q=Object.keys(X)[0],J={name:q,childs:[],parent:$,definition:X[q],index:$.childs.length,context:{}};$.childs.push(J),await Q({node:J})}$.resolve=$1}async function $1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||JQ($.definition);let q=$.context.transform;q.for.in=await X($.definition.for.in),await b({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var s$={hits:YQ,init:VQ,resolve:$1};async function WQ({node:$}){return!1}async function HQ({node:$,initNode:Q}){}async function KQ({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X,transformValue:q}){}var o$={hits:WQ,init:HQ,resolve:KQ};import _Q from"lodash.clonedeep";async function GQ({node:$}){return $.definition.hasOwnProperty("raise")}async function zQ({node:$,initNode:Q}){$.type="raise",$.resolve=Q1}async function Q1({node:$,resolveTypeCommon:Q,transformExpression:Z}){$.context.transform=$.context.transform||_Q($.definition);let X=$.context.transform;X.raise=await Z(X.raise),await Q({node:$})}var a$={hits:GQ,init:zQ,resolve:Q1};import UQ from"lodash.clonedeep";async function MQ({node:$}){return $.definition.hasOwnProperty("return")}async function OQ({node:$,initNode:Q}){$.type="return",$.resolve=Z1}async function Z1({node:$,resolveTypeCommon:Q,transformExpression:Z}){$.context.transform=$.context.transform||UQ($.definition);let X=$.context.transform;$.hasReturn=!0,X.return=await Z(X.return),await Q({node:$})}var t$={hits:MQ,init:OQ,resolve:Z1};import AQ from"lodash.clonedeep";async function LQ({node:$}){return $.definition.hasOwnProperty("call")}async function BQ({node:$,initNode:Q}){$.type="call",await D({node:$,initNode:Q}),$.resolve=X1}async function X1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||AQ($.definition);let q=$.context.transform,J=q.from||q.import||q.call;if($.target?.atom?.doc?.type==="function"){if(Reflect.has(q,"from"))J=q.from,q.from=await X($.target.atom.name);else if(Reflect.has(q,"import"))J=q.import,q.import=await X($.target.atom.name);else if(Reflect.has(q,"call"))q.call=await X($.target.atom.name),J=q.call}else if(Reflect.has(q,"from")||Reflect.has(q,"import")){if(q.call.startsWith("use:e::")){let V=q.call.substring(7);q.libExp=await X(`e::LIBRARY.${V}`)}}if(q.args)q.args=await X(q.args);if(q.new)q.new=await X(q.new);if(q.context)q.context=await X(q.context);if(q.result){if(typeof q.result==="string")q.result=[{[q.result]:"e::result"}];for(let V=0;V<q.result?.length;V++){let W=q.result[V],H=Object.keys(W)[0],K=W[H],_={key:await X(H),value:await X(K)};q.result[V]=_}}let Y=$.workflow.parent;$.context.lib=Y.context.libs.find((V)=>V.name===J),await b({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var X8={hits:LQ,init:BQ,resolve:X1};import RQ from"lodash.clonedeep";async function CQ({node:$}){return $.definition.hasOwnProperty("steps")}async function IQ({node:$,initNode:Q}){if(!$.type)$.type="steps";let Z=$.definition.steps||[];for await(let X of Z){let q=Object.keys(X)[0],J={name:q,childs:[],parent:$,definition:X[q],index:$.childs.length,context:{}};$.childs.push(J),await Q({node:J})}$.resolve=q1}async function q1({node:$,transformExpression:Q}){$.context.next=$.childs[0],$.context.transform=$.context.transform||RQ($.definition),await b({node:$,transformExpression:Q})}var e$={hits:CQ,init:IQ,resolve:q1};import FQ from"lodash.clonedeep";async function TQ({node:$}){return $.definition.hasOwnProperty("form")}async function jQ({node:$,initNode:Q}){$.type="form",await D({node:$,initNode:Q}),$.resolve=J1}async function J1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||FQ($.definition);let q=$.context.transform;if(q.props)q.props=await X(q.props);let J=$.workflow.parent;$.context.lib=J.context.libs.find((Y)=>Y.name===q.form),await b({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var $6={hits:TQ,init:jQ,resolve:J1};import wQ from"lodash.clonedeep";async function SQ({node:$}){return $.definition.hasOwnProperty("signal")}async function bQ({node:$,initNode:Q}){$.type="signal",$.resolve=Y1}async function Y1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X,transformValue:q}){$.context.transform=$.context.transform||wQ($.definition),await Q({node:$}),Z({node:$})}var Q6={hits:SQ,init:bQ,resolve:Y1};import NQ from"lodash.clonedeep";async function PQ({node:$}){return $.definition.hasOwnProperty("wait")}async function EQ({node:$,initNode:Q}){$.type="wait",$.resolve=V1}async function V1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X,transformValue:q}){$.context.transform=$.context.transform||NQ($.definition),await Q({node:$}),Z({node:$})}var Z6={hits:PQ,init:EQ,resolve:V1};import kQ from"lodash.clonedeep";async function DQ({node:$}){return $.definition.hasOwnProperty("next")}async function yQ({node:$,initNode:Q}){$.type="next",$.resolve=W1}async function W1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||kQ($.definition);let q=$.context.transform;q.next=await X(q.next),await b({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var X6={hits:DQ,init:yQ,resolve:W1};import vQ from"lodash.clonedeep";async function xQ({node:$}){return $.definition.hasOwnProperty("modules")}async function uQ({node:$,initNode:Q}){$.type="modules",await D({node:$,initNode:Q}),$.resolve=H1}async function H1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||vQ($.definition);let q=$.context.transform;await b({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var q6={hits:xQ,init:uQ,resolve:H1};function J6({node:$}){let Q=$.definition;if($.hasReturn)return;if(Q.next==="end");else if(Q.next==="stop");else if(Q.next==="none");else if(Q.next){let Z=$.parent;while(Z.parent){let X=Z.childs.find((q)=>q.name===Q.next);if(X){$.context.next=X;break}Z=Z.parent}}else{if($.module===!0)return;let Z=$.parent,X=$.index+1;while(Z.parent)if(Z.blockAutoJumpToParent&&Z.blockAutoJumpToSibling)break;else if(!Reflect.has(Z,"blockAutoJumpToParent")&&!Reflect.has(Z,"blockAutoJumpToSibling")){let q=Z.childs.find((J)=>J.index===X);if(q){$.context.next=q;break}else{X=Z.index+1,Z=Z.parent;continue}}else if(Z.blockAutoJumpToParent){let q=Z.childs.find((J)=>J.index===X);if(q)$.context.next=q;break}else if(!Z.blockAutoJumpToParent){X=Z.index+1,Z=Z.parent;continue}}}class K1{#Q;#$;#Z;#X;constructor({key:$,npm:Q,master:Z,extras:X}){this.#Q=$,this.#$=Q,this.#Z=Z,this.#X=X}hits({node:$}){return $.definition.hasOwnProperty(this.#Q)}async init($){let{node:Q}=$,Z=this.#Q,X=Q.definition,q=typeof X[Z];if(X.call=`npm:${this.#$}`,q!=="object")X.args={...X.args,[`${this.#Z}`]:X[Z]};else X.args=X[Z];if(delete X[Z],this.#X)for(let J in this.#X)X[J]=this.#X[J];console.log(`[npm-block] ${this.#Q} --> ${this.#$}`),await X8.init($)}}function h($){return new K1($)}import fQ from"lodash.clonedeep";async function gQ({node:$}){return $.definition.hasOwnProperty("new")}async function hQ({node:$,initNode:Q}){$.type="new",await D({node:$,initNode:Q}),$.resolve=_1}async function _1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||fQ($.definition);let q=$.context.transform,J=q.from||q.import;if($.target?.atom?.doc?.type==="function"){if(Reflect.has(q,"from"))J=q.from,q.from=await X($.target.atom.name);else if(Reflect.has(q,"import"))J=q.import,q.import=await X($.target.atom.name)}if(q.args)q.args=await X(q.args);if(q.new)q.new=await X(q.new);if(q.result){if(typeof q.result==="string")q.result=[{[q.result]:"e::result"}];for(let V=0;V<q.result?.length;V++){let W=q.result[V],H=Object.keys(W)[0],K=W[H],_={key:await X(H),value:await X(K)};q.result[V]=_}}let Y=$.workflow.parent;$.context.lib=Y.context.libs.find((V)=>V.name===J),await b({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var Y6={hits:gQ,init:hQ,resolve:_1};import mQ from"lodash.clonedeep";async function cQ({node:$}){return $.definition.hasOwnProperty("output")}async function lQ({node:$,initNode:Q}){$.type="output",await D({node:$,initNode:Q}),$.resolve=G1}async function G1({node:$,resolveTypeCommon:Q,resolveNextBlock:Z,transformExpression:X}){$.context.transform=$.context.transform||mQ($.definition),await b({node:$,transformExpression:X}),await Q({node:$}),Z({node:$})}var V6={hits:cQ,init:lQ,resolve:G1};var z1=({path:$})=>{if(!$)throw Error("Path is required");let Q=/^@([^\/]+\/[^\/]+)(?:\/(.+))?$/,Z=/^([^\/]+)(?:\/(.+))?$/,X;if(X=$.match(Q))return{path:$,package:"@"+X[1],subpath:X[2]||null};else if(X=$.match(Z))return{path:$,package:X[1],subpath:X[2]||null};return null};class B1{#Q;#$;#Z;#X;#J;#C;#R;#H;#G;#W;#_;#q;#O;#M;#U;#A;#T;#B;#F;#V;#I;#K=[];constructor($){this.#Q=new B6,this.#$=$,this.#C=[],this.#R=[],this.#H={},this._expire_ttl=3600,this._expire_ttl_short=300,this.#K.push(h({key:"config",npm:"@fnet/config",master:"name"})),this.#K.push(h({key:"yaml",npm:"@fnet/yaml",master:"file"})),this.#K.push(h({key:"prompt",npm:"@fnet/prompt",master:"message"})),this.#K.push(h({key:"html-link",npm:"@flownet/lib-load-browser-link-url",master:"src"})),this.#K.push(h({key:"html-script",npm:"@flownet/lib-load-browser-script-url",master:"src"})),this.#K.push(h({key:"http-server",npm:"@fnet/node-express",master:"server_port"})),this.#K.push(h({key:"shell",npm:"@fnet/shell-flow",master:"commands"})),this.#K.push(h({key:"list-files",npm:"@fnet/list-files",master:"pattern"})),this.#K.push(h({key:"up-list-files",npm:"@fnet/up-list-files",master:"pattern"})),this.#K.push(h({key:"auto-conda-env",npm:"@fnet/auto-conda-env",master:"envDir"})),this.#K.push(h({key:"ollama-chat",npm:"@fnet/ollama-chat",master:"model"})),this.#K.push(h({key:"ai",npm:"@fnet/ai",master:"prompt",extras:{subtype:"flow"}})),this.#K.push(h({key:"invoke",npm:"@fnet/invoke",master:"method",extras:{}})),this.#K.push(h({key:"fetch",npm:"@fnet/fetch",master:"url",extras:{}})),this.#K.push(h({key:"filemap",npm:"@fnet/filemap",master:"target",extras:{}})),this.#V={packageDependencies:this.#C,packageDevDependencies:this.#R,setProgress:this.setProgress.bind(this),context:this.#$,Atom:H0,registerToPackageManager:this.registerToPackageManager.bind(this)},this.#I={initNode:this.initNode.bind(this),cloneDeep:O1,resolveTypeCommon:this.resolveTypeCommon.bind(this),resolveNextBlock:J6,transformExpression:this.transformExpression.bind(this),transformValue:this.transformValue.bind(this)}}async _cache_set($,Q,Z){}async init(){this.#_=this.#$.buildId||A1(),this.#V.buildId=this.#_,this.#U=this.#$.mode,this.#A=["all","deploy","build","file"].includes(this.#U),this.#T=["all","deploy","build"].includes(this.#U),this.#B=["all","deploy"].includes(this.#U),this.#F=["all","deploy","build","file","bpmn"].includes(this.#U),this.#O=this.#$.protocol,this.#q="BUILD:"+this.#_,this.#M=(await iQ({optional:!0,name:"atom",dir:this.#$.projectDir,tags:this.#$.tags}))?.data;try{await this.setProgress({message:"Initialization started."});let $=this.#V.context.project;await this.initAuth(),await this.initWorkflow(),this.transformWorkflow({workflow:this.#X});let Q=await this.initNodeTree({workflow:this.#X});if(await this.initNodeTreeIndex({root:Q}),await this.initNodeCalls({root:Q}),await this.initNodeCallLibs({root:Q}),await this.initNodeForms({root:Q}),await this.initNodeFormLibs({root:Q}),await this.initEntryFiles({root:Q,features:this.#Z.doc.features}),await this.initFeaturesFromNodes({childs:Q.childs,features:this.#Z.doc.features}),await Q$(this.#V),$.runtime.type==="bun")await X$(this.#V);else await Z$(this.#V);await this.initAtomLibsAndDeps({libs:Q.context.libs,packageDependencies:this.#C}),await this.resolveNodeTree({root:Q}),this.#W=Q}catch($){throw await this._cache_set(this.#q,{status:"FAILED",message:$?.message||$}),$}}async initAuth(){if(!this.#$.id)return;this.#G=await this.#Q.init({config:this.#M}),this.#V.atomAccessToken=this.#G}async initWorkflow(){let $=this.#$.id;this.#Z=this.#$.project?.workflowAtom||await H0.get({id:$}),this.#X=typeof this.#Z.doc.content==="string"?(await rQ({content:this.#Z.doc.content,tags:this.#$.tags})).parsed:this.#Z.doc.content;let Q=this.#Z.doc.bundleName;Q=Q||(this.#Z.doc.name||"").toUpperCase().replace(/[^A-Z0-9]/g,"_"),this.#Z.doc.bundleName=Q,this.#Z.type=this.#Z.type||"workflow",this.#V.atom=this.#Z,this.#Z.doc.features=this.#Z.doc.features||{}}#j($){if(console.log("filePath",$),I.statSync($).isDirectory())I.readdirSync($).forEach((Q)=>{let Z=j.join($,Q);this.#j(Z)}),I.rmSync($);else I.unlinkSync($)}#L($,Q){let Z=I.existsSync($),X=Z&&I.statSync($);if(Z&&X.isDirectory())I.mkdirSync(Q,{recursive:!0}),I.readdirSync($).forEach((J)=>{this.#L(j.join($,J),j.join(Q,J))});else I.copyFileSync($,Q)}async initWorkflowDir(){this.setProgress({message:"Initializing library directory."});let $=this.#$.projectDir,Q=this.#$.coreDir;this.setProgress({message:"Cleaning project directory."});let Z=n5({dir:$,ignore:[".cache","node_modules",".conda",".bin",".dev"],absolute:!0});for(let V of Z)I.rmSync(V,{recursive:!0,force:!0});if(this.setProgress({message:"Creating project directory."}),!I.existsSync($))I.mkdirSync($,{recursive:!0});let X=j.join($,"src");if(!I.existsSync(X))I.mkdirSync(X,{recursive:!0});let q=j.join(X,"core");this.#L(Q,q);let J=j.join(X,"default","blocks");if(!I.existsSync(J))I.mkdirSync(J,{recursive:!0});let Y=j.join($,".dev");if(!I.existsSync(Y))I.mkdirSync(Y,{recursive:!0})}async initNunjucks(){this.setProgress({message:"Initializing nunjucks."});let $=this.#$.templateDir;this.#J=q8.configure($,{watch:!1,dev:!0}),this.#V.njEnv=this.#J}transformWorkflow({workflow:$}){for(let Q of Object.values($))Q.steps=Q.steps||[],Q.steps=Q.steps.filter((Z)=>Object.keys(Z).length>0),Q.steps=Q.steps.map((Z)=>this.transformStep({step:Z}))}transformStep({step:$}){if(Array.isArray($))throw Error("Step must be an object.");let[Q,Z]=Object.entries($)[0];if(Z.hasOwnProperty("onerror")){let{onerror:X,...q}=Z;$[Q]={try:q,except:X}}if($[Q].hasOwnProperty("steps")){let X=$[Q].steps;if(!Array.isArray(X))throw Error("Steps must be an array.");$[Q].steps=X.map((q)=>this.transformStep({step:q}))}return $}async initNodeTree({workflow:$}){let Q=Object.keys($),Z={definition:$,name:void 0,type:"root",parent:void 0,childs:[],blockAutoJumpToParent:!0,blockAutoJumpToSibling:!0,index:0,depth:0,context:{libs:[],atom:this.#Z}};Q.forEach((X)=>{let q={name:X,type:X==="main"?"workflow":"subworkflow",childs:[],parent:Z,definition:$[X],index:Z.childs.length,depth:Z.depth+1,context:{},blockAutoJumpToParent:!0,blockAutoJumpToSibling:!1};Z.childs.push(q)});for await(let X of Z.childs)await this.initNode({node:X});return Z}async initNode({node:$}){let Q={...this.#I,node:$};if($.workflow=$.parent.workflow||$,$.depth=$.parent.depth+1,await n$.hits(Q))await n$.init(Q);else if(await s$.hits(Q))await s$.init(Q);else if(await Z8.hits(Q))await Z8.init(Q);else if(await i$.hits(Q))await i$.init(Q);else if(await o$.hits(Q))await o$.init(Q);else if(await X8.hits(Q))await X8.init(Q);else if(await Y6.hits(Q))await Y6.init(Q);else if(await a$.hits(Q))await a$.init(Q);else if(await $6.hits(Q))await $6.init(Q);else if(await Q6.hits(Q))await Q6.init(Q);else if(await Z6.hits(Q))await Z6.init(Q);else if(await e$.hits(Q))await e$.init(Q);else if(await X6.hits(Q))await X6.init(Q);else if(await q6.hits(Q))await q6.init(Q);else if(await t$.hits(Q))await t$.init(Q);else if(this.#K.find((Z)=>Z.hits(Q)))await this.#K.find((Z)=>Z.hits(Q)).init(Q);else if(await r$.hits(Q))await r$.init(Q);else if(await V6.hits(Q))await V6.init(Q);else throw Error("Undefined step type.")}async initNodeTreeIndex({root:$}){let Q={};$.indexKey="/";for await(let Z of $.childs)await this.initNodeIndex({node:Z,index:Q});return $.context.index=Q,Q}async initNodeIndex({node:$,index:Q}){let Z=j.join($.parent.indexKey,$.name);$.indexKey=Z,Q[Z]=$;let X=[],q=$;while(q?.parent)X.push(q.index),q=q.parent;X.reverse(),$.codeKey=`B_${X.join("_")}_${$.type}`,$.pathKey=`${X.join(".")}`,$.typeId=A1();for await(let J of $.childs)await this.initNodeIndex({node:J,index:Q})}async initNodeCalls({root:$}){let Q=$.context.index,Z=[];for await(let X of Object.keys(Q)){let q=Q[X];if(q.type!=="call"&&q.type!=="new")continue;Z.push(q)}return $.context.calls=Z,Z}async initNodeCallLibs({root:$}){let Q=[],Z=$.context.calls;for await(let X of Z){let q=X.definition.from||X.definition.import||X.definition.call,J=await this.findNodeCallTarget({refNode:X,curNode:X.parent})||{name:q,type:"atom",definition:X.definition},Y=Q.find((V)=>V.name===J.name&&V.type===J.type);if(!Y)Q.push(J);X.target=Y||J}return $.context.callLibs=Q,$.context.libs=[...$.context.libs,...Q],Q}async findNodeCallTarget({refNode:$,curNode:Q}){if(!Q)return;let Z=$.definition.call,X=Q.childs.find((q)=>q.name===Z&&q.type==="subworkflow");if(X)return X;else return await this.findNodeCallTarget({refNode:$,curNode:Q.parent})}async initNodeForms({root:$}){let Q=$.context.index,Z=[];for await(let X of Object.keys(Q)){let q=Q[X];if(q.type!=="form")continue;Z.push(q)}return $.context.forms=Z,Z}async initNodeFormLibs({root:$}){let Q=[],Z=$.context.forms;for await(let X of Z){let q=X.definition.from||X.definition.import||X.definition.form,J=await this.findNodeCallTarget({refNode:X,curNode:X.parent})||{name:q,type:"atom"},Y=Q.find((V)=>V.name===J.name&&V.type===J.type);if(!Y)Q.push(J);X.target=Y||J}return $.context.formLibs=Q,$.context.libs=[...$.context.libs,...Q],Q}async initFeaturesFromNodes({childs:$,features:Q}){for await(let Z of $){if(Z.type==="form"&&!Reflect.has(Q,"form"))Q.form=!0;await this.initFeaturesFromNodes({childs:Z.childs,features:Q})}}async initEntryFiles({root:$,features:Q}){for await(let Z of $.childs){let X;if(Z.name==="main")X="index.js";else if(Z.name==="cli")X="cli.js";else if(Z.name==="app")X="app.js";else if(Z.name==="api")X="api.js";else continue;Q[`${Z.name}_default_entry_file`]=X,Z.entryFile=X}}async findNodeFormTarget({refNode:$,curNode:Q}){if(!Q)return;let Z=$.definition.form,X=Q.childs.find((q)=>q.name===Z&&q.type==="subworkflow");if(X)return X;else return await this.findNodeFormTarget({refNode:$,curNode:Q.parent})}async initAtomLibsAndDeps({libs:$,packageDependencies:Q}){let Z=$.filter((X)=>X.type==="atom");for(let X=0;X<Z.length;X++){let q=Z[X],J=await this.findAtomLibrary({url:q.name,libRef:q});q.atom=J,J.doc.dependencies?.filter((V)=>typeof V.repo>"u"||V.repo==="npm")?.forEach((V)=>{let W=Q.find((H)=>H.package===V.package);if(W){if(typeof V.path==="string"){if(!(W.path||[]).some((H)=>H===V.path))W.path=W.path||[],W.path.push(V.path)}else if(Array.isArray(V.path))V.path.forEach((H)=>{if(!(W.path||[]).some((K)=>K===H))W.path=W.path||[],W.path.push(H)})}else Q.push(V)})}Q.sort((X,q)=>X.package?.localeCompare(q.package))}async findAtomLibrary({url:$,libRef:Q}){let Z=pQ({url:$});if(!Z)throw Error(`Invalid package name: ${$}`);if(!Z.protocol)Z.protocol=this.#O;if(Z.protocol==="src:"){let X=j.resolve(this.#$.projectSrcDir,`${Z.pathname}.js`),q=[],Y=(await nQ({file:X,recursive:!0})).all;for await(let W of Y){if(W.type!=="npm")continue;if(q.find((K)=>K.package===W.package))continue;let H=await P0({name:W.package,projectDir:this.#$.projectDir,setProgress:this.#V.setProgress});q.push({package:W.package,subpath:W.subpath,version:H.minorRange,type:"npm"})}return{name:Z.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:q},protocol:Z.protocol}}else if(Z.protocol==="npm:"){let X=z1({path:Z.pathname}),q=await P0({name:X.package,subpath:X.subpath,projectDir:this.#$.projectDir,setProgress:this.#V.setProgress});return{name:Z.pathname,doc:{type:"workflow.lib",subtype:Q?.definition?.subtype==="flow"?"workflow":null,"content-type":"javascript",language:"js",dependencies:[{package:X.package,version:q.minorRange,type:"npm"}]},protocol:Z.protocol}}else if(Z.protocol==="use:")return{name:Z.pathname,doc:{type:"function",dependencies:[]},protocol:Z.protocol};else if(Z.protocol==="node:")return{name:Z.pathname,doc:{type:"workflow.lib","content-type":"javascript",language:"js",dependencies:[]},protocol:Z.protocol};else if(Z.protocol==="ac:"){let X=Z.pathname.split("/");if(X.length===1)return await H0.first({where:{name:$,parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"workflow.lib"}});if(X.length===2){let q=await H0.first({where:{name:X[0],parent_id:this.#M.env.ATOM_LIBRARIES_ID,type:"folder"}});return await H0.first({where:{name:X[1],parent_id:q.id,type:"workflow.lib"}})}}}async resolveNodeTree({root:$}){for await(let Q of $.childs)await this.resolveTypeWorkflow({node:Q})}async resolveTypeWorkflow({node:$}){$.context.transform=$.context.transform||O1($.definition);let Q=$.context.transform;for(let Z=0;Z<Q.params?.length;Z++){let X=Q.params[Z];if(typeof X==="string")Q.params[Z]={key:X,hasDefault:!1};else{let q=Object.keys(X)[0];Q.params[Z]={key:q,hasDefault:!0,default:X[q],type:typeof X[q]}}}$.context.next=$.childs[0];for await(let Z of $.childs)await this.resolveType({node:Z})}async resolveType({node:$}){let Q={...this.#I,node:$};if(typeof $.resolve==="function")await $.resolve(Q);for await(let Z of $.childs)await this.resolveType({node:Z})}async resolveTypeCommon({node:$}){let Q=$.context.transform;if(Q.hasOwnProperty("page"))Q.page=await this.transformExpression(Q.page);if(Q.hasOwnProperty("print"))Q.print=await this.transformExpression(Q.print);if(Q.hasOwnProperty("sleep"))Q.sleep=await this.transformExpression(Q.sleep);if(Q.hasOwnProperty("assert"))Q.assert=await this.transformExpression(Q.assert)}async createAtomLibFiles({root:$}){await this.setProgress({message:"Creating external lib files."}),this.#Z.typesDir="./types";let Z=$.context.libs.filter((X)=>X.type==="atom");for(let X=0;X<Z.length;X++){let J=Z[X].atom,Y=this.#$.projectDir;if(J.protocol==="src:"){let V=j.resolve(this.#$.projectSrcDir,`${J.fileName||J.name}.js`),W=j.relative(`${this.#$.projectDir}/src/default/blocks`,V);if(!I.existsSync(V)){I.mkdirSync(j.dirname(V),{recursive:!0});let H=`export default async (input)=>{
|
|
7
|
+
`;H+="}",I.writeFileSync(V,H,"utf8")}J.relativePath=W.split(j.sep).join("/"),this.#Z.typesDir=`./types/${j.basename(Y)}/src`}else if(J.protocol==="npm:")J.relativePath=J.name;else if(J.protocol==="node:")J.relativePath=J.name;else if(J.protocol==="use:");else{let V=`${Y}/src/libs/${J.id}.js`,W=J.doc.contents?.find((H)=>H.format==="esm")||J.doc;I.writeFileSync(j.normalize(V),W.content,"utf8")}}}async createEngine({root:$}){await this.setProgress({message:"Creating engine file."});let Q=this.#$.templateDir,Z=q8.compile(I.readFileSync(j.resolve(Q,"src/default/engine.js.njk"),"utf8"),this.#J);for(let X=0;X<$.childs.length;X++){let q=$.childs[X];if(!q.entryFile)continue;let J=Z.render({flow:q,ui:{package:"@fnet/react-app"}}),Y=this.#$.projectDir,V=j.resolve(Y,`src/default/${q.entryFile}`);I.writeFileSync(V,J,"utf8")}}async createNodeTree({root:$}){await this.setProgress({message:"Creating block files."});for await(let Q of $.childs)await this.createTypeWorkflow({node:Q})}async createTypeWorkflow({node:$}){let Q=this.#$.templateDir,X=q8.compile(I.readFileSync(j.resolve(Q,"src/default/workflow.js.njk"),"utf8"),this.#J).render($),q=this.#$.projectDir,J=j.resolve(q,`src/default/${$.codeKey}.js`);I.writeFileSync(J,X,"utf8");for await(let Y of $.childs)await this.createType({node:Y})}async createType({node:$}){switch($.type){case"assign":case"steps":case"return":case"call":case"new":case"form":case"raise":case"switch":case"next":case"tryexcept":case"for":case"signal":case"wait":case"modules":case"output":this.createBlockFromTemplate({node:$});break;default:break}for await(let Q of $.childs)await this.createType({node:Q})}createBlockFromTemplate({node:$}){let Q=this.getBlockTemplate({node:$});$.context.render=Q.render($),this.createStepFile({node:$})}getBlockTemplate({node:$}){let Q=this.#H[$.type];if(Q)return Q;let Z=this.#$.templateDir;return Q=q8.compile(I.readFileSync(j.resolve(Z,`src/default/blocks/${$.type}.js.njk`),"utf8"),this.#J),this.#H[$.type]=Q,Q}createStepFile({node:$}){let Q=this.#$.projectDir,Z=`${$.codeKey}.js`,X=j.resolve(Q,`src/default/blocks/${Z}`);I.writeFileSync(X,$.context.render,"utf8"),$.context.fileName=Z,$.context.filePath=X}async transformExpression($){let Q=await this.transformValue($);return Q=JSON.stringify(Q),Q=this.replaceSpecialPattern(Q),Q}async transformValue($){if(Array.isArray($))for(let Q=0;Q<$.length;Q++)$[Q]=await this.transformValue($[Q]);else if(dQ($)){let Q=Object.keys($);for(let Z=0;Z<Q.length;Z++){let X=Q[Z],q=L1({expression:X});if(q)if(q.processor==="e"){let J=$[X].replace(/(\r\n|\n|\r)/g,"");$[q.statement]=`$::${J}::`,delete $[X]}else $[X]=await this.transformValue($[X]);else $[X]=await this.transformValue($[X])}}else if(typeof $==="string"){let Q=L1({expression:$});if(Q){let{processor:Z,statement:X}=Q;switch(Z){case"v":$=`$::v.${X}::`;break;case"e":$=`$::${X}::`;break;case"m":$=`$::c.module?.${X}||flow.module?.${X}::`;break;case"f":$=`$::c.form.${X}::`;break;case"for":$=`$::caller.for.${X}::`;break}}}return $}replaceSpecialPattern($){let Q=/"\$::(.*?)::"/g;return $.replace(Q,"$1")}replaceExpressionLegacy($){let Q=/(?<outer>"\${(?<inner>[^{]*)}")/g;return $.replaceAll(Q,"$2")}async createProjectYaml(){await this.setProgress({message:"Creating fnet.yaml"});let{content:Z,...X}=this.#Z.doc,q=this.#$.projectDir,J=j.resolve(q,"fnet.yaml");I.writeFileSync(J,U1.stringify(X),"utf8")}async createProjectMainYaml(){await this.setProgress({message:"Creating flow.main.yaml"});let Z={content:U1.stringify(this.#X)},X=this.#$.templateDir,J=q8.compile(I.readFileSync(j.resolve(X,"flow.main.yaml.njk"),"utf8"),this.#J).render(Z),Y=this.#$.projectDir,V=j.resolve(Y,"flow.main.yaml");I.writeFileSync(V,J,"utf8")}async runPrettifier(){let $=this.#$.projectDir;if(J0("bun")){let Q=await M1("prettier --write .",{cwd:j.resolve($,"src")});if(Q.code!==0)throw Error(Q.stderr)}else{let Q=await M1("prettier --write .",{cwd:j.resolve($,"src")});if(Q.code!==0)throw Error(Q.stderr)}}async deploy(){if(await this.setProgress({message:"Deploying."}),this.#$.project?.devops){let $=[this.#$.project?.devops];for(let Q=0;Q<$.length;Q++){let Z=$[Q];if(await this.deployProject({deploymentProject:Z}),Z.isDirty===!0)await Z.save()}}else if(this.#Z.id){let $=await H0.list({type:"workflow.deploy",parent_id:this.#Z.id});for(let Q=0;Q<$.length;Q++){let Z=$[Q];if(await this.deployProject({deploymentProject:Z}),Z.isDirty===!0)Z=await H0.update(Z,{id:Z.id})}}}async deployProject($){let{deploymentProject:Q}=$,{yamlDocument:Z}=Q;if(Q.doc.targets&&Array.isArray(Q.doc.targets))throw Error("Deployment project targets are deprecated. Please update targets in the yaml file.");let X=Object.keys(Q.doc||{}),q=Z||{};for(let J=0;J<X.length;J++){let Y=Q.doc[X[J]];Y.name=X[J];let V=q.get(X[J]);await h6({...this.#V,deploymentProject:Q,deploymentProjectTarget:Y,yamlTarget:V})}}async registerToPackageManager($){let{target:Q,packageJSON:Z}=$;if(!this.#$.id)return;let X=await H0.first({name:Q.params.name,parent_id:this.#M.env.ATOM_PACKAGES_ID});if(!X)X=await H0.create({parent_id:this.#M.env.ATOM_PACKAGES_ID,doc:{name:Q.params.name,type:"pm",versions:[{v:Z.version}]}});else X.doc.versions.splice(0,0,{v:Z.version}),await H0.update(X,{id:X.id})}async setProgress($){let Q=typeof $==="string"?$:$?.message;console.log(sQ.blue(Q)),await this._cache_set(this.#q,{status:"IN_PROGRESS",message:Q})}async build(){if(this.#F&&!this.#A)return await this.createNetwork();try{let $=this.#F?await K8({root:this.#W}):void 0;if(this.#A){let Q=this.#V.context.project;if(await this.initWorkflowDir(),await this.initNunjucks(),this.#F){let Z=this.#$.project?.projectDir||this.#$.projectDir;if(Z=j.resolve(Z,"fnet"),I.existsSync(Z)){if(I.existsSync(j.resolve(Z,"flow.bpmn")))I.unlinkSync(j.resolve(Z,"flow.bpmn"));I.writeFileSync(j.resolve(Z,"flows.bpmn"),$.diagramXML,"utf8");let X=j.resolve(Z,"bpmn");if(!I.existsSync(X))I.mkdirSync(X,{recursive:!0});let q=await d6({root:this.#W});for(let J of q){let Y=`${J.flowName}.bpmn`,V=j.resolve(X,Y);I.writeFileSync(V,J.diagramXML,"utf8")}}}if(await this.createAtomLibFiles({root:this.#W}),await this.createEngine({root:this.#W}),await this.createNodeTree({root:this.#W}),await this.createProjectYaml(),await A$(this.#V),await O$(this.#V),await M$(this.#V),await U$(this.#V),await Y$(this.#V),await q$(this.#V),Q.runtime.type==="bun")await _$(this.#V);else await H$(this.#V);if(await J$(this.#V),await L$(this.#V),await B$(this.#V),this.#T){if(await R$(this.#V),await C$(this.#V),this.#B)await this.deploy()}}await this._cache_set(this.#q,{status:"COMPLETED",data:{network:$}})}catch($){throw await this._cache_set(this.#q,{status:"FAILED",message:$.message||$}),$}}async createNetwork(){try{let $=await K8({root:this.#W});await this._cache_set(this.#q,{status:"COMPLETED",data:{...$}})}catch($){throw await this._cache_set(this.#q,{status:"FAILED",message:$.message||$}),$}}}var R0=B1;var oQ={command:"build",describe:"Build flownet project",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"],describe:"Build mode"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("dev",{type:"boolean",default:!1,describe:"Development mode"})},handler:async($)=>{try{let Q=await w($),Z=new R0(Q);await Z.init(),await Z.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Q){console.error("Building workflow failed!",Q.message),process.exit(1)}}},R1=oQ;var aQ={command:"build:dev",describe:"Build flownet project",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"],describe:"Build mode"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("dev",{type:"boolean",default:!1,describe:"Development mode"})},handler:async($)=>{try{$.dev=!0;let Q=await w($),Z=new R0(Q);await Z.init(),await Z.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Q){console.error("Building workflow failed!",Q.message),process.exit(1)}}},C1=aQ;var tQ={command:"deploy",describe:"Build and deploy flownet project",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"})},handler:async($)=>{try{let Q=await w({...$,mode:"all"}),Z=new R0(Q);await Z.init(),await Z.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Q){console.error("Building workflow failed!",Q.message),process.exit(1)}}},I1=tQ;var eQ={command:"file",describe:"Just create files",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"})},handler:async($)=>{try{let Q=await w({...$,mode:"file"}),Z=new R0(Q);await Z.init(),await Z.build(),console.log("Building workflow succeeded!"),process.exit(0)}catch(Q){console.error("Building workflow failed!",Q.message),process.exit(1)}}},F1=eQ;import T1 from"path";import N8 from"fs";import $2 from"@fnet/prompt";var Q2={command:"input [name]",describe:"Create or modify an input config file",builder:($)=>{return $.positional("name",{type:"string",demandOption:!1,describe:"Input name"})},handler:async($)=>{try{let Q=await w($),{project:Z}=Q,{projectDir:X,projectFileParsed:q}=Z,J=q.input;if(!J)throw Error("Config schema not found in project file.");if(!Reflect.has($,"name")){let{inputName:_}=await $2({type:"input",name:"inputName",message:"Input name:",initial:"dev"});$.name=_}let Y=T1.resolve(X,".fnet");if(!N8.existsSync(Y))N8.mkdirSync(Y);let V=T1.resolve(Y,`${$.name}.fnet`),W=N8.existsSync(V),H=(await import("@fnet/object-from-schema")).default,K=await H({schema:J,format:"yaml",ref:W?V:void 0});N8.writeFileSync(V,K)}catch(Q){console.error(Q.message),process.exit(1)}}},j1=Q2;import F from"path";import C from"fs";import E8 from"os";import{spawn as k8}from"child_process";import B from"chalk";import M0 from"@fnet/prompt";import P8 from"chalk";import w1 from"@fnet/prompt";async function Z2($){let{items:Q,message:Z,nameField:X="name",valueField:q="name",initialValue:J=null,allowAbort:Y=!0}=$;if(!Q||Q.length===0)return console.log(P8.yellow("No items available for selection.")),null;if(Q.length===1&&!Y){let _=Q[0],G=typeof _==="string"?_:_[q];return console.log(P8.blue(`Only one option available: ${typeof _==="string"?_:_[X]}`)),G}let V=Q.map((_)=>{if(typeof _==="string")return{name:_,value:_,message:_};else return{name:_[q],value:_[q],message:_[X]||_[q]}});if(Y)V.push({name:"cancel",value:null,message:P8.yellow("Cancel")});let W=null;if(J){let _=V.findIndex((G)=>G.name===J);if(_!==-1)W=_}let H="selectedItem",{[H]:K}=await w1({type:"select",name:H,message:Z,choices:V,initial:W});if(K==="cancel")return null;return K}async function X2($){let{items:Q,message:Z,nameField:X="name",valueField:q="name",initialValues:J=[],allowAbort:Y=!0}=$;if(!Q||Q.length===0)return console.log(P8.yellow("No items available for selection.")),null;let V=Q.map((_)=>{if(typeof _==="string")return{name:_,value:_,message:_};else return{name:_[q],value:_[q],message:_[X]||_[q]}}),W=[];if(J&&J.length>0)W=V.map((_,G)=>J.includes(_.name)?G:-1).filter((_)=>_!==-1);let H="selectedItems",K=await w1({type:"multiselect",name:H,message:Z,choices:V,initial:W,hint:"(Use space to select, enter to confirm)",validate:(_)=>{if(_.length===0&&!Y)return"Please select at least one item";return!0}});if(Y&&K[H].length===0)return null;return K[H]}var W6={promptForSelection:Z2,promptForMultipleSelection:X2};var k=F.join(E8.homedir(),".fnet","express");async function b1($){$.command(["$0 [project-name]","create [project-name]"],"Create a new express project",(Q)=>{return Q.positional("project-name",{describe:"Name of the project",type:"string"}).option("yes",{alias:"y",describe:"Skip all prompts and use defaults",type:"boolean",default:!1}).option("runtime",{describe:"Runtime to use (node)",type:"string",choices:["node"],default:"node"})},async(Q)=>{await q2(Q)}).command("list","List express projects",(Q)=>{return Q.option("today",{describe:"Show only projects created today",type:"boolean",default:!1}).option("type",{describe:"Filter by project type (fnode or fnet)",type:"string",choices:["fnode","fnet"]}).option("all",{describe:"Show all projects regardless of type",type:"boolean",default:!1,alias:"a"}).option("name",{describe:"Filter by project name",type:"string"})},async(Q)=>{await J2(Q)}).command("open [project-name]","Open an express project",(Q)=>{return Q.positional("project-name",{describe:"Name of the project to open",type:"string"}).option("latest",{describe:"Open the most recent project",type:"boolean",default:!1})},async(Q)=>{await Y2(Q)}).command("move [project-name] [destination]","Move an express project to a real project location",(Q)=>{return Q.positional("project-name",{describe:"Name of the project to move",type:"string"}).positional("destination",{describe:"Destination directory",type:"string"}).option("latest",{describe:"Move the most recent project",type:"boolean",default:!1})},async(Q)=>{await V2(Q)}).command("remove [project-name]","Remove an express project",(Q)=>{return Q.positional("project-name",{describe:"Name of the project to remove",type:"string"}).option("latest",{describe:"Remove the most recent project",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Skip confirmation prompt",type:"boolean",default:!1})},async(Q)=>{await H2(Q)}).command("enter [project-name]","Enter the directory of an express project in the active terminal",(Q)=>{return Q.positional("project-name",{describe:"Name of the project to enter",type:"string"}).option("latest",{describe:"Enter the most recent project directory",type:"boolean",default:!1})},async(Q)=>{await K2(Q)}).demandCommand(1,"You need to specify a command").help()}async function q2($){try{if(!C.existsSync(k))C.mkdirSync(k,{recursive:!0});let Q=new Date().toISOString().slice(0,10).replace(/-/g,""),Z=F.join(k,Q);if(!C.existsSync(Z))C.mkdirSync(Z,{recursive:!0});let X=$.projectName,q,J=$.runtime;if(!$.yes){if(!X){let G=C.readdirSync(Z).filter((U)=>U.startsWith("fnet-")).map((U)=>parseInt(U.replace("fnet-",""),10)).filter((U)=>!isNaN(U)),O=`fnet-${G.length>0?Math.max(...G)+1:1}`;X=(await M0([{type:"input",name:"projectName",message:"Enter project name:",default:O}])).projectName}J=(await M0({type:"select",name:"runtime",message:"Select runtime:",choices:["node"],initial:J||"node"})).runtime}else{if(!X){let K=C.readdirSync(Z).filter((G)=>G.startsWith("fnet-")).map((G)=>parseInt(G.replace("fnet-",""),10)).filter((G)=>!isNaN(G));X=`fnet-${K.length>0?Math.max(...K)+1:1}`}if(!J)J="node"}if(q=F.join(Z,X),C.existsSync(q)){let K=1;while(C.existsSync(F.join(Z,`${X}-${K}`)))K++;X=`${X}-${K}`,q=F.join(Z,X)}if(!$.yes){if(!(await M0([{type:"confirm",name:"proceed",message:`Create express project "${X}" in ${q}?`,default:!0}])).proceed){console.log(B.yellow("Project creation cancelled."));return}}console.log(B.blue(`Creating express project "${X}" in ${q}...`));let Y=F.dirname(q),W=["create","--name",F.basename(q)];if(W.push("--runtime",J),$.yes)W.push("--yes");if(!C.existsSync(Y))C.mkdirSync(Y,{recursive:!0});let H=k8("fnet",W,{stdio:"inherit",shell:!0,cwd:Y});return new Promise((K,_)=>{H.on("close",(G)=>{if(G===0)if(console.log(B.green(`
|
|
8
8
|
Express project "${X}" created successfully!`)),console.log(B.blue(`
|
|
9
|
-
Project location: ${q}`)),!$.yes)
|
|
10
|
-
Failed to create express project "${X}".`)),
|
|
9
|
+
Project location: ${q}`)),!$.yes)W2(q);else K();else console.error(B.red(`
|
|
10
|
+
Failed to create express project "${X}".`)),_(Error(`Process exited with code ${G}`))})})}catch(Q){console.error(B.red(`Error creating express project: ${Q.message}`)),process.exit(1)}}async function J2($){try{if(!C.existsSync(k)){console.log(B.yellow("No express projects found."));return}let Q=C.readdirSync(k).filter((Y)=>/^\d{8}$/.test(Y)).sort((Y,V)=>V.localeCompare(Y));if($.today){let Y=new Date().toISOString().slice(0,10).replace(/-/g,""),V=Q.indexOf(Y);if(V===-1){console.log(B.yellow("No express projects found for today."));return}Q.splice(0,V),Q.splice(1)}let Z=[];if(!$.type&&!$.all)$.type="fnet";for(let Y of Q){let V=F.join(k,Y),W=C.readdirSync(V);for(let H of W){let K=F.join(V,H),_=C.statSync(K),G="unknown";if(H.startsWith("fnode-")||C.existsSync(F.join(K,"fnode.yaml")))G="fnode";else if(H.startsWith("fnet-")||C.existsSync(F.join(K,"fnet.yaml")))G="fnet";if($.type&&G!==$.type)continue;if($.name&&!H.includes($.name))continue;let M=`${Y.slice(0,4)}-${Y.slice(4,6)}-${Y.slice(6,8)}`;Z.push({name:H,type:G,date:M,path:K,created:_.birthtime})}}if(Z.sort((Y,V)=>V.created-Y.created),Z.length===0){console.log(B.yellow("No express projects found matching the criteria."));return}console.log(B.blue(`
|
|
11
11
|
Express Projects:`));let X=(await import("./index.h0bm9hcc.js")).default,q=["NAME","TYPE","DATE","PATH"],J=X.createTable(q,{chars:{mid:"","mid-mid":"","left-mid":"","right-mid":""}});for(let Y of Z){let V=Y.path;if(V.startsWith(E8.homedir()))V="~"+V.substring(E8.homedir().length);J.push([B.white(Y.name),Y.type==="fnet"?B.cyan(Y.type):Y.type==="fnode"?B.green(Y.type):Y.type,Y.date,V])}console.log(J.toString()),console.log(B.blue(`
|
|
12
|
-
Total: ${Z.length} projects`))}catch(Q){console.error(B.red(`Error listing express projects: ${Q.message}`)),process.exit(1)}}async function
|
|
13
|
-
Project moved successfully to ${q}`)),(await M0({type:"confirm",name:"deleteOriginal",message:"Delete the original express project?",initial:!1})).deleteOriginal)C.rmSync(X,{recursive:!0,force:!0}),console.log(B.green("Original project deleted."));await
|
|
12
|
+
Total: ${Z.length} projects`))}catch(Q){console.error(B.red(`Error listing express projects: ${Q.message}`)),process.exit(1)}}async function Y2($){try{if(!C.existsSync(k)){console.log(B.yellow("No express projects found."));return}let Q;if($.latest){if(Q=await D8(),!Q){console.log(B.yellow("No express projects found."));return}}else if($.projectName){if(Q=await y8($.projectName),!Q){console.log(B.yellow(`Project "${$.projectName}" not found.`));return}}else{let Z=await v8();if(!Z){console.log(B.yellow("No project selected."));return}Q=F.join(k,Z)}await H6(Q)}catch(Q){console.error(B.red(`Error opening express project: ${Q.message}`)),process.exit(1)}}async function V2($){try{let Q=process.cwd(),Z=Q.includes(k),X;if(Z)X=Q,console.log(B.blue(`Using current express project: ${F.basename(X)}`));else if($.latest){if(X=await D8(),!X){console.log(B.yellow("No express projects found."));return}}else if($.projectName){if(X=await y8($.projectName),!X){console.log(B.yellow(`Project "${$.projectName}" not found.`));return}}else{let Y=await v8();if(!Y){console.log(B.yellow("No project selected."));return}X=F.join(k,Y)}let q=$.destination;if(!q)q=(await M0({type:"input",name:"destination",message:"Enter destination directory:",initial:F.join(process.cwd(),F.basename(X))})).destination;if(q.startsWith("~"))q=F.join(E8.homedir(),q.slice(1));if(q=F.resolve(q),q.startsWith(X+F.sep)||q===X){console.log(B.red("Destination cannot be inside the source directory."));return}if(C.existsSync(q)){if(!C.statSync(q).isDirectory()){console.log(B.red(`Destination "${q}" is not a directory.`));return}if(C.readdirSync(q).length>0){if(!(await M0({type:"confirm",name:"overwrite",message:`Destination "${q}" is not empty. Continue anyway?`,initial:!1})).overwrite){console.log(B.yellow("Project move cancelled."));return}}}else C.mkdirSync(q,{recursive:!0});if(console.log(B.blue(`Moving project from ${X} to ${q}...`)),N1(X,q),console.log(B.green(`
|
|
13
|
+
Project moved successfully to ${q}`)),(await M0({type:"confirm",name:"deleteOriginal",message:"Delete the original express project?",initial:!1})).deleteOriginal)C.rmSync(X,{recursive:!0,force:!0}),console.log(B.green("Original project deleted."));await H6(q)}catch(Q){console.error(B.red(`Error moving express project: ${Q.message}`)),process.exit(1)}}async function D8(){let $=C.readdirSync(k).filter((Y)=>/^\d{8}$/.test(Y)).sort((Y,V)=>V.localeCompare(Y));if($.length===0)return null;let Q=$[0],Z=F.join(k,Q),X=C.readdirSync(Z);if(X.length===0)return null;let q=null,J=0;for(let Y of X){let V=F.join(Z,Y),W=C.statSync(V);if(W.birthtimeMs>J)J=W.birthtimeMs,q=V}return q}async function y8($){let Q=C.readdirSync(k).filter((Z)=>/^\d{8}$/.test(Z)).sort((Z,X)=>X.localeCompare(Z));for(let Z of Q){let X=F.join(k,Z),q=C.readdirSync(X);if(q.includes($))return F.join(X,$);let J=q.filter((Y)=>Y.includes($));if(J.length>0)if(J.length===1)return F.join(X,J[0]);else{let Y=J.map((W)=>({name:F.join(X,W),value:F.join(X,W),message:`${W} (${Z})`})),V=await W6.promptForSelection({items:Y,message:`Multiple projects match "${$}". Please select one:`,nameField:"message",valueField:"value",allowAbort:!0});if(V===null)return console.log(B.yellow("Operation cancelled.")),null;return V}}return null}async function v8(){let $=[],Q=C.readdirSync(k).filter((X)=>/^\d{8}$/.test(X)).sort((X,q)=>q.localeCompare(X));for(let X of Q){let q=F.join(k,X),J=C.readdirSync(q);for(let Y of J){let V=F.join(q,Y),W=C.statSync(V),H=`${X}/${Y}`;$.push({name:H,value:H,created:W.birthtime})}}if($.sort((X,q)=>q.created-X.created),$.length===0)return null;let Z=await W6.promptForSelection({items:$,message:"Select a project:",nameField:"value",valueField:"value",allowAbort:!0});if(Z===null)return console.log(B.yellow("Operation cancelled.")),null;return Z}async function W2($){try{if((await M0({type:"confirm",name:"openIDE",message:"Would you like to open the project in an IDE?",initial:!0})).openIDE)await H6($)}catch(Q){console.error(B.red(`Error opening IDE: ${Q.message}`))}}async function H6($){let Q=await S1("code --version"),Z=await S1("code-insiders --version"),X=null;if(Q&&Z)X=(await M0({type:"select",name:"ide",message:"Which IDE would you like to use?",choices:[{name:"Visual Studio Code",value:"code"},{name:"Visual Studio Code Insiders",value:"code-insiders"}]})).ide;else if(Q)X="code";else if(Z)X="code-insiders";else{console.log(B.yellow("No supported IDE found. Please open the project manually.")),console.log(B.blue(`Project path: ${$}`));return}console.log(B.blue(`Opening project in ${X}...`)),console.log(B.blue(`Project path: ${$}`));let q=k8(X,[$],{stdio:"inherit",shell:!0});return new Promise((J,Y)=>{q.on("close",(V)=>{if(V===0)console.log(B.green(`Project opened in ${X}.`)),J();else console.error(B.red(`Failed to open project in ${X}.`)),Y(Error(`Process exited with code ${V}`))})})}async function S1($){return new Promise((Q)=>{k8($,{shell:!0,stdio:"ignore"}).on("close",(X)=>{Q(X===0)})})}function N1($,Q){if(!C.existsSync(Q))C.mkdirSync(Q,{recursive:!0});let Z=C.readdirSync($,{withFileTypes:!0});for(let X of Z){let q=F.join($,X.name),J=F.join(Q,X.name);if(X.isDirectory()){if(X.name===".git"||X.name===".workspace")continue;N1(q,J)}else C.copyFileSync(q,J)}}async function H2($){try{if(!C.existsSync(k)){console.log(B.yellow("No express projects found."));return}let Q;if($.latest){if(Q=await D8(),!Q){console.log(B.yellow("No express projects found."));return}}else if($.projectName){if(Q=await y8($.projectName),!Q){console.log(B.yellow(`Project "${$.projectName}" not found.`));return}}else{let X=await v8();if(!X){console.log(B.yellow("No project selected."));return}Q=F.join(k,X)}let Z=F.basename(Q);if(!$.yes){if(!(await M0({type:"confirm",name:"confirm",message:`Are you sure you want to remove project "${Z}"?`,initial:!1})).confirm){console.log(B.yellow("Project removal cancelled."));return}}console.log(B.blue(`Removing project "${Z}"...`)),C.rmSync(Q,{recursive:!0,force:!0}),console.log(B.green(`Project "${Z}" removed successfully.`))}catch(Q){console.error(B.red(`Error removing express project: ${Q.message}`)),process.exit(1)}}async function K2($){try{if(!C.existsSync(k)){console.log(B.yellow("No express projects found."));return}let Q;if($.latest){if(Q=await D8(),!Q){console.log(B.yellow("No express projects found."));return}}else if($.projectName){if(Q=await y8($.projectName),!Q){console.log(B.yellow(`Project "${$.projectName}" not found.`));return}}else{let q=await v8();if(!q){console.log(B.yellow("No project selected."));return}Q=F.join(k,q)}console.log(B.blue(`Entering project directory: ${Q}`)),console.log(B.yellow(`
|
|
14
14
|
Opening a new shell in the project directory...`));let Z=process.env.SHELL||"/bin/bash",X=k8(Z,[],{stdio:"inherit",cwd:Q,shell:!0});return new Promise((q)=>{X.on("close",()=>{console.log(B.green(`
|
|
15
|
-
Returned from project directory.`)),q()})})}catch(Q){console.error(B.red(`Error entering express project directory: ${Q.message}`)),process.exit(1)}}import
|
|
15
|
+
Returned from project directory.`)),q()})})}catch(Q){console.error(B.red(`Error entering express project directory: ${Q.message}`)),process.exit(1)}}import E1 from"path";import{fileURLToPath as M2}from"url";import _2 from"fs";import x8 from"path";import{fileURLToPath as G2}from"url";var z2=x8.dirname(G2(import.meta.url));function U2({baseDir:$}){$=$||z2;let Q=$;while(Q!==x8.parse(Q).root){let Z=x8.join(Q,"node_modules");if(_2.existsSync(Z))return Z;Q=x8.dirname(Q)}return null}var P1=U2;var O2=E1.dirname(M2(import.meta.url));function k1(){let $=P1({baseDir:O2}),Q=process.platform==="win32"?";":":";if($)process.env.PATH=`${E1.join($,"/.bin")}${Q}${process.env.PATH}`}_6();k1();async function L2(){try{let $=A2(process.argv.slice(2)).usage("Usage: $0 <command> [options]").command(A6).command(L6).command(R1).command(C1).command(I1).command(F1).command(j1).command("express","Create and manage express projects",b1);$=m($,{bin:"npm",createContext:w}),$=m($,{bin:"node",createContext:w}),$=m($,{bin:"bun",createContext:w}),$=m($,{name:"serve",bin:"bun",preArgs:["run","serve","--"],createContext:w}),$=m($,{name:"watch",bin:"bun",preArgs:["run","watch","--"],createContext:w}),$=m($,{name:"app",bin:"bun",preArgs:["run","app","--"],createContext:w}),$=m($,{name:"cli",bin:"bun",preArgs:["run","cli","--"],createContext:w}),$=m($,{name:"cli:dev",bin:"bun",preArgs:["run","cli:dev","--"],createContext:w}),$=m($,{name:"cli:compile",bin:"bun",preArgs:["run","cli:compile","--"],createContext:w}),$=m($,{name:"cli:compile:dev",bin:"bun",preArgs:["run","cli:compile:dev","--"],createContext:w}),$=m($,{name:"cli:install",bin:"bun",preArgs:["run","cli:install","--"],createContext:w}),$=m($,{name:"compile",bin:"bun",preArgs:["run","compile","--"],createContext:w}),$=M6($,{name:"install",createContext:w}),$=m($,{bin:"npx",createContext:w}),$=m($,{bin:"cdk",createContext:w}),$=m($,{bin:"aws",createContext:w}),$=z6($,{name:"with",createContext:w}),$=U6($,{name:"run",projectType:"fnet"}),$.demandCommand(1,"You need at least one command before moving on").help().version().argv}catch($){console.error(D1.red(`Fatal error: ${$.message}`)),process.exit(1)}}L2().catch(($)=>{console.error(D1.red(`Fatal error: ${$.message}`)),process.exit(1)});
|