@crossdelta/platform-sdk 0.10.1 → 0.11.0

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/bin/cli.js CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var ld=Object.create;var Hs=Object.defineProperty;var pd=Object.getOwnPropertyDescriptor;var fd=Object.getOwnPropertyNames;var dd=Object.getPrototypeOf,hd=Object.prototype.hasOwnProperty;var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),md=(e,t)=>{for(var r in t)Hs(e,r,{get:t[r],enumerable:!0})},gd=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of fd(t))!hd.call(e,s)&&s!==r&&Hs(e,s,{get:()=>t[s],enumerable:!(n=pd(t,s))||n.enumerable});return e};var b=(e,t,r)=>(r=e!=null?ld(dd(e)):{},gd(t||!e||!e.__esModule?Hs(r,"default",{value:e,enumerable:!0}):r,e));var zs=P((JC,oa)=>{"use strict";oa.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),s=t.indexOf("--");return n!==-1&&(s===-1||n<s)}});var ca=P((VC,aa)=>{"use strict";var Vd=require("os"),ia=require("tty"),pt=zs(),{env:j}=process,re;pt("no-color")||pt("no-colors")||pt("color=false")||pt("color=never")?re=0:(pt("color")||pt("colors")||pt("color=true")||pt("color=always"))&&(re=1);"FORCE_COLOR"in j&&(j.FORCE_COLOR==="true"?re=1:j.FORCE_COLOR==="false"?re=0:re=j.FORCE_COLOR.length===0?1:Math.min(parseInt(j.FORCE_COLOR,10),3));function Ks(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Js(e,t){if(re===0)return 0;if(pt("color=16m")||pt("color=full")||pt("color=truecolor"))return 3;if(pt("color=256"))return 2;if(e&&!t&&re===void 0)return 0;let r=re||0;if(j.TERM==="dumb")return r;if(process.platform==="win32"){let n=Vd.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in j)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in j)||j.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in j)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(j.TEAMCITY_VERSION)?1:0;if(j.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in j){let n=parseInt((j.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(j.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(j.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(j.TERM)||"COLORTERM"in j?1:r}function qd(e){let t=Js(e,e&&e.isTTY);return Ks(t)}aa.exports={supportsColor:qd,stdout:Ks(Js(!0,ia.isatty(1))),stderr:Ks(Js(!0,ia.isatty(2)))}});var pa=P((qC,la)=>{"use strict";var Yd=ca(),Ie=zs();function ua(e){if(/^\d{3,4}$/.test(e)){let r=/(\d{1,2})(\d{2})/.exec(e)||[];return{major:0,minor:parseInt(r[1],10),patch:parseInt(r[2],10)}}let t=(e||"").split(".").map(r=>parseInt(r,10));return{major:t[0],minor:t[1],patch:t[2]}}function Vs(e){let{CI:t,FORCE_HYPERLINK:r,NETLIFY:n,TEAMCITY_VERSION:s,TERM_PROGRAM:o,TERM_PROGRAM_VERSION:i,VTE_VERSION:a,TERM:c}=process.env;if(r)return!(r.length>0&&parseInt(r,10)===0);if(Ie("no-hyperlink")||Ie("no-hyperlinks")||Ie("hyperlink=false")||Ie("hyperlink=never"))return!1;if(Ie("hyperlink=true")||Ie("hyperlink=always")||n)return!0;if(!Yd.supportsColor(e)||e&&!e.isTTY)return!1;if("WT_SESSION"in process.env)return!0;if(process.platform==="win32"||t||s)return!1;if(o){let u=ua(i||"");switch(o){case"iTerm.app":return u.major===3?u.minor>=1:u.major>3;case"WezTerm":return u.major>=20200620;case"vscode":return u.major>1||u.major===1&&u.minor>=72;case"ghostty":return!0}}if(a){if(a==="0.50.0")return!1;let u=ua(a);return u.major>0||u.minor>=50}switch(c){case"alacritty":return!0}return!1}la.exports={supportsHyperlink:Vs,stdout:Vs(process.stdout),stderr:Vs(process.stderr)}});var Yc=P((Ax,lg)=>{lg.exports={name:"dotenv",version:"17.2.3",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard",pretest:"npm run lint && npm run dts-check",test:"tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},homepage:"https://github.com/motdotla/dotenv#readme",funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@types/node":"^18.11.3",decache:"^4.6.2",sinon:"^14.0.1",standard:"^17.0.0","standard-version":"^9.5.0",tap:"^19.2.0",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var ru=P((Px,Vt)=>{var Io=require("fs"),ts=require("path"),pg=require("os"),fg=require("crypto"),dg=Yc(),No=dg.version,Zc=["\u{1F510} encrypt with Dotenvx: https://dotenvx.com","\u{1F510} prevent committing .env to code: https://dotenvx.com/precommit","\u{1F510} prevent building .env in docker: https://dotenvx.com/prebuild","\u{1F4E1} add observability to secrets: https://dotenvx.com/ops","\u{1F465} sync secrets across teammates & machines: https://dotenvx.com/ops","\u{1F5C2}\uFE0F backup and recover secrets: https://dotenvx.com/ops","\u2705 audit secrets and track compliance: https://dotenvx.com/ops","\u{1F504} add secrets lifecycle management: https://dotenvx.com/ops","\u{1F511} add access controls to secrets: https://dotenvx.com/ops","\u{1F6E0}\uFE0F run anywhere with `dotenvx run -- yourcommand`","\u2699\uFE0F specify custom .env file path with { path: '/custom/path/.env' }","\u2699\uFE0F enable debug logging with { debug: true }","\u2699\uFE0F override existing env vars with { override: true }","\u2699\uFE0F suppress all logs with { quiet: true }","\u2699\uFE0F write to custom object with { processEnv: myObject }","\u2699\uFE0F load multiple .env files with { path: ['.env.local', '.env'] }"];function hg(){return Zc[Math.floor(Math.random()*Zc.length)]}function Ze(e){return typeof e=="string"?!["false","0","no","off",""].includes(e.toLowerCase()):!!e}function mg(){return process.stdout.isTTY}function gg(e){return mg()?`\x1B[2m${e}\x1B[0m`:e}var Dg=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function yg(e){let t={},r=e.toString();r=r.replace(/\r\n?/mg,`
3
- `);let n;for(;(n=Dg.exec(r))!=null;){let s=n[1],o=n[2]||"";o=o.trim();let i=o[0];o=o.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),i==='"'&&(o=o.replace(/\\n/g,`
4
- `),o=o.replace(/\\r/g,"\r")),t[s]=o}return t}function wg(e){e=e||{};let t=eu(e);e.path=t;let r=B.configDotenv(e);if(!r.parsed){let i=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw i.code="MISSING_DATA",i}let n=tu(e).split(","),s=n.length,o;for(let i=0;i<s;i++)try{let a=n[i].trim(),c=bg(r,a);o=B.decrypt(c.ciphertext,c.key);break}catch(a){if(i+1>=s)throw a}return B.parse(o)}function Cg(e){console.error(`[dotenv@${No}][WARN] ${e}`)}function qr(e){console.log(`[dotenv@${No}][DEBUG] ${e}`)}function Qc(e){console.log(`[dotenv@${No}] ${e}`)}function tu(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function bg(e,t){let r;try{r=new URL(t)}catch(a){if(a.code==="ERR_INVALID_URL"){let c=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw c.code="INVALID_DOTENV_KEY",c}throw a}let n=r.password;if(!n){let a=new Error("INVALID_DOTENV_KEY: Missing key part");throw a.code="INVALID_DOTENV_KEY",a}let s=r.searchParams.get("environment");if(!s){let a=new Error("INVALID_DOTENV_KEY: Missing environment part");throw a.code="INVALID_DOTENV_KEY",a}let o=`DOTENV_VAULT_${s.toUpperCase()}`,i=e.parsed[o];if(!i){let a=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${o} in your .env.vault file.`);throw a.code="NOT_FOUND_DOTENV_ENVIRONMENT",a}return{ciphertext:i,key:n}}function eu(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)Io.existsSync(r)&&(t=r.endsWith(".vault")?r:`${r}.vault`);else t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else t=ts.resolve(process.cwd(),".env.vault");return Io.existsSync(t)?t:null}function Xc(e){return e[0]==="~"?ts.join(pg.homedir(),e.slice(1)):e}function vg(e){let t=Ze(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),r=Ze(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!r)&&Qc("Loading env from encrypted .env.vault");let n=B._parseVault(e),s=process.env;return e&&e.processEnv!=null&&(s=e.processEnv),B.populate(s,n,e),{parsed:n}}function xg(e){let t=ts.resolve(process.cwd(),".env"),r="utf8",n=process.env;e&&e.processEnv!=null&&(n=e.processEnv);let s=Ze(n.DOTENV_CONFIG_DEBUG||e&&e.debug),o=Ze(n.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?r=e.encoding:s&&qr("No encoding is specified. UTF-8 is used by default");let i=[t];if(e&&e.path)if(!Array.isArray(e.path))i=[Xc(e.path)];else{i=[];for(let l of e.path)i.push(Xc(l))}let a,c={};for(let l of i)try{let p=B.parse(Io.readFileSync(l,{encoding:r}));B.populate(c,p,e)}catch(p){s&&qr(`Failed to load ${l} ${p.message}`),a=p}let u=B.populate(n,c,e);if(s=Ze(n.DOTENV_CONFIG_DEBUG||s),o=Ze(n.DOTENV_CONFIG_QUIET||o),s||!o){let l=Object.keys(u).length,p=[];for(let d of i)try{let f=ts.relative(process.cwd(),d);p.push(f)}catch(f){s&&qr(`Failed to load ${d} ${f.message}`),a=f}Qc(`injecting env (${l}) from ${p.join(",")} ${gg(`-- tip: ${hg()}`)}`)}return a?{parsed:c,error:a}:{parsed:c}}function kg(e){if(tu(e).length===0)return B.configDotenv(e);let t=eu(e);return t?B._configVault(e):(Cg(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),B.configDotenv(e))}function Eg(e,t){let r=Buffer.from(t.slice(-64),"hex"),n=Buffer.from(e,"base64"),s=n.subarray(0,12),o=n.subarray(-16);n=n.subarray(12,-16);try{let i=fg.createDecipheriv("aes-256-gcm",r,s);return i.setAuthTag(o),`${i.update(n)}${i.final()}`}catch(i){let a=i instanceof RangeError,c=i.message==="Invalid key length",u=i.message==="Unsupported state or unable to authenticate data";if(a||c){let l=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw l.code="INVALID_DOTENV_KEY",l}else if(u){let l=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw l.code="DECRYPTION_FAILED",l}else throw i}}function Sg(e,t,r={}){let n=!!(r&&r.debug),s=!!(r&&r.override),o={};if(typeof t!="object"){let i=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw i.code="OBJECT_REQUIRED",i}for(let i of Object.keys(t))Object.prototype.hasOwnProperty.call(e,i)?(s===!0&&(e[i]=t[i],o[i]=t[i]),n&&qr(s===!0?`"${i}" is already defined and WAS overwritten`:`"${i}" is already defined and was NOT overwritten`)):(e[i]=t[i],o[i]=t[i]);return o}var B={configDotenv:xg,_configVault:vg,_parseVault:wg,config:kg,decrypt:Eg,parse:yg,populate:Sg};Vt.exports.configDotenv=B.configDotenv;Vt.exports._configVault=B._configVault;Vt.exports._parseVault=B._parseVault;Vt.exports.config=B.config;Vt.exports.decrypt=B.decrypt;Vt.exports.parse=B.parse;Vt.exports.populate=B.populate;Vt.exports=B});var ks=P((mS,Nl)=>{var hi=[],Il=0,V=(e,t)=>{Il>=t&&hi.push(e)};V.WARN=1;V.INFO=2;V.DEBUG=3;V.reset=()=>{hi=[]};V.setDebugLevel=e=>{Il=e};V.warn=e=>V(e,V.WARN);V.info=e=>V(e,V.INFO);V.debug=e=>V(e,V.DEBUG);V.debugMessages=()=>hi;Nl.exports=V});var Ml=P((gS,Ol)=>{"use strict";Ol.exports=({onlyFirst:e=!1}={})=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}});var Bl=P((DS,$l)=>{"use strict";var py=Ml();$l.exports=e=>typeof e=="string"?e.replace(py(),""):e});var _l=P((yS,mi)=>{"use strict";var jl=e=>Number.isNaN(e)?!1:e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141);mi.exports=jl;mi.exports.default=jl});var Wl=P((wS,Ll)=>{"use strict";Ll.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var Hl=P((CS,gi)=>{"use strict";var fy=Bl(),dy=_l(),hy=Wl(),Gl=e=>{if(typeof e!="string"||e.length===0||(e=fy(e),e.length===0))return 0;e=e.replace(hy()," ");let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,t+=dy(n)?2:1)}return t};gi.exports=Gl;gi.exports.default=Gl});var Di=P((bS,Jl)=>{var Ul=Hl();function Es(e){return e?/\u001b\[((?:\d*;){0,5}\d*)m/g:/\u001b\[(?:\d*;){0,5}\d*m/g}function jt(e){let t=Es();return(""+e).replace(t,"").split(`
5
- `).reduce(function(s,o){return Ul(o)>s?Ul(o):s},0)}function cn(e,t){return Array(t+1).join(e)}function my(e,t,r,n){let s=jt(e);if(t+1>=s){let o=t-s;switch(n){case"right":{e=cn(r,o)+e;break}case"center":{let i=Math.ceil(o/2),a=o-i;e=cn(r,a)+e+cn(r,i);break}default:{e=e+cn(r,o);break}}}return e}var ar={};function un(e,t,r){t="\x1B["+t+"m",r="\x1B["+r+"m",ar[t]={set:e,to:!0},ar[r]={set:e,to:!1},ar[e]={on:t,off:r}}un("bold",1,22);un("italics",3,23);un("underline",4,24);un("inverse",7,27);un("strikethrough",9,29);function zl(e,t){let r=t[1]?parseInt(t[1].split(";")[0]):0;if(r>=30&&r<=39||r>=90&&r<=97){e.lastForegroundAdded=t[0];return}if(r>=40&&r<=49||r>=100&&r<=107){e.lastBackgroundAdded=t[0];return}if(r===0){for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&delete e[s];return}let n=ar[t[0]];n&&(e[n.set]=n.to)}function gy(e){let t=Es(!0),r=t.exec(e),n={};for(;r!==null;)zl(n,r),r=t.exec(e);return n}function Kl(e,t){let r=e.lastBackgroundAdded,n=e.lastForegroundAdded;return delete e.lastBackgroundAdded,delete e.lastForegroundAdded,Object.keys(e).forEach(function(s){e[s]&&(t+=ar[s].off)}),r&&r!="\x1B[49m"&&(t+="\x1B[49m"),n&&n!="\x1B[39m"&&(t+="\x1B[39m"),t}function Dy(e,t){let r=e.lastBackgroundAdded,n=e.lastForegroundAdded;return delete e.lastBackgroundAdded,delete e.lastForegroundAdded,Object.keys(e).forEach(function(s){e[s]&&(t=ar[s].on+t)}),r&&r!="\x1B[49m"&&(t=r+t),n&&n!="\x1B[39m"&&(t=n+t),t}function yy(e,t){if(e.length===jt(e))return e.substr(0,t);for(;jt(e)>t;)e=e.slice(0,-1);return e}function wy(e,t){let r=Es(!0),n=e.split(Es()),s=0,o=0,i="",a,c={};for(;o<t;){a=r.exec(e);let u=n[s];if(s++,o+jt(u)>t&&(u=yy(u,t-o)),i+=u,o+=jt(u),o<t){if(!a)break;i+=a[0],zl(c,a)}}return Kl(c,i)}function Cy(e,t,r){if(r=r||"\u2026",jt(e)<=t)return e;t-=jt(r);let s=wy(e,t);s+=r;let o="\x1B]8;;\x07";return e.includes(o)&&!s.includes(o)&&(s+=o),s}function by(){return{chars:{top:"\u2500","top-mid":"\u252C","top-left":"\u250C","top-right":"\u2510",bottom:"\u2500","bottom-mid":"\u2534","bottom-left":"\u2514","bottom-right":"\u2518",left:"\u2502","left-mid":"\u251C",mid:"\u2500","mid-mid":"\u253C",right:"\u2502","right-mid":"\u2524",middle:"\u2502"},truncate:"\u2026",colWidths:[],rowHeights:[],colAligns:[],rowAligns:[],style:{"padding-left":1,"padding-right":1,head:["red"],border:["grey"],compact:!1},head:[]}}function vy(e,t){e=e||{},t=t||by();let r=Object.assign({},t,e);return r.chars=Object.assign({},t.chars,e.chars),r.style=Object.assign({},t.style,e.style),r}function xy(e,t){let r=[],n=t.split(/(\s+)/g),s=[],o=0,i;for(let a=0;a<n.length;a+=2){let c=n[a],u=o+jt(c);o>0&&i&&(u+=i.length),u>e?(o!==0&&r.push(s.join("")),s=[c],o=jt(c)):(s.push(i||"",c),o=u),i=n[a+1]}return o&&r.push(s.join("")),r}function ky(e,t){let r=[],n="";function s(i,a){for(n.length&&a&&(n+=a),n+=i;n.length>e;)r.push(n.slice(0,e)),n=n.slice(e)}let o=t.split(/(\s+)/g);for(let i=0;i<o.length;i+=2)s(o[i],i&&o[i-1]);return n.length&&r.push(n),r}function Ey(e,t,r=!0){let n=[];t=t.split(`
6
- `);let s=r?xy:ky;for(let o=0;o<t.length;o++)n.push.apply(n,s(e,t[o]));return n}function Sy(e){let t={},r=[];for(let n=0;n<e.length;n++){let s=Dy(t,e[n]);t=gy(s);let o=Object.assign({},t);r.push(Kl(o,s))}return r}function Fy(e,t){return["\x1B]","8",";",";",e||t,"\x07",t,"\x1B]","8",";",";","\x07"].join("")}Jl.exports={strlen:jt,repeat:cn,pad:my,truncate:Cy,mergeOptions:vy,wordWrap:Ey,colorizeLines:Sy,hyperlink:Fy}});var Zl=P((vS,Yl)=>{var ql={};Yl.exports=ql;var Vl={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(Vl).forEach(function(e){var t=Vl[e],r=ql[e]=[];r.open="\x1B["+t[0]+"m",r.close="\x1B["+t[1]+"m"})});var Ql=P((xS,Xl)=>{"use strict";Xl.exports=function(e,t){t=t||process.argv;var r=t.indexOf("--"),n=/^-{1,2}/.test(e)?"":"--",s=t.indexOf(n+e);return s!==-1&&(r===-1?!0:s<r)}});var ep=P((kS,tp)=>{"use strict";var Ty=require("os"),Tt=Ql(),tt=process.env,cr=void 0;Tt("no-color")||Tt("no-colors")||Tt("color=false")?cr=!1:(Tt("color")||Tt("colors")||Tt("color=true")||Tt("color=always"))&&(cr=!0);"FORCE_COLOR"in tt&&(cr=tt.FORCE_COLOR.length===0||parseInt(tt.FORCE_COLOR,10)!==0);function Ay(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Py(e){if(cr===!1)return 0;if(Tt("color=16m")||Tt("color=full")||Tt("color=truecolor"))return 3;if(Tt("color=256"))return 2;if(e&&!e.isTTY&&cr!==!0)return 0;var t=cr?1:0;if(process.platform==="win32"){var r=Ty.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in tt)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(s){return s in tt})||tt.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in tt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(tt.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in tt){var n=parseInt((tt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(tt.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(tt.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(tt.TERM)||"COLORTERM"in tt?1:(tt.TERM==="dumb",t)}function yi(e){var t=Py(e);return Ay(t)}tp.exports={supportsColor:yi,stdout:yi(process.stdout),stderr:yi(process.stderr)}});var np=P((ES,rp)=>{rp.exports=function(t,r){var n="";t=t||"Run the trap, drop the bass",t=t.split("");var s={a:["@","\u0104","\u023A","\u0245","\u0394","\u039B","\u0414"],b:["\xDF","\u0181","\u0243","\u026E","\u03B2","\u0E3F"],c:["\xA9","\u023B","\u03FE"],d:["\xD0","\u018A","\u0500","\u0501","\u0502","\u0503"],e:["\xCB","\u0115","\u018E","\u0258","\u03A3","\u03BE","\u04BC","\u0A6C"],f:["\u04FA"],g:["\u0262"],h:["\u0126","\u0195","\u04A2","\u04BA","\u04C7","\u050A"],i:["\u0F0F"],j:["\u0134"],k:["\u0138","\u04A0","\u04C3","\u051E"],l:["\u0139"],m:["\u028D","\u04CD","\u04CE","\u0520","\u0521","\u0D69"],n:["\xD1","\u014B","\u019D","\u0376","\u03A0","\u048A"],o:["\xD8","\xF5","\xF8","\u01FE","\u0298","\u047A","\u05DD","\u06DD","\u0E4F"],p:["\u01F7","\u048E"],q:["\u09CD"],r:["\xAE","\u01A6","\u0210","\u024C","\u0280","\u042F"],s:["\xA7","\u03DE","\u03DF","\u03E8"],t:["\u0141","\u0166","\u0373"],u:["\u01B1","\u054D"],v:["\u05D8"],w:["\u0428","\u0460","\u047C","\u0D70"],x:["\u04B2","\u04FE","\u04FC","\u04FD"],y:["\xA5","\u04B0","\u04CB"],z:["\u01B5","\u0240"]};return t.forEach(function(o){o=o.toLowerCase();var i=s[o]||[" "],a=Math.floor(Math.random()*i.length);typeof s[o]<"u"?n+=s[o][a]:n+=o}),n}});var op=P((SS,sp)=>{sp.exports=function(t,r){t=t||" he is here ";var n={up:["\u030D","\u030E","\u0304","\u0305","\u033F","\u0311","\u0306","\u0310","\u0352","\u0357","\u0351","\u0307","\u0308","\u030A","\u0342","\u0313","\u0308","\u034A","\u034B","\u034C","\u0303","\u0302","\u030C","\u0350","\u0300","\u0301","\u030B","\u030F","\u0312","\u0313","\u0314","\u033D","\u0309","\u0363","\u0364","\u0365","\u0366","\u0367","\u0368","\u0369","\u036A","\u036B","\u036C","\u036D","\u036E","\u036F","\u033E","\u035B","\u0346","\u031A"],down:["\u0316","\u0317","\u0318","\u0319","\u031C","\u031D","\u031E","\u031F","\u0320","\u0324","\u0325","\u0326","\u0329","\u032A","\u032B","\u032C","\u032D","\u032E","\u032F","\u0330","\u0331","\u0332","\u0333","\u0339","\u033A","\u033B","\u033C","\u0345","\u0347","\u0348","\u0349","\u034D","\u034E","\u0353","\u0354","\u0355","\u0356","\u0359","\u035A","\u0323"],mid:["\u0315","\u031B","\u0300","\u0301","\u0358","\u0321","\u0322","\u0327","\u0328","\u0334","\u0335","\u0336","\u035C","\u035D","\u035E","\u035F","\u0360","\u0362","\u0338","\u0337","\u0361"," \u0489"]},s=[].concat(n.up,n.down,n.mid);function o(c){var u=Math.floor(Math.random()*c);return u}function i(c){var u=!1;return s.filter(function(l){u=l===c}),u}function a(c,u){var l="",p,d;u=u||{},u.up=typeof u.up<"u"?u.up:!0,u.mid=typeof u.mid<"u"?u.mid:!0,u.down=typeof u.down<"u"?u.down:!0,u.size=typeof u.size<"u"?u.size:"maxi",c=c.split("");for(d in c)if(!i(d)){switch(l=l+c[d],p={up:0,down:0,mid:0},u.size){case"mini":p.up=o(8),p.mid=o(2),p.down=o(8);break;case"maxi":p.up=o(16)+3,p.mid=o(4)+1,p.down=o(64)+3;break;default:p.up=o(8)+1,p.mid=o(6)/2,p.down=o(8)+1;break}var f=["up","mid","down"];for(var m in f)for(var h=f[m],D=0;D<=p[h];D++)u[h]&&(l=l+n[h][o(n[h].length)])}return l}return a(t,r)}});var ap=P((FS,ip)=>{ip.exports=function(e){return function(t,r,n){if(t===" ")return t;switch(r%3){case 0:return e.red(t);case 1:return e.white(t);case 2:return e.blue(t)}}}});var up=P((TS,cp)=>{cp.exports=function(e){return function(t,r,n){return r%2===0?t:e.inverse(t)}}});var pp=P((AS,lp)=>{lp.exports=function(e){var t=["red","yellow","green","blue","magenta"];return function(r,n,s){return r===" "?r:e[t[n++%t.length]](r)}}});var dp=P((PS,fp)=>{fp.exports=function(e){var t=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(r,n,s){return r===" "?r:e[t[Math.round(Math.random()*(t.length-2))]](r)}}});var wp=P((IS,yp)=>{var x={};yp.exports=x;x.themes={};var Ry=require("util"),ke=x.styles=Zl(),mp=Object.defineProperties,Iy=new RegExp(/[\r\n]+/g);x.supportsColor=ep().supportsColor;typeof x.enabled>"u"&&(x.enabled=x.supportsColor()!==!1);x.enable=function(){x.enabled=!0};x.disable=function(){x.enabled=!1};x.stripColors=x.strip=function(e){return(""+e).replace(/\x1B\[\d+m/g,"")};var RS=x.stylize=function(t,r){if(!x.enabled)return t+"";var n=ke[r];return!n&&r in x?x[r](t):n.open+t+n.close},Ny=/[|\\{}()[\]^$+*?.]/g,Oy=function(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(Ny,"\\$&")};function gp(e){var t=function r(){return $y.apply(r,arguments)};return t._styles=e,t.__proto__=My,t}var Dp=(function(){var e={};return ke.grey=ke.gray,Object.keys(ke).forEach(function(t){ke[t].closeRe=new RegExp(Oy(ke[t].close),"g"),e[t]={get:function(){return gp(this._styles.concat(t))}}}),e})(),My=mp(function(){},Dp);function $y(){var e=Array.prototype.slice.call(arguments),t=e.map(function(i){return i!=null&&i.constructor===String?i:Ry.inspect(i)}).join(" ");if(!x.enabled||!t)return t;for(var r=t.indexOf(`
7
- `)!=-1,n=this._styles,s=n.length;s--;){var o=ke[n[s]];t=o.open+t.replace(o.closeRe,o.open)+o.close,r&&(t=t.replace(Iy,function(i){return o.close+i+o.open}))}return t}x.setTheme=function(e){if(typeof e=="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var t in e)(function(r){x[r]=function(n){if(typeof e[r]=="object"){var s=n;for(var o in e[r])s=x[e[r][o]](s);return s}return x[e[r]](n)}})(t)};function By(){var e={};return Object.keys(Dp).forEach(function(t){e[t]={get:function(){return gp([t])}}}),e}var jy=function(t,r){var n=r.split("");return n=n.map(t),n.join("")};x.trap=np();x.zalgo=op();x.maps={};x.maps.america=ap()(x);x.maps.zebra=up()(x);x.maps.rainbow=pp()(x);x.maps.random=dp()(x);for(hp in x.maps)(function(e){x[e]=function(t){return jy(x.maps[e],t)}})(hp);var hp;mp(x,By())});var bp=P((NS,Cp)=>{var _y=wp();Cp.exports=_y});var Ep=P((OS,Ss)=>{var{info:Ly,debug:kp}=ks(),at=Di(),Ci=class e{constructor(t){this.setOptions(t),this.x=null,this.y=null}setOptions(t){["boolean","number","bigint","string"].indexOf(typeof t)!==-1&&(t={content:""+t}),t=t||{},this.options=t;let r=t.content;if(["boolean","number","bigint","string"].indexOf(typeof r)!==-1)this.content=String(r);else if(!r)this.content=this.options.href||"";else throw new Error("Content needs to be a primitive, got: "+typeof r);this.colSpan=t.colSpan||1,this.rowSpan=t.rowSpan||1,this.options.href&&Object.defineProperty(this,"href",{get(){return this.options.href}})}mergeTableOptions(t,r){this.cells=r;let n=this.options.chars||{},s=t.chars,o=this.chars={};Gy.forEach(function(c){wi(n,s,c,o)}),this.truncate=this.options.truncate||t.truncate;let i=this.options.style=this.options.style||{},a=t.style;wi(i,a,"padding-left",this),wi(i,a,"padding-right",this),this.head=i.head||a.head,this.border=i.border||a.border,this.fixedWidth=t.colWidths[this.x],this.lines=this.computeLines(t),this.desiredWidth=at.strlen(this.content)+this.paddingLeft+this.paddingRight,this.desiredHeight=this.lines.length}computeLines(t){let r=t.wordWrap||t.textWrap,{wordWrap:n=r}=this.options;if(this.fixedWidth&&n){if(this.fixedWidth-=this.paddingLeft+this.paddingRight,this.colSpan){let i=1;for(;i<this.colSpan;)this.fixedWidth+=t.colWidths[this.x+i],i++}let{wrapOnWordBoundary:s=!0}=t,{wrapOnWordBoundary:o=s}=this.options;return this.wrapLines(at.wordWrap(this.fixedWidth,this.content,o))}return this.wrapLines(this.content.split(`
8
- `))}wrapLines(t){let r=at.colorizeLines(t);return this.href?r.map(n=>at.hyperlink(this.href,n)):r}init(t){let r=this.x,n=this.y;this.widths=t.colWidths.slice(r,r+this.colSpan),this.heights=t.rowHeights.slice(n,n+this.rowSpan),this.width=this.widths.reduce(xp,-1),this.height=this.heights.reduce(xp,-1),this.hAlign=this.options.hAlign||t.colAligns[r],this.vAlign=this.options.vAlign||t.rowAligns[n],this.drawRight=r+this.colSpan==t.colWidths.length}draw(t,r){if(t=="top")return this.drawTop(this.drawRight);if(t=="bottom")return this.drawBottom(this.drawRight);let n=at.truncate(this.content,10,this.truncate);t||Ly(`${this.y}-${this.x}: ${this.rowSpan-t}x${this.colSpan} Cell ${n}`);let s=Math.max(this.height-this.lines.length,0),o;switch(this.vAlign){case"center":o=Math.ceil(s/2);break;case"bottom":o=s;break;default:o=0}if(t<o||t>=o+this.lines.length)return this.drawEmpty(this.drawRight,r);let i=this.lines.length>this.height&&t+1>=this.height;return this.drawLine(t-o,this.drawRight,i,r)}drawTop(t){let r=[];return this.cells?this.widths.forEach(function(n,s){r.push(this._topLeftChar(s)),r.push(at.repeat(this.chars[this.y==0?"top":"mid"],n))},this):(r.push(this._topLeftChar(0)),r.push(at.repeat(this.chars[this.y==0?"top":"mid"],this.width))),t&&r.push(this.chars[this.y==0?"topRight":"rightMid"]),this.wrapWithStyleColors("border",r.join(""))}_topLeftChar(t){let r=this.x+t,n;if(this.y==0)n=r==0?"topLeft":t==0?"topMid":"top";else if(r==0)n="leftMid";else if(n=t==0?"midMid":"bottomMid",this.cells&&(this.cells[this.y-1][r]instanceof e.ColSpanCell&&(n=t==0?"topMid":"mid"),t==0)){let o=1;for(;this.cells[this.y][r-o]instanceof e.ColSpanCell;)o++;this.cells[this.y][r-o]instanceof e.RowSpanCell&&(n="leftMid")}return this.chars[n]}wrapWithStyleColors(t,r){if(this[t]&&this[t].length)try{let n=bp();for(let s=this[t].length-1;s>=0;s--)n=n[this[t][s]];return n(r)}catch{return r}else return r}drawLine(t,r,n,s){let o=this.chars[this.x==0?"left":"middle"];if(this.x&&s&&this.cells){let d=this.cells[this.y+s][this.x-1];for(;d instanceof ln;)d=this.cells[d.y][d.x-1];d instanceof pn||(o=this.chars.rightMid)}let i=at.repeat(" ",this.paddingLeft),a=r?this.chars.right:"",c=at.repeat(" ",this.paddingRight),u=this.lines[t],l=this.width-(this.paddingLeft+this.paddingRight);n&&(u+=this.truncate||"\u2026");let p=at.truncate(u,l,this.truncate);return p=at.pad(p,l," ",this.hAlign),p=i+p+c,this.stylizeLine(o,p,a)}stylizeLine(t,r,n){return t=this.wrapWithStyleColors("border",t),n=this.wrapWithStyleColors("border",n),this.y===0&&(r=this.wrapWithStyleColors("head",r)),t+r+n}drawBottom(t){let r=this.chars[this.x==0?"bottomLeft":"bottomMid"],n=at.repeat(this.chars.bottom,this.width),s=t?this.chars.bottomRight:"";return this.wrapWithStyleColors("border",r+n+s)}drawEmpty(t,r){let n=this.chars[this.x==0?"left":"middle"];if(this.x&&r&&this.cells){let i=this.cells[this.y+r][this.x-1];for(;i instanceof ln;)i=this.cells[i.y][i.x-1];i instanceof pn||(n=this.chars.rightMid)}let s=t?this.chars.right:"",o=at.repeat(" ",this.width);return this.stylizeLine(n,o,s)}},ln=class{constructor(){}draw(t){return typeof t=="number"&&kp(`${this.y}-${this.x}: 1x1 ColSpanCell`),""}init(){}mergeTableOptions(){}},pn=class{constructor(t){this.originalCell=t}init(t){let r=this.y,n=this.originalCell.y;this.cellOffset=r-n,this.offset=Wy(t.rowHeights,n,this.cellOffset)}draw(t){return t=="top"?this.originalCell.draw(this.offset,this.cellOffset):t=="bottom"?this.originalCell.draw("bottom"):(kp(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`),this.originalCell.draw(this.offset+1+t))}mergeTableOptions(){}};function vp(...e){return e.filter(t=>t!=null).shift()}function wi(e,t,r,n){let s=r.split("-");s.length>1?(s[1]=s[1].charAt(0).toUpperCase()+s[1].substr(1),s=s.join(""),n[s]=vp(e[s],e[r],t[s],t[r])):n[r]=vp(e[r],t[r])}function Wy(e,t,r){let n=e[t];for(let s=1;s<r;s++)n+=1+e[t+s];return n}function xp(e,t){return e+t+1}var Gy=["top","top-mid","top-left","top-right","bottom","bottom-mid","bottom-left","bottom-right","left","left-mid","mid","mid-mid","right","right-mid","middle"];Ss.exports=Ci;Ss.exports.ColSpanCell=ln;Ss.exports.RowSpanCell=pn});var Tp=P((MS,Fp)=>{var{warn:Hy,debug:Uy}=ks(),bi=Ep(),{ColSpanCell:zy,RowSpanCell:Ky}=bi;(function(){function e(f,m){return f[m]>0?e(f,m+1):m}function t(f){let m={};f.forEach(function(h,D){let g=0;h.forEach(function(y){y.y=D,y.x=D?e(m,g):g;let v=y.rowSpan||1,C=y.colSpan||1;if(v>1)for(let A=0;A<C;A++)m[y.x+A]=v;g=y.x+C}),Object.keys(m).forEach(y=>{m[y]--,m[y]<1&&delete m[y]})})}function r(f){let m=0;return f.forEach(function(h){h.forEach(function(D){m=Math.max(m,D.x+(D.colSpan||1))})}),m}function n(f){return f.length}function s(f,m){let h=f.y,D=f.y-1+(f.rowSpan||1),g=m.y,y=m.y-1+(m.rowSpan||1),v=!(h>y||g>D),C=f.x,A=f.x-1+(f.colSpan||1),lt=m.x,ee=m.x-1+(m.colSpan||1),Se=!(C>ee||lt>A);return v&&Se}function o(f,m,h){let D=Math.min(f.length-1,h),g={x:m,y:h};for(let y=0;y<=D;y++){let v=f[y];for(let C=0;C<v.length;C++)if(s(g,v[C]))return!0}return!1}function i(f,m,h,D){for(let g=h;g<D;g++)if(o(f,g,m))return!1;return!0}function a(f){f.forEach(function(m,h){m.forEach(function(D){for(let g=1;g<D.rowSpan;g++){let y=new Ky(D);y.x=D.x,y.y=D.y+g,y.colSpan=D.colSpan,u(y,f[h+g])}})})}function c(f){for(let m=f.length-1;m>=0;m--){let h=f[m];for(let D=0;D<h.length;D++){let g=h[D];for(let y=1;y<g.colSpan;y++){let v=new zy;v.x=g.x+y,v.y=g.y,h.splice(D+1,0,v)}}}}function u(f,m){let h=0;for(;h<m.length&&m[h].x<f.x;)h++;m.splice(h,0,f)}function l(f){let m=n(f),h=r(f);Uy(`Max rows: ${m}; Max cols: ${h}`);for(let D=0;D<m;D++)for(let g=0;g<h;g++)if(!o(f,g,D)){let y={x:g,y:D,colSpan:1,rowSpan:1};for(g++;g<h&&!o(f,g,D);)y.colSpan++,g++;let v=D+1;for(;v<m&&i(f,v,y.x,y.x+y.colSpan);)y.rowSpan++,v++;let C=new bi(y);C.x=y.x,C.y=y.y,Hy(`Missing cell at ${C.y}-${C.x}.`),u(C,f[D])}}function p(f){return f.map(function(m){if(!Array.isArray(m)){let h=Object.keys(m)[0];m=m[h],Array.isArray(m)?(m=m.slice(),m.unshift(h)):m=[h,m]}return m.map(function(h){return new bi(h)})})}function d(f){let m=p(f);return t(m),l(m),a(m),c(m),m}Fp.exports={makeTableLayout:d,layoutTable:t,addRowSpanCells:a,maxWidth:r,fillInTable:l,computeWidths:Sp("colSpan","desiredWidth","x",1),computeHeights:Sp("rowSpan","desiredHeight","y",1)}})();function Sp(e,t,r,n){return function(s,o){let i=[],a=[],c={};o.forEach(function(u){u.forEach(function(l){(l[e]||1)>1?a.push(l):i[l[r]]=Math.max(i[l[r]]||0,l[t]||0,n)})}),s.forEach(function(u,l){typeof u=="number"&&(i[l]=u)});for(let u=a.length-1;u>=0;u--){let l=a[u],p=l[e],d=l[r],f=i[d],m=typeof s[d]=="number"?0:1;if(typeof f=="number")for(let h=1;h<p;h++)f+=1+i[d+h],typeof s[d+h]!="number"&&m++;else f=t==="desiredWidth"?l.desiredWidth-1:1,(!c[d]||c[d]<f)&&(c[d]=f);if(l[t]>f){let h=0;for(;m>0&&l[t]>f;){if(typeof s[d+h]!="number"){let D=Math.round((l[t]-f)/m);f+=D,i[d+h]+=D,m--}h++}}}Object.assign(s,i,c);for(let u=0;u<s.length;u++)s[u]=Math.max(n,s[u]||0)}}});var Pp=P(($S,Ap)=>{var Zt=ks(),Jy=Di(),vi=Tp(),Fs=class extends Array{constructor(t){super();let r=Jy.mergeOptions(t);if(Object.defineProperty(this,"options",{value:r,enumerable:r.debug}),r.debug){switch(typeof r.debug){case"boolean":Zt.setDebugLevel(Zt.WARN);break;case"number":Zt.setDebugLevel(r.debug);break;case"string":Zt.setDebugLevel(parseInt(r.debug,10));break;default:Zt.setDebugLevel(Zt.WARN),Zt.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof r.debug}`)}Object.defineProperty(this,"messages",{get(){return Zt.debugMessages()}})}}toString(){let t=this,r=this.options.head&&this.options.head.length;r?(t=[this.options.head],this.length&&t.push.apply(t,this)):this.options.style.head=[];let n=vi.makeTableLayout(t);n.forEach(function(o){o.forEach(function(i){i.mergeTableOptions(this.options,n)},this)},this),vi.computeWidths(this.options.colWidths,n),vi.computeHeights(this.options.rowHeights,n),n.forEach(function(o){o.forEach(function(i){i.init(this.options)},this)},this);let s=[];for(let o=0;o<n.length;o++){let i=n[o],a=this.options.rowHeights[o];(o===0||!this.options.style.compact||o==1&&r)&&xi(i,"top",s);for(let c=0;c<a;c++)xi(i,c,s);o+1==n.length&&xi(i,"bottom",s)}return s.join(`
2
+ "use strict";var pd=Object.create;var Vs=Object.defineProperty;var fd=Object.getOwnPropertyDescriptor;var dd=Object.getOwnPropertyNames;var hd=Object.getPrototypeOf,md=Object.prototype.hasOwnProperty;var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),gd=(e,t)=>{for(var r in t)Vs(e,r,{get:t[r],enumerable:!0})},Dd=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of dd(t))!md.call(e,s)&&s!==r&&Vs(e,s,{get:()=>t[s],enumerable:!(n=fd(t,s))||n.enumerable});return e};var b=(e,t,r)=>(r=e!=null?pd(hd(e)):{},Dd(t||!e||!e.__esModule?Vs(r,"default",{value:e,enumerable:!0}):r,e));var Ys=P((ZC,ua)=>{"use strict";ua.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),s=t.indexOf("--");return n!==-1&&(s===-1||n<s)}});var fa=P((XC,pa)=>{"use strict";var qd=require("os"),la=require("tty"),pt=Ys(),{env:j}=process,ne;pt("no-color")||pt("no-colors")||pt("color=false")||pt("color=never")?ne=0:(pt("color")||pt("colors")||pt("color=true")||pt("color=always"))&&(ne=1);"FORCE_COLOR"in j&&(j.FORCE_COLOR==="true"?ne=1:j.FORCE_COLOR==="false"?ne=0:ne=j.FORCE_COLOR.length===0?1:Math.min(parseInt(j.FORCE_COLOR,10),3));function Zs(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Xs(e,t){if(ne===0)return 0;if(pt("color=16m")||pt("color=full")||pt("color=truecolor"))return 3;if(pt("color=256"))return 2;if(e&&!t&&ne===void 0)return 0;let r=ne||0;if(j.TERM==="dumb")return r;if(process.platform==="win32"){let n=qd.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in j)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in j)||j.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in j)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(j.TEAMCITY_VERSION)?1:0;if(j.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in j){let n=parseInt((j.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(j.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(j.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(j.TERM)||"COLORTERM"in j?1:r}function Yd(e){let t=Xs(e,e&&e.isTTY);return Zs(t)}pa.exports={supportsColor:Yd,stdout:Zs(Xs(!0,la.isatty(1))),stderr:Zs(Xs(!0,la.isatty(2)))}});var ma=P((QC,ha)=>{"use strict";var Zd=fa(),Ne=Ys();function da(e){if(/^\d{3,4}$/.test(e)){let r=/(\d{1,2})(\d{2})/.exec(e)||[];return{major:0,minor:parseInt(r[1],10),patch:parseInt(r[2],10)}}let t=(e||"").split(".").map(r=>parseInt(r,10));return{major:t[0],minor:t[1],patch:t[2]}}function Qs(e){let{CI:t,FORCE_HYPERLINK:r,NETLIFY:n,TEAMCITY_VERSION:s,TERM_PROGRAM:o,TERM_PROGRAM_VERSION:i,VTE_VERSION:a,TERM:c}=process.env;if(r)return!(r.length>0&&parseInt(r,10)===0);if(Ne("no-hyperlink")||Ne("no-hyperlinks")||Ne("hyperlink=false")||Ne("hyperlink=never"))return!1;if(Ne("hyperlink=true")||Ne("hyperlink=always")||n)return!0;if(!Zd.supportsColor(e)||e&&!e.isTTY)return!1;if("WT_SESSION"in process.env)return!0;if(process.platform==="win32"||t||s)return!1;if(o){let u=da(i||"");switch(o){case"iTerm.app":return u.major===3?u.minor>=1:u.major>3;case"WezTerm":return u.major>=20200620;case"vscode":return u.major>1||u.major===1&&u.minor>=72;case"ghostty":return!0}}if(a){if(a==="0.50.0")return!1;let u=da(a);return u.major>0||u.minor>=50}switch(c){case"alacritty":return!0}return!1}ha.exports={supportsHyperlink:Qs,stdout:Qs(process.stdout),stderr:Qs(process.stderr)}});var tu=P((Nx,fg)=>{fg.exports={name:"dotenv",version:"17.2.3",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard",pretest:"npm run lint && npm run dts-check",test:"tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},homepage:"https://github.com/motdotla/dotenv#readme",funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@types/node":"^18.11.3",decache:"^4.6.2",sinon:"^14.0.1",standard:"^17.0.0","standard-version":"^9.5.0",tap:"^19.2.0",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var iu=P((Ox,Vt)=>{var Bo=require("fs"),os=require("path"),dg=require("os"),hg=require("crypto"),mg=tu(),jo=mg.version,eu=["\u{1F510} encrypt with Dotenvx: https://dotenvx.com","\u{1F510} prevent committing .env to code: https://dotenvx.com/precommit","\u{1F510} prevent building .env in docker: https://dotenvx.com/prebuild","\u{1F4E1} add observability to secrets: https://dotenvx.com/ops","\u{1F465} sync secrets across teammates & machines: https://dotenvx.com/ops","\u{1F5C2}\uFE0F backup and recover secrets: https://dotenvx.com/ops","\u2705 audit secrets and track compliance: https://dotenvx.com/ops","\u{1F504} add secrets lifecycle management: https://dotenvx.com/ops","\u{1F511} add access controls to secrets: https://dotenvx.com/ops","\u{1F6E0}\uFE0F run anywhere with `dotenvx run -- yourcommand`","\u2699\uFE0F specify custom .env file path with { path: '/custom/path/.env' }","\u2699\uFE0F enable debug logging with { debug: true }","\u2699\uFE0F override existing env vars with { override: true }","\u2699\uFE0F suppress all logs with { quiet: true }","\u2699\uFE0F write to custom object with { processEnv: myObject }","\u2699\uFE0F load multiple .env files with { path: ['.env.local', '.env'] }"];function gg(){return eu[Math.floor(Math.random()*eu.length)]}function Xe(e){return typeof e=="string"?!["false","0","no","off",""].includes(e.toLowerCase()):!!e}function Dg(){return process.stdout.isTTY}function yg(e){return Dg()?`\x1B[2m${e}\x1B[0m`:e}var wg=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function Cg(e){let t={},r=e.toString();r=r.replace(/\r\n?/mg,`
3
+ `);let n;for(;(n=wg.exec(r))!=null;){let s=n[1],o=n[2]||"";o=o.trim();let i=o[0];o=o.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),i==='"'&&(o=o.replace(/\\n/g,`
4
+ `),o=o.replace(/\\r/g,"\r")),t[s]=o}return t}function bg(e){e=e||{};let t=ou(e);e.path=t;let r=B.configDotenv(e);if(!r.parsed){let i=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw i.code="MISSING_DATA",i}let n=su(e).split(","),s=n.length,o;for(let i=0;i<s;i++)try{let a=n[i].trim(),c=xg(r,a);o=B.decrypt(c.ciphertext,c.key);break}catch(a){if(i+1>=s)throw a}return B.parse(o)}function vg(e){console.error(`[dotenv@${jo}][WARN] ${e}`)}function Qr(e){console.log(`[dotenv@${jo}][DEBUG] ${e}`)}function nu(e){console.log(`[dotenv@${jo}] ${e}`)}function su(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function xg(e,t){let r;try{r=new URL(t)}catch(a){if(a.code==="ERR_INVALID_URL"){let c=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw c.code="INVALID_DOTENV_KEY",c}throw a}let n=r.password;if(!n){let a=new Error("INVALID_DOTENV_KEY: Missing key part");throw a.code="INVALID_DOTENV_KEY",a}let s=r.searchParams.get("environment");if(!s){let a=new Error("INVALID_DOTENV_KEY: Missing environment part");throw a.code="INVALID_DOTENV_KEY",a}let o=`DOTENV_VAULT_${s.toUpperCase()}`,i=e.parsed[o];if(!i){let a=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${o} in your .env.vault file.`);throw a.code="NOT_FOUND_DOTENV_ENVIRONMENT",a}return{ciphertext:i,key:n}}function ou(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)Bo.existsSync(r)&&(t=r.endsWith(".vault")?r:`${r}.vault`);else t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else t=os.resolve(process.cwd(),".env.vault");return Bo.existsSync(t)?t:null}function ru(e){return e[0]==="~"?os.join(dg.homedir(),e.slice(1)):e}function kg(e){let t=Xe(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),r=Xe(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!r)&&nu("Loading env from encrypted .env.vault");let n=B._parseVault(e),s=process.env;return e&&e.processEnv!=null&&(s=e.processEnv),B.populate(s,n,e),{parsed:n}}function Eg(e){let t=os.resolve(process.cwd(),".env"),r="utf8",n=process.env;e&&e.processEnv!=null&&(n=e.processEnv);let s=Xe(n.DOTENV_CONFIG_DEBUG||e&&e.debug),o=Xe(n.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?r=e.encoding:s&&Qr("No encoding is specified. UTF-8 is used by default");let i=[t];if(e&&e.path)if(!Array.isArray(e.path))i=[ru(e.path)];else{i=[];for(let l of e.path)i.push(ru(l))}let a,c={};for(let l of i)try{let p=B.parse(Bo.readFileSync(l,{encoding:r}));B.populate(c,p,e)}catch(p){s&&Qr(`Failed to load ${l} ${p.message}`),a=p}let u=B.populate(n,c,e);if(s=Xe(n.DOTENV_CONFIG_DEBUG||s),o=Xe(n.DOTENV_CONFIG_QUIET||o),s||!o){let l=Object.keys(u).length,p=[];for(let d of i)try{let f=os.relative(process.cwd(),d);p.push(f)}catch(f){s&&Qr(`Failed to load ${d} ${f.message}`),a=f}nu(`injecting env (${l}) from ${p.join(",")} ${yg(`-- tip: ${gg()}`)}`)}return a?{parsed:c,error:a}:{parsed:c}}function Sg(e){if(su(e).length===0)return B.configDotenv(e);let t=ou(e);return t?B._configVault(e):(vg(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),B.configDotenv(e))}function Fg(e,t){let r=Buffer.from(t.slice(-64),"hex"),n=Buffer.from(e,"base64"),s=n.subarray(0,12),o=n.subarray(-16);n=n.subarray(12,-16);try{let i=hg.createDecipheriv("aes-256-gcm",r,s);return i.setAuthTag(o),`${i.update(n)}${i.final()}`}catch(i){let a=i instanceof RangeError,c=i.message==="Invalid key length",u=i.message==="Unsupported state or unable to authenticate data";if(a||c){let l=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw l.code="INVALID_DOTENV_KEY",l}else if(u){let l=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw l.code="DECRYPTION_FAILED",l}else throw i}}function Tg(e,t,r={}){let n=!!(r&&r.debug),s=!!(r&&r.override),o={};if(typeof t!="object"){let i=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw i.code="OBJECT_REQUIRED",i}for(let i of Object.keys(t))Object.prototype.hasOwnProperty.call(e,i)?(s===!0&&(e[i]=t[i],o[i]=t[i]),n&&Qr(s===!0?`"${i}" is already defined and WAS overwritten`:`"${i}" is already defined and was NOT overwritten`)):(e[i]=t[i],o[i]=t[i]);return o}var B={configDotenv:Eg,_configVault:kg,_parseVault:bg,config:Sg,decrypt:Fg,parse:Cg,populate:Tg};Vt.exports.configDotenv=B.configDotenv;Vt.exports._configVault=B._configVault;Vt.exports._parseVault=B._parseVault;Vt.exports.config=B.config;Vt.exports.decrypt=B.decrypt;Vt.exports.parse=B.parse;Vt.exports.populate=B.populate;Vt.exports=B});var As=P((xS,Bl)=>{var wi=[],$l=0,V=(e,t)=>{$l>=t&&wi.push(e)};V.WARN=1;V.INFO=2;V.DEBUG=3;V.reset=()=>{wi=[]};V.setDebugLevel=e=>{$l=e};V.warn=e=>V(e,V.WARN);V.info=e=>V(e,V.INFO);V.debug=e=>V(e,V.DEBUG);V.debugMessages=()=>wi;Bl.exports=V});var _l=P((kS,jl)=>{"use strict";jl.exports=({onlyFirst:e=!1}={})=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}});var Wl=P((ES,Ll)=>{"use strict";var gy=_l();Ll.exports=e=>typeof e=="string"?e.replace(gy(),""):e});var Hl=P((SS,Ci)=>{"use strict";var Gl=e=>Number.isNaN(e)?!1:e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141);Ci.exports=Gl;Ci.exports.default=Gl});var zl=P((FS,Ul)=>{"use strict";Ul.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var Jl=P((TS,bi)=>{"use strict";var Dy=Wl(),yy=Hl(),wy=zl(),Kl=e=>{if(typeof e!="string"||e.length===0||(e=Dy(e),e.length===0))return 0;e=e.replace(wy()," ");let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,t+=yy(n)?2:1)}return t};bi.exports=Kl;bi.exports.default=Kl});var vi=P((AS,Zl)=>{var Vl=Jl();function Ps(e){return e?/\u001b\[((?:\d*;){0,5}\d*)m/g:/\u001b\[(?:\d*;){0,5}\d*m/g}function jt(e){let t=Ps();return(""+e).replace(t,"").split(`
5
+ `).reduce(function(s,o){return Vl(o)>s?Vl(o):s},0)}function dn(e,t){return Array(t+1).join(e)}function Cy(e,t,r,n){let s=jt(e);if(t+1>=s){let o=t-s;switch(n){case"right":{e=dn(r,o)+e;break}case"center":{let i=Math.ceil(o/2),a=o-i;e=dn(r,a)+e+dn(r,i);break}default:{e=e+dn(r,o);break}}}return e}var lr={};function hn(e,t,r){t="\x1B["+t+"m",r="\x1B["+r+"m",lr[t]={set:e,to:!0},lr[r]={set:e,to:!1},lr[e]={on:t,off:r}}hn("bold",1,22);hn("italics",3,23);hn("underline",4,24);hn("inverse",7,27);hn("strikethrough",9,29);function ql(e,t){let r=t[1]?parseInt(t[1].split(";")[0]):0;if(r>=30&&r<=39||r>=90&&r<=97){e.lastForegroundAdded=t[0];return}if(r>=40&&r<=49||r>=100&&r<=107){e.lastBackgroundAdded=t[0];return}if(r===0){for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&delete e[s];return}let n=lr[t[0]];n&&(e[n.set]=n.to)}function by(e){let t=Ps(!0),r=t.exec(e),n={};for(;r!==null;)ql(n,r),r=t.exec(e);return n}function Yl(e,t){let r=e.lastBackgroundAdded,n=e.lastForegroundAdded;return delete e.lastBackgroundAdded,delete e.lastForegroundAdded,Object.keys(e).forEach(function(s){e[s]&&(t+=lr[s].off)}),r&&r!="\x1B[49m"&&(t+="\x1B[49m"),n&&n!="\x1B[39m"&&(t+="\x1B[39m"),t}function vy(e,t){let r=e.lastBackgroundAdded,n=e.lastForegroundAdded;return delete e.lastBackgroundAdded,delete e.lastForegroundAdded,Object.keys(e).forEach(function(s){e[s]&&(t=lr[s].on+t)}),r&&r!="\x1B[49m"&&(t=r+t),n&&n!="\x1B[39m"&&(t=n+t),t}function xy(e,t){if(e.length===jt(e))return e.substr(0,t);for(;jt(e)>t;)e=e.slice(0,-1);return e}function ky(e,t){let r=Ps(!0),n=e.split(Ps()),s=0,o=0,i="",a,c={};for(;o<t;){a=r.exec(e);let u=n[s];if(s++,o+jt(u)>t&&(u=xy(u,t-o)),i+=u,o+=jt(u),o<t){if(!a)break;i+=a[0],ql(c,a)}}return Yl(c,i)}function Ey(e,t,r){if(r=r||"\u2026",jt(e)<=t)return e;t-=jt(r);let s=ky(e,t);s+=r;let o="\x1B]8;;\x07";return e.includes(o)&&!s.includes(o)&&(s+=o),s}function Sy(){return{chars:{top:"\u2500","top-mid":"\u252C","top-left":"\u250C","top-right":"\u2510",bottom:"\u2500","bottom-mid":"\u2534","bottom-left":"\u2514","bottom-right":"\u2518",left:"\u2502","left-mid":"\u251C",mid:"\u2500","mid-mid":"\u253C",right:"\u2502","right-mid":"\u2524",middle:"\u2502"},truncate:"\u2026",colWidths:[],rowHeights:[],colAligns:[],rowAligns:[],style:{"padding-left":1,"padding-right":1,head:["red"],border:["grey"],compact:!1},head:[]}}function Fy(e,t){e=e||{},t=t||Sy();let r=Object.assign({},t,e);return r.chars=Object.assign({},t.chars,e.chars),r.style=Object.assign({},t.style,e.style),r}function Ty(e,t){let r=[],n=t.split(/(\s+)/g),s=[],o=0,i;for(let a=0;a<n.length;a+=2){let c=n[a],u=o+jt(c);o>0&&i&&(u+=i.length),u>e?(o!==0&&r.push(s.join("")),s=[c],o=jt(c)):(s.push(i||"",c),o=u),i=n[a+1]}return o&&r.push(s.join("")),r}function Ay(e,t){let r=[],n="";function s(i,a){for(n.length&&a&&(n+=a),n+=i;n.length>e;)r.push(n.slice(0,e)),n=n.slice(e)}let o=t.split(/(\s+)/g);for(let i=0;i<o.length;i+=2)s(o[i],i&&o[i-1]);return n.length&&r.push(n),r}function Py(e,t,r=!0){let n=[];t=t.split(`
6
+ `);let s=r?Ty:Ay;for(let o=0;o<t.length;o++)n.push.apply(n,s(e,t[o]));return n}function Ry(e){let t={},r=[];for(let n=0;n<e.length;n++){let s=vy(t,e[n]);t=by(s);let o=Object.assign({},t);r.push(Yl(o,s))}return r}function Iy(e,t){return["\x1B]","8",";",";",e||t,"\x07",t,"\x1B]","8",";",";","\x07"].join("")}Zl.exports={strlen:jt,repeat:dn,pad:Cy,truncate:Ey,mergeOptions:Fy,wordWrap:Py,colorizeLines:Ry,hyperlink:Iy}});var ep=P((PS,tp)=>{var Ql={};tp.exports=Ql;var Xl={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(Xl).forEach(function(e){var t=Xl[e],r=Ql[e]=[];r.open="\x1B["+t[0]+"m",r.close="\x1B["+t[1]+"m"})});var np=P((RS,rp)=>{"use strict";rp.exports=function(e,t){t=t||process.argv;var r=t.indexOf("--"),n=/^-{1,2}/.test(e)?"":"--",s=t.indexOf(n+e);return s!==-1&&(r===-1?!0:s<r)}});var op=P((IS,sp)=>{"use strict";var Ny=require("os"),Ft=np(),tt=process.env,pr=void 0;Ft("no-color")||Ft("no-colors")||Ft("color=false")?pr=!1:(Ft("color")||Ft("colors")||Ft("color=true")||Ft("color=always"))&&(pr=!0);"FORCE_COLOR"in tt&&(pr=tt.FORCE_COLOR.length===0||parseInt(tt.FORCE_COLOR,10)!==0);function Oy(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function My(e){if(pr===!1)return 0;if(Ft("color=16m")||Ft("color=full")||Ft("color=truecolor"))return 3;if(Ft("color=256"))return 2;if(e&&!e.isTTY&&pr!==!0)return 0;var t=pr?1:0;if(process.platform==="win32"){var r=Ny.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in tt)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(s){return s in tt})||tt.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in tt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(tt.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in tt){var n=parseInt((tt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(tt.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(tt.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(tt.TERM)||"COLORTERM"in tt?1:(tt.TERM==="dumb",t)}function xi(e){var t=My(e);return Oy(t)}sp.exports={supportsColor:xi,stdout:xi(process.stdout),stderr:xi(process.stderr)}});var ap=P((NS,ip)=>{ip.exports=function(t,r){var n="";t=t||"Run the trap, drop the bass",t=t.split("");var s={a:["@","\u0104","\u023A","\u0245","\u0394","\u039B","\u0414"],b:["\xDF","\u0181","\u0243","\u026E","\u03B2","\u0E3F"],c:["\xA9","\u023B","\u03FE"],d:["\xD0","\u018A","\u0500","\u0501","\u0502","\u0503"],e:["\xCB","\u0115","\u018E","\u0258","\u03A3","\u03BE","\u04BC","\u0A6C"],f:["\u04FA"],g:["\u0262"],h:["\u0126","\u0195","\u04A2","\u04BA","\u04C7","\u050A"],i:["\u0F0F"],j:["\u0134"],k:["\u0138","\u04A0","\u04C3","\u051E"],l:["\u0139"],m:["\u028D","\u04CD","\u04CE","\u0520","\u0521","\u0D69"],n:["\xD1","\u014B","\u019D","\u0376","\u03A0","\u048A"],o:["\xD8","\xF5","\xF8","\u01FE","\u0298","\u047A","\u05DD","\u06DD","\u0E4F"],p:["\u01F7","\u048E"],q:["\u09CD"],r:["\xAE","\u01A6","\u0210","\u024C","\u0280","\u042F"],s:["\xA7","\u03DE","\u03DF","\u03E8"],t:["\u0141","\u0166","\u0373"],u:["\u01B1","\u054D"],v:["\u05D8"],w:["\u0428","\u0460","\u047C","\u0D70"],x:["\u04B2","\u04FE","\u04FC","\u04FD"],y:["\xA5","\u04B0","\u04CB"],z:["\u01B5","\u0240"]};return t.forEach(function(o){o=o.toLowerCase();var i=s[o]||[" "],a=Math.floor(Math.random()*i.length);typeof s[o]<"u"?n+=s[o][a]:n+=o}),n}});var up=P((OS,cp)=>{cp.exports=function(t,r){t=t||" he is here ";var n={up:["\u030D","\u030E","\u0304","\u0305","\u033F","\u0311","\u0306","\u0310","\u0352","\u0357","\u0351","\u0307","\u0308","\u030A","\u0342","\u0313","\u0308","\u034A","\u034B","\u034C","\u0303","\u0302","\u030C","\u0350","\u0300","\u0301","\u030B","\u030F","\u0312","\u0313","\u0314","\u033D","\u0309","\u0363","\u0364","\u0365","\u0366","\u0367","\u0368","\u0369","\u036A","\u036B","\u036C","\u036D","\u036E","\u036F","\u033E","\u035B","\u0346","\u031A"],down:["\u0316","\u0317","\u0318","\u0319","\u031C","\u031D","\u031E","\u031F","\u0320","\u0324","\u0325","\u0326","\u0329","\u032A","\u032B","\u032C","\u032D","\u032E","\u032F","\u0330","\u0331","\u0332","\u0333","\u0339","\u033A","\u033B","\u033C","\u0345","\u0347","\u0348","\u0349","\u034D","\u034E","\u0353","\u0354","\u0355","\u0356","\u0359","\u035A","\u0323"],mid:["\u0315","\u031B","\u0300","\u0301","\u0358","\u0321","\u0322","\u0327","\u0328","\u0334","\u0335","\u0336","\u035C","\u035D","\u035E","\u035F","\u0360","\u0362","\u0338","\u0337","\u0361"," \u0489"]},s=[].concat(n.up,n.down,n.mid);function o(c){var u=Math.floor(Math.random()*c);return u}function i(c){var u=!1;return s.filter(function(l){u=l===c}),u}function a(c,u){var l="",p,d;u=u||{},u.up=typeof u.up<"u"?u.up:!0,u.mid=typeof u.mid<"u"?u.mid:!0,u.down=typeof u.down<"u"?u.down:!0,u.size=typeof u.size<"u"?u.size:"maxi",c=c.split("");for(d in c)if(!i(d)){switch(l=l+c[d],p={up:0,down:0,mid:0},u.size){case"mini":p.up=o(8),p.mid=o(2),p.down=o(8);break;case"maxi":p.up=o(16)+3,p.mid=o(4)+1,p.down=o(64)+3;break;default:p.up=o(8)+1,p.mid=o(6)/2,p.down=o(8)+1;break}var f=["up","mid","down"];for(var m in f)for(var h=f[m],D=0;D<=p[h];D++)u[h]&&(l=l+n[h][o(n[h].length)])}return l}return a(t,r)}});var pp=P((MS,lp)=>{lp.exports=function(e){return function(t,r,n){if(t===" ")return t;switch(r%3){case 0:return e.red(t);case 1:return e.white(t);case 2:return e.blue(t)}}}});var dp=P(($S,fp)=>{fp.exports=function(e){return function(t,r,n){return r%2===0?t:e.inverse(t)}}});var mp=P((BS,hp)=>{hp.exports=function(e){var t=["red","yellow","green","blue","magenta"];return function(r,n,s){return r===" "?r:e[t[n++%t.length]](r)}}});var Dp=P((jS,gp)=>{gp.exports=function(e){var t=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(r,n,s){return r===" "?r:e[t[Math.round(Math.random()*(t.length-2))]](r)}}});var xp=P((LS,vp)=>{var x={};vp.exports=x;x.themes={};var $y=require("util"),Ee=x.styles=ep(),wp=Object.defineProperties,By=new RegExp(/[\r\n]+/g);x.supportsColor=op().supportsColor;typeof x.enabled>"u"&&(x.enabled=x.supportsColor()!==!1);x.enable=function(){x.enabled=!0};x.disable=function(){x.enabled=!1};x.stripColors=x.strip=function(e){return(""+e).replace(/\x1B\[\d+m/g,"")};var _S=x.stylize=function(t,r){if(!x.enabled)return t+"";var n=Ee[r];return!n&&r in x?x[r](t):n.open+t+n.close},jy=/[|\\{}()[\]^$+*?.]/g,_y=function(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(jy,"\\$&")};function Cp(e){var t=function r(){return Wy.apply(r,arguments)};return t._styles=e,t.__proto__=Ly,t}var bp=(function(){var e={};return Ee.grey=Ee.gray,Object.keys(Ee).forEach(function(t){Ee[t].closeRe=new RegExp(_y(Ee[t].close),"g"),e[t]={get:function(){return Cp(this._styles.concat(t))}}}),e})(),Ly=wp(function(){},bp);function Wy(){var e=Array.prototype.slice.call(arguments),t=e.map(function(i){return i!=null&&i.constructor===String?i:$y.inspect(i)}).join(" ");if(!x.enabled||!t)return t;for(var r=t.indexOf(`
7
+ `)!=-1,n=this._styles,s=n.length;s--;){var o=Ee[n[s]];t=o.open+t.replace(o.closeRe,o.open)+o.close,r&&(t=t.replace(By,function(i){return o.close+i+o.open}))}return t}x.setTheme=function(e){if(typeof e=="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var t in e)(function(r){x[r]=function(n){if(typeof e[r]=="object"){var s=n;for(var o in e[r])s=x[e[r][o]](s);return s}return x[e[r]](n)}})(t)};function Gy(){var e={};return Object.keys(bp).forEach(function(t){e[t]={get:function(){return Cp([t])}}}),e}var Hy=function(t,r){var n=r.split("");return n=n.map(t),n.join("")};x.trap=ap();x.zalgo=up();x.maps={};x.maps.america=pp()(x);x.maps.zebra=dp()(x);x.maps.rainbow=mp()(x);x.maps.random=Dp()(x);for(yp in x.maps)(function(e){x[e]=function(t){return Hy(x.maps[e],t)}})(yp);var yp;wp(x,Gy())});var Ep=P((WS,kp)=>{var Uy=xp();kp.exports=Uy});var Ap=P((GS,Rs)=>{var{info:zy,debug:Tp}=As(),at=vi(),Ei=class e{constructor(t){this.setOptions(t),this.x=null,this.y=null}setOptions(t){["boolean","number","bigint","string"].indexOf(typeof t)!==-1&&(t={content:""+t}),t=t||{},this.options=t;let r=t.content;if(["boolean","number","bigint","string"].indexOf(typeof r)!==-1)this.content=String(r);else if(!r)this.content=this.options.href||"";else throw new Error("Content needs to be a primitive, got: "+typeof r);this.colSpan=t.colSpan||1,this.rowSpan=t.rowSpan||1,this.options.href&&Object.defineProperty(this,"href",{get(){return this.options.href}})}mergeTableOptions(t,r){this.cells=r;let n=this.options.chars||{},s=t.chars,o=this.chars={};Jy.forEach(function(c){ki(n,s,c,o)}),this.truncate=this.options.truncate||t.truncate;let i=this.options.style=this.options.style||{},a=t.style;ki(i,a,"padding-left",this),ki(i,a,"padding-right",this),this.head=i.head||a.head,this.border=i.border||a.border,this.fixedWidth=t.colWidths[this.x],this.lines=this.computeLines(t),this.desiredWidth=at.strlen(this.content)+this.paddingLeft+this.paddingRight,this.desiredHeight=this.lines.length}computeLines(t){let r=t.wordWrap||t.textWrap,{wordWrap:n=r}=this.options;if(this.fixedWidth&&n){if(this.fixedWidth-=this.paddingLeft+this.paddingRight,this.colSpan){let i=1;for(;i<this.colSpan;)this.fixedWidth+=t.colWidths[this.x+i],i++}let{wrapOnWordBoundary:s=!0}=t,{wrapOnWordBoundary:o=s}=this.options;return this.wrapLines(at.wordWrap(this.fixedWidth,this.content,o))}return this.wrapLines(this.content.split(`
8
+ `))}wrapLines(t){let r=at.colorizeLines(t);return this.href?r.map(n=>at.hyperlink(this.href,n)):r}init(t){let r=this.x,n=this.y;this.widths=t.colWidths.slice(r,r+this.colSpan),this.heights=t.rowHeights.slice(n,n+this.rowSpan),this.width=this.widths.reduce(Fp,-1),this.height=this.heights.reduce(Fp,-1),this.hAlign=this.options.hAlign||t.colAligns[r],this.vAlign=this.options.vAlign||t.rowAligns[n],this.drawRight=r+this.colSpan==t.colWidths.length}draw(t,r){if(t=="top")return this.drawTop(this.drawRight);if(t=="bottom")return this.drawBottom(this.drawRight);let n=at.truncate(this.content,10,this.truncate);t||zy(`${this.y}-${this.x}: ${this.rowSpan-t}x${this.colSpan} Cell ${n}`);let s=Math.max(this.height-this.lines.length,0),o;switch(this.vAlign){case"center":o=Math.ceil(s/2);break;case"bottom":o=s;break;default:o=0}if(t<o||t>=o+this.lines.length)return this.drawEmpty(this.drawRight,r);let i=this.lines.length>this.height&&t+1>=this.height;return this.drawLine(t-o,this.drawRight,i,r)}drawTop(t){let r=[];return this.cells?this.widths.forEach(function(n,s){r.push(this._topLeftChar(s)),r.push(at.repeat(this.chars[this.y==0?"top":"mid"],n))},this):(r.push(this._topLeftChar(0)),r.push(at.repeat(this.chars[this.y==0?"top":"mid"],this.width))),t&&r.push(this.chars[this.y==0?"topRight":"rightMid"]),this.wrapWithStyleColors("border",r.join(""))}_topLeftChar(t){let r=this.x+t,n;if(this.y==0)n=r==0?"topLeft":t==0?"topMid":"top";else if(r==0)n="leftMid";else if(n=t==0?"midMid":"bottomMid",this.cells&&(this.cells[this.y-1][r]instanceof e.ColSpanCell&&(n=t==0?"topMid":"mid"),t==0)){let o=1;for(;this.cells[this.y][r-o]instanceof e.ColSpanCell;)o++;this.cells[this.y][r-o]instanceof e.RowSpanCell&&(n="leftMid")}return this.chars[n]}wrapWithStyleColors(t,r){if(this[t]&&this[t].length)try{let n=Ep();for(let s=this[t].length-1;s>=0;s--)n=n[this[t][s]];return n(r)}catch{return r}else return r}drawLine(t,r,n,s){let o=this.chars[this.x==0?"left":"middle"];if(this.x&&s&&this.cells){let d=this.cells[this.y+s][this.x-1];for(;d instanceof mn;)d=this.cells[d.y][d.x-1];d instanceof gn||(o=this.chars.rightMid)}let i=at.repeat(" ",this.paddingLeft),a=r?this.chars.right:"",c=at.repeat(" ",this.paddingRight),u=this.lines[t],l=this.width-(this.paddingLeft+this.paddingRight);n&&(u+=this.truncate||"\u2026");let p=at.truncate(u,l,this.truncate);return p=at.pad(p,l," ",this.hAlign),p=i+p+c,this.stylizeLine(o,p,a)}stylizeLine(t,r,n){return t=this.wrapWithStyleColors("border",t),n=this.wrapWithStyleColors("border",n),this.y===0&&(r=this.wrapWithStyleColors("head",r)),t+r+n}drawBottom(t){let r=this.chars[this.x==0?"bottomLeft":"bottomMid"],n=at.repeat(this.chars.bottom,this.width),s=t?this.chars.bottomRight:"";return this.wrapWithStyleColors("border",r+n+s)}drawEmpty(t,r){let n=this.chars[this.x==0?"left":"middle"];if(this.x&&r&&this.cells){let i=this.cells[this.y+r][this.x-1];for(;i instanceof mn;)i=this.cells[i.y][i.x-1];i instanceof gn||(n=this.chars.rightMid)}let s=t?this.chars.right:"",o=at.repeat(" ",this.width);return this.stylizeLine(n,o,s)}},mn=class{constructor(){}draw(t){return typeof t=="number"&&Tp(`${this.y}-${this.x}: 1x1 ColSpanCell`),""}init(){}mergeTableOptions(){}},gn=class{constructor(t){this.originalCell=t}init(t){let r=this.y,n=this.originalCell.y;this.cellOffset=r-n,this.offset=Ky(t.rowHeights,n,this.cellOffset)}draw(t){return t=="top"?this.originalCell.draw(this.offset,this.cellOffset):t=="bottom"?this.originalCell.draw("bottom"):(Tp(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`),this.originalCell.draw(this.offset+1+t))}mergeTableOptions(){}};function Sp(...e){return e.filter(t=>t!=null).shift()}function ki(e,t,r,n){let s=r.split("-");s.length>1?(s[1]=s[1].charAt(0).toUpperCase()+s[1].substr(1),s=s.join(""),n[s]=Sp(e[s],e[r],t[s],t[r])):n[r]=Sp(e[r],t[r])}function Ky(e,t,r){let n=e[t];for(let s=1;s<r;s++)n+=1+e[t+s];return n}function Fp(e,t){return e+t+1}var Jy=["top","top-mid","top-left","top-right","bottom","bottom-mid","bottom-left","bottom-right","left","left-mid","mid","mid-mid","right","right-mid","middle"];Rs.exports=Ei;Rs.exports.ColSpanCell=mn;Rs.exports.RowSpanCell=gn});var Ip=P((HS,Rp)=>{var{warn:Vy,debug:qy}=As(),Si=Ap(),{ColSpanCell:Yy,RowSpanCell:Zy}=Si;(function(){function e(f,m){return f[m]>0?e(f,m+1):m}function t(f){let m={};f.forEach(function(h,D){let g=0;h.forEach(function(y){y.y=D,y.x=D?e(m,g):g;let v=y.rowSpan||1,C=y.colSpan||1;if(v>1)for(let A=0;A<C;A++)m[y.x+A]=v;g=y.x+C}),Object.keys(m).forEach(y=>{m[y]--,m[y]<1&&delete m[y]})})}function r(f){let m=0;return f.forEach(function(h){h.forEach(function(D){m=Math.max(m,D.x+(D.colSpan||1))})}),m}function n(f){return f.length}function s(f,m){let h=f.y,D=f.y-1+(f.rowSpan||1),g=m.y,y=m.y-1+(m.rowSpan||1),v=!(h>y||g>D),C=f.x,A=f.x-1+(f.colSpan||1),lt=m.x,re=m.x-1+(m.colSpan||1),Fe=!(C>re||lt>A);return v&&Fe}function o(f,m,h){let D=Math.min(f.length-1,h),g={x:m,y:h};for(let y=0;y<=D;y++){let v=f[y];for(let C=0;C<v.length;C++)if(s(g,v[C]))return!0}return!1}function i(f,m,h,D){for(let g=h;g<D;g++)if(o(f,g,m))return!1;return!0}function a(f){f.forEach(function(m,h){m.forEach(function(D){for(let g=1;g<D.rowSpan;g++){let y=new Zy(D);y.x=D.x,y.y=D.y+g,y.colSpan=D.colSpan,u(y,f[h+g])}})})}function c(f){for(let m=f.length-1;m>=0;m--){let h=f[m];for(let D=0;D<h.length;D++){let g=h[D];for(let y=1;y<g.colSpan;y++){let v=new Yy;v.x=g.x+y,v.y=g.y,h.splice(D+1,0,v)}}}}function u(f,m){let h=0;for(;h<m.length&&m[h].x<f.x;)h++;m.splice(h,0,f)}function l(f){let m=n(f),h=r(f);qy(`Max rows: ${m}; Max cols: ${h}`);for(let D=0;D<m;D++)for(let g=0;g<h;g++)if(!o(f,g,D)){let y={x:g,y:D,colSpan:1,rowSpan:1};for(g++;g<h&&!o(f,g,D);)y.colSpan++,g++;let v=D+1;for(;v<m&&i(f,v,y.x,y.x+y.colSpan);)y.rowSpan++,v++;let C=new Si(y);C.x=y.x,C.y=y.y,Vy(`Missing cell at ${C.y}-${C.x}.`),u(C,f[D])}}function p(f){return f.map(function(m){if(!Array.isArray(m)){let h=Object.keys(m)[0];m=m[h],Array.isArray(m)?(m=m.slice(),m.unshift(h)):m=[h,m]}return m.map(function(h){return new Si(h)})})}function d(f){let m=p(f);return t(m),l(m),a(m),c(m),m}Rp.exports={makeTableLayout:d,layoutTable:t,addRowSpanCells:a,maxWidth:r,fillInTable:l,computeWidths:Pp("colSpan","desiredWidth","x",1),computeHeights:Pp("rowSpan","desiredHeight","y",1)}})();function Pp(e,t,r,n){return function(s,o){let i=[],a=[],c={};o.forEach(function(u){u.forEach(function(l){(l[e]||1)>1?a.push(l):i[l[r]]=Math.max(i[l[r]]||0,l[t]||0,n)})}),s.forEach(function(u,l){typeof u=="number"&&(i[l]=u)});for(let u=a.length-1;u>=0;u--){let l=a[u],p=l[e],d=l[r],f=i[d],m=typeof s[d]=="number"?0:1;if(typeof f=="number")for(let h=1;h<p;h++)f+=1+i[d+h],typeof s[d+h]!="number"&&m++;else f=t==="desiredWidth"?l.desiredWidth-1:1,(!c[d]||c[d]<f)&&(c[d]=f);if(l[t]>f){let h=0;for(;m>0&&l[t]>f;){if(typeof s[d+h]!="number"){let D=Math.round((l[t]-f)/m);f+=D,i[d+h]+=D,m--}h++}}}Object.assign(s,i,c);for(let u=0;u<s.length;u++)s[u]=Math.max(n,s[u]||0)}}});var Op=P((US,Np)=>{var Xt=As(),Xy=vi(),Fi=Ip(),Is=class extends Array{constructor(t){super();let r=Xy.mergeOptions(t);if(Object.defineProperty(this,"options",{value:r,enumerable:r.debug}),r.debug){switch(typeof r.debug){case"boolean":Xt.setDebugLevel(Xt.WARN);break;case"number":Xt.setDebugLevel(r.debug);break;case"string":Xt.setDebugLevel(parseInt(r.debug,10));break;default:Xt.setDebugLevel(Xt.WARN),Xt.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof r.debug}`)}Object.defineProperty(this,"messages",{get(){return Xt.debugMessages()}})}}toString(){let t=this,r=this.options.head&&this.options.head.length;r?(t=[this.options.head],this.length&&t.push.apply(t,this)):this.options.style.head=[];let n=Fi.makeTableLayout(t);n.forEach(function(o){o.forEach(function(i){i.mergeTableOptions(this.options,n)},this)},this),Fi.computeWidths(this.options.colWidths,n),Fi.computeHeights(this.options.rowHeights,n),n.forEach(function(o){o.forEach(function(i){i.init(this.options)},this)},this);let s=[];for(let o=0;o<n.length;o++){let i=n[o],a=this.options.rowHeights[o];(o===0||!this.options.style.compact||o==1&&r)&&Ti(i,"top",s);for(let c=0;c<a;c++)Ti(i,c,s);o+1==n.length&&Ti(i,"bottom",s)}return s.join(`
9
9
  `)}get width(){return this.toString().split(`
10
- `)[0].length}};Fs.reset=()=>Zt.reset();function xi(e,t,r){let n=[];e.forEach(function(o){n.push(o.draw(t))});let s=n.join("");s.length&&r.push(s)}Ap.exports=Fs});var ki=P((BS,Rp)=>{Rp.exports=Pp()});var od=require("node:process"),Ee=b(require("chalk")),id=require("commander");var yn={};md(yn,{ConEmu:()=>sa,beep:()=>Ud,clearScreen:()=>jd,clearTerminal:()=>Wd,clearViewport:()=>_d,cursorBackward:()=>xd,cursorDown:()=>bd,cursorForward:()=>vd,cursorGetPosition:()=>Sd,cursorHide:()=>Ad,cursorLeft:()=>ea,cursorMove:()=>Cd,cursorNextLine:()=>Fd,cursorPrevLine:()=>Td,cursorRestorePosition:()=>Ed,cursorSavePosition:()=>kd,cursorShow:()=>Pd,cursorTo:()=>wd,cursorUp:()=>ta,enterAlternativeScreen:()=>Gd,eraseDown:()=>Od,eraseEndLine:()=>Id,eraseLine:()=>ra,eraseLines:()=>Rd,eraseScreen:()=>Dn,eraseStartLine:()=>Nd,eraseUp:()=>Md,exitAlternativeScreen:()=>Hd,iTerm:()=>na,image:()=>Kd,link:()=>zd,scrollDown:()=>Bd,scrollUp:()=>$d,setCwd:()=>Jd});var he=b(require("node:process"),1),Xi=b(require("node:os"),1);var Ae=globalThis.window?.document!==void 0,AC=globalThis.process?.versions?.node!==void 0,PC=globalThis.process?.versions?.bun!==void 0,RC=globalThis.Deno?.version?.deno!==void 0,IC=globalThis.process?.versions?.electron!==void 0,NC=globalThis.navigator?.userAgent?.includes("jsdom")===!0,OC=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,MC=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,$C=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,BC=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,kr=globalThis.navigator?.userAgentData?.platform,jC=kr==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",_C=kr==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",LC=kr==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",WC=kr==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),GC=kr==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var E="\x1B[",Pe="\x1B]",me="\x07",Er=";",Qi=!Ae&&he.default.env.TERM_PROGRAM==="Apple_Terminal",Dd=!Ae&&he.default.platform==="win32",yd=!Ae&&(he.default.env.TERM?.startsWith("screen")||he.default.env.TERM?.startsWith("tmux")||he.default.env.TMUX!==void 0),Us=Ae?()=>{throw new Error("`process.cwd()` only works in Node.js, not the browser.")}:he.default.cwd,Re=e=>yd?"\x1BPtmux;"+e.replaceAll("\x1B","\x1B\x1B")+"\x1B\\":e,wd=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");return typeof t!="number"?E+(e+1)+"G":E+(t+1)+Er+(e+1)+"H"},Cd=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");let r="";return e<0?r+=E+-e+"D":e>0&&(r+=E+e+"C"),t<0?r+=E+-t+"A":t>0&&(r+=E+t+"B"),r},ta=(e=1)=>E+e+"A",bd=(e=1)=>E+e+"B",vd=(e=1)=>E+e+"C",xd=(e=1)=>E+e+"D",ea=E+"G",kd=Qi?"\x1B7":E+"s",Ed=Qi?"\x1B8":E+"u",Sd=E+"6n",Fd=E+"E",Td=E+"F",Ad=E+"?25l",Pd=E+"?25h",Rd=e=>{let t="";for(let r=0;r<e;r++)t+=ra+(r<e-1?ta():"");return e&&(t+=ea),t},Id=E+"K",Nd=E+"1K",ra=E+"2K",Od=E+"J",Md=E+"1J",Dn=E+"2J",$d=E+"S",Bd=E+"T",jd="\x1Bc",_d=`${Dn}${E}H`,Ld=()=>{if(Ae||!Dd)return!1;let e=Xi.default.release().split("."),t=Number(e[0]),r=Number(e[2]??0);return t<10||t===10&&r<10586},Wd=Ld()?`${Dn}${E}0f`:`${Dn}${E}3J${E}H`,Gd=E+"?1049h",Hd=E+"?1049l",Ud=me,zd=(e,t)=>{let r=Re(`${Pe}8${Er}${Er}${t}${me}`),n=Re(`${Pe}8${Er}${Er}${me}`);return r+e+n},Kd=(e,t={})=>{let r=`${Pe}1337;File=inline=1`;t.width&&(r+=`;width=${t.width}`),t.height&&(r+=`;height=${t.height}`),t.preserveAspectRatio===!1&&(r+=";preserveAspectRatio=0");let n=Buffer.from(e);return Re(r+`;size=${n.byteLength}:`+n.toString("base64")+me)},na={setCwd:(e=Us())=>Re(`${Pe}50;CurrentDir=${e}${me}`),annotation(e,t={}){let r=`${Pe}1337;`,n=t.x!==void 0,s=t.y!==void 0;if((n||s)&&!(n&&s&&t.length!==void 0))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return e=e.replaceAll("|",""),r+=t.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",t.length>0?r+=(n?[e,t.length,t.x,t.y]:[t.length,e]).join("|"):r+=e,Re(r+me)}},sa={setCwd:(e=Us())=>Re(`${Pe}9;9;${e}${me}`)},Jd=(e=Us())=>na.setCwd(e)+sa.setCwd(e);var wn=b(pa(),1);function Ut(e,t,{target:r="stdout",...n}={}){return wn.default[r]?yn.link(e,t):n.fallback===!1?e:typeof n.fallback=="function"?n.fallback(e,t):`${e} (\u200B${t}\u200B)`}Ut.isSupported=wn.default.stdout;Ut.stderr=(e,t,r={})=>Ut(e,t,{target:"stderr",...r});Ut.stderr.isSupported=wn.default.stderr;var wu=b(require("chalk")),Cu=require("commander");var bt=require("node:fs"),rt=require("node:path"),Ce=require("fs-extra");var fa=["bun.lock","bun.lockb","package-lock.json","yarn.lock","pnpm-lock.yaml"],qs="start:dev";var Sr=b(require("chalk"));function Ys(e,t){if(e.length===0)return"No entries to display.";let r=t?.title||"Benchmark Results",n=t?.footer||"",s=t?.maxBarWidth||50,o=t?.unit||"",i=Math.max(...e.map(c=>c.value)),a=[];a.push(""),a.push(r),a.push("");for(let c of e){let u=Zd(c.barColor??t?.barColor),l=Xd(c,i,s,u,o,t?.labelColor);a.push(l)}return n&&(a.push(""),a.push(n)),a.join(`
11
- `)}function Zd(e){return e?Sr.default[e]("\u2587"):"\u2587"}function Xd(e,t,r,n,s,o){let i=Math.round(e.value/t*r),a=e.barColor?Sr.default[e.barColor](n.repeat(i)):n.repeat(i),c=e.color??o;return`${Sr.default.bold(c?Sr.default[c](e.label.padEnd(12)):e.label.padEnd(12))} ${a} ${e.value.toLocaleString()}${s?` ${s}`:""}`}var Zs=b(require("chalk")),ha=require("commander"),Xs=require("listr2");var Fr=b(require("chalk")),w={logs:[],breakLine:()=>(console.log(),w),success:(e,...t)=>(console.log(Fr.default.green(`\u2714 ${e}`),...t),w),info:(e,...t)=>(console.log(Fr.default.cyan(`\u{1F6C8} ${e}`),...t),w),warn:(e,...t)=>(console.warn(Fr.default.yellow(`\u26A0\uFE0E ${e}`),...t),w),error:(e,...t)=>(console.error(Fr.default.red(`\u2716 ${e}`),...t),w),log:(e,...t)=>(console.log(e,...t),w.logs.push({message:e,context:t.join()}),w),getStoredLogs:e=>e?w.logs.filter(t=>t.context?.includes(e)):w.logs,storeLog:(e,t)=>w.logs.push({message:e,context:t})};function ne(e){let t=new ha.Command(e.name).description(e.description).showHelpAfterError();return e.arguments?.map(([r,n])=>t.argument(r,n)),e.options?.map(([r,n])=>t.option(r,n)),e.exampleUsage&&t.addHelpText("after",()=>`${Zs.default.cyan.bold(`
10
+ `)[0].length}};Is.reset=()=>Xt.reset();function Ti(e,t,r){let n=[];e.forEach(function(o){n.push(o.draw(t))});let s=n.join("");s.length&&r.push(s)}Np.exports=Is});var Ai=P((zS,Mp)=>{Mp.exports=Op()});var id=require("node:process"),Se=b(require("chalk")),ad=require("commander");var xn={};gd(xn,{ConEmu:()=>ca,beep:()=>zd,clearScreen:()=>_d,clearTerminal:()=>Gd,clearViewport:()=>Ld,cursorBackward:()=>kd,cursorDown:()=>vd,cursorForward:()=>xd,cursorGetPosition:()=>Fd,cursorHide:()=>Pd,cursorLeft:()=>oa,cursorMove:()=>bd,cursorNextLine:()=>Td,cursorPrevLine:()=>Ad,cursorRestorePosition:()=>Sd,cursorSavePosition:()=>Ed,cursorShow:()=>Rd,cursorTo:()=>Cd,cursorUp:()=>sa,enterAlternativeScreen:()=>Hd,eraseDown:()=>Md,eraseEndLine:()=>Nd,eraseLine:()=>ia,eraseLines:()=>Id,eraseScreen:()=>vn,eraseStartLine:()=>Od,eraseUp:()=>$d,exitAlternativeScreen:()=>Ud,iTerm:()=>aa,image:()=>Jd,link:()=>Kd,scrollDown:()=>jd,scrollUp:()=>Bd,setCwd:()=>Vd});var me=b(require("node:process"),1),ra=b(require("node:os"),1);var Pe=globalThis.window?.document!==void 0,NC=globalThis.process?.versions?.node!==void 0,OC=globalThis.process?.versions?.bun!==void 0,MC=globalThis.Deno?.version?.deno!==void 0,$C=globalThis.process?.versions?.electron!==void 0,BC=globalThis.navigator?.userAgent?.includes("jsdom")===!0,jC=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,_C=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,LC=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,WC=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,Fr=globalThis.navigator?.userAgentData?.platform,GC=Fr==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",HC=Fr==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",UC=Fr==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",zC=Fr==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),KC=Fr==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var E="\x1B[",Re="\x1B]",ge="\x07",Tr=";",na=!Pe&&me.default.env.TERM_PROGRAM==="Apple_Terminal",yd=!Pe&&me.default.platform==="win32",wd=!Pe&&(me.default.env.TERM?.startsWith("screen")||me.default.env.TERM?.startsWith("tmux")||me.default.env.TMUX!==void 0),qs=Pe?()=>{throw new Error("`process.cwd()` only works in Node.js, not the browser.")}:me.default.cwd,Ie=e=>wd?"\x1BPtmux;"+e.replaceAll("\x1B","\x1B\x1B")+"\x1B\\":e,Cd=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");return typeof t!="number"?E+(e+1)+"G":E+(t+1)+Tr+(e+1)+"H"},bd=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");let r="";return e<0?r+=E+-e+"D":e>0&&(r+=E+e+"C"),t<0?r+=E+-t+"A":t>0&&(r+=E+t+"B"),r},sa=(e=1)=>E+e+"A",vd=(e=1)=>E+e+"B",xd=(e=1)=>E+e+"C",kd=(e=1)=>E+e+"D",oa=E+"G",Ed=na?"\x1B7":E+"s",Sd=na?"\x1B8":E+"u",Fd=E+"6n",Td=E+"E",Ad=E+"F",Pd=E+"?25l",Rd=E+"?25h",Id=e=>{let t="";for(let r=0;r<e;r++)t+=ia+(r<e-1?sa():"");return e&&(t+=oa),t},Nd=E+"K",Od=E+"1K",ia=E+"2K",Md=E+"J",$d=E+"1J",vn=E+"2J",Bd=E+"S",jd=E+"T",_d="\x1Bc",Ld=`${vn}${E}H`,Wd=()=>{if(Pe||!yd)return!1;let e=ra.default.release().split("."),t=Number(e[0]),r=Number(e[2]??0);return t<10||t===10&&r<10586},Gd=Wd()?`${vn}${E}0f`:`${vn}${E}3J${E}H`,Hd=E+"?1049h",Ud=E+"?1049l",zd=ge,Kd=(e,t)=>{let r=Ie(`${Re}8${Tr}${Tr}${t}${ge}`),n=Ie(`${Re}8${Tr}${Tr}${ge}`);return r+e+n},Jd=(e,t={})=>{let r=`${Re}1337;File=inline=1`;t.width&&(r+=`;width=${t.width}`),t.height&&(r+=`;height=${t.height}`),t.preserveAspectRatio===!1&&(r+=";preserveAspectRatio=0");let n=Buffer.from(e);return Ie(r+`;size=${n.byteLength}:`+n.toString("base64")+ge)},aa={setCwd:(e=qs())=>Ie(`${Re}50;CurrentDir=${e}${ge}`),annotation(e,t={}){let r=`${Re}1337;`,n=t.x!==void 0,s=t.y!==void 0;if((n||s)&&!(n&&s&&t.length!==void 0))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return e=e.replaceAll("|",""),r+=t.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",t.length>0?r+=(n?[e,t.length,t.x,t.y]:[t.length,e]).join("|"):r+=e,Ie(r+ge)}},ca={setCwd:(e=qs())=>Ie(`${Re}9;9;${e}${ge}`)},Vd=(e=qs())=>aa.setCwd(e)+ca.setCwd(e);var kn=b(ma(),1);function Ut(e,t,{target:r="stdout",...n}={}){return kn.default[r]?xn.link(e,t):n.fallback===!1?e:typeof n.fallback=="function"?n.fallback(e,t):`${e} (\u200B${t}\u200B)`}Ut.isSupported=kn.default.stdout;Ut.stderr=(e,t,r={})=>Ut(e,t,{target:"stderr",...r});Ut.stderr.isSupported=kn.default.stderr;var xu=b(require("chalk")),ku=require("commander");var bt=require("node:fs"),rt=require("node:path"),be=require("fs-extra");var ga=["bun.lock","bun.lockb","package-lock.json","yarn.lock","pnpm-lock.yaml"],to="start:dev";var Ar=b(require("chalk"));function eo(e,t){if(e.length===0)return"No entries to display.";let r=t?.title||"Benchmark Results",n=t?.footer||"",s=t?.maxBarWidth||50,o=t?.unit||"",i=Math.max(...e.map(c=>c.value)),a=[];a.push(""),a.push(r),a.push("");for(let c of e){let u=Xd(c.barColor??t?.barColor),l=Qd(c,i,s,u,o,t?.labelColor);a.push(l)}return n&&(a.push(""),a.push(n)),a.join(`
11
+ `)}function Xd(e){return e?Ar.default[e]("\u2587"):"\u2587"}function Qd(e,t,r,n,s,o){let i=Math.round(e.value/t*r),a=e.barColor?Ar.default[e.barColor](n.repeat(i)):n.repeat(i),c=e.color??o;return`${Ar.default.bold(c?Ar.default[c](e.label.padEnd(12)):e.label.padEnd(12))} ${a} ${e.value.toLocaleString()}${s?` ${s}`:""}`}var ro=b(require("chalk")),ya=require("commander"),no=require("listr2");var Pr=b(require("chalk")),w={logs:[],breakLine:()=>(console.log(),w),success:(e,...t)=>(console.log(Pr.default.green(`\u2714 ${e}`),...t),w),info:(e,...t)=>(console.log(Pr.default.cyan(`\u{1F6C8} ${e}`),...t),w),warn:(e,...t)=>(console.warn(Pr.default.yellow(`\u26A0\uFE0E ${e}`),...t),w),error:(e,...t)=>(console.error(Pr.default.red(`\u2716 ${e}`),...t),w),log:(e,...t)=>(console.log(e,...t),w.logs.push({message:e,context:t.join()}),w),getStoredLogs:e=>e?w.logs.filter(t=>t.context?.includes(e)):w.logs,storeLog:(e,t)=>w.logs.push({message:e,context:t})};function se(e){let t=new ya.Command(e.name).description(e.description).showHelpAfterError();return e.arguments?.map(([r,n])=>t.argument(r,n)),e.options?.map(([r,n])=>t.option(r,n)),e.exampleUsage&&t.addHelpText("after",()=>`${ro.default.cyan.bold(`
12
12
  Example:`)}
13
- ${Zs.default.bold(e.exampleUsage)}
14
- `),e.additionalInfo&&t.addHelpText("after",()=>(typeof e.additionalInfo=="function"?e.additionalInfo():e.additionalInfo)??""),t.action(async(...r)=>{try{let n=r.at(-1),s=n.args,o=n.opts(),i=Qd(e.arguments??[],s);if(e.shouldSkipWorkflow?.(i,o)){await e.onSkipWorkflow?.(i,o);return}let a=await e.buildContext(i,o);e.prompts?.length&&await new Xs.Listr(da(e.prompts,a),{rendererOptions:{lazy:!0,showErrorMessage:!1}}).run(a),await new Xs.Listr(da(e.actions,a),{rendererOptions:{lazy:!1,showErrorMessage:!1,clearOutput:!0}}).run(a),await e.onComplete?.(a)}catch(n){let s=n;w.error(s.message)}}),t}function Qd(e,t){let r={};return e.forEach(([n],s)=>{let o=n.replace(/[<>[\]]/g,"");r[o]=t[s]}),r}function da(e,t){return e.map(r=>typeof r=="function"?r(t):r)}function Cn(e,t,r){let n=t.split("."),s=e;for(;n.length>1;){let o=n.shift();o in s||(s[o]={}),s=s[o]}s[n[0]]=r}var ma=require("execa");function Tr(e){try{return(0,ma.execaSync)(e,["--version"]),!0}catch{return!1}}var qe=require("node:path"),zc=require("fs-extra");var ba=b(require("node:process"),1);var Da=b(require("node:process"),1);var ya=require("node:url"),wa=b(require("node:fs"),1),ge=b(require("node:path"),1),ga=e=>e instanceof URL?(0,ya.fileURLToPath)(e):e;function Ca(e,{cwd:t=Da.default.cwd(),type:r="file",stopAt:n}={}){let s=ge.default.resolve(ga(t)??""),{root:o}=ge.default.parse(s);n=ge.default.resolve(s,ga(n)??o);let i=ge.default.isAbsolute(e);for(;s;){let a=i?e:ge.default.join(s,e);try{let c=wa.default.statSync(a,{throwIfNoEntry:!1});if(r==="file"&&c?.isFile()||r==="directory"&&c?.isDirectory())return a}catch{}if(s===n||s===o)break;s=ge.default.dirname(s)}}function va({cwd:e=ba.default.cwd()}={}){return Ca("package.json",{cwd:e})}var Qs=(e,t,r)=>{let n=e instanceof RegExp?xa(e,r):e,s=t instanceof RegExp?xa(t,r):t,o=n!==null&&s!=null&&th(n,s,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+s.length)}},xa=(e,t)=>{let r=t.match(e);return r?r[0]:null},th=(e,t,r)=>{let n,s,o,i,a,c=r.indexOf(e),u=r.indexOf(t,c+1),l=c;if(c>=0&&u>0){if(e===t)return[c,u];for(n=[],o=r.length;l>=0&&!a;){if(l===c)n.push(l),c=r.indexOf(e,l+1);else if(n.length===1){let p=n.pop();p!==void 0&&(a=[p,u])}else s=n.pop(),s!==void 0&&s<o&&(o=s,i=u),u=r.indexOf(t,l+1);l=c<u&&c>=0?c:u}n.length&&i!==void 0&&(a=[o,i])}return a};var ka="\0SLASH"+Math.random()+"\0",Ea="\0OPEN"+Math.random()+"\0",eo="\0CLOSE"+Math.random()+"\0",Sa="\0COMMA"+Math.random()+"\0",Fa="\0PERIOD"+Math.random()+"\0",eh=new RegExp(ka,"g"),rh=new RegExp(Ea,"g"),nh=new RegExp(eo,"g"),sh=new RegExp(Sa,"g"),oh=new RegExp(Fa,"g"),ih=/\\\\/g,ah=/\\{/g,ch=/\\}/g,uh=/\\,/g,lh=/\\./g;function to(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function ph(e){return e.replace(ih,ka).replace(ah,Ea).replace(ch,eo).replace(uh,Sa).replace(lh,Fa)}function fh(e){return e.replace(eh,"\\").replace(rh,"{").replace(nh,"}").replace(sh,",").replace(oh,".")}function Ta(e){if(!e)return[""];let t=[],r=Qs("{","}",e);if(!r)return e.split(",");let{pre:n,body:s,post:o}=r,i=n.split(",");i[i.length-1]+="{"+s+"}";let a=Ta(o);return o.length&&(i[i.length-1]+=a.shift(),i.push.apply(i,a)),t.push.apply(t,i),t}function Aa(e){return e?(e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),Ar(ph(e),!0).map(fh)):[]}function dh(e){return"{"+e+"}"}function hh(e){return/^-?0\d/.test(e)}function mh(e,t){return e<=t}function gh(e,t){return e>=t}function Ar(e,t){let r=[],n=Qs("{","}",e);if(!n)return[e];let s=n.pre,o=n.post.length?Ar(n.post,!1):[""];if(/\$$/.test(n.pre))for(let i=0;i<o.length;i++){let a=s+"{"+n.body+"}"+o[i];r.push(a)}else{let i=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),c=i||a,u=n.body.indexOf(",")>=0;if(!c&&!u)return n.post.match(/,(?!,).*\}/)?(e=n.pre+"{"+n.body+eo+n.post,Ar(e)):[e];let l;if(c)l=n.body.split(/\.\./);else if(l=Ta(n.body),l.length===1&&l[0]!==void 0&&(l=Ar(l[0],!1).map(dh),l.length===1))return o.map(d=>n.pre+l[0]+d);let p;if(c&&l[0]!==void 0&&l[1]!==void 0){let d=to(l[0]),f=to(l[1]),m=Math.max(l[0].length,l[1].length),h=l.length===3&&l[2]!==void 0?Math.abs(to(l[2])):1,D=mh;f<d&&(h*=-1,D=gh);let y=l.some(hh);p=[];for(let v=d;D(v,f);v+=h){let C;if(a)C=String.fromCharCode(v),C==="\\"&&(C="");else if(C=String(v),y){let A=m-C.length;if(A>0){let lt=new Array(A+1).join("0");v<0?C="-"+lt+C.slice(1):C=lt+C}}p.push(C)}}else{p=[];for(let d=0;d<l.length;d++)p.push.apply(p,Ar(l[d],!1))}for(let d=0;d<p.length;d++)for(let f=0;f<o.length;f++){let m=s+p[d]+o[f];(!t||c||m)&&r.push(m)}}return r}var Pr=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Dh={"[: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]},Rr=e=>e.replace(/[[\]\\-]/g,"\\$&"),yh=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Pa=e=>e.join(""),Ra=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],s=[],o=r+1,i=!1,a=!1,c=!1,u=!1,l=r,p="";t:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){u=!0,o++;continue}if(h==="]"&&i&&!c){l=o+1;break}if(i=!0,h==="\\"&&!c){c=!0,o++;continue}if(h==="["&&!c){for(let[D,[g,y,v]]of Object.entries(Dh))if(e.startsWith(D,o)){if(p)return["$.",!1,e.length-r,!0];o+=D.length,v?s.push(g):n.push(g),a=a||y;continue t}}if(c=!1,p){h>p?n.push(Rr(p)+"-"+Rr(h)):h===p&&n.push(Rr(h)),p="",o++;continue}if(e.startsWith("-]",o+1)){n.push(Rr(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){p=h,o+=2;continue}n.push(Rr(h)),o++}if(l<o)return["",!1,0,!1];if(!n.length&&!s.length)return["$.",!1,e.length-r,!0];if(s.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let h=n[0].length===2?n[0].slice(-1):n[0];return[yh(h),!1,l-r,!1]}let d="["+(u?"^":"")+Pa(n)+"]",f="["+(u?"":"^")+Pa(s)+"]";return[n.length&&s.length?"("+d+"|"+f+")":n.length?d:f,a,l-r,!0]};var Dt=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var wh=new Set(["!","?","+","*","@"]),Ia=e=>wh.has(e),Ch="(?!(?:^|/)\\.\\.?(?:$|/))",bn="(?!\\.)",bh=new Set(["[","."]),vh=new Set(["..","."]),xh=new Set("().*{}+?[]^$\\!"),kh=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ro="[^/]",Na=ro+"*?",Oa=ro+"+?",Ne=class e{type;#t;#r;#o=!1;#s=[];#i;#C;#D;#l=!1;#a;#f;#p=!1;constructor(t,r,n={}){this.type=t,t&&(this.#r=!0),this.#i=r,this.#t=this.#i?this.#i.#t:this,this.#a=this.#t===this?n:this.#t.#a,this.#D=this.#t===this?[]:this.#t.#D,t==="!"&&!this.#t.#l&&this.#D.push(this),this.#C=this.#i?this.#i.#s.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#s)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#f!==void 0?this.#f:this.type?this.#f=this.type+"("+this.#s.map(t=>String(t)).join("|")+")":this.#f=this.#s.map(t=>String(t)).join("")}#c(){if(this!==this.#t)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let t;for(;t=this.#D.pop();){if(t.type!=="!")continue;let r=t,n=r.#i;for(;n;){for(let s=r.#C+1;!n.type&&s<n.#s.length;s++)for(let o of t.#s){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#s[s])}r=n,n=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof e&&r.#i===this))throw new Error("invalid part: "+r);this.#s.push(r)}}toJSON(){let t=this.type===null?this.#s.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#s.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#l&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#i?.isStart())return!1;if(this.#C===0)return!0;let t=this.#i;for(let r=0;r<this.#C;r++){let n=t.#s[r];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#s.length:0;return this.#C===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new e(this.type,t);for(let n of this.#s)r.copyIn(n);return r}static#n(t,r,n,s){let o=!1,i=!1,a=-1,c=!1;if(r.type===null){let f=n,m="";for(;f<t.length;){let h=t.charAt(f++);if(o||h==="\\"){o=!o,m+=h;continue}if(i){f===a+1?(h==="^"||h==="!")&&(c=!0):h==="]"&&!(f===a+2&&c)&&(i=!1),m+=h;continue}else if(h==="["){i=!0,a=f,c=!1,m+=h;continue}if(!s.noext&&Ia(h)&&t.charAt(f)==="("){r.push(m),m="";let D=new e(h,r);f=e.#n(t,D,f,s),r.push(D);continue}m+=h}return r.push(m),f}let u=n+1,l=new e(null,r),p=[],d="";for(;u<t.length;){let f=t.charAt(u++);if(o||f==="\\"){o=!o,d+=f;continue}if(i){u===a+1?(f==="^"||f==="!")&&(c=!0):f==="]"&&!(u===a+2&&c)&&(i=!1),d+=f;continue}else if(f==="["){i=!0,a=u,c=!1,d+=f;continue}if(Ia(f)&&t.charAt(u)==="("){l.push(d),d="";let m=new e(f,l);l.push(m),u=e.#n(t,m,u,s);continue}if(f==="|"){l.push(d),d="",p.push(l),l=new e(null,r);continue}if(f===")")return d===""&&r.#s.length===0&&(r.#p=!0),l.push(d),d="",r.push(...p,l),u;d+=f}return r.type=null,r.#r=void 0,r.#s=[t.substring(n-1)],u}static fromGlob(t,r={}){let n=new e(null,void 0,r);return e.#n(t,n,0,r),n}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[r,n,s,o]=this.toRegExpSource();if(!(s||this.#r||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#t===this&&this.#c(),!this.type){let c=this.isStart()&&this.isEnd()&&!this.#s.some(f=>typeof f!="string"),u=this.#s.map(f=>{let[m,h,D,g]=typeof f=="string"?e.#b(f,this.#r,c):f.toRegExpSource(t);return this.#r=this.#r||D,this.#o=this.#o||g,m}).join(""),l="";if(this.isStart()&&typeof this.#s[0]=="string"&&!(this.#s.length===1&&vh.has(this.#s[0]))){let m=bh,h=r&&m.has(u.charAt(0))||u.startsWith("\\.")&&m.has(u.charAt(2))||u.startsWith("\\.\\.")&&m.has(u.charAt(4)),D=!r&&!t&&m.has(u.charAt(0));l=h?Ch:D?bn:""}let p="";return this.isEnd()&&this.#t.#l&&this.#i?.type==="!"&&(p="(?:$|\\/)"),[l+u+p,Dt(u),this.#r=!!this.#r,this.#o]}let n=this.type==="*"||this.type==="+",s=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#d(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let c=this.toString();return this.#s=[c],this.type=null,this.#r=void 0,[c,Dt(this.toString()),!1,!1]}let i=!n||t||r||!bn?"":this.#d(!0);i===o&&(i=""),i&&(o=`(?:${o})(?:${i})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?bn:"")+Oa;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!t?bn:"")+Na+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&i?")":this.type==="*"&&i?")?":`)${this.type}`;a=s+o+c}return[a,Dt(o),this.#r=!!this.#r,this.#o]}#d(t){return this.#s.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,s,o,i]=r.toRegExpSource(t);return this.#o=this.#o||i,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#b(t,r,n=!1){let s=!1,o="",i=!1;for(let a=0;a<t.length;a++){let c=t.charAt(a);if(s){s=!1,o+=(xh.has(c)?"\\":"")+c;continue}if(c==="\\"){a===t.length-1?o+="\\\\":s=!0;continue}if(c==="["){let[u,l,p,d]=Ra(t,a);if(p){o+=u,i=i||l,a+=p-1,r=r||d;continue}}if(c==="*"){o+=n&&t==="*"?Oa:Na,r=!0;continue}if(c==="?"){o+=ro,r=!0;continue}o+=kh(c)}return[o,Dt(t),!!r,i]}};var Oe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var q=(e,t,r={})=>(Pr(t),!r.nocomment&&t.charAt(0)==="#"?!1:new ot(t,r).match(e)),Eh=/^\*+([^+@!?\*\[\(]*)$/,Sh=e=>t=>!t.startsWith(".")&&t.endsWith(e),Fh=e=>t=>t.endsWith(e),Th=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Ah=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Ph=/^\*+\.\*+$/,Rh=e=>!e.startsWith(".")&&e.includes("."),Ih=e=>e!=="."&&e!==".."&&e.includes("."),Nh=/^\.\*+$/,Oh=e=>e!=="."&&e!==".."&&e.startsWith("."),Mh=/^\*+$/,$h=e=>e.length!==0&&!e.startsWith("."),Bh=e=>e.length!==0&&e!=="."&&e!=="..",jh=/^\?+([^+@!?\*\[\(]*)?$/,_h=([e,t=""])=>{let r=Ba([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Lh=([e,t=""])=>{let r=ja([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Wh=([e,t=""])=>{let r=ja([e]);return t?n=>r(n)&&n.endsWith(t):r},Gh=([e,t=""])=>{let r=Ba([e]);return t?n=>r(n)&&n.endsWith(t):r},Ba=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},ja=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},_a=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Ma={win32:{sep:"\\"},posix:{sep:"/"}},Hh=_a==="win32"?Ma.win32.sep:Ma.posix.sep;q.sep=Hh;var H=Symbol("globstar **");q.GLOBSTAR=H;var Uh="[^/]",zh=Uh+"*?",Kh="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Jh="(?:(?!(?:\\/|^)\\.).)*?",Vh=(e,t={})=>r=>q(r,e,t);q.filter=Vh;var ft=(e,t={})=>Object.assign({},e,t),qh=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return q;let t=q;return Object.assign((n,s,o={})=>t(n,s,ft(e,o)),{Minimatch:class extends t.Minimatch{constructor(s,o={}){super(s,ft(e,o))}static defaults(s){return t.defaults(ft(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,o,i={}){super(s,o,ft(e,i))}static fromGlob(s,o={}){return t.AST.fromGlob(s,ft(e,o))}},unescape:(n,s={})=>t.unescape(n,ft(e,s)),escape:(n,s={})=>t.escape(n,ft(e,s)),filter:(n,s={})=>t.filter(n,ft(e,s)),defaults:n=>t.defaults(ft(e,n)),makeRe:(n,s={})=>t.makeRe(n,ft(e,s)),braceExpand:(n,s={})=>t.braceExpand(n,ft(e,s)),match:(n,s,o={})=>t.match(n,s,ft(e,o)),sep:t.sep,GLOBSTAR:H})};q.defaults=qh;var La=(e,t={})=>(Pr(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Aa(e));q.braceExpand=La;var Yh=(e,t={})=>new ot(e,t).makeRe();q.makeRe=Yh;var Zh=(e,t,r={})=>{let n=new ot(t,r);return e=e.filter(s=>n.match(s)),n.options.nonull&&!e.length&&e.push(t),e};q.match=Zh;var $a=/[?*]|[+@!]\(.*?\)|\[|\]/,Xh=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ot=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,r={}){Pr(t),r=r||{},this.options=r,this.pattern=t,this.platform=r.platform||_a,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.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 t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let s=this.globParts.map((o,i,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=o[0]===""&&o[1]===""&&(o[2]==="?"||!$a.test(o[2]))&&!$a.test(o[3]),u=/^[a-z]:/i.test(o[0]);if(c)return[...o.slice(0,4),...o.slice(4).map(l=>this.parse(l))];if(u)return[o[0],...o.slice(1).map(l=>this.parse(l))]}return o.map(c=>this.parse(c))});if(this.debug(this.pattern,s),this.set=s.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let i=this.set[o];i[0]===""&&i[1]===""&&this.globParts[o][2]==="?"&&typeof i[3]=="string"&&/^[a-z]:$/i.test(i[3])&&(i[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n=0;n<t.length;n++)for(let s=0;s<t[n].length;s++)t[n][s]==="**"&&(t[n][s]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let s=n;for(;r[s+1]==="**";)s++;s!==n&&r.splice(n,s-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,s)=>{let o=n[n.length-1];return s==="**"&&o==="**"?n:s===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(s),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let s=1;s<t.length-1;s++){let o=t[s];s===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(s,1),s--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let s=t[n-1];s&&s!=="."&&s!==".."&&s!=="**"&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let s=-1;for(;(s=n.indexOf("**",s+1))!==-1;){let i=s;for(;n[i+1]==="**";)i++;i>s&&n.splice(s+1,i-s);let a=n[s+1],c=n[s+2],u=n[s+3];if(a!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;r=!0,n.splice(s,1);let l=n.slice(0);l[s]="**",t.push(l),s--}if(!this.preserveMultipleSlashes){for(let i=1;i<n.length-1;i++){let a=n[i];i===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(i,1),i--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let i=n[o-1];if(i&&i!=="."&&i!==".."&&i!=="**"){r=!0;let c=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...c),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let s=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(s){t[r]=[],t[n]=s;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let s=0,o=0,i=[],a="";for(;s<t.length&&o<r.length;)if(t[s]===r[o])i.push(a==="b"?r[o]:t[s]),s++,o++;else if(n&&t[s]==="**"&&r[o]===t[s+1])i.push(t[s]),s++;else if(n&&r[o]==="**"&&t[s]===r[o+1])i.push(r[o]),o++;else if(t[s]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",i.push(t[s]),s++,o++}else if(r[o]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(a==="a")return!1;a="b",i.push(r[o]),s++,o++}else return!1;return t.length===r.length&&i}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let s=0;s<t.length&&t.charAt(s)==="!";s++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let s=this.options;if(this.isWindows){let h=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),D=!h&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),g=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),y=!g&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),v=D?3:h?0:void 0,C=y?3:g?0:void 0;if(typeof v=="number"&&typeof C=="number"){let[A,lt]=[t[v],r[C]];A.toLowerCase()===lt.toLowerCase()&&(r[C]=A,C>v?r=r.slice(C):v>C&&(t=t.slice(v)))}}let{optimizationLevel:o=1}=this.options;o>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:r}),this.debug("matchOne",t.length,r.length);for(var i=0,a=0,c=t.length,u=r.length;i<c&&a<u;i++,a++){this.debug("matchOne loop");var l=r[a],p=t[i];if(this.debug(r,l,p),l===!1)return!1;if(l===H){this.debug("GLOBSTAR",[r,l,p]);var d=i,f=a+1;if(f===u){for(this.debug("** at the end");i<c;i++)if(t[i]==="."||t[i]===".."||!s.dot&&t[i].charAt(0)===".")return!1;return!0}for(;d<c;){var m=t[d];if(this.debug(`
13
+ ${ro.default.bold(e.exampleUsage)}
14
+ `),e.additionalInfo&&t.addHelpText("after",()=>(typeof e.additionalInfo=="function"?e.additionalInfo():e.additionalInfo)??""),t.action(async(...r)=>{try{let n=r.at(-1),s=n.args,o=n.opts(),i=th(e.arguments??[],s);if(e.shouldSkipWorkflow?.(i,o)){await e.onSkipWorkflow?.(i,o);return}let a=await e.buildContext(i,o);e.prompts?.length&&await new no.Listr(Da(e.prompts,a),{rendererOptions:{lazy:!0,showErrorMessage:!1}}).run(a),await new no.Listr(Da(e.actions,a),{rendererOptions:{lazy:!1,showErrorMessage:!1,clearOutput:!0}}).run(a),await e.onComplete?.(a)}catch(n){let s=n;w.error(s.message)}}),t}function th(e,t){let r={};return e.forEach(([n],s)=>{let o=n.replace(/[<>[\]]/g,"");r[o]=t[s]}),r}function Da(e,t){return e.map(r=>typeof r=="function"?r(t):r)}function En(e,t,r){let n=t.split("."),s=e;for(;n.length>1;){let o=n.shift();o in s||(s[o]={}),s=s[o]}s[n[0]]=r}var wa=require("execa");function Rr(e){try{return(0,wa.execaSync)(e,["--version"]),!0}catch{return!1}}var Ye=require("node:path"),qc=require("fs-extra");var Ea=b(require("node:process"),1);var ba=b(require("node:process"),1);var va=require("node:url"),xa=b(require("node:fs"),1),De=b(require("node:path"),1),Ca=e=>e instanceof URL?(0,va.fileURLToPath)(e):e;function ka(e,{cwd:t=ba.default.cwd(),type:r="file",stopAt:n}={}){let s=De.default.resolve(Ca(t)??""),{root:o}=De.default.parse(s);n=De.default.resolve(s,Ca(n)??o);let i=De.default.isAbsolute(e);for(;s;){let a=i?e:De.default.join(s,e);try{let c=xa.default.statSync(a,{throwIfNoEntry:!1});if(r==="file"&&c?.isFile()||r==="directory"&&c?.isDirectory())return a}catch{}if(s===n||s===o)break;s=De.default.dirname(s)}}function Sa({cwd:e=Ea.default.cwd()}={}){return ka("package.json",{cwd:e})}var so=(e,t,r)=>{let n=e instanceof RegExp?Fa(e,r):e,s=t instanceof RegExp?Fa(t,r):t,o=n!==null&&s!=null&&eh(n,s,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+s.length)}},Fa=(e,t)=>{let r=t.match(e);return r?r[0]:null},eh=(e,t,r)=>{let n,s,o,i,a,c=r.indexOf(e),u=r.indexOf(t,c+1),l=c;if(c>=0&&u>0){if(e===t)return[c,u];for(n=[],o=r.length;l>=0&&!a;){if(l===c)n.push(l),c=r.indexOf(e,l+1);else if(n.length===1){let p=n.pop();p!==void 0&&(a=[p,u])}else s=n.pop(),s!==void 0&&s<o&&(o=s,i=u),u=r.indexOf(t,l+1);l=c<u&&c>=0?c:u}n.length&&i!==void 0&&(a=[o,i])}return a};var Ta="\0SLASH"+Math.random()+"\0",Aa="\0OPEN"+Math.random()+"\0",io="\0CLOSE"+Math.random()+"\0",Pa="\0COMMA"+Math.random()+"\0",Ra="\0PERIOD"+Math.random()+"\0",rh=new RegExp(Ta,"g"),nh=new RegExp(Aa,"g"),sh=new RegExp(io,"g"),oh=new RegExp(Pa,"g"),ih=new RegExp(Ra,"g"),ah=/\\\\/g,ch=/\\{/g,uh=/\\}/g,lh=/\\,/g,ph=/\\./g;function oo(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function fh(e){return e.replace(ah,Ta).replace(ch,Aa).replace(uh,io).replace(lh,Pa).replace(ph,Ra)}function dh(e){return e.replace(rh,"\\").replace(nh,"{").replace(sh,"}").replace(oh,",").replace(ih,".")}function Ia(e){if(!e)return[""];let t=[],r=so("{","}",e);if(!r)return e.split(",");let{pre:n,body:s,post:o}=r,i=n.split(",");i[i.length-1]+="{"+s+"}";let a=Ia(o);return o.length&&(i[i.length-1]+=a.shift(),i.push.apply(i,a)),t.push.apply(t,i),t}function Na(e){return e?(e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),Ir(fh(e),!0).map(dh)):[]}function hh(e){return"{"+e+"}"}function mh(e){return/^-?0\d/.test(e)}function gh(e,t){return e<=t}function Dh(e,t){return e>=t}function Ir(e,t){let r=[],n=so("{","}",e);if(!n)return[e];let s=n.pre,o=n.post.length?Ir(n.post,!1):[""];if(/\$$/.test(n.pre))for(let i=0;i<o.length;i++){let a=s+"{"+n.body+"}"+o[i];r.push(a)}else{let i=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),c=i||a,u=n.body.indexOf(",")>=0;if(!c&&!u)return n.post.match(/,(?!,).*\}/)?(e=n.pre+"{"+n.body+io+n.post,Ir(e)):[e];let l;if(c)l=n.body.split(/\.\./);else if(l=Ia(n.body),l.length===1&&l[0]!==void 0&&(l=Ir(l[0],!1).map(hh),l.length===1))return o.map(d=>n.pre+l[0]+d);let p;if(c&&l[0]!==void 0&&l[1]!==void 0){let d=oo(l[0]),f=oo(l[1]),m=Math.max(l[0].length,l[1].length),h=l.length===3&&l[2]!==void 0?Math.abs(oo(l[2])):1,D=gh;f<d&&(h*=-1,D=Dh);let y=l.some(mh);p=[];for(let v=d;D(v,f);v+=h){let C;if(a)C=String.fromCharCode(v),C==="\\"&&(C="");else if(C=String(v),y){let A=m-C.length;if(A>0){let lt=new Array(A+1).join("0");v<0?C="-"+lt+C.slice(1):C=lt+C}}p.push(C)}}else{p=[];for(let d=0;d<l.length;d++)p.push.apply(p,Ir(l[d],!1))}for(let d=0;d<p.length;d++)for(let f=0;f<o.length;f++){let m=s+p[d]+o[f];(!t||c||m)&&r.push(m)}}return r}var Nr=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var yh={"[: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]},Or=e=>e.replace(/[[\]\\-]/g,"\\$&"),wh=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Oa=e=>e.join(""),Ma=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],s=[],o=r+1,i=!1,a=!1,c=!1,u=!1,l=r,p="";t:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){u=!0,o++;continue}if(h==="]"&&i&&!c){l=o+1;break}if(i=!0,h==="\\"&&!c){c=!0,o++;continue}if(h==="["&&!c){for(let[D,[g,y,v]]of Object.entries(yh))if(e.startsWith(D,o)){if(p)return["$.",!1,e.length-r,!0];o+=D.length,v?s.push(g):n.push(g),a=a||y;continue t}}if(c=!1,p){h>p?n.push(Or(p)+"-"+Or(h)):h===p&&n.push(Or(h)),p="",o++;continue}if(e.startsWith("-]",o+1)){n.push(Or(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){p=h,o+=2;continue}n.push(Or(h)),o++}if(l<o)return["",!1,0,!1];if(!n.length&&!s.length)return["$.",!1,e.length-r,!0];if(s.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let h=n[0].length===2?n[0].slice(-1):n[0];return[wh(h),!1,l-r,!1]}let d="["+(u?"^":"")+Oa(n)+"]",f="["+(u?"":"^")+Oa(s)+"]";return[n.length&&s.length?"("+d+"|"+f+")":n.length?d:f,a,l-r,!0]};var Dt=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var Ch=new Set(["!","?","+","*","@"]),$a=e=>Ch.has(e),bh="(?!(?:^|/)\\.\\.?(?:$|/))",Sn="(?!\\.)",vh=new Set(["[","."]),xh=new Set(["..","."]),kh=new Set("().*{}+?[]^$\\!"),Eh=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ao="[^/]",Ba=ao+"*?",ja=ao+"+?",Oe=class e{type;#t;#r;#o=!1;#s=[];#i;#C;#D;#l=!1;#a;#f;#p=!1;constructor(t,r,n={}){this.type=t,t&&(this.#r=!0),this.#i=r,this.#t=this.#i?this.#i.#t:this,this.#a=this.#t===this?n:this.#t.#a,this.#D=this.#t===this?[]:this.#t.#D,t==="!"&&!this.#t.#l&&this.#D.push(this),this.#C=this.#i?this.#i.#s.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#s)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#f!==void 0?this.#f:this.type?this.#f=this.type+"("+this.#s.map(t=>String(t)).join("|")+")":this.#f=this.#s.map(t=>String(t)).join("")}#c(){if(this!==this.#t)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let t;for(;t=this.#D.pop();){if(t.type!=="!")continue;let r=t,n=r.#i;for(;n;){for(let s=r.#C+1;!n.type&&s<n.#s.length;s++)for(let o of t.#s){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#s[s])}r=n,n=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof e&&r.#i===this))throw new Error("invalid part: "+r);this.#s.push(r)}}toJSON(){let t=this.type===null?this.#s.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#s.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#l&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#i?.isStart())return!1;if(this.#C===0)return!0;let t=this.#i;for(let r=0;r<this.#C;r++){let n=t.#s[r];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#s.length:0;return this.#C===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new e(this.type,t);for(let n of this.#s)r.copyIn(n);return r}static#n(t,r,n,s){let o=!1,i=!1,a=-1,c=!1;if(r.type===null){let f=n,m="";for(;f<t.length;){let h=t.charAt(f++);if(o||h==="\\"){o=!o,m+=h;continue}if(i){f===a+1?(h==="^"||h==="!")&&(c=!0):h==="]"&&!(f===a+2&&c)&&(i=!1),m+=h;continue}else if(h==="["){i=!0,a=f,c=!1,m+=h;continue}if(!s.noext&&$a(h)&&t.charAt(f)==="("){r.push(m),m="";let D=new e(h,r);f=e.#n(t,D,f,s),r.push(D);continue}m+=h}return r.push(m),f}let u=n+1,l=new e(null,r),p=[],d="";for(;u<t.length;){let f=t.charAt(u++);if(o||f==="\\"){o=!o,d+=f;continue}if(i){u===a+1?(f==="^"||f==="!")&&(c=!0):f==="]"&&!(u===a+2&&c)&&(i=!1),d+=f;continue}else if(f==="["){i=!0,a=u,c=!1,d+=f;continue}if($a(f)&&t.charAt(u)==="("){l.push(d),d="";let m=new e(f,l);l.push(m),u=e.#n(t,m,u,s);continue}if(f==="|"){l.push(d),d="",p.push(l),l=new e(null,r);continue}if(f===")")return d===""&&r.#s.length===0&&(r.#p=!0),l.push(d),d="",r.push(...p,l),u;d+=f}return r.type=null,r.#r=void 0,r.#s=[t.substring(n-1)],u}static fromGlob(t,r={}){let n=new e(null,void 0,r);return e.#n(t,n,0,r),n}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[r,n,s,o]=this.toRegExpSource();if(!(s||this.#r||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#t===this&&this.#c(),!this.type){let c=this.isStart()&&this.isEnd()&&!this.#s.some(f=>typeof f!="string"),u=this.#s.map(f=>{let[m,h,D,g]=typeof f=="string"?e.#b(f,this.#r,c):f.toRegExpSource(t);return this.#r=this.#r||D,this.#o=this.#o||g,m}).join(""),l="";if(this.isStart()&&typeof this.#s[0]=="string"&&!(this.#s.length===1&&xh.has(this.#s[0]))){let m=vh,h=r&&m.has(u.charAt(0))||u.startsWith("\\.")&&m.has(u.charAt(2))||u.startsWith("\\.\\.")&&m.has(u.charAt(4)),D=!r&&!t&&m.has(u.charAt(0));l=h?bh:D?Sn:""}let p="";return this.isEnd()&&this.#t.#l&&this.#i?.type==="!"&&(p="(?:$|\\/)"),[l+u+p,Dt(u),this.#r=!!this.#r,this.#o]}let n=this.type==="*"||this.type==="+",s=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#d(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let c=this.toString();return this.#s=[c],this.type=null,this.#r=void 0,[c,Dt(this.toString()),!1,!1]}let i=!n||t||r||!Sn?"":this.#d(!0);i===o&&(i=""),i&&(o=`(?:${o})(?:${i})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?Sn:"")+ja;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!t?Sn:"")+Ba+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&i?")":this.type==="*"&&i?")?":`)${this.type}`;a=s+o+c}return[a,Dt(o),this.#r=!!this.#r,this.#o]}#d(t){return this.#s.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,s,o,i]=r.toRegExpSource(t);return this.#o=this.#o||i,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#b(t,r,n=!1){let s=!1,o="",i=!1;for(let a=0;a<t.length;a++){let c=t.charAt(a);if(s){s=!1,o+=(kh.has(c)?"\\":"")+c;continue}if(c==="\\"){a===t.length-1?o+="\\\\":s=!0;continue}if(c==="["){let[u,l,p,d]=Ma(t,a);if(p){o+=u,i=i||l,a+=p-1,r=r||d;continue}}if(c==="*"){o+=n&&t==="*"?ja:Ba,r=!0;continue}if(c==="?"){o+=ao,r=!0;continue}o+=Eh(c)}return[o,Dt(t),!!r,i]}};var Me=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var q=(e,t,r={})=>(Nr(t),!r.nocomment&&t.charAt(0)==="#"?!1:new ot(t,r).match(e)),Sh=/^\*+([^+@!?\*\[\(]*)$/,Fh=e=>t=>!t.startsWith(".")&&t.endsWith(e),Th=e=>t=>t.endsWith(e),Ah=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Ph=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Rh=/^\*+\.\*+$/,Ih=e=>!e.startsWith(".")&&e.includes("."),Nh=e=>e!=="."&&e!==".."&&e.includes("."),Oh=/^\.\*+$/,Mh=e=>e!=="."&&e!==".."&&e.startsWith("."),$h=/^\*+$/,Bh=e=>e.length!==0&&!e.startsWith("."),jh=e=>e.length!==0&&e!=="."&&e!=="..",_h=/^\?+([^+@!?\*\[\(]*)?$/,Lh=([e,t=""])=>{let r=Wa([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Wh=([e,t=""])=>{let r=Ga([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Gh=([e,t=""])=>{let r=Ga([e]);return t?n=>r(n)&&n.endsWith(t):r},Hh=([e,t=""])=>{let r=Wa([e]);return t?n=>r(n)&&n.endsWith(t):r},Wa=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},Ga=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},Ha=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",_a={win32:{sep:"\\"},posix:{sep:"/"}},Uh=Ha==="win32"?_a.win32.sep:_a.posix.sep;q.sep=Uh;var H=Symbol("globstar **");q.GLOBSTAR=H;var zh="[^/]",Kh=zh+"*?",Jh="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Vh="(?:(?!(?:\\/|^)\\.).)*?",qh=(e,t={})=>r=>q(r,e,t);q.filter=qh;var ft=(e,t={})=>Object.assign({},e,t),Yh=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return q;let t=q;return Object.assign((n,s,o={})=>t(n,s,ft(e,o)),{Minimatch:class extends t.Minimatch{constructor(s,o={}){super(s,ft(e,o))}static defaults(s){return t.defaults(ft(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,o,i={}){super(s,o,ft(e,i))}static fromGlob(s,o={}){return t.AST.fromGlob(s,ft(e,o))}},unescape:(n,s={})=>t.unescape(n,ft(e,s)),escape:(n,s={})=>t.escape(n,ft(e,s)),filter:(n,s={})=>t.filter(n,ft(e,s)),defaults:n=>t.defaults(ft(e,n)),makeRe:(n,s={})=>t.makeRe(n,ft(e,s)),braceExpand:(n,s={})=>t.braceExpand(n,ft(e,s)),match:(n,s,o={})=>t.match(n,s,ft(e,o)),sep:t.sep,GLOBSTAR:H})};q.defaults=Yh;var Ua=(e,t={})=>(Nr(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Na(e));q.braceExpand=Ua;var Zh=(e,t={})=>new ot(e,t).makeRe();q.makeRe=Zh;var Xh=(e,t,r={})=>{let n=new ot(t,r);return e=e.filter(s=>n.match(s)),n.options.nonull&&!e.length&&e.push(t),e};q.match=Xh;var La=/[?*]|[+@!]\(.*?\)|\[|\]/,Qh=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ot=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,r={}){Nr(t),r=r||{},this.options=r,this.pattern=t,this.platform=r.platform||Ha,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.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 t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let s=this.globParts.map((o,i,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=o[0]===""&&o[1]===""&&(o[2]==="?"||!La.test(o[2]))&&!La.test(o[3]),u=/^[a-z]:/i.test(o[0]);if(c)return[...o.slice(0,4),...o.slice(4).map(l=>this.parse(l))];if(u)return[o[0],...o.slice(1).map(l=>this.parse(l))]}return o.map(c=>this.parse(c))});if(this.debug(this.pattern,s),this.set=s.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let i=this.set[o];i[0]===""&&i[1]===""&&this.globParts[o][2]==="?"&&typeof i[3]=="string"&&/^[a-z]:$/i.test(i[3])&&(i[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n=0;n<t.length;n++)for(let s=0;s<t[n].length;s++)t[n][s]==="**"&&(t[n][s]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let s=n;for(;r[s+1]==="**";)s++;s!==n&&r.splice(n,s-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,s)=>{let o=n[n.length-1];return s==="**"&&o==="**"?n:s===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(s),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let s=1;s<t.length-1;s++){let o=t[s];s===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(s,1),s--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let s=t[n-1];s&&s!=="."&&s!==".."&&s!=="**"&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let s=-1;for(;(s=n.indexOf("**",s+1))!==-1;){let i=s;for(;n[i+1]==="**";)i++;i>s&&n.splice(s+1,i-s);let a=n[s+1],c=n[s+2],u=n[s+3];if(a!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;r=!0,n.splice(s,1);let l=n.slice(0);l[s]="**",t.push(l),s--}if(!this.preserveMultipleSlashes){for(let i=1;i<n.length-1;i++){let a=n[i];i===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(i,1),i--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let i=n[o-1];if(i&&i!=="."&&i!==".."&&i!=="**"){r=!0;let c=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...c),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let s=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(s){t[r]=[],t[n]=s;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let s=0,o=0,i=[],a="";for(;s<t.length&&o<r.length;)if(t[s]===r[o])i.push(a==="b"?r[o]:t[s]),s++,o++;else if(n&&t[s]==="**"&&r[o]===t[s+1])i.push(t[s]),s++;else if(n&&r[o]==="**"&&t[s]===r[o+1])i.push(r[o]),o++;else if(t[s]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",i.push(t[s]),s++,o++}else if(r[o]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(a==="a")return!1;a="b",i.push(r[o]),s++,o++}else return!1;return t.length===r.length&&i}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let s=0;s<t.length&&t.charAt(s)==="!";s++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let s=this.options;if(this.isWindows){let h=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),D=!h&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),g=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),y=!g&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),v=D?3:h?0:void 0,C=y?3:g?0:void 0;if(typeof v=="number"&&typeof C=="number"){let[A,lt]=[t[v],r[C]];A.toLowerCase()===lt.toLowerCase()&&(r[C]=A,C>v?r=r.slice(C):v>C&&(t=t.slice(v)))}}let{optimizationLevel:o=1}=this.options;o>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:r}),this.debug("matchOne",t.length,r.length);for(var i=0,a=0,c=t.length,u=r.length;i<c&&a<u;i++,a++){this.debug("matchOne loop");var l=r[a],p=t[i];if(this.debug(r,l,p),l===!1)return!1;if(l===H){this.debug("GLOBSTAR",[r,l,p]);var d=i,f=a+1;if(f===u){for(this.debug("** at the end");i<c;i++)if(t[i]==="."||t[i]===".."||!s.dot&&t[i].charAt(0)===".")return!1;return!0}for(;d<c;){var m=t[d];if(this.debug(`
15
15
  globstar while`,t,d,r,f,m),this.matchOne(t.slice(d),r.slice(f),n))return this.debug("globstar found match!",d,c,m),!0;if(m==="."||m===".."||!s.dot&&m.charAt(0)==="."){this.debug("dot detected!",t,d,r,f);break}this.debug("globstar swallow a segment, and continue"),d++}return!!(n&&(this.debug(`
16
- >>> no match, partial?`,t,d,r,f),d===c))}let h;if(typeof l=="string"?(h=p===l,this.debug("string match",l,p,h)):(h=l.test(p),this.debug("pattern match",l,p,h)),!h)return!1}if(i===c&&a===u)return!0;if(i===c)return n;if(a===u)return i===c-1&&t[i]==="";throw new Error("wtf?")}braceExpand(){return La(this.pattern,this.options)}parse(t){Pr(t);let r=this.options;if(t==="**")return H;if(t==="")return"";let n,s=null;(n=t.match(Mh))?s=r.dot?Bh:$h:(n=t.match(Eh))?s=(r.nocase?r.dot?Ah:Th:r.dot?Fh:Sh)(n[1]):(n=t.match(jh))?s=(r.nocase?r.dot?Lh:_h:r.dot?Wh:Gh)(n):(n=t.match(Ph))?s=r.dot?Ih:Rh:(n=t.match(Nh))&&(s=Oh);let o=Ne.fromGlob(t,this.options).toMMPattern();return s&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:s}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?zh:r.dot?Kh:Jh,s=new Set(r.nocase?["i"]:[]),o=t.map(c=>{let u=c.map(p=>{if(p instanceof RegExp)for(let d of p.flags.split(""))s.add(d);return typeof p=="string"?Xh(p):p===H?H:p._src});u.forEach((p,d)=>{let f=u[d+1],m=u[d-1];p!==H||m===H||(m===void 0?f!==void 0&&f!==H?u[d+1]="(?:\\/|"+n+"\\/)?"+f:u[d]=n:f===void 0?u[d-1]=m+"(?:\\/|\\/"+n+")?":f!==H&&(u[d-1]=m+"(?:\\/|\\/"+n+"\\/)"+f,u[d+1]=H))});let l=u.filter(p=>p!==H);if(this.partial&&l.length>=1){let p=[];for(let d=1;d<=l.length;d++)p.push(l.slice(0,d).join("/"));return"(?:"+p.join("|")+")"}return l.join("/")}).join("|"),[i,a]=t.length>1?["(?:",")"]:["",""];o="^"+i+o+a+"$",this.partial&&(o="^(?:\\/|"+i+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...s].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let s=this.slashSplit(t);this.debug(this.pattern,"split",s);let o=this.set;this.debug(this.pattern,"set",o);let i=s[s.length-1];if(!i)for(let a=s.length-2;!i&&a>=0;a--)i=s[a];for(let a=0;a<o.length;a++){let c=o[a],u=s;if(n.matchBase&&c.length===1&&(u=[i]),this.matchOne(u,c,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return q.defaults(t).Minimatch}};q.AST=Ne;q.Minimatch=ot;q.escape=Oe;q.unescape=Dt;var lc=require("node:url");var Qh=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ga=new Set,no=typeof process=="object"&&process?process:{},Ha=(e,t,r,n)=>{typeof no.emitWarning=="function"?no.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)},vn=globalThis.AbortController,Wa=globalThis.AbortSignal;if(typeof vn>"u"){Wa=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(n,s){this._onabort.push(s)}},vn=class{constructor(){t()}signal=new Wa;abort(n){if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(let s of this.signal._onabort)s(n);this.signal.onabort?.(n)}}};let e=no.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,Ha("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var tm=e=>!Ga.has(e),Ob=Symbol("type"),se=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Ua=e=>se(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Me:null:null,Me=class extends Array{constructor(t){super(t),this.fill(0)}},so=class e{heap;length;static#t=!1;static create(t){let r=Ua(t);if(!r)return[];e.#t=!0;let n=new e(t,r);return e.#t=!1,n}constructor(t,r){if(!e.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},De=class e{#t;#r;#o;#s;#i;#C;#D;#l;get perf(){return this.#l}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#f;#p;#c;#n;#d;#b;#w;#h;#T;#m;#k;#E;#g;#y;#v;#S;#e;#O;static unsafeExposeInternals(t){return{starts:t.#E,ttls:t.#g,autopurgeTimers:t.#y,sizes:t.#k,keyMap:t.#p,keyList:t.#c,valList:t.#n,next:t.#d,prev:t.#b,get head(){return t.#w},get tail(){return t.#h},free:t.#T,isBackgroundFetch:r=>t.#u(r),backgroundFetch:(r,n,s,o)=>t.#G(r,n,s,o),moveToTail:r=>t.#$(r),indexes:r=>t.#P(r),rindexes:r=>t.#R(r),isStale:r=>t.#x(r)}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#f}get size(){return this.#a}get fetchMethod(){return this.#C}get memoMethod(){return this.#D}get dispose(){return this.#o}get onInsert(){return this.#s}get disposeAfter(){return this.#i}constructor(t){let{max:r=0,ttl:n,ttlResolution:s=1,ttlAutopurge:o,updateAgeOnGet:i,updateAgeOnHas:a,allowStale:c,dispose:u,onInsert:l,disposeAfter:p,noDisposeOnSet:d,noUpdateTTL:f,maxSize:m=0,maxEntrySize:h=0,sizeCalculation:D,fetchMethod:g,memoMethod:y,noDeleteOnFetchRejection:v,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:lt,ignoreFetchAbort:ee,perf:Se}=t;if(Se!==void 0&&typeof Se?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#l=Se??Qh,r!==0&&!se(r))throw new TypeError("max option must be a nonnegative integer");let Fe=r?Ua(r):Array;if(!Fe)throw new Error("invalid max value: "+r);if(this.#t=r,this.#r=m,this.maxEntrySize=h||this.#r,this.sizeCalculation=D,this.sizeCalculation){if(!this.#r&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(y!==void 0&&typeof y!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#D=y,g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#C=g,this.#S=!!g,this.#p=new Map,this.#c=new Array(r).fill(void 0),this.#n=new Array(r).fill(void 0),this.#d=new Fe(r),this.#b=new Fe(r),this.#w=0,this.#h=0,this.#T=so.create(r),this.#a=0,this.#f=0,typeof u=="function"&&(this.#o=u),typeof l=="function"&&(this.#s=l),typeof p=="function"?(this.#i=p,this.#m=[]):(this.#i=void 0,this.#m=void 0),this.#v=!!this.#o,this.#O=!!this.#s,this.#e=!!this.#i,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!f,this.noDeleteOnFetchRejection=!!v,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!lt,this.ignoreFetchAbort=!!ee,this.maxEntrySize!==0){if(this.#r!==0&&!se(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!se(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#U()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!a,this.ttlResolution=se(s)||s===0?s:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!se(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#I()}if(this.#t===0&&this.ttl===0&&this.#r===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){let Te="LRU_CACHE_UNBOUNDED";tm(Te)&&(Ga.add(Te),Ha("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Te,e))}}getRemainingTTL(t){return this.#p.has(t)?1/0:0}#I(){let t=new Me(this.#t),r=new Me(this.#t);this.#g=t,this.#E=r;let n=this.ttlAutopurge?new Array(this.#t):void 0;this.#y=n,this.#j=(i,a,c=this.#l.now())=>{if(r[i]=a!==0?c:0,t[i]=a,n?.[i]&&(clearTimeout(n[i]),n[i]=void 0),a!==0&&n){let u=setTimeout(()=>{this.#x(i)&&this.#A(this.#c[i],"expire")},a+1);u.unref&&u.unref(),n[i]=u}},this.#F=i=>{r[i]=t[i]!==0?this.#l.now():0},this.#N=(i,a)=>{if(t[a]){let c=t[a],u=r[a];if(!c||!u)return;i.ttl=c,i.start=u,i.now=s||o();let l=i.now-u;i.remainingTTL=c-l}};let s=0,o=()=>{let i=this.#l.now();if(this.ttlResolution>0){s=i;let a=setTimeout(()=>s=0,this.ttlResolution);a.unref&&a.unref()}return i};this.getRemainingTTL=i=>{let a=this.#p.get(i);if(a===void 0)return 0;let c=t[a],u=r[a];if(!c||!u)return 1/0;let l=(s||o())-u;return c-l},this.#x=i=>{let a=r[i],c=t[i];return!!c&&!!a&&(s||o())-a>c}}#F=()=>{};#N=()=>{};#j=()=>{};#x=()=>!1;#U(){let t=new Me(this.#t);this.#f=0,this.#k=t,this.#B=r=>{this.#f-=t[r],t[r]=0},this.#_=(r,n,s,o)=>{if(this.#u(n))return 0;if(!se(s))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(s=o(n,r),!se(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s},this.#M=(r,n,s)=>{if(t[r]=n,this.#r){let o=this.#r-t[r];for(;this.#f>o;)this.#W(!0)}this.#f+=t[r],s&&(s.entrySize=n,s.totalCalculatedSize=this.#f)}}#B=t=>{};#M=(t,r,n)=>{};#_=(t,r,n,s)=>{if(n||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#P({allowStale:t=this.allowStale}={}){if(this.#a)for(let r=this.#h;!(!this.#L(r)||((t||!this.#x(r))&&(yield r),r===this.#w));)r=this.#b[r]}*#R({allowStale:t=this.allowStale}={}){if(this.#a)for(let r=this.#w;!(!this.#L(r)||((t||!this.#x(r))&&(yield r),r===this.#h));)r=this.#d[r]}#L(t){return t!==void 0&&this.#p.get(this.#c[t])===t}*entries(){for(let t of this.#P())this.#n[t]!==void 0&&this.#c[t]!==void 0&&!this.#u(this.#n[t])&&(yield[this.#c[t],this.#n[t]])}*rentries(){for(let t of this.#R())this.#n[t]!==void 0&&this.#c[t]!==void 0&&!this.#u(this.#n[t])&&(yield[this.#c[t],this.#n[t]])}*keys(){for(let t of this.#P()){let r=this.#c[t];r!==void 0&&!this.#u(this.#n[t])&&(yield r)}}*rkeys(){for(let t of this.#R()){let r=this.#c[t];r!==void 0&&!this.#u(this.#n[t])&&(yield r)}}*values(){for(let t of this.#P())this.#n[t]!==void 0&&!this.#u(this.#n[t])&&(yield this.#n[t])}*rvalues(){for(let t of this.#R())this.#n[t]!==void 0&&!this.#u(this.#n[t])&&(yield this.#n[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,r={}){for(let n of this.#P()){let s=this.#n[n],o=this.#u(s)?s.__staleWhileFetching:s;if(o!==void 0&&t(o,this.#c[n],this))return this.get(this.#c[n],r)}}forEach(t,r=this){for(let n of this.#P()){let s=this.#n[n],o=this.#u(s)?s.__staleWhileFetching:s;o!==void 0&&t.call(r,o,this.#c[n],this)}}rforEach(t,r=this){for(let n of this.#R()){let s=this.#n[n],o=this.#u(s)?s.__staleWhileFetching:s;o!==void 0&&t.call(r,o,this.#c[n],this)}}purgeStale(){let t=!1;for(let r of this.#R({allowStale:!0}))this.#x(r)&&(this.#A(this.#c[r],"expire"),t=!0);return t}info(t){let r=this.#p.get(t);if(r===void 0)return;let n=this.#n[r],s=this.#u(n)?n.__staleWhileFetching:n;if(s===void 0)return;let o={value:s};if(this.#g&&this.#E){let i=this.#g[r],a=this.#E[r];if(i&&a){let c=i-(this.#l.now()-a);o.ttl=c,o.start=Date.now()}}return this.#k&&(o.size=this.#k[r]),o}dump(){let t=[];for(let r of this.#P({allowStale:!0})){let n=this.#c[r],s=this.#n[r],o=this.#u(s)?s.__staleWhileFetching:s;if(o===void 0||n===void 0)continue;let i={value:o};if(this.#g&&this.#E){i.ttl=this.#g[r];let a=this.#l.now()-this.#E[r];i.start=Math.floor(Date.now()-a)}this.#k&&(i.size=this.#k[r]),t.unshift([n,i])}return t}load(t){this.clear();for(let[r,n]of t){if(n.start){let s=Date.now()-n.start;n.start=this.#l.now()-s}this.set(r,n.value,n)}}set(t,r,n={}){if(r===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:o,noDisposeOnSet:i=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=n,{noUpdateTTL:u=this.noUpdateTTL}=n,l=this.#_(t,r,n.size||0,a);if(this.maxEntrySize&&l>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#A(t,"set"),this;let p=this.#a===0?void 0:this.#p.get(t);if(p===void 0)p=this.#a===0?this.#h:this.#T.length!==0?this.#T.pop():this.#a===this.#t?this.#W(!1):this.#a,this.#c[p]=t,this.#n[p]=r,this.#p.set(t,p),this.#d[this.#h]=p,this.#b[p]=this.#h,this.#h=p,this.#a++,this.#M(p,l,c),c&&(c.set="add"),u=!1,this.#O&&this.#s?.(r,t,"add");else{this.#$(p);let d=this.#n[p];if(r!==d){if(this.#S&&this.#u(d)){d.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:f}=d;f!==void 0&&!i&&(this.#v&&this.#o?.(f,t,"set"),this.#e&&this.#m?.push([f,t,"set"]))}else i||(this.#v&&this.#o?.(d,t,"set"),this.#e&&this.#m?.push([d,t,"set"]));if(this.#B(p),this.#M(p,l,c),this.#n[p]=r,c){c.set="replace";let f=d&&this.#u(d)?d.__staleWhileFetching:d;f!==void 0&&(c.oldValue=f)}}else c&&(c.set="update");this.#O&&this.onInsert?.(r,t,r===d?"update":"replace")}if(s!==0&&!this.#g&&this.#I(),this.#g&&(u||this.#j(p,s,o),c&&this.#N(c,p)),!i&&this.#e&&this.#m){let d=this.#m,f;for(;f=d?.shift();)this.#i?.(...f)}return this}pop(){try{for(;this.#a;){let t=this.#n[this.#w];if(this.#W(!0),this.#u(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#e&&this.#m){let t=this.#m,r;for(;r=t?.shift();)this.#i?.(...r)}}}#W(t){let r=this.#w,n=this.#c[r],s=this.#n[r];return this.#S&&this.#u(s)?s.__abortController.abort(new Error("evicted")):(this.#v||this.#e)&&(this.#v&&this.#o?.(s,n,"evict"),this.#e&&this.#m?.push([s,n,"evict"])),this.#B(r),this.#y?.[r]&&(clearTimeout(this.#y[r]),this.#y[r]=void 0),t&&(this.#c[r]=void 0,this.#n[r]=void 0,this.#T.push(r)),this.#a===1?(this.#w=this.#h=0,this.#T.length=0):this.#w=this.#d[r],this.#p.delete(n),this.#a--,r}has(t,r={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:s}=r,o=this.#p.get(t);if(o!==void 0){let i=this.#n[o];if(this.#u(i)&&i.__staleWhileFetching===void 0)return!1;if(this.#x(o))s&&(s.has="stale",this.#N(s,o));else return n&&this.#F(o),s&&(s.has="hit",this.#N(s,o)),!0}else s&&(s.has="miss");return!1}peek(t,r={}){let{allowStale:n=this.allowStale}=r,s=this.#p.get(t);if(s===void 0||!n&&this.#x(s))return;let o=this.#n[s];return this.#u(o)?o.__staleWhileFetching:o}#G(t,r,n,s){let o=r===void 0?void 0:this.#n[r];if(this.#u(o))return o;let i=new vn,{signal:a}=n;a?.addEventListener("abort",()=>i.abort(a.reason),{signal:i.signal});let c={signal:i.signal,options:n,context:s},u=(h,D=!1)=>{let{aborted:g}=i.signal,y=n.ignoreFetchAbort&&h!==void 0;if(n.status&&(g&&!D?(n.status.fetchAborted=!0,n.status.fetchError=i.signal.reason,y&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),g&&!y&&!D)return p(i.signal.reason);let v=f,C=this.#n[r];return(C===f||y&&D&&C===void 0)&&(h===void 0?v.__staleWhileFetching!==void 0?this.#n[r]=v.__staleWhileFetching:this.#A(t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,h,c.options))),h},l=h=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=h),p(h)),p=h=>{let{aborted:D}=i.signal,g=D&&n.allowStaleOnFetchAbort,y=g||n.allowStaleOnFetchRejection,v=y||n.noDeleteOnFetchRejection,C=f;if(this.#n[r]===f&&(!v||C.__staleWhileFetching===void 0?this.#A(t,"fetch"):g||(this.#n[r]=C.__staleWhileFetching)),y)return n.status&&C.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),C.__staleWhileFetching;if(C.__returned===C)throw h},d=(h,D)=>{let g=this.#C?.(t,o,c);g&&g instanceof Promise&&g.then(y=>h(y===void 0?void 0:y),D),i.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(h(void 0),n.allowStaleOnFetchAbort&&(h=y=>u(y,!0)))})};n.status&&(n.status.fetchDispatched=!0);let f=new Promise(d).then(u,l),m=Object.assign(f,{__abortController:i,__staleWhileFetching:o,__returned:void 0});return r===void 0?(this.set(t,m,{...c.options,status:void 0}),r=this.#p.get(t)):this.#n[r]=m,m}#u(t){if(!this.#S)return!1;let r=t;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof vn}async fetch(t,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:c=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:h,forceRefresh:D=!1,status:g,signal:y}=r;if(!this.#S)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:o,status:g});let v={allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:o,ttl:i,noDisposeOnSet:a,size:c,sizeCalculation:u,noUpdateTTL:l,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:m,ignoreFetchAbort:f,status:g,signal:y},C=this.#p.get(t);if(C===void 0){g&&(g.fetch="miss");let A=this.#G(t,C,v,h);return A.__returned=A}else{let A=this.#n[C];if(this.#u(A)){let Te=n&&A.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",Te&&(g.returnedStale=!0)),Te?A.__staleWhileFetching:A.__returned=A}let lt=this.#x(C);if(!D&&!lt)return g&&(g.fetch="hit"),this.#$(C),s&&this.#F(C),g&&this.#N(g,C),A;let ee=this.#G(t,C,v,h),Fe=ee.__staleWhileFetching!==void 0&&n;return g&&(g.fetch=lt?"stale":"refresh",Fe&&lt&&(g.returnedStale=!0)),Fe?ee.__staleWhileFetching:ee.__returned=ee}}async forceFetch(t,r={}){let n=await this.fetch(t,r);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(t,r={}){let n=this.#D;if(!n)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:o,...i}=r,a=this.get(t,i);if(!o&&a!==void 0)return a;let c=n(t,a,{options:i,context:s});return this.set(t,c,i),c}get(t,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:i}=r,a=this.#p.get(t);if(a!==void 0){let c=this.#n[a],u=this.#u(c);return i&&this.#N(i,a),this.#x(a)?(i&&(i.get="stale"),u?(i&&n&&c.__staleWhileFetching!==void 0&&(i.returnedStale=!0),n?c.__staleWhileFetching:void 0):(o||this.#A(t,"expire"),i&&n&&(i.returnedStale=!0),n?c:void 0)):(i&&(i.get="hit"),u?c.__staleWhileFetching:(this.#$(a),s&&this.#F(a),c))}else i&&(i.get="miss")}#H(t,r){this.#b[r]=t,this.#d[t]=r}#$(t){t!==this.#h&&(t===this.#w?this.#w=this.#d[t]:this.#H(this.#b[t],this.#d[t]),this.#H(this.#h,t),this.#h=t)}delete(t){return this.#A(t,"delete")}#A(t,r){let n=!1;if(this.#a!==0){let s=this.#p.get(t);if(s!==void 0)if(this.#y?.[s]&&(clearTimeout(this.#y?.[s]),this.#y[s]=void 0),n=!0,this.#a===1)this.#z(r);else{this.#B(s);let o=this.#n[s];if(this.#u(o)?o.__abortController.abort(new Error("deleted")):(this.#v||this.#e)&&(this.#v&&this.#o?.(o,t,r),this.#e&&this.#m?.push([o,t,r])),this.#p.delete(t),this.#c[s]=void 0,this.#n[s]=void 0,s===this.#h)this.#h=this.#b[s];else if(s===this.#w)this.#w=this.#d[s];else{let i=this.#b[s];this.#d[i]=this.#d[s];let a=this.#d[s];this.#b[a]=this.#b[s]}this.#a--,this.#T.push(s)}}if(this.#e&&this.#m?.length){let s=this.#m,o;for(;o=s?.shift();)this.#i?.(...o)}return n}clear(){return this.#z("delete")}#z(t){for(let r of this.#R({allowStale:!0})){let n=this.#n[r];if(this.#u(n))n.__abortController.abort(new Error("deleted"));else{let s=this.#c[r];this.#v&&this.#o?.(n,s,t),this.#e&&this.#m?.push([n,s,t])}}if(this.#p.clear(),this.#n.fill(void 0),this.#c.fill(void 0),this.#g&&this.#E){this.#g.fill(0),this.#E.fill(0);for(let r of this.#y??[])r!==void 0&&clearTimeout(r);this.#y?.fill(void 0)}if(this.#k&&this.#k.fill(0),this.#w=0,this.#h=0,this.#T.length=0,this.#f=0,this.#a=0,this.#e&&this.#m){let r=this.#m,n;for(;n=r?.shift();)this.#i?.(...n)}}};var je=require("node:path"),tc=require("node:url"),Nt=require("fs"),lm=b(require("node:fs"),1),ae=require("node:fs/promises");var An=require("node:events"),po=b(require("node:stream"),1),qa=require("node:string_decoder"),za=typeof process=="object"&&process?process:{stdout:null,stderr:null},em=e=>!!e&&typeof e=="object"&&(e instanceof ie||e instanceof po.default||rm(e)||nm(e)),rm=e=>!!e&&typeof e=="object"&&e instanceof An.EventEmitter&&typeof e.pipe=="function"&&e.pipe!==po.default.Writable.prototype.pipe,nm=e=>!!e&&typeof e=="object"&&e instanceof An.EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",zt=Symbol("EOF"),Kt=Symbol("maybeEmitEnd"),oe=Symbol("emittedEnd"),xn=Symbol("emittingEnd"),Ir=Symbol("emittedError"),kn=Symbol("closed"),Ka=Symbol("read"),En=Symbol("flush"),Ja=Symbol("flushChunk"),yt=Symbol("encoding"),$e=Symbol("decoder"),_=Symbol("flowing"),Nr=Symbol("paused"),Be=Symbol("resume"),L=Symbol("buffer"),Y=Symbol("pipes"),W=Symbol("bufferLength"),oo=Symbol("bufferPush"),Sn=Symbol("bufferShift"),U=Symbol("objectMode"),M=Symbol("destroyed"),io=Symbol("error"),ao=Symbol("emitData"),Va=Symbol("emitEnd"),co=Symbol("emitEnd2"),Rt=Symbol("async"),uo=Symbol("abort"),Fn=Symbol("aborted"),Or=Symbol("signal"),ye=Symbol("dataListeners"),it=Symbol("discarded"),Mr=e=>Promise.resolve().then(e),sm=e=>e(),om=e=>e==="end"||e==="finish"||e==="prefinish",im=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,am=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),Tn=class{src;dest;opts;ondrain;constructor(t,r,n){this.src=t,this.dest=r,this.opts=n,this.ondrain=()=>t[Be](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},lo=class extends Tn{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,r,n){super(t,r,n),this.proxyErrors=s=>r.emit("error",s),t.on("error",this.proxyErrors)}},cm=e=>!!e.objectMode,um=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",ie=class extends An.EventEmitter{[_]=!1;[Nr]=!1;[Y]=[];[L]=[];[U];[yt];[Rt];[$e];[zt]=!1;[oe]=!1;[xn]=!1;[kn]=!1;[Ir]=null;[W]=0;[M]=!1;[Or];[Fn]=!1;[ye]=0;[it]=!1;writable=!0;readable=!0;constructor(...t){let r=t[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");cm(r)?(this[U]=!0,this[yt]=null):um(r)?(this[yt]=r.encoding,this[U]=!1):(this[U]=!1,this[yt]=null),this[Rt]=!!r.async,this[$e]=this[yt]?new qa.StringDecoder(this[yt]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[L]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Y]});let{signal:n}=r;n&&(this[Or]=n,n.aborted?this[uo]():n.addEventListener("abort",()=>this[uo]()))}get bufferLength(){return this[W]}get encoding(){return this[yt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[U]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Rt]}set async(t){this[Rt]=this[Rt]||!!t}[uo](){this[Fn]=!0,this.emit("abort",this[Or]?.reason),this.destroy(this[Or]?.reason)}get aborted(){return this[Fn]}set aborted(t){}write(t,r,n){if(this[Fn])return!1;if(this[zt])throw new Error("write after end");if(this[M])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(n=r,r="utf8"),r||(r="utf8");let s=this[Rt]?Mr:sm;if(!this[U]&&!Buffer.isBuffer(t)){if(am(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(im(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[U]?(this[_]&&this[W]!==0&&this[En](!0),this[_]?this.emit("data",t):this[oo](t),this[W]!==0&&this.emit("readable"),n&&s(n),this[_]):t.length?(typeof t=="string"&&!(r===this[yt]&&!this[$e]?.lastNeed)&&(t=Buffer.from(t,r)),Buffer.isBuffer(t)&&this[yt]&&(t=this[$e].write(t)),this[_]&&this[W]!==0&&this[En](!0),this[_]?this.emit("data",t):this[oo](t),this[W]!==0&&this.emit("readable"),n&&s(n),this[_]):(this[W]!==0&&this.emit("readable"),n&&s(n),this[_])}read(t){if(this[M])return null;if(this[it]=!1,this[W]===0||t===0||t&&t>this[W])return this[Kt](),null;this[U]&&(t=null),this[L].length>1&&!this[U]&&(this[L]=[this[yt]?this[L].join(""):Buffer.concat(this[L],this[W])]);let r=this[Ka](t||null,this[L][0]);return this[Kt](),r}[Ka](t,r){if(this[U])this[Sn]();else{let n=r;t===n.length||t===null?this[Sn]():typeof n=="string"?(this[L][0]=n.slice(t),r=n.slice(0,t),this[W]-=t):(this[L][0]=n.subarray(t),r=n.subarray(0,t),this[W]-=t)}return this.emit("data",r),!this[L].length&&!this[zt]&&this.emit("drain"),r}end(t,r,n){return typeof t=="function"&&(n=t,t=void 0),typeof r=="function"&&(n=r,r="utf8"),t!==void 0&&this.write(t,r),n&&this.once("end",n),this[zt]=!0,this.writable=!1,(this[_]||!this[Nr])&&this[Kt](),this}[Be](){this[M]||(!this[ye]&&!this[Y].length&&(this[it]=!0),this[Nr]=!1,this[_]=!0,this.emit("resume"),this[L].length?this[En]():this[zt]?this[Kt]():this.emit("drain"))}resume(){return this[Be]()}pause(){this[_]=!1,this[Nr]=!0,this[it]=!1}get destroyed(){return this[M]}get flowing(){return this[_]}get paused(){return this[Nr]}[oo](t){this[U]?this[W]+=1:this[W]+=t.length,this[L].push(t)}[Sn](){return this[U]?this[W]-=1:this[W]-=this[L][0].length,this[L].shift()}[En](t=!1){do;while(this[Ja](this[Sn]())&&this[L].length);!t&&!this[L].length&&!this[zt]&&this.emit("drain")}[Ja](t){return this.emit("data",t),this[_]}pipe(t,r){if(this[M])return t;this[it]=!1;let n=this[oe];return r=r||{},t===za.stdout||t===za.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,n?r.end&&t.end():(this[Y].push(r.proxyErrors?new lo(this,t,r):new Tn(this,t,r)),this[Rt]?Mr(()=>this[Be]()):this[Be]()),t}unpipe(t){let r=this[Y].find(n=>n.dest===t);r&&(this[Y].length===1?(this[_]&&this[ye]===0&&(this[_]=!1),this[Y]=[]):this[Y].splice(this[Y].indexOf(r),1),r.unpipe())}addListener(t,r){return this.on(t,r)}on(t,r){let n=super.on(t,r);if(t==="data")this[it]=!1,this[ye]++,!this[Y].length&&!this[_]&&this[Be]();else if(t==="readable"&&this[W]!==0)super.emit("readable");else if(om(t)&&this[oe])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Ir]){let s=r;this[Rt]?Mr(()=>s.call(this,this[Ir])):s.call(this,this[Ir])}return n}removeListener(t,r){return this.off(t,r)}off(t,r){let n=super.off(t,r);return t==="data"&&(this[ye]=this.listeners("data").length,this[ye]===0&&!this[it]&&!this[Y].length&&(this[_]=!1)),n}removeAllListeners(t){let r=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[ye]=0,!this[it]&&!this[Y].length&&(this[_]=!1)),r}get emittedEnd(){return this[oe]}[Kt](){!this[xn]&&!this[oe]&&!this[M]&&this[L].length===0&&this[zt]&&(this[xn]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[kn]&&this.emit("close"),this[xn]=!1)}emit(t,...r){let n=r[0];if(t!=="error"&&t!=="close"&&t!==M&&this[M])return!1;if(t==="data")return!this[U]&&!n?!1:this[Rt]?(Mr(()=>this[ao](n)),!0):this[ao](n);if(t==="end")return this[Va]();if(t==="close"){if(this[kn]=!0,!this[oe]&&!this[M])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Ir]=n,super.emit(io,n);let o=!this[Or]||this.listeners("error").length?super.emit("error",n):!1;return this[Kt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Kt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let s=super.emit(t,...r);return this[Kt](),s}[ao](t){for(let n of this[Y])n.dest.write(t)===!1&&this.pause();let r=this[it]?!1:super.emit("data",t);return this[Kt](),r}[Va](){return this[oe]?!1:(this[oe]=!0,this.readable=!1,this[Rt]?(Mr(()=>this[co]()),!0):this[co]())}[co](){if(this[$e]){let r=this[$e].end();if(r){for(let n of this[Y])n.dest.write(r);this[it]||super.emit("data",r)}}for(let r of this[Y])r.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[U]||(t.dataLength=0);let r=this.promise();return this.on("data",n=>{t.push(n),this[U]||(t.dataLength+=n.length)}),await r,t}async concat(){if(this[U])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[yt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,r)=>{this.on(M,()=>r(new Error("stream destroyed"))),this.on("error",n=>r(n)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[it]=!1;let t=!1,r=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return r();let s=this.read();if(s!==null)return Promise.resolve({done:!1,value:s});if(this[zt])return r();let o,i,a=p=>{this.off("data",c),this.off("end",u),this.off(M,l),r(),i(p)},c=p=>{this.off("error",a),this.off("end",u),this.off(M,l),this.pause(),o({value:p,done:!!this[zt]})},u=()=>{this.off("error",a),this.off("data",c),this.off(M,l),r(),o({done:!0,value:void 0})},l=()=>a(new Error("stream destroyed"));return new Promise((p,d)=>{i=d,o=p,this.once(M,l),this.once("error",a),this.once("end",u),this.once("data",c)})},throw:r,return:r,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[it]=!1;let t=!1,r=()=>(this.pause(),this.off(io,r),this.off(M,r),this.off("end",r),t=!0,{done:!0,value:void 0}),n=()=>{if(t)return r();let s=this.read();return s===null?r():{done:!1,value:s}};return this.once("end",r),this.once(io,r),this.once(M,r),{next:n,throw:r,return:r,[Symbol.iterator](){return this}}}destroy(t){if(this[M])return t?this.emit("error",t):this.emit(M),this;this[M]=!0,this[it]=!0,this[L].length=0,this[W]=0;let r=this;return typeof r.close=="function"&&!this[kn]&&r.close(),t?this.emit("error",t):this.emit(M),this}static get isStream(){return em}};var pm=Nt.realpathSync.native,Br={lstatSync:Nt.lstatSync,readdir:Nt.readdir,readdirSync:Nt.readdirSync,readlinkSync:Nt.readlinkSync,realpathSync:pm,promises:{lstat:ae.lstat,readdir:ae.readdir,readlink:ae.readlink,realpath:ae.realpath}},ec=e=>!e||e===Br||e===lm?Br:{...Br,...e,promises:{...Br.promises,...e.promises||{}}},rc=/^\\\\\?\\([a-z]:)\\?$/i,fm=e=>e.replace(/\//g,"\\").replace(rc,"$1\\"),dm=/[\\\/]/,ht=0,nc=1,sc=2,It=4,oc=6,ic=8,we=10,ac=12,dt=15,$r=~dt,fo=16,Ya=32,jr=64,wt=128,Pn=256,In=512,Za=jr|wt|In,hm=1023,ho=e=>e.isFile()?ic:e.isDirectory()?It:e.isSymbolicLink()?we:e.isCharacterDevice()?sc:e.isBlockDevice()?oc:e.isSocket()?ac:e.isFIFO()?nc:ht,Xa=new De({max:2**12}),_r=e=>{let t=Xa.get(e);if(t)return t;let r=e.normalize("NFKD");return Xa.set(e,r),r},Qa=new De({max:2**12}),Rn=e=>{let t=Qa.get(e);if(t)return t;let r=_r(e.toLowerCase());return Qa.set(e,r),r},Nn=class extends De{constructor(){super({max:256})}},mo=class extends De{constructor(t=16*1024){super({maxSize:t,sizeCalculation:r=>r.length+1})}},cc=Symbol("PathScurry setAsCwd"),z=class{name;root;roots;parent;nocase;isCWD=!1;#t;#r;get dev(){return this.#r}#o;get mode(){return this.#o}#s;get nlink(){return this.#s}#i;get uid(){return this.#i}#C;get gid(){return this.#C}#D;get rdev(){return this.#D}#l;get blksize(){return this.#l}#a;get ino(){return this.#a}#f;get size(){return this.#f}#p;get blocks(){return this.#p}#c;get atimeMs(){return this.#c}#n;get mtimeMs(){return this.#n}#d;get ctimeMs(){return this.#d}#b;get birthtimeMs(){return this.#b}#w;get atime(){return this.#w}#h;get mtime(){return this.#h}#T;get ctime(){return this.#T}#m;get birthtime(){return this.#m}#k;#E;#g;#y;#v;#S;#e;#O;#I;#F;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,r=ht,n,s,o,i,a){this.name=t,this.#k=o?Rn(t):_r(t),this.#e=r&hm,this.nocase=o,this.roots=s,this.root=n||this,this.#O=i,this.#g=a.fullpath,this.#v=a.relative,this.#S=a.relativePosix,this.parent=a.parent,this.parent?this.#t=this.parent.#t:this.#t=ec(a.fs)}depth(){return this.#E!==void 0?this.#E:this.parent?this.#E=this.parent.depth()+1:this.#E=0}childrenCache(){return this.#O}resolve(t){if(!t)return this;let r=this.getRootString(t),s=t.substring(r.length).split(this.splitSep);return r?this.getRoot(r).#N(s):this.#N(s)}#N(t){let r=this;for(let n of t)r=r.child(n);return r}children(){let t=this.#O.get(this);if(t)return t;let r=Object.assign([],{provisional:0});return this.#O.set(this,r),this.#e&=~fo,r}child(t,r){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let n=this.children(),s=this.nocase?Rn(t):_r(t);for(let c of n)if(c.#k===s)return c;let o=this.parent?this.sep:"",i=this.#g?this.#g+o+t:void 0,a=this.newChild(t,ht,{...r,parent:this,fullpath:i});return this.canReaddir()||(a.#e|=wt),n.push(a),a}relative(){if(this.isCWD)return"";if(this.#v!==void 0)return this.#v;let t=this.name,r=this.parent;if(!r)return this.#v=this.name;let n=r.relative();return n+(!n||!r.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#S!==void 0)return this.#S;let t=this.name,r=this.parent;if(!r)return this.#S=this.fullpathPosix();let n=r.relativePosix();return n+(!n||!r.parent?"":"/")+t}fullpath(){if(this.#g!==void 0)return this.#g;let t=this.name,r=this.parent;if(!r)return this.#g=this.name;let s=r.fullpath()+(r.parent?this.sep:"")+t;return this.#g=s}fullpathPosix(){if(this.#y!==void 0)return this.#y;if(this.sep==="/")return this.#y=this.fullpath();if(!this.parent){let s=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(s)?this.#y=`//?/${s}`:this.#y=s}let t=this.parent,r=t.fullpathPosix(),n=r+(!r||!t.parent?"":"/")+this.name;return this.#y=n}isUnknown(){return(this.#e&dt)===ht}isType(t){return this[`is${t}`]()}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.#e&dt)===ic}isDirectory(){return(this.#e&dt)===It}isCharacterDevice(){return(this.#e&dt)===sc}isBlockDevice(){return(this.#e&dt)===oc}isFIFO(){return(this.#e&dt)===nc}isSocket(){return(this.#e&dt)===ac}isSymbolicLink(){return(this.#e&we)===we}lstatCached(){return this.#e&Ya?this:void 0}readlinkCached(){return this.#I}realpathCached(){return this.#F}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#I)return!0;if(!this.parent)return!1;let t=this.#e&dt;return!(t!==ht&&t!==we||this.#e&Pn||this.#e&wt)}calledReaddir(){return!!(this.#e&fo)}isENOENT(){return!!(this.#e&wt)}isNamed(t){return this.nocase?this.#k===Rn(t):this.#k===_r(t)}async readlink(){let t=this.#I;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=await this.#t.promises.readlink(this.fullpath()),n=(await this.parent.realpath())?.resolve(r);if(n)return this.#I=n}catch(r){this.#R(r.code);return}}readlinkSync(){let t=this.#I;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=this.#t.readlinkSync(this.fullpath()),n=this.parent.realpathSync()?.resolve(r);if(n)return this.#I=n}catch(r){this.#R(r.code);return}}#j(t){this.#e|=fo;for(let r=t.provisional;r<t.length;r++){let n=t[r];n&&n.#x()}}#x(){this.#e&wt||(this.#e=(this.#e|wt)&$r,this.#U())}#U(){let t=this.children();t.provisional=0;for(let r of t)r.#x()}#B(){this.#e|=In,this.#M()}#M(){if(this.#e&jr)return;let t=this.#e;(t&dt)===It&&(t&=$r),this.#e=t|jr,this.#U()}#_(t=""){t==="ENOTDIR"||t==="EPERM"?this.#M():t==="ENOENT"?this.#x():this.children().provisional=0}#P(t=""){t==="ENOTDIR"?this.parent.#M():t==="ENOENT"&&this.#x()}#R(t=""){let r=this.#e;r|=Pn,t==="ENOENT"&&(r|=wt),(t==="EINVAL"||t==="UNKNOWN")&&(r&=$r),this.#e=r,t==="ENOTDIR"&&this.parent&&this.parent.#M()}#L(t,r){return this.#G(t,r)||this.#W(t,r)}#W(t,r){let n=ho(t),s=this.newChild(t.name,n,{parent:this}),o=s.#e&dt;return o!==It&&o!==we&&o!==ht&&(s.#e|=jr),r.unshift(s),r.provisional++,s}#G(t,r){for(let n=r.provisional;n<r.length;n++){let s=r[n];if((this.nocase?Rn(t.name):_r(t.name))===s.#k)return this.#u(t,s,n,r)}}#u(t,r,n,s){let o=r.name;return r.#e=r.#e&$r|ho(t),o!==t.name&&(r.name=t.name),n!==s.provisional&&(n===s.length-1?s.pop():s.splice(n,1),s.unshift(r)),s.provisional++,r}async lstat(){if((this.#e&wt)===0)try{return this.#H(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#P(t.code)}}lstatSync(){if((this.#e&wt)===0)try{return this.#H(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#P(t.code)}}#H(t){let{atime:r,atimeMs:n,birthtime:s,birthtimeMs:o,blksize:i,blocks:a,ctime:c,ctimeMs:u,dev:l,gid:p,ino:d,mode:f,mtime:m,mtimeMs:h,nlink:D,rdev:g,size:y,uid:v}=t;this.#w=r,this.#c=n,this.#m=s,this.#b=o,this.#l=i,this.#p=a,this.#T=c,this.#d=u,this.#r=l,this.#C=p,this.#a=d,this.#o=f,this.#h=m,this.#n=h,this.#s=D,this.#D=g,this.#f=y,this.#i=v;let C=ho(t);this.#e=this.#e&$r|C|Ya,C!==ht&&C!==It&&C!==we&&(this.#e|=jr)}#$=[];#A=!1;#z(t){this.#A=!1;let r=this.#$.slice();this.#$.length=0,r.forEach(n=>n(null,t))}readdirCB(t,r=!1){if(!this.canReaddir()){r?t(null,[]):queueMicrotask(()=>t(null,[]));return}let n=this.children();if(this.calledReaddir()){let o=n.slice(0,n.provisional);r?t(null,o):queueMicrotask(()=>t(null,o));return}if(this.#$.push(t),this.#A)return;this.#A=!0;let s=this.fullpath();this.#t.readdir(s,{withFileTypes:!0},(o,i)=>{if(o)this.#_(o.code),n.provisional=0;else{for(let a of i)this.#L(a,n);this.#j(n)}this.#z(n.slice(0,n.provisional))})}#K;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();if(this.#K)await this.#K;else{let n=()=>{};this.#K=new Promise(s=>n=s);try{for(let s of await this.#t.promises.readdir(r,{withFileTypes:!0}))this.#L(s,t);this.#j(t)}catch(s){this.#_(s.code),t.provisional=0}this.#K=void 0,n()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();try{for(let n of this.#t.readdirSync(r,{withFileTypes:!0}))this.#L(n,t);this.#j(t)}catch(n){this.#_(n.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#e&Za)return!1;let t=dt&this.#e;return t===ht||t===It||t===we}shouldWalk(t,r){return(this.#e&It)===It&&!(this.#e&Za)&&!t.has(this)&&(!r||r(this))}async realpath(){if(this.#F)return this.#F;if(!((In|Pn|wt)&this.#e))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#F=this.resolve(t)}catch{this.#B()}}realpathSync(){if(this.#F)return this.#F;if(!((In|Pn|wt)&this.#e))try{let t=this.#t.realpathSync(this.fullpath());return this.#F=this.resolve(t)}catch{this.#B()}}[cc](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let r=new Set([]),n=[],s=this;for(;s&&s.parent;)r.add(s),s.#v=n.join(this.sep),s.#S=n.join("/"),s=s.parent,n.push("..");for(s=t;s&&s.parent&&!r.has(s);)s.#v=void 0,s.#S=void 0,s=s.parent}},On=class e extends z{sep="\\";splitSep=dm;constructor(t,r=ht,n,s,o,i,a){super(t,r,n,s,o,i,a)}newChild(t,r=ht,n={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(t){return je.win32.parse(t).root}getRoot(t){if(t=fm(t.toUpperCase()),t===this.root.name)return this.root;for(let[r,n]of Object.entries(this.roots))if(this.sameRoot(t,r))return this.roots[t]=n;return this.roots[t]=new _e(t,this).root}sameRoot(t,r=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(rc,"$1\\"),t===r}},Mn=class e extends z{splitSep="/";sep="/";constructor(t,r=ht,n,s,o,i,a){super(t,r,n,s,o,i,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,r=ht,n={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}},$n=class{root;rootPath;roots;cwd;#t;#r;#o;nocase;#s;constructor(t=process.cwd(),r,n,{nocase:s,childrenCacheSize:o=16*1024,fs:i=Br}={}){this.#s=ec(i),(t instanceof URL||t.startsWith("file://"))&&(t=(0,tc.fileURLToPath)(t));let a=r.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#t=new Nn,this.#r=new Nn,this.#o=new mo(o);let c=a.substring(this.rootPath.length).split(n);if(c.length===1&&!c[0]&&c.pop(),s===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=s,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let u=this.root,l=c.length-1,p=r.sep,d=this.rootPath,f=!1;for(let m of c){let h=l--;u=u.child(m,{relative:new Array(h).fill("..").join(p),relativePosix:new Array(h).fill("..").join("/"),fullpath:d+=(f?"":p)+m}),f=!0}this.cwd=u}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#o}resolve(...t){let r="";for(let o=t.length-1;o>=0;o--){let i=t[o];if(!(!i||i===".")&&(r=r?`${i}/${r}`:i,this.isAbsolute(i)))break}let n=this.#t.get(r);if(n!==void 0)return n;let s=this.cwd.resolve(r).fullpath();return this.#t.set(r,s),s}resolvePosix(...t){let r="";for(let o=t.length-1;o>=0;o--){let i=t[o];if(!(!i||i===".")&&(r=r?`${i}/${r}`:i,this.isAbsolute(i)))break}let n=this.#r.get(r);if(n!==void 0)return n;let s=this.cwd.resolve(r).fullpathPosix();return this.#r.set(r,s),s}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n}=r;if(t.canReaddir()){let s=await t.readdir();return n?s:s.map(o=>o.name)}else return[]}readdirSync(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0}=r;return t.canReaddir()?n?t.readdirSync():t.readdirSync().map(s=>s.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t.withFileTypes,t=this.cwd);let n=await t.readlink();return r?n:n?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t.withFileTypes,t=this.cwd);let n=t.readlinkSync();return r?n:n?.fullpath()}async realpath(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t.withFileTypes,t=this.cwd);let n=await t.realpath();return r?n:n?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t.withFileTypes,t=this.cwd);let n=t.realpathSync();return r?n:n?.fullpath()}async walk(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=[];(!o||o(t))&&a.push(n?t:t.fullpath());let c=new Set,u=(p,d)=>{c.add(p),p.readdirCB((f,m)=>{if(f)return d(f);let h=m.length;if(!h)return d();let D=()=>{--h===0&&d()};for(let g of m)(!o||o(g))&&a.push(n?g:g.fullpath()),s&&g.isSymbolicLink()?g.realpath().then(y=>y?.isUnknown()?y.lstat():y).then(y=>y?.shouldWalk(c,i)?u(y,D):D()):g.shouldWalk(c,i)?u(g,D):D()},!0)},l=t;return new Promise((p,d)=>{u(l,f=>{if(f)return d(f);p(a)})})}walkSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=[];(!o||o(t))&&a.push(n?t:t.fullpath());let c=new Set([t]);for(let u of c){let l=u.readdirSync();for(let p of l){(!o||o(p))&&a.push(n?p:p.fullpath());let d=p;if(p.isSymbolicLink()){if(!(s&&(d=p.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(c,i)&&c.add(d)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,r={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd),this.stream(t,r)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r;(!o||o(t))&&(yield n?t:t.fullpath());let a=new Set([t]);for(let c of a){let u=c.readdirSync();for(let l of u){(!o||o(l))&&(yield n?l:l.fullpath());let p=l;if(l.isSymbolicLink()){if(!(s&&(p=l.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(a,i)&&a.add(p)}}}stream(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=new ie({objectMode:!0});(!o||o(t))&&a.write(n?t:t.fullpath());let c=new Set,u=[t],l=0,p=()=>{let d=!1;for(;!d;){let f=u.shift();if(!f){l===0&&a.end();return}l++,c.add(f);let m=(D,g,y=!1)=>{if(D)return a.emit("error",D);if(s&&!y){let v=[];for(let C of g)C.isSymbolicLink()&&v.push(C.realpath().then(A=>A?.isUnknown()?A.lstat():A));if(v.length){Promise.all(v).then(()=>m(null,g,!0));return}}for(let v of g)v&&(!o||o(v))&&(a.write(n?v:v.fullpath())||(d=!0));l--;for(let v of g){let C=v.realpathCached()||v;C.shouldWalk(c,i)&&u.push(C)}d&&!a.flowing?a.once("drain",p):h||p()},h=!0;f.readdirCB(m,!0),h=!1}};return p(),a}streamSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=new ie({objectMode:!0}),c=new Set;(!o||o(t))&&a.write(n?t:t.fullpath());let u=[t],l=0,p=()=>{let d=!1;for(;!d;){let f=u.shift();if(!f){l===0&&a.end();return}l++,c.add(f);let m=f.readdirSync();for(let h of m)(!o||o(h))&&(a.write(n?h:h.fullpath())||(d=!0));l--;for(let h of m){let D=h;if(h.isSymbolicLink()){if(!(s&&(D=h.realpathSync())))continue;D.isUnknown()&&D.lstatSync()}D.shouldWalk(c,i)&&u.push(D)}}d&&!a.flowing&&a.once("drain",p)};return p(),a}chdir(t=this.cwd){let r=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[cc](r)}},_e=class extends $n{sep="\\";constructor(t=process.cwd(),r={}){let{nocase:n=!0}=r;super(t,je.win32,"\\",{...r,nocase:n}),this.nocase=n;for(let s=this.cwd;s;s=s.parent)s.nocase=this.nocase}parseRootPath(t){return je.win32.parse(t).root.toUpperCase()}newRoot(t){return new On(this.rootPath,It,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Le=class extends $n{sep="/";constructor(t=process.cwd(),r={}){let{nocase:n=!1}=r;super(t,je.posix,"/",{...r,nocase:n}),this.nocase=n}parseRootPath(t){return"/"}newRoot(t){return new Mn(this.rootPath,It,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Lr=class extends Le{constructor(t=process.cwd(),r={}){let{nocase:n=!0}=r;super(t,{...r,nocase:n})}},_b=process.platform==="win32"?On:Mn,uc=process.platform==="win32"?_e:process.platform==="darwin"?Lr:Le;var mm=e=>e.length>=1,gm=e=>e.length>=1,We=class e{#t;#r;#o;length;#s;#i;#C;#D;#l;#a;#f=!0;constructor(t,r,n,s){if(!mm(t))throw new TypeError("empty pattern list");if(!gm(r))throw new TypeError("empty glob list");if(r.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,n<0||n>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#r=r,this.#o=n,this.#s=s,this.#o===0){if(this.isUNC()){let[o,i,a,c,...u]=this.#t,[l,p,d,f,...m]=this.#r;u[0]===""&&(u.shift(),m.shift());let h=[o,i,a,c,""].join("/"),D=[l,p,d,f,""].join("/");this.#t=[h,...u],this.#r=[D,...m],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[o,...i]=this.#t,[a,...c]=this.#r;i[0]===""&&(i.shift(),c.shift());let u=o+"/",l=a+"/";this.#t=[u,...i],this.#r=[l,...c],this.length=this.#t.length}}}pattern(){return this.#t[this.#o]}isString(){return typeof this.#t[this.#o]=="string"}isGlobstar(){return this.#t[this.#o]===H}isRegExp(){return this.#t[this.#o]instanceof RegExp}globString(){return this.#C=this.#C||(this.#o===0?this.isAbsolute()?this.#r[0]+this.#r.slice(1).join("/"):this.#r.join("/"):this.#r.slice(this.#o).join("/"))}hasMore(){return this.length>this.#o+1}rest(){return this.#i!==void 0?this.#i:this.hasMore()?(this.#i=new e(this.#t,this.#r,this.#o+1,this.#s),this.#i.#a=this.#a,this.#i.#l=this.#l,this.#i.#D=this.#D,this.#i):this.#i=null}isUNC(){let t=this.#t;return this.#l!==void 0?this.#l:this.#l=this.#s==="win32"&&this.#o===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#D!==void 0?this.#D:this.#D=this.#s==="win32"&&this.#o===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#a!==void 0?this.#a:this.#a=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#o===0?t:""}checkFollowGlobstar(){return!(this.#o===0||!this.isGlobstar()||!this.#f)}markFollowGlobstar(){return this.#o===0||!this.isGlobstar()||!this.#f?!1:(this.#f=!1,!0)}};var Dm=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ge=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:r,nocase:n,noext:s,noglobstar:o,platform:i=Dm}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=i,this.mmopts={dot:!0,nobrace:r,nocase:n,noext:s,noglobstar:o,optimizationLevel:2,platform:i,nocomment:!0,nonegate:!0};for(let a of t)this.add(a)}add(t){let r=new ot(t,this.mmopts);for(let n=0;n<r.set.length;n++){let s=r.set[n],o=r.globParts[n];if(!s||!o)throw new Error("invalid pattern object");for(;s[0]==="."&&o[0]===".";)s.shift(),o.shift();let i=new We(s,o,0,this.platform),a=new ot(i.globString(),this.mmopts),c=o[o.length-1]==="**",u=i.isAbsolute();u?this.absolute.push(a):this.relative.push(a),c&&(u?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(t){let r=t.fullpath(),n=`${r}/`,s=t.relative()||".",o=`${s}/`;for(let i of this.relative)if(i.match(s)||i.match(o))return!0;for(let i of this.absolute)if(i.match(r)||i.match(n))return!0;return!1}childrenIgnored(t){let r=t.fullpath()+"/",n=(t.relative()||".")+"/";for(let s of this.relativeChildren)if(s.match(n))return!0;for(let s of this.absoluteChildren)if(s.match(r))return!0;return!1}};var go=class e{store;constructor(t=new Map){this.store=t}copy(){return new e(new Map(this.store))}hasWalked(t,r){return this.store.get(t.fullpath())?.has(r.globString())}storeWalked(t,r){let n=t.fullpath(),s=this.store.get(n);s?s.add(r.globString()):this.store.set(n,new Set([r.globString()]))}},Do=class{store=new Map;add(t,r,n){let s=(r?2:0)|(n?1:0),o=this.store.get(t);this.store.set(t,o===void 0?s:s&o)}entries(){return[...this.store.entries()].map(([t,r])=>[t,!!(r&2),!!(r&1)])}},yo=class{store=new Map;add(t,r){if(!t.canReaddir())return;let n=this.store.get(t);n?n.find(s=>s.globString()===r.globString())||n.push(r):this.store.set(t,[r])}get(t){let r=this.store.get(t);if(!r)throw new Error("attempting to walk unknown path");return r}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},Wr=class e{hasWalkedCache;matches=new Do;subwalks=new yo;patterns;follow;dot;opts;constructor(t,r){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=r?r.copy():new go}processPatterns(t,r){this.patterns=r;let n=r.map(s=>[t,s]);for(let[s,o]of n){this.hasWalkedCache.storeWalked(s,o);let i=o.root(),a=o.isAbsolute()&&this.opts.absolute!==!1;if(i){s=s.resolve(i==="/"&&this.opts.root!==void 0?this.opts.root:i);let p=o.rest();if(p)o=p;else{this.matches.add(s,!0,!1);continue}}if(s.isENOENT())continue;let c,u,l=!1;for(;typeof(c=o.pattern())=="string"&&(u=o.rest());)s=s.resolve(c),o=u,l=!0;if(c=o.pattern(),u=o.rest(),l){if(this.hasWalkedCache.hasWalked(s,o))continue;this.hasWalkedCache.storeWalked(s,o)}if(typeof c=="string"){let p=c===".."||c===""||c===".";this.matches.add(s.resolve(c),a,p);continue}else if(c===H){(!s.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(s,o);let p=u?.pattern(),d=u?.rest();if(!u||(p===""||p===".")&&!d)this.matches.add(s,a,p===""||p===".");else if(p===".."){let f=s.parent||s;d?this.hasWalkedCache.hasWalked(f,d)||this.subwalks.add(f,d):this.matches.add(f,a,!0)}}else c instanceof RegExp&&this.subwalks.add(s,o)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new e(this.opts,this.hasWalkedCache)}filterEntries(t,r){let n=this.subwalks.get(t),s=this.child();for(let o of r)for(let i of n){let a=i.isAbsolute(),c=i.pattern(),u=i.rest();c===H?s.testGlobstar(o,i,u,a):c instanceof RegExp?s.testRegExp(o,c,u,a):s.testString(o,c,u,a)}return s}testGlobstar(t,r,n,s){if((this.dot||!t.name.startsWith("."))&&(r.hasMore()||this.matches.add(t,s,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,r):t.isSymbolicLink()&&(n&&r.checkFollowGlobstar()?this.subwalks.add(t,n):r.markFollowGlobstar()&&this.subwalks.add(t,r)))),n){let o=n.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,n.rest(),s);else if(o===".."){let i=t.parent||t;this.subwalks.add(i,n)}else o instanceof RegExp&&this.testRegExp(t,o,n.rest(),s)}}testRegExp(t,r,n,s){r.test(t.name)&&(n?this.subwalks.add(t,n):this.matches.add(t,s,!1))}testString(t,r,n,s){t.isNamed(r)&&(n?this.subwalks.add(t,n):this.matches.add(t,s,!1))}};var ym=(e,t)=>typeof e=="string"?new Ge([e],t):Array.isArray(e)?new Ge(e,t):e,Bn=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#r;#o;signal;maxDepth;includeChildMatches;constructor(t,r,n){if(this.patterns=t,this.path=r,this.opts=n,this.#o=!n.posix&&n.platform==="win32"?"\\":"/",this.includeChildMatches=n.includeChildMatches!==!1,(n.ignore||!this.includeChildMatches)&&(this.#r=ym(n.ignore??[],n),!this.includeChildMatches&&typeof this.#r.add!="function")){let s="cannot ignore child matches, ignore lacks add() method.";throw new Error(s)}this.maxDepth=n.maxDepth||1/0,n.signal&&(this.signal=n.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#s(t){return this.seen.has(t)||!!this.#r?.ignored?.(t)}#i(t){return!!this.#r?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#t.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t())}async matchCheck(t,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=t.realpathCached()||await t.realpath(),!n)return;t=n}let o=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let i=await o.realpath();i&&(i.isUnknown()||this.opts.stat)&&await i.lstat()}return this.matchCheckTest(o,r)}matchCheckTest(t,r){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!r||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#s(t)?t:void 0}matchCheckSync(t,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=t.realpathCached()||t.realpathSync(),!n)return;t=n}let o=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let i=o.realpathSync();i&&(i?.isUnknown()||this.opts.stat)&&i.lstatSync()}return this.matchCheckTest(o,r)}matchFinish(t,r){if(this.#s(t))return;if(!this.includeChildMatches&&this.#r?.add){let o=`${t.relativePosix()}/**`;this.#r.add(o)}let n=this.opts.absolute===void 0?r:this.opts.absolute;this.seen.add(t);let s=this.opts.mark&&t.isDirectory()?this.#o:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(n){let o=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(o+s)}else{let o=this.opts.posix?t.relativePosix():t.relative(),i=this.opts.dotRelative&&!o.startsWith(".."+this.#o)?"."+this.#o:"";this.matchEmit(o?i+o+s:"."+s)}}async match(t,r,n){let s=await this.matchCheck(t,n);s&&this.matchFinish(s,r)}matchSync(t,r,n){let s=this.matchCheckSync(t,n);s&&this.matchFinish(s,r)}walkCB(t,r,n){this.signal?.aborted&&n(),this.walkCB2(t,r,new Wr(this.opts),n)}walkCB2(t,r,n,s){if(this.#i(t))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2(t,r,n,s));return}n.processPatterns(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,u]of n.matches.entries())this.#s(a)||(o++,this.match(a,c,u).then(()=>i()));for(let a of n.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let c=a.readdirCached();a.calledReaddir()?this.walkCB3(a,c,n,i):a.readdirCB((u,l)=>this.walkCB3(a,l,n,i),!0)}i()}walkCB3(t,r,n,s){n=n.filterEntries(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,u]of n.matches.entries())this.#s(a)||(o++,this.match(a,c,u).then(()=>i()));for(let[a,c]of n.subwalks.entries())o++,this.walkCB2(a,c,n.child(),i);i()}walkCBSync(t,r,n){this.signal?.aborted&&n(),this.walkCB2Sync(t,r,new Wr(this.opts),n)}walkCB2Sync(t,r,n,s){if(this.#i(t))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2Sync(t,r,n,s));return}n.processPatterns(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,u]of n.matches.entries())this.#s(a)||this.matchSync(a,c,u);for(let a of n.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let c=a.readdirSync();this.walkCB3Sync(a,c,n,i)}i()}walkCB3Sync(t,r,n,s){n=n.filterEntries(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,u]of n.matches.entries())this.#s(a)||this.matchSync(a,c,u);for(let[a,c]of n.subwalks.entries())o++,this.walkCB2Sync(a,c,n.child(),i);i()}},Gr=class extends Bn{matches=new Set;constructor(t,r,n){super(t,r,n)}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,r)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?r(this.signal.reason):t(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Hr=class extends Bn{results;constructor(t,r,n){super(t,r,n),this.results=new ie({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var wm=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ct=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(t,r){if(!r)throw new TypeError("glob options required");if(this.withFileTypes=!!r.withFileTypes,this.signal=r.signal,this.follow=!!r.follow,this.dot=!!r.dot,this.dotRelative=!!r.dotRelative,this.nodir=!!r.nodir,this.mark=!!r.mark,r.cwd?(r.cwd instanceof URL||r.cwd.startsWith("file://"))&&(r.cwd=(0,lc.fileURLToPath)(r.cwd)):this.cwd="",this.cwd=r.cwd||"",this.root=r.root,this.magicalBraces=!!r.magicalBraces,this.nobrace=!!r.nobrace,this.noext=!!r.noext,this.realpath=!!r.realpath,this.absolute=r.absolute,this.includeChildMatches=r.includeChildMatches!==!1,this.noglobstar=!!r.noglobstar,this.matchBase=!!r.matchBase,this.maxDepth=typeof r.maxDepth=="number"?r.maxDepth:1/0,this.stat=!!r.stat,this.ignore=r.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(c=>c.replace(/\\/g,"/"))),this.matchBase){if(r.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=t,this.platform=r.platform||wm,this.opts={...r,platform:this.platform},r.scurry){if(this.scurry=r.scurry,r.nocase!==void 0&&r.nocase!==r.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let c=r.platform==="win32"?_e:r.platform==="darwin"?Lr:r.platform?Le:uc;this.scurry=new c(this.cwd,{nocase:r.nocase,fs:r.fs})}this.nocase=this.scurry.nocase;let n=this.platform==="darwin"||this.platform==="win32",s={...r,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:n,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},o=this.pattern.map(c=>new ot(c,s)),[i,a]=o.reduce((c,u)=>(c[0].push(...u.set),c[1].push(...u.globParts),c),[[],[]]);this.patterns=i.map((c,u)=>{let l=a[u];if(!l)throw new Error("invalid pattern object");return new We(c,l,0,this.platform)})}async walk(){return[...await new Gr(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 Gr(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 Hr(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 Hr(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 wo=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let r of e)if(new ot(r,t).hasMagic())return!0;return!1};function _n(e,t={}){return new Ct(e,t).streamSync()}function fc(e,t={}){return new Ct(e,t).stream()}function Ln(e,t={}){return new Ct(e,t).walkSync()}async function pc(e,t={}){return new Ct(e,t).walk()}function Wn(e,t={}){return new Ct(e,t).iterateSync()}function dc(e,t={}){return new Ct(e,t).iterate()}var Cm=_n,bm=Object.assign(fc,{sync:_n}),vm=Wn,xm=Object.assign(dc,{sync:Wn}),km=Object.assign(Ln,{stream:_n,iterate:Wn}),jn=Object.assign(pc,{glob:pc,globSync:Ln,sync:km,globStream:fc,stream:bm,globStreamSync:_n,streamSync:Cm,globIterate:dc,iterate:xm,globIterateSync:Wn,iterateSync:vm,Glob:Ct,hasMagic:wo,escape:Oe,unescape:Dt});jn.glob=jn;var ce=(e,t)=>typeof e>"u"||typeof e===t,hc=e=>!!e&&typeof e=="object"&&ce(e.preserveRoot,"boolean")&&ce(e.tmp,"string")&&ce(e.maxRetries,"number")&&ce(e.retryDelay,"number")&&ce(e.backoff,"number")&&ce(e.maxBackoff,"number")&&(ce(e.glob,"boolean")||e.glob&&typeof e.glob=="object")&&ce(e.filter,"function"),mc=e=>{if(!hc(e))throw new Error("invalid rimraf options")},gc=e=>{mc(e);let{glob:t,...r}=e;if(!t)return r;let n=t===!0?e.signal?{signal:e.signal}:{}:e.signal?{signal:e.signal,...t}:t;return{...r,glob:{...n,absolute:!0,withFileTypes:!1}}},Dc=(e={})=>gc(e),yc=(e={})=>gc(e);var Ur=require("path"),wc=require("util"),Em=(e,t={})=>{let r=typeof e;if(r!=="string"){let s=e&&r==="object"&&e.constructor,i=`The "path" argument must be of type string. Received ${s&&s.name?`an instance of ${s.name}`:r==="object"?(0,wc.inspect)(e):`type ${r} ${e}`}`;throw Object.assign(new TypeError(i),{path:e,code:"ERR_INVALID_ARG_TYPE"})}if(/\0/.test(e)){let s="path must be a string without null bytes";throw Object.assign(new TypeError(s),{path:e,code:"ERR_INVALID_ARG_VALUE"})}e=(0,Ur.resolve)(e);let{root:n}=(0,Ur.parse)(e);if(e===n&&t.preserveRoot!==!1){let s="refusing to remove root directory without preserveRoot:false";throw Object.assign(new Error(s),{path:e,code:"ERR_PRESERVE_ROOT"})}if(process.platform==="win32"){let s=/[*|"<>?:]/,{root:o}=(0,Ur.parse)(e);if(s.test(e.substring(o.length)))throw Object.assign(new Error("Illegal characters in path."),{path:e,code:"EINVAL"})}return e},zr=Em;var Cc=require("fs"),Ot=b(require("fs/promises"),1),k=require("fs"),bc=e=>(0,Cc.readdirSync)(e,{withFileTypes:!0}),et={chmod:Ot.default.chmod,mkdir:Ot.default.mkdir,readdir:e=>Ot.default.readdir(e,{withFileTypes:!0}),rename:Ot.default.rename,rm:Ot.default.rm,rmdir:Ot.default.rmdir,stat:Ot.default.stat,lstat:Ot.default.lstat,unlink:Ot.default.unlink};var ze=require("path");var{readdir:Sm}=et,He=e=>Sm(e).catch(t=>t),Ue=e=>{try{return bc(e)}catch(t){return t}};var vc=e=>!!e&&typeof e=="object",Co=(e,t)=>t in e&&typeof e[t]=="string",bo=e=>vc(e)&&Co(e,"code")&&Co(e,"path"),I=e=>vc(e)&&Co(e,"code")?e.code:null;var Z=async(e,t)=>e.catch(r=>{if(I(r)!=="ENOENT")throw t??r}),X=(e,t)=>{try{return e()}catch(r){if(I(r)==="ENOENT")return;throw t??r}};var{lstat:Fm,rmdir:Tm,unlink:Am}=et,Gn=async(e,t)=>(t?.signal?.throwIfAborted(),await Z(Fm(e).then(r=>xc(e,t,r)))??!0),Hn=(e,t)=>(t?.signal?.throwIfAborted(),X(()=>kc(e,t,(0,k.lstatSync)(e)))??!0),xc=async(e,t,r)=>{t?.signal?.throwIfAborted();let n=r.isDirectory()?await He(e):null;if(!Array.isArray(n)){if(n){if(I(n)==="ENOENT")return!0;if(I(n)!=="ENOTDIR")throw n}return t.filter&&!await t.filter(e,r)?!1:(await Z(Am(e)),!0)}return!(await Promise.all(n.map(o=>xc((0,ze.resolve)(e,o.name),t,o)))).every(o=>o===!0)||t.preserveRoot===!1&&e===(0,ze.parse)(e).root||t.filter&&!await t.filter(e,r)?!1:(await Z(Tm(e)),!0)},kc=(e,t,r)=>{t?.signal?.throwIfAborted();let n=r.isDirectory()?Ue(e):null;if(!Array.isArray(n)){if(n){if(I(n)==="ENOENT")return!0;if(I(n)!=="ENOTDIR")throw n}return t.filter&&!t.filter(e,r)?!1:(X(()=>(0,k.unlinkSync)(e)),!0)}let s=!0;for(let o of n){let i=(0,ze.resolve)(e,o.name);s=kc(i,t,o)&&s}return t.preserveRoot===!1&&e===(0,ze.parse)(e).root||!s||t.filter&&!t.filter(e,r)?!1:(X(()=>(0,k.rmdirSync)(e)),!0)};var Ke=require("path");var{chmod:Pm}=et,Kr=e=>async t=>{try{return void await Z(e(t))}catch(r){if(I(r)==="EPERM")return await Z(Pm(t,438).then(()=>!0),r)?void await e(t):void 0;throw r}},Jr=e=>t=>{try{return void X(()=>e(t))}catch(r){if(I(r)==="EPERM")return X(()=>((0,k.chmodSync)(t,438),!0),r)?void e(t):void 0;throw r}};var Ec=require("timers/promises");var Rm=200,Im=1.2,Sc=10,Fc=new Set(["EMFILE","ENFILE","EBUSY"]),vo=e=>{let t=async(r,n,s=1,o=0)=>{let i=n.maxBackoff||Rm,a=n.backoff||Im,c=n.maxRetries||Sc,u=0;for(;;)try{return await e(r)}catch(l){if(bo(l)&&l.path===r&&Fc.has(l.code)){if(s=Math.ceil(s*a),o=s+o,o<i)return await(0,Ec.setTimeout)(s),t(r,n,s,o);if(u<c){u++;continue}}throw l}};return t},xo=e=>(r,n)=>{let s=n.maxRetries||Sc,o=0;for(;;)try{return e(r)}catch(i){if(bo(i)&&i.path===r&&Fc.has(i.code)&&o<s){o++;continue}throw i}};var mt=require("path");var Vr=require("os"),ue=require("path");var{stat:Nm}=et,Om=e=>{try{return(0,k.statSync)(e).isDirectory()}catch{return!1}},Mm=e=>Nm(e).then(t=>t.isDirectory(),()=>!1),$m=async e=>{let{root:t}=(0,ue.parse)(e),r=(0,Vr.tmpdir)(),{root:n}=(0,ue.parse)(r);if(t.toLowerCase()===n.toLowerCase())return r;let s=(0,ue.resolve)(t,"/temp");return await Mm(s)?s:t},Bm=e=>{let{root:t}=(0,ue.parse)(e),r=(0,Vr.tmpdir)(),{root:n}=(0,ue.parse)(r);if(t.toLowerCase()===n.toLowerCase())return r;let s=(0,ue.resolve)(t,"/temp");return Om(s)?s:t},jm=async()=>(0,Vr.tmpdir)(),_m=()=>(0,Vr.tmpdir)(),Tc=process.platform==="win32"?$m:jm,Ac=process.platform==="win32"?Bm:_m;var{lstat:Lm,rename:Wm,unlink:Gm,rmdir:Hm}=et,Ic=e=>`.${(0,mt.basename)(e)}.${Math.random()}`,Um=Kr(Gm),zm=Jr(k.unlinkSync),Un=async(e,t)=>(t?.signal?.throwIfAborted(),await Z(Lm(e).then(r=>ko(e,t,r)))??!0),ko=async(e,t,r)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return ko(e,{...t,tmp:await Tc(e)},r);if(e===t.tmp&&(0,mt.parse)(e).root!==e)throw new Error("cannot delete temp directory used for deletion");let n=r.isDirectory()?await He(e):null;if(!Array.isArray(n)){if(n){if(I(n)==="ENOENT")return!0;if(I(n)!=="ENOTDIR")throw n}return t.filter&&!await t.filter(e,r)?!1:(await Z(Pc(e,t.tmp,Um)),!0)}return!(await Promise.all(n.map(o=>ko((0,mt.resolve)(e,o.name),t,o)))).every(o=>o===!0)||t.preserveRoot===!1&&e===(0,mt.parse)(e).root||t.filter&&!await t.filter(e,r)?!1:(await Z(Pc(e,t.tmp,Hm)),!0)},Pc=async(e,t,r)=>{let n=(0,mt.resolve)(t,Ic(e));return await Wm(e,n),await r(n)},zn=(e,t)=>(t?.signal?.throwIfAborted(),X(()=>Eo(e,t,(0,k.lstatSync)(e)))??!0),Eo=(e,t,r)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return Eo(e,{...t,tmp:Ac(e)},r);let n=t.tmp;if(e===t.tmp&&(0,mt.parse)(e).root!==e)throw new Error("cannot delete temp directory used for deletion");let s=r.isDirectory()?Ue(e):null;if(!Array.isArray(s)){if(s){if(I(s)==="ENOENT")return!0;if(I(s)!=="ENOTDIR")throw s}return t.filter&&!t.filter(e,r)?!1:(X(()=>Rc(e,n,zm)),!0)}let o=!0;for(let i of s){let a=(0,mt.resolve)(e,i.name);o=Eo(a,t,i)&&o}return!o||t.preserveRoot===!1&&e===(0,mt.parse)(e).root||t.filter&&!t.filter(e,r)?!1:(X(()=>Rc(e,n,k.rmdirSync)),!0)},Rc=(e,t,r)=>{let n=(0,mt.resolve)(t,Ic(e));return(0,k.renameSync)(e,n),r(n)};var{unlink:Km,rmdir:Jm,lstat:Vm}=et,qm=vo(Kr(Km)),Ym=xo(Jr(k.unlinkSync)),Zm=vo(Kr(Jm)),Xm=xo(Jr(k.rmdirSync)),Qm=async(e,{filter:t,...r})=>{r?.signal?.throwIfAborted();try{return await Zm(e,r),!0}catch(n){if(I(n)==="ENOTEMPTY")return Un(e,r);throw n}},tg=(e,{filter:t,...r})=>{r?.signal?.throwIfAborted();try{return Xm(e,r),!0}catch(n){if(I(n)==="ENOTEMPTY")return zn(e,r);throw n}},le=Symbol("start"),Nc=Symbol("child"),Kn=Symbol("finish"),Jn=async(e,t)=>(t?.signal?.throwIfAborted(),await Z(Vm(e).then(r=>So(e,t,r,le)))??!0),Vn=(e,t)=>(t?.signal?.throwIfAborted(),X(()=>Fo(e,t,(0,k.lstatSync)(e),le))??!0),So=async(e,t,r,n=le)=>{t?.signal?.throwIfAborted();let s=r.isDirectory()?await He(e):null;if(!Array.isArray(s)){if(s){if(I(s)==="ENOENT")return!0;if(I(s)!=="ENOTDIR")throw s}return t.filter&&!await t.filter(e,r)?!1:(await Z(qm(e,t)),!0)}let o=n===le?Nc:n,i=(await Promise.all(s.map(a=>So((0,Ke.resolve)(e,a.name),t,a,o)))).every(a=>a===!0);if(n===le)return So(e,t,r,Kn);if(n===Kn){if(t.preserveRoot===!1&&e===(0,Ke.parse)(e).root||!i||t.filter&&!await t.filter(e,r))return!1;await Z(Qm(e,t))}return!0},Fo=(e,t,r,n=le)=>{let s=r.isDirectory()?Ue(e):null;if(!Array.isArray(s)){if(s){if(I(s)==="ENOENT")return!0;if(I(s)!=="ENOTDIR")throw s}return t.filter&&!t.filter(e,r)?!1:(X(()=>Ym(e,t)),!0)}let o=!0;for(let i of s){let a=n===le?Nc:n,c=(0,Ke.resolve)(e,i.name);o=Fo(c,t,i,a)&&o}if(n===le)return Fo(e,t,r,Kn);if(n===Kn){if(t.preserveRoot===!1&&e===(0,Ke.parse)(e).root||!o||t.filter&&!t.filter(e,r))return!1;X(()=>tg(e,t))}return!0};var To=process.platform==="win32"?Jn:Gn,Ao=process.platform==="win32"?Vn:Hn;var{rm:eg}=et,Po=async(e,t)=>(await eg(e,{...t,force:!0,recursive:!0}),!0),Ro=(e,t)=>((0,k.rmSync)(e,{...t,force:!0,recursive:!0}),!0);var[Oc=0,rg=0]=process.version.replace(/^v/,"").split(".").map(e=>parseInt(e,10)),Mc=Oc>14||Oc===14&&rg>=14,$c=!Mc||process.platform==="win32"?()=>!1:e=>!e?.signal&&!e?.filter,Bc=!Mc||process.platform==="win32"?()=>!1:e=>!e?.signal&&!e?.filter;var Je=e=>async(t,r)=>{let n=Dc(r);return n.glob&&(t=await jn(t,n.glob)),Array.isArray(t)?!!(await Promise.all(t.map(s=>e(zr(s,n),n)))).reduce((s,o)=>s&&o,!0):!!await e(zr(t,n),n)},Ve=e=>(t,r)=>{let n=yc(r);return n.glob&&(t=Ln(t,n.glob)),Array.isArray(t)?!!t.map(s=>e(zr(s,n),n)).reduce((s,o)=>s&&o,!0):!!e(zr(t,n),n)},Lc=Ve(Ro),ng=Object.assign(Je(Po),{sync:Lc}),Wc=Ve(Ao),sg=Object.assign(Je(To),{sync:Wc}),Gc=Ve(Vn),og=Object.assign(Je(Jn),{sync:Gc}),Hc=Ve(Hn),ig=Object.assign(Je(Gn),{sync:Hc}),Uc=Ve(zn),ag=Object.assign(Je(Un),{sync:Uc}),jc=Ve((e,t)=>Bc(t)?Ro(e,t):Ao(e,t));var _c=Je((e,t)=>$c(t)?Po(e,t):To(e,t)),qn=Object.assign(_c,{rimraf:_c,sync:jc,rimrafSync:jc,manual:sg,manualSync:Wc,native:ng,nativeSync:Lc,posix:ig,posixSync:Hc,windows:og,windowsSync:Gc,moveRemove:ag,moveRemoveSync:Uc});qn.rimraf=qn;var S=e=>(0,qe.join)(process.cwd(),e),Yn=e=>{try{return(0,zc.readdirSync)(e).length===0}catch{return!0}};function Kc(){let e=va({cwd:(0,qe.dirname)(__filename)});if(!e)throw new Error("Could not find package.json");return(0,qe.dirname)(e)}var Jc=e=>qn(e);var Vc=b(require("chalk"));async function K(e,t){let r=Date.now(),n=e.title,s=()=>Math.floor((Date.now()-r)/1e3),o=setInterval(()=>{s()>1&&(e.title=`${n} (${s()}s)`)},1e3);try{return await t(s)}finally{clearInterval(o)}}async function Zn(e,t,r){for(let n=0;n<t.length;n++){let s=t[n];e.output=Vc.default.dim(`[${n+1}/${t.length}] ${s.title}`),await s.fn(r??{},e)}}var Ye=e=>{let t=e??O(),r=(0,rt.join)(t,"package.json");if(!(0,bt.existsSync)(r))return null;try{return JSON.parse((0,bt.readFileSync)(r,"utf-8"))}catch{return null}},vt=e=>{let t={services:"services",apps:"apps",packages:"packages",contracts:"packages/contracts"},r=Ye(e);if(!r)return t;let n=r.pf?.paths;return{services:(typeof n?.services=="object"?n.services.path:n?.services)??t.services,apps:(typeof n?.apps=="object"?n.apps.path:n?.apps)??t.apps,packages:(typeof n?.packages=="object"?n.packages.path:n?.packages)??t.packages,contracts:(typeof n?.contracts=="object"?n.contracts.path:n?.contracts)??t.contracts}},G=e=>{let t=e??O(),r=vt(t);return{packagePath:(0,rt.join)(t,r.contracts),eventsPath:(0,rt.join)(t,r.contracts,"src","events"),indexPath:(0,rt.join)(t,r.contracts,"src","index.ts"),relativePath:r.contracts}},cg=e=>{let t=(0,rt.join)(e,"package.json");if(!(0,bt.existsSync)(t))return!1;try{let r=JSON.parse((0,bt.readFileSync)(t,"utf-8"));if(!r.workspaces)return!1;if(r.pf||(0,bt.existsSync)((0,rt.join)(e,"turbo.json")))return!0;let n=fa.some(o=>(0,bt.existsSync)((0,rt.join)(e,o))),s=(0,bt.existsSync)((0,rt.join)(e,"infra"));return!!(n&&s)}catch{return!1}};function O(){let e=process.cwd();for(;!cg(e);){let t=e.slice(0,e.lastIndexOf("/"));if(t===e)throw new Error(`
16
+ >>> no match, partial?`,t,d,r,f),d===c))}let h;if(typeof l=="string"?(h=p===l,this.debug("string match",l,p,h)):(h=l.test(p),this.debug("pattern match",l,p,h)),!h)return!1}if(i===c&&a===u)return!0;if(i===c)return n;if(a===u)return i===c-1&&t[i]==="";throw new Error("wtf?")}braceExpand(){return Ua(this.pattern,this.options)}parse(t){Nr(t);let r=this.options;if(t==="**")return H;if(t==="")return"";let n,s=null;(n=t.match($h))?s=r.dot?jh:Bh:(n=t.match(Sh))?s=(r.nocase?r.dot?Ph:Ah:r.dot?Th:Fh)(n[1]):(n=t.match(_h))?s=(r.nocase?r.dot?Wh:Lh:r.dot?Gh:Hh)(n):(n=t.match(Rh))?s=r.dot?Nh:Ih:(n=t.match(Oh))&&(s=Mh);let o=Oe.fromGlob(t,this.options).toMMPattern();return s&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:s}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?Kh:r.dot?Jh:Vh,s=new Set(r.nocase?["i"]:[]),o=t.map(c=>{let u=c.map(p=>{if(p instanceof RegExp)for(let d of p.flags.split(""))s.add(d);return typeof p=="string"?Qh(p):p===H?H:p._src});u.forEach((p,d)=>{let f=u[d+1],m=u[d-1];p!==H||m===H||(m===void 0?f!==void 0&&f!==H?u[d+1]="(?:\\/|"+n+"\\/)?"+f:u[d]=n:f===void 0?u[d-1]=m+"(?:\\/|\\/"+n+")?":f!==H&&(u[d-1]=m+"(?:\\/|\\/"+n+"\\/)"+f,u[d+1]=H))});let l=u.filter(p=>p!==H);if(this.partial&&l.length>=1){let p=[];for(let d=1;d<=l.length;d++)p.push(l.slice(0,d).join("/"));return"(?:"+p.join("|")+")"}return l.join("/")}).join("|"),[i,a]=t.length>1?["(?:",")"]:["",""];o="^"+i+o+a+"$",this.partial&&(o="^(?:\\/|"+i+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...s].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let s=this.slashSplit(t);this.debug(this.pattern,"split",s);let o=this.set;this.debug(this.pattern,"set",o);let i=s[s.length-1];if(!i)for(let a=s.length-2;!i&&a>=0;a--)i=s[a];for(let a=0;a<o.length;a++){let c=o[a],u=s;if(n.matchBase&&c.length===1&&(u=[i]),this.matchOne(u,c,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return q.defaults(t).Minimatch}};q.AST=Oe;q.Minimatch=ot;q.escape=Me;q.unescape=Dt;var hc=require("node:url");var tm=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ka=new Set,co=typeof process=="object"&&process?process:{},Ja=(e,t,r,n)=>{typeof co.emitWarning=="function"?co.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)},Fn=globalThis.AbortController,za=globalThis.AbortSignal;if(typeof Fn>"u"){za=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(n,s){this._onabort.push(s)}},Fn=class{constructor(){t()}signal=new za;abort(n){if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(let s of this.signal._onabort)s(n);this.signal.onabort?.(n)}}};let e=co.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,Ja("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var em=e=>!Ka.has(e),jb=Symbol("type"),oe=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Va=e=>oe(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?$e:null:null,$e=class extends Array{constructor(t){super(t),this.fill(0)}},uo=class e{heap;length;static#t=!1;static create(t){let r=Va(t);if(!r)return[];e.#t=!0;let n=new e(t,r);return e.#t=!1,n}constructor(t,r){if(!e.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},ye=class e{#t;#r;#o;#s;#i;#C;#D;#l;get perf(){return this.#l}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#f;#p;#c;#n;#d;#b;#w;#h;#T;#m;#k;#E;#g;#y;#v;#S;#e;#O;static unsafeExposeInternals(t){return{starts:t.#E,ttls:t.#g,autopurgeTimers:t.#y,sizes:t.#k,keyMap:t.#p,keyList:t.#c,valList:t.#n,next:t.#d,prev:t.#b,get head(){return t.#w},get tail(){return t.#h},free:t.#T,isBackgroundFetch:r=>t.#u(r),backgroundFetch:(r,n,s,o)=>t.#G(r,n,s,o),moveToTail:r=>t.#$(r),indexes:r=>t.#P(r),rindexes:r=>t.#R(r),isStale:r=>t.#x(r)}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#f}get size(){return this.#a}get fetchMethod(){return this.#C}get memoMethod(){return this.#D}get dispose(){return this.#o}get onInsert(){return this.#s}get disposeAfter(){return this.#i}constructor(t){let{max:r=0,ttl:n,ttlResolution:s=1,ttlAutopurge:o,updateAgeOnGet:i,updateAgeOnHas:a,allowStale:c,dispose:u,onInsert:l,disposeAfter:p,noDisposeOnSet:d,noUpdateTTL:f,maxSize:m=0,maxEntrySize:h=0,sizeCalculation:D,fetchMethod:g,memoMethod:y,noDeleteOnFetchRejection:v,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:lt,ignoreFetchAbort:re,perf:Fe}=t;if(Fe!==void 0&&typeof Fe?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#l=Fe??tm,r!==0&&!oe(r))throw new TypeError("max option must be a nonnegative integer");let Te=r?Va(r):Array;if(!Te)throw new Error("invalid max value: "+r);if(this.#t=r,this.#r=m,this.maxEntrySize=h||this.#r,this.sizeCalculation=D,this.sizeCalculation){if(!this.#r&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(y!==void 0&&typeof y!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#D=y,g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#C=g,this.#S=!!g,this.#p=new Map,this.#c=new Array(r).fill(void 0),this.#n=new Array(r).fill(void 0),this.#d=new Te(r),this.#b=new Te(r),this.#w=0,this.#h=0,this.#T=uo.create(r),this.#a=0,this.#f=0,typeof u=="function"&&(this.#o=u),typeof l=="function"&&(this.#s=l),typeof p=="function"?(this.#i=p,this.#m=[]):(this.#i=void 0,this.#m=void 0),this.#v=!!this.#o,this.#O=!!this.#s,this.#e=!!this.#i,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!f,this.noDeleteOnFetchRejection=!!v,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!lt,this.ignoreFetchAbort=!!re,this.maxEntrySize!==0){if(this.#r!==0&&!oe(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!oe(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#U()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!a,this.ttlResolution=oe(s)||s===0?s:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!oe(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#I()}if(this.#t===0&&this.ttl===0&&this.#r===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){let Ae="LRU_CACHE_UNBOUNDED";em(Ae)&&(Ka.add(Ae),Ja("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ae,e))}}getRemainingTTL(t){return this.#p.has(t)?1/0:0}#I(){let t=new $e(this.#t),r=new $e(this.#t);this.#g=t,this.#E=r;let n=this.ttlAutopurge?new Array(this.#t):void 0;this.#y=n,this.#j=(i,a,c=this.#l.now())=>{if(r[i]=a!==0?c:0,t[i]=a,n?.[i]&&(clearTimeout(n[i]),n[i]=void 0),a!==0&&n){let u=setTimeout(()=>{this.#x(i)&&this.#A(this.#c[i],"expire")},a+1);u.unref&&u.unref(),n[i]=u}},this.#F=i=>{r[i]=t[i]!==0?this.#l.now():0},this.#N=(i,a)=>{if(t[a]){let c=t[a],u=r[a];if(!c||!u)return;i.ttl=c,i.start=u,i.now=s||o();let l=i.now-u;i.remainingTTL=c-l}};let s=0,o=()=>{let i=this.#l.now();if(this.ttlResolution>0){s=i;let a=setTimeout(()=>s=0,this.ttlResolution);a.unref&&a.unref()}return i};this.getRemainingTTL=i=>{let a=this.#p.get(i);if(a===void 0)return 0;let c=t[a],u=r[a];if(!c||!u)return 1/0;let l=(s||o())-u;return c-l},this.#x=i=>{let a=r[i],c=t[i];return!!c&&!!a&&(s||o())-a>c}}#F=()=>{};#N=()=>{};#j=()=>{};#x=()=>!1;#U(){let t=new $e(this.#t);this.#f=0,this.#k=t,this.#B=r=>{this.#f-=t[r],t[r]=0},this.#_=(r,n,s,o)=>{if(this.#u(n))return 0;if(!oe(s))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(s=o(n,r),!oe(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s},this.#M=(r,n,s)=>{if(t[r]=n,this.#r){let o=this.#r-t[r];for(;this.#f>o;)this.#W(!0)}this.#f+=t[r],s&&(s.entrySize=n,s.totalCalculatedSize=this.#f)}}#B=t=>{};#M=(t,r,n)=>{};#_=(t,r,n,s)=>{if(n||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#P({allowStale:t=this.allowStale}={}){if(this.#a)for(let r=this.#h;!(!this.#L(r)||((t||!this.#x(r))&&(yield r),r===this.#w));)r=this.#b[r]}*#R({allowStale:t=this.allowStale}={}){if(this.#a)for(let r=this.#w;!(!this.#L(r)||((t||!this.#x(r))&&(yield r),r===this.#h));)r=this.#d[r]}#L(t){return t!==void 0&&this.#p.get(this.#c[t])===t}*entries(){for(let t of this.#P())this.#n[t]!==void 0&&this.#c[t]!==void 0&&!this.#u(this.#n[t])&&(yield[this.#c[t],this.#n[t]])}*rentries(){for(let t of this.#R())this.#n[t]!==void 0&&this.#c[t]!==void 0&&!this.#u(this.#n[t])&&(yield[this.#c[t],this.#n[t]])}*keys(){for(let t of this.#P()){let r=this.#c[t];r!==void 0&&!this.#u(this.#n[t])&&(yield r)}}*rkeys(){for(let t of this.#R()){let r=this.#c[t];r!==void 0&&!this.#u(this.#n[t])&&(yield r)}}*values(){for(let t of this.#P())this.#n[t]!==void 0&&!this.#u(this.#n[t])&&(yield this.#n[t])}*rvalues(){for(let t of this.#R())this.#n[t]!==void 0&&!this.#u(this.#n[t])&&(yield this.#n[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,r={}){for(let n of this.#P()){let s=this.#n[n],o=this.#u(s)?s.__staleWhileFetching:s;if(o!==void 0&&t(o,this.#c[n],this))return this.get(this.#c[n],r)}}forEach(t,r=this){for(let n of this.#P()){let s=this.#n[n],o=this.#u(s)?s.__staleWhileFetching:s;o!==void 0&&t.call(r,o,this.#c[n],this)}}rforEach(t,r=this){for(let n of this.#R()){let s=this.#n[n],o=this.#u(s)?s.__staleWhileFetching:s;o!==void 0&&t.call(r,o,this.#c[n],this)}}purgeStale(){let t=!1;for(let r of this.#R({allowStale:!0}))this.#x(r)&&(this.#A(this.#c[r],"expire"),t=!0);return t}info(t){let r=this.#p.get(t);if(r===void 0)return;let n=this.#n[r],s=this.#u(n)?n.__staleWhileFetching:n;if(s===void 0)return;let o={value:s};if(this.#g&&this.#E){let i=this.#g[r],a=this.#E[r];if(i&&a){let c=i-(this.#l.now()-a);o.ttl=c,o.start=Date.now()}}return this.#k&&(o.size=this.#k[r]),o}dump(){let t=[];for(let r of this.#P({allowStale:!0})){let n=this.#c[r],s=this.#n[r],o=this.#u(s)?s.__staleWhileFetching:s;if(o===void 0||n===void 0)continue;let i={value:o};if(this.#g&&this.#E){i.ttl=this.#g[r];let a=this.#l.now()-this.#E[r];i.start=Math.floor(Date.now()-a)}this.#k&&(i.size=this.#k[r]),t.unshift([n,i])}return t}load(t){this.clear();for(let[r,n]of t){if(n.start){let s=Date.now()-n.start;n.start=this.#l.now()-s}this.set(r,n.value,n)}}set(t,r,n={}){if(r===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:o,noDisposeOnSet:i=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=n,{noUpdateTTL:u=this.noUpdateTTL}=n,l=this.#_(t,r,n.size||0,a);if(this.maxEntrySize&&l>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#A(t,"set"),this;let p=this.#a===0?void 0:this.#p.get(t);if(p===void 0)p=this.#a===0?this.#h:this.#T.length!==0?this.#T.pop():this.#a===this.#t?this.#W(!1):this.#a,this.#c[p]=t,this.#n[p]=r,this.#p.set(t,p),this.#d[this.#h]=p,this.#b[p]=this.#h,this.#h=p,this.#a++,this.#M(p,l,c),c&&(c.set="add"),u=!1,this.#O&&this.#s?.(r,t,"add");else{this.#$(p);let d=this.#n[p];if(r!==d){if(this.#S&&this.#u(d)){d.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:f}=d;f!==void 0&&!i&&(this.#v&&this.#o?.(f,t,"set"),this.#e&&this.#m?.push([f,t,"set"]))}else i||(this.#v&&this.#o?.(d,t,"set"),this.#e&&this.#m?.push([d,t,"set"]));if(this.#B(p),this.#M(p,l,c),this.#n[p]=r,c){c.set="replace";let f=d&&this.#u(d)?d.__staleWhileFetching:d;f!==void 0&&(c.oldValue=f)}}else c&&(c.set="update");this.#O&&this.onInsert?.(r,t,r===d?"update":"replace")}if(s!==0&&!this.#g&&this.#I(),this.#g&&(u||this.#j(p,s,o),c&&this.#N(c,p)),!i&&this.#e&&this.#m){let d=this.#m,f;for(;f=d?.shift();)this.#i?.(...f)}return this}pop(){try{for(;this.#a;){let t=this.#n[this.#w];if(this.#W(!0),this.#u(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#e&&this.#m){let t=this.#m,r;for(;r=t?.shift();)this.#i?.(...r)}}}#W(t){let r=this.#w,n=this.#c[r],s=this.#n[r];return this.#S&&this.#u(s)?s.__abortController.abort(new Error("evicted")):(this.#v||this.#e)&&(this.#v&&this.#o?.(s,n,"evict"),this.#e&&this.#m?.push([s,n,"evict"])),this.#B(r),this.#y?.[r]&&(clearTimeout(this.#y[r]),this.#y[r]=void 0),t&&(this.#c[r]=void 0,this.#n[r]=void 0,this.#T.push(r)),this.#a===1?(this.#w=this.#h=0,this.#T.length=0):this.#w=this.#d[r],this.#p.delete(n),this.#a--,r}has(t,r={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:s}=r,o=this.#p.get(t);if(o!==void 0){let i=this.#n[o];if(this.#u(i)&&i.__staleWhileFetching===void 0)return!1;if(this.#x(o))s&&(s.has="stale",this.#N(s,o));else return n&&this.#F(o),s&&(s.has="hit",this.#N(s,o)),!0}else s&&(s.has="miss");return!1}peek(t,r={}){let{allowStale:n=this.allowStale}=r,s=this.#p.get(t);if(s===void 0||!n&&this.#x(s))return;let o=this.#n[s];return this.#u(o)?o.__staleWhileFetching:o}#G(t,r,n,s){let o=r===void 0?void 0:this.#n[r];if(this.#u(o))return o;let i=new Fn,{signal:a}=n;a?.addEventListener("abort",()=>i.abort(a.reason),{signal:i.signal});let c={signal:i.signal,options:n,context:s},u=(h,D=!1)=>{let{aborted:g}=i.signal,y=n.ignoreFetchAbort&&h!==void 0;if(n.status&&(g&&!D?(n.status.fetchAborted=!0,n.status.fetchError=i.signal.reason,y&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),g&&!y&&!D)return p(i.signal.reason);let v=f,C=this.#n[r];return(C===f||y&&D&&C===void 0)&&(h===void 0?v.__staleWhileFetching!==void 0?this.#n[r]=v.__staleWhileFetching:this.#A(t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,h,c.options))),h},l=h=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=h),p(h)),p=h=>{let{aborted:D}=i.signal,g=D&&n.allowStaleOnFetchAbort,y=g||n.allowStaleOnFetchRejection,v=y||n.noDeleteOnFetchRejection,C=f;if(this.#n[r]===f&&(!v||C.__staleWhileFetching===void 0?this.#A(t,"fetch"):g||(this.#n[r]=C.__staleWhileFetching)),y)return n.status&&C.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),C.__staleWhileFetching;if(C.__returned===C)throw h},d=(h,D)=>{let g=this.#C?.(t,o,c);g&&g instanceof Promise&&g.then(y=>h(y===void 0?void 0:y),D),i.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(h(void 0),n.allowStaleOnFetchAbort&&(h=y=>u(y,!0)))})};n.status&&(n.status.fetchDispatched=!0);let f=new Promise(d).then(u,l),m=Object.assign(f,{__abortController:i,__staleWhileFetching:o,__returned:void 0});return r===void 0?(this.set(t,m,{...c.options,status:void 0}),r=this.#p.get(t)):this.#n[r]=m,m}#u(t){if(!this.#S)return!1;let r=t;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof Fn}async fetch(t,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:c=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:h,forceRefresh:D=!1,status:g,signal:y}=r;if(!this.#S)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:o,status:g});let v={allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:o,ttl:i,noDisposeOnSet:a,size:c,sizeCalculation:u,noUpdateTTL:l,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:m,ignoreFetchAbort:f,status:g,signal:y},C=this.#p.get(t);if(C===void 0){g&&(g.fetch="miss");let A=this.#G(t,C,v,h);return A.__returned=A}else{let A=this.#n[C];if(this.#u(A)){let Ae=n&&A.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",Ae&&(g.returnedStale=!0)),Ae?A.__staleWhileFetching:A.__returned=A}let lt=this.#x(C);if(!D&&!lt)return g&&(g.fetch="hit"),this.#$(C),s&&this.#F(C),g&&this.#N(g,C),A;let re=this.#G(t,C,v,h),Te=re.__staleWhileFetching!==void 0&&n;return g&&(g.fetch=lt?"stale":"refresh",Te&&lt&&(g.returnedStale=!0)),Te?re.__staleWhileFetching:re.__returned=re}}async forceFetch(t,r={}){let n=await this.fetch(t,r);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(t,r={}){let n=this.#D;if(!n)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:o,...i}=r,a=this.get(t,i);if(!o&&a!==void 0)return a;let c=n(t,a,{options:i,context:s});return this.set(t,c,i),c}get(t,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:i}=r,a=this.#p.get(t);if(a!==void 0){let c=this.#n[a],u=this.#u(c);return i&&this.#N(i,a),this.#x(a)?(i&&(i.get="stale"),u?(i&&n&&c.__staleWhileFetching!==void 0&&(i.returnedStale=!0),n?c.__staleWhileFetching:void 0):(o||this.#A(t,"expire"),i&&n&&(i.returnedStale=!0),n?c:void 0)):(i&&(i.get="hit"),u?c.__staleWhileFetching:(this.#$(a),s&&this.#F(a),c))}else i&&(i.get="miss")}#H(t,r){this.#b[r]=t,this.#d[t]=r}#$(t){t!==this.#h&&(t===this.#w?this.#w=this.#d[t]:this.#H(this.#b[t],this.#d[t]),this.#H(this.#h,t),this.#h=t)}delete(t){return this.#A(t,"delete")}#A(t,r){let n=!1;if(this.#a!==0){let s=this.#p.get(t);if(s!==void 0)if(this.#y?.[s]&&(clearTimeout(this.#y?.[s]),this.#y[s]=void 0),n=!0,this.#a===1)this.#z(r);else{this.#B(s);let o=this.#n[s];if(this.#u(o)?o.__abortController.abort(new Error("deleted")):(this.#v||this.#e)&&(this.#v&&this.#o?.(o,t,r),this.#e&&this.#m?.push([o,t,r])),this.#p.delete(t),this.#c[s]=void 0,this.#n[s]=void 0,s===this.#h)this.#h=this.#b[s];else if(s===this.#w)this.#w=this.#d[s];else{let i=this.#b[s];this.#d[i]=this.#d[s];let a=this.#d[s];this.#b[a]=this.#b[s]}this.#a--,this.#T.push(s)}}if(this.#e&&this.#m?.length){let s=this.#m,o;for(;o=s?.shift();)this.#i?.(...o)}return n}clear(){return this.#z("delete")}#z(t){for(let r of this.#R({allowStale:!0})){let n=this.#n[r];if(this.#u(n))n.__abortController.abort(new Error("deleted"));else{let s=this.#c[r];this.#v&&this.#o?.(n,s,t),this.#e&&this.#m?.push([n,s,t])}}if(this.#p.clear(),this.#n.fill(void 0),this.#c.fill(void 0),this.#g&&this.#E){this.#g.fill(0),this.#E.fill(0);for(let r of this.#y??[])r!==void 0&&clearTimeout(r);this.#y?.fill(void 0)}if(this.#k&&this.#k.fill(0),this.#w=0,this.#h=0,this.#T.length=0,this.#f=0,this.#a=0,this.#e&&this.#m){let r=this.#m,n;for(;n=r?.shift();)this.#i?.(...n)}}};var _e=require("node:path"),sc=require("node:url"),It=require("fs"),pm=b(require("node:fs"),1),ce=require("node:fs/promises");var On=require("node:events"),Do=b(require("node:stream"),1),Qa=require("node:string_decoder"),qa=typeof process=="object"&&process?process:{stdout:null,stderr:null},rm=e=>!!e&&typeof e=="object"&&(e instanceof ae||e instanceof Do.default||nm(e)||sm(e)),nm=e=>!!e&&typeof e=="object"&&e instanceof On.EventEmitter&&typeof e.pipe=="function"&&e.pipe!==Do.default.Writable.prototype.pipe,sm=e=>!!e&&typeof e=="object"&&e instanceof On.EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",zt=Symbol("EOF"),Kt=Symbol("maybeEmitEnd"),ie=Symbol("emittedEnd"),Tn=Symbol("emittingEnd"),Mr=Symbol("emittedError"),An=Symbol("closed"),Ya=Symbol("read"),Pn=Symbol("flush"),Za=Symbol("flushChunk"),yt=Symbol("encoding"),Be=Symbol("decoder"),_=Symbol("flowing"),$r=Symbol("paused"),je=Symbol("resume"),L=Symbol("buffer"),Y=Symbol("pipes"),W=Symbol("bufferLength"),lo=Symbol("bufferPush"),Rn=Symbol("bufferShift"),U=Symbol("objectMode"),M=Symbol("destroyed"),po=Symbol("error"),fo=Symbol("emitData"),Xa=Symbol("emitEnd"),ho=Symbol("emitEnd2"),Pt=Symbol("async"),mo=Symbol("abort"),In=Symbol("aborted"),Br=Symbol("signal"),we=Symbol("dataListeners"),it=Symbol("discarded"),jr=e=>Promise.resolve().then(e),om=e=>e(),im=e=>e==="end"||e==="finish"||e==="prefinish",am=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,cm=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),Nn=class{src;dest;opts;ondrain;constructor(t,r,n){this.src=t,this.dest=r,this.opts=n,this.ondrain=()=>t[je](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},go=class extends Nn{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,r,n){super(t,r,n),this.proxyErrors=s=>r.emit("error",s),t.on("error",this.proxyErrors)}},um=e=>!!e.objectMode,lm=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",ae=class extends On.EventEmitter{[_]=!1;[$r]=!1;[Y]=[];[L]=[];[U];[yt];[Pt];[Be];[zt]=!1;[ie]=!1;[Tn]=!1;[An]=!1;[Mr]=null;[W]=0;[M]=!1;[Br];[In]=!1;[we]=0;[it]=!1;writable=!0;readable=!0;constructor(...t){let r=t[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");um(r)?(this[U]=!0,this[yt]=null):lm(r)?(this[yt]=r.encoding,this[U]=!1):(this[U]=!1,this[yt]=null),this[Pt]=!!r.async,this[Be]=this[yt]?new Qa.StringDecoder(this[yt]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[L]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Y]});let{signal:n}=r;n&&(this[Br]=n,n.aborted?this[mo]():n.addEventListener("abort",()=>this[mo]()))}get bufferLength(){return this[W]}get encoding(){return this[yt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[U]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Pt]}set async(t){this[Pt]=this[Pt]||!!t}[mo](){this[In]=!0,this.emit("abort",this[Br]?.reason),this.destroy(this[Br]?.reason)}get aborted(){return this[In]}set aborted(t){}write(t,r,n){if(this[In])return!1;if(this[zt])throw new Error("write after end");if(this[M])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(n=r,r="utf8"),r||(r="utf8");let s=this[Pt]?jr:om;if(!this[U]&&!Buffer.isBuffer(t)){if(cm(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(am(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[U]?(this[_]&&this[W]!==0&&this[Pn](!0),this[_]?this.emit("data",t):this[lo](t),this[W]!==0&&this.emit("readable"),n&&s(n),this[_]):t.length?(typeof t=="string"&&!(r===this[yt]&&!this[Be]?.lastNeed)&&(t=Buffer.from(t,r)),Buffer.isBuffer(t)&&this[yt]&&(t=this[Be].write(t)),this[_]&&this[W]!==0&&this[Pn](!0),this[_]?this.emit("data",t):this[lo](t),this[W]!==0&&this.emit("readable"),n&&s(n),this[_]):(this[W]!==0&&this.emit("readable"),n&&s(n),this[_])}read(t){if(this[M])return null;if(this[it]=!1,this[W]===0||t===0||t&&t>this[W])return this[Kt](),null;this[U]&&(t=null),this[L].length>1&&!this[U]&&(this[L]=[this[yt]?this[L].join(""):Buffer.concat(this[L],this[W])]);let r=this[Ya](t||null,this[L][0]);return this[Kt](),r}[Ya](t,r){if(this[U])this[Rn]();else{let n=r;t===n.length||t===null?this[Rn]():typeof n=="string"?(this[L][0]=n.slice(t),r=n.slice(0,t),this[W]-=t):(this[L][0]=n.subarray(t),r=n.subarray(0,t),this[W]-=t)}return this.emit("data",r),!this[L].length&&!this[zt]&&this.emit("drain"),r}end(t,r,n){return typeof t=="function"&&(n=t,t=void 0),typeof r=="function"&&(n=r,r="utf8"),t!==void 0&&this.write(t,r),n&&this.once("end",n),this[zt]=!0,this.writable=!1,(this[_]||!this[$r])&&this[Kt](),this}[je](){this[M]||(!this[we]&&!this[Y].length&&(this[it]=!0),this[$r]=!1,this[_]=!0,this.emit("resume"),this[L].length?this[Pn]():this[zt]?this[Kt]():this.emit("drain"))}resume(){return this[je]()}pause(){this[_]=!1,this[$r]=!0,this[it]=!1}get destroyed(){return this[M]}get flowing(){return this[_]}get paused(){return this[$r]}[lo](t){this[U]?this[W]+=1:this[W]+=t.length,this[L].push(t)}[Rn](){return this[U]?this[W]-=1:this[W]-=this[L][0].length,this[L].shift()}[Pn](t=!1){do;while(this[Za](this[Rn]())&&this[L].length);!t&&!this[L].length&&!this[zt]&&this.emit("drain")}[Za](t){return this.emit("data",t),this[_]}pipe(t,r){if(this[M])return t;this[it]=!1;let n=this[ie];return r=r||{},t===qa.stdout||t===qa.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,n?r.end&&t.end():(this[Y].push(r.proxyErrors?new go(this,t,r):new Nn(this,t,r)),this[Pt]?jr(()=>this[je]()):this[je]()),t}unpipe(t){let r=this[Y].find(n=>n.dest===t);r&&(this[Y].length===1?(this[_]&&this[we]===0&&(this[_]=!1),this[Y]=[]):this[Y].splice(this[Y].indexOf(r),1),r.unpipe())}addListener(t,r){return this.on(t,r)}on(t,r){let n=super.on(t,r);if(t==="data")this[it]=!1,this[we]++,!this[Y].length&&!this[_]&&this[je]();else if(t==="readable"&&this[W]!==0)super.emit("readable");else if(im(t)&&this[ie])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Mr]){let s=r;this[Pt]?jr(()=>s.call(this,this[Mr])):s.call(this,this[Mr])}return n}removeListener(t,r){return this.off(t,r)}off(t,r){let n=super.off(t,r);return t==="data"&&(this[we]=this.listeners("data").length,this[we]===0&&!this[it]&&!this[Y].length&&(this[_]=!1)),n}removeAllListeners(t){let r=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[we]=0,!this[it]&&!this[Y].length&&(this[_]=!1)),r}get emittedEnd(){return this[ie]}[Kt](){!this[Tn]&&!this[ie]&&!this[M]&&this[L].length===0&&this[zt]&&(this[Tn]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[An]&&this.emit("close"),this[Tn]=!1)}emit(t,...r){let n=r[0];if(t!=="error"&&t!=="close"&&t!==M&&this[M])return!1;if(t==="data")return!this[U]&&!n?!1:this[Pt]?(jr(()=>this[fo](n)),!0):this[fo](n);if(t==="end")return this[Xa]();if(t==="close"){if(this[An]=!0,!this[ie]&&!this[M])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Mr]=n,super.emit(po,n);let o=!this[Br]||this.listeners("error").length?super.emit("error",n):!1;return this[Kt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Kt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let s=super.emit(t,...r);return this[Kt](),s}[fo](t){for(let n of this[Y])n.dest.write(t)===!1&&this.pause();let r=this[it]?!1:super.emit("data",t);return this[Kt](),r}[Xa](){return this[ie]?!1:(this[ie]=!0,this.readable=!1,this[Pt]?(jr(()=>this[ho]()),!0):this[ho]())}[ho](){if(this[Be]){let r=this[Be].end();if(r){for(let n of this[Y])n.dest.write(r);this[it]||super.emit("data",r)}}for(let r of this[Y])r.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[U]||(t.dataLength=0);let r=this.promise();return this.on("data",n=>{t.push(n),this[U]||(t.dataLength+=n.length)}),await r,t}async concat(){if(this[U])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[yt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,r)=>{this.on(M,()=>r(new Error("stream destroyed"))),this.on("error",n=>r(n)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[it]=!1;let t=!1,r=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return r();let s=this.read();if(s!==null)return Promise.resolve({done:!1,value:s});if(this[zt])return r();let o,i,a=p=>{this.off("data",c),this.off("end",u),this.off(M,l),r(),i(p)},c=p=>{this.off("error",a),this.off("end",u),this.off(M,l),this.pause(),o({value:p,done:!!this[zt]})},u=()=>{this.off("error",a),this.off("data",c),this.off(M,l),r(),o({done:!0,value:void 0})},l=()=>a(new Error("stream destroyed"));return new Promise((p,d)=>{i=d,o=p,this.once(M,l),this.once("error",a),this.once("end",u),this.once("data",c)})},throw:r,return:r,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[it]=!1;let t=!1,r=()=>(this.pause(),this.off(po,r),this.off(M,r),this.off("end",r),t=!0,{done:!0,value:void 0}),n=()=>{if(t)return r();let s=this.read();return s===null?r():{done:!1,value:s}};return this.once("end",r),this.once(po,r),this.once(M,r),{next:n,throw:r,return:r,[Symbol.iterator](){return this}}}destroy(t){if(this[M])return t?this.emit("error",t):this.emit(M),this;this[M]=!0,this[it]=!0,this[L].length=0,this[W]=0;let r=this;return typeof r.close=="function"&&!this[An]&&r.close(),t?this.emit("error",t):this.emit(M),this}static get isStream(){return rm}};var fm=It.realpathSync.native,Lr={lstatSync:It.lstatSync,readdir:It.readdir,readdirSync:It.readdirSync,readlinkSync:It.readlinkSync,realpathSync:fm,promises:{lstat:ce.lstat,readdir:ce.readdir,readlink:ce.readlink,realpath:ce.realpath}},oc=e=>!e||e===Lr||e===pm?Lr:{...Lr,...e,promises:{...Lr.promises,...e.promises||{}}},ic=/^\\\\\?\\([a-z]:)\\?$/i,dm=e=>e.replace(/\//g,"\\").replace(ic,"$1\\"),hm=/[\\\/]/,ht=0,ac=1,cc=2,Rt=4,uc=6,lc=8,Ce=10,pc=12,dt=15,_r=~dt,yo=16,tc=32,Wr=64,wt=128,Mn=256,Bn=512,ec=Wr|wt|Bn,mm=1023,wo=e=>e.isFile()?lc:e.isDirectory()?Rt:e.isSymbolicLink()?Ce:e.isCharacterDevice()?cc:e.isBlockDevice()?uc:e.isSocket()?pc:e.isFIFO()?ac:ht,rc=new ye({max:2**12}),Gr=e=>{let t=rc.get(e);if(t)return t;let r=e.normalize("NFKD");return rc.set(e,r),r},nc=new ye({max:2**12}),$n=e=>{let t=nc.get(e);if(t)return t;let r=Gr(e.toLowerCase());return nc.set(e,r),r},jn=class extends ye{constructor(){super({max:256})}},Co=class extends ye{constructor(t=16*1024){super({maxSize:t,sizeCalculation:r=>r.length+1})}},fc=Symbol("PathScurry setAsCwd"),z=class{name;root;roots;parent;nocase;isCWD=!1;#t;#r;get dev(){return this.#r}#o;get mode(){return this.#o}#s;get nlink(){return this.#s}#i;get uid(){return this.#i}#C;get gid(){return this.#C}#D;get rdev(){return this.#D}#l;get blksize(){return this.#l}#a;get ino(){return this.#a}#f;get size(){return this.#f}#p;get blocks(){return this.#p}#c;get atimeMs(){return this.#c}#n;get mtimeMs(){return this.#n}#d;get ctimeMs(){return this.#d}#b;get birthtimeMs(){return this.#b}#w;get atime(){return this.#w}#h;get mtime(){return this.#h}#T;get ctime(){return this.#T}#m;get birthtime(){return this.#m}#k;#E;#g;#y;#v;#S;#e;#O;#I;#F;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,r=ht,n,s,o,i,a){this.name=t,this.#k=o?$n(t):Gr(t),this.#e=r&mm,this.nocase=o,this.roots=s,this.root=n||this,this.#O=i,this.#g=a.fullpath,this.#v=a.relative,this.#S=a.relativePosix,this.parent=a.parent,this.parent?this.#t=this.parent.#t:this.#t=oc(a.fs)}depth(){return this.#E!==void 0?this.#E:this.parent?this.#E=this.parent.depth()+1:this.#E=0}childrenCache(){return this.#O}resolve(t){if(!t)return this;let r=this.getRootString(t),s=t.substring(r.length).split(this.splitSep);return r?this.getRoot(r).#N(s):this.#N(s)}#N(t){let r=this;for(let n of t)r=r.child(n);return r}children(){let t=this.#O.get(this);if(t)return t;let r=Object.assign([],{provisional:0});return this.#O.set(this,r),this.#e&=~yo,r}child(t,r){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let n=this.children(),s=this.nocase?$n(t):Gr(t);for(let c of n)if(c.#k===s)return c;let o=this.parent?this.sep:"",i=this.#g?this.#g+o+t:void 0,a=this.newChild(t,ht,{...r,parent:this,fullpath:i});return this.canReaddir()||(a.#e|=wt),n.push(a),a}relative(){if(this.isCWD)return"";if(this.#v!==void 0)return this.#v;let t=this.name,r=this.parent;if(!r)return this.#v=this.name;let n=r.relative();return n+(!n||!r.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#S!==void 0)return this.#S;let t=this.name,r=this.parent;if(!r)return this.#S=this.fullpathPosix();let n=r.relativePosix();return n+(!n||!r.parent?"":"/")+t}fullpath(){if(this.#g!==void 0)return this.#g;let t=this.name,r=this.parent;if(!r)return this.#g=this.name;let s=r.fullpath()+(r.parent?this.sep:"")+t;return this.#g=s}fullpathPosix(){if(this.#y!==void 0)return this.#y;if(this.sep==="/")return this.#y=this.fullpath();if(!this.parent){let s=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(s)?this.#y=`//?/${s}`:this.#y=s}let t=this.parent,r=t.fullpathPosix(),n=r+(!r||!t.parent?"":"/")+this.name;return this.#y=n}isUnknown(){return(this.#e&dt)===ht}isType(t){return this[`is${t}`]()}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.#e&dt)===lc}isDirectory(){return(this.#e&dt)===Rt}isCharacterDevice(){return(this.#e&dt)===cc}isBlockDevice(){return(this.#e&dt)===uc}isFIFO(){return(this.#e&dt)===ac}isSocket(){return(this.#e&dt)===pc}isSymbolicLink(){return(this.#e&Ce)===Ce}lstatCached(){return this.#e&tc?this:void 0}readlinkCached(){return this.#I}realpathCached(){return this.#F}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#I)return!0;if(!this.parent)return!1;let t=this.#e&dt;return!(t!==ht&&t!==Ce||this.#e&Mn||this.#e&wt)}calledReaddir(){return!!(this.#e&yo)}isENOENT(){return!!(this.#e&wt)}isNamed(t){return this.nocase?this.#k===$n(t):this.#k===Gr(t)}async readlink(){let t=this.#I;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=await this.#t.promises.readlink(this.fullpath()),n=(await this.parent.realpath())?.resolve(r);if(n)return this.#I=n}catch(r){this.#R(r.code);return}}readlinkSync(){let t=this.#I;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=this.#t.readlinkSync(this.fullpath()),n=this.parent.realpathSync()?.resolve(r);if(n)return this.#I=n}catch(r){this.#R(r.code);return}}#j(t){this.#e|=yo;for(let r=t.provisional;r<t.length;r++){let n=t[r];n&&n.#x()}}#x(){this.#e&wt||(this.#e=(this.#e|wt)&_r,this.#U())}#U(){let t=this.children();t.provisional=0;for(let r of t)r.#x()}#B(){this.#e|=Bn,this.#M()}#M(){if(this.#e&Wr)return;let t=this.#e;(t&dt)===Rt&&(t&=_r),this.#e=t|Wr,this.#U()}#_(t=""){t==="ENOTDIR"||t==="EPERM"?this.#M():t==="ENOENT"?this.#x():this.children().provisional=0}#P(t=""){t==="ENOTDIR"?this.parent.#M():t==="ENOENT"&&this.#x()}#R(t=""){let r=this.#e;r|=Mn,t==="ENOENT"&&(r|=wt),(t==="EINVAL"||t==="UNKNOWN")&&(r&=_r),this.#e=r,t==="ENOTDIR"&&this.parent&&this.parent.#M()}#L(t,r){return this.#G(t,r)||this.#W(t,r)}#W(t,r){let n=wo(t),s=this.newChild(t.name,n,{parent:this}),o=s.#e&dt;return o!==Rt&&o!==Ce&&o!==ht&&(s.#e|=Wr),r.unshift(s),r.provisional++,s}#G(t,r){for(let n=r.provisional;n<r.length;n++){let s=r[n];if((this.nocase?$n(t.name):Gr(t.name))===s.#k)return this.#u(t,s,n,r)}}#u(t,r,n,s){let o=r.name;return r.#e=r.#e&_r|wo(t),o!==t.name&&(r.name=t.name),n!==s.provisional&&(n===s.length-1?s.pop():s.splice(n,1),s.unshift(r)),s.provisional++,r}async lstat(){if((this.#e&wt)===0)try{return this.#H(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#P(t.code)}}lstatSync(){if((this.#e&wt)===0)try{return this.#H(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#P(t.code)}}#H(t){let{atime:r,atimeMs:n,birthtime:s,birthtimeMs:o,blksize:i,blocks:a,ctime:c,ctimeMs:u,dev:l,gid:p,ino:d,mode:f,mtime:m,mtimeMs:h,nlink:D,rdev:g,size:y,uid:v}=t;this.#w=r,this.#c=n,this.#m=s,this.#b=o,this.#l=i,this.#p=a,this.#T=c,this.#d=u,this.#r=l,this.#C=p,this.#a=d,this.#o=f,this.#h=m,this.#n=h,this.#s=D,this.#D=g,this.#f=y,this.#i=v;let C=wo(t);this.#e=this.#e&_r|C|tc,C!==ht&&C!==Rt&&C!==Ce&&(this.#e|=Wr)}#$=[];#A=!1;#z(t){this.#A=!1;let r=this.#$.slice();this.#$.length=0,r.forEach(n=>n(null,t))}readdirCB(t,r=!1){if(!this.canReaddir()){r?t(null,[]):queueMicrotask(()=>t(null,[]));return}let n=this.children();if(this.calledReaddir()){let o=n.slice(0,n.provisional);r?t(null,o):queueMicrotask(()=>t(null,o));return}if(this.#$.push(t),this.#A)return;this.#A=!0;let s=this.fullpath();this.#t.readdir(s,{withFileTypes:!0},(o,i)=>{if(o)this.#_(o.code),n.provisional=0;else{for(let a of i)this.#L(a,n);this.#j(n)}this.#z(n.slice(0,n.provisional))})}#K;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();if(this.#K)await this.#K;else{let n=()=>{};this.#K=new Promise(s=>n=s);try{for(let s of await this.#t.promises.readdir(r,{withFileTypes:!0}))this.#L(s,t);this.#j(t)}catch(s){this.#_(s.code),t.provisional=0}this.#K=void 0,n()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();try{for(let n of this.#t.readdirSync(r,{withFileTypes:!0}))this.#L(n,t);this.#j(t)}catch(n){this.#_(n.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#e&ec)return!1;let t=dt&this.#e;return t===ht||t===Rt||t===Ce}shouldWalk(t,r){return(this.#e&Rt)===Rt&&!(this.#e&ec)&&!t.has(this)&&(!r||r(this))}async realpath(){if(this.#F)return this.#F;if(!((Bn|Mn|wt)&this.#e))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#F=this.resolve(t)}catch{this.#B()}}realpathSync(){if(this.#F)return this.#F;if(!((Bn|Mn|wt)&this.#e))try{let t=this.#t.realpathSync(this.fullpath());return this.#F=this.resolve(t)}catch{this.#B()}}[fc](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let r=new Set([]),n=[],s=this;for(;s&&s.parent;)r.add(s),s.#v=n.join(this.sep),s.#S=n.join("/"),s=s.parent,n.push("..");for(s=t;s&&s.parent&&!r.has(s);)s.#v=void 0,s.#S=void 0,s=s.parent}},_n=class e extends z{sep="\\";splitSep=hm;constructor(t,r=ht,n,s,o,i,a){super(t,r,n,s,o,i,a)}newChild(t,r=ht,n={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(t){return _e.win32.parse(t).root}getRoot(t){if(t=dm(t.toUpperCase()),t===this.root.name)return this.root;for(let[r,n]of Object.entries(this.roots))if(this.sameRoot(t,r))return this.roots[t]=n;return this.roots[t]=new Le(t,this).root}sameRoot(t,r=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(ic,"$1\\"),t===r}},Ln=class e extends z{splitSep="/";sep="/";constructor(t,r=ht,n,s,o,i,a){super(t,r,n,s,o,i,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,r=ht,n={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}},Wn=class{root;rootPath;roots;cwd;#t;#r;#o;nocase;#s;constructor(t=process.cwd(),r,n,{nocase:s,childrenCacheSize:o=16*1024,fs:i=Lr}={}){this.#s=oc(i),(t instanceof URL||t.startsWith("file://"))&&(t=(0,sc.fileURLToPath)(t));let a=r.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#t=new jn,this.#r=new jn,this.#o=new Co(o);let c=a.substring(this.rootPath.length).split(n);if(c.length===1&&!c[0]&&c.pop(),s===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=s,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let u=this.root,l=c.length-1,p=r.sep,d=this.rootPath,f=!1;for(let m of c){let h=l--;u=u.child(m,{relative:new Array(h).fill("..").join(p),relativePosix:new Array(h).fill("..").join("/"),fullpath:d+=(f?"":p)+m}),f=!0}this.cwd=u}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#o}resolve(...t){let r="";for(let o=t.length-1;o>=0;o--){let i=t[o];if(!(!i||i===".")&&(r=r?`${i}/${r}`:i,this.isAbsolute(i)))break}let n=this.#t.get(r);if(n!==void 0)return n;let s=this.cwd.resolve(r).fullpath();return this.#t.set(r,s),s}resolvePosix(...t){let r="";for(let o=t.length-1;o>=0;o--){let i=t[o];if(!(!i||i===".")&&(r=r?`${i}/${r}`:i,this.isAbsolute(i)))break}let n=this.#r.get(r);if(n!==void 0)return n;let s=this.cwd.resolve(r).fullpathPosix();return this.#r.set(r,s),s}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n}=r;if(t.canReaddir()){let s=await t.readdir();return n?s:s.map(o=>o.name)}else return[]}readdirSync(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0}=r;return t.canReaddir()?n?t.readdirSync():t.readdirSync().map(s=>s.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t.withFileTypes,t=this.cwd);let n=await t.readlink();return r?n:n?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t.withFileTypes,t=this.cwd);let n=t.readlinkSync();return r?n:n?.fullpath()}async realpath(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t.withFileTypes,t=this.cwd);let n=await t.realpath();return r?n:n?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t.withFileTypes,t=this.cwd);let n=t.realpathSync();return r?n:n?.fullpath()}async walk(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=[];(!o||o(t))&&a.push(n?t:t.fullpath());let c=new Set,u=(p,d)=>{c.add(p),p.readdirCB((f,m)=>{if(f)return d(f);let h=m.length;if(!h)return d();let D=()=>{--h===0&&d()};for(let g of m)(!o||o(g))&&a.push(n?g:g.fullpath()),s&&g.isSymbolicLink()?g.realpath().then(y=>y?.isUnknown()?y.lstat():y).then(y=>y?.shouldWalk(c,i)?u(y,D):D()):g.shouldWalk(c,i)?u(g,D):D()},!0)},l=t;return new Promise((p,d)=>{u(l,f=>{if(f)return d(f);p(a)})})}walkSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=[];(!o||o(t))&&a.push(n?t:t.fullpath());let c=new Set([t]);for(let u of c){let l=u.readdirSync();for(let p of l){(!o||o(p))&&a.push(n?p:p.fullpath());let d=p;if(p.isSymbolicLink()){if(!(s&&(d=p.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(c,i)&&c.add(d)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,r={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd),this.stream(t,r)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r;(!o||o(t))&&(yield n?t:t.fullpath());let a=new Set([t]);for(let c of a){let u=c.readdirSync();for(let l of u){(!o||o(l))&&(yield n?l:l.fullpath());let p=l;if(l.isSymbolicLink()){if(!(s&&(p=l.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(a,i)&&a.add(p)}}}stream(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=new ae({objectMode:!0});(!o||o(t))&&a.write(n?t:t.fullpath());let c=new Set,u=[t],l=0,p=()=>{let d=!1;for(;!d;){let f=u.shift();if(!f){l===0&&a.end();return}l++,c.add(f);let m=(D,g,y=!1)=>{if(D)return a.emit("error",D);if(s&&!y){let v=[];for(let C of g)C.isSymbolicLink()&&v.push(C.realpath().then(A=>A?.isUnknown()?A.lstat():A));if(v.length){Promise.all(v).then(()=>m(null,g,!0));return}}for(let v of g)v&&(!o||o(v))&&(a.write(n?v:v.fullpath())||(d=!0));l--;for(let v of g){let C=v.realpathCached()||v;C.shouldWalk(c,i)&&u.push(C)}d&&!a.flowing?a.once("drain",p):h||p()},h=!0;f.readdirCB(m,!0),h=!1}};return p(),a}streamSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=new ae({objectMode:!0}),c=new Set;(!o||o(t))&&a.write(n?t:t.fullpath());let u=[t],l=0,p=()=>{let d=!1;for(;!d;){let f=u.shift();if(!f){l===0&&a.end();return}l++,c.add(f);let m=f.readdirSync();for(let h of m)(!o||o(h))&&(a.write(n?h:h.fullpath())||(d=!0));l--;for(let h of m){let D=h;if(h.isSymbolicLink()){if(!(s&&(D=h.realpathSync())))continue;D.isUnknown()&&D.lstatSync()}D.shouldWalk(c,i)&&u.push(D)}}d&&!a.flowing&&a.once("drain",p)};return p(),a}chdir(t=this.cwd){let r=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[fc](r)}},Le=class extends Wn{sep="\\";constructor(t=process.cwd(),r={}){let{nocase:n=!0}=r;super(t,_e.win32,"\\",{...r,nocase:n}),this.nocase=n;for(let s=this.cwd;s;s=s.parent)s.nocase=this.nocase}parseRootPath(t){return _e.win32.parse(t).root.toUpperCase()}newRoot(t){return new _n(this.rootPath,Rt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},We=class extends Wn{sep="/";constructor(t=process.cwd(),r={}){let{nocase:n=!1}=r;super(t,_e.posix,"/",{...r,nocase:n}),this.nocase=n}parseRootPath(t){return"/"}newRoot(t){return new Ln(this.rootPath,Rt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Hr=class extends We{constructor(t=process.cwd(),r={}){let{nocase:n=!0}=r;super(t,{...r,nocase:n})}},Hb=process.platform==="win32"?_n:Ln,dc=process.platform==="win32"?Le:process.platform==="darwin"?Hr:We;var gm=e=>e.length>=1,Dm=e=>e.length>=1,Ge=class e{#t;#r;#o;length;#s;#i;#C;#D;#l;#a;#f=!0;constructor(t,r,n,s){if(!gm(t))throw new TypeError("empty pattern list");if(!Dm(r))throw new TypeError("empty glob list");if(r.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,n<0||n>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#r=r,this.#o=n,this.#s=s,this.#o===0){if(this.isUNC()){let[o,i,a,c,...u]=this.#t,[l,p,d,f,...m]=this.#r;u[0]===""&&(u.shift(),m.shift());let h=[o,i,a,c,""].join("/"),D=[l,p,d,f,""].join("/");this.#t=[h,...u],this.#r=[D,...m],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[o,...i]=this.#t,[a,...c]=this.#r;i[0]===""&&(i.shift(),c.shift());let u=o+"/",l=a+"/";this.#t=[u,...i],this.#r=[l,...c],this.length=this.#t.length}}}pattern(){return this.#t[this.#o]}isString(){return typeof this.#t[this.#o]=="string"}isGlobstar(){return this.#t[this.#o]===H}isRegExp(){return this.#t[this.#o]instanceof RegExp}globString(){return this.#C=this.#C||(this.#o===0?this.isAbsolute()?this.#r[0]+this.#r.slice(1).join("/"):this.#r.join("/"):this.#r.slice(this.#o).join("/"))}hasMore(){return this.length>this.#o+1}rest(){return this.#i!==void 0?this.#i:this.hasMore()?(this.#i=new e(this.#t,this.#r,this.#o+1,this.#s),this.#i.#a=this.#a,this.#i.#l=this.#l,this.#i.#D=this.#D,this.#i):this.#i=null}isUNC(){let t=this.#t;return this.#l!==void 0?this.#l:this.#l=this.#s==="win32"&&this.#o===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#D!==void 0?this.#D:this.#D=this.#s==="win32"&&this.#o===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#a!==void 0?this.#a:this.#a=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#o===0?t:""}checkFollowGlobstar(){return!(this.#o===0||!this.isGlobstar()||!this.#f)}markFollowGlobstar(){return this.#o===0||!this.isGlobstar()||!this.#f?!1:(this.#f=!1,!0)}};var ym=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",He=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:r,nocase:n,noext:s,noglobstar:o,platform:i=ym}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=i,this.mmopts={dot:!0,nobrace:r,nocase:n,noext:s,noglobstar:o,optimizationLevel:2,platform:i,nocomment:!0,nonegate:!0};for(let a of t)this.add(a)}add(t){let r=new ot(t,this.mmopts);for(let n=0;n<r.set.length;n++){let s=r.set[n],o=r.globParts[n];if(!s||!o)throw new Error("invalid pattern object");for(;s[0]==="."&&o[0]===".";)s.shift(),o.shift();let i=new Ge(s,o,0,this.platform),a=new ot(i.globString(),this.mmopts),c=o[o.length-1]==="**",u=i.isAbsolute();u?this.absolute.push(a):this.relative.push(a),c&&(u?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(t){let r=t.fullpath(),n=`${r}/`,s=t.relative()||".",o=`${s}/`;for(let i of this.relative)if(i.match(s)||i.match(o))return!0;for(let i of this.absolute)if(i.match(r)||i.match(n))return!0;return!1}childrenIgnored(t){let r=t.fullpath()+"/",n=(t.relative()||".")+"/";for(let s of this.relativeChildren)if(s.match(n))return!0;for(let s of this.absoluteChildren)if(s.match(r))return!0;return!1}};var bo=class e{store;constructor(t=new Map){this.store=t}copy(){return new e(new Map(this.store))}hasWalked(t,r){return this.store.get(t.fullpath())?.has(r.globString())}storeWalked(t,r){let n=t.fullpath(),s=this.store.get(n);s?s.add(r.globString()):this.store.set(n,new Set([r.globString()]))}},vo=class{store=new Map;add(t,r,n){let s=(r?2:0)|(n?1:0),o=this.store.get(t);this.store.set(t,o===void 0?s:s&o)}entries(){return[...this.store.entries()].map(([t,r])=>[t,!!(r&2),!!(r&1)])}},xo=class{store=new Map;add(t,r){if(!t.canReaddir())return;let n=this.store.get(t);n?n.find(s=>s.globString()===r.globString())||n.push(r):this.store.set(t,[r])}get(t){let r=this.store.get(t);if(!r)throw new Error("attempting to walk unknown path");return r}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},Ur=class e{hasWalkedCache;matches=new vo;subwalks=new xo;patterns;follow;dot;opts;constructor(t,r){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=r?r.copy():new bo}processPatterns(t,r){this.patterns=r;let n=r.map(s=>[t,s]);for(let[s,o]of n){this.hasWalkedCache.storeWalked(s,o);let i=o.root(),a=o.isAbsolute()&&this.opts.absolute!==!1;if(i){s=s.resolve(i==="/"&&this.opts.root!==void 0?this.opts.root:i);let p=o.rest();if(p)o=p;else{this.matches.add(s,!0,!1);continue}}if(s.isENOENT())continue;let c,u,l=!1;for(;typeof(c=o.pattern())=="string"&&(u=o.rest());)s=s.resolve(c),o=u,l=!0;if(c=o.pattern(),u=o.rest(),l){if(this.hasWalkedCache.hasWalked(s,o))continue;this.hasWalkedCache.storeWalked(s,o)}if(typeof c=="string"){let p=c===".."||c===""||c===".";this.matches.add(s.resolve(c),a,p);continue}else if(c===H){(!s.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(s,o);let p=u?.pattern(),d=u?.rest();if(!u||(p===""||p===".")&&!d)this.matches.add(s,a,p===""||p===".");else if(p===".."){let f=s.parent||s;d?this.hasWalkedCache.hasWalked(f,d)||this.subwalks.add(f,d):this.matches.add(f,a,!0)}}else c instanceof RegExp&&this.subwalks.add(s,o)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new e(this.opts,this.hasWalkedCache)}filterEntries(t,r){let n=this.subwalks.get(t),s=this.child();for(let o of r)for(let i of n){let a=i.isAbsolute(),c=i.pattern(),u=i.rest();c===H?s.testGlobstar(o,i,u,a):c instanceof RegExp?s.testRegExp(o,c,u,a):s.testString(o,c,u,a)}return s}testGlobstar(t,r,n,s){if((this.dot||!t.name.startsWith("."))&&(r.hasMore()||this.matches.add(t,s,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,r):t.isSymbolicLink()&&(n&&r.checkFollowGlobstar()?this.subwalks.add(t,n):r.markFollowGlobstar()&&this.subwalks.add(t,r)))),n){let o=n.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,n.rest(),s);else if(o===".."){let i=t.parent||t;this.subwalks.add(i,n)}else o instanceof RegExp&&this.testRegExp(t,o,n.rest(),s)}}testRegExp(t,r,n,s){r.test(t.name)&&(n?this.subwalks.add(t,n):this.matches.add(t,s,!1))}testString(t,r,n,s){t.isNamed(r)&&(n?this.subwalks.add(t,n):this.matches.add(t,s,!1))}};var wm=(e,t)=>typeof e=="string"?new He([e],t):Array.isArray(e)?new He(e,t):e,Gn=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#r;#o;signal;maxDepth;includeChildMatches;constructor(t,r,n){if(this.patterns=t,this.path=r,this.opts=n,this.#o=!n.posix&&n.platform==="win32"?"\\":"/",this.includeChildMatches=n.includeChildMatches!==!1,(n.ignore||!this.includeChildMatches)&&(this.#r=wm(n.ignore??[],n),!this.includeChildMatches&&typeof this.#r.add!="function")){let s="cannot ignore child matches, ignore lacks add() method.";throw new Error(s)}this.maxDepth=n.maxDepth||1/0,n.signal&&(this.signal=n.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#s(t){return this.seen.has(t)||!!this.#r?.ignored?.(t)}#i(t){return!!this.#r?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#t.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t())}async matchCheck(t,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=t.realpathCached()||await t.realpath(),!n)return;t=n}let o=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let i=await o.realpath();i&&(i.isUnknown()||this.opts.stat)&&await i.lstat()}return this.matchCheckTest(o,r)}matchCheckTest(t,r){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!r||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#s(t)?t:void 0}matchCheckSync(t,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=t.realpathCached()||t.realpathSync(),!n)return;t=n}let o=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let i=o.realpathSync();i&&(i?.isUnknown()||this.opts.stat)&&i.lstatSync()}return this.matchCheckTest(o,r)}matchFinish(t,r){if(this.#s(t))return;if(!this.includeChildMatches&&this.#r?.add){let o=`${t.relativePosix()}/**`;this.#r.add(o)}let n=this.opts.absolute===void 0?r:this.opts.absolute;this.seen.add(t);let s=this.opts.mark&&t.isDirectory()?this.#o:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(n){let o=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(o+s)}else{let o=this.opts.posix?t.relativePosix():t.relative(),i=this.opts.dotRelative&&!o.startsWith(".."+this.#o)?"."+this.#o:"";this.matchEmit(o?i+o+s:"."+s)}}async match(t,r,n){let s=await this.matchCheck(t,n);s&&this.matchFinish(s,r)}matchSync(t,r,n){let s=this.matchCheckSync(t,n);s&&this.matchFinish(s,r)}walkCB(t,r,n){this.signal?.aborted&&n(),this.walkCB2(t,r,new Ur(this.opts),n)}walkCB2(t,r,n,s){if(this.#i(t))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2(t,r,n,s));return}n.processPatterns(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,u]of n.matches.entries())this.#s(a)||(o++,this.match(a,c,u).then(()=>i()));for(let a of n.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let c=a.readdirCached();a.calledReaddir()?this.walkCB3(a,c,n,i):a.readdirCB((u,l)=>this.walkCB3(a,l,n,i),!0)}i()}walkCB3(t,r,n,s){n=n.filterEntries(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,u]of n.matches.entries())this.#s(a)||(o++,this.match(a,c,u).then(()=>i()));for(let[a,c]of n.subwalks.entries())o++,this.walkCB2(a,c,n.child(),i);i()}walkCBSync(t,r,n){this.signal?.aborted&&n(),this.walkCB2Sync(t,r,new Ur(this.opts),n)}walkCB2Sync(t,r,n,s){if(this.#i(t))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2Sync(t,r,n,s));return}n.processPatterns(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,u]of n.matches.entries())this.#s(a)||this.matchSync(a,c,u);for(let a of n.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let c=a.readdirSync();this.walkCB3Sync(a,c,n,i)}i()}walkCB3Sync(t,r,n,s){n=n.filterEntries(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,u]of n.matches.entries())this.#s(a)||this.matchSync(a,c,u);for(let[a,c]of n.subwalks.entries())o++,this.walkCB2Sync(a,c,n.child(),i);i()}},zr=class extends Gn{matches=new Set;constructor(t,r,n){super(t,r,n)}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,r)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?r(this.signal.reason):t(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Kr=class extends Gn{results;constructor(t,r,n){super(t,r,n),this.results=new ae({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var Cm=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ct=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(t,r){if(!r)throw new TypeError("glob options required");if(this.withFileTypes=!!r.withFileTypes,this.signal=r.signal,this.follow=!!r.follow,this.dot=!!r.dot,this.dotRelative=!!r.dotRelative,this.nodir=!!r.nodir,this.mark=!!r.mark,r.cwd?(r.cwd instanceof URL||r.cwd.startsWith("file://"))&&(r.cwd=(0,hc.fileURLToPath)(r.cwd)):this.cwd="",this.cwd=r.cwd||"",this.root=r.root,this.magicalBraces=!!r.magicalBraces,this.nobrace=!!r.nobrace,this.noext=!!r.noext,this.realpath=!!r.realpath,this.absolute=r.absolute,this.includeChildMatches=r.includeChildMatches!==!1,this.noglobstar=!!r.noglobstar,this.matchBase=!!r.matchBase,this.maxDepth=typeof r.maxDepth=="number"?r.maxDepth:1/0,this.stat=!!r.stat,this.ignore=r.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(c=>c.replace(/\\/g,"/"))),this.matchBase){if(r.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=t,this.platform=r.platform||Cm,this.opts={...r,platform:this.platform},r.scurry){if(this.scurry=r.scurry,r.nocase!==void 0&&r.nocase!==r.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let c=r.platform==="win32"?Le:r.platform==="darwin"?Hr:r.platform?We:dc;this.scurry=new c(this.cwd,{nocase:r.nocase,fs:r.fs})}this.nocase=this.scurry.nocase;let n=this.platform==="darwin"||this.platform==="win32",s={...r,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:n,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},o=this.pattern.map(c=>new ot(c,s)),[i,a]=o.reduce((c,u)=>(c[0].push(...u.set),c[1].push(...u.globParts),c),[[],[]]);this.patterns=i.map((c,u)=>{let l=a[u];if(!l)throw new Error("invalid pattern object");return new Ge(c,l,0,this.platform)})}async walk(){return[...await new zr(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 zr(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 Kr(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 Kr(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 ko=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let r of e)if(new ot(r,t).hasMagic())return!0;return!1};function Un(e,t={}){return new Ct(e,t).streamSync()}function gc(e,t={}){return new Ct(e,t).stream()}function zn(e,t={}){return new Ct(e,t).walkSync()}async function mc(e,t={}){return new Ct(e,t).walk()}function Kn(e,t={}){return new Ct(e,t).iterateSync()}function Dc(e,t={}){return new Ct(e,t).iterate()}var bm=Un,vm=Object.assign(gc,{sync:Un}),xm=Kn,km=Object.assign(Dc,{sync:Kn}),Em=Object.assign(zn,{stream:Un,iterate:Kn}),Hn=Object.assign(mc,{glob:mc,globSync:zn,sync:Em,globStream:gc,stream:vm,globStreamSync:Un,streamSync:bm,globIterate:Dc,iterate:km,globIterateSync:Kn,iterateSync:xm,Glob:Ct,hasMagic:ko,escape:Me,unescape:Dt});Hn.glob=Hn;var ue=(e,t)=>typeof e>"u"||typeof e===t,yc=e=>!!e&&typeof e=="object"&&ue(e.preserveRoot,"boolean")&&ue(e.tmp,"string")&&ue(e.maxRetries,"number")&&ue(e.retryDelay,"number")&&ue(e.backoff,"number")&&ue(e.maxBackoff,"number")&&(ue(e.glob,"boolean")||e.glob&&typeof e.glob=="object")&&ue(e.filter,"function"),wc=e=>{if(!yc(e))throw new Error("invalid rimraf options")},Cc=e=>{wc(e);let{glob:t,...r}=e;if(!t)return r;let n=t===!0?e.signal?{signal:e.signal}:{}:e.signal?{signal:e.signal,...t}:t;return{...r,glob:{...n,absolute:!0,withFileTypes:!1}}},bc=(e={})=>Cc(e),vc=(e={})=>Cc(e);var Jr=require("path"),xc=require("util"),Sm=(e,t={})=>{let r=typeof e;if(r!=="string"){let s=e&&r==="object"&&e.constructor,i=`The "path" argument must be of type string. Received ${s&&s.name?`an instance of ${s.name}`:r==="object"?(0,xc.inspect)(e):`type ${r} ${e}`}`;throw Object.assign(new TypeError(i),{path:e,code:"ERR_INVALID_ARG_TYPE"})}if(/\0/.test(e)){let s="path must be a string without null bytes";throw Object.assign(new TypeError(s),{path:e,code:"ERR_INVALID_ARG_VALUE"})}e=(0,Jr.resolve)(e);let{root:n}=(0,Jr.parse)(e);if(e===n&&t.preserveRoot!==!1){let s="refusing to remove root directory without preserveRoot:false";throw Object.assign(new Error(s),{path:e,code:"ERR_PRESERVE_ROOT"})}if(process.platform==="win32"){let s=/[*|"<>?:]/,{root:o}=(0,Jr.parse)(e);if(s.test(e.substring(o.length)))throw Object.assign(new Error("Illegal characters in path."),{path:e,code:"EINVAL"})}return e},Vr=Sm;var kc=require("fs"),Nt=b(require("fs/promises"),1),k=require("fs"),Ec=e=>(0,kc.readdirSync)(e,{withFileTypes:!0}),et={chmod:Nt.default.chmod,mkdir:Nt.default.mkdir,readdir:e=>Nt.default.readdir(e,{withFileTypes:!0}),rename:Nt.default.rename,rm:Nt.default.rm,rmdir:Nt.default.rmdir,stat:Nt.default.stat,lstat:Nt.default.lstat,unlink:Nt.default.unlink};var Ke=require("path");var{readdir:Fm}=et,Ue=e=>Fm(e).catch(t=>t),ze=e=>{try{return Ec(e)}catch(t){return t}};var Sc=e=>!!e&&typeof e=="object",Eo=(e,t)=>t in e&&typeof e[t]=="string",So=e=>Sc(e)&&Eo(e,"code")&&Eo(e,"path"),I=e=>Sc(e)&&Eo(e,"code")?e.code:null;var Z=async(e,t)=>e.catch(r=>{if(I(r)!=="ENOENT")throw t??r}),X=(e,t)=>{try{return e()}catch(r){if(I(r)==="ENOENT")return;throw t??r}};var{lstat:Tm,rmdir:Am,unlink:Pm}=et,Jn=async(e,t)=>(t?.signal?.throwIfAborted(),await Z(Tm(e).then(r=>Fc(e,t,r)))??!0),Vn=(e,t)=>(t?.signal?.throwIfAborted(),X(()=>Tc(e,t,(0,k.lstatSync)(e)))??!0),Fc=async(e,t,r)=>{t?.signal?.throwIfAborted();let n=r.isDirectory()?await Ue(e):null;if(!Array.isArray(n)){if(n){if(I(n)==="ENOENT")return!0;if(I(n)!=="ENOTDIR")throw n}return t.filter&&!await t.filter(e,r)?!1:(await Z(Pm(e)),!0)}return!(await Promise.all(n.map(o=>Fc((0,Ke.resolve)(e,o.name),t,o)))).every(o=>o===!0)||t.preserveRoot===!1&&e===(0,Ke.parse)(e).root||t.filter&&!await t.filter(e,r)?!1:(await Z(Am(e)),!0)},Tc=(e,t,r)=>{t?.signal?.throwIfAborted();let n=r.isDirectory()?ze(e):null;if(!Array.isArray(n)){if(n){if(I(n)==="ENOENT")return!0;if(I(n)!=="ENOTDIR")throw n}return t.filter&&!t.filter(e,r)?!1:(X(()=>(0,k.unlinkSync)(e)),!0)}let s=!0;for(let o of n){let i=(0,Ke.resolve)(e,o.name);s=Tc(i,t,o)&&s}return t.preserveRoot===!1&&e===(0,Ke.parse)(e).root||!s||t.filter&&!t.filter(e,r)?!1:(X(()=>(0,k.rmdirSync)(e)),!0)};var Je=require("path");var{chmod:Rm}=et,qr=e=>async t=>{try{return void await Z(e(t))}catch(r){if(I(r)==="EPERM")return await Z(Rm(t,438).then(()=>!0),r)?void await e(t):void 0;throw r}},Yr=e=>t=>{try{return void X(()=>e(t))}catch(r){if(I(r)==="EPERM")return X(()=>((0,k.chmodSync)(t,438),!0),r)?void e(t):void 0;throw r}};var Ac=require("timers/promises");var Im=200,Nm=1.2,Pc=10,Rc=new Set(["EMFILE","ENFILE","EBUSY"]),Fo=e=>{let t=async(r,n,s=1,o=0)=>{let i=n.maxBackoff||Im,a=n.backoff||Nm,c=n.maxRetries||Pc,u=0;for(;;)try{return await e(r)}catch(l){if(So(l)&&l.path===r&&Rc.has(l.code)){if(s=Math.ceil(s*a),o=s+o,o<i)return await(0,Ac.setTimeout)(s),t(r,n,s,o);if(u<c){u++;continue}}throw l}};return t},To=e=>(r,n)=>{let s=n.maxRetries||Pc,o=0;for(;;)try{return e(r)}catch(i){if(So(i)&&i.path===r&&Rc.has(i.code)&&o<s){o++;continue}throw i}};var mt=require("path");var Zr=require("os"),le=require("path");var{stat:Om}=et,Mm=e=>{try{return(0,k.statSync)(e).isDirectory()}catch{return!1}},$m=e=>Om(e).then(t=>t.isDirectory(),()=>!1),Bm=async e=>{let{root:t}=(0,le.parse)(e),r=(0,Zr.tmpdir)(),{root:n}=(0,le.parse)(r);if(t.toLowerCase()===n.toLowerCase())return r;let s=(0,le.resolve)(t,"/temp");return await $m(s)?s:t},jm=e=>{let{root:t}=(0,le.parse)(e),r=(0,Zr.tmpdir)(),{root:n}=(0,le.parse)(r);if(t.toLowerCase()===n.toLowerCase())return r;let s=(0,le.resolve)(t,"/temp");return Mm(s)?s:t},_m=async()=>(0,Zr.tmpdir)(),Lm=()=>(0,Zr.tmpdir)(),Ic=process.platform==="win32"?Bm:_m,Nc=process.platform==="win32"?jm:Lm;var{lstat:Wm,rename:Gm,unlink:Hm,rmdir:Um}=et,$c=e=>`.${(0,mt.basename)(e)}.${Math.random()}`,zm=qr(Hm),Km=Yr(k.unlinkSync),qn=async(e,t)=>(t?.signal?.throwIfAborted(),await Z(Wm(e).then(r=>Ao(e,t,r)))??!0),Ao=async(e,t,r)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return Ao(e,{...t,tmp:await Ic(e)},r);if(e===t.tmp&&(0,mt.parse)(e).root!==e)throw new Error("cannot delete temp directory used for deletion");let n=r.isDirectory()?await Ue(e):null;if(!Array.isArray(n)){if(n){if(I(n)==="ENOENT")return!0;if(I(n)!=="ENOTDIR")throw n}return t.filter&&!await t.filter(e,r)?!1:(await Z(Oc(e,t.tmp,zm)),!0)}return!(await Promise.all(n.map(o=>Ao((0,mt.resolve)(e,o.name),t,o)))).every(o=>o===!0)||t.preserveRoot===!1&&e===(0,mt.parse)(e).root||t.filter&&!await t.filter(e,r)?!1:(await Z(Oc(e,t.tmp,Um)),!0)},Oc=async(e,t,r)=>{let n=(0,mt.resolve)(t,$c(e));return await Gm(e,n),await r(n)},Yn=(e,t)=>(t?.signal?.throwIfAborted(),X(()=>Po(e,t,(0,k.lstatSync)(e)))??!0),Po=(e,t,r)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return Po(e,{...t,tmp:Nc(e)},r);let n=t.tmp;if(e===t.tmp&&(0,mt.parse)(e).root!==e)throw new Error("cannot delete temp directory used for deletion");let s=r.isDirectory()?ze(e):null;if(!Array.isArray(s)){if(s){if(I(s)==="ENOENT")return!0;if(I(s)!=="ENOTDIR")throw s}return t.filter&&!t.filter(e,r)?!1:(X(()=>Mc(e,n,Km)),!0)}let o=!0;for(let i of s){let a=(0,mt.resolve)(e,i.name);o=Po(a,t,i)&&o}return!o||t.preserveRoot===!1&&e===(0,mt.parse)(e).root||t.filter&&!t.filter(e,r)?!1:(X(()=>Mc(e,n,k.rmdirSync)),!0)},Mc=(e,t,r)=>{let n=(0,mt.resolve)(t,$c(e));return(0,k.renameSync)(e,n),r(n)};var{unlink:Jm,rmdir:Vm,lstat:qm}=et,Ym=Fo(qr(Jm)),Zm=To(Yr(k.unlinkSync)),Xm=Fo(qr(Vm)),Qm=To(Yr(k.rmdirSync)),tg=async(e,{filter:t,...r})=>{r?.signal?.throwIfAborted();try{return await Xm(e,r),!0}catch(n){if(I(n)==="ENOTEMPTY")return qn(e,r);throw n}},eg=(e,{filter:t,...r})=>{r?.signal?.throwIfAborted();try{return Qm(e,r),!0}catch(n){if(I(n)==="ENOTEMPTY")return Yn(e,r);throw n}},pe=Symbol("start"),Bc=Symbol("child"),Zn=Symbol("finish"),Xn=async(e,t)=>(t?.signal?.throwIfAborted(),await Z(qm(e).then(r=>Ro(e,t,r,pe)))??!0),Qn=(e,t)=>(t?.signal?.throwIfAborted(),X(()=>Io(e,t,(0,k.lstatSync)(e),pe))??!0),Ro=async(e,t,r,n=pe)=>{t?.signal?.throwIfAborted();let s=r.isDirectory()?await Ue(e):null;if(!Array.isArray(s)){if(s){if(I(s)==="ENOENT")return!0;if(I(s)!=="ENOTDIR")throw s}return t.filter&&!await t.filter(e,r)?!1:(await Z(Ym(e,t)),!0)}let o=n===pe?Bc:n,i=(await Promise.all(s.map(a=>Ro((0,Je.resolve)(e,a.name),t,a,o)))).every(a=>a===!0);if(n===pe)return Ro(e,t,r,Zn);if(n===Zn){if(t.preserveRoot===!1&&e===(0,Je.parse)(e).root||!i||t.filter&&!await t.filter(e,r))return!1;await Z(tg(e,t))}return!0},Io=(e,t,r,n=pe)=>{let s=r.isDirectory()?ze(e):null;if(!Array.isArray(s)){if(s){if(I(s)==="ENOENT")return!0;if(I(s)!=="ENOTDIR")throw s}return t.filter&&!t.filter(e,r)?!1:(X(()=>Zm(e,t)),!0)}let o=!0;for(let i of s){let a=n===pe?Bc:n,c=(0,Je.resolve)(e,i.name);o=Io(c,t,i,a)&&o}if(n===pe)return Io(e,t,r,Zn);if(n===Zn){if(t.preserveRoot===!1&&e===(0,Je.parse)(e).root||!o||t.filter&&!t.filter(e,r))return!1;X(()=>eg(e,t))}return!0};var No=process.platform==="win32"?Xn:Jn,Oo=process.platform==="win32"?Qn:Vn;var{rm:rg}=et,Mo=async(e,t)=>(await rg(e,{...t,force:!0,recursive:!0}),!0),$o=(e,t)=>((0,k.rmSync)(e,{...t,force:!0,recursive:!0}),!0);var[jc=0,ng=0]=process.version.replace(/^v/,"").split(".").map(e=>parseInt(e,10)),_c=jc>14||jc===14&&ng>=14,Lc=!_c||process.platform==="win32"?()=>!1:e=>!e?.signal&&!e?.filter,Wc=!_c||process.platform==="win32"?()=>!1:e=>!e?.signal&&!e?.filter;var Ve=e=>async(t,r)=>{let n=bc(r);return n.glob&&(t=await Hn(t,n.glob)),Array.isArray(t)?!!(await Promise.all(t.map(s=>e(Vr(s,n),n)))).reduce((s,o)=>s&&o,!0):!!await e(Vr(t,n),n)},qe=e=>(t,r)=>{let n=vc(r);return n.glob&&(t=zn(t,n.glob)),Array.isArray(t)?!!t.map(s=>e(Vr(s,n),n)).reduce((s,o)=>s&&o,!0):!!e(Vr(t,n),n)},Uc=qe($o),sg=Object.assign(Ve(Mo),{sync:Uc}),zc=qe(Oo),og=Object.assign(Ve(No),{sync:zc}),Kc=qe(Qn),ig=Object.assign(Ve(Xn),{sync:Kc}),Jc=qe(Vn),ag=Object.assign(Ve(Jn),{sync:Jc}),Vc=qe(Yn),cg=Object.assign(Ve(qn),{sync:Vc}),Gc=qe((e,t)=>Wc(t)?$o(e,t):Oo(e,t));var Hc=Ve((e,t)=>Lc(t)?Mo(e,t):No(e,t)),ts=Object.assign(Hc,{rimraf:Hc,sync:Gc,rimrafSync:Gc,manual:og,manualSync:zc,native:sg,nativeSync:Uc,posix:ag,posixSync:Jc,windows:ig,windowsSync:Kc,moveRemove:cg,moveRemoveSync:Vc});ts.rimraf=ts;var S=e=>(0,Ye.join)(process.cwd(),e),es=e=>{try{return(0,qc.readdirSync)(e).length===0}catch{return!0}};function Yc(){let e=Sa({cwd:(0,Ye.dirname)(__filename)});if(!e)throw new Error("Could not find package.json");return(0,Ye.dirname)(e)}var Zc=e=>ts(e);var Xc=b(require("chalk"));async function K(e,t){let r=Date.now(),n=e.title,s=()=>Math.floor((Date.now()-r)/1e3),o=setInterval(()=>{s()>1&&(e.title=`${n} (${s()}s)`)},1e3);try{return await t(s)}finally{clearInterval(o)}}async function rs(e,t,r){for(let n=0;n<t.length;n++){let s=t[n];e.output=Xc.default.dim(`[${n+1}/${t.length}] ${s.title}`),await s.fn(r??{},e)}}var Ze=e=>{let t=e??O(),r=(0,rt.join)(t,"package.json");if(!(0,bt.existsSync)(r))return null;try{return JSON.parse((0,bt.readFileSync)(r,"utf-8"))}catch{return null}},vt=e=>{let t={services:"services",apps:"apps",packages:"packages",contracts:"packages/contracts"},r=Ze(e);if(!r)return t;let n=r.pf?.paths;return{services:(typeof n?.services=="object"?n.services.path:n?.services)??t.services,apps:(typeof n?.apps=="object"?n.apps.path:n?.apps)??t.apps,packages:(typeof n?.packages=="object"?n.packages.path:n?.packages)??t.packages,contracts:(typeof n?.contracts=="object"?n.contracts.path:n?.contracts)??t.contracts}},G=e=>{let t=e??O(),r=vt(t);return{packagePath:(0,rt.join)(t,r.contracts),eventsPath:(0,rt.join)(t,r.contracts,"src","events"),indexPath:(0,rt.join)(t,r.contracts,"src","index.ts"),relativePath:r.contracts}},ug=e=>{let t=(0,rt.join)(e,"package.json");if(!(0,bt.existsSync)(t))return!1;try{let r=JSON.parse((0,bt.readFileSync)(t,"utf-8"));if(!r.workspaces)return!1;if(r.pf||(0,bt.existsSync)((0,rt.join)(e,"turbo.json")))return!0;let n=ga.some(o=>(0,bt.existsSync)((0,rt.join)(e,o))),s=(0,bt.existsSync)((0,rt.join)(e,"infra"));return!!(n&&s)}catch{return!1}};function O(){let e=process.cwd();for(;!ug(e);){let t=e.slice(0,e.lastIndexOf("/"));if(t===e)throw new Error(`
17
17
  \x1B[31m\u2716\x1B[0m Not in a workspace directory
18
18
 
19
19
  Current directory: ${process.cwd()}
@@ -23,17 +23,17 @@ This command must be run from within a workspace created with \x1B[36mpf new wor
23
23
  To create a new workspace, run:
24
24
 
25
25
  \x1B[36mpf new workspace my-platform\x1B[0m
26
- `);e=t}return e}function Xn(){let e=O(),t=(0,rt.join)(e,"package.json");if(!(0,bt.existsSync)(t))return`@${e.split("/").pop()||"workspace"}`;try{let n=JSON.parse((0,bt.readFileSync)(t,"utf-8")).name;return n?n.startsWith("@")?n.split("/")[0]:`@${n}`:`@${e.split("/").pop()||"workspace"}`}catch{return`@${e.split("/").pop()||"workspace"}`}}function Jt(e,t,r=process.cwd()){let n=(0,rt.join)(r,"package.json"),s=(0,Ce.readJsonSync)(n);ug(s,e,t),(0,Ce.writeJsonSync)(n,s,{spaces:2,EOL:`
27
- `,encoding:"utf-8"})}function qc(e,t=process.cwd()){let r=(0,rt.join)(t,"package.json"),n=(0,Ce.readJsonSync)(r),s=e.split("."),o=n;for(let i of s){if(o===null||typeof o!="object"||!(i in o))return;o=o[i]}return o}function ug(e,t,r){let n=t.split("."),s=e;for(let o=0;o<n.length-1;o++){let i=n[o];(!(i in s)||typeof s[i]!="object"||s[i]===null)&&(s[i]={}),s=s[i]}s[n[n.length-1]]=r}var Qn=e=>{let t=Kc();return(0,Ce.readJSONSync)((0,rt.resolve)(t,e),{encoding:"utf-8"})},xt=Qn("package.json");var pu=require("node:fs"),fu=require("node:path"),Bo=require("node:process"),du=require("execa");var $o=require("node:child_process"),au=require("node:path"),cu=require("execa");var nu=require("node:fs"),su=require("node:path"),ou=b(ru()),Oo=(e,t)=>{let r=(0,su.resolve)(t,e);return(0,nu.existsSync)(r)?(0,ou.config)({path:r,processEnv:{}}).parsed||{}:{}},iu=(e,t)=>{let r=Oo(e,t),n=[];for(let[s,o]of Object.entries(r))if(s.endsWith("_PORT")&&o){let i=Number.parseInt(o,10);!Number.isNaN(i)&&i>0&&n.push(i)}return n};var Mo={...process.env,NODE_NO_WARNINGS:"1"},Fg=(e,t,r)=>e?"pipe":t||r?["ignore","pipe","pipe"]:"inherit",Tg=(e,t,r)=>e?{...Mo,...e}:t||r?{...Mo,CI:"true"}:{...Mo},Ag=e=>e.includes("EEXIST")||e.includes("failed to link package");async function pe(e,t,{cwd:r=process.cwd(),task:n,shell:s,context:o=e,quiet:i=!1,nonInteractive:a=!1,env:c}={}){try{t.length===0&&(t=e.split(" ").slice(1));let u=(0,cu.execa)(e,t,{cwd:r,stdio:Fg(i,n,a),all:n||a?!0:void 0,shell:s??!0,env:Tg(c,n,a)});u.all&&u.all.on("data",l=>{let p=l.toString().trim();n?(n.output=p,p.length&&w.storeLog(p,o)):a&&p.length&&console.log(p)}),await u}catch(u){let l=u instanceof Error?u.message:String(u);if(Ag(l))return;throw new Error(Pg(l))}}var Pg=e=>{let t=e.match(/error: (.+)/);return t?t[1].trim():e};function uu(e,t,r={}){let{cwd:n=process.cwd(),envFile:s,detached:o=!0,pipeStdout:i=!1,onStdout:a,onStderr:c,onExit:u}=r,l=s?Oo(s,n):{},p=(0,au.resolve)(n,"node_modules",".bin"),d=process.env.PATH||"",f=`${p}:${d}`,m={...process.env,...l,PATH:f,FORCE_COLOR:"1"},h=(0,$o.spawn)(e,t,{cwd:n,env:m,stdio:["inherit",i?"pipe":"inherit","pipe"],detached:o});return a&&i&&h.stdout?.on("data",a),c&&h.stderr?.on("data",c),u&&h.on("exit",u),h}function es(e,t,r={}){let{cwd:n=process.cwd()}=r;(0,$o.spawn)(e,t,{cwd:n,stdio:"inherit",shell:!0}).on("exit",o=>process.exit(o||0))}async function lu(e){let{execSync:t}=await import("node:child_process");for(let r of e)try{let s=t(`lsof -ti:${r}`,{encoding:"utf8",stdio:"pipe"}).trim().split(`
28
- `).filter(Boolean);for(let o of s)try{process.kill(Number.parseInt(o,10),"SIGKILL")}catch{}}catch{}}var rs=e=>Tr(e);function jo(e=process.cwd()){let t=r=>(0,pu.existsSync)((0,fu.join)(e,r));if(t("bun.lock")||t("bun.lockb"))return"bun";if(t("pnpm-lock.yaml"))return"pnpm";if(t("yarn.lock"))return"yarn";if(t("package-lock.json"))return"npm"}function $(e){return jo(e)??_o()}function _o(){return rs("bun")?"bun":rs("pnpm")?"pnpm":rs("yarn")?"yarn":"npm"}function hu(){return["bun","pnpm","yarn","npm"].filter(rs)}async function kt(e,t){let r=Ig(e,t),{mergedOptions:n,packages:s}=r,{cwd:o=process.cwd(),flags:i=[],task:a,quiet:c}=n,u=n.packageManager??$(),l=[],p=Array.isArray(s)?s:[s];u==="bun"&&(p=p.map(f=>f.replace("git+ssh://",""))),u==="pnpm"&&(l.push("--config.engine-strict=false"),l.push("--no-frozen-lockfile")),["yarn","npm"].includes(u)&&l.push("--ignore-engines");let d=p.length?u==="npm"?["install",...i,...l,...p]:["add",...i,...l,...p]:["install",...i,...l];await pe(u,d,{cwd:o,task:a,quiet:c})}async function mu(e){let t=["-g"],r=[...e.flags??[],...t];await kt({...e,flags:r,packageManager:e.packageManager??$()})}function gu(e,t,r){let{args:n,mergedOptions:s}=yu(t??[],r),o=s.manager??$(),{command:i,args:a}=Du(o);console.log(`
26
+ `);e=t}return e}function ns(){let e=O(),t=(0,rt.join)(e,"package.json");if(!(0,bt.existsSync)(t))return`@${e.split("/").pop()||"workspace"}`;try{let n=JSON.parse((0,bt.readFileSync)(t,"utf-8")).name;return n?n.startsWith("@")?n.split("/")[0]:`@${n}`:`@${e.split("/").pop()||"workspace"}`}catch{return`@${e.split("/").pop()||"workspace"}`}}function Jt(e,t,r=process.cwd()){let n=(0,rt.join)(r,"package.json"),s=(0,be.readJsonSync)(n);lg(s,e,t),(0,be.writeJsonSync)(n,s,{spaces:2,EOL:`
27
+ `,encoding:"utf-8"})}function Qc(e,t=process.cwd()){let r=(0,rt.join)(t,"package.json"),n=(0,be.readJsonSync)(r),s=e.split("."),o=n;for(let i of s){if(o===null||typeof o!="object"||!(i in o))return;o=o[i]}return o}function lg(e,t,r){let n=t.split("."),s=e;for(let o=0;o<n.length-1;o++){let i=n[o];(!(i in s)||typeof s[i]!="object"||s[i]===null)&&(s[i]={}),s=s[i]}s[n[n.length-1]]=r}var ss=e=>{let t=Yc();return(0,be.readJSONSync)((0,rt.resolve)(t,e),{encoding:"utf-8"})},Ot=ss("package.json"),pg={docs:{base:["service.md"],frameworks:{}},serviceTypes:{hono:{commandType:"hono-micro",entryPoint:"src/index.ts",skipFiles:[]},nest:{commandType:"nest-micro",entryPoint:"src/main.ts",skipFiles:[]}}},Xr=()=>Ot.generatorConfig??pg;var mu=require("node:fs"),gu=require("node:path"),Go=require("node:process"),Du=require("execa");var Wo=require("node:child_process"),pu=require("node:path"),fu=require("execa");var au=require("node:fs"),cu=require("node:path"),uu=b(iu()),_o=(e,t)=>{let r=(0,cu.resolve)(t,e);return(0,au.existsSync)(r)?(0,uu.config)({path:r,processEnv:{}}).parsed||{}:{}},lu=(e,t)=>{let r=_o(e,t),n=[];for(let[s,o]of Object.entries(r))if(s.endsWith("_PORT")&&o){let i=Number.parseInt(o,10);!Number.isNaN(i)&&i>0&&n.push(i)}return n};var Lo={...process.env,NODE_NO_WARNINGS:"1"},Ag=(e,t,r)=>e?"pipe":t||r?["ignore","pipe","pipe"]:"inherit",Pg=(e,t,r)=>e?{...Lo,...e}:t||r?{...Lo,CI:"true"}:{...Lo},Rg=e=>e.includes("EEXIST")||e.includes("failed to link package");async function fe(e,t,{cwd:r=process.cwd(),task:n,shell:s,context:o=e,quiet:i=!1,nonInteractive:a=!1,env:c}={}){try{t.length===0&&(t=e.split(" ").slice(1));let u=(0,fu.execa)(e,t,{cwd:r,stdio:Ag(i,n,a),all:n||a?!0:void 0,shell:s??!0,env:Pg(c,n,a)});u.all&&u.all.on("data",l=>{let p=l.toString().trim();n?(n.output=p,p.length&&w.storeLog(p,o)):a&&p.length&&console.log(p)}),await u}catch(u){let l=u instanceof Error?u.message:String(u);if(Rg(l))return;throw new Error(Ig(l))}}var Ig=e=>{let t=e.match(/error: (.+)/);return t?t[1].trim():e};function du(e,t,r={}){let{cwd:n=process.cwd(),envFile:s,detached:o=!0,pipeStdout:i=!1,onStdout:a,onStderr:c,onExit:u}=r,l=s?_o(s,n):{},p=(0,pu.resolve)(n,"node_modules",".bin"),d=process.env.PATH||"",f=`${p}:${d}`,m={...process.env,...l,PATH:f,FORCE_COLOR:"1"},h=(0,Wo.spawn)(e,t,{cwd:n,env:m,stdio:["inherit",i?"pipe":"inherit","pipe"],detached:o});return a&&i&&h.stdout?.on("data",a),c&&h.stderr?.on("data",c),u&&h.on("exit",u),h}function is(e,t,r={}){let{cwd:n=process.cwd()}=r;(0,Wo.spawn)(e,t,{cwd:n,stdio:"inherit",shell:!0}).on("exit",o=>process.exit(o||0))}async function hu(e){let{execSync:t}=await import("node:child_process");for(let r of e)try{let s=t(`lsof -ti:${r}`,{encoding:"utf8",stdio:"pipe"}).trim().split(`
28
+ `).filter(Boolean);for(let o of s)try{process.kill(Number.parseInt(o,10),"SIGKILL")}catch{}}catch{}}var as=e=>Rr(e);function Ho(e=process.cwd()){let t=r=>(0,mu.existsSync)((0,gu.join)(e,r));if(t("bun.lock")||t("bun.lockb"))return"bun";if(t("pnpm-lock.yaml"))return"pnpm";if(t("yarn.lock"))return"yarn";if(t("package-lock.json"))return"npm"}function $(e){return Ho(e)??Uo()}function Uo(){return as("bun")?"bun":as("pnpm")?"pnpm":as("yarn")?"yarn":"npm"}function yu(){return["bun","pnpm","yarn","npm"].filter(as)}async function xt(e,t){let r=Og(e,t),{mergedOptions:n,packages:s}=r,{cwd:o=process.cwd(),flags:i=[],task:a,quiet:c}=n,u=n.packageManager??$(),l=[],p=Array.isArray(s)?s:[s];u==="bun"&&(p=p.map(f=>f.replace("git+ssh://",""))),u==="pnpm"&&(l.push("--config.engine-strict=false"),l.push("--no-frozen-lockfile")),["yarn","npm"].includes(u)&&l.push("--ignore-engines");let d=p.length?u==="npm"?["install",...i,...l,...p]:["add",...i,...l,...p]:["install",...i,...l];await fe(u,d,{cwd:o,task:a,quiet:c})}async function wu(e){let t=["-g"],r=[...e.flags??[],...t];await xt({...e,flags:r,packageManager:e.packageManager??$()})}function Cu(e,t,r){let{args:n,mergedOptions:s}=vu(t??[],r),o=s.manager??$(),{command:i,args:a}=bu(o);console.log(`
29
29
  Running command: ${i} ${[...a,e,...n].join(" ")}
30
- `),(0,du.execaSync)(i,[...a,e,...n],{cwd:s.cwd??(0,Bo.cwd)(),stdio:"inherit",preferLocal:!0})}async function qt(e,t,r){let{args:n,mergedOptions:s}=yu(t??[],r),o=s.manager??$(),{command:i,args:a}=Du(o);await pe(i,[...a,e,...n],s)}async function Yr(e,t){let{script:r,mergedOptions:n}=Ng(e,t),s=n.packageManager??$();await pe(s,["run",r,...n.args??[]],{cwd:n.cwd??(0,Bo.cwd)(),task:n.task})}function Du(e){let r={bun:"bunx",pnpm:"npx",yarn:"npx",npm:"npx"}[e];if(!r)throw new Error(`No executor found for the detected package manager: ${e}`);let[n,...s]=r.split(" ");return{command:n,args:s}}function Ig(e,t){return Array.isArray(e)?{packages:e,mergedOptions:{...t,packages:e}}:{packages:e.packages??[],mergedOptions:e}}function yu(e,t){return Array.isArray(e)?{args:e,mergedOptions:t??{}}:{args:[],mergedOptions:e}}function Ng(e,t){return typeof e=="string"?{script:e,mergedOptions:t??{}}:{script:e.script,mergedOptions:e}}var Og=e=>e==="yarn"?["npm","audit"]:["audit"],bu=new Cu.Command("audit").description("Run security audit on dependencies").allowUnknownOption(!0).action((e,t)=>{let r=O(),n=$(),s=Og(n),o=t.args||[];console.log(wu.default.dim(`Running ${n} ${[...s,...o].join(" ")}`)),es(n,[...s,...o],{cwd:r})});var Mt=require("listr2"),Mg=Object.defineProperty,vu=(e,t)=>Mg(e,"name",{value:t,configurable:!0}),R=class extends Mt.ListrPromptAdapter{static{vu(this,"ListrEnquirerPromptAdapter")}error;prompt;get instance(){return this.prompt}async run(e,t){Array.isArray(e)?e.length===1&&(e=e.map(s=>({...s,name:"default"}))):e=[{...e,name:"default"}],e=e.map(s=>({onCancel:vu(()=>(this.error=new Mt.PromptError("Cancelled prompt."),!0),"onCancel"),...s,stdout:t?.stdout??this.wrapper.stdout(Mt.ListrTaskEventType.PROMPT)}));let r;if(t?.enquirer)r=t.enquirer;else try{r=await import("enquirer").then(s=>s.default?new s.default:new s)}catch{throw this.reportFailed(),new Mt.PromptError("Enquirer is a optional peer dependency that must be installed separately.")}this.reportStarted(),this.task.on(Mt.ListrTaskEventType.STATE,s=>{s===Mt.ListrTaskState.SKIPPED&&this.prompt&&!this.error&&this.cancel({throw:!1})});let n;try{n=await r.once("prompt",s=>this.prompt=s).prompt(e)}catch(s){throw this.reportFailed(),this.error?this.error:s}return this.reportCompleted(),e.length===1?n.default:n}cancel(e){!this.prompt||this.error||(e?.throw?this.prompt.cancel():this.prompt.submit(),this.reportFailed())}};var te=b(require("chalk"));var Qe=require("node:fs"),Au=require("node:os"),Pu=require("node:path");var fe=require("node:crypto"),Xe=require("node:fs"),be=require("node:os"),xu=require("node:path"),Lo=(0,xu.join)((0,be.homedir)(),".platform-sdk-keys"),ku="aes-256-gcm",Eu=()=>{let e=`${(0,be.hostname)()}:${(0,be.userInfo)().username}:${(0,be.homedir)()}`;return(0,fe.createHash)("sha256").update(e).digest()},Su=()=>{if(!(0,Xe.existsSync)(Lo))return{};try{return JSON.parse((0,Xe.readFileSync)(Lo,"utf-8"))}catch{return{}}},$g=e=>{(0,Xe.writeFileSync)(Lo,JSON.stringify(e,null,2),{mode:384})},Bg=e=>{let t=Eu(),r=(0,fe.randomBytes)(16),n=(0,fe.createCipheriv)(ku,t,r),s=n.update(e,"utf8","hex");return s+=n.final("hex"),{iv:r.toString("hex"),tag:n.getAuthTag().toString("hex"),data:s}},jg=e=>{let t=Eu(),r=Buffer.from(e.iv,"hex"),n=Buffer.from(e.tag,"hex"),s=(0,fe.createDecipheriv)(ku,t,r);s.setAuthTag(n);let o=s.update(e.data,"hex","utf8");return o+=s.final("utf8"),o};async function Fu(e,t){let r=Su();r[e]=Bg(t),$g(r)}async function ns(e){let r=Su()[e];if(!r)return null;try{return jg(r)}catch{return null}}var Zr={openai:{id:"openai",name:"OpenAI",defaultApiKeyEnvVar:"OPENAI_API_KEY",defaultModel:"gpt-4o-mini",modelsApiUrl:"https://api.openai.com/v1/models",apiKeyUrl:"https://platform.openai.com/api-keys",buildHeaders:e=>({Authorization:`Bearer ${e}`}),parseModelsResponse:e=>e.data??[],modelFilters:[/^gpt-4/,/^gpt-3\.5/,/^o1/,/^o3/]},anthropic:{id:"anthropic",name:"Anthropic (Claude)",defaultApiKeyEnvVar:"ANTHROPIC_API_KEY",defaultModel:"claude-sonnet-4-20250514",modelsApiUrl:"https://api.anthropic.com/v1/models",apiKeyUrl:"https://console.anthropic.com/settings/keys",buildHeaders:e=>({"x-api-key":e,"anthropic-version":"2023-06-01"}),parseModelsResponse:e=>(e.data??[]).map(r=>({id:r.id,created:new Date(r.created_at).getTime()})),modelFilters:[/^claude-/]}};function Tu(){return Object.entries(Zr).map(([e,t])=>({name:t.name,value:e}))}function Xr(e){let t=Zr[e];if(!t)throw new Error(`Unknown AI provider: ${e}`);return t}var ve=(0,Pu.join)((0,Au.homedir)(),".platform-sdk-ai.json"),_g=()=>{let e="anthropic",t=Zr[e];return{provider:e,model:t.defaultModel}},Wo=_g();function Qr(){return(0,Qe.existsSync)(ve)}function ss(){if(!Qr())throw new Error("AI configuration not found. Please run 'pf ai:setup' to configure your AI provider.");try{let e=(0,Qe.readFileSync)(ve,"utf-8"),t=JSON.parse(e);return{...Wo,...t}}catch{throw new Error(`Failed to load AI configuration from ${ve}. Please run 'pf setup --ai' again.`)}}function Ru(e){let t=JSON.stringify(e,null,2);(0,Qe.writeFileSync)(ve,t,"utf-8")}async function Iu(e,t){await Fu(e,t)}async function Nu(e){let t=await ns(e.provider);if(t)return t;let r=Zr[e.provider],n=process.env[r.defaultApiKeyEnvVar];if(n)return n;throw new Error("API key not found. Please run 'pf setup --ai' to configure your API key.")}var Lg=async(e,t,r,n)=>{let{createOpenAI:s}=await import("@ai-sdk/openai"),o=s({apiKey:r});if(n.onToken){let{streamText:c}=await import("ai"),u=c({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature}),l="";for await(let p of(await u).textStream)l+=p,n.onToken(p);return l}let{generateText:i}=await import("ai"),{text:a}=await i({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature});return a},Wg=async(e,t,r,n)=>{let{createAnthropic:s}=await import("@ai-sdk/anthropic"),o=s({apiKey:r});if(n.onToken){let{streamText:c}=await import("ai"),u=c({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature}),l="";for await(let p of(await u).textStream)l+=p,n.onToken(p);return l}let{generateText:i}=await import("ai"),{text:a}=await i({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature});return a};async function Ou(e,t,r={}){let{system:n,maxTokens:s=4096,temperature:o=.7,onToken:i}=r,a=await Nu(e);switch(e.provider){case"openai":return Lg(t,e.model,a,{system:n,maxTokens:s,temperature:o,onToken:i});case"anthropic":return Wg(t,e.model,a,{system:n,maxTokens:s,temperature:o,onToken:i});default:throw new Error(`Unsupported AI provider: ${e.provider}`)}}var ms=require("node:fs"),nn=require("node:path"),ml=require("@inquirer/prompts"),T=b(require("chalk")),gl=b(require("ora"));var ls=require("node:fs"),Hu=require("node:path"),Uu=require("ts-morph");var gt=require("node:fs"),tn=require("node:path");var Gg=e=>e.replace(/\./g,"-").toLowerCase(),Hg=e=>e.split(/[-.]/).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(""),Ug=e=>({string:"z.string()",number:"z.number()",boolean:"z.boolean()",date:"z.string().datetime()",array:"z.array(z.unknown())",object:"z.record(z.unknown())","string?":"z.string().optional()","number?":"z.number().optional()","boolean?":"z.boolean().optional()"})[e.toLowerCase()]||`z.${e}()`,zg=e=>!e||Object.keys(e).length===0?` id: z.string(),
31
- createdAt: z.string(),`:Object.entries(e).map(([t,r])=>` ${t}: ${Ug(r)},`).join(`
32
- `),Et=e=>{let t=Gg(e),r=Hg(e);return{eventName:t,contractName:`${r}Contract`,schemaName:`${r}Schema`,typeName:`${r}Data`}},Go=e=>{let{eventsPath:t}=G(),{eventName:r}=Et(e);return(0,gt.existsSync)((0,tn.join)(t,`${r}.ts`))},Ho=(e,t)=>{let{eventsPath:r}=G(),{eventName:n,contractName:s,schemaName:o,typeName:i}=Et(e),a=`import { createContract } from '@crossdelta/cloudevents'
30
+ `),(0,Du.execaSync)(i,[...a,e,...n],{cwd:s.cwd??(0,Go.cwd)(),stdio:"inherit",preferLocal:!0})}async function qt(e,t,r){let{args:n,mergedOptions:s}=vu(t??[],r),o=s.manager??$(),{command:i,args:a}=bu(o);await fe(i,[...a,e,...n],s)}async function tn(e,t){let{script:r,mergedOptions:n}=Mg(e,t),s=n.packageManager??$();await fe(s,["run",r,...n.args??[]],{cwd:n.cwd??(0,Go.cwd)(),task:n.task})}function bu(e){let r={bun:"bunx",pnpm:"npx",yarn:"npx",npm:"npx"}[e];if(!r)throw new Error(`No executor found for the detected package manager: ${e}`);let[n,...s]=r.split(" ");return{command:n,args:s}}function Og(e,t){return Array.isArray(e)?{packages:e,mergedOptions:{...t,packages:e}}:{packages:e.packages??[],mergedOptions:e}}function vu(e,t){return Array.isArray(e)?{args:e,mergedOptions:t??{}}:{args:[],mergedOptions:e}}function Mg(e,t){return typeof e=="string"?{script:e,mergedOptions:t??{}}:{script:e.script,mergedOptions:e}}var $g=e=>e==="yarn"?["npm","audit"]:["audit"],Eu=new ku.Command("audit").description("Run security audit on dependencies").allowUnknownOption(!0).action((e,t)=>{let r=O(),n=$(),s=$g(n),o=t.args||[];console.log(xu.default.dim(`Running ${n} ${[...s,...o].join(" ")}`)),is(n,[...s,...o],{cwd:r})});var Mt=require("listr2"),Bg=Object.defineProperty,Su=(e,t)=>Bg(e,"name",{value:t,configurable:!0}),R=class extends Mt.ListrPromptAdapter{static{Su(this,"ListrEnquirerPromptAdapter")}error;prompt;get instance(){return this.prompt}async run(e,t){Array.isArray(e)?e.length===1&&(e=e.map(s=>({...s,name:"default"}))):e=[{...e,name:"default"}],e=e.map(s=>({onCancel:Su(()=>(this.error=new Mt.PromptError("Cancelled prompt."),!0),"onCancel"),...s,stdout:t?.stdout??this.wrapper.stdout(Mt.ListrTaskEventType.PROMPT)}));let r;if(t?.enquirer)r=t.enquirer;else try{r=await import("enquirer").then(s=>s.default?new s.default:new s)}catch{throw this.reportFailed(),new Mt.PromptError("Enquirer is a optional peer dependency that must be installed separately.")}this.reportStarted(),this.task.on(Mt.ListrTaskEventType.STATE,s=>{s===Mt.ListrTaskState.SKIPPED&&this.prompt&&!this.error&&this.cancel({throw:!1})});let n;try{n=await r.once("prompt",s=>this.prompt=s).prompt(e)}catch(s){throw this.reportFailed(),this.error?this.error:s}return this.reportCompleted(),e.length===1?n.default:n}cancel(e){!this.prompt||this.error||(e?.throw?this.prompt.cancel():this.prompt.submit(),this.reportFailed())}};var ee=b(require("chalk"));var tr=require("node:fs"),Nu=require("node:os"),Ou=require("node:path");var de=require("node:crypto"),Qe=require("node:fs"),ve=require("node:os"),Fu=require("node:path"),zo=(0,Fu.join)((0,ve.homedir)(),".platform-sdk-keys"),Tu="aes-256-gcm",Au=()=>{let e=`${(0,ve.hostname)()}:${(0,ve.userInfo)().username}:${(0,ve.homedir)()}`;return(0,de.createHash)("sha256").update(e).digest()},Pu=()=>{if(!(0,Qe.existsSync)(zo))return{};try{return JSON.parse((0,Qe.readFileSync)(zo,"utf-8"))}catch{return{}}},jg=e=>{(0,Qe.writeFileSync)(zo,JSON.stringify(e,null,2),{mode:384})},_g=e=>{let t=Au(),r=(0,de.randomBytes)(16),n=(0,de.createCipheriv)(Tu,t,r),s=n.update(e,"utf8","hex");return s+=n.final("hex"),{iv:r.toString("hex"),tag:n.getAuthTag().toString("hex"),data:s}},Lg=e=>{let t=Au(),r=Buffer.from(e.iv,"hex"),n=Buffer.from(e.tag,"hex"),s=(0,de.createDecipheriv)(Tu,t,r);s.setAuthTag(n);let o=s.update(e.data,"hex","utf8");return o+=s.final("utf8"),o};async function Ru(e,t){let r=Pu();r[e]=_g(t),jg(r)}async function cs(e){let r=Pu()[e];if(!r)return null;try{return Lg(r)}catch{return null}}var en={openai:{id:"openai",name:"OpenAI",defaultApiKeyEnvVar:"OPENAI_API_KEY",defaultModel:"gpt-4o-mini",modelsApiUrl:"https://api.openai.com/v1/models",apiKeyUrl:"https://platform.openai.com/api-keys",buildHeaders:e=>({Authorization:`Bearer ${e}`}),parseModelsResponse:e=>e.data??[],modelFilters:[/^gpt-4/,/^gpt-3\.5/,/^o1/,/^o3/]},anthropic:{id:"anthropic",name:"Anthropic (Claude)",defaultApiKeyEnvVar:"ANTHROPIC_API_KEY",defaultModel:"claude-sonnet-4-20250514",modelsApiUrl:"https://api.anthropic.com/v1/models",apiKeyUrl:"https://console.anthropic.com/settings/keys",buildHeaders:e=>({"x-api-key":e,"anthropic-version":"2023-06-01"}),parseModelsResponse:e=>(e.data??[]).map(r=>({id:r.id,created:new Date(r.created_at).getTime()})),modelFilters:[/^claude-/]}};function Iu(){return Object.entries(en).map(([e,t])=>({name:t.name,value:e}))}function rn(e){let t=en[e];if(!t)throw new Error(`Unknown AI provider: ${e}`);return t}var xe=(0,Ou.join)((0,Nu.homedir)(),".platform-sdk-ai.json"),Wg=()=>{let e="anthropic",t=en[e];return{provider:e,model:t.defaultModel}},Ko=Wg();function nn(){return(0,tr.existsSync)(xe)}function us(){if(!nn())throw new Error("AI configuration not found. Please run 'pf ai:setup' to configure your AI provider.");try{let e=(0,tr.readFileSync)(xe,"utf-8"),t=JSON.parse(e);return{...Ko,...t}}catch{throw new Error(`Failed to load AI configuration from ${xe}. Please run 'pf setup --ai' again.`)}}function Mu(e){let t=JSON.stringify(e,null,2);(0,tr.writeFileSync)(xe,t,"utf-8")}async function $u(e,t){await Ru(e,t)}async function Bu(e){let t=await cs(e.provider);if(t)return t;let r=en[e.provider],n=process.env[r.defaultApiKeyEnvVar];if(n)return n;throw new Error("API key not found. Please run 'pf setup --ai' to configure your API key.")}var Gg=async(e,t,r,n)=>{let{createOpenAI:s}=await import("@ai-sdk/openai"),o=s({apiKey:r});if(n.onToken){let{streamText:c}=await import("ai"),u=c({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature}),l="";for await(let p of(await u).textStream)l+=p,n.onToken(p);return l}let{generateText:i}=await import("ai"),{text:a}=await i({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature});return a},Hg=async(e,t,r,n)=>{let{createAnthropic:s}=await import("@ai-sdk/anthropic"),o=s({apiKey:r});if(n.onToken){let{streamText:c}=await import("ai"),u=c({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature}),l="";for await(let p of(await u).textStream)l+=p,n.onToken(p);return l}let{generateText:i}=await import("ai"),{text:a}=await i({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature});return a};async function ju(e,t,r={}){let{system:n,maxTokens:s=4096,temperature:o=.7,onToken:i}=r,a=await Bu(e);switch(e.provider){case"openai":return Gg(t,e.model,a,{system:n,maxTokens:s,temperature:o,onToken:i});case"anthropic":return Hg(t,e.model,a,{system:n,maxTokens:s,temperature:o,onToken:i});default:throw new Error(`Unsupported AI provider: ${e.provider}`)}}var Zt=require("node:fs"),ar=require("node:path"),Cl=require("@inquirer/prompts"),T=b(require("chalk")),bl=b(require("ora"));var er=require("node:fs"),sn=require("node:path"),ls=b(require("chokidar"));var on=".pf-generating",Ug=e=>(0,er.existsSync)((0,sn.join)(e,on)),zg=e=>{let t=(0,sn.join)(e,on);(0,er.existsSync)(t)&&(0,er.unlinkSync)(t)},Kg=e=>e?Object.values(e).filter(t=>typeof t=="object"&&t!==null&&t.watch===!0&&typeof t.path=="string").map(t=>t.path):["services","apps"],_u=(e,t)=>{zg(e);let r=Ze(e),n=Kg(r?.pf?.paths),s=(0,sn.join)(e,on),o=()=>{Ug(e)||t()};ls.default.watch(s,{ignoreInitial:!0}).on("unlink",()=>t());for(let i of n){let a=(0,sn.join)(e,i);(0,er.existsSync)(a)&&(ls.default.watch(a,{ignoreInitial:!0,depth:0}).on("addDir",o).on("unlinkDir",o),ls.default.watch(`${a}/*/package.json`,{ignoreInitial:!0}).on("add",o).on("change",o).on("unlink",o))}};var gs=require("node:fs"),Vu=require("node:path"),qu=require("ts-morph");var gt=require("node:fs"),an=require("node:path");var Jg=e=>e.replace(/\./g,"-").toLowerCase(),Vg=e=>e.split(/[-.]/).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(""),qg=e=>({string:"z.string()",number:"z.number()",boolean:"z.boolean()",date:"z.string().datetime()",array:"z.array(z.unknown())",object:"z.record(z.unknown())","string?":"z.string().optional()","number?":"z.number().optional()","boolean?":"z.boolean().optional()"})[e.toLowerCase()]||`z.${e}()`,Yg=e=>!e||Object.keys(e).length===0?` id: z.string(),
31
+ createdAt: z.string(),`:Object.entries(e).map(([t,r])=>` ${t}: ${qg(r)},`).join(`
32
+ `),kt=e=>{let t=Jg(e),r=Vg(e);return{eventName:t,contractName:`${r}Contract`,schemaName:`${r}Schema`,typeName:`${r}Data`}},Jo=e=>{let{eventsPath:t}=G(),{eventName:r}=kt(e);return(0,gt.existsSync)((0,an.join)(t,`${r}.ts`))},Vo=(e,t)=>{let{eventsPath:r}=G(),{eventName:n,contractName:s,schemaName:o,typeName:i}=kt(e),a=`import { createContract } from '@crossdelta/cloudevents'
33
33
  import { z } from 'zod'
34
34
 
35
35
  export const ${o} = z.object({
36
- ${zg(t)}
36
+ ${Yg(t)}
37
37
  })
38
38
 
39
39
  export const ${s} = createContract({
@@ -42,9 +42,9 @@ export const ${s} = createContract({
42
42
  })
43
43
 
44
44
  export type ${i} = z.infer<typeof ${s}.schema>
45
- `,c=(0,tn.join)(r,`${n}.ts`);return(0,gt.existsSync)(r)||(0,gt.mkdirSync)(r,{recursive:!0}),(0,gt.writeFileSync)(c,a,"utf-8"),c},os=e=>{let{eventsPath:t}=G(),{eventName:r}=Et(e);return(0,tn.join)(t,`${r}.ts`)},Uo=e=>{let t=os(e);if(!(0,gt.existsSync)(t))return null;let r=(0,gt.readFileSync)(t,"utf-8"),n=r.match(/export const \w+Schema\s*=\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m);if(n)return n[1];let s=r.match(/schema:\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m);return s?s[1]:null},zo=()=>{let{packagePath:e}=G(),t=(0,tn.join)(e,"package.json");if(!(0,gt.existsSync)(t))return"@my-platform";try{return JSON.parse((0,gt.readFileSync)(t,"utf-8")).name?.split("/")[0]??"@my-platform"}catch{return"@my-platform"}};var as=require("node:fs"),Vo=require("node:path");var Q=require("node:fs"),tr=require("node:path");var is=e=>e.split(".")[0].toUpperCase(),Mu=(e,t)=>{let r=(0,tr.join)(e,"src","index.ts");if(!(0,Q.existsSync)(r))return!1;let n=(0,Q.readFileSync)(r,"utf-8"),s=t.toLowerCase();return n.includes(`stream: '${t}'`)?!0:new RegExp(`subjects:\\s*\\[.*['"]${s}\\.[*>]`).test(n)},Kg=e=>{if(e.includes("@crossdelta/cloudevents"))return e;let t=`import { consumeJetStreamEvents, ensureJetStreamStream } from '@crossdelta/cloudevents'
45
+ `,c=(0,an.join)(r,`${n}.ts`);return(0,gt.existsSync)(r)||(0,gt.mkdirSync)(r,{recursive:!0}),(0,gt.writeFileSync)(c,a,"utf-8"),c},ps=e=>{let{eventsPath:t}=G(),{eventName:r}=kt(e);return(0,an.join)(t,`${r}.ts`)},qo=e=>{let t=ps(e);if(!(0,gt.existsSync)(t))return null;let r=(0,gt.readFileSync)(t,"utf-8"),n=r.match(/export const \w+Schema\s*=\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m);if(n)return n[1];let s=r.match(/schema:\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m);return s?s[1]:null},Yo=()=>{let{packagePath:e}=G(),t=(0,an.join)(e,"package.json");if(!(0,gt.existsSync)(t))return"@my-platform";try{return JSON.parse((0,gt.readFileSync)(t,"utf-8")).name?.split("/")[0]??"@my-platform"}catch{return"@my-platform"}};var ds=require("node:fs"),Qo=require("node:path");var Q=require("node:fs"),rr=require("node:path");var fs=e=>e.split(".")[0].toUpperCase(),Lu=(e,t)=>{let r=(0,rr.join)(e,"src","index.ts");if(!(0,Q.existsSync)(r))return!1;let n=(0,Q.readFileSync)(r,"utf-8"),s=t.toLowerCase();return n.includes(`stream: '${t}'`)?!0:new RegExp(`subjects:\\s*\\[.*['"]${s}\\.[*>]`).test(n)},Zg=e=>{if(e.includes("@crossdelta/cloudevents"))return e;let t=`import { consumeJetStreamEvents, ensureJetStreamStream } from '@crossdelta/cloudevents'
46
46
  `,r=e.match(/import\s+['"]@crossdelta\/telemetry['"]\s*\n/);if(r){let s=(r.index??0)+r[0].length;return`${e.slice(0,s)}
47
- ${t}${e.slice(s)}`}let n=e.match(/import\s+.*\n/);if(n){let s=(n.index??0)+n[0].length;return e.slice(0,s)+t+e.slice(s)}return e},Jg=(e,t,r)=>`
47
+ ${t}${e.slice(s)}`}let n=e.match(/import\s+.*\n/);if(n){let s=(n.index??0)+n[0].length;return e.slice(0,s)+t+e.slice(s)}return e},Xg=(e,t,r)=>`
48
48
 
49
49
  // ${e} stream (${t}.* events)
50
50
  await ensureJetStreamStream({
@@ -56,33 +56,33 @@ consumeJetStreamEvents({
56
56
  stream: '${e}',
57
57
  consumer: '${r}-service',
58
58
  discover: './src/events/**/*.event.ts',
59
- })`,Ko=(e,t)=>{let r=is(t),n=t.split(".")[0],s=(0,tr.join)(e,"src","index.ts"),o=(0,tr.join)(e,"src","main.ts");if(!(0,Q.existsSync)(s)&&(0,Q.existsSync)(o))return{added:!1,streamName:r};if(!(0,Q.existsSync)(s))return{added:!1,streamName:r,warning:"Entry point not found (index.ts or main.ts)"};if(Mu(e,r))return{added:!1,streamName:r};let i=(0,Q.readFileSync)(s,"utf-8"),a=e.split("/").pop()||"unknown";i.includes("consumeJetStreamEvents")||(i=Kg(i));let c=Jg(r,n,a),u=`${i.trimEnd()+c}
60
- `;return(0,Q.writeFileSync)(s,u,"utf-8"),{added:!0,streamName:r}},Jo=(e,t)=>{let{eventName:r,contractName:n,typeName:s}=Et(e),o=zo(),i=(0,tr.join)(t,"src","events"),a=(0,tr.join)(i,`${r}.event.ts`);if((0,Q.existsSync)(a))return null;let c=`import { handleEvent } from '@crossdelta/cloudevents'
59
+ })`,Zo=(e,t)=>{let r=fs(t),n=t.split(".")[0],s=(0,rr.join)(e,"src","index.ts"),o=(0,rr.join)(e,"src","main.ts");if(!(0,Q.existsSync)(s)&&(0,Q.existsSync)(o))return{added:!1,streamName:r};if(!(0,Q.existsSync)(s))return{added:!1,streamName:r,warning:"Entry point not found (index.ts or main.ts)"};if(Lu(e,r))return{added:!1,streamName:r};let i=(0,Q.readFileSync)(s,"utf-8"),a=e.split("/").pop()||"unknown";i.includes("consumeJetStreamEvents")||(i=Zg(i));let c=Xg(r,n,a),u=`${i.trimEnd()+c}
60
+ `;return(0,Q.writeFileSync)(s,u,"utf-8"),{added:!0,streamName:r}},Xo=(e,t)=>{let{eventName:r,contractName:n,typeName:s}=kt(e),o=Yo(),i=(0,rr.join)(t,"src","events"),a=(0,rr.join)(i,`${r}.event.ts`);if((0,Q.existsSync)(a))return null;let c=`import { handleEvent } from '@crossdelta/cloudevents'
61
61
  import { ${n}, type ${s} } from '${o}/contracts'
62
62
 
63
63
  export default handleEvent(${n}, async (data: ${s}) => {
64
64
  // TODO: Implement event handling logic
65
65
  console.log('Received ${e}:', data)
66
66
  })
67
- `;return(0,Q.existsSync)(i)||(0,Q.mkdirSync)(i,{recursive:!0}),(0,Q.writeFileSync)(a,c,"utf-8"),a};var $u=e=>{try{return(0,as.readdirSync)(e,{withFileTypes:!0}).flatMap(r=>{let n=(0,Vo.join)(e,r.name);return r.isDirectory()?$u(n):r.name.endsWith(".event.ts")?[n]:[]})}catch{return[]}},qo=e=>{let t=(0,Vo.join)(e,"src","events");return $u(t).flatMap(n=>{let s=(0,as.readFileSync)(n,"utf-8");return Vg(n,s)})},Vg=(e,t)=>{let r=qg(t);if(!r)return[];let o=(r.replace(/Contract$/,"").match(/[A-Z][a-z]*/g)??[]).map(i=>i.toLowerCase()).join(".");return[{filePath:e,eventType:o,contractName:r}]},qg=e=>{let r=/import\s+{([^}]+)}\s+from\s+['"]@[\w-]+\/contracts['"]/.exec(e);return r?r[1].split(",").map(o=>o.trim()).filter(o=>o.endsWith("Contract")).map(o=>o.replace(/\s+as\s+.+$/,"").trim()).at(0)??null:null},Yo=e=>{let t=e.reduce((r,n)=>{let s=n.eventType.split(".")[0],o=r.get(s)??[];return r.set(s,[...o,n]),r},new Map);return Array.from(t.entries()).map(([r,n])=>Yg(r,n)).sort((r,n)=>r.stream.localeCompare(n.stream))},Yg=(e,t)=>{let r=is(t[0]?.eventType??`${e}.event`),n=`${e}.>`;return{stream:r,subjects:[n],handlers:t}},Zo=(e,t)=>e.length===0?"":` await ensureJetStreamStreams({
67
+ `;return(0,Q.existsSync)(i)||(0,Q.mkdirSync)(i,{recursive:!0}),(0,Q.writeFileSync)(a,c,"utf-8"),a};var Wu=e=>{try{return(0,ds.readdirSync)(e,{withFileTypes:!0}).flatMap(r=>{let n=(0,Qo.join)(e,r.name);return r.isDirectory()?Wu(n):r.name.endsWith(".event.ts")?[n]:[]})}catch{return[]}},ti=e=>{let t=(0,Qo.join)(e,"src","events");return Wu(t).flatMap(n=>{let s=(0,ds.readFileSync)(n,"utf-8");return Qg(n,s)})},Qg=(e,t)=>{let r=tD(t);if(!r)return[];let o=(r.replace(/Contract$/,"").match(/[A-Z][a-z]*/g)??[]).map(i=>i.toLowerCase()).join(".");return[{filePath:e,eventType:o,contractName:r}]},tD=e=>{let r=/import\s+{([^}]+)}\s+from\s+['"]@[\w-]+\/contracts['"]/.exec(e);return r?r[1].split(",").map(o=>o.trim()).filter(o=>o.endsWith("Contract")).map(o=>o.replace(/\s+as\s+.+$/,"").trim()).at(0)??null:null},ei=e=>{let t=e.reduce((r,n)=>{let s=n.eventType.split(".")[0],o=r.get(s)??[];return r.set(s,[...o,n]),r},new Map);return Array.from(t.entries()).map(([r,n])=>eD(r,n)).sort((r,n)=>r.stream.localeCompare(n.stream))},eD=(e,t)=>{let r=fs(t[0]?.eventType??`${e}.event`),n=`${e}.>`;return{stream:r,subjects:[n],handlers:t}},ri=(e,t)=>e.length===0?"":` await ensureJetStreams({
68
68
  streams: [
69
69
  ${e.map(n=>{let s=n.subjects.map(o=>`'${o}'`).join(", ");return` { stream: '${n.stream}', subjects: [${s}] }`}).join(`,
70
70
  `)}
71
71
  ],
72
72
  })
73
73
 
74
- consumeJetStreamStreams({
74
+ consumeJetStreams({
75
75
  streams: [${e.map(n=>`'${n.stream}'`).join(", ")}],
76
76
  consumer: '${t}',
77
77
  discover: './src/events/**/*.event.ts',
78
- })`;var er=require("node:fs"),Bu=require("node:path");var cs=(e,t)=>{if(!(0,er.existsSync)(e))return!1;let r=`export * from './events/${t}'`,n=(0,er.readFileSync)(e,"utf-8");if(n.includes(`'./events/${t}'`))return!1;let s=n.split(`
79
- `),o=s.findLastIndex(i=>i.startsWith("export"));return o>=0?s.splice(o+1,0,r):s.push("",r),(0,er.writeFileSync)(e,s.join(`
80
- `),"utf-8"),!0},Xo=e=>{let{packagePath:t}=G(),{eventName:r}=Et(e),n=(0,Bu.join)(t,"src","index.ts");return cs(n,r)};var nt=require("node:fs"),Yt=require("node:path"),F=require("@faker-js/faker");var ju=[{pattern:"email",generate:()=>F.faker.internet.email(),hint:"email"},{pattern:"id",generate:()=>F.faker.string.uuid(),hint:"uuid"},{pattern:"firstname",generate:()=>F.faker.person.firstName(),hint:"firstName"},{pattern:"lastname",generate:()=>F.faker.person.lastName(),hint:"lastName"},{pattern:"name",generate:()=>F.faker.person.fullName(),hint:"fullName"},{pattern:"phone",generate:()=>F.faker.phone.number(),hint:"phoneNumber"},{pattern:"address",generate:()=>F.faker.location.streetAddress(),hint:"streetAddress"},{pattern:"street",generate:()=>F.faker.location.streetAddress(),hint:"streetAddress"},{pattern:"city",generate:()=>F.faker.location.city(),hint:"city"},{pattern:"country",generate:()=>F.faker.location.country(),hint:"country"},{pattern:"price",generate:()=>F.faker.number.float({min:10,max:1e3,fractionDigits:2}),hint:"price"},{pattern:"amount",generate:()=>F.faker.number.float({min:10,max:1e3,fractionDigits:2}),hint:"price"},{pattern:"total",generate:()=>F.faker.number.float({min:10,max:1e3,fractionDigits:2}),hint:"price"},{pattern:"quantity",generate:()=>F.faker.number.int({min:1,max:10}),hint:"quantity"},{pattern:"date",generate:()=>F.faker.date.recent().toISOString(),hint:"date"},{pattern:"createdat",generate:()=>F.faker.date.recent().toISOString(),hint:"date"},{pattern:"updatedat",generate:()=>F.faker.date.recent().toISOString(),hint:"date"}],_u=e=>({email:()=>F.faker.internet.email(),datetime:()=>F.faker.date.recent().toISOString(),url:()=>F.faker.internet.url(),uuid:()=>F.faker.string.uuid(),date:()=>F.faker.date.recent().toISOString().split("T")[0],time:()=>F.faker.date.recent().toISOString().split("T")[1]?.split(".")[0]})[e]?.()??F.faker.lorem.word(),Lu=e=>{let t=e.toLowerCase(),r=ju.find(n=>t.includes(n.pattern));return r?{value:r.generate(),hint:r.hint}:null},Zg=(e,t)=>{if(e.format)return _u(e.format);let r=Lu(t);if(r)return r.value;switch(e.type){case"string":return F.faker.lorem.word();case"number":return F.faker.number.int({min:1,max:100});case"boolean":return F.faker.datatype.boolean();case"array":return e.element?[Qo(e.element)]:[];case"object":return Qo(e);default:return null}},Qo=e=>{let t={},r=e.shape??(typeof e.def?.shape=="function"?e.def.shape():void 0);if(!r)return t;for(let[n,s]of Object.entries(r))t[n]=Zg(s,n);return t},Xg=async e=>{try{let{createJiti:t}=await import("jiti"),n=t(process.cwd(),{interopDefault:!0})(e),s=Object.entries(n).find(([o])=>o.endsWith("Schema")||o==="schema");if(s?.[1]){let o=s[1],i=Qo(o);if(i&&typeof i=="object"&&Object.keys(i).length>0){let a={};return ti(i,a,""),{data:i,faker:a}}}}catch{}return null},ti=(e,t,r)=>{if(!(!e||typeof e!="object"))for(let[n,s]of Object.entries(e)){let o=r?`${r}.${n}`:n,i=n.toLowerCase(),a=ju.find(c=>i.includes(c.pattern));a&&(a.hint!=="uuid"||typeof s=="string")&&(t[o]=a.hint),typeof s=="object"&&s!==null&&!Array.isArray(s)?ti(s,t,o):Array.isArray(s)&&s.length>0&&typeof s[0]=="object"&&ti(s[0],t,`${o}[0]`)}},Qg=e=>({string:()=>F.faker.lorem.word(),number:()=>F.faker.number.int({min:1,max:100}),boolean:()=>F.faker.datatype.boolean()})[e]?.(),tD=(e,t,r)=>{let n=/(\w+):\s*z\.(\w+)\(/g,s=Array.from(e.matchAll(n));for(let[,o,i]of s){if(i==="array"||i==="object")continue;let a=Lu(o);if(a)t[o]=a.value,a.hint&&(r[o]=a.hint);else{let c=Qg(i);c!==void 0&&(t[o]=c)}}},eD=(e,t,r)=>{let n=/(\w+):\s*z\.string\(\)\.(datetime|email|url|uuid)\(\)/g,s=Array.from(e.matchAll(n));for(let[,o,i]of s)t[o]=_u(i),r[o]=i==="datetime"?"date":i},Wu=e=>{let t={},r={};return tD(e,t,r),eD(e,t,r),{data:t,faker:r}},us=async e=>{let{eventsPath:t}=G(),{eventName:r}=Et(e),n=os(e);if(!(0,nt.existsSync)(n))return null;let o=(0,nt.readFileSync)(n,"utf-8").match(/type:\s*['"]([^'"]+)['"]/),i=o?o[1]:e,a=await Xg(n);if(!a){let l=Uo(e);l&&(a=Wu(l))}if(!a)return null;let c={eventName:i,description:`Mock data for ${i} event`,data:a.data};Object.keys(a.faker).length>0&&(c.faker=a.faker);let u=(0,Yt.join)(t,`${r}.mock.json`);return(0,nt.writeFileSync)(u,JSON.stringify(c,null,2),"utf-8"),u};var Gu=e=>{let t=e.match(/import\s+\{[^}]*?(\w+Contract)[^}]*?\}\s+from\s+['"][^'"]+\/contracts['"]/);return t?t[1].replace("Contract","").replace(/([A-Z])/g,(n,s,o)=>(o>0?".":"")+s.toLowerCase()):null},rD=(e,t,r)=>{if(!(0,nt.existsSync)(e))return!1;let n=(0,nt.readFileSync)(e,"utf-8"),s=n.match(/export const \w+(?:Schema|Data)\s*=\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m)??n.match(/schema:\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m);if(!s)return!1;let o=Wu(s[1]),i={eventName:r,description:`Mock data for ${r} event`,data:o.data};return Object.keys(o.faker).length>0&&(i.faker=o.faker),(0,nt.writeFileSync)(t,JSON.stringify(i,null,2)),!0},ei=async(e,t={})=>{let r=(0,Yt.join)(e,"src","events");if(!(0,nt.existsSync)(r))return{mockPaths:[],skippedHandlers:[]};let n=(0,nt.readdirSync)(r).filter(i=>i.endsWith(".event.ts")).map(i=>(0,Yt.join)(r,i)),s=[],o=[];for(let i of n){let a=(0,nt.readFileSync)(i,"utf-8"),c=Gu(a);if(!c){o.push(`${(0,Yt.basename)(i)} (Handler does not use contracts)`);continue}let{eventName:u}=Et(c),l=t.outputDir??G().eventsPath,p=(0,Yt.join)(l,`${u}.mock.json`);if((0,nt.existsSync)(p)&&!t.overwrite){o.push(`${(0,Yt.basename)(i)} (Mock already exists)`);continue}if(t.outputDir){let f=(0,Yt.join)(t.outputDir,`${u}.ts`);rD(f,p,c)&&s.push(p);continue}let d=await us(c);d&&s.push(d)}return{mockPaths:s,skippedHandlers:o}};var zu=e=>{let t=e.split("/").pop()||"service",r=(0,Hu.join)(e,"src","events","events.service.ts");if(!(0,ls.existsSync)(r))return!1;let n=qo(e);if(n.length===0||(0,ls.readFileSync)(r,"utf-8").replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").includes("await ensureJetStreamStreams"))return!1;let a=Yo(n),c=Zo(a,t);if(!c)return!1;let u=new Uu.Project({skipAddingFilesFromTsConfig:!0,skipFileDependencyResolution:!0}),l=u.addSourceFileAtPath(r),p=!1;for(let d of l.getClasses()){let f=d.getMethod("startConsumers");if(!f)continue;let h=[...c.split(`
78
+ })`;var nr=require("node:fs"),Gu=require("node:path");var hs=(e,t)=>{if(!(0,nr.existsSync)(e))return!1;let r=`export * from './events/${t}'`,n=(0,nr.readFileSync)(e,"utf-8");if(n.includes(`'./events/${t}'`))return!1;let s=n.split(`
79
+ `),o=s.findLastIndex(i=>i.startsWith("export"));return o>=0?s.splice(o+1,0,r):s.push("",r),(0,nr.writeFileSync)(e,s.join(`
80
+ `),"utf-8"),!0},ni=e=>{let{packagePath:t}=G(),{eventName:r}=kt(e),n=(0,Gu.join)(t,"src","index.ts");return hs(n,r)};var nt=require("node:fs"),Yt=require("node:path"),F=require("@faker-js/faker");var Hu=[{pattern:"email",generate:()=>F.faker.internet.email(),hint:"email"},{pattern:"id",generate:()=>F.faker.string.uuid(),hint:"uuid"},{pattern:"firstname",generate:()=>F.faker.person.firstName(),hint:"firstName"},{pattern:"lastname",generate:()=>F.faker.person.lastName(),hint:"lastName"},{pattern:"name",generate:()=>F.faker.person.fullName(),hint:"fullName"},{pattern:"phone",generate:()=>F.faker.phone.number(),hint:"phoneNumber"},{pattern:"address",generate:()=>F.faker.location.streetAddress(),hint:"streetAddress"},{pattern:"street",generate:()=>F.faker.location.streetAddress(),hint:"streetAddress"},{pattern:"city",generate:()=>F.faker.location.city(),hint:"city"},{pattern:"country",generate:()=>F.faker.location.country(),hint:"country"},{pattern:"price",generate:()=>F.faker.number.float({min:10,max:1e3,fractionDigits:2}),hint:"price"},{pattern:"amount",generate:()=>F.faker.number.float({min:10,max:1e3,fractionDigits:2}),hint:"price"},{pattern:"total",generate:()=>F.faker.number.float({min:10,max:1e3,fractionDigits:2}),hint:"price"},{pattern:"quantity",generate:()=>F.faker.number.int({min:1,max:10}),hint:"quantity"},{pattern:"date",generate:()=>F.faker.date.recent().toISOString(),hint:"date"},{pattern:"createdat",generate:()=>F.faker.date.recent().toISOString(),hint:"date"},{pattern:"updatedat",generate:()=>F.faker.date.recent().toISOString(),hint:"date"}],Uu=e=>({email:()=>F.faker.internet.email(),datetime:()=>F.faker.date.recent().toISOString(),url:()=>F.faker.internet.url(),uuid:()=>F.faker.string.uuid(),date:()=>F.faker.date.recent().toISOString().split("T")[0],time:()=>F.faker.date.recent().toISOString().split("T")[1]?.split(".")[0]})[e]?.()??F.faker.lorem.word(),zu=e=>{let t=e.toLowerCase(),r=Hu.find(n=>t.includes(n.pattern));return r?{value:r.generate(),hint:r.hint}:null},rD=(e,t)=>{if(e.format)return Uu(e.format);let r=zu(t);if(r)return r.value;switch(e.type){case"string":return F.faker.lorem.word();case"number":return F.faker.number.int({min:1,max:100});case"boolean":return F.faker.datatype.boolean();case"array":return e.element?[si(e.element)]:[];case"object":return si(e);default:return null}},si=e=>{let t={},r=e.shape??(typeof e.def?.shape=="function"?e.def.shape():void 0);if(!r)return t;for(let[n,s]of Object.entries(r))t[n]=rD(s,n);return t},nD=async e=>{try{let{createJiti:t}=await import("jiti"),n=t(process.cwd(),{interopDefault:!0})(e),s=Object.entries(n).find(([o])=>o.endsWith("Schema")||o==="schema");if(s?.[1]){let o=s[1],i=si(o);if(i&&typeof i=="object"&&Object.keys(i).length>0){let a={};return oi(i,a,""),{data:i,faker:a}}}}catch{}return null},oi=(e,t,r)=>{if(!(!e||typeof e!="object"))for(let[n,s]of Object.entries(e)){let o=r?`${r}.${n}`:n,i=n.toLowerCase(),a=Hu.find(c=>i.includes(c.pattern));a&&(a.hint!=="uuid"||typeof s=="string")&&(t[o]=a.hint),typeof s=="object"&&s!==null&&!Array.isArray(s)?oi(s,t,o):Array.isArray(s)&&s.length>0&&typeof s[0]=="object"&&oi(s[0],t,`${o}[0]`)}},sD=e=>({string:()=>F.faker.lorem.word(),number:()=>F.faker.number.int({min:1,max:100}),boolean:()=>F.faker.datatype.boolean()})[e]?.(),oD=(e,t,r)=>{let n=/(\w+):\s*z\.(\w+)\(/g,s=Array.from(e.matchAll(n));for(let[,o,i]of s){if(i==="array"||i==="object")continue;let a=zu(o);if(a)t[o]=a.value,a.hint&&(r[o]=a.hint);else{let c=sD(i);c!==void 0&&(t[o]=c)}}},iD=(e,t,r)=>{let n=/(\w+):\s*z\.string\(\)\.(datetime|email|url|uuid)\(\)/g,s=Array.from(e.matchAll(n));for(let[,o,i]of s)t[o]=Uu(i),r[o]=i==="datetime"?"date":i},Ku=e=>{let t={},r={};return oD(e,t,r),iD(e,t,r),{data:t,faker:r}},ms=async e=>{let{eventsPath:t}=G(),{eventName:r}=kt(e),n=ps(e);if(!(0,nt.existsSync)(n))return null;let o=(0,nt.readFileSync)(n,"utf-8").match(/type:\s*['"]([^'"]+)['"]/),i=o?o[1]:e,a=await nD(n);if(!a){let l=qo(e);l&&(a=Ku(l))}if(!a)return null;let c={eventName:i,description:`Mock data for ${i} event`,data:a.data};Object.keys(a.faker).length>0&&(c.faker=a.faker);let u=(0,Yt.join)(t,`${r}.mock.json`);return(0,nt.writeFileSync)(u,JSON.stringify(c,null,2),"utf-8"),u};var Ju=e=>{let t=e.match(/import\s+\{[^}]*?(\w+Contract)[^}]*?\}\s+from\s+['"][^'"]+\/contracts['"]/);return t?t[1].replace("Contract","").replace(/([A-Z])/g,(n,s,o)=>(o>0?".":"")+s.toLowerCase()):null},aD=(e,t,r)=>{if(!(0,nt.existsSync)(e))return!1;let n=(0,nt.readFileSync)(e,"utf-8"),s=n.match(/export const \w+(?:Schema|Data)\s*=\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m)??n.match(/schema:\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m);if(!s)return!1;let o=Ku(s[1]),i={eventName:r,description:`Mock data for ${r} event`,data:o.data};return Object.keys(o.faker).length>0&&(i.faker=o.faker),(0,nt.writeFileSync)(t,JSON.stringify(i,null,2)),!0},ii=async(e,t={})=>{let r=(0,Yt.join)(e,"src","events");if(!(0,nt.existsSync)(r))return{mockPaths:[],skippedHandlers:[]};let n=(0,nt.readdirSync)(r).filter(i=>i.endsWith(".event.ts")).map(i=>(0,Yt.join)(r,i)),s=[],o=[];for(let i of n){let a=(0,nt.readFileSync)(i,"utf-8"),c=Ju(a);if(!c){o.push(`${(0,Yt.basename)(i)} (Handler does not use contracts)`);continue}let{eventName:u}=kt(c),l=t.outputDir??G().eventsPath,p=(0,Yt.join)(l,`${u}.mock.json`);if((0,nt.existsSync)(p)&&!t.overwrite){o.push(`${(0,Yt.basename)(i)} (Mock already exists)`);continue}if(t.outputDir){let f=(0,Yt.join)(t.outputDir,`${u}.ts`);aD(f,p,c)&&s.push(p);continue}let d=await ms(c);d&&s.push(d)}return{mockPaths:s,skippedHandlers:o}};var Yu=e=>{let t=e.split("/").pop()||"service",r=(0,Vu.join)(e,"src","events","events.service.ts");if(!(0,gs.existsSync)(r))return!1;let n=ti(e);if(n.length===0||(0,gs.readFileSync)(r,"utf-8").replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").includes("await ensureJetStreams"))return!1;let a=ei(n),c=ri(a,t);if(!c)return!1;let u=new qu.Project({skipAddingFilesFromTsConfig:!0,skipFileDependencyResolution:!0}),l=u.addSourceFileAtPath(r),p=!1;for(let d of l.getClasses()){let f=d.getMethod("startConsumers");if(!f)continue;let h=[...c.split(`
81
81
  `),""," this.logger.log('Event consumers started successfully')"].join(`
82
- `);f.setBodyText(h),p=!0;break}return p&&u.saveSync(),p};var nD=e=>{let t=e.split(/\s+/),r=t[0],n=t.slice(1);return r==="pf"&&(r=process.argv[1]),{executable:r,args:n}},sD=async(e,t)=>{try{let{executable:r,args:n}=nD(e.command);return await pe(r,n,{cwd:t,shell:!1}),{command:e.command,success:!0}}catch(r){return{command:e.command,success:!1,error:r instanceof Error?r.message:String(r)}}},ri=async(e,t)=>{let r=[];for(let n of e){let s=await sD(n,t);if(r.push(s),!s.success)break}return r},ni=e=>{let t=[/^pf\s+/,/^bun\s+pf\s+/,/^npx\s+pf\s+/,/^bunx\s+pf\s+/];return e.filter(r=>t.some(n=>n.test(r.command)))},Ku=e=>{for(let t of e){let r=t.command.match(/(?:bun\s+)?pf\s+new\s+\S+\s+(\S+)/);if(r)return r[1]}return null};var en=require("node:fs"),fs=require("node:path"),$t=b(require("chalk"));var xe=require("node:fs"),ps=require("node:path"),oD=(e,t)=>{let n=e.path.startsWith("packages/")&&t.workspaceRoot?t.workspaceRoot:t.baseDir,s=(0,ps.join)(n,e.path);try{if((0,xe.existsSync)(s)&&!t.overwrite)return{status:"skipped",path:e.path};if(t.dryRun)return{status:"written",path:e.path};let o=(0,ps.dirname)(s);return(0,xe.existsSync)(o)||(0,xe.mkdirSync)(o,{recursive:!0}),(0,xe.writeFileSync)(s,e.content,"utf-8"),{status:"written",path:e.path}}catch(o){return{status:"failed",path:e.path,error:o.message}}},Ju=(e,t)=>{let r=e.map(n=>oD(n,t));return{written:r.filter(n=>n.status==="written").map(n=>n.path),skipped:r.filter(n=>n.status==="skipped").map(n=>n.path),failed:r.filter(n=>n.status==="failed").map(n=>({path:n.path,error:n.error}))}};var iD=(e,t)=>{let r=vt(t.workspaceRoot),n=(0,fs.join)(t.workspaceRoot,r.contracts);if(!(0,en.existsSync)(n))return[];let s=/import\s+(?:type\s+)?{([^}]+)}\s+from\s+['"]@\w+\/contracts['"]/g,o=new Set;for(let i of e){let a=i.content.matchAll(s);for(let c of a){let l=c[1].split(",").map(p=>p.trim()).map(p=>p.replace(/^type\s+/,"").replace(/\s+as\s+.+$/,"").trim()).filter(p=>p.endsWith("Contract"));for(let p of l)o.add(p)}}return Array.from(o).sort()},aD=e=>{let t=(0,fs.join)(e,"packages/contracts/src/index.ts");if(!(0,en.existsSync)(t))return new Set;try{let r=(0,en.readFileSync)(t,"utf-8"),n=new Set,s=/export\s+(?:\*|{[^}]*Contract[^}]*})\s+from\s+['"]\.\/events\/([^'"]+)['"]/g,o=r.matchAll(s);for(let i of o){let a=i[0],c=/(\w+Contract)/g,u=a.matchAll(c);for(let l of u)n.add(l[1])}return n}catch{return new Set}},cD=e=>{let t=e.replace(/Contract$/,""),r=t.split(/(?=[A-Z])/).filter(Boolean);if(r.length<2)return t.toLowerCase();let n=r[0].toLowerCase(),s=r.slice(1).join("").toLowerCase();return`${n}.${s}`},uD=(e,t,r)=>{let n=aD(t),s=[],o=[],i=[];for(let a of e)if(n.has(a))s.push(a);else{o.push(a);let c=cD(a),u=r.replace(`${t}/`,"");i.push(`pf event add ${c} --service ${u}`)}return{existing:s,missing:o,suggestedCommands:i}},lD=(e,t)=>{if(e.length!==0){console.log($t.default.cyan(`\u{1F4E6} Using existing contracts:
83
- `));for(let r of e)console.log($t.default.dim(` ${t}/contracts \u2192 ${r}`));console.log()}},pD=(e,t)=>{let r=/^packages\/contracts\/src\/events\/([^/]+)\.ts$/,n=(0,fs.join)(t,"packages/contracts/src/index.ts");for(let s of e){let o=s.match(r);o&&o[1]!=="index"&&cs(n,o[1])}},Vu=async(e,t)=>{t.start("Applying code formatting...");try{await qt("biome",["check","--fix","--unsafe",e],{cwd:process.cwd(),quiet:!0}),t.succeed("Code formatted!")}catch{t.warn("Code formatting completed with warnings")}},fD=async(e,t)=>{t.start("Scanning for event handlers...");let{mockPaths:r,skippedHandlers:n}=await ei(e);if(r.length+n.length===0){t.info("No event handlers found");return}if(r.length>0){t.succeed(`Generated ${r.length} event ${r.length===1?"mock":"mocks"}`),console.log();for(let o of r){let i=o.replace(`${e}/`,"");console.log($t.default.dim(` ${i}`))}console.log()}else t.succeed("Event handlers found");if(n.length>0){for(let o of n)console.log($t.default.dim(` \u2139 Skipped: ${o}`));console.log()}},qu=async(e,t,r,n)=>{n.start("Writing generated files...");let s=Ju(e,{baseDir:t,workspaceRoot:r.workspaceRoot,overwrite:!0});if(s.written.length>0){n.succeed(`Created ${s.written.length} files`),console.log();for(let u of s.written)console.log($t.default.dim(` ${u}`));console.log()}else n.succeed("No files to write");let o=iD(e,r),{existing:i,missing:a,suggestedCommands:c}=uD(o,r.workspaceRoot,t);if(i.length>0&&lD(i,r.scope),a.length>0){console.log($t.default.yellow(`\u26A0\uFE0F Missing contracts (not exported from @${r.scope}/contracts):
82
+ `);f.setBodyText(h),p=!0;break}return p&&u.saveSync(),p};var cD=e=>{let t=e.split(/\s+/),r=t[0],n=t.slice(1);return r==="pf"&&(r=process.argv[1]),{executable:r,args:n}},uD=async(e,t)=>{try{let{executable:r,args:n}=cD(e.command);return await fe(r,n,{cwd:t,shell:!1}),{command:e.command,success:!0}}catch(r){return{command:e.command,success:!1,error:r instanceof Error?r.message:String(r)}}},ai=async(e,t)=>{let r=[];for(let n of e){let s=await uD(n,t);if(r.push(s),!s.success)break}return r},ci=e=>{let t=[/^pf\s+/,/^bun\s+pf\s+/,/^npx\s+pf\s+/,/^bunx\s+pf\s+/];return e.filter(r=>t.some(n=>n.test(r.command)))},Zu=e=>{for(let t of e){let r=t.command.match(/(?:bun\s+)?pf\s+new\s+\S+\s+(\S+)/);if(r)return r[1]}return null};var cn=require("node:fs"),ys=require("node:path"),$t=b(require("chalk"));var ke=require("node:fs"),Ds=require("node:path"),lD=(e,t)=>{let n=e.path.startsWith("packages/")&&t.workspaceRoot?t.workspaceRoot:t.baseDir,s=(0,Ds.join)(n,e.path);try{if((0,ke.existsSync)(s)&&!t.overwrite)return{status:"skipped",path:e.path};if(t.dryRun)return{status:"written",path:e.path};let o=(0,Ds.dirname)(s);return(0,ke.existsSync)(o)||(0,ke.mkdirSync)(o,{recursive:!0}),(0,ke.writeFileSync)(s,e.content,"utf-8"),{status:"written",path:e.path}}catch(o){return{status:"failed",path:e.path,error:o.message}}},Xu=(e,t)=>{let r=e.map(n=>lD(n,t));return{written:r.filter(n=>n.status==="written").map(n=>n.path),skipped:r.filter(n=>n.status==="skipped").map(n=>n.path),failed:r.filter(n=>n.status==="failed").map(n=>({path:n.path,error:n.error}))}};var pD=(e,t)=>{let r=vt(t.workspaceRoot),n=(0,ys.join)(t.workspaceRoot,r.contracts);if(!(0,cn.existsSync)(n))return[];let s=/import\s+(?:type\s+)?{([^}]+)}\s+from\s+['"]@\w+\/contracts['"]/g,o=new Set;for(let i of e){let a=i.content.matchAll(s);for(let c of a){let l=c[1].split(",").map(p=>p.trim()).map(p=>p.replace(/^type\s+/,"").replace(/\s+as\s+.+$/,"").trim()).filter(p=>p.endsWith("Contract"));for(let p of l)o.add(p)}}return Array.from(o).sort()},fD=e=>{let t=(0,ys.join)(e,"packages/contracts/src/index.ts");if(!(0,cn.existsSync)(t))return new Set;try{let r=(0,cn.readFileSync)(t,"utf-8"),n=new Set,s=/export\s+(?:\*|{[^}]*Contract[^}]*})\s+from\s+['"]\.\/events\/([^'"]+)['"]/g,o=r.matchAll(s);for(let i of o){let a=i[0],c=/(\w+Contract)/g,u=a.matchAll(c);for(let l of u)n.add(l[1])}return n}catch{return new Set}},dD=e=>{let t=e.replace(/Contract$/,""),r=t.split(/(?=[A-Z])/).filter(Boolean);if(r.length<2)return t.toLowerCase();let n=r[0].toLowerCase(),s=r.slice(1).join("").toLowerCase();return`${n}.${s}`},hD=(e,t,r)=>{let n=fD(t),s=[],o=[],i=[];for(let a of e)if(n.has(a))s.push(a);else{o.push(a);let c=dD(a),u=r.replace(`${t}/`,"");i.push(`pf event add ${c} --service ${u}`)}return{existing:s,missing:o,suggestedCommands:i}},mD=(e,t)=>{if(e.length!==0){console.log($t.default.cyan(`\u{1F4E6} Using existing contracts:
83
+ `));for(let r of e)console.log($t.default.dim(` ${t}/contracts \u2192 ${r}`));console.log()}},gD=(e,t)=>{let r=/^packages\/contracts\/src\/events\/([^/]+)\.ts$/,n=(0,ys.join)(t,"packages/contracts/src/index.ts");for(let s of e){let o=s.match(r);o&&o[1]!=="index"&&hs(n,o[1])}},Qu=async(e,t)=>{t.start("Applying code formatting...");try{await qt("biome",["check","--fix","--unsafe","."],{cwd:e,quiet:!0}),t.succeed("Code formatted!")}catch{t.warn("Code formatting completed with warnings")}},DD=async(e,t)=>{t.start("Scanning for event handlers...");let{mockPaths:r,skippedHandlers:n}=await ii(e);if(r.length+n.length===0){t.info("No event handlers found");return}if(r.length>0){t.succeed(`Generated ${r.length} event ${r.length===1?"mock":"mocks"}`),console.log();for(let o of r){let i=o.replace(`${e}/`,"");console.log($t.default.dim(` ${i}`))}console.log()}else t.succeed("Event handlers found");if(n.length>0){for(let o of n)console.log($t.default.dim(` \u2139 Skipped: ${o}`));console.log()}},tl=async(e,t,r,n)=>{n.start("Writing generated files...");let s=Xu(e,{baseDir:t,workspaceRoot:r.workspaceRoot,overwrite:!0});if(s.written.length>0){n.succeed(`Created ${s.written.length} files`),console.log();for(let u of s.written)console.log($t.default.dim(` ${u}`));console.log()}else n.succeed("No files to write");let o=pD(e,r),{existing:i,missing:a,suggestedCommands:c}=hD(o,r.workspaceRoot,t);if(i.length>0&&mD(i,r.scope),a.length>0){console.log($t.default.yellow(`\u26A0\uFE0F Missing contracts (not exported from @${r.scope}/contracts):
84
84
  `));for(let u of a)console.log($t.default.yellow(` ${u}`));console.log(),console.log($t.default.cyan(`\u{1F4A1} Run these commands to create the missing contracts:
85
- `));for(let u of c)console.log($t.default.dim(` ${u}`));console.log()}return pD(s.written,r.workspaceRoot),s.written.length>0&&await fD(t,n),{missingContractCommands:c}};var ds=require("node:fs"),nr=require("node:path");var rr=require("node:fs"),Yu=require("node:path");var Zu=e=>{let{eventsPath:t}=G(e);if(!(0,rr.existsSync)(t))return[];let r=[];try{let n=(0,rr.readdirSync)(t).filter(s=>s.endsWith(".ts")&&!s.endsWith(".mock.json")&&s!=="index.ts");for(let s of n){let o=(0,Yu.join)(t,s),i=(0,rr.readFileSync)(o,"utf-8"),a=dD(i,o);a&&r.push(a)}}catch(n){return console.warn("Warning: Could not scan contracts package:",n),[]}return r},dD=(e,t)=>{try{let r=e.match(/export const (\w+Contract) = createContract/);if(!r)return null;let n=r[1],s=e.match(/export type (\w+(?:Data|Event)) = z\.infer/);if(!s)return null;let o=s[1],i=e.match(/type:\s*['"]([^'"]+)['"]/);if(!i)return null;let a=i[1],c=mD(e);return{name:n,typeName:o,eventType:a,fields:c,filePath:t}}catch{return null}},hD={string:"string",number:"number",boolean:"boolean",array:"array",object:"object",date:"date"},mD=e=>{let t=e.match(/z\.object\({([^}]+)\}/);if(!t)return[];let r=t[1],n=/(\w+):\s*z\.(\w+)\([^)]*\)/g,s=[...r.matchAll(n)].map(([,a,c])=>{let u=hD[c]||c;return`${a}: ${u}`});if(!e.includes("z.array("))return s;let o=/(\w+):\s*z\.array\(/g,i=[...e.matchAll(o)].map(([,a])=>a).filter(a=>!s.some(c=>c.startsWith(a))).map(a=>`${a}: array`);return[...s,...i]},Xu=(e,t)=>{if(e.length===0)return`
85
+ `));for(let u of c)console.log($t.default.dim(` ${u}`));console.log()}return gD(s.written,r.workspaceRoot),s.written.length>0&&await DD(t,n),{missingContractCommands:c}};var ws=require("node:fs"),or=require("node:path");var sr=require("node:fs"),el=require("node:path");var rl=e=>{let{eventsPath:t}=G(e);if(!(0,sr.existsSync)(t))return[];let r=[];try{let n=(0,sr.readdirSync)(t).filter(s=>s.endsWith(".ts")&&!s.endsWith(".mock.json")&&s!=="index.ts");for(let s of n){let o=(0,el.join)(t,s),i=(0,sr.readFileSync)(o,"utf-8"),a=yD(i,o);a&&r.push(a)}}catch(n){return console.warn("Warning: Could not scan contracts package:",n),[]}return r},yD=(e,t)=>{try{let r=e.match(/export const (\w+Contract) = createContract/);if(!r)return null;let n=r[1],s=e.match(/export type (\w+(?:Data|Event)) = z\.infer/);if(!s)return null;let o=s[1],i=e.match(/type:\s*['"]([^'"]+)['"]/);if(!i)return null;let a=i[1],c=CD(e);return{name:n,typeName:o,eventType:a,fields:c,filePath:t}}catch{return null}},wD={string:"string",number:"number",boolean:"boolean",array:"array",object:"object",date:"date"},CD=e=>{let t=e.match(/z\.object\({([^}]+)\}/);if(!t)return[];let r=t[1],n=/(\w+):\s*z\.(\w+)\([^)]*\)/g,s=[...r.matchAll(n)].map(([,a,c])=>{let u=wD[c]||c;return`${a}: ${u}`});if(!e.includes("z.array("))return s;let o=/(\w+):\s*z\.array\(/g,i=[...e.matchAll(o)].map(([,a])=>a).filter(a=>!s.some(c=>c.startsWith(a))).map(a=>`${a}: array`);return[...s,...i]},nl=(e,t)=>{if(e.length===0)return`
86
86
  **Available Contracts:**
87
87
 
88
88
  No contracts are currently defined. Use Basic Mode with inline schemas for all events.
@@ -103,15 +103,15 @@ The following event contracts are available in \`${t}/contracts\`:
103
103
  ${r}
104
104
 
105
105
  If the event type your service consumes matches one of these, **you MUST use Advanced Mode**.
106
- `.trim()};var gD=(e,t)=>{let r=(0,nr.join)(__dirname,"docs","generators"),n=[];if(n.push((0,nr.join)(r,"service.md")),e==="nest")n.push((0,nr.join)(r,"nest.md"));else if(e==="hono"){let s=t==="bun";n.push((0,nr.join)(r,s?"hono-bun.md":"hono-node.md"))}return n},Qu={copilot:".github/copilot-instructions.md",projectGuidelines:"docs/ai-guidelines.md"},DD=1500,tl=e=>{try{return(0,ds.existsSync)(e)?(0,ds.readFileSync)(e,"utf-8"):null}catch{return null}},yD=e=>e.replace(/<!--[\s\S]*?-->/g,"").replace(/^\[.+\]:\s*.+$/gm,"").replace(/\n{3,}/g,`
106
+ `.trim()};var bD=(e,t)=>{let r=(0,or.join)(__dirname,"docs","generators"),n=Xr(),s=[];for(let o of n.docs.base)s.push((0,or.join)(r,o));if(e&&n.docs.frameworks[e]){let o=n.docs.frameworks[e];if(typeof o=="string")s.push((0,or.join)(r,o));else{let i=t==="bun"?"bun":"node";o[i]&&s.push((0,or.join)(r,o[i]))}}return s},sl={copilot:".github/copilot-instructions.md",projectGuidelines:"docs/ai-guidelines.md"},vD=1500,ol=e=>{try{return(0,ws.existsSync)(e)?(0,ws.readFileSync)(e,"utf-8"):null}catch{return null}},xD=e=>e.replace(/<!--[\s\S]*?-->/g,"").replace(/^\[.+\]:\s*.+$/gm,"").replace(/\n{3,}/g,`
107
107
 
108
- `).replace(/[ \t]+$/gm,"").trim(),wD=e=>e.replace(/<!--[\s\S]*?-->/g,"").replace(/^\[.+\]:\s*.+$/gm,"").replace(/```[\s\S]*?```/g,"").replace(/`[^`]{50,}`/g,"`...`").replace(/\n{3,}/g,`
108
+ `).replace(/[ \t]+$/gm,"").trim(),kD=e=>e.replace(/<!--[\s\S]*?-->/g,"").replace(/^\[.+\]:\s*.+$/gm,"").replace(/```[\s\S]*?```/g,"").replace(/`[^`]{50,}`/g,"`...`").replace(/\n{3,}/g,`
109
109
 
110
- `).replace(/[ \t]+$/gm,"").trim(),CD=e=>Math.ceil(e.length/4),bD=(e,t)=>{let r=e.split(/(?=^## )/m),n="",s=0;for(let o of r){let i=CD(o);if(s+i<=t)n+=o,s+=i;else if(s===0){n=o.slice(0,t*4);break}else break}return n.trim()},vD=(e,t)=>{let{workspaceRoot:r,scope:n}=t,s=Zu(r),o=Xu(s,n);return e.replace(/\{\{scope\}\}/g,n).replace(/\{\{AVAILABLE_CONTRACTS\}\}/g,o)},el=e=>{let{workspaceRoot:t,scope:r}=e,n=[],s=gD(e.serviceType,e.packageManager);for(let a of s){let c=tl(a);if(c){let u=vD(c,e),l=yD(u);n.push(l)}}let o=[Qu.copilot,Qu.projectGuidelines],i=Math.floor(DD/o.length);for(let a of o){let c=tl((0,nr.join)(t,a));if(c){let u=wD(c),l=bD(u,i);l.length>50&&n.push(l)}}return n.length===0?(console.warn("\u26A0\uFE0F No instruction files found."),`Use ${r}/contracts for shared types.`):n.join(`
110
+ `).replace(/[ \t]+$/gm,"").trim(),ED=e=>Math.ceil(e.length/4),SD=(e,t)=>{let r=e.split(/(?=^## )/m),n="",s=0;for(let o of r){let i=ED(o);if(s+i<=t)n+=o,s+=i;else if(s===0){n=o.slice(0,t*4);break}else break}return n.trim()},FD=(e,t)=>{let{workspaceRoot:r,scope:n}=t,s=rl(r),o=nl(s,n);return e.replace(/\{\{scope\}\}/g,n).replace(/\{\{AVAILABLE_CONTRACTS\}\}/g,o)},il=e=>{let{workspaceRoot:t,scope:r}=e,n=[],s=bD(e.serviceType,e.packageManager);for(let a of s){let c=ol(a);if(c){let u=FD(c,e),l=xD(u);n.push(l)}}let o=[sl.copilot,sl.projectGuidelines],i=Math.floor(vD/o.length);for(let a of o){let c=ol((0,or.join)(t,a));if(c){let u=kD(c),l=SD(u,i);l.length>50&&n.push(l)}}return n.length===0?(console.warn("\u26A0\uFE0F No instruction files found."),`Use ${r}/contracts for shared types.`):n.join(`
111
111
 
112
112
  ---
113
113
 
114
- `)};var xD=`You are an expert code generator. Generate clean, production-ready code.
114
+ `)};var TD=`You are an expert code generator. Generate clean, production-ready code.
115
115
 
116
116
  ## Output Format
117
117
 
@@ -125,13 +125,13 @@ Format your code blocks with the file path on the line before the code block:
125
125
  **IMPORTANT:** Always generate:
126
126
  - Source code files (src/**)
127
127
  - Test files (src/**/*.test.ts) for all business logic
128
- - README.md with service documentation`,kD=e=>e.replace(/-/g,"_").toUpperCase(),ED=e=>e.split("/").pop()||"my-service",rl=(e,t,r)=>{let n=el({...e,serviceType:t,packageManager:r});return`${xD}
128
+ - README.md with service documentation`,AD=e=>e.replace(/-/g,"_").toUpperCase(),PD=e=>e.split("/").pop()||"my-service",al=(e,t,r)=>{let n=il({...e,serviceType:t,packageManager:r});return`${TD}
129
129
 
130
130
  ## Project Guidelines & Patterns
131
131
 
132
132
  Follow these project-specific conventions and patterns when generating code:
133
133
 
134
- ${n}`},nl=(e,t,r)=>{let n=ED(e),s=`${kD(n)}_PORT`;return`Generate source code for a microservice at path "${e}".
134
+ ${n}`},cl=(e,t,r)=>{let n=PD(e),s=`${AD(n)}_PORT`;return`Generate source code for a microservice at path "${e}".
135
135
 
136
136
  Use the patterns and conventions from the Project Guidelines above.
137
137
 
@@ -140,57 +140,57 @@ Service purpose: ${t}
140
140
  **CRITICAL:**
141
141
  - Service name: "${n}"
142
142
  - Port env var: Use \`process.env.${s}\` (NOT SERVICE_NAME_PORT)
143
- - Consumer name: Use "${n}" as the consumer name in consumeJetStreamStreams
143
+ - Consumer name: Use "${n}" as the consumer name in consumeJetStreams
144
144
 
145
145
  Do NOT include the service path in file headers (use \`src/...\`, NOT \`${e}/src/...\`).
146
- `};var SD=()=>!1,sl=(e,t)=>{SD()&&console.log(`[AI Parser] ${e}`,t??"")},hs={commandsBlock:/```commands\n([\s\S]*?)```/gi,postCommandsBlock:/```post-commands\n([\s\S]*?)```/gi,dependenciesBlock:/```dependencies\n([\s\S]*?)```/gi,fileHeader:/^#{1,4}\s+`([^`]+)`\s*$/},oi=(e,t)=>[...e.matchAll(t)].flatMap(n=>n[1].split(`
147
- `).map(s=>s.trim()).filter(s=>s.length>0&&!s.startsWith("#"))),ol=e=>({command:e,isPfCommand:e.startsWith("pf ")||e.includes(" pf ")}),FD=e=>oi(e,hs.commandsBlock).map(ol),TD=e=>oi(e,hs.postCommandsBlock).map(ol),AD=e=>oi(e,hs.dependenciesBlock).filter(t=>!t.startsWith("@crossdelta/")&&t!=="zod"),PD=e=>{let t={ts:"typescript",js:"javascript",md:"markdown",yml:"yaml"},r=(e||"typescript").toLowerCase();return t[r]||r},RD=e=>{let t=e.split(".").pop()?.toLowerCase();return{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",json:"json",yaml:"yaml",yml:"yaml",md:"markdown"}[t||""]||"plaintext"},ID=e=>e.replace(/^\s*\/\/ \.{3,}.*$/gm,"").replace(/^\s*\/\/ Lines? \d+.*omitted.*$/gim,"").replace(/^\s*\/\* Lines? \d+.*omitted.*\*\/$/gim,"").trim(),ND=e=>{let t=e.split(`
148
- `),r=[],n=0;for(let s of t){let o=hs.fileHeader.exec(s);o&&r.push({path:o[1],index:n}),n+=s.length+1}return r},OD=(e,t)=>{let n=e.slice(t).match(/```(\w+)?\n([\s\S]*?)```/);return n?{language:n[1]?PD(n[1]):void 0,content:ID(n[2])}:null},MD=e=>ND(e).map(r=>{let n=OD(e,r.index);return!n||n.content.length===0?null:{path:r.path,language:n.language||RD(r.path),content:n.content,startIndex:r.index}}).filter(r=>r!==null),si=e=>e.includes("packages/contracts")||e.includes("contracts/src"),$D=e=>{let t=e.filter(n=>si(n.path)),r=e.filter(n=>!si(n.path));return[...t,...r]},BD=e=>{let t=e.replace(/^\/+/,"").replace(/\/{2,}/g,"/");if(si(t))return t;let r=t.match(/^services\/[^/]+\/(.+)$/);return r?r[1]:t},il=(e,t)=>{sl("Parsing AI response",{length:e.length});let r=FD(e),n=TD(e),s=AD(e),o=MD(e),i=$D(o.map(a=>({path:BD(a.path),content:a.content,language:a.language})));return sl("Parsed response",{commands:r.length,postCommands:n.length,dependencies:s.length,files:i.length}),{commands:r,files:i,dependencies:s,postCommands:n}},al=e=>{let t=e.filter(o=>!o.content||o.content.trim().length===0),r=e.length===0?["No files could be extracted from the AI response"]:t.map(o=>`File ${o.path} is empty`),n=e.some(o=>["src/index.ts","src/main.ts","index.ts"].includes(o.path)),s=e.length>0&&!n?["No entry point file (src/index.ts or src/main.ts) found - assuming it exists from scaffolding"]:[];return{valid:r.length===0,errors:r,warnings:s}};var cl=require("node:fs"),St=b(require("chalk"));var ul=async(e,t,r)=>{if(e.length===0){(0,cl.mkdirSync)(t,{recursive:!0}),console.log(St.default.yellow(`\u26A0 No scaffolding command found - creating empty directory
149
- `));return}let s=(await ri(e,r)).find(o=>!o.success);if(s)throw console.log(St.default.red(`
150
- \u2717 Scaffolding failed: ${s.command}`)),s.error&&console.log(St.default.red(` Error: ${s.error}`)),new Error(`Command failed: ${s.command}${s.error?` - ${s.error}`:""}`)},ll=async(e,t)=>{t.start("Linking workspace dependencies...");try{await kt({cwd:e,quiet:!0}),t.succeed("Workspace dependencies linked")}catch{let r=$();t.warn(`Workspace sync skipped (run ${r} install manually)`)}},pl=async(e,t,r)=>{if(e.length===0)return;r.stop();let n=e.length===1?"package":"packages";console.log(St.default.cyan(`
146
+ `};var RD=()=>!1,ul=(e,t)=>{RD()&&console.log(`[AI Parser] ${e}`,t??"")},Cs={commandsBlock:/```commands\n([\s\S]*?)```/gi,postCommandsBlock:/```post-commands\n([\s\S]*?)```/gi,dependenciesBlock:/```dependencies\n([\s\S]*?)```/gi,fileHeader:/^#{1,4}\s+`([^`]+)`\s*$/},li=(e,t)=>[...e.matchAll(t)].flatMap(n=>n[1].split(`
147
+ `).map(s=>s.trim()).filter(s=>s.length>0&&!s.startsWith("#"))),ll=e=>({command:e,isPfCommand:e.startsWith("pf ")||e.includes(" pf ")}),ID=e=>li(e,Cs.commandsBlock).map(ll),ND=e=>li(e,Cs.postCommandsBlock).map(ll),OD=e=>li(e,Cs.dependenciesBlock).filter(t=>!t.startsWith("@crossdelta/")&&t!=="zod"),MD=e=>{let t={ts:"typescript",js:"javascript",md:"markdown",yml:"yaml"},r=(e||"typescript").toLowerCase();return t[r]||r},$D=e=>{let t=e.split(".").pop()?.toLowerCase();return{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",json:"json",yaml:"yaml",yml:"yaml",md:"markdown"}[t||""]||"plaintext"},BD=e=>e.replace(/^\s*\/\/ \.{3,}.*$/gm,"").replace(/^\s*\/\/ Lines? \d+.*omitted.*$/gim,"").replace(/^\s*\/\* Lines? \d+.*omitted.*\*\/$/gim,"").trim(),jD=e=>{let t=e.split(`
148
+ `),r=[],n=0;for(let s of t){let o=Cs.fileHeader.exec(s);o&&r.push({path:o[1],index:n}),n+=s.length+1}return r},_D=(e,t)=>{let n=e.slice(t).match(/```(\w+)?\n([\s\S]*?)```/);return n?{language:n[1]?MD(n[1]):void 0,content:BD(n[2])}:null},LD=e=>jD(e).map(r=>{let n=_D(e,r.index);return!n||n.content.length===0?null:{path:r.path,language:n.language||$D(r.path),content:n.content,startIndex:r.index}}).filter(r=>r!==null),ui=e=>e.includes("packages/contracts")||e.includes("contracts/src"),WD=e=>{let t=e.filter(n=>ui(n.path)),r=e.filter(n=>!ui(n.path));return[...t,...r]},GD=e=>{let t=e.replace(/^\/+/,"").replace(/\/{2,}/g,"/");if(ui(t))return t;let r=t.match(/^services\/[^/]+\/(.+)$/);return r?r[1]:t},pl=(e,t)=>{ul("Parsing AI response",{length:e.length});let r=ID(e),n=ND(e),s=OD(e),o=LD(e),i=WD(o.map(a=>({path:GD(a.path),content:a.content,language:a.language})));return ul("Parsed response",{commands:r.length,postCommands:n.length,dependencies:s.length,files:i.length}),{commands:r,files:i,dependencies:s,postCommands:n}},fl=e=>{let t=e.filter(o=>!o.content||o.content.trim().length===0),r=e.length===0?["No files could be extracted from the AI response"]:t.map(o=>`File ${o.path} is empty`),n=e.some(o=>["src/index.ts","src/main.ts","index.ts"].includes(o.path)),s=e.length>0&&!n?["No entry point file (src/index.ts or src/main.ts) found - assuming it exists from scaffolding"]:[];return{valid:r.length===0,errors:r,warnings:s}};var dl=require("node:fs"),Et=b(require("chalk"));var hl=async(e,t,r)=>{if(e.length===0){(0,dl.mkdirSync)(t,{recursive:!0}),console.log(Et.default.yellow(`\u26A0 No scaffolding command found - creating empty directory
149
+ `));return}let s=(await ai(e,r)).find(o=>!o.success);if(s)throw console.log(Et.default.red(`
150
+ \u2717 Scaffolding failed: ${s.command}`)),s.error&&console.log(Et.default.red(` Error: ${s.error}`)),new Error(`Command failed: ${s.command}${s.error?` - ${s.error}`:""}`)},ml=async(e,t)=>{t.start("Linking workspace dependencies...");try{await xt({cwd:e,quiet:!0}),t.succeed("Workspace dependencies linked")}catch{let r=$();t.warn(`Workspace sync skipped (run ${r} install manually)`)}},gl=async(e,t,r)=>{if(e.length===0)return;r.stop();let n=e.length===1?"package":"packages";console.log(Et.default.cyan(`
151
151
  \u25B6 Installing ${e.length} additional ${n}...
152
- `));try{await kt({packages:e,cwd:t,flags:["--silent"]}),console.log(St.default.green(`\u2713 Installed ${e.length} ${n}
153
- `))}catch(s){throw console.log(St.default.red(`\u2717 Package installation failed
154
- `)),s}},ii=async(e,t)=>{if(e.length===0)return;console.log(St.default.cyan(`
152
+ `));try{await xt({packages:e,cwd:t,flags:["--silent"]}),console.log(Et.default.green(`\u2713 Installed ${e.length} ${n}
153
+ `))}catch(s){throw console.log(Et.default.red(`\u2717 Package installation failed
154
+ `)),s}},pi=async(e,t)=>{if(e.length===0)return;console.log(Et.default.cyan(`
155
155
  \u25B6 Running post-generation commands...
156
- `));let n=(await ri(e,t)).find(s=>!s.success);if(n){console.log(St.default.yellow(`
157
- \u26A0 Post-command failed: ${n.command}`)),n.error&&console.log(St.default.yellow(` Error: ${n.error}`));return}console.log(St.default.green(`\u2713 Post-generation commands complete
158
- `))};var rn=b(require("chalk")),jD=e=>`${rn.default.dim(" \u2022 ")+rn.default.cyan(e)}
159
- `,fl=e=>rn.default.dim(` \u2728 Generated ${rn.default.white.bold(e)} tokens
160
- `),dl=()=>{let e="",t=0,r=Date.now(),n=[],s=()=>{let i=e.match(/####\s+`([^`]+)`/);if(!i)return!1;n.push(i[1]),process.stdout.write(jD(i[1]));let a=e.indexOf(i[0])+i[0].length;return e=e.slice(a),!0},o=i=>{e+=i,t++,s(),e.length>500&&(e=e.slice(-200))};return o.getStats=()=>{let i=((Date.now()-r)/1e3).toFixed(2),a=(t/Number.parseFloat(i)).toFixed(0);return{tokenCount:t,duration:i,tokensPerSec:a}},o.getFiles=()=>n,o};var _D=()=>{let e=O(),t=(0,nn.join)(e,"package.json"),r=(()=>{if(!(0,ms.existsSync)(t))throw new Error("No package.json found in workspace root. Run from a valid workspace.");try{let s=JSON.parse((0,ms.readFileSync)(t,"utf-8")).name;if(!s)throw new Error('package.json has no "name" field. Please add a name to your root package.json.');return s.startsWith("@")?s:`@${s}`}catch(n){throw n instanceof SyntaxError?new Error("Invalid JSON in package.json"):n}})();return{workspaceRoot:e,scope:r,cwd:process.cwd()}},LD=async(e,t,r,n,s,o)=>{let i=nl(r,n,s),a=rl(t,s,o),c=dl(),u=await Ou(e,i,{system:a,maxTokens:16384,temperature:.7,onToken:c}),l=c.getStats();return console.log(fl(l.tokenCount)),console.log(),u},Dl=()=>xt.generatorConfig?.serviceTypes||{hono:{commandType:"hono-micro"},nest:{commandType:"nest-micro"}},WD=(e,t)=>{let r=Dl(),n=r[t]?.commandType;if(!n)return e;let s=Object.values(r).map(o=>o.commandType);return e.map(o=>{for(let i of s)if(i!==n&&o.command.includes(`pf new ${i}`))return{...o,command:o.command.replace(`pf new ${i}`,`pf new ${n}`)};return o})},GD=e=>e.length===0?"":`${[T.default.cyan(`
156
+ `));let n=(await ai(e,t)).find(s=>!s.success);if(n){console.log(Et.default.yellow(`
157
+ \u26A0 Post-command failed: ${n.command}`)),n.error&&console.log(Et.default.yellow(` Error: ${n.error}`));return}console.log(Et.default.green(`\u2713 Post-generation commands complete
158
+ `))};var un=b(require("chalk")),HD=e=>`${un.default.dim(" \u2022 ")+un.default.cyan(e)}
159
+ `,Dl=e=>un.default.dim(` \u2728 Generated ${un.default.white.bold(e)} tokens
160
+ `),yl=()=>{let e="",t=0,r=Date.now(),n=[],s=()=>{let i=e.match(/####\s+`([^`]+)`/);if(!i)return!1;n.push(i[1]),process.stdout.write(HD(i[1]));let a=e.indexOf(i[0])+i[0].length;return e=e.slice(a),!0},o=i=>{e+=i,t++,s(),e.length>500&&(e=e.slice(-200))};return o.getStats=()=>{let i=((Date.now()-r)/1e3).toFixed(2),a=(t/Number.parseFloat(i)).toFixed(0);return{tokenCount:t,duration:i,tokensPerSec:a}},o.getFiles=()=>n,o};var UD=()=>{let e=O(),t=(0,ar.join)(e,"package.json"),r=(()=>{if(!(0,Zt.existsSync)(t))throw new Error("No package.json found in workspace root. Run from a valid workspace.");try{let s=JSON.parse((0,Zt.readFileSync)(t,"utf-8")).name;if(!s)throw new Error('package.json has no "name" field. Please add a name to your root package.json.');return s.startsWith("@")?s:`@${s}`}catch(n){throw n instanceof SyntaxError?new Error("Invalid JSON in package.json"):n}})();return{workspaceRoot:e,scope:r,cwd:process.cwd()}},zD=async(e,t,r,n,s,o)=>{let i=cl(r,n,s),a=al(t,s,o),c=yl(),u=await ju(e,i,{system:a,maxTokens:16384,temperature:.7,onToken:c}),l=c.getStats();return console.log(Dl(l.tokenCount)),console.log(),u},KD=(e,t)=>{let{serviceTypes:r}=Xr(),n=r[t]?.commandType;if(!n)return e;let s=Object.values(r).map(o=>o.commandType);return e.map(o=>{for(let i of s)if(i!==n&&o.command.includes(`pf new ${i}`))return{...o,command:o.command.replace(`pf new ${i}`,`pf new ${n}`)};return o})},JD=e=>e.length===0?"":`${[T.default.cyan(`
161
161
  \u{1F4C1} Files to create:`),...e.map(t=>` ${T.default.green("\u2022")} ${T.default.white(t.path)} ${T.default.dim(`(${t.language})`)}`)].join(`
162
162
  `)}
163
- `,hl=(e,t,r)=>e.length===0?"":`${[T.default.cyan(`
163
+ `,wl=(e,t,r)=>e.length===0?"":`${[T.default.cyan(`
164
164
  ${r} ${t}:`),...e.map(n=>` ${T.default.yellow("$")} ${T.default.white(n.command)}`)].join(`
165
165
  `)}
166
- `,HD=e=>e.length===0?"":`${[T.default.cyan(`
166
+ `,VD=e=>e.length===0?"":`${[T.default.cyan(`
167
167
  \u{1F4E6} Dependencies to install:`),...e.map(t=>` ${T.default.magenta("+")} ${T.default.white(t)}`)].join(`
168
168
  `)}
169
- `,UD=(e,t)=>`${[T.default.yellow(`
169
+ `,qD=(e,t)=>`${[T.default.yellow(`
170
170
  Validation errors:`),...e.map(r=>T.default.yellow(` \u26A0 ${r}`)),T.default.dim(`
171
171
  Response preview:`),T.default.dim(t)].join(`
172
172
  `)}
173
- `,sr=e=>{e&&process.stdout.write(e)},zD=(e,t)=>{let r=il(e,t),n=ni(r.commands),s=ni(r.postCommands),o=al(r.files);return o.valid?{files:r.files,commands:n,dependencies:r.dependencies,postCommands:s}:(console.log(`${T.default.yellow("\u26A0")} Could not extract structured files from AI response`),sr(UD(o.errors,e.slice(0,500))),null)},KD=e=>{console.log(`${T.default.green("\u2714")} Extracted ${e.files.length} files`),sr(GD(e.files)),sr(hl(e.commands,"Commands to run","\u{1F527}")),sr(hl(e.postCommands,"Post-generation commands","\u{1F4DD}")),sr(HD(e.dependencies)),sr(`
174
- `)},JD=(e,t,r)=>{let n=Ku(e);return n&&!n.includes("/")&&!n.startsWith(".")&&(n=`${vt().services}/${n}`),n?(0,nn.resolve)(r,n):(0,nn.resolve)(r,t)},VD=(e,t)=>{let n=Dl()[t]?.skipFiles||["package.json","tsconfig.json","Dockerfile"];return e.filter(s=>!n.includes(s.path))},or=()=>{if(!Qr())return{valid:!1,error:T.default.red.bold(`\u274C AI configuration not found.
173
+ `,ir=e=>{e&&process.stdout.write(e)},YD=(e,t)=>{let r=pl(e,t),n=ci(r.commands),s=ci(r.postCommands),o=fl(r.files);return o.valid?{files:r.files,commands:n,dependencies:r.dependencies,postCommands:s}:(console.log(`${T.default.yellow("\u26A0")} Could not extract structured files from AI response`),ir(qD(o.errors,e.slice(0,500))),null)},ZD=e=>{console.log(`${T.default.green("\u2714")} Extracted ${e.files.length} files`),ir(JD(e.files)),ir(wl(e.commands,"Commands to run","\u{1F527}")),ir(wl(e.postCommands,"Post-generation commands","\u{1F4DD}")),ir(VD(e.dependencies)),ir(`
174
+ `)},XD=(e,t,r)=>{let n=Zu(e);return n&&!n.includes("/")&&!n.startsWith(".")&&(n=`${vt().services}/${n}`),n?(0,ar.resolve)(r,n):(0,ar.resolve)(r,t)},QD=(e,t)=>{let{serviceTypes:r}=Xr(),n=r[t]?.skipFiles||["package.json","tsconfig.json","Dockerfile"];return e.filter(s=>!n.includes(s.path))},cr=()=>{if(!nn())return{valid:!1,error:T.default.red.bold(`\u274C AI configuration not found.
175
175
  `)+T.default.yellow("Please run ")+T.default.cyan.bold("pf setup --ai")+T.default.yellow(` first to configure your AI provider.
176
- `)};try{return{valid:!0,config:ss()}}catch(e){return{valid:!1,error:T.default.red.bold(`\u274C ${e.message}
177
- `)}}},gs=async e=>e||(0,ml.input)({message:"\u{1F4DD} Describe what this service should do:",validate:t=>t.trim().length>0||"Please provide a description for the AI to generate code"}),Ds=(e,t,r)=>{console.log(T.default.cyan.bold(`
176
+ `)};try{return{valid:!0,config:us()}}catch(e){return{valid:!1,error:T.default.red.bold(`\u274C ${e.message}
177
+ `)}}},bs=async e=>e||(0,Cl.input)({message:"\u{1F4DD} Describe what this service should do:",validate:t=>t.trim().length>0||"Please provide a description for the AI to generate code"}),vs=(e,t,r)=>{console.log(T.default.cyan.bold(`
178
178
  \u{1F916} AI-Powered Generation
179
179
  `)),console.log(T.default.dim(`Service: ${e.split("/").pop()}`)),console.log(T.default.dim(`Path: ${e}`)),console.log(T.default.dim(`Model: ${t.model}`)),console.log(T.default.dim(`Description: ${r}
180
- `))},ys=async(e,t)=>{let{servicePath:r,description:n="",serviceType:s,packageManager:o}=e,i=r.split("/").pop()||r,a=_D();console.log(T.default.cyan.bold(`
180
+ `))},xs=async(e,t)=>{let{servicePath:r,description:n="",serviceType:s,packageManager:o}=e,i=r.split("/").pop()||r,a=UD(),c=(0,ar.join)(a.workspaceRoot,on);(0,Zt.writeFileSync)(c,`generating:${r}`);let u=()=>{(0,Zt.existsSync)(c)&&(0,Zt.unlinkSync)(c)},l=()=>{u(),process.exit(130)};process.on("SIGINT",l),process.on("SIGTERM",l);try{console.log(T.default.cyan.bold(`
181
181
  \u{1F916} AI Generation
182
- `));let c=await LD(t,a,r,n,s,o),u=zD(c,i);if(!u)return!1;KD(u);let l=(0,gl.default)({text:"Processing files...",color:"cyan"}).start(),p=WD(u.commands,s),d=JD(p,r,a.cwd),f=VD(u.files,s);await ul(p,d,a.workspaceRoot);let{missingContractCommands:m}=await qu(f,d,a,l);if(u.postCommands.length>0)await ii(u.postCommands,a.workspaceRoot);else if(m.length>0){console.log(T.default.cyan(`\u{1F527} Auto-creating missing contracts...
183
- `));let h=m.map(D=>({command:D,isPfCommand:!0}));await ii(h,a.workspaceRoot)}return zu(d),await pl(u.dependencies,d,l),await ll(a.workspaceRoot,l),await Vu(d,l),!0};var wl=require("node:fs"),sn=require("ts-morph"),yl=new sn.Project({skipAddingFilesFromTsConfig:!0,skipFileDependencyResolution:!0}),ai=e=>{if(!(0,wl.existsSync)(e))return null;let t=yl.getSourceFile(e);return t||yl.addSourceFileAtPath(e)},ci=e=>{e.saveSync()},ui=(e,t,r)=>{let n=e.getImportDeclaration(t);if(n){let s=n.getNamedImports().map(i=>i.getName()),o=r.filter(i=>!s.includes(i));for(let i of o)n.addNamedImport(i);return}e.addImportDeclaration({moduleSpecifier:t,namedImports:r})},qD=e=>{for(let t of e.getClasses()){let r=t.getDecorator("Module");if(!r)continue;let n=r.getArguments();if(n.length===0)continue;let s=n[0];if(s.getKind()===sn.SyntaxKind.ObjectLiteralExpression)return s}return null},li=(e,t)=>{let r=qD(e);if(!r)return!1;let n=r.getProperty("imports");if(n){let s=n.getFirstChildByKind(sn.SyntaxKind.ArrayLiteralExpression);return s?(s.getElements().map(i=>i.getText()).includes(t)||s.addElement(t),!0):!1}return r.addPropertyAssignment({name:"imports",initializer:`[${t}]`}),!0};var ws=require("node:fs"),on=b(require("node:path")),pi=b(require("chalk"));var Cl=async e=>{await pe("bash",["-c",`
182
+ `));let p=await zD(t,a,r,n,s,o),d=YD(p,i);if(!d)return!1;ZD(d);let f=(0,bl.default)({text:"Processing files...",color:"cyan"}).start(),m=KD(d.commands,s),h=XD(m,r,a.cwd),D=QD(d.files,s);await hl(m,h,a.workspaceRoot);let{missingContractCommands:g}=await tl(D,h,a,f);if(d.postCommands.length>0)await pi(d.postCommands,a.workspaceRoot);else if(g.length>0){console.log(T.default.cyan(`\u{1F527} Auto-creating missing contracts...
183
+ `));let y=g.map(v=>({command:v,isPfCommand:!0}));await pi(y,a.workspaceRoot)}return Yu(h),await gl(d.dependencies,h,f),await ml(a.workspaceRoot,f),await Qu(h,f),!0}finally{process.off("SIGINT",l),process.off("SIGTERM",l),u()}};var xl=require("node:fs"),ln=require("ts-morph"),vl=new ln.Project({skipAddingFilesFromTsConfig:!0,skipFileDependencyResolution:!0}),fi=e=>{if(!(0,xl.existsSync)(e))return null;let t=vl.getSourceFile(e);return t||vl.addSourceFileAtPath(e)},di=e=>{e.saveSync()},hi=(e,t,r)=>{let n=e.getImportDeclaration(t);if(n){let s=n.getNamedImports().map(i=>i.getName()),o=r.filter(i=>!s.includes(i));for(let i of o)n.addNamedImport(i);return}e.addImportDeclaration({moduleSpecifier:t,namedImports:r})},ty=e=>{for(let t of e.getClasses()){let r=t.getDecorator("Module");if(!r)continue;let n=r.getArguments();if(n.length===0)continue;let s=n[0];if(s.getKind()===ln.SyntaxKind.ObjectLiteralExpression)return s}return null},mi=(e,t)=>{let r=ty(e);if(!r)return!1;let n=r.getProperty("imports");if(n){let s=n.getFirstChildByKind(ln.SyntaxKind.ArrayLiteralExpression);return s?(s.getElements().map(i=>i.getText()).includes(t)||s.addElement(t),!0):!1}return r.addPropertyAssignment({name:"imports",initializer:`[${t}]`}),!0};var ks=require("node:fs"),pn=b(require("node:path")),gi=b(require("chalk"));var kl=async e=>{await fe("bash",["-c",`
184
184
  curl -fsSL https://bun.sh/install | bash && if [ -f "$HOME/.bun/bin/bun" ]; then export PATH="$HOME/.bun/bin:$PATH"; fi
185
- `],{task:e,shell:!0}),await YD()},fi=()=>Tr("bun"),bl=()=>Ys([{label:"Bun",value:59026,color:"magenta",barColor:"magenta"},{label:"Deno",value:25335},{label:"Node.js",value:19039}],{title:'Express.js "hello world" HTTP requests per second (Linux x64)',barColor:"blackBright"}),vl=()=>Ys([{label:"Bun",value:.36,color:"magenta",barColor:"magenta"},{label:"pnpm",value:6.44},{label:"npm",value:10.58},{label:"yarn",value:12.08}],{title:"Bun is an npm-compatible package manager.",unit:"s",footer:pi.default.blackBright("* Installing dependencies from cache for a Remix app."),barColor:"blackBright"}),YD=async()=>{let e='export PATH="$HOME/.bun/bin:$PATH"',t=process.env.HOME;if(!t){w.error("Could not detect $HOME environment variable. Cannot update shell config.");return}let r=[on.default.join(t,".zshrc"),on.default.join(t,".bashrc"),on.default.join(t,".bash_profile")];for(let n of r)try{if(await ws.promises.stat(n).then(()=>!0).catch(()=>!1)){(await ws.promises.readFile(n,"utf8")).includes(e)||(await ws.promises.appendFile(n,`
185
+ `],{task:e,shell:!0}),await ey()},Di=()=>Rr("bun"),El=()=>eo([{label:"Bun",value:59026,color:"magenta",barColor:"magenta"},{label:"Deno",value:25335},{label:"Node.js",value:19039}],{title:'Express.js "hello world" HTTP requests per second (Linux x64)',barColor:"blackBright"}),Sl=()=>eo([{label:"Bun",value:.36,color:"magenta",barColor:"magenta"},{label:"pnpm",value:6.44},{label:"npm",value:10.58},{label:"yarn",value:12.08}],{title:"Bun is an npm-compatible package manager.",unit:"s",footer:gi.default.blackBright("* Installing dependencies from cache for a Remix app."),barColor:"blackBright"}),ey=async()=>{let e='export PATH="$HOME/.bun/bin:$PATH"',t=process.env.HOME;if(!t){w.error("Could not detect $HOME environment variable. Cannot update shell config.");return}let r=[pn.default.join(t,".zshrc"),pn.default.join(t,".bashrc"),pn.default.join(t,".bash_profile")];for(let n of r)try{if(await ks.promises.stat(n).then(()=>!0).catch(()=>!1)){(await ks.promises.readFile(n,"utf8")).includes(e)||(await ks.promises.appendFile(n,`
186
186
  # Added by platform installer
187
187
  ${e}
188
- `),w.log(`Added Bun path to ${on.default.basename(n)}`));return}}catch(s){w.error(`Failed to update ${n}: ${s.message}`)}w.warn("No shell config file (.zshrc, .bashrc, .bash_profile) found. Please add the following manually:"),w.log(pi.default.cyan(e))};var Bt=b(require("chalk"));var Cs="integrations-run";var J=require("zod"),ZD=J.z.object({name:J.z.string(),description:J.z.string(),link:J.z.string().url().optional(),install:J.z.union([J.z.string(),J.z.array(J.z.string())]).transform(e=>Array.isArray(e)?e:[e]),installFlags:J.z.array(J.z.string()).optional(),run:J.z.array(J.z.string()).optional(),initial:J.z.boolean().optional(),interactive:J.z.boolean().optional()}),xl=J.z.array(ZD);var kl=e=>{try{return xl.parse(e)}catch(t){throw new Error(t.issues.map(r=>` - Path ${r.path.join(". ")} : ${r.message}`).join(`
189
- `))}};var Ft=()=>{try{let e=Qn("bin/integration.collection.json");return kl(e)}catch(e){throw new Error(`Failed to load integrations!
188
+ `),w.log(`Added Bun path to ${pn.default.basename(n)}`));return}}catch(s){w.error(`Failed to update ${n}: ${s.message}`)}w.warn("No shell config file (.zshrc, .bashrc, .bash_profile) found. Please add the following manually:"),w.log(gi.default.cyan(e))};var Bt=b(require("chalk"));var Es="integrations-run";var J=require("zod"),ry=J.z.object({name:J.z.string(),description:J.z.string(),link:J.z.string().url().optional(),install:J.z.union([J.z.string(),J.z.array(J.z.string())]).transform(e=>Array.isArray(e)?e:[e]),installFlags:J.z.array(J.z.string()).optional(),run:J.z.array(J.z.string()).optional(),initial:J.z.boolean().optional(),interactive:J.z.boolean().optional()}),Fl=J.z.array(ry);var Tl=e=>{try{return Fl.parse(e)}catch(t){throw new Error(t.issues.map(r=>` - Path ${r.path.join(". ")} : ${r.message}`).join(`
189
+ `))}};var St=()=>{try{let e=ss("bin/integration.collection.json");return Tl(e)}catch(e){throw new Error(`Failed to load integrations!
190
190
  Check your integration.collection.json:
191
- ${e.message}`)}},ir=()=>Ft().reduce((t,r)=>(r.initial&&t.push(r.name),t),[]),XD=e=>!!e?.name&&!!e?.link&&!!e?.description,bs=e=>{let t=Ft();if(!t?.length||!e?.length)return;let r=e.map(n=>t.find(s=>s.name===n)).filter(XD);r.length&&(w.breakLine().log("\u{1F50C} Installed Integrations:"),r.forEach(({name:n,link:s,description:o})=>{let i=w.getStoredLogs(`${Cs}:${n}`);s&&w.log(`${Ut(Bt.default.cyan(n),s)} - ${o}`),i.length&&w.log(i.map(a=>` \u203A ${Bt.default.dim(a.message)}`).join(`
192
- `))}))},QD=e=>e.toUpperCase().replace(/-/g,"_"),El=(e,t)=>{let r=QD(e);w.breakLine().log(Bt.default.bold("Environment variables:")).log(Bt.default.dim(" Local:")).log(Bt.default.cyan(` ${r}_PORT=${t}`)).log(Bt.default.cyan(` ${r}_URL=http://localhost:${t}`)).breakLine().log(Bt.default.dim(" Production (auto-configured):")).log(Bt.default.cyan(` ${r}_PORT=${t}`)).log(Bt.default.cyan(` ${r}_URL=http://${e}:${t}`))};var di=b(require("chalk"));var ty=e=>{let t=e.match(/^(@?[^@]+)@(.+)$/);return t?{name:t[1],version:t[2]}:{name:e,version:"latest"}},Sl=async e=>{let{selectedIntegrations:t,cwd:r,packageManager:n=$(),task:s}=e;if(!t?.length||!s)return;let o=ey(t,r,n,s);await Zn(s,o)},ey=(e,t,r,n)=>{let o=Ft()?.filter(a=>e.includes(a.name))?.flatMap(a=>a.install.map(c=>{let{name:u,version:l}=ty(c);return{title:di.default.cyanBright(`Adding ${c} (${a.name})`),fn:async()=>{Jt(`dependencies.${u}`,l,t)}}})),i={title:di.default.cyanBright("Installing packages..."),fn:async()=>{await kt({cwd:t,packageManager:r,task:n})}};return[...o??[],i]};var Fl=b(require("chalk"));var Tl=async e=>{let{selectedIntegrations:t,cwd:r,task:n}=e;if(!t?.length||!n)return;let s=ry(t,r,n,e.packageManager);await Zn(n,s)},ry=(e,t,r,n)=>Ft().filter(o=>e.includes(o.name)&&o.run?.length).flatMap(o=>(o.run||[]).map(i=>({title:Fl.default.cyanBright(`Running "${i}" for ${o.name}
193
- `),fn:()=>ny(o,i,t,r,n)}))),ny=async(e,t,r,n,s)=>{let o=`${Cs}:${e.name}`;try{if(e.interactive)return gu(t,[],{cwd:r,context:o,task:n,manager:s});await qt(t,[],{cwd:r,task:n,context:o})}catch(i){w.error(`Failed to run command "${t}" for ${e.name}: ${i.message}`)}};var vs=require("node:fs"),an=require("node:path");var xs=(e,t)=>{try{let r=(0,vs.readFileSync)(e,"utf-8"),n=JSON.parse(r);t(n),(0,vs.writeFileSync)(e,JSON.stringify(n,null,2),"utf-8")}catch{}},sy=e=>{let t=(0,an.join)(S(e),"tsconfig.json");xs(t,r=>{r.compilerOptions.module="node16",r.compilerOptions.moduleResolution="node16",r.compilerOptions.resolvePackageJsonExports=!0,r.exclude=["node_modules","dist","**/*.test.ts","**/*.spec.ts"]})},oy=e=>{let t=(0,an.join)(S(e),"tsconfig.build.json");xs(t,r=>{r.exclude=["node_modules","test","dist","**/*.spec.ts","**/*.test.ts"]})},iy=e=>{let t=(0,an.join)(S(e),"nest-cli.json");xs(t,r=>{r.compilerOptions=r.compilerOptions||{},r.compilerOptions.tsConfigPath="tsconfig.build.json"})},ay=e=>{let t=(0,an.join)(S(e),"package.json");xs(t,r=>{delete r.jest})},Al=e=>{sy(e),oy(e),iy(e),ay(e)};var Pl=require("node:path");var cy=(e,t)=>{let r=ai(e);if(r){for(let{className:n,importPath:s}of t)ui(r,s,[n]),li(r,n);ci(r)}},Rl=e=>{let t=(0,Pl.join)(S(e),"src","app.module.ts");cy(t,[{className:"EventsModule",importPath:"./events/events.module"}])};var uy=require("fs-extra");var Vy=b(require("chalk")),qy=b(ki());var Ts=require("node:fs"),Ip=require("node:path"),Np=b(require("handlebars")),ur=(e,t)=>{for(let r of e)if((0,Ts.existsSync)(r))return r;throw new Error(t??`Templates directory not found. Searched in: ${e.join(", ")}`)},Ei=(e,t={})=>{let r=(0,Ts.readFileSync)(e,"utf-8");return Np.default.compile(r)(t)},As=e=>(t,r={})=>{let n=(0,Ip.join)(e,t);return Ei(n,r)};var fn=e=>e.toUpperCase().replace(/-/g,"_");var Op=e=>e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ");function Ps(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}async function Mp(e,t,r={},n=[],s=[]){if(!e){console.error("Subcommand is not defined.");return}let o=n.map(u=>t[u]).filter(u=>u!==void 0),i=s.map(u=>{let l=t[u];if(!(l===!1||l===void 0))return l===!0?`--${Ps(String(u))}`:`--${Ps(String(u))}=${String(l)}`}).filter(u=>u!==void 0),a=Object.entries(r).map(([u,l])=>{if(!(l===!1||l===void 0))return l===!0?`--${Ps(u)}`:`--${Ps(u)}=${String(l)}`}).filter(u=>u!==void 0),c=[...o,...i,...a].map(String);await e.parseAsync(c,{from:"user"})}var Yp=require("node:path"),Xt=b(require("chalk"));var lr={title:"Confirm creation",enabled:e=>!e.userConfirmed,task:async(e,t)=>{if(e.userConfirmed=await t.prompt(R).run({type:"Toggle",initial:!0,message:"\u{1F680} Ready to launch your project?"}),!e.userConfirmed)throw new Error("Project creation was canceled by the user.")}};var _t=require("node:fs"),pr=require("node:path");function $p(e,t){return`import type { K8sServiceConfig } from '@crossdelta/infrastructure'
191
+ ${e.message}`)}},ur=()=>St().reduce((t,r)=>(r.initial&&t.push(r.name),t),[]),ny=e=>!!e?.name&&!!e?.link&&!!e?.description,Ss=e=>{let t=St();if(!t?.length||!e?.length)return;let r=e.map(n=>t.find(s=>s.name===n)).filter(ny);r.length&&(w.breakLine().log("\u{1F50C} Installed Integrations:"),r.forEach(({name:n,link:s,description:o})=>{let i=w.getStoredLogs(`${Es}:${n}`);s&&w.log(`${Ut(Bt.default.cyan(n),s)} - ${o}`),i.length&&w.log(i.map(a=>` \u203A ${Bt.default.dim(a.message)}`).join(`
192
+ `))}))},sy=e=>e.toUpperCase().replace(/-/g,"_"),Al=(e,t)=>{let r=sy(e);w.breakLine().log(Bt.default.bold("Environment variables:")).log(Bt.default.dim(" Local:")).log(Bt.default.cyan(` ${r}_PORT=${t}`)).log(Bt.default.cyan(` ${r}_URL=http://localhost:${t}`)).breakLine().log(Bt.default.dim(" Production (auto-configured):")).log(Bt.default.cyan(` ${r}_PORT=${t}`)).log(Bt.default.cyan(` ${r}_URL=http://${e}:${t}`))};var yi=b(require("chalk"));var oy=e=>{let t=e.match(/^(@?[^@]+)@(.+)$/);return t?{name:t[1],version:t[2]}:{name:e,version:"latest"}},Pl=async e=>{let{selectedIntegrations:t,cwd:r,packageManager:n=$(),task:s}=e;if(!t?.length||!s)return;let o=iy(t,r,n,s);await rs(s,o)},iy=(e,t,r,n)=>{let o=St()?.filter(a=>e.includes(a.name))?.flatMap(a=>a.install.map(c=>{let{name:u,version:l}=oy(c);return{title:yi.default.cyanBright(`Adding ${c} (${a.name})`),fn:async()=>{Jt(`dependencies.${u}`,l,t)}}})),i={title:yi.default.cyanBright("Installing packages..."),fn:async()=>{await xt({cwd:t,packageManager:r,task:n})}};return[...o??[],i]};var Rl=b(require("chalk"));var Il=async e=>{let{selectedIntegrations:t,cwd:r,task:n}=e;if(!t?.length||!n)return;let s=ay(t,r,n,e.packageManager);await rs(n,s)},ay=(e,t,r,n)=>St().filter(o=>e.includes(o.name)&&o.run?.length).flatMap(o=>(o.run||[]).map(i=>({title:Rl.default.cyanBright(`Running "${i}" for ${o.name}
193
+ `),fn:()=>cy(o,i,t,r,n)}))),cy=async(e,t,r,n,s)=>{let o=`${Es}:${e.name}`;try{if(e.interactive)return Cu(t,[],{cwd:r,context:o,task:n,manager:s});await qt(t,[],{cwd:r,task:n,context:o})}catch(i){w.error(`Failed to run command "${t}" for ${e.name}: ${i.message}`)}};var Fs=require("node:fs"),fn=require("node:path");var Ts=(e,t)=>{try{let r=(0,Fs.readFileSync)(e,"utf-8"),n=JSON.parse(r);t(n),(0,Fs.writeFileSync)(e,JSON.stringify(n,null,2),"utf-8")}catch{}},uy=e=>{let t=(0,fn.join)(S(e),"tsconfig.json");Ts(t,r=>{r.compilerOptions.module="ESNext",r.compilerOptions.moduleResolution="bundler",r.compilerOptions.resolvePackageJsonExports=!0,r.compilerOptions.types=r.compilerOptions.types||[],r.compilerOptions.types.includes("bun-types")||r.compilerOptions.types.push("bun-types"),r.exclude=["node_modules","dist"]})},ly=e=>{let t=(0,fn.join)(S(e),"tsconfig.build.json");Ts(t,r=>{r.exclude=["node_modules","test","dist","**/*.spec.ts","**/*.test.ts"]})},py=e=>{let t=(0,fn.join)(S(e),"nest-cli.json");Ts(t,r=>{r.compilerOptions=r.compilerOptions||{},r.compilerOptions.tsConfigPath="tsconfig.build.json"})},fy=e=>{let t=(0,fn.join)(S(e),"package.json");Ts(t,r=>{delete r.jest})},Nl=e=>{uy(e),ly(e),py(e),fy(e)};var Ol=require("node:path");var dy=(e,t)=>{let r=fi(e);if(r){for(let{className:n,importPath:s}of t)hi(r,s,[n]),mi(r,n);di(r)}},Ml=e=>{let t=(0,Ol.join)(S(e),"src","app.module.ts");dy(t,[{className:"EventsModule",importPath:"./events/events.module"}])};var hy=require("fs-extra");var Qy=b(require("chalk")),tw=b(Ai());var Ns=require("node:fs"),$p=require("node:path"),Bp=b(require("handlebars")),fr=(e,t)=>{for(let r of e)if((0,Ns.existsSync)(r))return r;throw new Error(t??`Templates directory not found. Searched in: ${e.join(", ")}`)},Pi=(e,t={})=>{let r=(0,Ns.readFileSync)(e,"utf-8");return Bp.default.compile(r)(t)},Os=e=>(t,r={})=>{let n=(0,$p.join)(e,t);return Pi(n,r)};var Dn=e=>e.toUpperCase().replace(/-/g,"_");var jp=e=>e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ");function Ms(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}async function _p(e,t,r={},n=[],s=[]){if(!e){console.error("Subcommand is not defined.");return}let o=n.map(u=>t[u]).filter(u=>u!==void 0),i=s.map(u=>{let l=t[u];if(!(l===!1||l===void 0))return l===!0?`--${Ms(String(u))}`:`--${Ms(String(u))}=${String(l)}`}).filter(u=>u!==void 0),a=Object.entries(r).map(([u,l])=>{if(!(l===!1||l===void 0))return l===!0?`--${Ms(u)}`:`--${Ms(u)}=${String(l)}`}).filter(u=>u!==void 0),c=[...o,...i,...a].map(String);await e.parseAsync(c,{from:"user"})}var tf=require("node:path"),Qt=b(require("chalk"));var dr={title:"Confirm creation",enabled:e=>!e.userConfirmed,task:async(e,t)=>{if(e.userConfirmed=await t.prompt(R).run({type:"Toggle",initial:!0,message:"\u{1F680} Ready to launch your project?"}),!e.userConfirmed)throw new Error("Project creation was canceled by the user.")}};var _t=require("node:fs"),hr=require("node:path");function Lp(e,t){return`import type { K8sServiceConfig } from '@crossdelta/infrastructure'
194
194
  import { ports } from '@crossdelta/infrastructure'
195
195
 
196
196
  /**
@@ -211,7 +211,7 @@ const config: K8sServiceConfig = {
211
211
  }
212
212
 
213
213
  export default config
214
- `}function Bp(e,t){return`import type { K8sServiceConfig } from '@crossdelta/infrastructure'
214
+ `}function Wp(e,t){return`import type { K8sServiceConfig } from '@crossdelta/infrastructure'
215
215
  import { ports } from '@crossdelta/infrastructure'
216
216
 
217
217
  /**
@@ -232,73 +232,73 @@ const config: K8sServiceConfig = {
232
232
  }
233
233
 
234
234
  export default config
235
- `}var Yy=4001,Zy=4e3;function Xy(e){let t=[],r=e.matchAll(/ports\(\)\.(?:http|https|grpc|primary)\((\d+)\)/g);for(let c of r)t.push(Number(c[1]));let n=e.matchAll(/\.add(?:Http|Grpc)?\((\d+)/g);for(let c of n)t.push(Number(c[1]));let s=e.match(/containerPort\s*:\s*(\d+)/);s&&t.push(Number(s[1]));let o=e.match(/internalPorts\s*:\s*\[([^\]]+)\]/);if(o){let c=o[1].match(/\d+/g);c&&t.push(...c.map(Number))}let i=e.match(/httpPort\s*:\s*(\d+)/);i&&t.push(Number(i[1]));let a=e.matchAll(/const\s+\w*[pP]ort\w*\s*=\s*(\d+)/g);for(let c of a)t.push(Number(c[1]));return t}function Qy(e,t){let r=t?Yy:Zy,n=new Set;if(!(0,_t.existsSync)(e))return r;let s=(0,_t.readdirSync)(e).filter(i=>i.endsWith(".ts"));for(let i of s){let a=(0,pr.join)(e,i);try{let c=(0,_t.readFileSync)(a,"utf-8"),u=Xy(c);for(let l of u)n.add(l)}catch{}}let o=r;for(;n.has(o);)o++;return o}function tw(e){return(0,pr.basename)(e)}var Rs={title:"Creating infrastructure service config",task:async(e,t)=>{let r=tw(e.projectName),n=O(),s=(0,pr.join)(n,"infra","services");if(!(0,_t.existsSync)(s)){t.title="Skipping infra config (no infra/services directory found)";return}let o=(0,pr.join)(s,`${r}.ts`);if((0,_t.existsSync)(o)){t.title=`Service config already exists: infra/services/${r}.ts`;return}let i=Qy(s,!0);e.assignedPort=i;let a=e.serviceType==="hono"?$p(r,i):Bp(r,i);(0,_t.writeFileSync)(o,a),t.title=`Created infra/services/${r}.ts (port: ${i})`}};var dn=require("node:child_process"),jp=require("node:fs"),_p=require("node:path"),ew=()=>{try{return(0,dn.execSync)("git --version",{stdio:"ignore"}),!0}catch{return!1}},rw=e=>(0,jp.existsSync)((0,_p.join)(e,".git")),Lp={title:"Initializing git repository",enabled:()=>ew(),skip:e=>rw(e.cwd)?"Already a git repository":!1,task:async(e,t)=>{try{(0,dn.execSync)("git init",{cwd:e.cwd,stdio:"ignore"}),(0,dn.execSync)("git add -A",{cwd:e.cwd,stdio:"ignore"}),(0,dn.execSync)('git commit -m "chore: initial commit"',{cwd:e.cwd,stdio:"ignore",env:{...process.env,GIT_AUTHOR_NAME:process.env.GIT_AUTHOR_NAME||"Platform SDK",GIT_AUTHOR_EMAIL:process.env.GIT_AUTHOR_EMAIL||"platform-sdk@localhost",GIT_COMMITTER_NAME:process.env.GIT_COMMITTER_NAME||"Platform SDK",GIT_COMMITTER_EMAIL:process.env.GIT_COMMITTER_EMAIL||"platform-sdk@localhost"}}),t.title="Git repository initialized with initial commit"}catch{t.title="Git initialization skipped (git error)"}}};var Si=b(require("chalk"));var fr={title:"Installing Bun",enabled:e=>!!e.shouldInstallBun&&!fi(),task:async(e,t)=>K(t,async r=>{await Cl(t),e.elapsedTime+=r(),t.title=`Bun installed successfully. (${e.elapsedTime}s)`})},dr={enabled:e=>!fi()&&!e.shouldInstallBun&&!e.packageManager,task:async(e,t)=>{e.shouldInstallBun=await t.prompt(R).run({type:"Toggle",message:"Would you like to use Bun? (recommended)",initial:!0,footer:["",`${Si.default.magenta.bold("Bun")} is a fast JavaScript runtime, package manager, bundler, and test runner: ${Si.default.underline("https://bun.sh")}`,bl(),vl()].join(`
236
- `)}),e.shouldInstallBun&&(e.packageManager="bun")}};var Fi=b(require("chalk"));var Is={title:"Install integrations",enabled:e=>e.selectedIntegrations.length>0,task:async(e,t)=>K(t,async r=>{let{selectedIntegrations:n,cwd:s,packageManager:o}=e;await Sl({selectedIntegrations:n,packageManager:o,cwd:s,task:t}),e.elapsedTime+=r()}),rendererOptions:{outputBar:1e3}},Ns={title:"Select integrations",enabled:e=>e.selectedIntegrations.length===0,task:async(e,t)=>{e.selectedIntegrations=await t.prompt(R).run({type:"MultiSelect",hint:`
237
- Press <space> to select/deselect, <enter> to confirm, <i> to invert selection`,message:"Which integrations would you like to include?",initial:ir().map((r,n)=>n),choices:e.availableIntegrations.map(({name:r,description:n})=>({name:r,message:[Fi.default.bold(r),n].join(" - "),value:r}))}),!e.selectedIntegrations||e.selectedIntegrations.length===0?t.title="No integrations selected.":t.title=["Selected integrations:",...e.selectedIntegrations.map(r=>Fi.default.bold(`\u2022 ${r}`))].join(`
238
- `)}};var Wp={title:"Install Nest CLI",task:async(e,t)=>K(t,async r=>{await mu({packages:["@nestjs/cli"],task:t,cwd:e.cwd}),e.elapsedTime+=r()}),rendererOptions:{outputBar:1e3}};var Os={title:"Install dependencies",task:async(e,t)=>K(t,async r=>{await kt({cwd:e.cwd,task:t,packageManager:e.packageManager}),e.elapsedTime+=r()})};var Gp=b(require("chalk"));var hr={enabled:e=>!e.removeDir&&!Yn(e.cwd),task:async(e,t)=>{if(e.removeDir=await t.prompt(R).run({type:"Toggle",message:Gp.default.bold("\u26A0\uFE0F Overwrite existing directory?"),initial:!1}),!e.removeDir)throw new Error("Project creation was canceled by the user.")}},mr={enabled:e=>!!e.removeDir,task:async e=>Jc(e.cwd)};var Ms={title:"Run integration commands",enabled:e=>e.selectedIntegrations.length>0,task:async(e,t)=>K(t,async r=>{let{selectedIntegrations:n,cwd:s}=e;await Tl({selectedIntegrations:n,cwd:s,task:t,packageManager:e.packageManager}),e.elapsedTime+=r()}),rendererOptions:{outputBar:1}};var nw=["services/my-hono-service","services/my-nest-service","my-platform"],gr={enabled:e=>e.skipInputPrompts||e.userConfirmed?!1:e.projectName?nw.includes(e.projectName):!0,task:async(e,t)=>{e.projectName=await t.prompt(R).run({type:"Input",initial:e.projectName,message:"Enter project name",validate:r=>r?!0:"Project name is required."}),e.cwd&&(e.cwd=S(e.projectName))}};var Ti=b(require("chalk"));var Dr={title:"Select Package manager",task:async(e,t)=>{if(e.packageManager??=jo(),e.packageManager){t.title=`Using ${Ti.default.bold(e.packageManager)} as package manager.`;return}e.packageManager=await t.prompt(R).run({type:"Select",message:"Which package manager would you like to use?",initial:_o(),choices:hu}),t.title=`Using ${Ti.default.bold(e.packageManager)} as package manager.`}};var hn=b(require("chalk")),Hp={title:"GitHub repository owner",task:async(e,t)=>{if(e.githubOwner){t.title=`GitHub owner: ${hn.default.bold(e.githubOwner)}`;return}e.githubOwner=await t.prompt(R).run({type:"Input",message:"Enter GitHub organization or username",initial:"my-org",validate:r=>r?.trim()?!0:"GitHub owner is required."}),t.title=`GitHub owner: ${hn.default.bold(e.githubOwner)}`}},Up={title:"Include GitHub CI/CD",task:async(e,t)=>{if(e.includeGitHubCI!==void 0){t.title=e.includeGitHubCI?"Including GitHub CI/CD workflows":"Skipping GitHub CI/CD";return}e.includeGitHubCI=await t.prompt(R).run({type:"Toggle",message:"Include GitHub Actions workflows and CI/CD?",initial:!0,enabled:"Yes",disabled:"No"}),t.title=e.includeGitHubCI?"Including GitHub CI/CD workflows":"Skipping GitHub CI/CD"}};var zp={title:"Pulumi stack name",task:async(e,t)=>{if(e.pulumiStackBase){t.title=`Pulumi stack: ${hn.default.bold(e.pulumiStackBase)}`;return}let r=e.githubOwner||"myorg",n=e.projectName?.replace(/[^a-zA-Z0-9-]/g,"-")||"myproject",s=`${r}/${n}`;e.pulumiStackBase=await t.prompt(R).run({type:"Input",message:"Enter Pulumi stack base name (org/project)",initial:s,validate:o=>o?.trim()?o.includes("/")?!0:"Format should be org/project (e.g., myorg/myproject)":"Pulumi stack name is required."}),t.title=`Pulumi stack: ${hn.default.bold(e.pulumiStackBase)}`}};var Lt=require("node:fs"),Wt=require("node:path");var Pi=require("node:path");var sw=()=>ur([(0,Pi.join)(__dirname,"templates","hono-microservice"),(0,Pi.join)(__dirname,"..","hono-microservice","templates")],"Hono templates directory not found."),Ri=(e,t={})=>As(sw())(e,t);function Kp(){return Ri("tsconfig.json.hbs")}function Jp(e="1.2.23"){return Ri("Dockerfile.hbs",{bunVersion:e})}function Vp(){return Ri("biome.json.hbs")}var ow=async({projectName:e,packageManager:t},r)=>{let n=t==="bun"?"bun":"nodejs";try{await qt("create-hono@latest",[e,"--pm",t,"--template",n,"--install"],{task:r})}catch(o){let i=(0,Wt.join)(S(e),"package.json");if(!(0,Lt.existsSync)(i))throw new Error(`Failed to scaffold: ${o instanceof Error?o.message:String(o)}`)}let s=(0,Wt.join)(S(e),"package.json");if(!(0,Lt.existsSync)(s))throw new Error("Failed to scaffold Hono app structure - package.json not created")},iw=({projectName:e,packageManager:t})=>{let r=(0,Wt.basename)(e),n=Xn(),s=t==="npm"?"*":"workspace:*",o=S(e),i=qc("scripts.dev",o);i&&Jt("scripts.start:dev",i,e),[{field:"name",value:`${n}/${r}`},{field:"scripts.test",value:"bun test"},{field:"scripts.lint",value:"biome lint --write ./src"},{field:`dependencies.${n}/contracts`,value:s},{field:"dependencies.@crossdelta/telemetry",value:"*"},{field:"devDependencies.bun-types",value:"latest",condition:t!=="bun"},{field:"devDependencies.@biomejs/biome",value:"latest"}].filter(({condition:c})=>c??!0).map(({field:c,value:u})=>Jt(c,u,e))},aw=({projectName:e})=>{let t=(0,Wt.basename)(e),r=(0,Wt.join)(S(e),"src","index.ts"),n=(0,Lt.readFileSync)(r,"utf-8");n.includes("@crossdelta/telemetry")||(n=`// IMPORTANT: telemetry must be imported first to patch modules before they're loaded
235
+ `}var ew=4001,rw=4e3;function nw(e){let t=[],r=e.matchAll(/ports\(\)\.(?:http|https|grpc|primary)\((\d+)\)/g);for(let c of r)t.push(Number(c[1]));let n=e.matchAll(/\.add(?:Http|Grpc)?\((\d+)/g);for(let c of n)t.push(Number(c[1]));let s=e.match(/containerPort\s*:\s*(\d+)/);s&&t.push(Number(s[1]));let o=e.match(/internalPorts\s*:\s*\[([^\]]+)\]/);if(o){let c=o[1].match(/\d+/g);c&&t.push(...c.map(Number))}let i=e.match(/httpPort\s*:\s*(\d+)/);i&&t.push(Number(i[1]));let a=e.matchAll(/const\s+\w*[pP]ort\w*\s*=\s*(\d+)/g);for(let c of a)t.push(Number(c[1]));return t}function sw(e,t){let r=t?ew:rw,n=new Set;if(!(0,_t.existsSync)(e))return r;let s=(0,_t.readdirSync)(e).filter(i=>i.endsWith(".ts"));for(let i of s){let a=(0,hr.join)(e,i);try{let c=(0,_t.readFileSync)(a,"utf-8"),u=nw(c);for(let l of u)n.add(l)}catch{}}let o=r;for(;n.has(o);)o++;return o}function ow(e){return(0,hr.basename)(e)}var $s={title:"Creating infrastructure service config",task:async(e,t)=>{let r=ow(e.projectName),n=O(),s=(0,hr.join)(n,"infra","services");if(!(0,_t.existsSync)(s)){t.title="Skipping infra config (no infra/services directory found)";return}let o=(0,hr.join)(s,`${r}.ts`);if((0,_t.existsSync)(o)){t.title=`Service config already exists: infra/services/${r}.ts`;return}let i=sw(s,!0);e.assignedPort=i;let a=e.serviceType==="hono"?Lp(r,i):Wp(r,i);(0,_t.writeFileSync)(o,a),t.title=`Created infra/services/${r}.ts (port: ${i})`}};var yn=require("node:child_process"),Gp=require("node:fs"),Hp=require("node:path"),iw=()=>{try{return(0,yn.execSync)("git --version",{stdio:"ignore"}),!0}catch{return!1}},aw=e=>(0,Gp.existsSync)((0,Hp.join)(e,".git")),Up={title:"Initializing git repository",enabled:()=>iw(),skip:e=>aw(e.cwd)?"Already a git repository":!1,task:async(e,t)=>{try{(0,yn.execSync)("git init",{cwd:e.cwd,stdio:"ignore"}),(0,yn.execSync)("git add -A",{cwd:e.cwd,stdio:"ignore"}),(0,yn.execSync)('git commit -m "chore: initial commit"',{cwd:e.cwd,stdio:"ignore",env:{...process.env,GIT_AUTHOR_NAME:process.env.GIT_AUTHOR_NAME||"Platform SDK",GIT_AUTHOR_EMAIL:process.env.GIT_AUTHOR_EMAIL||"platform-sdk@localhost",GIT_COMMITTER_NAME:process.env.GIT_COMMITTER_NAME||"Platform SDK",GIT_COMMITTER_EMAIL:process.env.GIT_COMMITTER_EMAIL||"platform-sdk@localhost"}}),t.title="Git repository initialized with initial commit"}catch{t.title="Git initialization skipped (git error)"}}};var Ri=b(require("chalk"));var mr={title:"Installing Bun",enabled:e=>!!e.shouldInstallBun&&!Di(),task:async(e,t)=>K(t,async r=>{await kl(t),e.elapsedTime+=r(),t.title=`Bun installed successfully. (${e.elapsedTime}s)`})},gr={enabled:e=>!Di()&&!e.shouldInstallBun&&!e.packageManager,task:async(e,t)=>{e.shouldInstallBun=await t.prompt(R).run({type:"Toggle",message:"Would you like to use Bun? (recommended)",initial:!0,footer:["",`${Ri.default.magenta.bold("Bun")} is a fast JavaScript runtime, package manager, bundler, and test runner: ${Ri.default.underline("https://bun.sh")}`,El(),Sl()].join(`
236
+ `)}),e.shouldInstallBun&&(e.packageManager="bun")}};var Ii=b(require("chalk"));var Bs={title:"Install integrations",enabled:e=>e.selectedIntegrations.length>0,task:async(e,t)=>K(t,async r=>{let{selectedIntegrations:n,cwd:s,packageManager:o}=e;await Pl({selectedIntegrations:n,packageManager:o,cwd:s,task:t}),e.elapsedTime+=r()}),rendererOptions:{outputBar:1e3}},js={title:"Select integrations",enabled:e=>e.selectedIntegrations.length===0,task:async(e,t)=>{e.selectedIntegrations=await t.prompt(R).run({type:"MultiSelect",hint:`
237
+ Press <space> to select/deselect, <enter> to confirm, <i> to invert selection`,message:"Which integrations would you like to include?",initial:ur().map((r,n)=>n),choices:e.availableIntegrations.map(({name:r,description:n})=>({name:r,message:[Ii.default.bold(r),n].join(" - "),value:r}))}),!e.selectedIntegrations||e.selectedIntegrations.length===0?t.title="No integrations selected.":t.title=["Selected integrations:",...e.selectedIntegrations.map(r=>Ii.default.bold(`\u2022 ${r}`))].join(`
238
+ `)}};var zp={title:"Install Nest CLI",task:async(e,t)=>K(t,async r=>{await wu({packages:["@nestjs/cli"],task:t,cwd:e.cwd}),e.elapsedTime+=r()}),rendererOptions:{outputBar:1e3}};var _s={title:"Install dependencies",task:async(e,t)=>K(t,async r=>{await xt({cwd:e.cwd,task:t,packageManager:e.packageManager}),e.elapsedTime+=r()})};var Kp=b(require("chalk"));var Dr={enabled:e=>!e.removeDir&&!es(e.cwd),task:async(e,t)=>{if(e.removeDir=await t.prompt(R).run({type:"Toggle",message:Kp.default.bold("\u26A0\uFE0F Overwrite existing directory?"),initial:!1}),!e.removeDir)throw new Error("Project creation was canceled by the user.")}},yr={enabled:e=>!!e.removeDir,task:async e=>Zc(e.cwd)};var Ls={title:"Run integration commands",enabled:e=>e.selectedIntegrations.length>0,task:async(e,t)=>K(t,async r=>{let{selectedIntegrations:n,cwd:s}=e;await Il({selectedIntegrations:n,cwd:s,task:t,packageManager:e.packageManager}),e.elapsedTime+=r()}),rendererOptions:{outputBar:1}};var cw=["services/my-hono-service","services/my-nest-service","my-platform"],wr={enabled:e=>e.skipInputPrompts||e.userConfirmed?!1:e.projectName?cw.includes(e.projectName):!0,task:async(e,t)=>{e.projectName=await t.prompt(R).run({type:"Input",initial:e.projectName,message:"Enter project name",validate:r=>r?!0:"Project name is required."}),e.cwd&&(e.cwd=S(e.projectName))}};var Ni=b(require("chalk"));var Cr={title:"Select Package manager",task:async(e,t)=>{if(e.packageManager??=Ho(),e.packageManager){t.title=`Using ${Ni.default.bold(e.packageManager)} as package manager.`;return}e.packageManager=await t.prompt(R).run({type:"Select",message:"Which package manager would you like to use?",initial:Uo(),choices:yu}),t.title=`Using ${Ni.default.bold(e.packageManager)} as package manager.`}};var wn=b(require("chalk")),Jp={title:"GitHub repository owner",task:async(e,t)=>{if(e.githubOwner){t.title=`GitHub owner: ${wn.default.bold(e.githubOwner)}`;return}e.githubOwner=await t.prompt(R).run({type:"Input",message:"Enter GitHub organization or username",initial:"my-org",validate:r=>r?.trim()?!0:"GitHub owner is required."}),t.title=`GitHub owner: ${wn.default.bold(e.githubOwner)}`}},Vp={title:"Include GitHub CI/CD",task:async(e,t)=>{if(e.includeGitHubCI!==void 0){t.title=e.includeGitHubCI?"Including GitHub CI/CD workflows":"Skipping GitHub CI/CD";return}e.includeGitHubCI=await t.prompt(R).run({type:"Toggle",message:"Include GitHub Actions workflows and CI/CD?",initial:!0,enabled:"Yes",disabled:"No"}),t.title=e.includeGitHubCI?"Including GitHub CI/CD workflows":"Skipping GitHub CI/CD"}};var qp={title:"Pulumi stack name",task:async(e,t)=>{if(e.pulumiStackBase){t.title=`Pulumi stack: ${wn.default.bold(e.pulumiStackBase)}`;return}let r=e.githubOwner||"myorg",n=e.projectName?.replace(/[^a-zA-Z0-9-]/g,"-")||"myproject",s=`${r}/${n}`;e.pulumiStackBase=await t.prompt(R).run({type:"Input",message:"Enter Pulumi stack base name (org/project)",initial:s,validate:o=>o?.trim()?o.includes("/")?!0:"Format should be org/project (e.g., myorg/myproject)":"Pulumi stack name is required."}),t.title=`Pulumi stack: ${wn.default.bold(e.pulumiStackBase)}`}};var Lt=require("node:fs"),Wt=require("node:path");var Mi=require("node:path");var uw=()=>fr([(0,Mi.join)(__dirname,"templates","hono-microservice"),(0,Mi.join)(__dirname,"..","hono-microservice","templates")],"Hono templates directory not found."),$i=(e,t={})=>Os(uw())(e,t);function Yp(){return $i("tsconfig.json.hbs")}function Zp(e="1.2.23"){return $i("Dockerfile.hbs",{bunVersion:e})}function Xp(){return $i("biome.json.hbs")}var lw=async({projectName:e,packageManager:t},r)=>{let n=t==="bun"?"bun":"nodejs";try{await qt("create-hono@latest",[e,"--pm",t,"--template",n,"--install"],{task:r})}catch(o){let i=(0,Wt.join)(S(e),"package.json");if(!(0,Lt.existsSync)(i))throw new Error(`Failed to scaffold: ${o instanceof Error?o.message:String(o)}`)}let s=(0,Wt.join)(S(e),"package.json");if(!(0,Lt.existsSync)(s))throw new Error("Failed to scaffold Hono app structure - package.json not created")},pw=({projectName:e,packageManager:t})=>{let r=(0,Wt.basename)(e),n=ns(),s=t==="npm"?"*":"workspace:*",o=S(e),i=Qc("scripts.dev",o);i&&Jt("scripts.start:dev",i,e),[{field:"name",value:`${n}/${r}`},{field:"scripts.test",value:"bun test"},{field:"scripts.lint",value:"biome lint --write ./src"},{field:`dependencies.${n}/contracts`,value:s},{field:"dependencies.@crossdelta/telemetry",value:"*"},{field:"devDependencies.bun-types",value:"latest",condition:t!=="bun"},{field:"devDependencies.@biomejs/biome",value:"latest"}].filter(({condition:c})=>c??!0).map(({field:c,value:u})=>Jt(c,u,e))},fw=({projectName:e})=>{let t=(0,Wt.basename)(e),r=(0,Wt.join)(S(e),"src","index.ts"),n=(0,Lt.readFileSync)(r,"utf-8");n.includes("@crossdelta/telemetry")||(n=`// IMPORTANT: telemetry must be imported first to patch modules before they're loaded
239
239
  import '@crossdelta/telemetry'
240
240
 
241
- `+n);let o=fn(t);n=n.replace(/const port = .+/,`const port = Number(process.env.PORT || process.env.${o}_PORT) || 8080`),(0,Lt.writeFileSync)(r,n)},cw=({projectName:e})=>{let t=S(e),r=(0,Wt.join)(t,"tsconfig.json");(0,Lt.writeFileSync)(r,Kp());let n=(0,Wt.join)(t,"Dockerfile");(0,Lt.writeFileSync)(n,Jp());let s=(0,Wt.join)(t,"biome.json");(0,Lt.writeFileSync)(s,Vp())},qp={title:"Create Hono app structure",rendererOptions:{outputBar:1e3},task:async(e,t)=>K(t,async r=>{await ow(e,t),iw(e),aw(e),cw(e),e.elapsedTime+=r()})};var uw=e=>{let t=(e||"my-hono-service").trim();return t.includes("/")||t.startsWith(".")?t:`${vt().services}/${t}`},lw=async(e,t)=>{let{valid:r,config:n,error:s}=or();if(!r||!n){console.log(s);return}let o=uw(e.name),i=t.packageManager||$(),a=await gs(t.description);if(Ds(o,n,a),await ys({servicePath:o,description:a,serviceType:"hono",packageManager:i},n))console.log(Xt.default.green.bold(`
241
+ `+n);let o=Dn(t);n=n.replace(/const port = .+/,`const port = Number(process.env.PORT || process.env.${o}_PORT) || 8080`),(0,Lt.writeFileSync)(r,n)},dw=({projectName:e})=>{let t=S(e),r=(0,Wt.join)(t,"tsconfig.json");(0,Lt.writeFileSync)(r,Yp());let n=(0,Wt.join)(t,"Dockerfile");(0,Lt.writeFileSync)(n,Zp());let s=(0,Wt.join)(t,"biome.json");(0,Lt.writeFileSync)(s,Xp())},Qp={title:"Create Hono app structure",rendererOptions:{outputBar:1e3},task:async(e,t)=>K(t,async r=>{await lw(e,t),pw(e),fw(e),dw(e),e.elapsedTime+=r()})};var hw=e=>{let t=(e||"my-hono-service").trim();return t.includes("/")||t.startsWith(".")?t:`${vt().services}/${t}`},mw=async(e,t)=>{let{valid:r,config:n,error:s}=cr();if(!r||!n){console.log(s);return}let o=hw(e.name),i=t.packageManager||$(),a=await bs(t.description);if(vs(o,n,a),await xs({servicePath:o,description:a,serviceType:"hono",packageManager:i},n))console.log(Qt.default.green.bold(`
242
242
  \u2705 Service generated successfully!
243
- `)),console.log(Xt.default.dim("Next steps:")),console.log(Xt.default.dim(` ${Xt.default.cyan("pf dev")} - Start all services`)),console.log(Xt.default.dim(` ${Xt.default.cyan(`cd ${o} && bun dev`)} - Start this service only`)),console.log();else throw new Error("Service generation failed")},Zp=ne({name:"hono-micro",description:"Create a new Hono microservice with the Crossdelta setup. Use --ai for AI-powered generation.",arguments:[["[name]","Name or path of the service"]],options:[["-P, --package-manager <manager>","Specify the package manager (e.g., npm, yarn, pnpm, bun)"],["-y, --yes","Skip all prompts and use default values"],["--ai","Use AI to generate service code based on a description"],["-d, --description <description>","Service description for AI generation (requires --ai)"],["--remove-dir","Remove existing directory before creating (used internally)"]],exampleUsage:'platform new hono-micro my-service --ai -d "Payment processing service"',shouldSkipWorkflow:(e,t)=>!!t.ai,onSkipWorkflow:lw,buildContext:async(e,t)=>{let r=(e.name??"my-hono-service").trim();!r.includes("/")&&!r.startsWith(".")&&(r=`${vt().services}/${r}`);let n=S(r),s=t.packageManager??(t.yes&&$()),o=Ft(),i=t.yes?ir():[],a=t.packageManager==="bun",c=!!t.yes||!!e.name&&e.name!=="my-hono-service";return{cwd:n,projectName:r,packageManager:s,shouldInstallBun:a,availableIntegrations:o,selectedIntegrations:i,serviceType:"hono",elapsedTime:0,userConfirmed:!!t.yes,skipInputPrompts:c,removeDir:!!t.removeDir||!!t.yes}},prompts:[gr,hr,dr,Dr,Ns,lr],actions:[mr,fr,qp,Rs,Is,Ms],onComplete:({projectName:e,packageManager:t,selectedIntegrations:r,assignedPort:n})=>{w.breakLine().log(Xt.default.bold.green("Hono Microservice created successfully!")),bs(r),El((0,Yp.basename)(e),n??8080);let s=t??$();w.breakLine().log(`To start the project, run:
244
- ${Xt.default.bold(`cd ${e} && ${s} run dev`)}`).breakLine().log("Happy shipping with Hono! \u26A1\uFE0F").breakLine()}});var Qt=b(require("chalk"));var At=require("node:fs"),ct=require("node:path");var Ii=require("node:path");var pw=()=>ur([(0,Ii.join)(__dirname,"templates","nest-microservice"),(0,Ii.join)(__dirname,"..","nest-microservice","templates")],"NestJS templates directory not found."),yr=(e,t={})=>As(pw())(e,t);function $s(e,t=3e3){return yr("src/main.ts.hbs",{serviceName:e,envKey:fn(e),displayName:Op(e),defaultPort:t})}function Xp(){return yr("src/app.context.ts.hbs",{})}function Qp(){return yr("src/events/events.module.ts.hbs",{})}function tf(e){return yr("src/events/events.service.ts.hbs",{serviceName:e})}function ef(e="24",t="1.2.23"){return yr("Dockerfile.hbs",{nodeVersion:e,bunVersion:t})}function rf(){return yr("biome.json.hbs",{})}var fw=async(e,t)=>{await qt("@nestjs/cli",["new",e.projectName,"--skip-install","--skip-git","--package-manager",e.packageManager],{task:t})},dw=({projectName:e,packageManager:t})=>{let r=(0,ct.basename)(e),n=Xn(),s=t==="npm"?"*":"workspace:*";[{field:"name",value:`${n}/${r}`},{field:"type",value:"module"},{field:"scripts.start",value:"bun src/main.ts"},{field:"scripts.start:dev",value:"bun --hot src/main.ts"},{field:"scripts.start:prod",value:"node dist/main.js"},{field:"scripts.test",value:"bun test"},{field:"scripts.lint",value:"biome lint --write ./src"},{field:`dependencies.${n}/contracts`,value:s},{field:"dependencies.@crossdelta/telemetry",value:"*"},{field:"devDependencies.bun-types",value:"latest"},{field:"devDependencies.@biomejs/biome",value:"latest"}].map(({field:a,value:c})=>Jt(a,c,e)),["jest","@types/jest","ts-jest","@nestjs/testing","supertest","@types/supertest","ts-node","tsconfig-paths","@nestjs/schematics","@nestjs/cli"].map(a=>Jt(`devDependencies.${a}`,void 0,e))},hw=({projectName:e})=>{let t=["eslint.config.mjs","src/app.controller.spec.ts"];for(let r of t)try{(0,At.unlinkSync)((0,ct.join)(S(e),r))}catch{}},mw=({projectName:e})=>{let t=S(e),r=(0,ct.join)(t,"Dockerfile");(0,At.writeFileSync)(r,ef());let n=(0,ct.join)(t,"biome.json");(0,At.writeFileSync)(n,rf())},gw=({projectName:e})=>{let t=(0,ct.join)(S(e),"src","app.context.ts");(0,At.writeFileSync)(t,Xp())},Dw=({projectName:e})=>{let t=(0,ct.basename)(e),r=(0,ct.join)(S(e),"src","events");(0,At.mkdirSync)(r,{recursive:!0}),(0,At.writeFileSync)((0,ct.join)(r,"events.module.ts"),Qp()),(0,At.writeFileSync)((0,ct.join)(r,"events.service.ts"),tf(t)),Rl(e)},yw=({projectName:e})=>{let t=(0,ct.basename)(e),r=(0,ct.join)(S(e),"src","main.ts");(0,At.writeFileSync)(r,$s(t))},nf={title:"Create NestJS app structure",rendererOptions:{outputBar:1e3},task:async(e,t)=>K(t,async r=>{await fw(e,t),dw(e),Al(e.projectName),hw(e),mw(e),gw(e),Dw(e),yw(e),e.elapsedTime+=r()})};var sf=require("node:fs"),Bs=require("node:path");var of={title:"Patch main.ts with PORT pattern",task:async(e,t)=>K(t,async r=>{let n=(0,Bs.basename)(e.projectName),s=e.assignedPort??3e3,o=(0,Bs.join)(S(e.projectName),"src","main.ts");(0,sf.writeFileSync)(o,$s(n,s)),t.title=`Patched main.ts with PORT || ${n.toUpperCase().replace(/-/g,"_")}_PORT`,e.elapsedTime+=r()})};var ww=e=>{let t=(e||"my-nest-service").trim();return t.includes("/")||t.startsWith(".")?t:`${vt().services}/${t}`},Cw=async(e,t)=>{let{valid:r,config:n,error:s}=or();if(!r||!n){console.log(s);return}let o=ww(e.name),i=t.packageManager||$(),a=await gs(t.description);if(Ds(o,n,a),await ys({servicePath:o,description:a,serviceType:"nest",packageManager:i},n))console.log(Qt.default.green.bold(`
243
+ `)),console.log(Qt.default.dim("Next steps:")),console.log(Qt.default.dim(` ${Qt.default.cyan("pf dev")} - Start all services`)),console.log(Qt.default.dim(` ${Qt.default.cyan(`cd ${o} && bun dev`)} - Start this service only`)),console.log();else throw new Error("Service generation failed")},ef=se({name:"hono-micro",description:"Create a new Hono microservice with the Crossdelta setup. Use --ai for AI-powered generation.",arguments:[["[name]","Name or path of the service"]],options:[["-P, --package-manager <manager>","Specify the package manager (e.g., npm, yarn, pnpm, bun)"],["-y, --yes","Skip all prompts and use default values"],["--ai","Use AI to generate service code based on a description"],["-d, --description <description>","Service description for AI generation (requires --ai)"],["--remove-dir","Remove existing directory before creating (used internally)"]],exampleUsage:'platform new hono-micro my-service --ai -d "Payment processing service"',shouldSkipWorkflow:(e,t)=>!!t.ai,onSkipWorkflow:mw,buildContext:async(e,t)=>{let r=(e.name??"my-hono-service").trim();!r.includes("/")&&!r.startsWith(".")&&(r=`${vt().services}/${r}`);let n=S(r),s=t.packageManager??(t.yes&&$()),o=St(),i=t.yes?ur():[],a=t.packageManager==="bun",c=!!t.yes||!!e.name&&e.name!=="my-hono-service";return{cwd:n,projectName:r,packageManager:s,shouldInstallBun:a,availableIntegrations:o,selectedIntegrations:i,serviceType:"hono",elapsedTime:0,userConfirmed:!!t.yes,skipInputPrompts:c,removeDir:!!t.removeDir||!!t.yes}},prompts:[wr,Dr,gr,Cr,js,dr],actions:[yr,mr,Qp,$s,Bs,Ls],onComplete:({projectName:e,packageManager:t,selectedIntegrations:r,assignedPort:n})=>{w.breakLine().log(Qt.default.bold.green("Hono Microservice created successfully!")),Ss(r),Al((0,tf.basename)(e),n??8080);let s=t??$();w.breakLine().log(`To start the project, run:
244
+ ${Qt.default.bold(`cd ${e} && ${s} run dev`)}`).breakLine().log("Happy shipping with Hono! \u26A1\uFE0F").breakLine()}});var te=b(require("chalk"));var Tt=require("node:fs"),ct=require("node:path");var Bi=require("node:path");var gw=()=>fr([(0,Bi.join)(__dirname,"templates","nest-microservice"),(0,Bi.join)(__dirname,"..","nest-microservice","templates")],"NestJS templates directory not found."),br=(e,t={})=>Os(gw())(e,t);function Ws(e,t=3e3){return br("src/main.ts.hbs",{serviceName:e,envKey:Dn(e),displayName:jp(e),defaultPort:t})}function rf(){return br("src/app.context.ts.hbs",{})}function nf(){return br("src/events/events.module.ts.hbs",{})}function sf(e){return br("src/events/events.service.ts.hbs",{serviceName:e})}function of(e="24",t="1.2.23"){return br("Dockerfile.hbs",{nodeVersion:e,bunVersion:t})}function af(){return br("biome.json.hbs",{})}var Dw=async(e,t)=>{await qt("@nestjs/cli",["new",e.projectName,"--skip-install","--skip-git","--package-manager",e.packageManager],{task:t})},yw=({projectName:e,packageManager:t})=>{let r=(0,ct.basename)(e),n=ns(),s=t==="npm"?"*":"workspace:*";[{field:"name",value:`${n}/${r}`},{field:"type",value:"module"},{field:"scripts.start",value:"bun src/main.ts"},{field:"scripts.start:dev",value:"bun --hot src/main.ts"},{field:"scripts.start:prod",value:"node dist/main.js"},{field:"scripts.test",value:"bun test"},{field:"scripts.lint",value:"biome lint --write ./src"},{field:`dependencies.${n}/contracts`,value:s},{field:"dependencies.@crossdelta/telemetry",value:"*"},{field:"dependencies.@nestjs/config",value:"^4"},{field:"devDependencies.bun-types",value:"latest"},{field:"devDependencies.@biomejs/biome",value:"latest"}].map(({field:a,value:c})=>Jt(a,c,e)),["jest","@types/jest","ts-jest","@nestjs/testing","supertest","@types/supertest","ts-node","tsconfig-paths","@nestjs/schematics","@nestjs/cli"].map(a=>Jt(`devDependencies.${a}`,void 0,e))},ww=({projectName:e})=>{let t=["eslint.config.mjs","src/app.controller.spec.ts"];for(let r of t)try{(0,Tt.unlinkSync)((0,ct.join)(S(e),r))}catch{}},Cw=({projectName:e})=>{let t=S(e),r=(0,ct.join)(t,"Dockerfile");(0,Tt.writeFileSync)(r,of());let n=(0,ct.join)(t,"biome.json");(0,Tt.writeFileSync)(n,af())},bw=({projectName:e})=>{let t=(0,ct.join)(S(e),"src","app.context.ts");(0,Tt.writeFileSync)(t,rf())},vw=({projectName:e})=>{let t=(0,ct.basename)(e),r=(0,ct.join)(S(e),"src","events");(0,Tt.mkdirSync)(r,{recursive:!0}),(0,Tt.writeFileSync)((0,ct.join)(r,"events.module.ts"),nf()),(0,Tt.writeFileSync)((0,ct.join)(r,"events.service.ts"),sf(t)),Ml(e)},xw=({projectName:e})=>{let t=(0,ct.basename)(e),r=(0,ct.join)(S(e),"src","main.ts");(0,Tt.writeFileSync)(r,Ws(t))},cf={title:"Create NestJS app structure",rendererOptions:{outputBar:1e3},task:async(e,t)=>K(t,async r=>{await Dw(e,t),yw(e),Nl(e.projectName),ww(e),Cw(e),bw(e),vw(e),xw(e),e.elapsedTime+=r()})};var uf=require("node:fs"),Gs=require("node:path");var lf={title:"Patch main.ts with PORT pattern",task:async(e,t)=>K(t,async r=>{let n=(0,Gs.basename)(e.projectName),s=e.assignedPort??3e3,o=(0,Gs.join)(S(e.projectName),"src","main.ts");(0,uf.writeFileSync)(o,Ws(n,s)),t.title=`Patched main.ts with PORT || ${n.toUpperCase().replace(/-/g,"_")}_PORT`,e.elapsedTime+=r()})};var kw=e=>{let t=(e||"my-nest-service").trim();return t.includes("/")||t.startsWith(".")?t:`${vt().services}/${t}`},Ew=async(e,t)=>{let{valid:r,config:n,error:s}=cr();if(!r||!n){console.log(s);return}let o=kw(e.name),i=t.packageManager||$(),a=await bs(t.description);if(vs(o,n,a),await xs({servicePath:o,description:a,serviceType:"nest",packageManager:i},n))console.log(te.default.green.bold(`
245
245
  \u2705 Service generated successfully!
246
- `)),console.log(Qt.default.dim("Next steps:")),console.log(Qt.default.dim(` ${Qt.default.cyan("pf dev")} - Start all services`)),console.log(Qt.default.dim(` ${Qt.default.cyan(`cd ${o} && bun run start:dev`)} - Start this service only`)),console.log();else throw new Error("Service generation failed")},af=ne({name:"nest-micro",description:"Create a new NestJS microservice with the Crossdelta setup. Use --ai for AI-powered generation.",arguments:[["[name]","Name or path of the service"]],options:[["-P, --package-manager <manager>","Specify the package manager (e.g., npm, yarn, pnpm, bun)"],["-y, --yes","Skip all prompts and use default values"],["--ai","Use AI to generate service code based on a description"],["-d, --description <description>","Service description for AI generation (requires --ai)"],["--remove-dir","Remove existing directory before creating (used internally)"]],exampleUsage:'platform new nest-micro my-service --ai -d "User authentication service"',shouldSkipWorkflow:(e,t)=>!!t.ai,onSkipWorkflow:Cw,buildContext:async(e,t)=>{let r=(e.name??"my-nest-service").trim();!r.includes("/")&&!r.startsWith(".")&&(r=`${vt().services}/${r}`);let n=S(r),s=t.packageManager??(t.yes&&$()),o=t.packageManager==="bun",i=Ft(),a=t.yes?ir():[],c=!!t.yes||!!e.name;return{cwd:n,projectName:r,shouldInstallBun:o,packageManager:s,availableIntegrations:i,selectedIntegrations:a,serviceType:"nest",elapsedTime:0,userConfirmed:!!t.yes,skipInputPrompts:c,removeDir:!!t.removeDir||!!t.yes}},prompts:[gr,hr,dr,Dr,Ns,lr],actions:[mr,fr,nf,Rs,of,Os,Wp,Is,Ms],onComplete:({projectName:e,packageManager:t,selectedIntegrations:r})=>{w.breakLine().log(Qt.default.bold.green("NestJS Microservice created successfully!")),bs(r),w.breakLine().log(`To start the project, run:
247
- ${Qt.default.bold(`cd ${e} && ${t} run start:dev`)}`).breakLine().log("Happy coding! \u{1F389}").breakLine()}});var ut=b(require("chalk"));var Pt=require("node:fs"),wr=require("node:path");var cf=require("node:fs"),js=require("node:path");var Ni=()=>ur([(0,js.join)(__dirname,"templates","workspace"),(0,js.join)(__dirname,"..","..","..","..","templates","workspace")],"Workspace templates directory not found."),uf=()=>{let e=Ni(),t=(0,js.join)(e,"packages","contracts");if(!(0,cf.existsSync)(t))throw new Error(`Contracts templates directory not found at: ${t}`);return t},_s=(e,t)=>Ei(e,t);var bw=()=>{let e=(0,wr.join)(process.cwd(),"package.json");if(!(0,Pt.existsSync)(e))throw new Error("Root package.json not found. Please run this command from the workspace root.");let r=JSON.parse((0,Pt.readFileSync)(e,"utf-8")).name;if(!r)throw new Error('package.json must have a "name" field');return r.startsWith("@")?r:`@${r}`},lf=()=>{let e=bw(),{relativePath:t,packagePath:r}=G();if((0,Pt.existsSync)(r))throw new Error(`${t} already exists. Remove it first if you want to regenerate.`);console.log(`Creating contracts package with scope: ${e}`);let n=uf(),s={scope:e};(0,Pt.mkdirSync)(r,{recursive:!0}),(0,Pt.mkdirSync)((0,wr.join)(r,"src","streams"),{recursive:!0}),(0,Pt.mkdirSync)((0,wr.join)(r,"src","events"),{recursive:!0});let o=[{template:"package.json.hbs",output:"package.json"},{template:"tsconfig.json.hbs",output:"tsconfig.json"},{template:"README.md.hbs",output:"README.md"},{template:"src/index.ts",output:"src/index.ts"}];for(let i of o){let a=(0,wr.join)(n,i.template),c=(0,wr.join)(r,i.output),u=_s(a,s);(0,Pt.writeFileSync)(c,u,"utf-8")}console.log(`\u2705 Created ${e}/contracts at ${t}`),console.log(`
248
- Next steps:`),console.log("1. Run: bun install"),console.log("2. Define your first event schema in src/events/"),console.log('3. Add contracts to services: "@scope/contracts": "workspace:*"')};var ff=require("node:child_process"),st=require("node:fs"),Cr=require("node:path");var pf=e=>{e.endsWith(".sh")&&(0,st.chmodSync)(e,493)},vw=[{template:"package.json.hbs",output:"package.json"},{template:"pnpm-workspace.yaml.hbs",output:"pnpm-workspace.yaml",forPackageManager:"pnpm"},{template:"biome.json.hbs",output:"biome.json"},{template:"turbo.json.hbs",output:"turbo.json"},{template:"bunfig.toml.hbs",output:"bunfig.toml"},{template:"gitignore.hbs",output:".gitignore"},{template:"editorconfig.hbs",output:".editorconfig"},{template:"npmrc.hbs",output:".npmrc"},{template:"infra/package.json.hbs",output:"infra/package.json"},{template:"infra/index.ts.hbs",output:"infra/index.ts"},{template:"infra/tsconfig.json.hbs",output:"infra/tsconfig.json"},{template:"infra/Pulumi.yaml.hbs",output:"infra/Pulumi.yaml"},{template:"infra/Pulumi.dev.yaml.hbs",output:"infra/Pulumi.dev.yaml"},{template:"infra/services/nats.ts.hbs",output:"infra/services/nats.ts"},{template:"services/nats/package.json.hbs",output:"services/nats/package.json"},{template:"services/nats/nats.conf",output:"services/nats/nats.conf",isStatic:!0},{template:"services/nats/nats.prod.conf",output:"services/nats/nats.prod.conf",isStatic:!0},{template:"services/nats/README.md",output:"services/nats/README.md",isStatic:!0},{template:"services/nats/scripts/start-dev.sh.hbs",output:"services/nats/scripts/start-dev.sh"},{template:"apps/.gitkeep",output:"apps/.gitkeep",isStatic:!0},{template:"packages/.gitkeep",output:"packages/.gitkeep",isStatic:!0},{template:"docs/.gitkeep",output:"docs/.gitkeep",isStatic:!0},{template:".github/copilot-instructions.md.hbs",output:".github/copilot-instructions.md"},{template:".github/README.md",output:".github/README.md",isStatic:!0,isGitHubCI:!0},{template:".github/dependabot.yml",output:".github/dependabot.yml",isStatic:!0,isGitHubCI:!0},{template:".github/workflows/lint-and-tests.yml.hbs",output:".github/workflows/lint-and-tests.yml",isGitHubCI:!0},{template:".github/workflows/build-and-deploy.yml.hbs",output:".github/workflows/build-and-deploy.yml",isGitHubCI:!0},{template:".github/workflows/publish-packages.yml",output:".github/workflows/publish-packages.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/setup-bun-install/action.yml.hbs",output:".github/actions/setup-bun-install/action.yml",isGitHubCI:!0},{template:".github/actions/check-image-tag-exists/action.yml",output:".github/actions/check-image-tag-exists/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/check-image-tag-exists/index.js",output:".github/actions/check-image-tag-exists/index.js",isStatic:!0,isGitHubCI:!0},{template:".github/actions/check-path-changes/action.yml",output:".github/actions/check-path-changes/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/check-path-changes/index.js",output:".github/actions/check-path-changes/index.js",isStatic:!0,isGitHubCI:!0},{template:".github/actions/detect-skipped-services/action.yml",output:".github/actions/detect-skipped-services/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/generate-scope-matrix/action.yml",output:".github/actions/generate-scope-matrix/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/generate-scope-matrix/index.js",output:".github/actions/generate-scope-matrix/index.js",isStatic:!0,isGitHubCI:!0},{template:".github/actions/prepare-build-context/action.yml",output:".github/actions/prepare-build-context/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/resolve-scope-tags/action.yml",output:".github/actions/resolve-scope-tags/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/resolve-scope-tags/index.js",output:".github/actions/resolve-scope-tags/index.js",isStatic:!0,isGitHubCI:!0}],df={title:"Creating workspace structure",task:async(e,t)=>{if((0,st.existsSync)(e.cwd)){t.title="Workspace directory already exists, skipping...";return}let r=Ni(),n=e.includeGitHubCI??!0,s=e.packageManager||"bun",o=c=>{try{let p=(0,ff.spawnSync)(c,["--version"],{encoding:"utf-8",timeout:5e3}).stdout?.trim();if(p&&/^\d+\.\d+/.test(p))return`${c}@${p}`}catch{}return{bun:"bun@1.2.7",npm:"npm@10.9.2",yarn:"yarn@4.6.0",pnpm:"pnpm@9.15.2"}[c]||`${c}@latest`},i={projectName:e.projectName,githubOwner:e.githubOwner||"",pulumiStackBase:e.pulumiStackBase||e.projectName,packageManager:s,packageManagerVersion:o(s)},a=vw.filter(c=>!(c.isGitHubCI&&!n||c.forPackageManager&&c.forPackageManager!==s));for(let c of a){let u=(0,Cr.join)(e.cwd,c.output),l=(0,Cr.dirname)(u);if((0,st.existsSync)(l)||(0,st.mkdirSync)(l,{recursive:!0}),c.isStatic){let p=(0,Cr.join)(r,c.template);(0,st.existsSync)(p)?(0,st.writeFileSync)(u,(0,st.readFileSync)(p)):(0,st.writeFileSync)(u,""),pf(u)}else{let p=(0,Cr.join)(r,c.template),d=_s(p,i);(0,st.writeFileSync)(u,d),pf(u)}}t.title="Workspace structure created"}};var hf=ne({name:"workspace",description:"Create a new workspace with infrastructure setup",arguments:[["[name]","Name or path of the workspace"]],options:[["-P, --package-manager <manager>","Specify the package manager (e.g., npm, yarn, pnpm, bun)"],["-y, --yes","Skip all prompts and use default values"],["-o, --github-owner <owner>","GitHub organization or username"],["-s, --pulumi-stack <name>","Pulumi stack base name (org/project)"],["--no-github","Skip GitHub CI/CD workflows"],["--remove-dir","Remove existing directory before creating (internal use)"]],exampleUsage:"pf new workspace my-platform -o my-org",buildContext:(e,t)=>{let r=(e.name??"my-platform").trim(),n=S(r),s=!!t.yes,o=t.packageManager??(s?$():void 0),i=t.packageManager==="bun",a=t.githubOwner??(s?"my-org":void 0),c=t.pulumiStack??(s?`${a}/${r}`:void 0),u=t.github===!1?!1:s?!0:void 0,l=!!e.name,p=t.removeDir||s;return{cwd:n,projectName:r,shouldInstallBun:i,packageManager:o,elapsedTime:0,userConfirmed:s,skipInputPrompts:l&&!s,removeDir:p,githubOwner:a,pulumiStackBase:c,includeGitHubCI:u}},prompts:[{enabled:e=>!e.userConfirmed,task:async(e,t)=>{try{let r=O();if(!await t.prompt(R).run({type:"toggle",message:`\u26A0\uFE0F You are inside an existing workspace (${r}). Create a nested workspace anyway?`,enabled:"Yes",disabled:"No",initial:!1}))throw new Error("Workspace creation cancelled - already inside a workspace");t.title=ut.default.yellow("Warning: Creating nested workspace")}catch(r){if(r.message?.includes("cancelled"))throw r;t.title="No existing workspace detected"}}},gr,hr,Hp,Up,zp,dr,Dr,lr],actions:[mr,fr,df,{title:"Initializing contracts package",task:(e,t)=>{let r=process.cwd();try{process.chdir(e.cwd),lf(),t.title="Contracts package initialized"}catch(n){throw t.title=ut.default.red(`Contracts package failed: ${n.message}`),n}finally{process.chdir(r)}}},Os,Lp],onComplete:({projectName:e,includeGitHubCI:t})=>{w.breakLine().log(ut.default.bold.green("Workspace created successfully!")),w.breakLine().log(ut.default.bold("Next steps:")).log(` 1. ${ut.default.cyan(`cd ${e}`)}`).log(` 2. ${ut.default.cyan("bun pulumi login")}`).log(` 3. ${ut.default.cyan("bun pulumi up --stack dev")}`),t&&w.breakLine().log(ut.default.bold("GitHub Setup:")).log(" Configure these secrets in your GitHub repository:").log(` \u2022 ${ut.default.yellow("PULUMI_ACCESS_TOKEN")} - Pulumi Cloud access token`).log(` \u2022 ${ut.default.yellow("DIGITALOCEAN_TOKEN")} - DigitalOcean API token`).log(` \u2022 ${ut.default.yellow("NPM_TOKEN")} - (optional) NPM token for private packages`),w.breakLine().log(ut.default.bold("Structure created:")).log(" apps/ # Frontend applications").log(" services/ # Backend microservices").log(" packages/").log(" \u2514\u2500\u2500 contracts/ # Shared event contracts").log(" infra/").log(" \u251C\u2500\u2500 index.ts # Pulumi entry point").log(" \u251C\u2500\u2500 services/ # Service configs").log(" \u251C\u2500\u2500 Pulumi.yaml # Pulumi project config").log(" \u2514\u2500\u2500 Pulumi.dev.yaml # Dev stack config"),t&&w.log(" .github/").log(" \u251C\u2500\u2500 workflows/ # CI/CD workflows").log(" \u2514\u2500\u2500 actions/ # Custom actions"),w.breakLine().log("Happy coding! \u{1F389}").breakLine()}});var mn=[{name:"Hono Microservice",value:"hono-micro",command:Zp,supportsAi:!0},{name:"Nest Microservice",value:"nest-micro",command:af,supportsAi:!0},{name:"Workspace (Infrastructure)",value:"workspace",command:hf,supportsAi:!1}],mf=()=>{let e=ne({name:"new",description:"Create a new project",arguments:[["[type]","Type of the project (e.g., nest-micro, hono-micro, workspace)"]],exampleUsage:"platform new hono-micro test-service",buildContext:t=>({projectType:t.type??"",useAi:!1,aiDescription:"",elapsedTime:0,cwd:process.cwd()}),prompts:[{enabled:t=>!t.projectType,task:async(t,r)=>{let n=await r.prompt(R).run({type:"select",message:"Select Project type",choices:mn});t.projectType=mn.find(s=>s.name===n)?.value||"",r.title=`Using ${te.default.bold(n)}`}},{enabled:t=>t.projectType!=="workspace"&&t.projectType!=="",task:async(t,r)=>{try{O(),r.title="Workspace detected"}catch{let n=["Not in a workspace directory","",`Current directory: ${process.cwd()}`,"","This command must be run from within a workspace created with pf new workspace","","To create a new workspace, run:",""," pf new workspace my-platform"].join(`
249
- `);throw new Error(n)}}},{enabled:t=>t.projectType==="workspace",task:async(t,r)=>{try{let n=O();if(!await r.prompt(R).run({type:"toggle",message:`\u26A0\uFE0F You are inside an existing workspace (${n}). Create a nested workspace anyway?`,enabled:"Yes",disabled:"No",initial:!1}))throw new Error("Workspace creation cancelled - already inside a workspace");r.title=te.default.yellow("Warning: Creating nested workspace")}catch(n){if(n.message?.includes("cancelled"))throw n;r.title="No existing workspace detected"}}},{enabled:t=>!!t.projectType,task:async(t,r)=>{let s={"hono-micro":"services/my-hono-service","nest-micro":"services/my-nest-service",workspace:"my-platform"}[t.projectType]||"my-project",o=t.projectType==="workspace"?"\u{1F4E6} Workspace name:":"\u{1F4E6} Service path (e.g., services/my-service):",i=await r.prompt(R).run({type:"input",message:o,initial:s});t.servicePath=i.trim(),r.title=`Path: ${te.default.dim(i)}`}},{enabled:t=>!!mn.find(n=>n.value===t.projectType)?.supportsAi&&or().valid,task:async(t,r)=>{let n=await r.prompt(R).run({type:"toggle",message:"Use AI to generate service code?",enabled:"Yes",disabled:"No",initial:!1});t.useAi=n,r.title=n?te.default.cyan("\u{1F916} AI-powered generation"):"Standard scaffolding"}},{enabled:t=>t.useAi,task:async(t,r)=>{let n=await r.prompt(R).run({type:"input",message:"Describe what this service should do:"});t.aiDescription=n,r.title=`Description: ${te.default.dim(n.slice(0,50))}${n.length>50?"...":""}`}},{enabled:t=>{if(!t.servicePath)return!1;let r=S(t.servicePath);return!Yn(r)},task:async(t,r)=>{if(!await r.prompt(R).run({type:"toggle",message:te.default.bold("\u26A0\uFE0F Overwrite existing directory?"),enabled:"Yes",disabled:"No",initial:!1}))throw new Error("Project creation was canceled by the user.");t.shouldRemoveDir=!0,r.title=te.default.yellow("Will overwrite existing directory")}},{title:"Confirm creation",enabled:t=>t.projectType!=="workspace",task:async(t,r)=>{if(!await r.prompt(R).run({type:"Toggle",initial:!0,message:"\u{1F680} Ready to launch your project?"}))throw new Error("Project creation was canceled by the user.")}}],actions:[],onComplete:async t=>{mn.find(o=>o.value===t.projectType)||e.error(te.default.red(`Project type ${t.projectType} is not supported.`));let r=e.commands.find(o=>o.name()===t.projectType),n={};t.projectType!=="workspace"&&(n.yes=!0);let s=[];t.servicePath&&s.push("servicePath"),t.shouldRemoveDir&&(n.removeDir=!0),t.useAi&&(n.ai=!0,n.description=t.aiDescription),await Mp(r,t,n,s)}});for(let t of mn)e.addCommand(t.command);return e};var bf=require("commander");var gf=require("node:fs"),Df=require("node:path"),Oi=b(require("chokidar")),yf=(e,t,r)=>{for(let n of e){let s=(0,Df.join)(t,n);(0,gf.existsSync)(s)&&(Oi.default.watch(s,{ignoreInitial:!0,depth:0}).on("addDir",()=>r()).on("unlinkDir",()=>r()),Oi.default.watch(`${s}/*/package.json`,{ignoreInitial:!0}).on("add",()=>r()).on("change",()=>r()).on("unlink",()=>r()))}};var Ls=b(require("chalk"));var $i=e=>new Promise(t=>setTimeout(t,e)),Mi=e=>process.stdout.write(`${e}
250
- `),xw=()=>{process.stdout.write("\x1B[?1049l"),process.stdout.write("\x1B[2J"),process.stdout.write("\x1B[3J"),process.stdout.write("\x1B[H"),process.stdout.write("\x1B[?25h"),process.stdout.isTTY&&process.stdout.write("\x1Bc")},wf=()=>({turboProcess:null,isRestarting:!1,isShuttingDown:!1}),Cf=async(e,t)=>{let r=iu(".env.local",t);r.length>0&&(await lu(r),await $i(50)),Mi(Ls.default.cyan("\u{1F525} Starting services...")),Mi(Ls.default.dim(` Command: turbo run ${qs} --continue`)),e.isShuttingDown=!1,e.isRestarting=!1,e.turboProcess=uu("turbo",["run",qs,"--continue","--no-daemon"],{cwd:t,envFile:".env.local",onExit:n=>{!e.isRestarting&&!e.isShuttingDown&&(Mi(`
251
- ${Ls.default.red("Turbo exited with code")} ${n}`),process.exit(n??0))}})},Bi=async(e,t=!1)=>{let r=e.turboProcess?.pid;if(r){t?e.isRestarting=!0:e.isShuttingDown=!0;try{try{process.kill(-r,"SIGTERM")}catch{e.turboProcess?.kill("SIGTERM")}await $i(200);try{process.kill(-r,"SIGKILL")}catch{}await $i(30)}catch{}e.turboProcess=null,xw()}};var kw=300,Ew=["services","apps"],vf=new bf.Command("dev").description("Start development mode with auto-reload").action(async()=>{let e=O(),t=wf(),r=l=>Yr("generate-env",{cwd:l}),n=()=>kt({cwd:e,quiet:!0}),s=async()=>{await n(),await r(e),await Cf(t,e)},i=Ye(e)?.pf?.dev?.watchPackages??Ew,a=async()=>{if(!(t.isRestarting||t.isShuttingDown)){t.isRestarting=!0;try{await Bi(t,!0),await s()}catch{}finally{t.isRestarting=!1}}},c=(()=>{let l=null;return async()=>{t.isRestarting||t.isShuttingDown||(l&&clearTimeout(l),l=setTimeout(()=>a(),kw))}})(),u=async()=>{await Bi(t,!1),process.exit(0)};await s(),yf(i,e,c),process.on("SIGINT",u),process.on("SIGTERM",u)});var jf=require("commander");var xf=require("node:fs"),kf=require("node:path"),Gt=b(require("chalk")),Ef=require("commander");var Sw=e=>{if(e)try{return JSON.parse(e)}catch{return}},Fw=e=>{if(!e)return;let t={},r=e.split(",").map(n=>n.trim()).filter(Boolean);for(let n of r){let[s,o]=n.split(":").map(i=>i.trim());s&&o&&(t[s]=o)}return Object.keys(t).length>0?t:void 0},Tw=(e,t)=>{if(!t)return;let r=t.startsWith("/")?t:(0,kf.resolve)(e,t);return(0,xf.existsSync)(r)?r:void 0},Aw=async(e,t)=>{let r=[],n=[],s=[];if(Go(e)&&!t.force)n.push("Contract (already exists)");else{let i=Ho(e,t.schema);r.push(`Contract: ${i}`)}Xo(e)&&r.push("Export: packages/contracts/src/index.ts");let o=await us(e);if(o&&r.push(`Mock: ${o}`),t.servicePath){let i=Jo(e,t.servicePath);i?r.push(`Handler: ${i}`):n.push("Handler (already exists)");let a=Ko(t.servicePath,e);a.added?r.push(`Stream: ${a.streamName} added to index.ts`):a.warning&&s.push(a.warning)}return{created:r,skipped:n,warnings:s}},Pw=(e,t,r=[])=>{if(e.length>0){console.log(Gt.default.green(`\u2713 Created:
246
+ `)),console.log(te.default.dim("Next steps:")),console.log(te.default.dim(` ${te.default.cyan("pf dev")} - Start all services`)),console.log(te.default.dim(` ${te.default.cyan(`cd ${o} && bun run start:dev`)} - Start this service only`)),console.log();else throw new Error("Service generation failed")},pf=se({name:"nest-micro",description:"Create a new NestJS microservice with the Crossdelta setup. Use --ai for AI-powered generation.",arguments:[["[name]","Name or path of the service"]],options:[["-P, --package-manager <manager>","Specify the package manager (e.g., npm, yarn, pnpm, bun)"],["-y, --yes","Skip all prompts and use default values"],["--ai","Use AI to generate service code based on a description"],["-d, --description <description>","Service description for AI generation (requires --ai)"],["--remove-dir","Remove existing directory before creating (used internally)"]],exampleUsage:'platform new nest-micro my-service --ai -d "User authentication service"',shouldSkipWorkflow:(e,t)=>!!t.ai,onSkipWorkflow:Ew,buildContext:async(e,t)=>{let r=(e.name??"my-nest-service").trim();!r.includes("/")&&!r.startsWith(".")&&(r=`${vt().services}/${r}`);let n=S(r),s=t.packageManager??(t.yes&&$()),o=t.packageManager==="bun",i=St(),a=t.yes?ur():[],c=!!t.yes||!!e.name;return{cwd:n,projectName:r,shouldInstallBun:o,packageManager:s,availableIntegrations:i,selectedIntegrations:a,serviceType:"nest",elapsedTime:0,userConfirmed:!!t.yes,skipInputPrompts:c,removeDir:!!t.removeDir||!!t.yes}},prompts:[wr,Dr,gr,Cr,js,dr],actions:[yr,mr,cf,$s,lf,_s,zp,Bs,Ls],onComplete:({projectName:e,packageManager:t,selectedIntegrations:r})=>{w.breakLine().log(te.default.bold.green("NestJS Microservice created successfully!")),Ss(r),w.breakLine().log(`To start the project, run:
247
+ ${te.default.bold(`cd ${e} && ${t} run start:dev`)}`).breakLine().log("Happy coding! \u{1F389}").breakLine()}});var ut=b(require("chalk"));var At=require("node:fs"),vr=require("node:path");var ff=require("node:fs"),Hs=require("node:path");var ji=()=>fr([(0,Hs.join)(__dirname,"templates","workspace"),(0,Hs.join)(__dirname,"..","..","..","..","templates","workspace")],"Workspace templates directory not found."),df=()=>{let e=ji(),t=(0,Hs.join)(e,"packages","contracts");if(!(0,ff.existsSync)(t))throw new Error(`Contracts templates directory not found at: ${t}`);return t},Us=(e,t)=>Pi(e,t);var Sw=()=>{let e=(0,vr.join)(process.cwd(),"package.json");if(!(0,At.existsSync)(e))throw new Error("Root package.json not found. Please run this command from the workspace root.");let r=JSON.parse((0,At.readFileSync)(e,"utf-8")).name;if(!r)throw new Error('package.json must have a "name" field');return r.startsWith("@")?r:`@${r}`},hf=()=>{let e=Sw(),{relativePath:t,packagePath:r}=G();if((0,At.existsSync)(r))throw new Error(`${t} already exists. Remove it first if you want to regenerate.`);console.log(`Creating contracts package with scope: ${e}`);let n=df(),s={scope:e};(0,At.mkdirSync)(r,{recursive:!0}),(0,At.mkdirSync)((0,vr.join)(r,"src","streams"),{recursive:!0}),(0,At.mkdirSync)((0,vr.join)(r,"src","events"),{recursive:!0});let o=[{template:"package.json.hbs",output:"package.json"},{template:"tsconfig.json.hbs",output:"tsconfig.json"},{template:"README.md.hbs",output:"README.md"},{template:"src/index.ts",output:"src/index.ts"}];for(let i of o){let a=(0,vr.join)(n,i.template),c=(0,vr.join)(r,i.output),u=Us(a,s);(0,At.writeFileSync)(c,u,"utf-8")}console.log(`\u2705 Created ${e}/contracts at ${t}`),console.log(`
248
+ Next steps:`),console.log("1. Run: bun install"),console.log("2. Define your first event schema in src/events/"),console.log('3. Add contracts to services: "@scope/contracts": "workspace:*"')};var gf=require("node:child_process"),st=require("node:fs"),xr=require("node:path");var mf=e=>{e.endsWith(".sh")&&(0,st.chmodSync)(e,493)},Fw=[{template:"package.json.hbs",output:"package.json"},{template:"pnpm-workspace.yaml.hbs",output:"pnpm-workspace.yaml",forPackageManager:"pnpm"},{template:"biome.json.hbs",output:"biome.json"},{template:"turbo.json.hbs",output:"turbo.json"},{template:"bunfig.toml.hbs",output:"bunfig.toml"},{template:"gitignore.hbs",output:".gitignore"},{template:"editorconfig.hbs",output:".editorconfig"},{template:"npmrc.hbs",output:".npmrc"},{template:".vscode/settings.json",output:".vscode/settings.json",isStatic:!0},{template:".vscode/extensions.json",output:".vscode/extensions.json",isStatic:!0},{template:"infra/package.json.hbs",output:"infra/package.json"},{template:"infra/index.ts.hbs",output:"infra/index.ts"},{template:"infra/tsconfig.json.hbs",output:"infra/tsconfig.json"},{template:"infra/Pulumi.yaml.hbs",output:"infra/Pulumi.yaml"},{template:"infra/Pulumi.dev.yaml.hbs",output:"infra/Pulumi.dev.yaml"},{template:"infra/services/nats.ts.hbs",output:"infra/services/nats.ts"},{template:"services/nats/package.json.hbs",output:"services/nats/package.json"},{template:"services/nats/nats.conf",output:"services/nats/nats.conf",isStatic:!0},{template:"services/nats/nats.prod.conf",output:"services/nats/nats.prod.conf",isStatic:!0},{template:"services/nats/README.md",output:"services/nats/README.md",isStatic:!0},{template:"services/nats/scripts/start-dev.sh.hbs",output:"services/nats/scripts/start-dev.sh"},{template:"apps/.gitkeep",output:"apps/.gitkeep",isStatic:!0},{template:"packages/.gitkeep",output:"packages/.gitkeep",isStatic:!0},{template:"docs/.gitkeep",output:"docs/.gitkeep",isStatic:!0},{template:".github/copilot-instructions.md.hbs",output:".github/copilot-instructions.md"},{template:".github/README.md",output:".github/README.md",isStatic:!0,isGitHubCI:!0},{template:".github/dependabot.yml",output:".github/dependabot.yml",isStatic:!0,isGitHubCI:!0},{template:".github/workflows/lint-and-tests.yml.hbs",output:".github/workflows/lint-and-tests.yml",isGitHubCI:!0},{template:".github/workflows/build-and-deploy.yml.hbs",output:".github/workflows/build-and-deploy.yml",isGitHubCI:!0},{template:".github/workflows/publish-packages.yml",output:".github/workflows/publish-packages.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/setup-bun-install/action.yml.hbs",output:".github/actions/setup-bun-install/action.yml",isGitHubCI:!0},{template:".github/actions/check-image-tag-exists/action.yml",output:".github/actions/check-image-tag-exists/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/check-image-tag-exists/index.js",output:".github/actions/check-image-tag-exists/index.js",isStatic:!0,isGitHubCI:!0},{template:".github/actions/check-path-changes/action.yml",output:".github/actions/check-path-changes/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/check-path-changes/index.js",output:".github/actions/check-path-changes/index.js",isStatic:!0,isGitHubCI:!0},{template:".github/actions/detect-skipped-services/action.yml",output:".github/actions/detect-skipped-services/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/generate-scope-matrix/action.yml",output:".github/actions/generate-scope-matrix/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/generate-scope-matrix/index.js",output:".github/actions/generate-scope-matrix/index.js",isStatic:!0,isGitHubCI:!0},{template:".github/actions/prepare-build-context/action.yml",output:".github/actions/prepare-build-context/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/resolve-scope-tags/action.yml",output:".github/actions/resolve-scope-tags/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/resolve-scope-tags/index.js",output:".github/actions/resolve-scope-tags/index.js",isStatic:!0,isGitHubCI:!0}],Df={title:"Creating workspace structure",task:async(e,t)=>{if((0,st.existsSync)(e.cwd)){t.title="Workspace directory already exists, skipping...";return}let r=ji(),n=e.includeGitHubCI??!0,s=e.packageManager||"bun",o=c=>{try{let p=(0,gf.spawnSync)(c,["--version"],{encoding:"utf-8",timeout:5e3}).stdout?.trim();if(p&&/^\d+\.\d+/.test(p))return`${c}@${p}`}catch{}return{bun:"bun@1.2.7",npm:"npm@10.9.2",yarn:"yarn@4.6.0",pnpm:"pnpm@9.15.2"}[c]||`${c}@latest`},i={projectName:e.projectName,githubOwner:e.githubOwner||"",pulumiStackBase:e.pulumiStackBase||e.projectName,packageManager:s,packageManagerVersion:o(s)},a=Fw.filter(c=>!(c.isGitHubCI&&!n||c.forPackageManager&&c.forPackageManager!==s));for(let c of a){let u=(0,xr.join)(e.cwd,c.output),l=(0,xr.dirname)(u);if((0,st.existsSync)(l)||(0,st.mkdirSync)(l,{recursive:!0}),c.isStatic){let p=(0,xr.join)(r,c.template);(0,st.existsSync)(p)?(0,st.writeFileSync)(u,(0,st.readFileSync)(p)):(0,st.writeFileSync)(u,""),mf(u)}else{let p=(0,xr.join)(r,c.template),d=Us(p,i);(0,st.writeFileSync)(u,d),mf(u)}}t.title="Workspace structure created"}};var yf=se({name:"workspace",description:"Create a new workspace with infrastructure setup",arguments:[["[name]","Name or path of the workspace"]],options:[["-P, --package-manager <manager>","Specify the package manager (e.g., npm, yarn, pnpm, bun)"],["-y, --yes","Skip all prompts and use default values"],["-o, --github-owner <owner>","GitHub organization or username"],["-s, --pulumi-stack <name>","Pulumi stack base name (org/project)"],["--no-github","Skip GitHub CI/CD workflows"],["--remove-dir","Remove existing directory before creating (internal use)"]],exampleUsage:"pf new workspace my-platform -o my-org",buildContext:(e,t)=>{let r=(e.name??"my-platform").trim(),n=S(r),s=!!t.yes,o=t.packageManager??(s?$():void 0),i=t.packageManager==="bun",a=t.githubOwner??(s?"my-org":void 0),c=t.pulumiStack??(s?`${a}/${r}`:void 0),u=t.github===!1?!1:s?!0:void 0,l=!!e.name,p=t.removeDir||s;return{cwd:n,projectName:r,shouldInstallBun:i,packageManager:o,elapsedTime:0,userConfirmed:s,skipInputPrompts:l&&!s,removeDir:p,githubOwner:a,pulumiStackBase:c,includeGitHubCI:u}},prompts:[{enabled:e=>!e.userConfirmed,task:async(e,t)=>{try{let r=O();if(!await t.prompt(R).run({type:"toggle",message:`\u26A0\uFE0F You are inside an existing workspace (${r}). Create a nested workspace anyway?`,enabled:"Yes",disabled:"No",initial:!1}))throw new Error("Workspace creation cancelled - already inside a workspace");t.title=ut.default.yellow("Warning: Creating nested workspace")}catch(r){if(r.message?.includes("cancelled"))throw r;t.title="No existing workspace detected"}}},wr,Dr,Jp,Vp,qp,gr,Cr,dr],actions:[yr,mr,Df,{title:"Initializing contracts package",task:(e,t)=>{let r=process.cwd();try{process.chdir(e.cwd),hf(),t.title="Contracts package initialized"}catch(n){throw t.title=ut.default.red(`Contracts package failed: ${n.message}`),n}finally{process.chdir(r)}}},_s,Up],onComplete:({projectName:e,includeGitHubCI:t})=>{w.breakLine().log(ut.default.bold.green("Workspace created successfully!")),w.breakLine().log(ut.default.bold("Next steps:")).log(` 1. ${ut.default.cyan(`cd ${e}`)}`).log(` 2. ${ut.default.cyan("bun pulumi login")}`).log(` 3. ${ut.default.cyan("bun pulumi up --stack dev")}`),t&&w.breakLine().log(ut.default.bold("GitHub Setup:")).log(" Configure these secrets in your GitHub repository:").log(` \u2022 ${ut.default.yellow("PULUMI_ACCESS_TOKEN")} - Pulumi Cloud access token`).log(` \u2022 ${ut.default.yellow("DIGITALOCEAN_TOKEN")} - DigitalOcean API token`).log(` \u2022 ${ut.default.yellow("NPM_TOKEN")} - (optional) NPM token for private packages`),w.breakLine().log(ut.default.bold("Structure created:")).log(" apps/ # Frontend applications").log(" services/ # Backend microservices").log(" packages/").log(" \u2514\u2500\u2500 contracts/ # Shared event contracts").log(" infra/").log(" \u251C\u2500\u2500 index.ts # Pulumi entry point").log(" \u251C\u2500\u2500 services/ # Service configs").log(" \u251C\u2500\u2500 Pulumi.yaml # Pulumi project config").log(" \u2514\u2500\u2500 Pulumi.dev.yaml # Dev stack config"),t&&w.log(" .github/").log(" \u251C\u2500\u2500 workflows/ # CI/CD workflows").log(" \u2514\u2500\u2500 actions/ # Custom actions"),w.breakLine().log("Happy coding! \u{1F389}").breakLine()}});var Cn=[{name:"Hono Microservice",value:"hono-micro",command:ef,supportsAi:!0},{name:"Nest Microservice",value:"nest-micro",command:pf,supportsAi:!0},{name:"Workspace (Infrastructure)",value:"workspace",command:yf,supportsAi:!1}],wf=()=>{let e=se({name:"new",description:"Create a new project",arguments:[["[type]","Type of the project (e.g., nest-micro, hono-micro, workspace)"]],exampleUsage:"platform new hono-micro test-service",buildContext:t=>({projectType:t.type??"",useAi:!1,aiDescription:"",elapsedTime:0,cwd:process.cwd()}),prompts:[{enabled:t=>!t.projectType,task:async(t,r)=>{let n=await r.prompt(R).run({type:"select",message:"Select Project type",choices:Cn});t.projectType=Cn.find(s=>s.name===n)?.value||"",r.title=`Using ${ee.default.bold(n)}`}},{enabled:t=>t.projectType!=="workspace"&&t.projectType!=="",task:async(t,r)=>{try{O(),r.title="Workspace detected"}catch{let n=["Not in a workspace directory","",`Current directory: ${process.cwd()}`,"","This command must be run from within a workspace created with pf new workspace","","To create a new workspace, run:",""," pf new workspace my-platform"].join(`
249
+ `);throw new Error(n)}}},{enabled:t=>t.projectType==="workspace",task:async(t,r)=>{try{let n=O();if(!await r.prompt(R).run({type:"toggle",message:`\u26A0\uFE0F You are inside an existing workspace (${n}). Create a nested workspace anyway?`,enabled:"Yes",disabled:"No",initial:!1}))throw new Error("Workspace creation cancelled - already inside a workspace");r.title=ee.default.yellow("Warning: Creating nested workspace")}catch(n){if(n.message?.includes("cancelled"))throw n;r.title="No existing workspace detected"}}},{enabled:t=>!!t.projectType,task:async(t,r)=>{let s={"hono-micro":"services/my-hono-service","nest-micro":"services/my-nest-service",workspace:"my-platform"}[t.projectType]||"my-project",o=t.projectType==="workspace"?"\u{1F4E6} Workspace name:":"\u{1F4E6} Service path (e.g., services/my-service):",i=await r.prompt(R).run({type:"input",message:o,initial:s});t.servicePath=i.trim(),r.title=`Path: ${ee.default.dim(i)}`}},{enabled:t=>!!Cn.find(n=>n.value===t.projectType)?.supportsAi&&cr().valid,task:async(t,r)=>{let n=await r.prompt(R).run({type:"toggle",message:"Use AI to generate service code?",enabled:"Yes",disabled:"No",initial:!1});t.useAi=n,r.title=n?ee.default.cyan("\u{1F916} AI-powered generation"):"Standard scaffolding"}},{enabled:t=>t.useAi,task:async(t,r)=>{let n=await r.prompt(R).run({type:"input",message:"Describe what this service should do:"});t.aiDescription=n,r.title=`Description: ${ee.default.dim(n.slice(0,50))}${n.length>50?"...":""}`}},{enabled:t=>{if(!t.servicePath)return!1;let r=S(t.servicePath);return!es(r)},task:async(t,r)=>{if(!await r.prompt(R).run({type:"toggle",message:ee.default.bold("\u26A0\uFE0F Overwrite existing directory?"),enabled:"Yes",disabled:"No",initial:!1}))throw new Error("Project creation was canceled by the user.");t.shouldRemoveDir=!0,r.title=ee.default.yellow("Will overwrite existing directory")}},{title:"Confirm creation",enabled:t=>t.projectType!=="workspace",task:async(t,r)=>{if(!await r.prompt(R).run({type:"Toggle",initial:!0,message:"\u{1F680} Ready to launch your project?"}))throw new Error("Project creation was canceled by the user.")}}],actions:[],onComplete:async t=>{Cn.find(o=>o.value===t.projectType)||e.error(ee.default.red(`Project type ${t.projectType} is not supported.`));let r=e.commands.find(o=>o.name()===t.projectType),n={};t.projectType!=="workspace"&&(n.yes=!0);let s=[];t.servicePath&&s.push("servicePath"),t.shouldRemoveDir&&(n.removeDir=!0),t.useAi&&(n.ai=!0,n.description=t.aiDescription),await _p(r,t,n,s)}});for(let t of Cn)e.addCommand(t.command);return e};var vf=require("commander");var zs=b(require("chalk"));var Li=e=>new Promise(t=>setTimeout(t,e)),_i=e=>process.stdout.write(`${e}
250
+ `),Tw=()=>{process.stdout.write("\x1B[?1049l"),process.stdout.write("\x1B[2J"),process.stdout.write("\x1B[3J"),process.stdout.write("\x1B[H"),process.stdout.write("\x1B[?25h"),process.stdout.isTTY&&process.stdout.write("\x1Bc")},Cf=()=>({turboProcess:null,isRestarting:!1,isShuttingDown:!1}),bf=async(e,t)=>{let r=lu(".env.local",t);r.length>0&&(await hu(r),await Li(50)),_i(zs.default.cyan("\u{1F525} Starting services...")),_i(zs.default.dim(` Command: turbo run ${to} --continue`)),e.isShuttingDown=!1,e.isRestarting=!1,e.turboProcess=du("turbo",["run",to,"--continue","--no-daemon"],{cwd:t,envFile:".env.local",onExit:n=>{!e.isRestarting&&!e.isShuttingDown&&(_i(`
251
+ ${zs.default.red("Turbo exited with code")} ${n}`),process.exit(n??0))}})},Wi=async(e,t=!1)=>{let r=e.turboProcess?.pid;if(r){t?e.isRestarting=!0:e.isShuttingDown=!0;try{try{process.kill(-r,"SIGTERM")}catch{e.turboProcess?.kill("SIGTERM")}await Li(200);try{process.kill(-r,"SIGKILL")}catch{}await Li(30)}catch{}e.turboProcess=null,Tw()}};var Aw=300,xf=new vf.Command("dev").description("Start development mode with auto-reload").action(async()=>{let e=O(),t=Cf(),r=c=>tn("generate-env",{cwd:c}),n=()=>xt({cwd:e,quiet:!0}),s=async()=>{await n(),await r(e),await bf(t,e)},o=async()=>{if(!(t.isRestarting||t.isShuttingDown)){t.isRestarting=!0;try{await Wi(t,!0),await s()}catch{}finally{t.isRestarting=!1}}},i=(()=>{let c=null;return async()=>{t.isRestarting||t.isShuttingDown||(c&&clearTimeout(c),c=setTimeout(()=>o(),Aw))}})(),a=async()=>{await Wi(t,!1),process.exit(0)};await s(),_u(e,i),process.on("SIGINT",a),process.on("SIGTERM",a)});var _f=require("commander");var kf=require("node:fs"),Ef=require("node:path"),Gt=b(require("chalk")),Sf=require("commander");var Pw=e=>{if(e)try{return JSON.parse(e)}catch{return}},Rw=e=>{if(!e)return;let t={},r=e.split(",").map(n=>n.trim()).filter(Boolean);for(let n of r){let[s,o]=n.split(":").map(i=>i.trim());s&&o&&(t[s]=o)}return Object.keys(t).length>0?t:void 0},Iw=(e,t)=>{if(!t)return;let r=t.startsWith("/")?t:(0,Ef.resolve)(e,t);return(0,kf.existsSync)(r)?r:void 0},Nw=async(e,t)=>{let r=[],n=[],s=[];if(Jo(e)&&!t.force)n.push("Contract (already exists)");else{let i=Vo(e,t.schema);r.push(`Contract: ${i}`)}ni(e)&&r.push("Export: packages/contracts/src/index.ts");let o=await ms(e);if(o&&r.push(`Mock: ${o}`),t.servicePath){let i=Xo(e,t.servicePath);i?r.push(`Handler: ${i}`):n.push("Handler (already exists)");let a=Zo(t.servicePath,e);a.added?r.push(`Stream: ${a.streamName} added to index.ts`):a.warning&&s.push(a.warning)}return{created:r,skipped:n,warnings:s}},Ow=(e,t,r=[])=>{if(e.length>0){console.log(Gt.default.green(`\u2713 Created:
252
252
  `));for(let n of e)console.log(Gt.default.dim(` ${n}`))}if(t.length>0){console.log(Gt.default.yellow(`
253
253
  \u2139 Skipped:
254
254
  `));for(let n of t)console.log(Gt.default.dim(` ${n}`))}if(r.length>0){console.log(Gt.default.yellow(`
255
255
  \u26A0 Warning:
256
- `));for(let n of r)console.log(Gt.default.dim(` ${n}`))}},ji=async(e,t)=>{let r=O();if(!r){w.error("Not in a pf workspace. Run this command from your workspace root.");return}if(!e.includes(".")){w.error("Event type must include a namespace (e.g., orders.created)");return}let n=Fw(t.fields)||Sw(t.schema);if(t.schema&&!n&&!t.fields){w.error(`Invalid schema JSON. Example: '{"orderId":"string","total":"number"}'`);return}if(t.fields&&!n){w.error("Invalid fields format. Example: orderId:string,total:number");return}let s=Tw(r,t.service);if(t.service&&!s){w.error(`Service directory not found: ${t.service}`);return}console.log(Gt.default.cyan(`
256
+ `));for(let n of r)console.log(Gt.default.dim(` ${n}`))}},Gi=async(e,t)=>{let r=O();if(!r){w.error("Not in a pf workspace. Run this command from your workspace root.");return}if(!e.includes(".")){w.error("Event type must include a namespace (e.g., orders.created)");return}let n=Rw(t.fields)||Pw(t.schema);if(t.schema&&!n&&!t.fields){w.error(`Invalid schema JSON. Example: '{"orderId":"string","total":"number"}'`);return}if(t.fields&&!n){w.error("Invalid fields format. Example: orderId:string,total:number");return}let s=Iw(r,t.service);if(t.service&&!s){w.error(`Service directory not found: ${t.service}`);return}console.log(Gt.default.cyan(`
257
257
  \u{1F4E6} Adding event: ${e}
258
- `));let{created:o,skipped:i,warnings:a}=await Aw(e,{schema:n,servicePath:s,force:t.force});Pw(o,i,a),console.log(),t.service||(console.log(Gt.default.yellow(`\u{1F4A1} Tip: Use --service to also create an event handler:
258
+ `));let{created:o,skipped:i,warnings:a}=await Nw(e,{schema:n,servicePath:s,force:t.force});Ow(o,i,a),console.log(),t.service||(console.log(Gt.default.yellow(`\u{1F4A1} Tip: Use --service to also create an event handler:
259
259
  `)),console.log(Gt.default.dim(` pf event add ${e} --service services/my-service
260
- `)))},lT=new Ef.Command("event:add").description("Add event contract, handler, and mock").argument("<event-type>","Event type (e.g., orders.created)").option("-s, --service <path>","Service path to create handler in (e.g., services/orders)").option("-f, --fields <fields>","Schema fields (e.g., orderId:string,total:number,customerId:string)").option("--schema <json>",`Schema fields as JSON (e.g., '{"orderId":"string","total":"number"}')`).option("--force","Overwrite existing files",!1).action(ji);var Tf=require("commander");var Sf=require("fs-extra"),Ff=require("globby"),de=require("zod");var Rw=["**/node_modules/**","**/.nats-data/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**"],Iw=de.z.record(de.z.string()),Nw=de.z.object({description:de.z.string().optional(),eventName:de.z.string(),faker:Iw.optional(),data:de.z.record(de.z.any())}),br=(e=process.cwd())=>(0,Ff.globbySync)("**/*.mock.json",{cwd:e,absolute:!0,gitignore:!0,ignore:Rw}).map(r=>{try{let n=(0,Sf.readJSONSync)(r,{encoding:"utf8"}),s=Nw.safeParse(n);return s.success?{eventName:s.data.eventName,path:r,schema:s.data}:(w.warn(`\u26A0\uFE0F Invalid schema in ${r}`),console.log(s.error.format()),null)}catch{return w.warn(`\u26A0\uFE0F Failed to read or parse ${r}`),null}}).filter(r=>r!==null);var _i=null,Af=async()=>{if(!_i){let{faker:e}=await import("@faker-js/faker");_i=e}return _i},Li=async(e,t)=>{let r=await Af(),s=br().find(l=>l.eventName===e);if(!s){w.error(`Event "${e}" not found. Use "pf event list" to see available events.`);return}let o=s.schema,i=t.fake?await Ow(o):o.data,c={message:{data:Buffer.from(JSON.stringify({...i,type:o.eventName})).toString("base64"),messageId:r.string.uuid(),attributes:{source:"platform-sdk"}}};if(t.print){console.dir(c,{colors:!0});return}let u=await fetch(t.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!u.ok){let l=await u.text();throw new Error(`Request failed: ${u.status} \u2013 ${l}`)}w.success("Event sent successfully.")},gT=new Tf.Command("event:http").description("Send via HTTP Pub/Sub endpoint").argument("<eventName>","The name of the event").option("--endpoint <url>","Target HTTP endpoint","http://localhost:3000").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated Pub/Sub event without sending").action(Li),Ow=async e=>{let t=structuredClone(e.data);return e.faker&&await Promise.all(Object.entries(e.faker).map(async([r,n])=>{let s=await Mw(n);Cn(t,r,s)})),t},Mw=async e=>{let t=await Af();switch(e){case"uuid":return t.string.uuid();case"email":return t.internet.email();case"string":return t.lorem.word();case"number":return t.number.int();case"boolean":return t.datatype.boolean();case"date":return new Date().toISOString();case"productName":return t.commerce.productName();case"productDescription":return t.commerce.productDescription();case"firstName":return t.person.firstName();case"lastName":return t.person.lastName();case"url":return t.internet.url();case"phoneNumber":return t.phone.number();case"streetAddress":return t.location.streetAddress();case"city":return t.location.city();case"state":return t.location.state();case"country":return t.location.country();case"companyName":return t.company.name();case"zipCode":return t.location.zipCode();case"password":return t.internet.password();default:return null}};var Nf=b(ki()),Of=require("commander");var Wi=require("node:fs"),Pf=require("node:path"),Gi=require("globby");var $w=["**/node_modules/**","**/.nats-data/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**"],Bw=e=>{let t=e.split("/"),r=t.findIndex(n=>n==="services");return r!==-1&&r+1<t.length?t[r+1]:"unknown"},jw=(e,t)=>{try{let{eventsPath:r}=G(t),s=(0,Gi.globbySync)("**/*.ts",{cwd:r,absolute:!0}).map(i=>({file:i,content:(0,Wi.readFileSync)(i,"utf-8")})).find(({content:i})=>i.includes(`export const ${e}`));if(!s)return null;let o=s.content.match(/type:\s*['"]([^'"]+)['"]/);return o?o[1]:null}catch{return null}},_w=e=>e.replace(/Contract$/,"").replace(/([A-Z])/g,(t,r,n)=>(n>0?".":"")+r.toLowerCase()),Lw=(e,t)=>{let r=e.match(/handleEvent\s*\(\s*\{\s*[^}]*type:\s*['"]([^'"]+)['"]/s);if(r)return r[1];let n=e.match(/handleEvent\s*\(\s*['"]([^'"]+)['"]/s);if(n)return n[1];let s=e.match(/import\s+(?:type\s+)?{[^}]*?(\w+Contract)[^}]*?}\s+from/);if(!s)return null;let o=s[1];return jw(o,t)||_w(o)},Ww=(e,t)=>{try{let r=(0,Wi.readFileSync)(e,"utf-8"),n=Lw(r,t);return n?{serviceName:Bw(e),handlerPath:(0,Pf.relative)(t,e),eventType:n}:null}catch{return null}},Rf=(e=process.cwd())=>(0,Gi.globbySync)("services/**/src/events/*.event.ts",{cwd:e,absolute:!0,gitignore:!0,ignore:$w}).map(r=>Ww(r,e)).filter(r=>r!==null),If=e=>e.reduce((t,r)=>{let n=t.get(r.eventType)||[];return t.set(r.eventType,[...n,r]),t},new Map);var Gw=(e,t)=>{let r=t.get(e)||[],n=[...new Set(r.map(s=>s.serviceName))];return n.length>0?n.join(", "):"-"},Hi=()=>{let e=br();if(e.length===0){w.error("No event schemas found.");return}let t=Rf(),r=If(t),n=new Nf.default({head:["name","description","consumers"],style:{head:["dim","bold"],compact:!0}});for(let{eventName:s,schema:o}of e)n.push([s,o.description||"-",Gw(s,r)]);console.log(n.toString())},xT=new Of.Command("event:list").description("List all available event mocks").action(Hi);var Mf=require("node:path"),$f=require("commander");var Kw={},Ui=null,zi=null,Bf=async()=>{if(!Ui){let{faker:e}=await import("@faker-js/faker");Ui=e}return Ui},Hw=async()=>{if(!zi)try{let{createJiti:e}=await import("jiti"),t=e(Kw.url),r=O(),n=G(r),s=(0,Mf.join)(n.packagePath,"node_modules","@crossdelta","cloudevents");zi=(await t.import(s)).publish}catch{throw new Error(`@crossdelta/cloudevents is required for event:publish.
261
- Install it in your contracts package with: cd packages/contracts && bun add @crossdelta/cloudevents`)}return zi},Ki=async(e,t)=>{let r=await Bf(),s=br().find(a=>a.eventName===e||a.path.includes(`${e}.mock.json`));if(!s){w.error(`Event "${e}" not found. Use "pf event list" to see available events.`);return}let o=s.schema,i=t.fake?await Uw(o):o.data;if(t.print){console.log(`
262
- \u{1F4E6} Event Type:`,o.eventName),console.log("\u{1F4C4} Payload:"),console.dir(i,{colors:!0,depth:null});return}try{let a=await Hw();if(!a)throw new Error("Failed to load publish function from cloudevents");await a(o.eventName,i,{source:"platform-sdk-cli",subject:r.string.uuid()}),w.success(`Event "${o.eventName}" published successfully to NATS JetStream.`),await new Promise(c=>setTimeout(c,100)),process.exit(0)}catch(a){w.error(`Failed to publish event: ${a instanceof Error?a.message:String(a)}`),w.info("Make sure NATS is running and NATS_URL is configured."),process.exit(1)}},TT=new $f.Command("event:publish").description("Publish to NATS JetStream").argument("<eventName>","The name of the event (e.g., order-created)").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated event data without publishing").action(Ki),Uw=async e=>{let t=structuredClone(e.data);return e.faker&&await Promise.all(Object.entries(e.faker).map(async([r,n])=>{let s=await zw(n);Cn(t,r,s)})),t},zw=async e=>{let t=await Bf();switch(e.toLowerCase()){case"uuid":return t.string.uuid();case"email":return t.internet.email();case"firstname":return t.person.firstName();case"lastname":return t.person.lastName();case"name":return t.person.fullName();case"url":return t.internet.url();case"phone":return t.phone.number();case"date":return t.date.recent().toISOString();case"boolean":return t.datatype.boolean();case"number":return t.number.int({min:1,max:1e3});case"string":return t.lorem.word();case"text":return t.lorem.sentence();default:return e}};var gn=new jf.Command("event").description("Event management commands");gn.command("add").description("Add event contract, handler, and mock").argument("<event-type>","Event type (e.g., orders.created)").option("-s, --service <path>","Service path to create handler in (e.g., services/orders)").option("--schema <fields>",`Schema fields as JSON (e.g., '{"orderId":"string","total":"number"}')`).option("--force","Overwrite existing files",!1).action(ji);gn.command("list").description("List all available event mocks").action(Hi);gn.command("publish").description("Publish to NATS JetStream").argument("<eventName>","Event name to publish").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated event data without publishing").action(Ki);gn.command("http").description("Send via HTTP Pub/Sub endpoint").argument("<eventName>","Event name to send").option("--endpoint <url>","Target HTTP endpoint","http://localhost:3000").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated Pub/Sub event without sending").action(Li);var _f=gn;var qi=b(require("chalk")),Uf=require("commander");var vr=require("node:fs"),Vi=b(require("node:path")),Ws=b(require("chalk")),Lf=require("commander"),Wf=b(require("os"));var{name:Jw,publishConfig:Vw}=xt,qw=Vw?.registry,Yw=Jw?.split("/")[0],BT=new Lf.Command("token:set").description(Ws.default.bold("Set a registry auth token in a .npmrc file")).argument("<token>","Authentication token (e.g. GitHub or npm token)").option("--scope <scope>","Package scope (e.g. @my-workspace)",Yw).option("--registry <registry>","Registry URL",qw).option("--local","Write token to a local .npmrc in the current directory",!1).option("--force","Force overwrite existing token if already present",!1).action((e,t)=>Gf(e,t.scope||"",t.registry||"",t.local,t.force)).addHelpText("after",()=>`${Ws.default.cyan(`
260
+ `)))},DT=new Sf.Command("event:add").description("Add event contract, handler, and mock").argument("<event-type>","Event type (e.g., orders.created)").option("-s, --service <path>","Service path to create handler in (e.g., services/orders)").option("-f, --fields <fields>","Schema fields (e.g., orderId:string,total:number,customerId:string)").option("--schema <json>",`Schema fields as JSON (e.g., '{"orderId":"string","total":"number"}')`).option("--force","Overwrite existing files",!1).action(Gi);var Af=require("commander");var Ff=require("fs-extra"),Tf=require("globby"),he=require("zod");var Mw=["**/node_modules/**","**/.nats-data/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**"],$w=he.z.record(he.z.string()),Bw=he.z.object({description:he.z.string().optional(),eventName:he.z.string(),faker:$w.optional(),data:he.z.record(he.z.any())}),kr=(e=process.cwd())=>(0,Tf.globbySync)("**/*.mock.json",{cwd:e,absolute:!0,gitignore:!0,ignore:Mw}).map(r=>{try{let n=(0,Ff.readJSONSync)(r,{encoding:"utf8"}),s=Bw.safeParse(n);return s.success?{eventName:s.data.eventName,path:r,schema:s.data}:(w.warn(`\u26A0\uFE0F Invalid schema in ${r}`),console.log(s.error.format()),null)}catch{return w.warn(`\u26A0\uFE0F Failed to read or parse ${r}`),null}}).filter(r=>r!==null);var Hi=null,Pf=async()=>{if(!Hi){let{faker:e}=await import("@faker-js/faker");Hi=e}return Hi},Ui=async(e,t)=>{let r=await Pf(),s=kr().find(l=>l.eventName===e);if(!s){w.error(`Event "${e}" not found. Use "pf event list" to see available events.`);return}let o=s.schema,i=t.fake?await jw(o):o.data,c={message:{data:Buffer.from(JSON.stringify({...i,type:o.eventName})).toString("base64"),messageId:r.string.uuid(),attributes:{source:"platform-sdk"}}};if(t.print){console.dir(c,{colors:!0});return}let u=await fetch(t.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!u.ok){let l=await u.text();throw new Error(`Request failed: ${u.status} \u2013 ${l}`)}w.success("Event sent successfully.")},xT=new Af.Command("event:http").description("Send via HTTP Pub/Sub endpoint").argument("<eventName>","The name of the event").option("--endpoint <url>","Target HTTP endpoint","http://localhost:3000").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated Pub/Sub event without sending").action(Ui),jw=async e=>{let t=structuredClone(e.data);return e.faker&&await Promise.all(Object.entries(e.faker).map(async([r,n])=>{let s=await _w(n);En(t,r,s)})),t},_w=async e=>{let t=await Pf();switch(e){case"uuid":return t.string.uuid();case"email":return t.internet.email();case"string":return t.lorem.word();case"number":return t.number.int();case"boolean":return t.datatype.boolean();case"date":return new Date().toISOString();case"productName":return t.commerce.productName();case"productDescription":return t.commerce.productDescription();case"firstName":return t.person.firstName();case"lastName":return t.person.lastName();case"url":return t.internet.url();case"phoneNumber":return t.phone.number();case"streetAddress":return t.location.streetAddress();case"city":return t.location.city();case"state":return t.location.state();case"country":return t.location.country();case"companyName":return t.company.name();case"zipCode":return t.location.zipCode();case"password":return t.internet.password();default:return null}};var Of=b(Ai()),Mf=require("commander");var zi=require("node:fs"),Rf=require("node:path"),Ki=require("globby");var Lw=["**/node_modules/**","**/.nats-data/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**"],Ww=e=>{let t=e.split("/"),r=t.findIndex(n=>n==="services");return r!==-1&&r+1<t.length?t[r+1]:"unknown"},Gw=(e,t)=>{try{let{eventsPath:r}=G(t),s=(0,Ki.globbySync)("**/*.ts",{cwd:r,absolute:!0}).map(i=>({file:i,content:(0,zi.readFileSync)(i,"utf-8")})).find(({content:i})=>i.includes(`export const ${e}`));if(!s)return null;let o=s.content.match(/type:\s*['"]([^'"]+)['"]/);return o?o[1]:null}catch{return null}},Hw=e=>e.replace(/Contract$/,"").replace(/([A-Z])/g,(t,r,n)=>(n>0?".":"")+r.toLowerCase()),Uw=(e,t)=>{let r=e.match(/handleEvent\s*\(\s*\{\s*[^}]*type:\s*['"]([^'"]+)['"]/s);if(r)return r[1];let n=e.match(/handleEvent\s*\(\s*['"]([^'"]+)['"]/s);if(n)return n[1];let s=e.match(/import\s+(?:type\s+)?{[^}]*?(\w+Contract)[^}]*?}\s+from/);if(!s)return null;let o=s[1];return Gw(o,t)||Hw(o)},zw=(e,t)=>{try{let r=(0,zi.readFileSync)(e,"utf-8"),n=Uw(r,t);return n?{serviceName:Ww(e),handlerPath:(0,Rf.relative)(t,e),eventType:n}:null}catch{return null}},If=(e=process.cwd())=>(0,Ki.globbySync)("services/**/src/events/*.event.ts",{cwd:e,absolute:!0,gitignore:!0,ignore:Lw}).map(r=>zw(r,e)).filter(r=>r!==null),Nf=e=>e.reduce((t,r)=>{let n=t.get(r.eventType)||[];return t.set(r.eventType,[...n,r]),t},new Map);var Kw=(e,t)=>{let r=t.get(e)||[],n=[...new Set(r.map(s=>s.serviceName))];return n.length>0?n.join(", "):"-"},Ji=()=>{let e=kr();if(e.length===0){w.error("No event schemas found.");return}let t=If(),r=Nf(t),n=new Of.default({head:["name","description","consumers"],style:{head:["dim","bold"],compact:!0}});for(let{eventName:s,schema:o}of e)n.push([s,o.description||"-",Kw(s,r)]);console.log(n.toString())},PT=new Mf.Command("event:list").description("List all available event mocks").action(Ji);var $f=require("node:path"),Bf=require("commander");var Yw={},Vi=null,qi=null,jf=async()=>{if(!Vi){let{faker:e}=await import("@faker-js/faker");Vi=e}return Vi},Jw=async()=>{if(!qi)try{let{createJiti:e}=await import("jiti"),t=e(Yw.url),r=O(),n=G(r),s=(0,$f.join)(n.packagePath,"node_modules","@crossdelta","cloudevents");qi=(await t.import(s)).publish}catch{throw new Error(`@crossdelta/cloudevents is required for event:publish.
261
+ Install it in your contracts package with: cd packages/contracts && bun add @crossdelta/cloudevents`)}return qi},Yi=async(e,t)=>{let r=await jf(),s=kr().find(a=>a.eventName===e||a.path.includes(`${e}.mock.json`));if(!s){w.error(`Event "${e}" not found. Use "pf event list" to see available events.`);return}let o=s.schema,i=t.fake?await Vw(o):o.data;if(t.print){console.log(`
262
+ \u{1F4E6} Event Type:`,o.eventName),console.log("\u{1F4C4} Payload:"),console.dir(i,{colors:!0,depth:null});return}try{let a=await Jw();if(!a)throw new Error("Failed to load publish function from cloudevents");await a(o.eventName,i,{source:"platform-sdk-cli",subject:r.string.uuid()}),w.success(`Event "${o.eventName}" published successfully to NATS JetStream.`),await new Promise(c=>setTimeout(c,100)),process.exit(0)}catch(a){w.error(`Failed to publish event: ${a instanceof Error?a.message:String(a)}`),w.info("Make sure NATS is running and NATS_URL is configured."),process.exit(1)}},MT=new Bf.Command("event:publish").description("Publish to NATS JetStream").argument("<eventName>","The name of the event (e.g., order-created)").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated event data without publishing").action(Yi),Vw=async e=>{let t=structuredClone(e.data);return e.faker&&await Promise.all(Object.entries(e.faker).map(async([r,n])=>{let s=await qw(n);En(t,r,s)})),t},qw=async e=>{let t=await jf();switch(e.toLowerCase()){case"uuid":return t.string.uuid();case"email":return t.internet.email();case"firstname":return t.person.firstName();case"lastname":return t.person.lastName();case"name":return t.person.fullName();case"url":return t.internet.url();case"phone":return t.phone.number();case"date":return t.date.recent().toISOString();case"boolean":return t.datatype.boolean();case"number":return t.number.int({min:1,max:1e3});case"string":return t.lorem.word();case"text":return t.lorem.sentence();default:return e}};var bn=new _f.Command("event").description("Event management commands");bn.command("add").description("Add event contract, handler, and mock").argument("<event-type>","Event type (e.g., orders.created)").option("-s, --service <path>","Service path to create handler in (e.g., services/orders)").option("--schema <fields>",`Schema fields as JSON (e.g., '{"orderId":"string","total":"number"}')`).option("--force","Overwrite existing files",!1).action(Gi);bn.command("list").description("List all available event mocks").action(Ji);bn.command("publish").description("Publish to NATS JetStream").argument("<eventName>","Event name to publish").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated event data without publishing").action(Yi);bn.command("http").description("Send via HTTP Pub/Sub endpoint").argument("<eventName>","Event name to send").option("--endpoint <url>","Target HTTP endpoint","http://localhost:3000").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated Pub/Sub event without sending").action(Ui);var Lf=bn;var Qi=b(require("chalk")),zf=require("commander");var Er=require("node:fs"),Xi=b(require("node:path")),Ks=b(require("chalk")),Wf=require("commander"),Gf=b(require("os"));var{name:Zw,publishConfig:Xw}=Ot,Qw=Xw?.registry,tC=Zw?.split("/")[0],UT=new Wf.Command("token:set").description(Ks.default.bold("Set a registry auth token in a .npmrc file")).argument("<token>","Authentication token (e.g. GitHub or npm token)").option("--scope <scope>","Package scope (e.g. @my-workspace)",tC).option("--registry <registry>","Registry URL",Qw).option("--local","Write token to a local .npmrc in the current directory",!1).option("--force","Force overwrite existing token if already present",!1).action((e,t)=>Hf(e,t.scope||"",t.registry||"",t.local,t.force)).addHelpText("after",()=>`${Ks.default.cyan(`
263
263
  Example:`)}
264
- ${Ws.default.bold("pf token set <token> --scope @my-workspace --registry https://npm.pkg.github.com")}
265
- `),Zw=e=>e?Vi.default.join(process.cwd(),".npmrc"):Vi.default.join(Wf.default.homedir(),".npmrc"),Xw=(e,t,r)=>{let n=new URL(r).host;return t?`${t}:registry=https://${n}
266
- //${n}/:_authToken=${e}`:`//${n}/:_authToken=${e}`},Qw=e=>(0,vr.existsSync)(e)?(0,vr.readFileSync)(e,"utf8"):"",Ji=(e,t)=>(0,vr.writeFileSync)(e,t),Gf=(e,t,r,n=!1,s=!1)=>{let o=Zw(n),i=Xw(e,t,r),a=new URL(r).host,c=Qw(o),u=new RegExp(`//${a}/:_authToken=\\S+`);if(!c){Ji(o,`${i}
267
- `),w.success(`Created new .npmrc and set token for ${a}`);return}if(u.test(c)){if(!s){w.warn(`Token for ${a} already exists in ${o}. Use --force to overwrite.`);return}c=c.replace(u,i),Ji(o,c),w.success(`Overwrote existing token for ${a} in ${o}`);return}c+=`
264
+ ${Ks.default.bold("pf token set <token> --scope @my-workspace --registry https://npm.pkg.github.com")}
265
+ `),eC=e=>e?Xi.default.join(process.cwd(),".npmrc"):Xi.default.join(Gf.default.homedir(),".npmrc"),rC=(e,t,r)=>{let n=new URL(r).host;return t?`${t}:registry=https://${n}
266
+ //${n}/:_authToken=${e}`:`//${n}/:_authToken=${e}`},nC=e=>(0,Er.existsSync)(e)?(0,Er.readFileSync)(e,"utf8"):"",Zi=(e,t)=>(0,Er.writeFileSync)(e,t),Hf=(e,t,r,n=!1,s=!1)=>{let o=eC(n),i=rC(e,t,r),a=new URL(r).host,c=nC(o),u=new RegExp(`//${a}/:_authToken=\\S+`);if(!c){Zi(o,`${i}
267
+ `),w.success(`Created new .npmrc and set token for ${a}`);return}if(u.test(c)){if(!s){w.warn(`Token for ${a} already exists in ${o}. Use --force to overwrite.`);return}c=c.replace(u,i),Zi(o,c),w.success(`Overwrote existing token for ${a} in ${o}`);return}c+=`
268
268
  ${i}
269
- `,Ji(o,c),w.success(`Appended token for ${a} to ${o}`)},Hf=(e,t)=>Gf(e,t.scope||"",t.registry||"",t.local,t.force);var{name:tC,publishConfig:eC}=xt,rC=eC?.registry,nC=tC?.split("/")[0],zf=new Uf.Command("token").description("Token management commands");zf.command("set").description("Set a registry auth token in a .npmrc file").argument("<token>","Authentication token (e.g. GitHub or npm token)").option("--scope <scope>","Package scope (e.g. @my-workspace)",nC).option("--registry <registry>","Registry URL",rC).option("--local","Write token to a local .npmrc in the current directory",!1).option("--force","Force overwrite existing token if already present",!1).action(Hf).addHelpText("after",()=>`${qi.default.cyan(`
269
+ `,Zi(o,c),w.success(`Appended token for ${a} to ${o}`)},Uf=(e,t)=>Hf(e,t.scope||"",t.registry||"",t.local,t.force);var{name:sC,publishConfig:oC}=Ot,iC=oC?.registry,aC=sC?.split("/")[0],Kf=new zf.Command("token").description("Token management commands");Kf.command("set").description("Set a registry auth token in a .npmrc file").argument("<token>","Authentication token (e.g. GitHub or npm token)").option("--scope <scope>","Package scope (e.g. @my-workspace)",aC).option("--registry <registry>","Registry URL",iC).option("--local","Write token to a local .npmrc in the current directory",!1).option("--force","Force overwrite existing token if already present",!1).action(Uf).addHelpText("after",()=>`${Qi.default.cyan(`
270
270
  Example:`)}
271
- ${qi.default.bold("pf token set <token> --scope @my-workspace --registry https://npm.pkg.github.com")}
272
- `);var Kf=zf;var Ht=require("@inquirer/prompts"),N=b(require("chalk")),Vf=require("commander");var sC=[/embed/i,/whisper/i,/tts/i,/dall-e/i,/davinci/i,/babbage/i,/curie/i,/ada(?!-)/i,/moderation/i,/realtime/i,/audio/i,/transcription/i,/search/i],oC=async(e,t,r=1e4)=>{let n=new AbortController,s=setTimeout(()=>n.abort(),r);try{return await fetch(e,{...t,signal:n.signal})}finally{clearTimeout(s)}},iC=e=>e.replace(/-(\d{8})$/," ($1)").replace(/^claude-/,"Claude ").replace(/^gpt-/,"GPT-").replace(/-/g," ").replace(/(\d)\.(\d)/g,"$1.$2").replace(/\s+/g," ").split(" ").map(t=>/^\d/.test(t)||/^\(\d+\)$/.test(t)?t:t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ").trim(),aC=async(e,t)=>{let r=Xr(e),n=await oC(r.modelsApiUrl,{headers:r.buildHeaders(t)});if(!n.ok)throw new Error(`${r.name} API error: ${n.status}`);let s=await n.json(),o=r.parseModelsResponse(s);if(!Array.isArray(o)||o.length===0)throw new Error(`No models returned from ${r.name} API`);let i=o.filter(a=>{let c=r.modelFilters.some(l=>l.test(a.id)),u=sC.some(l=>l.test(a.id));return c&&!u}).sort((a,c)=>{let u=typeof a.created=="number"?a.created:new Date(a.created).getTime();return(typeof c.created=="number"?c.created:new Date(c.created).getTime())-u}).map(a=>({name:iC(a.id),value:a.id}));if(i.length===0)throw new Error(`No chat models found from ${r.name} API`);return i};async function Jf(e,t){if(!t)throw new Error("API key is required to fetch available models");return{models:await aC(e,t),fromApi:!0}}function cC(){if(!Qr())return null;try{let e=ss();return console.log(N.default.dim(`Found existing configuration at ${ve}
271
+ ${Qi.default.bold("pf token set <token> --scope @my-workspace --registry https://npm.pkg.github.com")}
272
+ `);var Jf=Kf;var Ht=require("@inquirer/prompts"),N=b(require("chalk")),qf=require("commander");var cC=[/embed/i,/whisper/i,/tts/i,/dall-e/i,/davinci/i,/babbage/i,/curie/i,/ada(?!-)/i,/moderation/i,/realtime/i,/audio/i,/transcription/i,/search/i],uC=async(e,t,r=1e4)=>{let n=new AbortController,s=setTimeout(()=>n.abort(),r);try{return await fetch(e,{...t,signal:n.signal})}finally{clearTimeout(s)}},lC=e=>e.replace(/-(\d{8})$/," ($1)").replace(/^claude-/,"Claude ").replace(/^gpt-/,"GPT-").replace(/-/g," ").replace(/(\d)\.(\d)/g,"$1.$2").replace(/\s+/g," ").split(" ").map(t=>/^\d/.test(t)||/^\(\d+\)$/.test(t)?t:t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ").trim(),pC=async(e,t)=>{let r=rn(e),n=await uC(r.modelsApiUrl,{headers:r.buildHeaders(t)});if(!n.ok)throw new Error(`${r.name} API error: ${n.status}`);let s=await n.json(),o=r.parseModelsResponse(s);if(!Array.isArray(o)||o.length===0)throw new Error(`No models returned from ${r.name} API`);let i=o.filter(a=>{let c=r.modelFilters.some(l=>l.test(a.id)),u=cC.some(l=>l.test(a.id));return c&&!u}).sort((a,c)=>{let u=typeof a.created=="number"?a.created:new Date(a.created).getTime();return(typeof c.created=="number"?c.created:new Date(c.created).getTime())-u}).map(a=>({name:lC(a.id),value:a.id}));if(i.length===0)throw new Error(`No chat models found from ${r.name} API`);return i};async function Vf(e,t){if(!t)throw new Error("API key is required to fetch available models");return{models:await pC(e,t),fromApi:!0}}function fC(){if(!nn())return null;try{let e=us();return console.log(N.default.dim(`Found existing configuration at ${xe}
273
273
  `)),e}catch{return console.log(N.default.yellow(`Found corrupted configuration, starting fresh.
274
- `)),null}}async function uC(e,t){return console.log(N.default.dim(`
274
+ `)),null}}async function dC(e,t){return console.log(N.default.dim(`
275
275
  \u{1F4CB} Get your ${e} API key here:`)),console.log(N.default.cyan(` ${t}
276
- `)),(0,Ht.password)({message:`Enter your ${e} API key:`,mask:"*",validate:r=>r.trim()?r.length<10?"API key seems too short":!0:"API key cannot be empty"})}async function lC(e,t,r){let n=await(0,Ht.select)({message:"Select model:",choices:e,default:t?.provider===r?t.model:void 0});return await(0,Ht.confirm)({message:"Enter a custom model ID instead?",default:!1})?(0,Ht.input)({message:"Enter custom model ID:",default:n,validate:o=>o.trim()?!0:"Model ID cannot be empty"}):n}function qf(e){return e.length<=12?"****":`${e.slice(0,4)}...${e.slice(-4)}`}function pC(e,t){console.log(N.default.green.bold(`
276
+ `)),(0,Ht.password)({message:`Enter your ${e} API key:`,mask:"*",validate:r=>r.trim()?r.length<10?"API key seems too short":!0:"API key cannot be empty"})}async function hC(e,t,r){let n=await(0,Ht.select)({message:"Select model:",choices:e,default:t?.provider===r?t.model:void 0});return await(0,Ht.confirm)({message:"Enter a custom model ID instead?",default:!1})?(0,Ht.input)({message:"Enter custom model ID:",default:n,validate:o=>o.trim()?!0:"Model ID cannot be empty"}):n}function Yf(e){return e.length<=12?"****":`${e.slice(0,4)}...${e.slice(-4)}`}function mC(e,t){console.log(N.default.green.bold(`
277
277
  \u2705 AI configuration saved successfully!
278
- `)),console.log(N.default.dim(`Configuration file: ${ve}`)),console.log(N.default.dim("API Key: Stored securely in system keychain")),console.log(N.default.dim(`Provider: ${e.provider}`)),console.log(N.default.dim(`Model: ${e.model}`)),console.log(N.default.dim(`API Key: ${qf(t)}
278
+ `)),console.log(N.default.dim(`Configuration file: ${xe}`)),console.log(N.default.dim("API Key: Stored securely in system keychain")),console.log(N.default.dim(`Provider: ${e.provider}`)),console.log(N.default.dim(`Model: ${e.model}`)),console.log(N.default.dim(`API Key: ${Yf(t)}
279
279
  `)),console.log(N.default.cyan("You can now use AI-powered service generation:")),console.log(N.default.dim(` pf new hono-micro services/my-service --ai
280
- `))}async function fC(e){let t=await ns(e);if(t)return t;let r=Xr(e);return process.env[r.defaultApiKeyEnvVar]??null}async function dC(){console.log(N.default.cyan.bold(`
280
+ `))}async function gC(e){let t=await cs(e);if(t)return t;let r=rn(e);return process.env[r.defaultApiKeyEnvVar]??null}async function DC(){console.log(N.default.cyan.bold(`
281
281
  \u{1F916} AI Configuration Setup
282
- `));let e=cC();try{let t=await(0,Ht.select)({message:"Select AI provider:",choices:Tu(),default:e?.provider??Wo.provider}),r=Xr(t),n,s=await fC(t);s&&(console.log(N.default.green(`
283
- \u2713 Found existing API key: ${qf(s)}`)),await(0,Ht.confirm)({message:"Use this existing API key?",default:!0})&&(n=s)),n||(n=await uC(r.name,r.apiKeyUrl)),console.log(N.default.dim(`
284
- Fetching available models...`));let o;try{o=(await Jf(t,n)).models,console.log(N.default.green(`\u2713 Loaded ${o.length} models from ${r.name} API
282
+ `));let e=fC();try{let t=await(0,Ht.select)({message:"Select AI provider:",choices:Iu(),default:e?.provider??Ko.provider}),r=rn(t),n,s=await gC(t);s&&(console.log(N.default.green(`
283
+ \u2713 Found existing API key: ${Yf(s)}`)),await(0,Ht.confirm)({message:"Use this existing API key?",default:!0})&&(n=s)),n||(n=await dC(r.name,r.apiKeyUrl)),console.log(N.default.dim(`
284
+ Fetching available models...`));let o;try{o=(await Vf(t,n)).models,console.log(N.default.green(`\u2713 Loaded ${o.length} models from ${r.name} API
285
285
  `))}catch(c){console.error(N.default.red(`
286
286
  \u274C Failed to fetch models: ${c.message}`)),console.log(N.default.yellow(`
287
287
  Please check your API key and try again.
288
- `)),process.exit(1)}let i=await lC(o,e,t),a={provider:t,model:i.trim()};Ru(a),await Iu(t,n),pC(a,n)}catch(t){throw t.name==="ExitPromptError"&&(console.log(N.default.yellow(`
288
+ `)),process.exit(1)}let i=await hC(o,e,t),a={provider:t,model:i.trim()};Mu(a),await $u(t,n),mC(a,n)}catch(t){throw t.name==="ExitPromptError"&&(console.log(N.default.yellow(`
289
289
  Setup cancelled.
290
- `)),process.exit(0)),t}}var Yi=new Vf.Command("setup").description("Configure platform settings").option("--ai","Configure AI provider and API key for code generation").addHelpText("after",`
290
+ `)),process.exit(0)),t}}var ta=new qf.Command("setup").description("Configure platform settings").option("--ai","Configure AI provider and API key for code generation").addHelpText("after",`
291
291
  Examples:
292
292
  # Configure AI provider (OpenAI, Anthropic)
293
293
  $ pf setup --ai
294
- `).action(async e=>{if(e.ai){await dC();return}console.log(N.default.cyan.bold(`
294
+ `).action(async e=>{if(e.ai){await DC();return}console.log(N.default.cyan.bold(`
295
295
  \u2699\uFE0F Platform Setup
296
296
  `)),console.log(`Available setup options:
297
- `),console.log(N.default.dim(" --ai Configure AI provider for code generation")),console.log(),console.log(N.default.dim("Example: pf setup --ai")),console.log()});var Yf=require("node:fs"),Zf=require("node:path"),xr=b(require("chalk"));var hC=(e,t)=>t.some(r=>r.name()===e),mC=(e,t)=>t.pf?.commands?.[e]??null,gC=(e,t)=>!!t.scripts?.[e],DC=(e,t)=>t.cwd?(0,Zf.join)(e,t.cwd):e,yC=(e,t)=>t.command||e,wC=(e,t,r,n)=>{let s=DC(n,r),o=yC(e,r);if(r.cwd&&!(0,Yf.existsSync)(s))return console.error(xr.default.red(`
297
+ `),console.log(N.default.dim(" --ai Configure AI provider for code generation")),console.log(),console.log(N.default.dim("Example: pf setup --ai")),console.log()});var Zf=require("node:fs"),Xf=require("node:path"),Sr=b(require("chalk"));var yC=(e,t)=>t.some(r=>r.name()===e),wC=(e,t)=>t.pf?.commands?.[e]??null,CC=(e,t)=>!!t.scripts?.[e],bC=(e,t)=>t.cwd?(0,Xf.join)(e,t.cwd):e,vC=(e,t)=>t.command||e,xC=(e,t,r,n)=>{let s=bC(n,r),o=vC(e,r);if(r.cwd&&!(0,Zf.existsSync)(s))return console.error(Sr.default.red(`
298
298
  \u2716 Directory not found: ${s}
299
- `)),!0;let i=r.cwd?xr.default.dim(` in ${r.cwd}/`):"";return console.log(xr.default.dim(`Running ${o}${i}`)),es(o,t,{cwd:s}),!0},CC=(e,t,r)=>(console.log(xr.default.dim(`Running workspace script: ${e}`)),Yr(e,{args:t,cwd:r}),!0);async function bC(e,t,r){if(hC(e,r))return!1;let n;try{n=O()}catch{return!1}let s=Ye(n);if(!s)return!1;let o=mC(e,s);return o?wC(e,t,o,n):gC(e,s)?CC(e,t,n):!1}function vC(){let e;try{e=Ye()}catch{return{configured:[],scripts:[]}}if(!e)return{configured:[],scripts:[]};let t=Object.keys(e.pf?.commands??{}),n=Object.keys(e.scripts??{}).filter(s=>!t.includes(s));return{configured:t,scripts:n}}function Xf(){let{configured:e,scripts:t}=vC(),r=[...e,...t];return r.length===0?"":[`
300
- Workspace Commands:`,...r.map(n=>xr.default.cyan(` ${n}`))].join(`
301
- `)}function Qf(e,t,r){let n=t.slice(2);if(n.length>0&&!n[0].startsWith("-")){let s=n[0],o=n.slice(1);bC(s,o,r).then(i=>{i||e.parse(t)})}else e.parse(t)}process.on("SIGINT",()=>{process.exit(0)});process.on("unhandledRejection",e=>{throw(e.name==="ExitPromptError"||e.message?.includes("ERR_USE_AFTER_CLOSE")||e.message?.includes("Cancelled prompt"))&&process.exit(0),e});process.on("uncaughtException",e=>{(e.name==="ExitPromptError"||e.message?.includes("ERR_USE_AFTER_CLOSE")||e.message?.includes("Cancelled prompt"))&&process.exit(0),(e.message?.includes("Not in a workspace directory")||e.message?.includes("Could not locate workspace root"))&&(console.error(e.message),process.exit(1)),console.error(Ee.default.red(`
302
- \u2716 An unexpected error occurred:`)),console.error(e),process.exit(1)});var Gs=new id.Command,td=Object.keys(xt.bin||{}),[ad="pf",Zi]=td.length>0?td:["pf"],{description:ed,version:xC,repository:rd,homepage:kC}=xt,nd=ed?.split(/ —|,|\./)[0]||ed||"Platform CLI",cd=rd?.url?`https://${rd.url.replace(/^(git\+|git@)/,"").replace(/\.git$/,"").replace(":","/")}`:null,sd=cd||kC,EC=cd?"GitHub":"README",SC=sd?[Ee.default.bold(nd),`
299
+ `)),!0;let i=r.cwd?Sr.default.dim(` in ${r.cwd}/`):"";return console.log(Sr.default.dim(`Running ${o}${i}`)),is(o,t,{cwd:s}),!0},kC=(e,t,r)=>(console.log(Sr.default.dim(`Running workspace script: ${e}`)),tn(e,{args:t,cwd:r}),!0);async function EC(e,t,r){if(yC(e,r))return!1;let n;try{n=O()}catch{return!1}let s=Ze(n);if(!s)return!1;let o=wC(e,s);return o?xC(e,t,o,n):CC(e,s)?kC(e,t,n):!1}function SC(){let e;try{e=Ze()}catch{return{configured:[],scripts:[]}}if(!e)return{configured:[],scripts:[]};let t=Object.keys(e.pf?.commands??{}),n=Object.keys(e.scripts??{}).filter(s=>!t.includes(s));return{configured:t,scripts:n}}function Qf(){let{configured:e,scripts:t}=SC(),r=[...e,...t];return r.length===0?"":[`
300
+ Workspace Commands:`,...r.map(n=>Sr.default.cyan(` ${n}`))].join(`
301
+ `)}function td(e,t,r){let n=t.slice(2);if(n.length>0&&!n[0].startsWith("-")){let s=n[0],o=n.slice(1);EC(s,o,r).then(i=>{i||e.parse(t)})}else e.parse(t)}process.on("SIGINT",()=>{process.exit(0)});process.on("unhandledRejection",e=>{throw(e.name==="ExitPromptError"||e.message?.includes("ERR_USE_AFTER_CLOSE")||e.message?.includes("Cancelled prompt"))&&process.exit(0),e});process.on("uncaughtException",e=>{(e.name==="ExitPromptError"||e.message?.includes("ERR_USE_AFTER_CLOSE")||e.message?.includes("Cancelled prompt"))&&process.exit(0),(e.message?.includes("Not in a workspace directory")||e.message?.includes("Could not locate workspace root"))&&(console.error(e.message),process.exit(1)),console.error(Se.default.red(`
302
+ \u2716 An unexpected error occurred:`)),console.error(e),process.exit(1)});var Js=new ad.Command,ed=Object.keys(Ot.bin||{}),[cd="pf",ea]=ed.length>0?ed:["pf"],{description:rd,version:FC,repository:nd,homepage:TC}=Ot,sd=rd?.split(/ —|,|\./)[0]||rd||"Platform CLI",ud=nd?.url?`https://${nd.url.replace(/^(git\+|git@)/,"").replace(/\.git$/,"").replace(":","/")}`:null,od=ud||TC,AC=ud?"GitHub":"README",PC=od?[Se.default.bold(sd),`
303
303
 
304
- `,Ee.default.cyan("See more at: "),Ee.default.bold(Ut(EC,sd))].join(""):Ee.default.bold(nd),ud=[Yi,mf(),vf,_f,Kf,bu];Gs.name(ad).description(SC).version(xC||"0.0.1").helpCommand(!1).configureHelp({subcommandTerm:e=>Ee.default.cyan(e.name())}).addHelpText("after",Xf);Zi&&Zi!==ad&&Gs.alias(Zi);ud.forEach(e=>{Gs.addCommand(e)});Qf(Gs,od.argv,ud);
304
+ `,Se.default.cyan("See more at: "),Se.default.bold(Ut(AC,od))].join(""):Se.default.bold(sd),ld=[ta,wf(),xf,Lf,Jf,Eu];Js.name(cd).description(PC).version(FC||"0.0.1").helpCommand(!1).configureHelp({subcommandTerm:e=>Se.default.cyan(e.name())}).addHelpText("after",Qf);ea&&ea!==cd&&Js.alias(ea);ld.forEach(e=>{Js.addCommand(e)});td(Js,id.argv,ld);