@visulima/vis 3.0.1 → 3.0.2

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE.md +159 -19
  3. package/dashboard/dist/index.html +12 -12
  4. package/dist/bin.js +1 -1
  5. package/dist/binx.js +1 -1
  6. package/dist/packem_chunks/CONFIG_FILES.js +1 -1
  7. package/dist/packem_chunks/bloom-status.js +1 -1
  8. package/dist/packem_chunks/bloom-sync.js +1 -1
  9. package/dist/packem_chunks/catalog.js +2 -2
  10. package/dist/packem_chunks/cli-exec.js +1 -1
  11. package/dist/packem_chunks/cli-main.js +132 -132
  12. package/dist/packem_chunks/doctor-probe.js +2 -2
  13. package/dist/packem_chunks/fix.js +5 -5
  14. package/dist/packem_chunks/handler13.js +1 -1
  15. package/dist/packem_chunks/handler14.js +1 -1
  16. package/dist/packem_chunks/handler15.js +1 -1
  17. package/dist/packem_chunks/handler2.js +1 -1
  18. package/dist/packem_chunks/handler20.js +1 -1
  19. package/dist/packem_chunks/handler23.js +1 -1
  20. package/dist/packem_chunks/handler24.js +1 -1
  21. package/dist/packem_chunks/handler26.js +1 -1
  22. package/dist/packem_chunks/handler28.js +1 -1
  23. package/dist/packem_chunks/handler3.js +1 -1
  24. package/dist/packem_chunks/handler50.js +4 -4
  25. package/dist/packem_chunks/handler53.js +1 -1
  26. package/dist/packem_chunks/handler54.js +1 -1
  27. package/dist/packem_chunks/handler59.js +1 -1
  28. package/dist/packem_chunks/handler60.js +1 -1
  29. package/dist/packem_chunks/handler61.js +7 -7
  30. package/dist/packem_chunks/handler62.js +1 -1
  31. package/dist/packem_chunks/handler63.js +1 -1
  32. package/dist/packem_chunks/handler65.js +2 -2
  33. package/dist/packem_chunks/handler66.js +1 -1
  34. package/dist/packem_chunks/handler67.js +25 -24
  35. package/dist/packem_chunks/handler68.js +153 -25
  36. package/dist/packem_chunks/handler69.js +10 -153
  37. package/dist/packem_chunks/handler70.js +22 -10
  38. package/dist/packem_chunks/handler71.js +4 -4
  39. package/dist/packem_chunks/handler72.js +3 -3
  40. package/dist/packem_chunks/handler73.js +6 -6
  41. package/dist/packem_chunks/handler74.js +1 -1
  42. package/dist/packem_chunks/handler75.js +1 -1
  43. package/dist/packem_chunks/handler77.js +1 -1
  44. package/dist/packem_chunks/handler78.js +20 -20
  45. package/dist/packem_chunks/heal.js +4 -4
  46. package/dist/packem_chunks/help-command.js +5 -5
  47. package/dist/packem_chunks/index4.js +6 -8
  48. package/dist/packem_chunks/index6.js +5 -5
  49. package/dist/packem_chunks/prompts.js +1 -1
  50. package/dist/packem_chunks/prune.js +1 -1
  51. package/dist/packem_chunks/shell-runner.js +1 -1
  52. package/dist/packem_chunks/status.js +1 -1
  53. package/dist/packem_chunks/sync.js +1 -1
  54. package/dist/packem_chunks/tar.js +3 -3
  55. package/dist/packem_shared/{advisories-CyDqzi5j.js → advisories-DZd1uGqa.js} +1 -1
  56. package/dist/packem_shared/{affected-selection-DPQR-Bd3.js → affected-selection-CoRXp5H4.js} +1 -1
  57. package/dist/packem_shared/{bin-wafzkjaB.js → bin-C2eYtJ_N.js} +1 -1
  58. package/dist/packem_shared/{cyclonedx-C_ezHg8b.js → cyclonedx-B1vzerwP.js} +1 -1
  59. package/dist/packem_shared/{docker-Br_iFmI-.js → docker-Bex05Qcn.js} +16 -16
  60. package/dist/packem_shared/giget-D8Kwb0kD.js +2 -0
  61. package/dist/packem_shared/index.server-BAjDJSEu.js +2 -0
  62. package/dist/packem_shared/main-BP-w-K-6.js +1 -0
  63. package/dist/packem_shared/{osv-bloom-5wDAoZ1e.js → osv-bloom-1JS__1or.js} +1 -1
  64. package/dist/packem_shared/{package-version-BJkg7-6H.js → package-version-Bb7KGF36.js} +3 -3
  65. package/dist/packem_shared/{project-name-filter-BeREbPMI.js → project-name-filter-DYaIbrXa.js} +1 -1
  66. package/dist/packem_shared/{resolve-explicit-COmP7eqr.js → resolve-explicit-DYaHAVDg.js} +1 -1
  67. package/dist/packem_shared/{s1ngularity-RZOHbGrE.js → s1ngularity-C8sva2SO.js} +1 -1
  68. package/dist/packem_shared/{scan-progress-C9nMDLis.js → scan-progress-aVHGZYWf.js} +1 -1
  69. package/dist/packem_shared/{target-merge-D1xbylFw.js → target-merge-DCGow6Kw.js} +1 -1
  70. package/dist/packem_shared/{typosquats-D8ppc5kr.js → typosquats-Cdsnf6aN.js} +1 -1
  71. package/dist/packem_shared/{vis-user-error-jhNwmkZp.js → vis-user-error-CAu9wIbe.js} +1 -1
  72. package/index.js +26 -26
  73. package/package.json +14 -14
  74. package/dist/packem_shared/giget-CVyyR7x8.js +0 -2
  75. package/dist/packem_shared/index.server-CwSgbeN7.js +0 -2
  76. package/dist/packem_shared/main-BjJN8kWj.js +0 -1
@@ -1 +1 @@
1
- import{createRequire as X}from"node:module";import{X as j,r as _}from"./index.server-CwSgbeN7.js";import{e as A}from"./index-DHD8wb6Z.js";import{g as L}from"./formatBytes-BHAzNIrn-DFIppnY0.js";import{D as m,m as y}from"./provenance-CvfQEJPQ.js";import{g as E}from"./packument-C55kVxcQ.js";import{c as w}from"../packem_chunks/cli-main.js";import{y as U}from"./isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as O}from"./readJsonSync-CbryXYxN-B2aSeDpC.js";import{h as C}from"./writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{s as p}from"./index-B4AjSxHU.js";let Y;const Q=r=>(Y??=X(import.meta.url))(r),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=r=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[e,t]=R.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return R.getBuiltinModule(r)}return Q(r)},{rmSync:D,writeFileSync:P}=$("node:fs"),{createHash:Z}=$("node:crypto"),{Resolver:ee}=$("node:dns/promises");class rr{entries=[];add(e){this.entries.push(e)}addMany(e){for(const t of e)this.entries.push(t)}all(){return this.entries}errors(){return this.entries.filter(e=>e.severity==="error")}warnings(){return this.entries.filter(e=>e.severity==="warning")}hasErrors(){return this.entries.some(e=>e.severity==="error")}hasWarnings(){return this.entries.some(e=>e.severity==="warning")}isEmpty(){return this.entries.length===0}size(){return this.entries.length}}const tr=r=>{if(r.length===0)return[];const e=[],t=r.filter(s=>s.severity==="error"),n=r.filter(s=>s.severity==="warning");if(t.length>0){e.push(j(`${String(t.length)} error${t.length===1?"":"s"}:`));for(const s of t)e.push(` ${j("✗")} [${s.marshall}] ${s.packageName}: ${s.message}`),s.suggestedAction!==void 0&&e.push(` ${_("→")} ${s.suggestedAction}`)}if(n.length>0){t.length>0&&e.push(""),e.push(_(`${String(n.length)} warning${n.length===1?"":"s"}:`));for(const s of n)e.push(` ${_("⚠")} [${s.marshall}] ${s.packageName}: ${s.message}`),s.suggestedAction!==void 0&&e.push(` ${_("→")} ${s.suggestedAction}`)}return e},nr=r=>({errors:r.filter(e=>e.severity==="error"),findings:[...r],summary:{errorCount:r.filter(e=>e.severity==="error").length,warningCount:r.filter(e=>e.severity==="warning").length},warnings:r.filter(e=>e.severity==="warning")}),re=1440*60*1e3,te=15e3,ne="https://api.github.com/repos",W=()=>A(L(),"archived-repo"),q=(r,e)=>A(W(),`${encodeURIComponent(r)}__${encodeURIComponent(e)}.json`),se=(r,e)=>{const t=q(r,e);if(U(t))try{const n=O(t);if(Date.now()-n.createdAt>n.ttlMs){D(t,{force:!0});return}return n}catch{D(t,{force:!0});return}},B=(r,e,t,n)=>{C(W());const s={createdAt:Date.now(),ttlMs:n,...t};P(q(r,e),JSON.stringify(s),"utf8")},oe=r=>{if(typeof r!="string"||r.trim()==="")return;const e=r.trim().replace(/^git\+/,""),t=/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(e);if(t)return{owner:t[1],repo:t[2]};const n=/^ssh:\/\/git@github\.com\/([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(e);if(n)return{owner:n[1],repo:n[2]};const s=/^https?:\/\/(?:www\.)?github\.com\/([^/]+)\/([^/?#]+?)(?:\.git)?\/?$/i.exec(e);if(s)return{owner:s[1],repo:s[2]}},ie=async(r,e,t,n)=>{const s=`${ne}/${encodeURIComponent(r)}/${encodeURIComponent(e)}`,l=new AbortController,o=setTimeout(()=>{l.abort()},te),i=()=>{l.abort()};n?.addEventListener("abort",i,{once:!0});const a={Accept:"application/vnd.github+json","User-Agent":"visulima-vis-marshall"};t!==void 0&&t!==""&&(a.Authorization=`Bearer ${t}`);try{const c=await fetch(s,{headers:a,signal:l.signal});if(c.status===404)return{kind:"missing"};if(!c.ok)return{kind:"transient-error"};const d=await c.json(),u=d.archived===!0,f=typeof d.archived_at=="string"?d.archived_at:void 0;return{archived:u,archivedAt:f,kind:"ok"}}catch{return{kind:"transient-error"}}finally{clearTimeout(o),n?.removeEventListener("abort",i)}},ae=(r,e)=>e!==void 0&&r.includes(e)?e:r.at(-1),sr=async(r,e={})=>{if(w("archivedRepo"))return[];const t=new Set(e.allowlist),n=e.cacheTtlMs??re,s=e.githubToken??process.env.GITHUB_TOKEN,l=e.concurrency??m,o=new Map,i=async(c,d)=>{const u=`${c}/${d}`;let f=o.get(u);return f===void 0&&(f=(async()=>{const h=se(c,d);if(h!==void 0)return h.missing===!0?{archived:!1,kind:"missing"}:{archived:h.archived,archivedAt:h.archivedAt,kind:"ok"};const v=await ie(c,d,s,e.signal);return v.kind==="missing"?B(c,d,{archived:!1,missing:!0},n):v.kind==="ok"&&B(c,d,{archived:v.archived===!0,archivedAt:v.archivedAt},n),v})(),o.set(u,f)),f};return(await y(r,l,async({name:c,version:d})=>{if(t.has(c))return;const u=await E(c,{workspaceRoot:e.workspaceRoot});if(u===void 0)return;const f=u.versions[d]??u.versions[ae(Object.keys(u.versions),u["dist-tags"]?.latest)??""];if(f===void 0)return;const h=oe(f.repository?.url);if(h===void 0)return;const v=await i(h.owner,h.repo);if(v.kind!=="transient-error"){if(v.kind==="missing")return{kind:"missing-repo",owner:h.owner,packageName:c,repo:h.repo};if(v.archived===!0)return{...v.archivedAt===void 0?{}:{archivedAt:v.archivedAt},kind:"archived",owner:h.owner,packageName:c,repo:h.repo}}})).filter(c=>c!==void 0)},ce={dormantErrorDays:274,dormantWarnDays:183,newPublisherWindowDays:21,recentVersionErrorDays:7,recentVersionWarnDays:30},de=1440*60*1e3,F=(r,e)=>(r-e)/de,b=r=>{if(r!==void 0)return r.email??r.name},ue=(r,e,t,n,s)=>{const l=r.time?.[t];if(l===void 0)return;const o=new Date(l).getTime();if(!Number.isFinite(o))return;const i=F(n,o);if(i<s.recentVersionErrorDays)return{kind:"recent-version",message:`published ${i.toFixed(1)} days ago (error threshold: ${String(s.recentVersionErrorDays)})`,packageName:e,severity:"error",version:t};if(i<s.recentVersionWarnDays)return{kind:"recent-version",message:`published ${i.toFixed(1)} days ago (warn threshold: ${String(s.recentVersionWarnDays)})`,packageName:e,severity:"warning",version:t}},le=(r,e,t,n,s)=>{const l=r.versions[t],o=b(l?._npmUser);if(o===void 0)return;const a=Object.keys(r.versions).filter(h=>p.valid(h)!==null).filter(h=>p.lt(h,t));if(a.length===0||a.some(h=>b(r.versions[h]?._npmUser)===o))return;const d=r.time?.[a[0]??""];if(d===void 0)return;const u=new Date(d).getTime();if(!Number.isFinite(u))return;const f=F(n,u);if(!(f<=s.newPublisherWindowDays))return{kind:"new-publisher",message:`first publish by ${o} on a ${f.toFixed(0)}-day-old package`,packageName:e,severity:"error",version:t}},fe=(r,e,t,n,s)=>{const l=r.versions[t],o=b(l?._npmUser);if(o===void 0)return;const i=[];for(const[d,u]of Object.entries(r.versions)){if(d===t||b(u._npmUser)!==o)continue;const f=r.time?.[d];if(f===void 0)continue;const h=new Date(f).getTime();Number.isFinite(h)&&i.push(h)}if(i.length===0)return;const a=Math.max(...i),c=F(n,a);if(c>=s.dormantErrorDays)return{kind:"dormant-maintainer",message:`previous release by ${o} was ${c.toFixed(0)} days ago (error threshold: ${String(s.dormantErrorDays)})`,packageName:e,severity:"error",version:t};if(c>=s.dormantWarnDays)return{kind:"dormant-maintainer",message:`previous release by ${o} was ${c.toFixed(0)} days ago (warn threshold: ${String(s.dormantWarnDays)})`,packageName:e,severity:"warning",version:t}},or=async(r,e={})=>{if(w("author"))return[];const t=new Set(e.allowlist),n={...ce,...e.thresholds},s=e.now??(()=>Date.now()),l=e.concurrency??m;return(await y(r,l,async({name:i,version:a})=>{if(t.has(i))return[];const c=await E(i,{cacheTtlMs:e.cacheTtlMs,signal:e.signal,workspaceRoot:e.workspaceRoot});if(c===void 0)return[];const d=s(),u=[],f=ue(c,i,a,d,n);f!==void 0&&u.push(f);const h=le(c,i,a,d,n);h!==void 0&&u.push(h);const v=fe(c,i,a,d,n);return v!==void 0&&u.push(v),u})).flat()},he=1440*60*1e3,ve=15e3,ge=20,pe=1e4,me="https://api.npmjs.org/downloads/point/last-month",G=()=>A(L(),"downloads"),J=r=>A(G(),`${encodeURIComponent(r)}.json`),ye=r=>{const e=J(r);if(U(e))try{const t=O(e);if(Date.now()-t.createdAt>t.ttlMs){D(e,{force:!0});return}return t.downloads}catch{D(e,{force:!0});return}},we=(r,e,t)=>{C(G());const n={createdAt:Date.now(),downloads:e,observedAt:new Date().toISOString(),ttlMs:t};P(J(r),JSON.stringify(n),"utf8")},ke=async(r,e)=>{const t=`${me}/${encodeURIComponent(r)}`,n=new AbortController,s=setTimeout(()=>{n.abort()},ve),l=()=>{n.abort()};e?.addEventListener("abort",l,{once:!0});try{const o=await fetch(t,{signal:n.signal});if(o.status===404)return{kind:"no-data"};if(!o.ok)return{kind:"error"};const i=await o.json();return typeof i.downloads=="number"?{downloads:i.downloads,kind:"ok"}:{kind:"no-data"}}catch{return{kind:"error"}}finally{clearTimeout(s),e?.removeEventListener("abort",l)}},ir=async(r,e={})=>{if(w("downloads"))return[];const t=new Set(e.allowlist),n=e.errorThreshold??ge,s=e.warnThreshold??pe,l=e.cacheTtlMs??he,o=e.concurrency??m;return(await y(r,o,async a=>{if(t.has(a))return;let d=ye(a);if(d===void 0){const u=await ke(a,e.signal);if(u.kind==="no-data"||u.kind==="error")return{downloadsLastMonth:void 0,kind:"no-data",packageName:a,severity:"warning"};d=u.downloads??0,we(a,d,l)}if(d<n)return{downloadsLastMonth:d,kind:"below-error",packageName:a,severity:"error"};if(d<s)return{downloadsLastMonth:d,kind:"below-warning",packageName:a,severity:"warning"}})).filter(a=>a!==void 0)},De=1440*60*1e3,Ae=4e3,Ee=["1.1.1.1","8.8.8.8"],K=()=>A(L(),"expired-domains"),z=r=>{const e=Z("sha256").update(r).digest("hex").slice(0,12);return A(K(),`${e}.json`)},Re=r=>{const e=z(r);if(U(e))try{const t=O(e);if(Date.now()-t.createdAt>t.ttlMs){D(e,{force:!0});return}return t}catch{D(e,{force:!0});return}},Te=(r,e,t)=>{C(K());const n={createdAt:Date.now(),outcome:e,ttlMs:t};P(z(r),JSON.stringify(n),"utf8")},_e=r=>{if(typeof r!="string")return;const e=r.lastIndexOf("@");if(e===-1||e===r.length-1)return;const t=r.slice(e+1).trim().toLowerCase();return t===""?void 0:t},be=(r,e)=>{const t=[];e!==void 0&&t.push(e);for(const n of r??[])t.push(n);return t},Me=async(r,e)=>{let t;try{return await Promise.race([r,new Promise((n,s)=>{t=setTimeout(()=>{s(new Error("ETIMEDOUT"))},e)})])}finally{t!==void 0&&clearTimeout(t)}},Se=r=>{if(r===null||typeof r!="object")return!1;const{code:e}=r;return e==="ENOTFOUND"||e==="ENODATA"||e==="NXDOMAIN"},$e=async(r,e,t)=>{try{const n=await Me(r.resolveNs(e),t);return Array.isArray(n)&&n.length>0?{kind:"ok"}:{kind:"expired"}}catch(n){return Se(n)?{kind:"expired"}:{kind:"transient-error"}}},Pe=(r,e)=>e!==void 0&&r.includes(e)?e:r.at(-1),ar=async(r,e={})=>{if(w("expiredDomains"))return[];const t=new Set(e.allowlist),n=new Set((e.allowDomains??[]).map(f=>f.toLowerCase())),s=e.cacheTtlMs??De,l=e.perDomainTimeoutMs??Ae,o=e.dnsServers??Ee,i=e.concurrency??m,a=e.createResolver===void 0?new ee:e.createResolver();typeof a.setServers=="function"&&a.setServers(o);const c=new Map,d=async f=>{let h=c.get(f);return h===void 0&&(h=(async()=>{const v=Re(f);if(v!==void 0)return{kind:v.outcome==="ok"?"ok":"expired"};const g=await $e(a,f,l);return g.kind!=="transient-error"&&Te(f,g.kind,s),g})(),c.set(f,h)),h};return(await y(r,i,async({name:f,version:h})=>{if(t.has(f))return[];const v=await E(f,{workspaceRoot:e.workspaceRoot});if(v===void 0)return[];const g=v.versions[h]??v.versions[Pe(Object.keys(v.versions),v["dist-tags"]?.latest)??""];if(g===void 0)return[];const M=be(g.maintainers,g._npmUser),N=new Set,S=[];for(const T of M){const k=_e(T.email);if(k===void 0||n.has(k))continue;const I=`${k}:${T.email??""}`;if(N.has(I))continue;N.add(I);const x=await d(k);x.kind==="expired"?S.push({domain:k,kind:"expired",maintainer:T.email??"",packageName:f,severity:"error"}):x.kind==="transient-error"&&S.push({domain:k,kind:"unresolved",maintainer:T.email??"",packageName:f,severity:"warning"})}return S})).flat()},Le=["readme","license","repo"],Ue=["ERROR: No README data found!","# Security holding package"],Oe=r=>{const e=r.trim();return e===""?!0:Ue.some(t=>e.startsWith(t))},Ce=(r,e)=>{if(typeof e.readme=="string")return e.readme;if(typeof r.readme=="string")return r.readme},Fe=(r,e)=>{const t=Ce(r,e);if(t===void 0)return"missing-readme";if(Oe(t))return"placeholder-readme"},Ne=r=>{const{license:e}=r;return e===void 0?"missing-license":typeof e=="string"?e.trim()===""?"missing-license":void 0:typeof e.type=="string"&&e.type.trim()!==""?void 0:"missing-license"},Ie=r=>{const{repository:e}=r;if(e===void 0)return"missing-repo";const t=typeof e.url=="string"?e.url.trim():"";if(t==="")return"missing-repo";let n=t.replace(/^git\+/,"");const s=/^git@([^:]+):(.+?)(?:\.git)?$/.exec(n);return s&&(n=`https://${s[1]}/${s[2]}`),URL.canParse(n)?void 0:"invalid-repo-url"},xe=r=>{const e=r["dist-tags"]?.latest;return e!==void 0&&Object.hasOwn(r.versions,e)?e:Object.keys(r.versions).at(-1)},cr=async(r,e={})=>{if(w("metadata"))return[];const t=new Set(e.allowlist),n=new Set(e.checks??Le),s=e.concurrency??m;return(await y(r,s,async({name:o,version:i})=>{if(t.has(o))return;const a=await E(o,{workspaceRoot:e.workspaceRoot});if(a===void 0)return;const c=a.versions[i]??a.versions[xe(a)??""];if(c===void 0||c.private===!0)return;const d=[];if(n.has("readme")){const u=Fe(a,c);u!==void 0&&d.push(u)}if(n.has("license")){const u=Ne(c);u!==void 0&&d.push(u)}if(n.has("repo")){const u=Ie(c);u!==void 0&&d.push(u)}if(d.length!==0)return{issues:d,packageName:o,version:i}})).filter(o=>o!==void 0)},H=(r,e)=>r===void 0?{}:typeof r=="string"?{[e.startsWith("@")?e.split("/").at(1)??e:e]:r}:{...r},je=(r,e)=>p.valid(e)?Object.keys(r.versions).filter(n=>p.valid(n)!==null&&p.lt(n,e)).sort((n,s)=>p.lt(n,s)?1:-1)[0]:void 0,dr=async(r,e={})=>{if(w("newBin"))return[];const t=new Set(e.allowlist),n=new Set(e.allowBins),s=e.concurrency??m;return(await y(r,s,async({name:o,version:i})=>{if(t.has(o))return;const a=await E(o,{workspaceRoot:e.workspaceRoot});if(a===void 0)return;const c=a.versions[i];if(c===void 0)return;const d=je(a,i);if(d===void 0)return;const u=a.versions[d];if(u===void 0)return;const f=H(c.bin,o),h=H(u.bin,o),v=Object.entries(f).filter(([g])=>!(g in h)).filter(([g])=>!n.has(g)).map(([g,M])=>({command:M,name:g}));if(v.length!==0)return{fromVersion:d,newBins:v,packageName:o,toVersion:i}})).filter(o=>o!==void 0)},Be=["preinstall","install","postinstall"],V=(r,e)=>r.versions[e]?.dist?.attestations?.provenance!==void 0,He=(r,e)=>{if(p.valid(e)!==null)return Object.keys(r.versions).filter(t=>p.valid(t)!==null&&p.prerelease(t)===null&&p.lt(t,e)).sort((t,n)=>p.lt(t,n)?1:-1)[0]},Ve=(r,e)=>{const t=r??{},n=e??{},s=[];for(const l of Be){const o=t[l];if(o===void 0||o==="")continue;const i=n[l];i===void 0||i===""?s.push({command:o,hook:l,kind:"introduced"}):i!==o&&s.push({command:o,hook:l,kind:"changed"})}return s},ur=async(r,e={})=>{if(w("s1ngularity"))return[];const t=new Set(e.allowlist),n=e.concurrency??m;return(await y(r,n,async({name:l,version:o})=>{if(t.has(l))return;const i=await E(l,{workspaceRoot:e.workspaceRoot});if(i?.versions[o]===void 0)return;const a=He(i,o);if(a===void 0||!V(i,a)||V(i,o))return;const c=Ve(i.versions[o]?.scripts,i.versions[a]?.scripts);if(c.length!==0)return{hookChanges:c,packageName:l,priorVersion:a,trustSignal:"provenance-dropped",version:o}})).filter(l=>l!==void 0)};export{rr as M,ur as a,dr as b,cr as c,ir as d,ar as e,sr as f,nr as g,tr as h,or as r};
1
+ import{createRequire as X}from"node:module";import{X as j,b as T}from"./index.server-BAjDJSEu.js";import{e as A}from"./index-DHD8wb6Z.js";import{g as L}from"./formatBytes-BHAzNIrn-DFIppnY0.js";import{D as m,m as y}from"./provenance-CvfQEJPQ.js";import{g as E}from"./packument-C55kVxcQ.js";import{c as w}from"../packem_chunks/cli-main.js";import{y as U}from"./isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as O}from"./readJsonSync-CbryXYxN-B2aSeDpC.js";import{h as C}from"./writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{s as p}from"./index-B4AjSxHU.js";let Y;const Q=r=>(Y??=X(import.meta.url))(r),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=r=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[e,t]=b.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return b.getBuiltinModule(r)}return Q(r)},{rmSync:D,writeFileSync:P}=$("node:fs"),{createHash:Z}=$("node:crypto"),{Resolver:ee}=$("node:dns/promises");class rr{entries=[];add(e){this.entries.push(e)}addMany(e){for(const t of e)this.entries.push(t)}all(){return this.entries}errors(){return this.entries.filter(e=>e.severity==="error")}warnings(){return this.entries.filter(e=>e.severity==="warning")}hasErrors(){return this.entries.some(e=>e.severity==="error")}hasWarnings(){return this.entries.some(e=>e.severity==="warning")}isEmpty(){return this.entries.length===0}size(){return this.entries.length}}const tr=r=>{if(r.length===0)return[];const e=[],t=r.filter(s=>s.severity==="error"),n=r.filter(s=>s.severity==="warning");if(t.length>0){e.push(j(`${String(t.length)} error${t.length===1?"":"s"}:`));for(const s of t)e.push(` ${j("✗")} [${s.marshall}] ${s.packageName}: ${s.message}`),s.suggestedAction!==void 0&&e.push(` ${T("→")} ${s.suggestedAction}`)}if(n.length>0){t.length>0&&e.push(""),e.push(T(`${String(n.length)} warning${n.length===1?"":"s"}:`));for(const s of n)e.push(` ${T("⚠")} [${s.marshall}] ${s.packageName}: ${s.message}`),s.suggestedAction!==void 0&&e.push(` ${T("→")} ${s.suggestedAction}`)}return e},nr=r=>({errors:r.filter(e=>e.severity==="error"),findings:[...r],summary:{errorCount:r.filter(e=>e.severity==="error").length,warningCount:r.filter(e=>e.severity==="warning").length},warnings:r.filter(e=>e.severity==="warning")}),re=1440*60*1e3,te=15e3,ne="https://api.github.com/repos",W=()=>A(L(),"archived-repo"),q=(r,e)=>A(W(),`${encodeURIComponent(r)}__${encodeURIComponent(e)}.json`),se=(r,e)=>{const t=q(r,e);if(U(t))try{const n=O(t);if(Date.now()-n.createdAt>n.ttlMs){D(t,{force:!0});return}return n}catch{D(t,{force:!0});return}},B=(r,e,t,n)=>{C(W());const s={createdAt:Date.now(),ttlMs:n,...t};P(q(r,e),JSON.stringify(s),"utf8")},oe=r=>{if(typeof r!="string"||r.trim()==="")return;const e=r.trim().replace(/^git\+/,""),t=/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(e);if(t)return{owner:t[1],repo:t[2]};const n=/^ssh:\/\/git@github\.com\/([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(e);if(n)return{owner:n[1],repo:n[2]};const s=/^https?:\/\/(?:www\.)?github\.com\/([^/]+)\/([^/?#]+?)(?:\.git)?\/?$/i.exec(e);if(s)return{owner:s[1],repo:s[2]}},ie=async(r,e,t,n)=>{const s=`${ne}/${encodeURIComponent(r)}/${encodeURIComponent(e)}`,l=new AbortController,o=setTimeout(()=>{l.abort()},te),i=()=>{l.abort()};n?.addEventListener("abort",i,{once:!0});const a={Accept:"application/vnd.github+json","User-Agent":"visulima-vis-marshall"};t!==void 0&&t!==""&&(a.Authorization=`Bearer ${t}`);try{const c=await fetch(s,{headers:a,signal:l.signal});if(c.status===404)return{kind:"missing"};if(!c.ok)return{kind:"transient-error"};const d=await c.json(),u=d.archived===!0,f=typeof d.archived_at=="string"?d.archived_at:void 0;return{archived:u,archivedAt:f,kind:"ok"}}catch{return{kind:"transient-error"}}finally{clearTimeout(o),n?.removeEventListener("abort",i)}},ae=(r,e)=>e!==void 0&&r.includes(e)?e:r.at(-1),sr=async(r,e={})=>{if(w("archivedRepo"))return[];const t=new Set(e.allowlist),n=e.cacheTtlMs??re,s=e.githubToken??process.env.GITHUB_TOKEN,l=e.concurrency??m,o=new Map,i=async(c,d)=>{const u=`${c}/${d}`;let f=o.get(u);return f===void 0&&(f=(async()=>{const h=se(c,d);if(h!==void 0)return h.missing===!0?{archived:!1,kind:"missing"}:{archived:h.archived,archivedAt:h.archivedAt,kind:"ok"};const v=await ie(c,d,s,e.signal);return v.kind==="missing"?B(c,d,{archived:!1,missing:!0},n):v.kind==="ok"&&B(c,d,{archived:v.archived===!0,archivedAt:v.archivedAt},n),v})(),o.set(u,f)),f};return(await y(r,l,async({name:c,version:d})=>{if(t.has(c))return;const u=await E(c,{workspaceRoot:e.workspaceRoot});if(u===void 0)return;const f=u.versions[d]??u.versions[ae(Object.keys(u.versions),u["dist-tags"]?.latest)??""];if(f===void 0)return;const h=oe(f.repository?.url);if(h===void 0)return;const v=await i(h.owner,h.repo);if(v.kind!=="transient-error"){if(v.kind==="missing")return{kind:"missing-repo",owner:h.owner,packageName:c,repo:h.repo};if(v.archived===!0)return{...v.archivedAt===void 0?{}:{archivedAt:v.archivedAt},kind:"archived",owner:h.owner,packageName:c,repo:h.repo}}})).filter(c=>c!==void 0)},ce={dormantErrorDays:274,dormantWarnDays:183,newPublisherWindowDays:21,recentVersionErrorDays:7,recentVersionWarnDays:30},de=1440*60*1e3,F=(r,e)=>(r-e)/de,_=r=>{if(r!==void 0)return r.email??r.name},ue=(r,e,t,n,s)=>{const l=r.time?.[t];if(l===void 0)return;const o=new Date(l).getTime();if(!Number.isFinite(o))return;const i=F(n,o);if(i<s.recentVersionErrorDays)return{kind:"recent-version",message:`published ${i.toFixed(1)} days ago (error threshold: ${String(s.recentVersionErrorDays)})`,packageName:e,severity:"error",version:t};if(i<s.recentVersionWarnDays)return{kind:"recent-version",message:`published ${i.toFixed(1)} days ago (warn threshold: ${String(s.recentVersionWarnDays)})`,packageName:e,severity:"warning",version:t}},le=(r,e,t,n,s)=>{const l=r.versions[t],o=_(l?._npmUser);if(o===void 0)return;const a=Object.keys(r.versions).filter(h=>p.valid(h)!==null).filter(h=>p.lt(h,t));if(a.length===0||a.some(h=>_(r.versions[h]?._npmUser)===o))return;const d=r.time?.[a[0]??""];if(d===void 0)return;const u=new Date(d).getTime();if(!Number.isFinite(u))return;const f=F(n,u);if(!(f<=s.newPublisherWindowDays))return{kind:"new-publisher",message:`first publish by ${o} on a ${f.toFixed(0)}-day-old package`,packageName:e,severity:"error",version:t}},fe=(r,e,t,n,s)=>{const l=r.versions[t],o=_(l?._npmUser);if(o===void 0)return;const i=[];for(const[d,u]of Object.entries(r.versions)){if(d===t||_(u._npmUser)!==o)continue;const f=r.time?.[d];if(f===void 0)continue;const h=new Date(f).getTime();Number.isFinite(h)&&i.push(h)}if(i.length===0)return;const a=Math.max(...i),c=F(n,a);if(c>=s.dormantErrorDays)return{kind:"dormant-maintainer",message:`previous release by ${o} was ${c.toFixed(0)} days ago (error threshold: ${String(s.dormantErrorDays)})`,packageName:e,severity:"error",version:t};if(c>=s.dormantWarnDays)return{kind:"dormant-maintainer",message:`previous release by ${o} was ${c.toFixed(0)} days ago (warn threshold: ${String(s.dormantWarnDays)})`,packageName:e,severity:"warning",version:t}},or=async(r,e={})=>{if(w("author"))return[];const t=new Set(e.allowlist),n={...ce,...e.thresholds},s=e.now??(()=>Date.now()),l=e.concurrency??m;return(await y(r,l,async({name:i,version:a})=>{if(t.has(i))return[];const c=await E(i,{cacheTtlMs:e.cacheTtlMs,signal:e.signal,workspaceRoot:e.workspaceRoot});if(c===void 0)return[];const d=s(),u=[],f=ue(c,i,a,d,n);f!==void 0&&u.push(f);const h=le(c,i,a,d,n);h!==void 0&&u.push(h);const v=fe(c,i,a,d,n);return v!==void 0&&u.push(v),u})).flat()},he=1440*60*1e3,ve=15e3,ge=20,pe=1e4,me="https://api.npmjs.org/downloads/point/last-month",G=()=>A(L(),"downloads"),J=r=>A(G(),`${encodeURIComponent(r)}.json`),ye=r=>{const e=J(r);if(U(e))try{const t=O(e);if(Date.now()-t.createdAt>t.ttlMs){D(e,{force:!0});return}return t.downloads}catch{D(e,{force:!0});return}},we=(r,e,t)=>{C(G());const n={createdAt:Date.now(),downloads:e,observedAt:new Date().toISOString(),ttlMs:t};P(J(r),JSON.stringify(n),"utf8")},ke=async(r,e)=>{const t=`${me}/${encodeURIComponent(r)}`,n=new AbortController,s=setTimeout(()=>{n.abort()},ve),l=()=>{n.abort()};e?.addEventListener("abort",l,{once:!0});try{const o=await fetch(t,{signal:n.signal});if(o.status===404)return{kind:"no-data"};if(!o.ok)return{kind:"error"};const i=await o.json();return typeof i.downloads=="number"?{downloads:i.downloads,kind:"ok"}:{kind:"no-data"}}catch{return{kind:"error"}}finally{clearTimeout(s),e?.removeEventListener("abort",l)}},ir=async(r,e={})=>{if(w("downloads"))return[];const t=new Set(e.allowlist),n=e.errorThreshold??ge,s=e.warnThreshold??pe,l=e.cacheTtlMs??he,o=e.concurrency??m;return(await y(r,o,async a=>{if(t.has(a))return;let d=ye(a);if(d===void 0){const u=await ke(a,e.signal);if(u.kind==="no-data"||u.kind==="error")return{downloadsLastMonth:void 0,kind:"no-data",packageName:a,severity:"warning"};d=u.downloads??0,we(a,d,l)}if(d<n)return{downloadsLastMonth:d,kind:"below-error",packageName:a,severity:"error"};if(d<s)return{downloadsLastMonth:d,kind:"below-warning",packageName:a,severity:"warning"}})).filter(a=>a!==void 0)},De=1440*60*1e3,Ae=4e3,Ee=["1.1.1.1","8.8.8.8"],K=()=>A(L(),"expired-domains"),z=r=>{const e=Z("sha256").update(r).digest("hex").slice(0,12);return A(K(),`${e}.json`)},be=r=>{const e=z(r);if(U(e))try{const t=O(e);if(Date.now()-t.createdAt>t.ttlMs){D(e,{force:!0});return}return t}catch{D(e,{force:!0});return}},Re=(r,e,t)=>{C(K());const n={createdAt:Date.now(),outcome:e,ttlMs:t};P(z(r),JSON.stringify(n),"utf8")},Te=r=>{if(typeof r!="string")return;const e=r.lastIndexOf("@");if(e===-1||e===r.length-1)return;const t=r.slice(e+1).trim().toLowerCase();return t===""?void 0:t},_e=(r,e)=>{const t=[];e!==void 0&&t.push(e);for(const n of r??[])t.push(n);return t},Me=async(r,e)=>{let t;try{return await Promise.race([r,new Promise((n,s)=>{t=setTimeout(()=>{s(new Error("ETIMEDOUT"))},e)})])}finally{t!==void 0&&clearTimeout(t)}},Se=r=>{if(r===null||typeof r!="object")return!1;const{code:e}=r;return e==="ENOTFOUND"||e==="ENODATA"||e==="NXDOMAIN"},$e=async(r,e,t)=>{try{const n=await Me(r.resolveNs(e),t);return Array.isArray(n)&&n.length>0?{kind:"ok"}:{kind:"expired"}}catch(n){return Se(n)?{kind:"expired"}:{kind:"transient-error"}}},Pe=(r,e)=>e!==void 0&&r.includes(e)?e:r.at(-1),ar=async(r,e={})=>{if(w("expiredDomains"))return[];const t=new Set(e.allowlist),n=new Set((e.allowDomains??[]).map(f=>f.toLowerCase())),s=e.cacheTtlMs??De,l=e.perDomainTimeoutMs??Ae,o=e.dnsServers??Ee,i=e.concurrency??m,a=e.createResolver===void 0?new ee:e.createResolver();typeof a.setServers=="function"&&a.setServers(o);const c=new Map,d=async f=>{let h=c.get(f);return h===void 0&&(h=(async()=>{const v=be(f);if(v!==void 0)return{kind:v.outcome==="ok"?"ok":"expired"};const g=await $e(a,f,l);return g.kind!=="transient-error"&&Re(f,g.kind,s),g})(),c.set(f,h)),h};return(await y(r,i,async({name:f,version:h})=>{if(t.has(f))return[];const v=await E(f,{workspaceRoot:e.workspaceRoot});if(v===void 0)return[];const g=v.versions[h]??v.versions[Pe(Object.keys(v.versions),v["dist-tags"]?.latest)??""];if(g===void 0)return[];const M=_e(g.maintainers,g._npmUser),N=new Set,S=[];for(const R of M){const k=Te(R.email);if(k===void 0||n.has(k))continue;const I=`${k}:${R.email??""}`;if(N.has(I))continue;N.add(I);const x=await d(k);x.kind==="expired"?S.push({domain:k,kind:"expired",maintainer:R.email??"",packageName:f,severity:"error"}):x.kind==="transient-error"&&S.push({domain:k,kind:"unresolved",maintainer:R.email??"",packageName:f,severity:"warning"})}return S})).flat()},Le=["readme","license","repo"],Ue=["ERROR: No README data found!","# Security holding package"],Oe=r=>{const e=r.trim();return e===""?!0:Ue.some(t=>e.startsWith(t))},Ce=(r,e)=>{if(typeof e.readme=="string")return e.readme;if(typeof r.readme=="string")return r.readme},Fe=(r,e)=>{const t=Ce(r,e);if(t===void 0)return"missing-readme";if(Oe(t))return"placeholder-readme"},Ne=r=>{const{license:e}=r;return e===void 0?"missing-license":typeof e=="string"?e.trim()===""?"missing-license":void 0:typeof e.type=="string"&&e.type.trim()!==""?void 0:"missing-license"},Ie=r=>{const{repository:e}=r;if(e===void 0)return"missing-repo";const t=typeof e.url=="string"?e.url.trim():"";if(t==="")return"missing-repo";let n=t.replace(/^git\+/,"");const s=/^git@([^:]+):(.+?)(?:\.git)?$/.exec(n);return s&&(n=`https://${s[1]}/${s[2]}`),URL.canParse(n)?void 0:"invalid-repo-url"},xe=r=>{const e=r["dist-tags"]?.latest;return e!==void 0&&Object.hasOwn(r.versions,e)?e:Object.keys(r.versions).at(-1)},cr=async(r,e={})=>{if(w("metadata"))return[];const t=new Set(e.allowlist),n=new Set(e.checks??Le),s=e.concurrency??m;return(await y(r,s,async({name:o,version:i})=>{if(t.has(o))return;const a=await E(o,{workspaceRoot:e.workspaceRoot});if(a===void 0)return;const c=a.versions[i]??a.versions[xe(a)??""];if(c===void 0||c.private===!0)return;const d=[];if(n.has("readme")){const u=Fe(a,c);u!==void 0&&d.push(u)}if(n.has("license")){const u=Ne(c);u!==void 0&&d.push(u)}if(n.has("repo")){const u=Ie(c);u!==void 0&&d.push(u)}if(d.length!==0)return{issues:d,packageName:o,version:i}})).filter(o=>o!==void 0)},H=(r,e)=>r===void 0?{}:typeof r=="string"?{[e.startsWith("@")?e.split("/").at(1)??e:e]:r}:{...r},je=(r,e)=>p.valid(e)?Object.keys(r.versions).filter(n=>p.valid(n)!==null&&p.lt(n,e)).sort((n,s)=>p.lt(n,s)?1:-1)[0]:void 0,dr=async(r,e={})=>{if(w("newBin"))return[];const t=new Set(e.allowlist),n=new Set(e.allowBins),s=e.concurrency??m;return(await y(r,s,async({name:o,version:i})=>{if(t.has(o))return;const a=await E(o,{workspaceRoot:e.workspaceRoot});if(a===void 0)return;const c=a.versions[i];if(c===void 0)return;const d=je(a,i);if(d===void 0)return;const u=a.versions[d];if(u===void 0)return;const f=H(c.bin,o),h=H(u.bin,o),v=Object.entries(f).filter(([g])=>!(g in h)).filter(([g])=>!n.has(g)).map(([g,M])=>({command:M,name:g}));if(v.length!==0)return{fromVersion:d,newBins:v,packageName:o,toVersion:i}})).filter(o=>o!==void 0)},Be=["preinstall","install","postinstall"],V=(r,e)=>r.versions[e]?.dist?.attestations?.provenance!==void 0,He=(r,e)=>{if(p.valid(e)!==null)return Object.keys(r.versions).filter(t=>p.valid(t)!==null&&p.prerelease(t)===null&&p.lt(t,e)).sort((t,n)=>p.lt(t,n)?1:-1)[0]},Ve=(r,e)=>{const t=r??{},n=e??{},s=[];for(const l of Be){const o=t[l];if(o===void 0||o==="")continue;const i=n[l];i===void 0||i===""?s.push({command:o,hook:l,kind:"introduced"}):i!==o&&s.push({command:o,hook:l,kind:"changed"})}return s},ur=async(r,e={})=>{if(w("s1ngularity"))return[];const t=new Set(e.allowlist),n=e.concurrency??m;return(await y(r,n,async({name:l,version:o})=>{if(t.has(l))return;const i=await E(l,{workspaceRoot:e.workspaceRoot});if(i?.versions[o]===void 0)return;const a=He(i,o);if(a===void 0||!V(i,a)||V(i,o))return;const c=Ve(i.versions[o]?.scripts,i.versions[a]?.scripts);if(c.length!==0)return{hookChanges:c,packageName:l,priorVersion:a,trustSignal:"provenance-dropped",version:o}})).filter(l=>l!==void 0)};export{rr as M,ur as a,dr as b,cr as c,ir as d,ar as e,sr as f,nr as g,tr as h,or as r};
@@ -1,2 +1,2 @@
1
- import{F as h,r as S,J as T,X as R}from"./index.server-CwSgbeN7.js";import{C as k,S as l}from"../packem_chunks/cli-main.js";import{i as y}from"./index-BjdW45xX.js";import{y as s,X as d,m as a,R as g}from"../packem_chunks/catalog.js";import{l as $}from"./spinner-CbJfWYwB.js";import{D as j,W as v,T as A,C as D}from"./symbols-BXDZ_sKt.js";const b=({rows:i})=>s.jsx(d,{flexDirection:"column",children:i.map(r=>{let t;switch(r.status){case"error":{t=s.jsx(a,{color:"red",children:D});break}case"ok":{t=s.jsx(a,{color:"green",children:A});break}case"running":{t=s.jsx(a,{color:"white",children:s.jsx($,{type:"dots"})});break}case"warn":{t=s.jsx(a,{color:"yellow",children:v});break}default:{t=s.jsx(a,{dimColor:!0,children:j});break}}return s.jsxs(d,{children:[s.jsx(d,{width:3,children:t}),s.jsx(d,{flexGrow:1,children:s.jsx(a,{children:r.label})}),r.summary?s.jsx(d,{children:s.jsxs(a,{dimColor:!0,children:[j," ",r.summary]})}):null]},r.id)})}),I={error:R(l.failure),ok:T(l.success),pending:h(l.dash),skip:h(l.dash),warn:S(l.warning)},Y=(i,r,t)=>{const p=t?`${i} ${h(`— ${t}`)}`:i;return` ${I[r]} ${p}
1
+ import{F as h,b as S,J as T,X as R}from"./index.server-BAjDJSEu.js";import{C as k,S as l}from"../packem_chunks/cli-main.js";import{i as y}from"./index-BjdW45xX.js";import{y as s,X as d,m as a,R as g}from"../packem_chunks/catalog.js";import{l as $}from"./spinner-CbJfWYwB.js";import{D as j,W as v,T as A,C as D}from"./symbols-BXDZ_sKt.js";const b=({rows:i})=>s.jsx(d,{flexDirection:"column",children:i.map(r=>{let t;switch(r.status){case"error":{t=s.jsx(a,{color:"red",children:D});break}case"ok":{t=s.jsx(a,{color:"green",children:A});break}case"running":{t=s.jsx(a,{color:"white",children:s.jsx($,{type:"dots"})});break}case"warn":{t=s.jsx(a,{color:"yellow",children:v});break}default:{t=s.jsx(a,{dimColor:!0,children:j});break}}return s.jsxs(d,{children:[s.jsx(d,{width:3,children:t}),s.jsx(d,{flexGrow:1,children:s.jsx(a,{children:r.label})}),r.summary?s.jsx(d,{children:s.jsxs(a,{dimColor:!0,children:[j," ",r.summary]})}):null]},r.id)})}),I={error:R(l.failure),ok:T(l.success),pending:h(l.dash),skip:h(l.dash),warn:S(l.warning)},Y=(i,r,t)=>{const p=t?`${i} ${h(`— ${t}`)}`:i;return` ${I[r]} ${p}
2
2
  `},M=(i,r={})=>{const t=r.stream??process.stderr,w=typeof t.isTTY=="boolean"&&t.isTTY&&!y,C=r.live??w,n=new Map;for(const e of i)n.set(e.id,{id:e.id,label:e.label,status:"pending"});if(!C||i.length===0)return{finish:(e,o,m)=>{const c=n.get(e);c&&(n.set(e,{...c,status:o,summary:m}),t.write(Y(c.label,o,m)))},start:e=>{const o=n.get(e);o&&n.set(e,{...o,status:"running"})},stop:()=>{}};const x=()=>i.map(e=>n.get(e.id));let u=k(g.createElement(b,{rows:x()}),{interactive:!0,patchConsole:!1});const f=()=>{u?.rerender(g.createElement(b,{rows:x()}))};return{finish:(e,o,m)=>{const c=n.get(e);c&&(n.set(e,{...c,status:o,summary:m}),f())},start:e=>{const o=n.get(e);o&&(n.set(e,{...o,status:"running"}),f())},stop:()=>{u&&(f(),u.unmount(),u=void 0)}}};export{M as s};
@@ -1,4 +1,4 @@
1
1
  import{createRequire as re}from"node:module";import{_ as ue}from"./index-DHD8wb6Z.js";import{y as ae}from"./isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{U as fe}from"./writeFileSync-DJoHk3Ks-CgQ-VNNT.js";let ie;const ce=e=>(ie??=re(import.meta.url))(e),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,le=e=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[t,s]=x.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return x.getBuiltinModule(e)}return ce(e)},{createRequire:ee}=le("node:module"),pe=/^(?:( )+|\t+)/,M="space";function W(e,t,s){return e&&t===M&&s===1}function H(e,t){const s=new Map;let o=0,r,n;for(const c of e.split(/\n/g)){if(!c)continue;const i=c.match(pe);if(i===null)o=0,r="";else{const d=i[0].length,a=i[1]?M:"tab";if(W(t,a,d))continue;a!==r&&(o=0),r=a;let l=1,u=0;const f=d-o;if(o=d,f===0)l=0,u=1;else{const g=Math.abs(f);if(W(t,a,g))continue;n=de(a,g)}const p=s.get(n);s.set(n,p===void 0?[1,0]:[p[0]+l,p[1]+u])}}return s}function de(e,t){return(e===M?"s":"t")+String(t)}function me(e){const t=e[0]==="s"?M:"tab",s=Number(e.slice(1));return{type:t,amount:s}}function ge(e){let t,s=0,o=0;for(const[r,[n,c]]of e)(n>s||n===s&&c>o)&&(s=n,o=c,t=r);return t}function he(e,t){return(e===M?" ":" ").repeat(t)}function be(e){if(typeof e!="string")throw new TypeError("Expected a string");let t=H(e,!0);t.size===0&&(t=H(e,!1));const s=ge(t);let o,r=0,n="";return s!==void 0&&({type:o,amount:r}=me(s),n=he(o,r)),{amount:r,type:o,indent:n}}let ye;const ve=e=>(ye??=ee(import.meta.url))(e),T=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,we=e=>{if(typeof T<"u"&&T.versions&&T.versions.node){const[t,s]=T.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return T.getBuiltinModule(e)}return ve(e)},{readFileSync:xe}=we("node:fs"),Ot=(e,t,s={})=>{const{detectIndent:o,indent:r,replacer:n,stringify:c=JSON.stringify,...i}={indent:" ",...s};let d=r,a=`
2
2
  `;if(ae(e,ue))try{const u=xe(e,"utf8");if(o){const{indent:f}=be(u);d=f}a=u.endsWith(`
3
3
  `)?`
4
- `:""}catch(u){if(u.code!=="ENOENT")throw u}const l=c(t,n,d);fe(e,`${l}${a}`,i)};let Te;const ke=e=>(Te??=ee(import.meta.url))(e),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=e=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[t,s]=v.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return v.getBuiltinModule(e)}return ke(e)},{homedir:Ee,tmpdir:B}=te("node:os"),{env:A,cwd:$e,platform:G}=v,{createRequire:h}=te("node:module"),Ne=0,se=2,Se=Symbol("findUpStop"),_e=/^[A-Z]:\//i,y=(e="")=>e&&e.replaceAll("\\","/").replace(_e,t=>t.toUpperCase()),Ce=/^[/\\]{2}/,ze=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,L=/^[A-Z]:$/i,je=/[^/](\.[^./]+)$/,Ie=/^[/\\]|^[a-z]:[/\\]/i,Ae=/\/$/,Me=()=>{if(typeof process.cwd=="function")try{const e=process.cwd();if(typeof e=="string")return y(e)}catch{}return"/"},D="/",oe=(e,t)=>{let s="",o=0,r=-1,n=0,c;for(let i=0;i<=e.length;++i){if(i<e.length)c=e[i];else{if(c==="/")break;c="/"}if(c==="/"){if(!(r===i-1||n===1))if(n===2){if(s.length<2||o!==2||!s.endsWith(".")||s.at(-2)!=="."){if(s.length>2){const d=s.lastIndexOf("/");d===-1?(s="",o=0):(s=s.slice(0,d),o=s.length-1-s.lastIndexOf("/")),r=i,n=0;continue}else if(s.length>0){s="",o=0,r=i,n=0;continue}}t&&(s+=s.length>0?"/..":"..",o=2)}else s.length>0?s+=`/${e.slice(r+1,i)}`:s=e.slice(r+1,i),o=i-r-1;r=i,n=0}else c==="."&&n!==-1?++n:n=-1}return s},b=e=>ze.test(e),Oe=function(e){if(e.length===0)return".";e=y(e);const t=Ce.exec(e),s=b(e),o=e.at(-1)==="/";return e=oe(e,!s),e.length===0?s?"/":o?"./":".":(o&&(e+="/"),L.test(e)&&(e+="/"),t?s?`//${e}`:`//./${e}`:s&&!b(e)?`/${e}`:e)},m=(...e)=>{let t="";for(const s of e)if(s)if(t.length>0){const o=t.at(-1)==="/",r=s[0]==="/";o&&r?t+=s.slice(1):t+=o||r?s:`/${s}`}else t+=s;return Oe(t)},O=function(...e){e=e.map(o=>y(o));let t="",s=!1;for(let o=e.length-1;o>=-1&&!s;o--){const r=o>=0?e[o]:Me();!r||r.length===0||(t=`${r}/${t}`,s=b(r))}return t=oe(t,!s),L.test(t)?`${t}/`:s&&!b(t)?`/${t}`:t.length>0?t:"."},Re=function(e){return je.exec(y(e))?.[1]??""},U=e=>{const t=y(e).replace(Ae,""),s=t.lastIndexOf("/");if(s===-1)return b(e)?"/":".";const o=t.slice(0,s);return L.test(o)?`${o}/`:o||(b(e)?"/":".")},Be=(e,t)=>{const s=y(e);return s.slice(s.lastIndexOf("/")+1)},De=function(e){const t=Ie.exec(e)?.[0]?.replaceAll("\\","/")??"",s=Be(e),o=Re(s);return{base:s,dir:U(e),ext:o,name:s.slice(0,s.length-o.length),root:t}};let Fe;const Le=e=>(Fe??=h(import.meta.url))(e),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ue=e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[t,s]=k.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return k.getBuiltinModule(e)}return Le(e)},{fileURLToPath:Pe}=Ue("node:url");function qe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var V,Z;function We(){return Z||(Z=1,V=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),V}var He=We();const Ge=qe(He);new Set(Ge);const w=e=>y(e instanceof URL?Pe(e):e),ne=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},X=e=>{if(e.isFile())return"file";if(e.isDirectory())return"dir";if(e.isSymbolicLink())return"symlink"};let Ve;const Ze=e=>(Ve??=h(import.meta.url))(e),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xe=e=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[t,s]=E.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return E.getBuiltinModule(e)}return Ze(e)},{lstat:Rt,mkdir:Bt}=Xe("node:fs/promises");let Ye;const Je=e=>(Ye??=h(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ke=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return Je(e)},{lstatSync:Y,mkdirSync:Qe}=Ke("node:fs"),N=e=>{ne(e);try{const t=Y(e);if(!t.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(X(t))}'`);return}catch(t){if(t.code!=="ENOENT")throw t}try{Qe(e,{recursive:!0})}catch(t){if(t.code!=="EEXIST")throw t;const s=Y(e);if(!s.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(X(s))}'`,{cause:t})}};let et;const tt=e=>(et??=h(import.meta.url))(e),S=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,st=e=>{if(typeof S<"u"&&S.versions&&S.versions.node){const[t,s]=S.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return S.getBuiltinModule(e)}return tt(e)},{stat:Dt,lstat:Ft}=st("node:fs/promises");let ot;const nt=e=>(ot??=h(import.meta.url))(e),_=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,rt=e=>{if(typeof _<"u"&&_.versions&&_.versions.node){const[t,s]=_.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return _.getBuiltinModule(e)}return nt(e)},{statSync:it,lstatSync:ct}=rt("node:fs"),lt=(e,t={})=>{const s=t.cwd?w(t.cwd):process.cwd();let o=O(s);const{root:r}=De(o),n=w(t.stopAt??r),c=O(o,n),i=t.type??"file",d=function(l){return[e]};t.allowSymlinks??=!0;const a=t.allowSymlinks?it:ct;for(;o;){for(let l of d()){if(l===Se)return;if(l===void 0)continue;Buffer.isBuffer(l)?l=l.toString():l instanceof URL&&(l=w(l));const u=b(l)?l:O(o,l);try{const f=a(u);if(i==="file"&&f.isFile()||i==="directory"&&f.isDirectory())return u}catch{}}if(o===c||o===r)break;o=U(o)}};let ut;const at=e=>(ut??=h(import.meta.url))(e),C=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ft=e=>{if(typeof C<"u"&&C.versions&&C.versions.node){const[t,s]=C.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return C.getBuiltinModule(e)}return at(e)},{access:Lt}=ft("node:fs/promises");let pt;const dt=e=>(pt??=h(import.meta.url))(e),z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,mt=e=>{if(typeof z<"u"&&z.versions&&z.versions.node){const[t,s]=z.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return z.getBuiltinModule(e)}return dt(e)},{accessSync:gt}=mt("node:fs");function R(e,t=Ne){ne(e),e=w(e);try{return gt(e,t),!0}catch{return!1}}class ht extends Error{constructor(t){super(`ENOENT: ${t}`)}get code(){return"ENOENT"}set code(t){throw new Error("Cannot overwrite code ENOENT")}get name(){return"NotFoundError"}set name(t){throw new Error("Cannot overwrite name of NotFoundError")}}let bt;const yt=e=>(bt??=h(import.meta.url))(e),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,s]=j.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return j.getBuiltinModule(e)}return yt(e)},vt=P("fs"),wt=P("os"),xt=P("path");var F={},J;function Tt(){if(J)return F;J=1;var e=Object.defineProperty,t=(l,u)=>e(l,"name",{value:u,configurable:!0}),s=vt,o=wt,r=xt;const n=t(l=>{let u="";for(let f=0;f<l.length;f+=1){const p=l[f],g=p.toUpperCase();u+=p===g?p.toLowerCase():g}return u},"invertCase"),c=new Map,i=t((l,u)=>{const f=r.join(l,`.is-fs-case-sensitive-test-${process.pid}`);try{return u.writeFileSync(f,""),!u.existsSync(n(f))}finally{try{u.unlinkSync(f)}catch{}}},"checkDirectoryCaseWithWrite"),d=t((l,u,f)=>{try{return i(l,f)}catch(p){if(u===void 0)return i(o.tmpdir(),f);throw p}},"checkDirectoryCaseWithFallback"),a=t((l,u=s,f=!0)=>{const p=l??process.cwd();if(f&&c.has(p))return c.get(p);let g;const q=n(p);return q!==p&&u.existsSync(p)?g=!u.existsSync(q):g=d(p,l,u),f&&c.set(p,g),g},"isFsCaseSensitive");return F.isFsCaseSensitive=a,F}var kt=Tt();kt.isFsCaseSensitive;const K=e=>{const t=Ee();if(G==="win32"){const n=A.LOCALAPPDATA,c=t?m(t,"AppData","Local"):B(),i=n&&n.length>0?n:c;return m(i,e,"Cache")}if(G==="darwin"){const n=t?m(t,"Library","Caches"):B();return m(n,e)}const s=A.XDG_CACHE_HOME,o=t?m(t,".cache"):B(),r=s&&s.length>0?s:o;return m(r,e)},Et=e=>{if(e.length===0)return;const t=e.map(n=>O(w(n)).split(D));let s=Number.POSITIVE_INFINITY;for(const n of t)n.length<s&&(s=n.length);const o=[];for(let n=0;n<s;n+=1){const c=t[0][n];if(t.every(i=>i[n]===c))o.push(c);else break}const r=o.join(D);return r===""?D:r},I=(e,t)=>{if(e!==void 0)return t?(...s)=>m(e,...s):e},$t=e=>{if(e?.files&&e.files.length>0){const t=Et(e.files);if(t!==void 0)return t}return e?.cwd??$e()},Nt=e=>new ht(`No package.json found searching upwards from '${w(e)}'.`),St=e=>!R(e,se)&&R(e),_t=(e,t)=>{if(A.CACHE_DIR&&!["0","1","false","true"].includes(A.CACHE_DIR)){const a=m(A.CACHE_DIR,e);return t?.create&&N(a),I(a,t?.thunk)}const s=$t(t),o=lt("package.json",{cwd:s,type:"file"});if(!o){if(t?.useGlobalCacheFallback){const a=K(e);return t.create&&N(a),I(a,t.thunk)}if(t?.throwError)throw Nt(s);return}const r=U(o),n=m(r,"node_modules"),c=m(n,".cache"),i=m(c,e);if(R(i,se))return t?.create&&N(i),I(i,t?.thunk);const d=[i,c,n];if(R(n)||d.push(r),d.some(a=>St(a))){if(t?.useGlobalCacheFallback){const a=K(e);return t.create&&N(a),I(a,t.thunk)}return}return t?.create&&N(i),I(i,t?.thunk)},Ut=_t,Q="@inherit",Ct=["aliases","dependsOn","inputs","outputs"],zt=(e,t)=>{if(t===void 0)return e===void 0?void 0:[...e];if(!t.includes(Q))return[...t];const s=[];for(const o of t){if(o===Q){e!==void 0&&s.push(...e);continue}s.push(o)}return s},Pt=(e,t)=>{const s={...e,...t};for(const o of Ct){const r=e?.[o],n=t?.[o],c=zt(r,n);c===void 0?delete s[o]:s[o]=c}return s};export{Ot as T,Pt as m,Ut as w};
4
+ `:""}catch(u){if(u.code!=="ENOENT")throw u}const l=c(t,n,d);fe(e,`${l}${a}`,i)};let Te;const ke=e=>(Te??=ee(import.meta.url))(e),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=e=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[t,s]=v.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return v.getBuiltinModule(e)}return ke(e)},{homedir:Ee,tmpdir:D}=te("node:os"),{env:A,cwd:$e,platform:G}=v,{createRequire:h}=te("node:module"),Ne=0,se=2,Se=Symbol("findUpStop"),_e=/^[A-Z]:\//i,y=(e="")=>e&&e.replaceAll("\\","/").replace(_e,t=>t.toUpperCase()),Ce=/^[/\\]{2}/,ze=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,L=/^[A-Z]:$/i,je=/[^/](\.[^./]+)$/,Ie=/^[/\\]|^[a-z]:[/\\]/i,Ae=/\/$/,Me=()=>{if(typeof process.cwd=="function")try{const e=process.cwd();if(typeof e=="string")return y(e)}catch{}return"/"},F="/",oe=(e,t)=>{let s="",o=0,r=-1,n=0,c;for(let i=0;i<=e.length;++i){if(i<e.length)c=e[i];else{if(c==="/")break;c="/"}if(c==="/"){if(!(r===i-1||n===1))if(n===2){if(s.length<2||o!==2||!s.endsWith(".")||s.at(-2)!=="."){if(s.length>2){const d=s.lastIndexOf("/");d===-1?(s="",o=0):(s=s.slice(0,d),o=s.length-1-s.lastIndexOf("/")),r=i,n=0;continue}else if(s.length>0){s="",o=0,r=i,n=0;continue}}t&&(s+=s.length>0?"/..":"..",o=2)}else s.length>0?s+=`/${e.slice(r+1,i)}`:s=e.slice(r+1,i),o=i-r-1;r=i,n=0}else c==="."&&n!==-1?++n:n=-1}return s},b=e=>ze.test(e),Oe=function(e){if(e.length===0)return".";e=y(e);const t=Ce.exec(e),s=b(e),o=e.at(-1)==="/";return e=oe(e,!s),e.length===0?s?"/":o?"./":".":(o&&(e+="/"),L.test(e)&&(e+="/"),t?s?`//${e}`:`//./${e}`:s&&!b(e)?`/${e}`:e)},m=(...e)=>{let t="";for(const s of e)if(s)if(t.length>0){const o=t.at(-1)==="/",r=s[0]==="/";o&&r?t+=s.slice(1):t+=o||r?s:`/${s}`}else t+=s;return Oe(t)},O=function(...e){e=e.map(o=>y(o));let t="",s=!1;for(let o=e.length-1;o>=-1&&!s;o--){const r=o>=0?e[o]:Me();!r||r.length===0||(t=`${r}/${t}`,s=b(r))}return t=oe(t,!s),L.test(t)?`${t}/`:s&&!b(t)?`/${t}`:t.length>0?t:"."},Re=function(e){return je.exec(y(e))?.[1]??""},U=e=>{const t=y(e).replace(Ae,""),s=t.lastIndexOf("/");if(s===-1)return b(e)?"/":".";const o=t.slice(0,s);return L.test(o)?`${o}/`:o||(b(e)?"/":".")},De=(e,t)=>{const s=y(e);return s.slice(s.lastIndexOf("/")+1)},Fe=function(e){const t=Ie.exec(e)?.[0]?.replaceAll("\\","/")??"",s=De(e),o=Re(s);return{base:s,dir:U(e),ext:o,name:s.slice(0,s.length-o.length),root:t}};let Be;const Le=e=>(Be??=h(import.meta.url))(e),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ue=e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[t,s]=k.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return k.getBuiltinModule(e)}return Le(e)},{fileURLToPath:Pe}=Ue("node:url");function qe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var V,Z;function We(){return Z||(Z=1,V=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),V}var He=We();const Ge=qe(He);new Set(Ge);const w=e=>y(e instanceof URL?Pe(e):e),ne=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},X=e=>{if(e.isFile())return"file";if(e.isDirectory())return"dir";if(e.isSymbolicLink())return"symlink"};let Ve;const Ze=e=>(Ve??=h(import.meta.url))(e),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xe=e=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[t,s]=E.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return E.getBuiltinModule(e)}return Ze(e)},{lstat:Rt,mkdir:Dt}=Xe("node:fs/promises");let Ye;const Je=e=>(Ye??=h(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ke=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return Je(e)},{lstatSync:Y,mkdirSync:Qe}=Ke("node:fs"),N=e=>{ne(e);try{const t=Y(e);if(!t.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(X(t))}'`);return}catch(t){if(t.code!=="ENOENT")throw t}try{Qe(e,{recursive:!0})}catch(t){if(t.code!=="EEXIST")throw t;const s=Y(e);if(!s.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(X(s))}'`,{cause:t})}};let et;const tt=e=>(et??=h(import.meta.url))(e),S=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,st=e=>{if(typeof S<"u"&&S.versions&&S.versions.node){const[t,s]=S.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return S.getBuiltinModule(e)}return tt(e)},{stat:Ft,lstat:Bt}=st("node:fs/promises");let ot;const nt=e=>(ot??=h(import.meta.url))(e),_=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,rt=e=>{if(typeof _<"u"&&_.versions&&_.versions.node){const[t,s]=_.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return _.getBuiltinModule(e)}return nt(e)},{statSync:it,lstatSync:ct}=rt("node:fs"),lt=(e,t={})=>{const s=t.cwd?w(t.cwd):process.cwd();let o=O(s);const{root:r}=Fe(o),n=w(t.stopAt??r),c=O(o,n),i=t.type??"file",d=function(l){return[e]};t.allowSymlinks??=!0;const a=t.allowSymlinks?it:ct;for(;o;){for(let l of d()){if(l===Se)return;if(l===void 0)continue;Buffer.isBuffer(l)?l=l.toString():l instanceof URL&&(l=w(l));const u=b(l)?l:O(o,l);try{const f=a(u);if(i==="file"&&f.isFile()||i==="directory"&&f.isDirectory())return u}catch{}}if(o===c||o===r)break;o=U(o)}};let ut;const at=e=>(ut??=h(import.meta.url))(e),C=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ft=e=>{if(typeof C<"u"&&C.versions&&C.versions.node){const[t,s]=C.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return C.getBuiltinModule(e)}return at(e)},{access:Lt}=ft("node:fs/promises");let pt;const dt=e=>(pt??=h(import.meta.url))(e),z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,mt=e=>{if(typeof z<"u"&&z.versions&&z.versions.node){const[t,s]=z.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return z.getBuiltinModule(e)}return dt(e)},{accessSync:gt}=mt("node:fs");function R(e,t=Ne){ne(e),e=w(e);try{return gt(e,t),!0}catch{return!1}}class ht extends Error{constructor(t){super(`ENOENT: ${t}`)}get code(){return"ENOENT"}set code(t){throw new Error("Cannot overwrite code ENOENT")}get name(){return"NotFoundError"}set name(t){throw new Error("Cannot overwrite name of NotFoundError")}}let bt;const yt=e=>(bt??=h(import.meta.url))(e),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,s]=j.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return j.getBuiltinModule(e)}return yt(e)},vt=P("fs"),wt=P("os"),xt=P("path");var B={},J;function Tt(){if(J)return B;J=1;var e=Object.defineProperty,t=(l,u)=>e(l,"name",{value:u,configurable:!0}),s=vt,o=wt,r=xt;const n=t(l=>{let u="";for(let f=0;f<l.length;f+=1){const p=l[f],g=p.toUpperCase();u+=p===g?p.toLowerCase():g}return u},"invertCase"),c=new Map,i=t((l,u)=>{const f=r.join(l,`.is-fs-case-sensitive-test-${process.pid}`);try{return u.writeFileSync(f,""),!u.existsSync(n(f))}finally{try{u.unlinkSync(f)}catch{}}},"checkDirectoryCaseWithWrite"),d=t((l,u,f)=>{try{return i(l,f)}catch(p){if(u===void 0)return i(o.tmpdir(),f);throw p}},"checkDirectoryCaseWithFallback"),a=t((l,u=s,f=!0)=>{const p=l??process.cwd();if(f&&c.has(p))return c.get(p);let g;const q=n(p);return q!==p&&u.existsSync(p)?g=!u.existsSync(q):g=d(p,l,u),f&&c.set(p,g),g},"isFsCaseSensitive");return B.isFsCaseSensitive=a,B}var kt=Tt();kt.isFsCaseSensitive;const K=e=>{const t=Ee();if(G==="win32"){const n=A.LOCALAPPDATA,c=t?m(t,"AppData","Local"):D(),i=n&&n.length>0?n:c;return m(i,e,"Cache")}if(G==="darwin"){const n=t?m(t,"Library","Caches"):D();return m(n,e)}const s=A.XDG_CACHE_HOME,o=t?m(t,".cache"):D(),r=s&&s.length>0?s:o;return m(r,e)},Et=e=>{if(e.length===0)return;const t=e.map(n=>O(w(n)).split(F));let s=Number.POSITIVE_INFINITY;for(const n of t)n.length<s&&(s=n.length);const o=[];for(let n=0;n<s;n+=1){const c=t[0][n];if(t.every(i=>i[n]===c))o.push(c);else break}const r=o.join(F);return r===""?F:r},I=(e,t)=>{if(e!==void 0)return t?(...s)=>m(e,...s):e},$t=e=>{if(e?.files&&e.files.length>0){const t=Et(e.files);if(t!==void 0)return t}return e?.cwd??$e()},Nt=e=>new ht(`No package.json found searching upwards from '${w(e)}'.`),St=e=>!R(e,se)&&R(e),_t=(e,t)=>{if(A.CACHE_DIR&&!["0","1","false","true"].includes(A.CACHE_DIR)){const a=m(A.CACHE_DIR,e);return t?.create&&N(a),I(a,t?.thunk)}const s=$t(t),o=lt("package.json",{cwd:s,type:"file"});if(!o){if(t?.useGlobalCacheFallback){const a=K(e);return t.create&&N(a),I(a,t.thunk)}if(t?.throwError)throw Nt(s);return}const r=U(o),n=m(r,"node_modules"),c=m(n,".cache"),i=m(c,e);if(R(i,se))return t?.create&&N(i),I(i,t?.thunk);const d=[i,c,n];if(R(n)||d.push(r),d.some(a=>St(a))){if(t?.useGlobalCacheFallback){const a=K(e);return t.create&&N(a),I(a,t.thunk)}return}return t?.create&&N(i),I(i,t?.thunk)},Ut=_t,Q="@inherit",Ct=["aliases","dependsOn","inputs","outputs"],zt=(e,t)=>{if(t===void 0)return e===void 0?void 0:[...e];if(!t.includes(Q))return[...t];const s=[];for(const o of t){if(o===Q){e!==void 0&&s.push(...e);continue}s.push(o)}return s},Pt=(e,t)=>{const s={...e,...t};for(const o of Ct){const r=e?.[o],n=t?.[o],c=zt(r,n);c===void 0?delete s[o]:s[o]=c}return s};export{Ot as T,Pt as m,Ut as w};
@@ -1 +1 @@
1
- import{createRequire as $}from"node:module";import{X as j,r as k}from"./index.server-CwSgbeN7.js";import{e as D}from"./index-DHD8wb6Z.js";import{g as M}from"./_commonjsHelpers-DTfxOvZk.js";import{c as g,p as i}from"../packem_chunks/cli-main.js";import{y as A}from"./isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as R}from"./readJsonSync-CbryXYxN-B2aSeDpC.js";let _;const z=e=>(_??=$(import.meta.url))(e),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=e=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[o,r]=l.versions.node.split(".").map(Number);if(o>22||o===22&&r>=3||o===20&&r>=16)return l.getBuiltinModule(e)}return z(e)},{createInterface:S}=T("node:readline");var B=["aj","aju","av","avj","ejv","jav","jv"],C=["angula","angular-node","angularjs"],E=["auto-prefixer"],L=["aaxios","aios","axio","axioos","axios-node","axioss","axis","axiso","axois","axos","axxios"],O=["abel","babbel","babe","babel-js","babel-node","babl","bable","bbael","bebel"],F=["bcrpyt","bcrypt-node","brcypt","crypt","dcrypt"],I=["bcryptjs-node","dcryptjs"],P=["bunan","bunya","bunyan-node","buynan"],U=["cai","cha","chaijs","chal","chi","chia","hai"],W=["cahlk","calk","cchalk","ch4lk","cha1k","chaalk","chaik","chak","chakl","chalk-node","chalkk","challk","chhalk","chlak","chlk","halk","hcalk"],V=["cheero","cherio"],X=["c0lor","ccolor","clor","colo","coloor","color-js","colorjs","colorr","colr","coolor","coolr"],J=["ccolors","colors-node","colorss","colorz","colrs","coolors"],Y=["c0mmander","ccommander","cmmander","cmomander","co-mmander","comamnder","comander","comm4nder","commaander","commader","commadner","commamder","command3r","commandder","commande","commandeer","commander-js","commanderr","commandr","commandre","commanedr","commaner","commannder","commender","commmander","commnader","commnder","coommander","ocmmander","ommander"],G=["cor","corss","cos","cosr","cros","crs","ors"],H=["days"],K=["d3bug","dbeug","dbug","ddebug","debbug","debg","debgu","debu","debu9","debug-js","debug-node","debugg","debugjs","debuug","deebug","deubg","deug","ebug","edbug"],Q=["dot-env","dotenv-node","dotenvjs","dotevn"],Z=["3lectron","eectron","eelctron","eelectron","el3ctron","elcetron","elctron","elecctron","elecron","elecrton","electon","electorn","electr0n","electrn","electrno","electro","electrom","electron-node","electronn","electroon","electrron","electtron","eleectron","eletcron","eletron","ellectron","lectron","leectron"],N=["asbuild","ebuild","esbuild-node","esbuildjs","ezbuild","sbuild"],ee=["aslint","elint","eslint-js","eslint-node","eslit","ezlint","slint"],oe=["eexpress","epress","epxress","experss","expess","exppress","expreess","expres","express-node","expressjs","expresss","exprress","exprses","exprss","exress","exrpess","exxpress","xepress","xpress"],se=["astify"],re=["firebasejs"],te=["form1dable"],ae=["glb","glo","glob-js","globjs","gob","golb","lob"],ce=["go","goot","gotjs","gott","gt","gto","ogt","ot","qot"],ne=["helmetjs","helnet"],ie=["homo","hon","hoo","hoon","ohno","ono"],de=["inquire","inquirer-js","nquirer"],le=["iredis"],me=["ejst","est","jast","jes","jestjs","jestt","jet","jets","jst"],pe=["imp","jim","jip","jmp"],ue=["ji","jio","jo","joii","jol","oi","oji"],he=["jdom","jsdm","jsdo","jsdom-js","jsdon","jsom","sdom"],ve=["jsonwebtoken-js","jsonwebtoken-node"],be=["ka","kao","ko","koaa","koajs","koe","oa","oka"],je=["1odash","iodash","l0dash","ldash","ldoash","llodash","lo-dash","loadsh","loash","lobash","lod4sh","lodaash","lodah","lodahs","lodas","lodash-node","lodashh","lodassh","loddash","lodesh","lodsah","lodsh","loodash","odash","oldash"],ke=["luca","luci","lucie"],fe=["luon","luxo","luxon-js"],ge=["imcromatch","mciromatch","micormatch","micrmoatch","micro-match","microamtch","micromacth","micromathc","micromtach","mircomatch"],ye=["minimath"],xe=["mcha","mmocha","moca","moch","mocha-js","moha","nocha","ocha"],we=["m0ment","mment","mmoent","mmoment","moemnt","moent","mom3nt","momeent","momemt","momen","momen7","momennt","moment-js","momentjs","momentt","momet","mometn","momment","momnet","momnt","monent","mooment","oment","omment"],qe=["mognoose","mogoose","mongoos","mongose","monqoose","moongoose"],$e=["moran","organ"],_e=["muler","multer-js","muter"],ze=["mysql"],Te=["ext","mext","n3xt","naxt","net","netx","nex","next-js","next-node","nextjs","nxt"],Se=["node-mailer","nodemailer-js"],De=["nodemo","nodemonjs","nodmeon"],Me=["oar","or","ora-node","ore","ra","roa"],Ae=["arcel","parce","parceljs"],Re=["passport-js"],Be=["phase","phaser-node"],Ce=["ino","pimo","pin","pino-node","pinojs","pio","pion"],Ee=["playright","playwright-js"],Le=["postcss-js","postcss-node","potscss"],Oe=["pettier","pprettier","pretier","prettierjs","prettierr","prtetier"],Fe=["prima","prism","prisma-js","prismajs","prizma"],Ie=["pupeteer"],Pe=["rada","rama","ramd","randa"],Ue=["eact","eract","r3act","raact","ract","raect","re4ct","reaact","reac","reac7","reacct","react-node","reactjs","reactt","reat","reatc","recat","rect","reeact","reect","rreact"],We=["erdis","radis","rdis","redi","redis-js","redis-node","rediss","rediz","reds","reis","rredis"],Ve=["resen","rsend"],Xe=["ollup","rollup-js","rollup-node"],Je=["ass","asss","sas","sass-node","sess","ssas","sss"],Ye=["emver","seemver","semver-node","semvre","senver","sever"],Ge=["sequelize-js","sequelize-node"],He=["harp","shap","shar","sharp-js","sharpjs"],Ke=["stipe","strip","stripe-node","tripe"],Qe=["supabase-js"],Ze=["suelte","svelt3","svelte-js","sveltejs","velte"],Ne=["tailwindcss-js"],eo=["auri","taui"],oo=["hree","htree","thee","there","three-js","three-node","tree"],so=["stx","sx","ts","tsxx","ttsx","tx","txs","tzx"],ro=["ttypescript","typecript","typescipt","typescript-node","typescriptjs","typescrit","typescritp"],to=["udnerscore","undercore","underscoer","underscore-node","underscroe","undersocre","undesrcore"],ao=["uid","uud","uudi","uui","uuid-js","uuid-node","uuidjs","vuid"],co=["ite","vie","vit","vita","vite-node","vitee","vlte","vte"],no=["itest","uitest","vitestjs","vitezt","vittest","vtest"],io=["ue","uue","uve","ve","veu","vu","vu3","vua","vue-node","vuee","vuejs","vuue","vve","vvue"],lo=["web-pack","weback","webpac","webpack-node","webpackjs","webpak","weebpack","wepack","wepback"],mo=["winson","winston-js","winstoon"],po=["up","uyp","yp","yu","yupjs","yupp"],uo=["od","zd","zdo","zo","zob","zod-js","zodjs"];const ho={ajv:B,angular:C,autoprefixer:E,"aws-sdk":["awssdk","ews-sdk"],axios:L,babel:O,bcrypt:F,bcryptjs:I,"body-parser":["body-paresr","body-parse","body-parser-js","body_parser"],bunyan:P,chai:U,chalk:W,cheerio:V,color:X,colors:J,commander:Y,"cookie-parser":["cookie-parse","cookieparser"],cors:G,"cross-env":["crossenv"],"date-fns":["data-fns","date-fn"],dayjs:H,debug:K,dotenv:Q,electron:Z,esbuild:N,eslint:ee,express:oe,fastify:se,firebase:re,formidable:te,glob:ae,got:ce,helmet:ne,hono:ie,inquirer:de,ioredis:le,jest:me,jimp:pe,joi:ue,jsdom:he,jsonwebtoken:ve,koa:be,lodash:je,lucia:ke,luxon:fe,micromatch:ge,minimatch:ye,mocha:xe,moment:we,mongoose:qe,morgan:$e,multer:_e,mysql2:ze,next:Te,"node-fetch":["node-fecth","node-fethc","node.fetch"],nodemailer:Se,nodemon:De,ora:Me,parcel:Ae,passport:Re,phaser:Be,pino:Ce,playwright:Ee,postcss:Le,prettier:Oe,prisma:Fe,puppeteer:Ie,ramda:Pe,react:Ue,"react-dom":["eact-dom","eract-dom","r3act-dom","ract-dom","raect-dom","re4ct-dom","reaact-dom","reac-dom","reac7-dom","reacct-dom","react-bom","react-d0m","react-ddom","react-dm","react-dmo","react-do","react-domm","react-don","react-doom","react-odm","react-om","react.dom","reactdom","reactt-dom","reat-dom","reatc-dom","recat-dom","rect-dom","reeact-dom","rreact-dom"],redis:We,resend:Ve,rollup:Xe,sass:Je,semver:Ye,sequelize:Ge,sharp:He,"socket.io":["ocket.io","oscket.io","scket.io","scoket.io","soccket.io","socekt.io","socet.io","sock3t.io","socke.io","socke7.io","sockeet.io","socket.1o","socket.i","socket.iio","socket.ioo","socket.lo","socket.o","socket.oi","sockett.io","sockket.io","sockt.io","sockte.io","sokcet.io","soket.io","soocket.io","ssocket.io"],stripe:Ke,supabase:Qe,svelte:Ze,tailwindcss:Ne,tauri:eo,three:oo,"ts-node":["tts-node"],tsx:so,typescript:ro,underscore:to,uuid:ao,vite:co,vitest:no,vue:io,webpack:lo,winston:mo,yup:po,zod:uo};var h,f;function vo(){return f||(f=1,h={"@tanstack/start":["start-tanstack-app","tanstack","tanstack-app","tanstack-start"]}),h}var bo=vo();const jo=M(bo),ko={a:["4","e"],b:["d"],d:["b"],e:["3","a"],g:["9","q"],i:["1","l"],l:["1","i"],m:["n"],n:["m"],o:["0"],s:["5","z"],t:["7"],u:["v"],v:["u"]},fo=["app","cli","core","kit","lib","pkg","sdk"],go=e=>{const o=new Set;if(e.length<3)return o;for(let s=0;s<e.length;s++){const a=e[s],c=a==="-"||a==="."||a==="_";if(c||o.add(e.slice(0,s)+e.slice(s+1)),c||o.add(e.slice(0,s)+a+e.slice(s)),s<e.length-1&&e[s]!==e[s+1]){const u=e[s+1]==="-"||e[s+1]==="."||e[s+1]==="_";if(!c&&!u){const d=[...e];[d[s],d[s+1]]=[d[s+1],d[s]],o.add(d.join(""))}}const n=e[s].toLowerCase(),b=ko[n];if(b)for(const u of b)o.add(e.slice(0,s)+u+e.slice(s+1))}const r=/[-._]/g;if(r.test(e))o.add(e.replaceAll(r,"")),o.add(e.replaceAll(r,"-")),o.add(e.replaceAll(r,".")),o.add(e.replaceAll(r,"_"));else if(e.length>5)for(let s=2;s<e.length-2;s++)o.add(`${e.slice(0,s)}-${e.slice(s)}`),o.add(`${e.slice(0,s)}.${e.slice(s)}`),o.add(`${e.slice(0,s)}_${e.slice(s)}`);if(e.startsWith("@")||(o.add(`${e}-js`),o.add(`${e}js`),o.add(`${e}-node`)),e.startsWith("@")){const s=e.indexOf("/");if(s>1&&s<e.length-1){const a=e.slice(1,s),c=e.slice(s+1);a.length>=3&&o.add(a);for(const n of["","-",".","_"])o.add(`${a}${n}${c}`),o.add(`${c}${n}${a}`);for(const n of fo)o.add(`${a}-${n}`),o.add(`${c}-${a}-${n}`),o.add(`${n}-${a}-${c}`)}}return o.delete(e),o};let v,p,m;const y=()=>{if(!v){const e={};for(const o of[ho,jo])for(const[r,t]of Object.entries(o)){const s=e[r]??(e[r]=[]);for(const a of t)s.includes(a)||s.push(a)}v=e}return v},yo=()=>{if(!p){p=new Map;for(const[e,o]of Object.entries(y()))for(const r of o)p.set(r,e)}return p},xo=()=>{if(!m){m=new Map;for(const e of Object.keys(y()))for(const o of go(e))m.has(o)||m.set(o,e)}return m},wo=e=>e.startsWith("@")?e.split("/")[1]??e:e,qo=e=>{const o=wo(e),r=yo().get(o);if(r)return{input:e,legitimate:r,method:"blocklist"};const t=xo().get(o);if(t)return{input:e,legitimate:t,method:"heuristic"}},x=(e,o)=>{const r=o?new Set(o):void 0,t=[];for(const s of e){if(r?.has(s))continue;const a=qo(s);a&&t.push(a)}return t},w=(e,o)=>{i.warn(""),i.warn(j(`Possible typosquat${e.length===1?"":"s"} ${o}:`));for(const r of e){const t=r.method==="blocklist"?"known typosquat":"similar name";i.warn(` ${k("⚠")} ${j(r.input)} — did you mean ${k(r.legitimate)}? (${t})`)}i.warn("")},q=async e=>{if(!process.stdin.isTTY){i.warn("Aborting: potential typosquat detected in non-interactive mode. Use --no-typosquat-check to skip.");return}const o=S({input:process.stdin,output:process.stdout}),r=await new Promise(t=>{o.question(e,s=>{t(s.trim().toLowerCase())})});return o.close(),r},Co=async(e,o)=>{if(g("typosquats"))return{ok:!0,packages:e};const r=x(e,o);if(r.length===0)return{ok:!0,packages:e};w(r,"detected");const t=await q(`Use suggested package${r.length===1?"":"s"} instead? [S]uggested / [y]es, keep original / [N]o, abort (default: N) `);if(t===void 0)return{ok:!1,packages:e};if(t==="s"||t==="suggested"){const s=new Map(r.map(c=>[c.input,c.legitimate]));return{ok:!0,packages:e.map(c=>s.get(c)??c)}}return t==="y"||t==="yes"?{ok:!0,packages:e}:{ok:!1,packages:e}},$o=/^(?:npm|pnpm|yarn):(.+?)(?:@.*)?$/,_o=e=>$o.exec(e)?.[1],zo=e=>{if(!A(e))return[];const o=R(e),r={...o.dependencies,...o.devDependencies,...o.optionalDependencies,...o.peerDependencies},t=new Set;for(const[s,a]of Object.entries(r)){t.add(s);const c=_o(a);c&&t.add(c)}return[...t]},Eo=async(e,o)=>{if(g("typosquats"))return!0;const r=D(e,"package.json"),t=zo(r);if(t.length===0)return!0;const s=x(t,o);if(s.length===0)return!0;w(s,"in package.json dependencies"),i.warn("Fix the package name in package.json before proceeding.");const a=await q("Continue anyway? [y/N] ");return a==="y"||a==="yes"};export{Co as r,Eo as s};
1
+ import{createRequire as $}from"node:module";import{X as j,b as k}from"./index.server-BAjDJSEu.js";import{e as D}from"./index-DHD8wb6Z.js";import{g as M}from"./_commonjsHelpers-DTfxOvZk.js";import{c as g,p as i}from"../packem_chunks/cli-main.js";import{y as A}from"./isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as R}from"./readJsonSync-CbryXYxN-B2aSeDpC.js";let _;const z=e=>(_??=$(import.meta.url))(e),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=e=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[o,r]=l.versions.node.split(".").map(Number);if(o>22||o===22&&r>=3||o===20&&r>=16)return l.getBuiltinModule(e)}return z(e)},{createInterface:S}=T("node:readline");var B=["aj","aju","av","avj","ejv","jav","jv"],C=["angula","angular-node","angularjs"],E=["auto-prefixer"],L=["aaxios","aios","axio","axioos","axios-node","axioss","axis","axiso","axois","axos","axxios"],O=["abel","babbel","babe","babel-js","babel-node","babl","bable","bbael","bebel"],F=["bcrpyt","bcrypt-node","brcypt","crypt","dcrypt"],I=["bcryptjs-node","dcryptjs"],P=["bunan","bunya","bunyan-node","buynan"],U=["cai","cha","chaijs","chal","chi","chia","hai"],W=["cahlk","calk","cchalk","ch4lk","cha1k","chaalk","chaik","chak","chakl","chalk-node","chalkk","challk","chhalk","chlak","chlk","halk","hcalk"],V=["cheero","cherio"],X=["c0lor","ccolor","clor","colo","coloor","color-js","colorjs","colorr","colr","coolor","coolr"],J=["ccolors","colors-node","colorss","colorz","colrs","coolors"],Y=["c0mmander","ccommander","cmmander","cmomander","co-mmander","comamnder","comander","comm4nder","commaander","commader","commadner","commamder","command3r","commandder","commande","commandeer","commander-js","commanderr","commandr","commandre","commanedr","commaner","commannder","commender","commmander","commnader","commnder","coommander","ocmmander","ommander"],G=["cor","corss","cos","cosr","cros","crs","ors"],H=["days"],K=["d3bug","dbeug","dbug","ddebug","debbug","debg","debgu","debu","debu9","debug-js","debug-node","debugg","debugjs","debuug","deebug","deubg","deug","ebug","edbug"],Q=["dot-env","dotenv-node","dotenvjs","dotevn"],Z=["3lectron","eectron","eelctron","eelectron","el3ctron","elcetron","elctron","elecctron","elecron","elecrton","electon","electorn","electr0n","electrn","electrno","electro","electrom","electron-node","electronn","electroon","electrron","electtron","eleectron","eletcron","eletron","ellectron","lectron","leectron"],N=["asbuild","ebuild","esbuild-node","esbuildjs","ezbuild","sbuild"],ee=["aslint","elint","eslint-js","eslint-node","eslit","ezlint","slint"],oe=["eexpress","epress","epxress","experss","expess","exppress","expreess","expres","express-node","expressjs","expresss","exprress","exprses","exprss","exress","exrpess","exxpress","xepress","xpress"],se=["astify"],re=["firebasejs"],te=["form1dable"],ae=["glb","glo","glob-js","globjs","gob","golb","lob"],ce=["go","goot","gotjs","gott","gt","gto","ogt","ot","qot"],ne=["helmetjs","helnet"],ie=["homo","hon","hoo","hoon","ohno","ono"],de=["inquire","inquirer-js","nquirer"],le=["iredis"],me=["ejst","est","jast","jes","jestjs","jestt","jet","jets","jst"],pe=["imp","jim","jip","jmp"],ue=["ji","jio","jo","joii","jol","oi","oji"],he=["jdom","jsdm","jsdo","jsdom-js","jsdon","jsom","sdom"],ve=["jsonwebtoken-js","jsonwebtoken-node"],be=["ka","kao","ko","koaa","koajs","koe","oa","oka"],je=["1odash","iodash","l0dash","ldash","ldoash","llodash","lo-dash","loadsh","loash","lobash","lod4sh","lodaash","lodah","lodahs","lodas","lodash-node","lodashh","lodassh","loddash","lodesh","lodsah","lodsh","loodash","odash","oldash"],ke=["luca","luci","lucie"],fe=["luon","luxo","luxon-js"],ge=["imcromatch","mciromatch","micormatch","micrmoatch","micro-match","microamtch","micromacth","micromathc","micromtach","mircomatch"],ye=["minimath"],xe=["mcha","mmocha","moca","moch","mocha-js","moha","nocha","ocha"],we=["m0ment","mment","mmoent","mmoment","moemnt","moent","mom3nt","momeent","momemt","momen","momen7","momennt","moment-js","momentjs","momentt","momet","mometn","momment","momnet","momnt","monent","mooment","oment","omment"],qe=["mognoose","mogoose","mongoos","mongose","monqoose","moongoose"],$e=["moran","organ"],_e=["muler","multer-js","muter"],ze=["mysql"],Te=["ext","mext","n3xt","naxt","net","netx","nex","next-js","next-node","nextjs","nxt"],Se=["node-mailer","nodemailer-js"],De=["nodemo","nodemonjs","nodmeon"],Me=["oar","or","ora-node","ore","ra","roa"],Ae=["arcel","parce","parceljs"],Re=["passport-js"],Be=["phase","phaser-node"],Ce=["ino","pimo","pin","pino-node","pinojs","pio","pion"],Ee=["playright","playwright-js"],Le=["postcss-js","postcss-node","potscss"],Oe=["pettier","pprettier","pretier","prettierjs","prettierr","prtetier"],Fe=["prima","prism","prisma-js","prismajs","prizma"],Ie=["pupeteer"],Pe=["rada","rama","ramd","randa"],Ue=["eact","eract","r3act","raact","ract","raect","re4ct","reaact","reac","reac7","reacct","react-node","reactjs","reactt","reat","reatc","recat","rect","reeact","reect","rreact"],We=["erdis","radis","rdis","redi","redis-js","redis-node","rediss","rediz","reds","reis","rredis"],Ve=["resen","rsend"],Xe=["ollup","rollup-js","rollup-node"],Je=["ass","asss","sas","sass-node","sess","ssas","sss"],Ye=["emver","seemver","semver-node","semvre","senver","sever"],Ge=["sequelize-js","sequelize-node"],He=["harp","shap","shar","sharp-js","sharpjs"],Ke=["stipe","strip","stripe-node","tripe"],Qe=["supabase-js"],Ze=["suelte","svelt3","svelte-js","sveltejs","velte"],Ne=["tailwindcss-js"],eo=["auri","taui"],oo=["hree","htree","thee","there","three-js","three-node","tree"],so=["stx","sx","ts","tsxx","ttsx","tx","txs","tzx"],ro=["ttypescript","typecript","typescipt","typescript-node","typescriptjs","typescrit","typescritp"],to=["udnerscore","undercore","underscoer","underscore-node","underscroe","undersocre","undesrcore"],ao=["uid","uud","uudi","uui","uuid-js","uuid-node","uuidjs","vuid"],co=["ite","vie","vit","vita","vite-node","vitee","vlte","vte"],no=["itest","uitest","vitestjs","vitezt","vittest","vtest"],io=["ue","uue","uve","ve","veu","vu","vu3","vua","vue-node","vuee","vuejs","vuue","vve","vvue"],lo=["web-pack","weback","webpac","webpack-node","webpackjs","webpak","weebpack","wepack","wepback"],mo=["winson","winston-js","winstoon"],po=["up","uyp","yp","yu","yupjs","yupp"],uo=["od","zd","zdo","zo","zob","zod-js","zodjs"];const ho={ajv:B,angular:C,autoprefixer:E,"aws-sdk":["awssdk","ews-sdk"],axios:L,babel:O,bcrypt:F,bcryptjs:I,"body-parser":["body-paresr","body-parse","body-parser-js","body_parser"],bunyan:P,chai:U,chalk:W,cheerio:V,color:X,colors:J,commander:Y,"cookie-parser":["cookie-parse","cookieparser"],cors:G,"cross-env":["crossenv"],"date-fns":["data-fns","date-fn"],dayjs:H,debug:K,dotenv:Q,electron:Z,esbuild:N,eslint:ee,express:oe,fastify:se,firebase:re,formidable:te,glob:ae,got:ce,helmet:ne,hono:ie,inquirer:de,ioredis:le,jest:me,jimp:pe,joi:ue,jsdom:he,jsonwebtoken:ve,koa:be,lodash:je,lucia:ke,luxon:fe,micromatch:ge,minimatch:ye,mocha:xe,moment:we,mongoose:qe,morgan:$e,multer:_e,mysql2:ze,next:Te,"node-fetch":["node-fecth","node-fethc","node.fetch"],nodemailer:Se,nodemon:De,ora:Me,parcel:Ae,passport:Re,phaser:Be,pino:Ce,playwright:Ee,postcss:Le,prettier:Oe,prisma:Fe,puppeteer:Ie,ramda:Pe,react:Ue,"react-dom":["eact-dom","eract-dom","r3act-dom","ract-dom","raect-dom","re4ct-dom","reaact-dom","reac-dom","reac7-dom","reacct-dom","react-bom","react-d0m","react-ddom","react-dm","react-dmo","react-do","react-domm","react-don","react-doom","react-odm","react-om","react.dom","reactdom","reactt-dom","reat-dom","reatc-dom","recat-dom","rect-dom","reeact-dom","rreact-dom"],redis:We,resend:Ve,rollup:Xe,sass:Je,semver:Ye,sequelize:Ge,sharp:He,"socket.io":["ocket.io","oscket.io","scket.io","scoket.io","soccket.io","socekt.io","socet.io","sock3t.io","socke.io","socke7.io","sockeet.io","socket.1o","socket.i","socket.iio","socket.ioo","socket.lo","socket.o","socket.oi","sockett.io","sockket.io","sockt.io","sockte.io","sokcet.io","soket.io","soocket.io","ssocket.io"],stripe:Ke,supabase:Qe,svelte:Ze,tailwindcss:Ne,tauri:eo,three:oo,"ts-node":["tts-node"],tsx:so,typescript:ro,underscore:to,uuid:ao,vite:co,vitest:no,vue:io,webpack:lo,winston:mo,yup:po,zod:uo};var h,f;function vo(){return f||(f=1,h={"@tanstack/start":["start-tanstack-app","tanstack","tanstack-app","tanstack-start"]}),h}var bo=vo();const jo=M(bo),ko={a:["4","e"],b:["d"],d:["b"],e:["3","a"],g:["9","q"],i:["1","l"],l:["1","i"],m:["n"],n:["m"],o:["0"],s:["5","z"],t:["7"],u:["v"],v:["u"]},fo=["app","cli","core","kit","lib","pkg","sdk"],go=e=>{const o=new Set;if(e.length<3)return o;for(let s=0;s<e.length;s++){const a=e[s],c=a==="-"||a==="."||a==="_";if(c||o.add(e.slice(0,s)+e.slice(s+1)),c||o.add(e.slice(0,s)+a+e.slice(s)),s<e.length-1&&e[s]!==e[s+1]){const u=e[s+1]==="-"||e[s+1]==="."||e[s+1]==="_";if(!c&&!u){const d=[...e];[d[s],d[s+1]]=[d[s+1],d[s]],o.add(d.join(""))}}const n=e[s].toLowerCase(),b=ko[n];if(b)for(const u of b)o.add(e.slice(0,s)+u+e.slice(s+1))}const r=/[-._]/g;if(r.test(e))o.add(e.replaceAll(r,"")),o.add(e.replaceAll(r,"-")),o.add(e.replaceAll(r,".")),o.add(e.replaceAll(r,"_"));else if(e.length>5)for(let s=2;s<e.length-2;s++)o.add(`${e.slice(0,s)}-${e.slice(s)}`),o.add(`${e.slice(0,s)}.${e.slice(s)}`),o.add(`${e.slice(0,s)}_${e.slice(s)}`);if(e.startsWith("@")||(o.add(`${e}-js`),o.add(`${e}js`),o.add(`${e}-node`)),e.startsWith("@")){const s=e.indexOf("/");if(s>1&&s<e.length-1){const a=e.slice(1,s),c=e.slice(s+1);a.length>=3&&o.add(a);for(const n of["","-",".","_"])o.add(`${a}${n}${c}`),o.add(`${c}${n}${a}`);for(const n of fo)o.add(`${a}-${n}`),o.add(`${c}-${a}-${n}`),o.add(`${n}-${a}-${c}`)}}return o.delete(e),o};let v,p,m;const y=()=>{if(!v){const e={};for(const o of[ho,jo])for(const[r,t]of Object.entries(o)){const s=e[r]??(e[r]=[]);for(const a of t)s.includes(a)||s.push(a)}v=e}return v},yo=()=>{if(!p){p=new Map;for(const[e,o]of Object.entries(y()))for(const r of o)p.set(r,e)}return p},xo=()=>{if(!m){m=new Map;for(const e of Object.keys(y()))for(const o of go(e))m.has(o)||m.set(o,e)}return m},wo=e=>e.startsWith("@")?e.split("/")[1]??e:e,qo=e=>{const o=wo(e),r=yo().get(o);if(r)return{input:e,legitimate:r,method:"blocklist"};const t=xo().get(o);if(t)return{input:e,legitimate:t,method:"heuristic"}},x=(e,o)=>{const r=o?new Set(o):void 0,t=[];for(const s of e){if(r?.has(s))continue;const a=qo(s);a&&t.push(a)}return t},w=(e,o)=>{i.warn(""),i.warn(j(`Possible typosquat${e.length===1?"":"s"} ${o}:`));for(const r of e){const t=r.method==="blocklist"?"known typosquat":"similar name";i.warn(` ${k("⚠")} ${j(r.input)} — did you mean ${k(r.legitimate)}? (${t})`)}i.warn("")},q=async e=>{if(!process.stdin.isTTY){i.warn("Aborting: potential typosquat detected in non-interactive mode. Use --no-typosquat-check to skip.");return}const o=S({input:process.stdin,output:process.stdout}),r=await new Promise(t=>{o.question(e,s=>{t(s.trim().toLowerCase())})});return o.close(),r},Co=async(e,o)=>{if(g("typosquats"))return{ok:!0,packages:e};const r=x(e,o);if(r.length===0)return{ok:!0,packages:e};w(r,"detected");const t=await q(`Use suggested package${r.length===1?"":"s"} instead? [S]uggested / [y]es, keep original / [N]o, abort (default: N) `);if(t===void 0)return{ok:!1,packages:e};if(t==="s"||t==="suggested"){const s=new Map(r.map(c=>[c.input,c.legitimate]));return{ok:!0,packages:e.map(c=>s.get(c)??c)}}return t==="y"||t==="yes"?{ok:!0,packages:e}:{ok:!1,packages:e}},$o=/^(?:npm|pnpm|yarn):(.+?)(?:@.*)?$/,_o=e=>$o.exec(e)?.[1],zo=e=>{if(!A(e))return[];const o=R(e),r={...o.dependencies,...o.devDependencies,...o.optionalDependencies,...o.peerDependencies},t=new Set;for(const[s,a]of Object.entries(r)){t.add(s);const c=_o(a);c&&t.add(c)}return[...t]},Eo=async(e,o)=>{if(g("typosquats"))return!0;const r=D(e,"package.json"),t=zo(r);if(t.length===0)return!0;const s=x(t,o);if(s.length===0)return!0;w(s,"in package.json dependencies"),i.warn("Fix the package name in package.json before proceeding.");const a=await q("Continue anyway? [y/N] ");return a==="y"||a==="yes"};export{Co as r,Eo as s};
@@ -1,4 +1,4 @@
1
- import{createRequire as It}from"node:module";import{b as he,u as Ut,c as W,h as jt,i as be,d as Vt,a as Dt,l as Tt,e as Ie}from"./package-version-BJkg7-6H.js";let St;const Lt=t=>(St??=It(import.meta.url))(t),ne=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Mt=t=>{if(typeof ne<"u"&&ne.versions&&ne.versions.node){const[e,n]=ne.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ne.getBuiltinModule(t)}return Lt(t)},{createRequire:Pt}=Mt("node:module"),Rt=16,fe=32,Bt=64,T=128,le="positionals";let te=class extends Error{loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:o,message:i,name:s,stack:l,title:a}){super(i,{cause:e}),this.title=a,this.name=s,this.stack=l??this.stack,this.loc=o,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}},b=class extends te{code;context;constructor(e,n,o){super({message:e,name:"CerebroError"}),this.code=n,this.context=o}};const nt=String.raw,Se=nt`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,zt=()=>new RegExp(nt`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${Se}(?:\u200D${Se})*`,"gu");Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]]));const Zs=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,Ys=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,F=zt(),Wt=/[-_./\s]+/g,ce=/(\u001B\[[0-9;]*[a-z])/i,Le=new RegExp("\\p{Script=Arabic}","u"),Ft=new RegExp("\\p{Script=Bengali}","u"),X=new RegExp("\\p{Script=Cyrillic}","u"),qt=new RegExp("\\p{Script=Devanagari}","u"),Gt=new RegExp("\\p{Script=Ethiopic}","u"),me=new RegExp("\\p{Script=Greek}","u"),Me=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),Jt=new RegExp("\\p{Script=Gujarati}","u"),Ht=new RegExp("\\p{Script=Gurmukhi}","u"),Pe=new RegExp("\\p{Script=Hangul}","u"),Ue=new RegExp("\\p{Script=Hebrew}","u"),Kt=new RegExp("\\p{Script=Hiragana}","u"),je=new RegExp("\\p{Script=Han}","u"),Zt=new RegExp("\\p{Script=Kannada}","u"),Yt=new RegExp("\\p{Script=Katakana}","u"),Xt=new RegExp("\\p{Script=Khmer}","u"),Qt=new RegExp("\\p{Script=Lao}","u"),L=new RegExp("\\p{Script=Latin}","u"),en=new RegExp("\\p{Script=Malayalam}","u"),tn=new RegExp("\\p{Script=Myanmar}","u"),nn=new RegExp("\\p{Script=Oriya}","u"),on=new RegExp("\\p{Script=Sinhala}","u"),sn=new RegExp("\\p{Script=Tamil}","u"),rn=new RegExp("\\p{Script=Telugu}","u"),an=new RegExp("\\p{Script=Thai}","u"),ln=new RegExp("\\p{Script=Tibetan}","u"),Ve=/[\u02BB\u02BC\u0027]/u,cn=t=>t.replace(F,""),R=new Uint32Array(65536),un=(t,e)=>{const n=t.length,o=e.length,i=1<<n-1;let s=-1,l=0,a=n,u=n;for(;u--;)R[t.charCodeAt(u)]|=1<<u;for(u=0;u<o;u++){let r=R[e.charCodeAt(u)];const c=r|l;r|=(r&s)+s^s,l|=~(r|s),s&=r,l&i&&a++,s&i&&a--,l=l<<1|1,s=s<<1|~(c|l),l&=c}for(u=n;u--;)R[t.charCodeAt(u)]=0;return a},hn=(t,e)=>{const n=e.length,o=t.length,i=[],s=[],l=Math.ceil(n/32),a=Math.ceil(o/32);for(let p=0;p<l;p++)s[p]=-1,i[p]=0;let u=0;for(;u<a-1;u++){let p=0,w=-1;const $=u*32,m=Math.min(32,o)+$;for(let v=$;v<m;v++)R[t.charCodeAt(v)]|=1<<v;for(let v=0;v<n;v++){const A=R[e.charCodeAt(v)],k=s[v/32|0]>>>v&1,C=i[v/32|0]>>>v&1,j=A|p,_=((A|C)&w)+w^w|A|C;let g=p|~(_|w),y=w&_;g>>>31^k&&(s[v/32|0]^=1<<v),y>>>31^C&&(i[v/32|0]^=1<<v),g=g<<1|k,y=y<<1|C,w=y|~(j|g),p=g&j}for(let v=$;v<m;v++)R[t.charCodeAt(v)]=0}let r=0,c=-1;const d=u*32,h=Math.min(32,o-d)+d;for(let p=d;p<h;p++)R[t.charCodeAt(p)]|=1<<p;let f=o;for(let p=0;p<n;p++){const w=R[e.charCodeAt(p)],$=s[p/32|0]>>>p&1,m=i[p/32|0]>>>p&1,v=w|r,A=((w|m)&c)+c^c|w|m;let k=r|~(A|c),C=c&A;f+=k>>>o-1&1,f-=C>>>o-1&1,k>>>31^$&&(s[p/32|0]^=1<<p),C>>>31^m&&(i[p/32|0]^=1<<p),k=k<<1|$,C=C<<1|m,c=C|~(v|k),r=k&v}for(let p=d;p<h;p++)R[t.charCodeAt(p)]=0;return f},pn=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return e.length===0?t.length:t.length<=32?un(t,e):hn(t,e)};let dn;const fn=t=>(dn??=Pt(import.meta.url))(t),oe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,mn=t=>{if(typeof oe<"u"&&oe.versions&&oe.versions.node){const[e,n]=oe.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return oe.getBuiltinModule(t)}return fn(t)},{writeFile:gn,stat:wn,rm:yn,readFile:De,readdir:vn,mkdir:$n,access:xn}=mn("node:fs/promises"),re=[{alias:"v",description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];let G=class extends b{commandName;constructor(e,n=[]){const o=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(o,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}},ot=class extends b{option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}};class An extends b{unknownOptions;constructor(e,n){const o=e.join(", "),i=`Found unknown ${e.length===1?"option":"options"}: ${o}`;super(i,"UNKNOWN_OPTION",{suggestions:n,unknownOptions:e}),this.name="UnknownOptionError",this.unknownOptions=e,n&&n.length>0&&(this.hint=`Did you mean: ${n.join(", ")}?`)}}class Nn extends b{pluginName;constructor(e,n,o){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:o,pluginName:e}),this.name="PluginError",this.pluginName=e,o&&(this.cause=o)}}class bn{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(e){this.logger=e}hasPlugins(){return this.plugins.size>0}register(e){if(this.initialized)throw new Error(`Cannot register plugin "${e.name}" after initialization`);if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);he().CEREBRO_OUTPUT_LEVEL===String(T)&&this.logger.debug(`registering plugin: ${e.name}`),this.plugins.set(e.name,e),this.cachedDependencyOrder=void 0}async init(e){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const n=this.getDependencyOrder();this.logger.debug(`initializing ${String(n.length)} plugin(s)...`);for(const o of n)if(typeof o.init=="function"){this.logger.debug(`initializing plugin: ${o.name}`);try{await o.init(e)}catch(i){const s=new Nn(o.name,`Failed to initialize: ${i instanceof Error?i.message:String(i)}`,i instanceof Error?i:void 0);throw this.logger.error(s.message),s}}this.initialized=!0}async executeLifecycle(e,n,o){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const i=this.getDependencyOrder();for(const s of i){const l=s[e];if(typeof l=="function"){this.logger.debug(`executing ${e} hook for plugin: ${s.name}`);try{await(e==="afterCommand"?l(n,o):l(n))}catch(a){throw this.logger.error(`Error in ${e} hook for plugin "${s.name}":`,a),a}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const o=this.getDependencyOrder();for(const i of o)if(typeof i.onError=="function"){this.logger.debug(`executing error handler for plugin: ${i.name}`);try{await i.onError(e,n)}catch(s){this.logger.error(`Error in error handler for plugin "${i.name}":`,s)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,o=new Set,i=s=>{if(n.has(s))return;if(o.has(s))throw new Error(`Circular dependency detected involving plugin "${s}"`);const l=this.plugins.get(s);if(!l)throw new Error(`Plugin "${s}" not found`);if(o.add(s),l.dependencies)for(const a of l.dependencies)i(a);o.delete(s),n.add(s),e.push(l)};for(const s of this.plugins.keys())i(s);return this.cachedDependencyOrder=e,e}validateDependencies(){for(const e of this.plugins.values())if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin "${e.name}" depends on "${n}" which is not registered`)}}}const se=t=>t.type?.name==="Boolean",Cn=t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},Te=t=>(se(t)||(t.typeLabel=t.typeLabel??Cn(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),kn=new RegExp(/^-([^\d-])$/),En=new RegExp(/^--(\S+)/),On=new RegExp(/^-([^\d-]{2,})$/),_n=t=>kn.test(t)||En.test(t)||On.test(t),In=(t,e)=>{const n=e[0]&&_n(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const o=new Error(`Command not recognised: ${String(n)}`);throw o.command=n,o.name="INVALID_COMMAND",o}return{argv:e,command:n}};let Sn=class st extends te{optionName;value;constructor(e,n,o){super({hint:`Pass a valid ${o} value for '${e}'.`,message:`Invalid ${o} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,st.prototype)}},Ln=class it extends te{optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,it.prototype)}},Re=class rt extends te{optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,rt.prototype)}},Mn=class at extends te{value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,at.prototype)}},M=class lt extends te{constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,lt.prototype)}};const H=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",Ce=t=>t===Number||typeof t=="function"&&t.name==="Number",Be=t=>t===String||typeof t=="function"&&t.name==="String",ze=(t,e,n)=>{const o=Number(t);if(e&&Number.isNaN(o)&&String(t).trim().toLowerCase()!=="nan")throw new Sn(n??"",String(t),"Number");return o},Pn=(t,e,n={})=>{const{optionName:o,strictTypes:i}=n;return Array.isArray(t)?H(e)?t.map(Boolean):Ce(e)?t.map(s=>ze(s,i,o)):Be(e)?t.map(String):t.map(s=>e(String(s))):t===null?null:H(e)?!!t:Ce(e)?ze(t,i,o):Be(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},O=(t,e,n,...o)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...o)},Un=/-([a-z])/g,jn=/^\d+$/,Vn=t=>t.codePointAt(0)===95,We=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],Fe=t=>t==="__proto__"||t==="constructor"||t==="prototype",ge=(t,e,n,o=!1)=>{t[e]===void 0?t[e]=o?[n]:n:o&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},qe=(t,e,n,o,i)=>{let s=e.get(t)??n.get(t);if(!s&&o){const l=t.toLowerCase();s=o.get(l)??i?.get(l)}return s},Dn=(t,e,n,o)=>{const i=n.debug??!1;O(i,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),O(i,"Starting argument resolution","resolver"),O(i,"Tokens:","resolver",t),O(i,"Definitions:","resolver",e),O(i,"Processing tokens...","resolver");const s=new Map,l=new Map,a=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,c=n.camelCase?new Map:void 0;for(const g of e)if(s.set(g.name,g),g.alias&&l.set(g.alias,g),n.caseInsensitive&&a&&(a.set(g.name.toLowerCase(),g),g.alias&&u&&u.set(g.alias.toLowerCase(),g)),n.camelCase&&r&&c){const y=g.name.replaceAll(Un,(x,I)=>I.toUpperCase());r.set(g.name,y),c.set(y,g.name)}const d=Object.create(null),h=Object.create(null),f=[],p=[],w=new Set;let $=!1;const m=e.find(g=>g.defaultOption),v=e.some(g=>g.group),A=e.find(g=>Ce(g.type));for(let g=0;g<t.length;g++){const y=t[g];if(y.kind==="option-terminator"){d._unknown=o.slice(y.index),$=!0;break}if(y.kind==="option"&&y.name){let x=qe(y.name,s,l,a,u);!x&&y.value===void 0&&A&&jn.test(y.name)&&(x=A,y.value=y.name,y.name=A.name);let I=!1;if(!x&&n.negation&&y.value===void 0&&y.name.startsWith("no-")){const E=y.name.slice(3),U=qe(E,s,l,a,u);U?.type&&H(U.type)&&(x=U,I=!0)}const N=x?x.name:y.name,S=x?.multiple,P=x?.lazyMultiple;if(Object.hasOwn(h,N)&&h[N]!==void 0&&!S&&!P&&!n.partial)throw new Ln(N);if(!x&&n.partial){const E=y.rawName??`--${y.name}${y.value!==void 0&&y.inlineValue?`=${y.value}`:""}`;f.push({index:y.index,value:E});continue}if(!x&&n.stopAtFirstUnknown){d._unknown=o.slice(y.index);break}if(!x&&!n.partial)throw new Re(y.name);if(y.value===void 0){const E=t[g+1],U=E?.kind==="option"&&!("name"in E)&&E.value!==void 0,V=E&&x&&!(x.type&&H(x.type))&&(E.kind==="positional"||U),_t=x&&x.defaultOption&&!x.multiple&&!x.lazyMultiple;if(V&&(!x?.defaultOption||_t))if(S){let D=g+1;const de=[];for(;D<t.length&&(t[D].kind==="positional"||t[D].kind==="option"&&!("name"in t[D])&&t[D].value!==void 0);)de.push(t[D].value),w.add(t[D].index),D++;h[N]=h[N]===void 0?de:We(h[N],de),g=D-1}else P?(ge(h,N,E.value,!0),w.add(E.index),g++):(h[N]=E.value,w.add(E.index),g++);else x?.type&&H(x.type)?ge(h,N,!I,S):(S||P)&&h[N]!==void 0?ge(h,N,null,!0):h[N]=S?[]:null}else{let{value:E}=y;if(x?.type&&H(x.type))switch(E){case"":{if(n.partial){const V=`${y.rawName??`--${y.name}`}${y.value?`=${y.value}`:""}`;p.push({index:y.index,value:V}),E=!0}else throw new Re(y.name);break}case"false":{E=!1;break}case"true":{E=!0;break}default:E=!0}const U=[E];if(S){let V=g+1;for(;V<t.length&&t[V].kind==="positional";)U.push(t[V].value),w.add(t[V].index),V++;g=V-1}h[N]===void 0?h[N]=S||P?U:E:S||P?h[N]=We(h[N],U):h[N]=E}}else if(y.kind==="positional"&&n.stopAtFirstUnknown&&!w.has(y.index)&&!m){O(i,`Found unconsumed positional token at index ${String(y.index)}, stopping processing`,"resolver"),d._unknown=o.slice(y.index);break}}for(const[g,y]of Object.entries(h)){const x=s.get(g);x&&(x.multiple||x.lazyMultiple)&&!Array.isArray(y)&&(h[g]=[y])}const k=g=>g.kind==="option"&&!s.has(g.name??"")&&!l.has(g.name??"")&&(!n.caseInsensitive||!a?.has(g.name?.toLowerCase()??"")&&!u?.has(g.name?.toLowerCase()??""));let C=-1,j=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!$&&(C=t.findIndex(g=>k(g)),C!==-1&&(j=t[C].index)),m){const g=[],y=[];for(const x of t)x.kind==="positional"&&!w.has(x.index)&&x.index<j&&(g.push(x.value),y.push(x));if(g.length>0){const x=h[m.name],I=m.multiple??m.lazyMultiple;x===void 0?I?(y.forEach(N=>w.add(N.index)),h[m.name]=g):(w.add(y[0].index),h[m.name]=g[0]):I&&(y.forEach(N=>w.add(N.index)),h[m.name]=Array.isArray(x)?[...g,...x]:[...g,x])}}if(!n.partial){for(const g of t)if(g.kind==="positional"&&!w.has(g.index))throw new Mn(o[g.index])}if(n.partial&&!n.stopAtFirstUnknown){const g=[...f];for(const y of p)g.push({index:y.index,value:y.value});for(const y of t)y.kind==="positional"&&!w.has(y.index)&&g.push({index:y.index,value:o[y.index]});g.length>0&&(g.sort((y,x)=>y.index-x.index),d._unknown=g.map(y=>y.value))}if(n.stopAtFirstUnknown&&!$){const g=t.findIndex(x=>x.kind==="positional"&&!w.has(x.index));let y=-1;if(C!==-1&&g!==-1?y=Math.min(C,g):C!==-1?y=C:g!==-1&&(y=g),y>=0){const x=t[y].index;d._unknown=o.slice(x)}}for(const[g,y]of Object.entries(h)){const x=n.camelCase?r?.get(g)??g:g,I=s.get(g);I?.type?d[x]=Pn(y,I.type,{optionName:I.name,strictTypes:n.strictTypes}):d[x]=y===void 0?null:y}for(const g of e){const y=n.camelCase?r?.get(g.name)??g.name:g.name;!(y in d)&&g.defaultValue!==void 0&&(g.multiple??g.lazyMultiple?d[y]=Array.isArray(g.defaultValue)?[...g.defaultValue]:[g.defaultValue]:d[y]=g.defaultValue)}if(v){const g={},y={},x={};for(const N of e)if(N.group){const S=Array.isArray(N.group)?N.group:[N.group];for(const P of S)Fe(P)||(g[P]??={})}for(const N of Object.keys(d))if(!Vn(N)){y[N]=d[N];let S=N;n.camelCase&&(S=c?.get(N)??N);const P=s.get(S);if(P?.group){const E=Array.isArray(P.group)?P.group:[P.group];for(const U of E)Fe(U)||g[U]&&(g[U][N]=d[N])}else x[N]=d[N]}const I={_all:y};for(const[N,S]of Object.entries(g))I[N]=S;Object.keys(x).length>0&&(I._none=x),d._unknown&&(I._unknown=d._unknown),Object.keys(d).forEach(N=>delete d[N]),Object.assign(d,I)}const _=Object.defineProperties({},Object.getOwnPropertyDescriptors(d));return O(i,"Final parsed result:","resolver",_),_},ct="-",ee=ct.codePointAt(0),K="=",Tn=K.codePointAt(0),Rn="--",Bn=ct,zn="--",ut=t=>t.length>2&&t.startsWith(zn),Wn=t=>ut(t)&&!t.includes(K,3),Fn=t=>ut(t)&&t.includes(K,3),qn=t=>{if(t.length!==2||t.codePointAt(0)!==ee||t.codePointAt(1)===ee)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},Gn=t=>{if(t.length<=2||t.codePointAt(0)!==ee||t.codePointAt(1)===ee)return!1;const e=t.codePointAt(1);return!(e!==void 0&&e>=48&&e<=57)},Jn=t=>{const e=[];let n=0,o=[],i=0,s=-1,l=0;for(;i<o.length||n<t.length;){let a;if(i<o.length?(a=o[i],i++):(a=t[n],n++),l>0?l--:s++,a===Rn){e.push({index:s,kind:"option-terminator"});const u=[...o.slice(i),...t.slice(n)],r=u.map((c,d)=>({index:s+d+1,kind:"positional",value:c}));e.push(...r),s+=u.length;break}if(qn(a)){const u=a.charAt(1);e.push({index:s,kind:"option",name:u,rawName:a});continue}if(Gn(a)&&!a.includes(K)){const u=[];let r="",c=!1;for(let d=1;d<a.length;d++){const h=a.charAt(d);c?r+=h:h.codePointAt(0)===Tn?c=!0:u.push(`${Bn}${h}`)}if(c)if(u.length>0){const d=u.pop();u.push(`${d}=${r}`)}else u.push(r);o=i<o.length?[...u,...o.slice(i)]:u,i=0,l=u.length;continue}if(Wn(a)){const u=a.slice(2);e.push({index:s,kind:"option",name:u,rawName:a});continue}if(Fn(a)){const u=a.indexOf(K),r=a.slice(2,u),c=a.slice(u+1);e.push({index:s,inlineValue:!0,kind:"option",name:r,rawName:a,value:c});continue}if(a.length>2&&a.codePointAt(0)===ee&&a.codePointAt(1)!==ee&&a.includes(K)){const u=a.indexOf(K),r=a.charAt(1),c=a.slice(u+1);e.push({index:s,inlineValue:!0,kind:"option",name:r,rawName:a,value:c});continue}e.push({index:s,kind:"positional",value:a})}return e},Hn=/\d/,Kn=t=>typeof t=="function",Zn=(t,e,n)=>{const o=n?.debug??!1;O(o,"Validating definitions:","validation",t,"caseInsensitive:",e);const i=new Set,s=new Set,l=new Set,a=new Set;let u=0;for(const r of t){if(O(o,"Checking definition:","validation",r),!r.name)throw O(o,"Validation failed: name is required","validation"),new M("Invalid option definition: name is required");if(typeof r.name!="string")throw new M("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new M("Invalid option definition: name cannot be empty");const c=e?r.name.toLowerCase():"";if(i.has(r.name)||e&&l.has(c))throw new M(`Invalid option definition: duplicate name '${r.name}'`);if(s.has(r.name)||e&&a.has(c))throw new M(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(i.add(r.name),e&&l.add(c),r.alias!==void 0){if(typeof r.alias!="string")throw new M("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new M("Invalid option definition: alias must be a single character");if(Hn.test(r.alias))throw new M("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new M('Invalid option definition: alias cannot be "-"');const d=e?r.alias.toLowerCase():"";if(s.has(r.alias)||e&&a.has(d))throw new M(`Invalid option definition: duplicate alias '${r.alias}'`);if(i.has(r.alias)||e&&l.has(d))throw new M(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);s.add(r.alias),e&&a.add(d)}if(r.defaultOption&&(u++,r.type!==void 0&&H(r.type)))throw new M("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&Kn(r.type)))throw new M("Invalid option definition: invalid type")}if(u>1)throw O(o,"Validation failed: multiple defaultOptions not allowed","validation"),new M("Invalid option definition: multiple defaultOptions not allowed");O(o,"Validation completed successfully","validation")};function Yn(t,e={}){const n=e.debug??!1;O(n,"Starting command-line-args parsing","index"),O(n,"Options:","index",e);const o={...e};o.stopAtFirstUnknown&&(o.partial=!0);const i=Array.isArray(t)?t:[t];O(n,"Normalized definitions:","index",i),Zn(i,o.caseInsensitive,n?o:void 0);let{argv:s}=o;s??=process.argv.slice(2),O(n,"Using argv:","index",s);let l=s;o.caseInsensitive&&(l=s.map(r=>{if(r.startsWith("--")){const c=r.indexOf("="),d=(c===-1?r.slice(2):r.slice(2,c)).toLowerCase();return c===-1?`--${d}`:`--${d}${r.slice(c)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const c=r.indexOf("="),d=c===-1?r.slice(1):r.slice(1,c);if(!d)return r;const h=d.toLowerCase();return c===-1?`-${h}`:`-${h}${r.slice(c)}`}return r}));const a=Jn(l.map(String));O(n,"Tokenized arguments:","index",a);const u=Dn(a,i,o,s);return O(n,"Command-line-args parsing completed","index"),u}class Xn{result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}let we=class extends b{commandName;constructor(e,n,o){super(`Failed to load command "${e}": ${n}`,"COMMAND_LOADER_ERROR",{commandName:e,reason:n}),this.name="CommandLoaderError",this.commandName=e,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",o!==void 0&&(this.cause=o)}};const Qn=/^-{1,2}(\w+)(=(.+))?$/,ht=(t,e,n,o)=>{const i=Qn.exec(t);if(i===null)return{};const s=i[1];if(!s)return{};const l=n&&o?n.get(s)??o.get(s):e.find(a=>a.name===s||a.alias===s);return l!==void 0?{argName:l.name,argValue:i[3],option:l}:{}},Ge=(t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},eo=new Set(["0","1","false","true"]),to=(t,e,n,o)=>{if(e.length===0||t.length===0)return{};const i=(s,l)=>{const{argName:a,argValue:u,option:r}=ht(l,e,n,o),{lastOption:c}=s;return r&&se(r)&&u&&a?s.partial[a]=Ge(u,r):s.lastName&&c&&se(c)&&eo.has(l)&&(s.partial[s.lastName]=Ge(l,c)),{lastName:a,lastOption:r,partial:s.partial}};return t.reduce(i,{partial:{}}).partial},no=new Set(["0","1","false","true"]),oo=(t,e,n,o)=>{if(e.length===0||t.length===0)return t;const i=(s,l)=>{const{argValue:a,option:u}=ht(l,e,n,o),{lastOption:r}=s;if(r&&se(r)&&no.has(l)){const{args:c}=s;return{args:c.slice(0,-1)}}return u&&se(u)&&a?{args:s.args}:{args:[...s.args,l],lastOption:u}};return t.reduce(i,{args:[]}).args},so=t=>{const e=new Map;for(const n of t){const o=e.get(n.name);o?e.set(n.name,{...o,...n}):e.set(n.name,n)}return[...e.values()]},io=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},ro=(t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return io(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const n=Number.parseFloat(e);return Number.isNaN(n)?void 0:n}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)}},ao=/_./g,lo=/^[A-Z]/,co=t=>t.toLowerCase().replaceAll(ao,e=>e[1]?.toUpperCase()??e).replace(lo,e=>e.toLowerCase()),uo=(t,e=he())=>{if(!t||t.length===0)return{};const n={};for(const o of t){const i=e[o.name],s=ro(o,i),l=s===void 0?o.defaultValue:s,a=co(o.name);n[a]=l}return n},ho=t=>{const e=new Map,n=new Map;for(const o of t)if(e.set(o.name,o),o.alias){const i=Array.isArray(o.alias)?o.alias:[o.alias];for(const s of i)n.set(s,o)}return{optionMapByAlias:n,optionMapByName:e}},pt=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new we(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(o){throw new we(t.name,o instanceof Error?o.message:String(o),o)}const n=e.default;if(typeof n!="function")throw new we(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},po=(t,e,n,o,i)=>{const s=new Xn(t.name,t),{_all:l,_unknown:a,positionals:u}=e,r=Object.keys(n).length>0?{...l,...n}:l;le in r&&delete r[le],s.argument=u?.[le]??[],s.rawUnknown=[...a??[]];const c=Object.keys(o).length>0;return s.options=c?{...r,...o}:r,s.env=uo(t.env,i),s},fo=(t,e,n)=>{const o=t.options??[],i=o.length>0;let s=so(i?[...o,...n]:n);if(s.length>0){for(const r of s)if(r.multiple&&r.lazyMultiple)throw new Error(`Argument "${r.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(s=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:le,type:t.argument.type,typeLabel:t.argument.typeLabel},...s]);let l,a;if(i){const{optionMapByAlias:r,optionMapByName:c}=ho(o);l=oo(e,o,c,r),a=to(e,o,c,r)}else l=e,a={};const u=Yn(s,{argv:l,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:s,booleanValues:a,parsedArgs:u}},ye=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await pt(t))(e);let mo=class{capacity;cache;constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;const e=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,e),e}has(t){return this.cache.has(t)}set(t,e){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const n=this.cache.keys().next().value;n!==void 0&&this.cache.delete(n)}this.cache.set(t,e)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}};const go=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),wo=new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))","g"),yo=t=>{if(typeof t!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof t}`);return t.replaceAll(wo,"")},ve=new mo(1e3),vo=/[.*+?^${}()|[\]\\]/g,$o=t=>{const e=t.join("");if(ve.has(e)){const i=ve.get(e);return i.lastIndex=0,i}const n=t.map(i=>i.replaceAll(vo,String.raw`\$&`)).join("|"),o=new RegExp(n,"g");return ve.set(e,o),o},xo=t=>{const e=[];let n=0,o;for(F.lastIndex=0;(o=F.exec(t))!==null;)o.index>n&&e.push(t.slice(n,o.index)),e.push(o[0]),n=F.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},Ao=/[ČŠŽĐ]/i,dt=new Uint8Array(128),ft=new Uint8Array(128),mt=new Uint8Array(128);for(let t=0;t<128;t++)dt[t]=t>=65&&t<=90?1:0,ft[t]=t>=97&&t<=122?1:0,mt[t]=t>=48&&t<=57?1:0;const $e=t=>dt[t],Je=t=>ft[t],xe=t=>mt[t],B=(t,e,n,o,i)=>{if(t.length===0)return[];let s=!1;const l=Object.values(e);for(const f of l)if(f(t[0])){s=!0;break}if(!s&&!n)return[t];const a=[...t],u=[];let r=a[0],c="other";const d=Object.entries(e);for(const f of d){const[p,w]=f;if(w(a[0])){c=p;break}}let h=n&&o?a[0]===a[0].toLocaleUpperCase(o):!1;for(let f=1;f<a.length;f++){const p=a[f];let w="other";for(const v of d){const[A,k]=v;if(k(p)){w=A;break}}const $=n&&o?p===p.toLocaleUpperCase(o):!1;let m=!1;i?m=i(c,w,h,$,p,f,a):(c!==w&&c!=="other"&&w!=="other"&&(m=!0),n&&w!=="other"&&!h&&$&&(m=!0)),m?(u.push(r),r=p):r+=p,c=w,n&&(h=$)}return r&&r.length>0&&u.push(r),u.length>0?u:[t]},No=(t,e,n,o)=>{if(n.size===0)return e;for(const i of n)if(t.startsWith(i,e))return o.push(i),e+i.length;return e},gt=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const o=[],i=t.length;for(let s=1;s<i;s++){const l=No(t,n,e,o);if(l!==n){n=l,s=n-1;continue}const a=t.codePointAt(s-1),u=t.codePointAt(s),r=a&&a<128&&$e(a),c=u&&u<128&&$e(u),d=a&&a<128&&Je(a),h=a&&a<128&&xe(a),f=u&&u<128&&xe(u);if(d&&c){o.push(t.slice(n,s)),n=s;continue}if(h&&!f||!h&&f){o.push(t.slice(n,s)),n=s;continue}if(f&&!h){let p=!1,w=!1;if(s+1<i){const $=t.codePointAt(s+1);p=$&&$<128&&$e($),w=$&&$<128&&xe($)}if(!w&&p){o.push(t.slice(n,s),t.slice(s,s+1)),n=s+1;continue}}if(s+1<i){const p=t.codePointAt(s+1),w=p&&p<128&&Je(p);if(r&&c&&w){const $=t.slice(n,s+1);e.has($)||(o.push(t.slice(n,s)),n=s)}}}return n<i&&o.push(t.slice(n)),o.filter(s=>s!=="")},wt=(t,e,n)=>{if(t.length===0)return[];const o=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!o&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const r=[...t],c=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e),p=f,w=f?0:-1;for(let $=1;$<c;$++){const m=r[$],v=m===m.toLocaleUpperCase(e);if(v===f)h+=m;else if(v)h&&h.length>0&&(d.push(h),h=m),p=!0,w=$;else{if(p&&$-w>1){const A=r[$-1],k=h.slice(0,-1);k&&k.length>0&&d.push(k),h=A+m}else h+=m;p=!1,w=-1}f=v}return h&&h.length>0&&d.push(h),d}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!X.test(t)&&!L.test(t))return[t];const r=[...t],c=r.length,d=[];let h=r[0];const f=r[0];let p;X.test(f)?p=1:L.test(f)?p=2:p=0;let w=f===f.toLocaleUpperCase(e);for(let m=1;m<c;m++){const v=r[m];let A;X.test(v)?A=1:L.test(v)?A=2:A=0;const k=v===v.toLocaleUpperCase(e);p!==A&&(p===1||p===2)&&(A===1||A===2)||A===p&&!w&&k?(d.push(h),h=v):h+=v,p=A,w=k}h&&h.length>0&&d.push(h);const $=[];for(let m=0;m<d.length;m++)m<d.length-1&&d[m].length===1&&L.test(d[m])&&X.test(d[m+1][0])?($.push(d[m]+d[m+1]),m+=1):$.push(d[m]);return $}if(e.startsWith("el")){if(!me.test(t)&&!L.test(t))return[t];const r=[];Me.lastIndex=0;let c;for(;(c=Me.exec(t))!==null;)r.push(c[0]);r.length===0&&r.push(t);const d=[];if(r.length===1){const h=r[0];if(!h||!me.test(h[0])||h.length===1)return[h??t]}for(const h of r){if(!h)continue;if(!me.test(h[0])||h.length===1){d.push(h);continue}const f=h.length;let p=h[0],w=h[0]===h[0].toLocaleUpperCase(e);for(let $=1;$<f;$++){const m=h[$],v=m===m.toLocaleUpperCase(e);!w&&v?(d.push(p),p=m):p+=m,w=v}p&&d.push(p)}return d}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),c=r?{hiragana:h=>Kt.test(h),kanji:h=>je.test(h),katakana:h=>Yt.test(h),latin:h=>L.test(h)}:{hangul:h=>Pe.test(h),latin:h=>L.test(h)},d=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const h=B(t,c,!1,e,(p,w)=>p==="hiragana"&&w==="katakana"||p==="katakana"&&w==="hiragana"||p==="hiragana"&&w==="latin"||p==="katakana"&&w==="latin"||p==="kanji"&&w==="latin"||p==="latin"&&(w==="hiragana"||w==="katakana"||w==="kanji")),f=[];for(const p of h){const w=p;w.length===1&&d.has(w)&&f.length>0?f[f.length-1]=f.at(-1)+w:f.push(w)}return f.length>0?f:[t]}return B(t,c,!1,e,(h,f)=>h==="hangul"&&f==="latin"||h==="latin"&&f==="hangul")}if(e.startsWith("sl")){const r=[...t],c=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let p=1;p<c;p++){const w=r[p],$=w===w.toLocaleUpperCase(e),m=Ao.test(w),v=p<c-1&&r[p+1]===r[p+1].toLocaleUpperCase(e);!f&&$||m&&v?(d.push(h),h=w,m&&v&&(d.push(h),h="")):h+=w,f=$}return h&&h.length>0&&d.push(h),d}if(e.startsWith("zh"))return B(t,{han:r=>je.test(r),latin:r=>L.test(r)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=c=>Ue.test(c)||Le.test(c);return B(t,{latin:c=>L.test(c),rtl:c=>r(c)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const r=c=>qt.test(c)||Ft.test(c)||Jt.test(c)||Ht.test(c)||Zt.test(c)||sn.test(c)||rn.test(c)||en.test(c)||on.test(c)||an.test(c)||Qt.test(c)||ln.test(c)||tn.test(c)||Gt.test(c)||Xt.test(c)||nn.test(c);return B(t,{indic:c=>r(c),latin:c=>L.test(c)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return B(t,{cyrillic:r=>X.test(r),latin:r=>L.test(r)},!0,e);if(["ar","fa","he"].includes(e))return B(t,{latin:r=>L.test(r),rtl:r=>Ue.test(r)||Le.test(r)},!1,e);if(e.startsWith("ko"))return B(t,{hangul:r=>Pe.test(r),latin:r=>L.test(r)},!1,e);if(e.startsWith("uz")){if(!X.test(t)&&!L.test(t))return[t];const r=[...t],c=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let p=1;p<c;p++){const w=r[p],$=w===w.toLocaleUpperCase(e);if(Ve.test(w)||Ve.test(r[p-1])){h+=w;continue}!f&&$?(d.push(h),h=w):h+=w,f=$}return h&&h.length>0&&d.push(h),d}const i=[...t],s=i.length,l=[];let a=i[0],u=i[0]===i[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){l.push(r),a=i[r.length],u=a===a.toLocaleUpperCase(e);break}for(let r=1;r<s;r++){const c=i[r],d=c===c.toLocaleUpperCase(e);let h=0;for(const f of n)if(t.startsWith(f,r)){l.push(a,f),h=f.length,a="";const p=f.at(-1);p&&(u=p===p.toLocaleUpperCase(e));break}if(h>0){r+=h-1;continue}!u&&d?(l.push(a),a=c):a+=c,u=d}return a&&l.push(a),l},bo=(t,e,n)=>{const o=[],i=ce.test(t)?t.split(ce).filter(Boolean):[t];for(const s of i){const l=s;if(ce.test(l))o.push(l);else{F.lastIndex=0;const a=F.test(l)?xo(l).filter(Boolean):[l];for(const u of a)if(F.lastIndex=0,F.test(u))o.push(u);else if(e){const r=e.toLowerCase().split("-")[0];o.push(...wt(u,r,n))}else o.push(...gt(u,n))}}return o},Co=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:o=!1,knownAcronyms:i=[],locale:s,normalize:l=!1,separators:a,stripAnsi:u=!1,stripEmoji:r=!1}=e,c=new Set([...i].toSorted((m,v)=>v.length-m.length));let d=t;u&&(d=yo(d)),r&&(d=cn(d));let h;Array.isArray(a)?h=$o(a):a instanceof RegExp?h=a:h=Wt;const f=[];let p=d;const w=h.flags.includes("g")?h:new RegExp(h.source,`${h.flags}g`);for(;p.length>0;){const m=w.exec(p);if(!m){p===".."?f.push(".."):p==="."?f.push("."):p.length>0&&f.push(p);break}const v=m.index,A=m[0],k=A.length,C=p.slice(0,v),j=p.slice(v+k);if(A.startsWith("../"))f.push(".."),p=p.slice(v+3);else if(A.startsWith("./"))f.push("."),p=p.slice(v+2);else if(v===0&&A==="..")f.push(".."),p=p.slice(2);else if(v===0&&A===".")f.push("."),p=p.slice(1);else{C.length>0&&f.push(C);let _=0;for(;(_=A.indexOf("../",_))!==-1;)f.push(".."),_+=3;for(_=0;(_=A.indexOf("./",_))!==-1;)(_===0||A[_-1]!==".")&&f.push("."),_+=2;let g=j;for(;g.startsWith("../");)f.push(".."),g=g.slice(3);for(;g.startsWith("./");)f.push("."),g=g.slice(2);if(g===".."){f.push("..");break}else if(g==="."){f.push(".");break}else p=g}w.lastIndex=0}if(f.length===0){const m=d.split(h).filter(Boolean);f.push(...m)}let $=[];for(const m of f)n||o?$.push(...bo(m,s,c)):s?$.push(...wt(m,s,c)):$.push(...gt(m,c));return l&&($=$.map(m=>c.has(m)?m:s&&m===m.toLocaleUpperCase(s)?m[0]+m.slice(1).toLocaleLowerCase(s):m.toUpperCase()===m&&!c.has(m)?m.slice(0,1)+m.slice(1).toLowerCase():m)),$},ko=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),Eo=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const o=[];let i="",s="";for(let l=0;l<n;l++){const a=t[l];if(ce.test(a)){i?(o.push(i+s+a),i="",s=""):(o.length>0&&o.push(e),i=a);continue}i?(s&&(s+=e),s+=a):(o.length>0&&o.push(e),o.push(a))}return o.join("")},Q=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return Eo(Co(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(o=>{const i=o,s=i.toLowerCase();return n?(n=!1,go(s)):ko(s)}),"")};class Oo extends b{commandName;missingOptions;constructor(e,n){super(`Command "${e}" is missing required options: ${n.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:e,missingOptions:n}),this.name="CommandValidationError",this.commandName=e,this.missingOptions=n,this.hint=`Provide the following required options: ${n.join(", ")}`}}class _o extends b{choices;option;value;constructor(e,n,o){super(`Invalid value "${n}" for option "${e}". Allowed values: ${o.join(", ")}`,"INVALID_CHOICE",{choices:o,option:e,value:n}),this.name="InvalidChoiceError",this.option=e,this.value=n,this.choices=o,this.hint=`Use one of: ${o.map(i=>`--${e} ${i}`).join(", ")}`}}const He=(t,e,n=!1)=>{const o=[],i=e._all??e;for(const s of t){if(!n&&!s.required)continue;const l=s.__camelCaseName__??s.name;if(i[l]===void 0){if(s.type?.name==="Boolean"){e[l]=!1;continue}o.push(s)}}return o},Io=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:pn(t,e)<=t.length/3,z=(t,e)=>{const n=t.toLowerCase();return e.filter(o=>Io(o.toLowerCase(),n))},So=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(o=>{const i=o.startsWith("--");let s=`Found unknown ${i?"option":"argument"} "${o}"`;if(i){const l=z(o.replace("--",""),(e.options??[]).map(a=>a.name));if(l.length>0){const[a,...u]=l.map(r=>`--${r}`);s+=u.length>0?`, did you mean ${a??""} or ${u.join(", ")}?`:`, did you mean ${a??""}?`}}n.push(s)}),n.length>0)throw new Error(n.join(`
1
+ import{createRequire as It}from"node:module";import{b as he,u as Ut,c as W,h as jt,i as be,d as Vt,a as Dt,l as Tt,e as Ie}from"./package-version-Bb7KGF36.js";let St;const Lt=t=>(St??=It(import.meta.url))(t),ne=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Mt=t=>{if(typeof ne<"u"&&ne.versions&&ne.versions.node){const[e,n]=ne.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ne.getBuiltinModule(t)}return Lt(t)},{createRequire:Pt}=Mt("node:module"),Rt=16,fe=32,Bt=64,T=128,le="positionals";let te=class extends Error{loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:o,message:i,name:s,stack:l,title:a}){super(i,{cause:e}),this.title=a,this.name=s,this.stack=l??this.stack,this.loc=o,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}},b=class extends te{code;context;constructor(e,n,o){super({message:e,name:"CerebroError"}),this.code=n,this.context=o}};const nt=String.raw,Se=nt`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,zt=()=>new RegExp(nt`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${Se}(?:\u200D${Se})*`,"gu");Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]]));const Zs=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,Ys=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,F=zt(),Wt=/[-_./\s]+/g,ce=/(\u001B\[[0-9;]*[a-z])/i,Le=new RegExp("\\p{Script=Arabic}","u"),Ft=new RegExp("\\p{Script=Bengali}","u"),X=new RegExp("\\p{Script=Cyrillic}","u"),qt=new RegExp("\\p{Script=Devanagari}","u"),Gt=new RegExp("\\p{Script=Ethiopic}","u"),me=new RegExp("\\p{Script=Greek}","u"),Me=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),Jt=new RegExp("\\p{Script=Gujarati}","u"),Ht=new RegExp("\\p{Script=Gurmukhi}","u"),Pe=new RegExp("\\p{Script=Hangul}","u"),Ue=new RegExp("\\p{Script=Hebrew}","u"),Kt=new RegExp("\\p{Script=Hiragana}","u"),je=new RegExp("\\p{Script=Han}","u"),Zt=new RegExp("\\p{Script=Kannada}","u"),Yt=new RegExp("\\p{Script=Katakana}","u"),Xt=new RegExp("\\p{Script=Khmer}","u"),Qt=new RegExp("\\p{Script=Lao}","u"),L=new RegExp("\\p{Script=Latin}","u"),en=new RegExp("\\p{Script=Malayalam}","u"),tn=new RegExp("\\p{Script=Myanmar}","u"),nn=new RegExp("\\p{Script=Oriya}","u"),on=new RegExp("\\p{Script=Sinhala}","u"),sn=new RegExp("\\p{Script=Tamil}","u"),rn=new RegExp("\\p{Script=Telugu}","u"),an=new RegExp("\\p{Script=Thai}","u"),ln=new RegExp("\\p{Script=Tibetan}","u"),Ve=/[\u02BB\u02BC\u0027]/u,cn=t=>t.replace(F,""),R=new Uint32Array(65536),un=(t,e)=>{const n=t.length,o=e.length,i=1<<n-1;let s=-1,l=0,a=n,u=n;for(;u--;)R[t.charCodeAt(u)]|=1<<u;for(u=0;u<o;u++){let r=R[e.charCodeAt(u)];const c=r|l;r|=(r&s)+s^s,l|=~(r|s),s&=r,l&i&&a++,s&i&&a--,l=l<<1|1,s=s<<1|~(c|l),l&=c}for(u=n;u--;)R[t.charCodeAt(u)]=0;return a},hn=(t,e)=>{const n=e.length,o=t.length,i=[],s=[],l=Math.ceil(n/32),a=Math.ceil(o/32);for(let p=0;p<l;p++)s[p]=-1,i[p]=0;let u=0;for(;u<a-1;u++){let p=0,w=-1;const $=u*32,m=Math.min(32,o)+$;for(let v=$;v<m;v++)R[t.charCodeAt(v)]|=1<<v;for(let v=0;v<n;v++){const A=R[e.charCodeAt(v)],k=s[v/32|0]>>>v&1,C=i[v/32|0]>>>v&1,j=A|p,_=((A|C)&w)+w^w|A|C;let g=p|~(_|w),y=w&_;g>>>31^k&&(s[v/32|0]^=1<<v),y>>>31^C&&(i[v/32|0]^=1<<v),g=g<<1|k,y=y<<1|C,w=y|~(j|g),p=g&j}for(let v=$;v<m;v++)R[t.charCodeAt(v)]=0}let r=0,c=-1;const d=u*32,h=Math.min(32,o-d)+d;for(let p=d;p<h;p++)R[t.charCodeAt(p)]|=1<<p;let f=o;for(let p=0;p<n;p++){const w=R[e.charCodeAt(p)],$=s[p/32|0]>>>p&1,m=i[p/32|0]>>>p&1,v=w|r,A=((w|m)&c)+c^c|w|m;let k=r|~(A|c),C=c&A;f+=k>>>o-1&1,f-=C>>>o-1&1,k>>>31^$&&(s[p/32|0]^=1<<p),C>>>31^m&&(i[p/32|0]^=1<<p),k=k<<1|$,C=C<<1|m,c=C|~(v|k),r=k&v}for(let p=d;p<h;p++)R[t.charCodeAt(p)]=0;return f},pn=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return e.length===0?t.length:t.length<=32?un(t,e):hn(t,e)};let dn;const fn=t=>(dn??=Pt(import.meta.url))(t),oe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,mn=t=>{if(typeof oe<"u"&&oe.versions&&oe.versions.node){const[e,n]=oe.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return oe.getBuiltinModule(t)}return fn(t)},{writeFile:gn,stat:wn,rm:yn,readFile:De,readdir:vn,mkdir:$n,access:xn}=mn("node:fs/promises"),re=[{alias:"v",description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];let G=class extends b{commandName;constructor(e,n=[]){const o=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(o,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}},ot=class extends b{option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}};class An extends b{unknownOptions;constructor(e,n){const o=e.join(", "),i=`Found unknown ${e.length===1?"option":"options"}: ${o}`;super(i,"UNKNOWN_OPTION",{suggestions:n,unknownOptions:e}),this.name="UnknownOptionError",this.unknownOptions=e,n&&n.length>0&&(this.hint=`Did you mean: ${n.join(", ")}?`)}}class Nn extends b{pluginName;constructor(e,n,o){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:o,pluginName:e}),this.name="PluginError",this.pluginName=e,o&&(this.cause=o)}}class bn{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(e){this.logger=e}hasPlugins(){return this.plugins.size>0}register(e){if(this.initialized)throw new Error(`Cannot register plugin "${e.name}" after initialization`);if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);he().CEREBRO_OUTPUT_LEVEL===String(T)&&this.logger.debug(`registering plugin: ${e.name}`),this.plugins.set(e.name,e),this.cachedDependencyOrder=void 0}async init(e){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const n=this.getDependencyOrder();this.logger.debug(`initializing ${String(n.length)} plugin(s)...`);for(const o of n)if(typeof o.init=="function"){this.logger.debug(`initializing plugin: ${o.name}`);try{await o.init(e)}catch(i){const s=new Nn(o.name,`Failed to initialize: ${i instanceof Error?i.message:String(i)}`,i instanceof Error?i:void 0);throw this.logger.error(s.message),s}}this.initialized=!0}async executeLifecycle(e,n,o){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const i=this.getDependencyOrder();for(const s of i){const l=s[e];if(typeof l=="function"){this.logger.debug(`executing ${e} hook for plugin: ${s.name}`);try{await(e==="afterCommand"?l(n,o):l(n))}catch(a){throw this.logger.error(`Error in ${e} hook for plugin "${s.name}":`,a),a}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const o=this.getDependencyOrder();for(const i of o)if(typeof i.onError=="function"){this.logger.debug(`executing error handler for plugin: ${i.name}`);try{await i.onError(e,n)}catch(s){this.logger.error(`Error in error handler for plugin "${i.name}":`,s)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,o=new Set,i=s=>{if(n.has(s))return;if(o.has(s))throw new Error(`Circular dependency detected involving plugin "${s}"`);const l=this.plugins.get(s);if(!l)throw new Error(`Plugin "${s}" not found`);if(o.add(s),l.dependencies)for(const a of l.dependencies)i(a);o.delete(s),n.add(s),e.push(l)};for(const s of this.plugins.keys())i(s);return this.cachedDependencyOrder=e,e}validateDependencies(){for(const e of this.plugins.values())if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin "${e.name}" depends on "${n}" which is not registered`)}}}const se=t=>t.type?.name==="Boolean",Cn=t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},Te=t=>(se(t)||(t.typeLabel=t.typeLabel??Cn(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),kn=new RegExp(/^-([^\d-])$/),En=new RegExp(/^--(\S+)/),On=new RegExp(/^-([^\d-]{2,})$/),_n=t=>kn.test(t)||En.test(t)||On.test(t),In=(t,e)=>{const n=e[0]&&_n(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const o=new Error(`Command not recognised: ${String(n)}`);throw o.command=n,o.name="INVALID_COMMAND",o}return{argv:e,command:n}};let Sn=class st extends te{optionName;value;constructor(e,n,o){super({hint:`Pass a valid ${o} value for '${e}'.`,message:`Invalid ${o} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,st.prototype)}},Ln=class it extends te{optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,it.prototype)}},Re=class rt extends te{optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,rt.prototype)}},Mn=class at extends te{value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,at.prototype)}},M=class lt extends te{constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,lt.prototype)}};const H=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",Ce=t=>t===Number||typeof t=="function"&&t.name==="Number",Be=t=>t===String||typeof t=="function"&&t.name==="String",ze=(t,e,n)=>{const o=Number(t);if(e&&Number.isNaN(o)&&String(t).trim().toLowerCase()!=="nan")throw new Sn(n??"",String(t),"Number");return o},Pn=(t,e,n={})=>{const{optionName:o,strictTypes:i}=n;return Array.isArray(t)?H(e)?t.map(Boolean):Ce(e)?t.map(s=>ze(s,i,o)):Be(e)?t.map(String):t.map(s=>e(String(s))):t===null?null:H(e)?!!t:Ce(e)?ze(t,i,o):Be(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},O=(t,e,n,...o)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...o)},Un=/-([a-z])/g,jn=/^\d+$/,Vn=t=>t.codePointAt(0)===95,We=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],Fe=t=>t==="__proto__"||t==="constructor"||t==="prototype",ge=(t,e,n,o=!1)=>{t[e]===void 0?t[e]=o?[n]:n:o&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},qe=(t,e,n,o,i)=>{let s=e.get(t)??n.get(t);if(!s&&o){const l=t.toLowerCase();s=o.get(l)??i?.get(l)}return s},Dn=(t,e,n,o)=>{const i=n.debug??!1;O(i,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),O(i,"Starting argument resolution","resolver"),O(i,"Tokens:","resolver",t),O(i,"Definitions:","resolver",e),O(i,"Processing tokens...","resolver");const s=new Map,l=new Map,a=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,c=n.camelCase?new Map:void 0;for(const g of e)if(s.set(g.name,g),g.alias&&l.set(g.alias,g),n.caseInsensitive&&a&&(a.set(g.name.toLowerCase(),g),g.alias&&u&&u.set(g.alias.toLowerCase(),g)),n.camelCase&&r&&c){const y=g.name.replaceAll(Un,(x,I)=>I.toUpperCase());r.set(g.name,y),c.set(y,g.name)}const d=Object.create(null),h=Object.create(null),f=[],p=[],w=new Set;let $=!1;const m=e.find(g=>g.defaultOption),v=e.some(g=>g.group),A=e.find(g=>Ce(g.type));for(let g=0;g<t.length;g++){const y=t[g];if(y.kind==="option-terminator"){d._unknown=o.slice(y.index),$=!0;break}if(y.kind==="option"&&y.name){let x=qe(y.name,s,l,a,u);!x&&y.value===void 0&&A&&jn.test(y.name)&&(x=A,y.value=y.name,y.name=A.name);let I=!1;if(!x&&n.negation&&y.value===void 0&&y.name.startsWith("no-")){const E=y.name.slice(3),U=qe(E,s,l,a,u);U?.type&&H(U.type)&&(x=U,I=!0)}const N=x?x.name:y.name,S=x?.multiple,P=x?.lazyMultiple;if(Object.hasOwn(h,N)&&h[N]!==void 0&&!S&&!P&&!n.partial)throw new Ln(N);if(!x&&n.partial){const E=y.rawName??`--${y.name}${y.value!==void 0&&y.inlineValue?`=${y.value}`:""}`;f.push({index:y.index,value:E});continue}if(!x&&n.stopAtFirstUnknown){d._unknown=o.slice(y.index);break}if(!x&&!n.partial)throw new Re(y.name);if(y.value===void 0){const E=t[g+1],U=E?.kind==="option"&&!("name"in E)&&E.value!==void 0,V=E&&x&&!(x.type&&H(x.type))&&(E.kind==="positional"||U),_t=x&&x.defaultOption&&!x.multiple&&!x.lazyMultiple;if(V&&(!x?.defaultOption||_t))if(S){let D=g+1;const de=[];for(;D<t.length&&(t[D].kind==="positional"||t[D].kind==="option"&&!("name"in t[D])&&t[D].value!==void 0);)de.push(t[D].value),w.add(t[D].index),D++;h[N]=h[N]===void 0?de:We(h[N],de),g=D-1}else P?(ge(h,N,E.value,!0),w.add(E.index),g++):(h[N]=E.value,w.add(E.index),g++);else x?.type&&H(x.type)?ge(h,N,!I,S):(S||P)&&h[N]!==void 0?ge(h,N,null,!0):h[N]=S?[]:null}else{let{value:E}=y;if(x?.type&&H(x.type))switch(E){case"":{if(n.partial){const V=`${y.rawName??`--${y.name}`}${y.value?`=${y.value}`:""}`;p.push({index:y.index,value:V}),E=!0}else throw new Re(y.name);break}case"false":{E=!1;break}case"true":{E=!0;break}default:E=!0}const U=[E];if(S){let V=g+1;for(;V<t.length&&t[V].kind==="positional";)U.push(t[V].value),w.add(t[V].index),V++;g=V-1}h[N]===void 0?h[N]=S||P?U:E:S||P?h[N]=We(h[N],U):h[N]=E}}else if(y.kind==="positional"&&n.stopAtFirstUnknown&&!w.has(y.index)&&!m){O(i,`Found unconsumed positional token at index ${String(y.index)}, stopping processing`,"resolver"),d._unknown=o.slice(y.index);break}}for(const[g,y]of Object.entries(h)){const x=s.get(g);x&&(x.multiple||x.lazyMultiple)&&!Array.isArray(y)&&(h[g]=[y])}const k=g=>g.kind==="option"&&!s.has(g.name??"")&&!l.has(g.name??"")&&(!n.caseInsensitive||!a?.has(g.name?.toLowerCase()??"")&&!u?.has(g.name?.toLowerCase()??""));let C=-1,j=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!$&&(C=t.findIndex(g=>k(g)),C!==-1&&(j=t[C].index)),m){const g=[],y=[];for(const x of t)x.kind==="positional"&&!w.has(x.index)&&x.index<j&&(g.push(x.value),y.push(x));if(g.length>0){const x=h[m.name],I=m.multiple??m.lazyMultiple;x===void 0?I?(y.forEach(N=>w.add(N.index)),h[m.name]=g):(w.add(y[0].index),h[m.name]=g[0]):I&&(y.forEach(N=>w.add(N.index)),h[m.name]=Array.isArray(x)?[...g,...x]:[...g,x])}}if(!n.partial){for(const g of t)if(g.kind==="positional"&&!w.has(g.index))throw new Mn(o[g.index])}if(n.partial&&!n.stopAtFirstUnknown){const g=[...f];for(const y of p)g.push({index:y.index,value:y.value});for(const y of t)y.kind==="positional"&&!w.has(y.index)&&g.push({index:y.index,value:o[y.index]});g.length>0&&(g.sort((y,x)=>y.index-x.index),d._unknown=g.map(y=>y.value))}if(n.stopAtFirstUnknown&&!$){const g=t.findIndex(x=>x.kind==="positional"&&!w.has(x.index));let y=-1;if(C!==-1&&g!==-1?y=Math.min(C,g):C!==-1?y=C:g!==-1&&(y=g),y>=0){const x=t[y].index;d._unknown=o.slice(x)}}for(const[g,y]of Object.entries(h)){const x=n.camelCase?r?.get(g)??g:g,I=s.get(g);I?.type?d[x]=Pn(y,I.type,{optionName:I.name,strictTypes:n.strictTypes}):d[x]=y===void 0?null:y}for(const g of e){const y=n.camelCase?r?.get(g.name)??g.name:g.name;!(y in d)&&g.defaultValue!==void 0&&(g.multiple??g.lazyMultiple?d[y]=Array.isArray(g.defaultValue)?[...g.defaultValue]:[g.defaultValue]:d[y]=g.defaultValue)}if(v){const g={},y={},x={};for(const N of e)if(N.group){const S=Array.isArray(N.group)?N.group:[N.group];for(const P of S)Fe(P)||(g[P]??={})}for(const N of Object.keys(d))if(!Vn(N)){y[N]=d[N];let S=N;n.camelCase&&(S=c?.get(N)??N);const P=s.get(S);if(P?.group){const E=Array.isArray(P.group)?P.group:[P.group];for(const U of E)Fe(U)||g[U]&&(g[U][N]=d[N])}else x[N]=d[N]}const I={_all:y};for(const[N,S]of Object.entries(g))I[N]=S;Object.keys(x).length>0&&(I._none=x),d._unknown&&(I._unknown=d._unknown),Object.keys(d).forEach(N=>delete d[N]),Object.assign(d,I)}const _=Object.defineProperties({},Object.getOwnPropertyDescriptors(d));return O(i,"Final parsed result:","resolver",_),_},ct="-",ee=ct.codePointAt(0),K="=",Tn=K.codePointAt(0),Rn="--",Bn=ct,zn="--",ut=t=>t.length>2&&t.startsWith(zn),Wn=t=>ut(t)&&!t.includes(K,3),Fn=t=>ut(t)&&t.includes(K,3),qn=t=>{if(t.length!==2||t.codePointAt(0)!==ee||t.codePointAt(1)===ee)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},Gn=t=>{if(t.length<=2||t.codePointAt(0)!==ee||t.codePointAt(1)===ee)return!1;const e=t.codePointAt(1);return!(e!==void 0&&e>=48&&e<=57)},Jn=t=>{const e=[];let n=0,o=[],i=0,s=-1,l=0;for(;i<o.length||n<t.length;){let a;if(i<o.length?(a=o[i],i++):(a=t[n],n++),l>0?l--:s++,a===Rn){e.push({index:s,kind:"option-terminator"});const u=[...o.slice(i),...t.slice(n)],r=u.map((c,d)=>({index:s+d+1,kind:"positional",value:c}));e.push(...r),s+=u.length;break}if(qn(a)){const u=a.charAt(1);e.push({index:s,kind:"option",name:u,rawName:a});continue}if(Gn(a)&&!a.includes(K)){const u=[];let r="",c=!1;for(let d=1;d<a.length;d++){const h=a.charAt(d);c?r+=h:h.codePointAt(0)===Tn?c=!0:u.push(`${Bn}${h}`)}if(c)if(u.length>0){const d=u.pop();u.push(`${d}=${r}`)}else u.push(r);o=i<o.length?[...u,...o.slice(i)]:u,i=0,l=u.length;continue}if(Wn(a)){const u=a.slice(2);e.push({index:s,kind:"option",name:u,rawName:a});continue}if(Fn(a)){const u=a.indexOf(K),r=a.slice(2,u),c=a.slice(u+1);e.push({index:s,inlineValue:!0,kind:"option",name:r,rawName:a,value:c});continue}if(a.length>2&&a.codePointAt(0)===ee&&a.codePointAt(1)!==ee&&a.includes(K)){const u=a.indexOf(K),r=a.charAt(1),c=a.slice(u+1);e.push({index:s,inlineValue:!0,kind:"option",name:r,rawName:a,value:c});continue}e.push({index:s,kind:"positional",value:a})}return e},Hn=/\d/,Kn=t=>typeof t=="function",Zn=(t,e,n)=>{const o=n?.debug??!1;O(o,"Validating definitions:","validation",t,"caseInsensitive:",e);const i=new Set,s=new Set,l=new Set,a=new Set;let u=0;for(const r of t){if(O(o,"Checking definition:","validation",r),!r.name)throw O(o,"Validation failed: name is required","validation"),new M("Invalid option definition: name is required");if(typeof r.name!="string")throw new M("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new M("Invalid option definition: name cannot be empty");const c=e?r.name.toLowerCase():"";if(i.has(r.name)||e&&l.has(c))throw new M(`Invalid option definition: duplicate name '${r.name}'`);if(s.has(r.name)||e&&a.has(c))throw new M(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(i.add(r.name),e&&l.add(c),r.alias!==void 0){if(typeof r.alias!="string")throw new M("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new M("Invalid option definition: alias must be a single character");if(Hn.test(r.alias))throw new M("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new M('Invalid option definition: alias cannot be "-"');const d=e?r.alias.toLowerCase():"";if(s.has(r.alias)||e&&a.has(d))throw new M(`Invalid option definition: duplicate alias '${r.alias}'`);if(i.has(r.alias)||e&&l.has(d))throw new M(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);s.add(r.alias),e&&a.add(d)}if(r.defaultOption&&(u++,r.type!==void 0&&H(r.type)))throw new M("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&Kn(r.type)))throw new M("Invalid option definition: invalid type")}if(u>1)throw O(o,"Validation failed: multiple defaultOptions not allowed","validation"),new M("Invalid option definition: multiple defaultOptions not allowed");O(o,"Validation completed successfully","validation")};function Yn(t,e={}){const n=e.debug??!1;O(n,"Starting command-line-args parsing","index"),O(n,"Options:","index",e);const o={...e};o.stopAtFirstUnknown&&(o.partial=!0);const i=Array.isArray(t)?t:[t];O(n,"Normalized definitions:","index",i),Zn(i,o.caseInsensitive,n?o:void 0);let{argv:s}=o;s??=process.argv.slice(2),O(n,"Using argv:","index",s);let l=s;o.caseInsensitive&&(l=s.map(r=>{if(r.startsWith("--")){const c=r.indexOf("="),d=(c===-1?r.slice(2):r.slice(2,c)).toLowerCase();return c===-1?`--${d}`:`--${d}${r.slice(c)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const c=r.indexOf("="),d=c===-1?r.slice(1):r.slice(1,c);if(!d)return r;const h=d.toLowerCase();return c===-1?`-${h}`:`-${h}${r.slice(c)}`}return r}));const a=Jn(l.map(String));O(n,"Tokenized arguments:","index",a);const u=Dn(a,i,o,s);return O(n,"Command-line-args parsing completed","index"),u}class Xn{result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}let we=class extends b{commandName;constructor(e,n,o){super(`Failed to load command "${e}": ${n}`,"COMMAND_LOADER_ERROR",{commandName:e,reason:n}),this.name="CommandLoaderError",this.commandName=e,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",o!==void 0&&(this.cause=o)}};const Qn=/^-{1,2}(\w+)(=(.+))?$/,ht=(t,e,n,o)=>{const i=Qn.exec(t);if(i===null)return{};const s=i[1];if(!s)return{};const l=n&&o?n.get(s)??o.get(s):e.find(a=>a.name===s||a.alias===s);return l!==void 0?{argName:l.name,argValue:i[3],option:l}:{}},Ge=(t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},eo=new Set(["0","1","false","true"]),to=(t,e,n,o)=>{if(e.length===0||t.length===0)return{};const i=(s,l)=>{const{argName:a,argValue:u,option:r}=ht(l,e,n,o),{lastOption:c}=s;return r&&se(r)&&u&&a?s.partial[a]=Ge(u,r):s.lastName&&c&&se(c)&&eo.has(l)&&(s.partial[s.lastName]=Ge(l,c)),{lastName:a,lastOption:r,partial:s.partial}};return t.reduce(i,{partial:{}}).partial},no=new Set(["0","1","false","true"]),oo=(t,e,n,o)=>{if(e.length===0||t.length===0)return t;const i=(s,l)=>{const{argValue:a,option:u}=ht(l,e,n,o),{lastOption:r}=s;if(r&&se(r)&&no.has(l)){const{args:c}=s;return{args:c.slice(0,-1)}}return u&&se(u)&&a?{args:s.args}:{args:[...s.args,l],lastOption:u}};return t.reduce(i,{args:[]}).args},so=t=>{const e=new Map;for(const n of t){const o=e.get(n.name);o?e.set(n.name,{...o,...n}):e.set(n.name,n)}return[...e.values()]},io=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},ro=(t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return io(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const n=Number.parseFloat(e);return Number.isNaN(n)?void 0:n}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)}},ao=/_./g,lo=/^[A-Z]/,co=t=>t.toLowerCase().replaceAll(ao,e=>e[1]?.toUpperCase()??e).replace(lo,e=>e.toLowerCase()),uo=(t,e=he())=>{if(!t||t.length===0)return{};const n={};for(const o of t){const i=e[o.name],s=ro(o,i),l=s===void 0?o.defaultValue:s,a=co(o.name);n[a]=l}return n},ho=t=>{const e=new Map,n=new Map;for(const o of t)if(e.set(o.name,o),o.alias){const i=Array.isArray(o.alias)?o.alias:[o.alias];for(const s of i)n.set(s,o)}return{optionMapByAlias:n,optionMapByName:e}},pt=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new we(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(o){throw new we(t.name,o instanceof Error?o.message:String(o),o)}const n=e.default;if(typeof n!="function")throw new we(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},po=(t,e,n,o,i)=>{const s=new Xn(t.name,t),{_all:l,_unknown:a,positionals:u}=e,r=Object.keys(n).length>0?{...l,...n}:l;le in r&&delete r[le],s.argument=u?.[le]??[],s.rawUnknown=[...a??[]];const c=Object.keys(o).length>0;return s.options=c?{...r,...o}:r,s.env=uo(t.env,i),s},fo=(t,e,n)=>{const o=t.options??[],i=o.length>0;let s=so(i?[...o,...n]:n);if(s.length>0){for(const r of s)if(r.multiple&&r.lazyMultiple)throw new Error(`Argument "${r.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(s=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:le,type:t.argument.type,typeLabel:t.argument.typeLabel},...s]);let l,a;if(i){const{optionMapByAlias:r,optionMapByName:c}=ho(o);l=oo(e,o,c,r),a=to(e,o,c,r)}else l=e,a={};const u=Yn(s,{argv:l,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:s,booleanValues:a,parsedArgs:u}},ye=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await pt(t))(e);let mo=class{capacity;cache;constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;const e=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,e),e}has(t){return this.cache.has(t)}set(t,e){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const n=this.cache.keys().next().value;n!==void 0&&this.cache.delete(n)}this.cache.set(t,e)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}};const go=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),wo=new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))","g"),yo=t=>{if(typeof t!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof t}`);return t.replaceAll(wo,"")},ve=new mo(1e3),vo=/[.*+?^${}()|[\]\\]/g,$o=t=>{const e=t.join("");if(ve.has(e)){const i=ve.get(e);return i.lastIndex=0,i}const n=t.map(i=>i.replaceAll(vo,String.raw`\$&`)).join("|"),o=new RegExp(n,"g");return ve.set(e,o),o},xo=t=>{const e=[];let n=0,o;for(F.lastIndex=0;(o=F.exec(t))!==null;)o.index>n&&e.push(t.slice(n,o.index)),e.push(o[0]),n=F.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},Ao=/[ČŠŽĐ]/i,dt=new Uint8Array(128),ft=new Uint8Array(128),mt=new Uint8Array(128);for(let t=0;t<128;t++)dt[t]=t>=65&&t<=90?1:0,ft[t]=t>=97&&t<=122?1:0,mt[t]=t>=48&&t<=57?1:0;const $e=t=>dt[t],Je=t=>ft[t],xe=t=>mt[t],B=(t,e,n,o,i)=>{if(t.length===0)return[];let s=!1;const l=Object.values(e);for(const f of l)if(f(t[0])){s=!0;break}if(!s&&!n)return[t];const a=[...t],u=[];let r=a[0],c="other";const d=Object.entries(e);for(const f of d){const[p,w]=f;if(w(a[0])){c=p;break}}let h=n&&o?a[0]===a[0].toLocaleUpperCase(o):!1;for(let f=1;f<a.length;f++){const p=a[f];let w="other";for(const v of d){const[A,k]=v;if(k(p)){w=A;break}}const $=n&&o?p===p.toLocaleUpperCase(o):!1;let m=!1;i?m=i(c,w,h,$,p,f,a):(c!==w&&c!=="other"&&w!=="other"&&(m=!0),n&&w!=="other"&&!h&&$&&(m=!0)),m?(u.push(r),r=p):r+=p,c=w,n&&(h=$)}return r&&r.length>0&&u.push(r),u.length>0?u:[t]},No=(t,e,n,o)=>{if(n.size===0)return e;for(const i of n)if(t.startsWith(i,e))return o.push(i),e+i.length;return e},gt=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const o=[],i=t.length;for(let s=1;s<i;s++){const l=No(t,n,e,o);if(l!==n){n=l,s=n-1;continue}const a=t.codePointAt(s-1),u=t.codePointAt(s),r=a&&a<128&&$e(a),c=u&&u<128&&$e(u),d=a&&a<128&&Je(a),h=a&&a<128&&xe(a),f=u&&u<128&&xe(u);if(d&&c){o.push(t.slice(n,s)),n=s;continue}if(h&&!f||!h&&f){o.push(t.slice(n,s)),n=s;continue}if(f&&!h){let p=!1,w=!1;if(s+1<i){const $=t.codePointAt(s+1);p=$&&$<128&&$e($),w=$&&$<128&&xe($)}if(!w&&p){o.push(t.slice(n,s),t.slice(s,s+1)),n=s+1;continue}}if(s+1<i){const p=t.codePointAt(s+1),w=p&&p<128&&Je(p);if(r&&c&&w){const $=t.slice(n,s+1);e.has($)||(o.push(t.slice(n,s)),n=s)}}}return n<i&&o.push(t.slice(n)),o.filter(s=>s!=="")},wt=(t,e,n)=>{if(t.length===0)return[];const o=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!o&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const r=[...t],c=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e),p=f,w=f?0:-1;for(let $=1;$<c;$++){const m=r[$],v=m===m.toLocaleUpperCase(e);if(v===f)h+=m;else if(v)h&&h.length>0&&(d.push(h),h=m),p=!0,w=$;else{if(p&&$-w>1){const A=r[$-1],k=h.slice(0,-1);k&&k.length>0&&d.push(k),h=A+m}else h+=m;p=!1,w=-1}f=v}return h&&h.length>0&&d.push(h),d}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!X.test(t)&&!L.test(t))return[t];const r=[...t],c=r.length,d=[];let h=r[0];const f=r[0];let p;X.test(f)?p=1:L.test(f)?p=2:p=0;let w=f===f.toLocaleUpperCase(e);for(let m=1;m<c;m++){const v=r[m];let A;X.test(v)?A=1:L.test(v)?A=2:A=0;const k=v===v.toLocaleUpperCase(e);p!==A&&(p===1||p===2)&&(A===1||A===2)||A===p&&!w&&k?(d.push(h),h=v):h+=v,p=A,w=k}h&&h.length>0&&d.push(h);const $=[];for(let m=0;m<d.length;m++)m<d.length-1&&d[m].length===1&&L.test(d[m])&&X.test(d[m+1][0])?($.push(d[m]+d[m+1]),m+=1):$.push(d[m]);return $}if(e.startsWith("el")){if(!me.test(t)&&!L.test(t))return[t];const r=[];Me.lastIndex=0;let c;for(;(c=Me.exec(t))!==null;)r.push(c[0]);r.length===0&&r.push(t);const d=[];if(r.length===1){const h=r[0];if(!h||!me.test(h[0])||h.length===1)return[h??t]}for(const h of r){if(!h)continue;if(!me.test(h[0])||h.length===1){d.push(h);continue}const f=h.length;let p=h[0],w=h[0]===h[0].toLocaleUpperCase(e);for(let $=1;$<f;$++){const m=h[$],v=m===m.toLocaleUpperCase(e);!w&&v?(d.push(p),p=m):p+=m,w=v}p&&d.push(p)}return d}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),c=r?{hiragana:h=>Kt.test(h),kanji:h=>je.test(h),katakana:h=>Yt.test(h),latin:h=>L.test(h)}:{hangul:h=>Pe.test(h),latin:h=>L.test(h)},d=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const h=B(t,c,!1,e,(p,w)=>p==="hiragana"&&w==="katakana"||p==="katakana"&&w==="hiragana"||p==="hiragana"&&w==="latin"||p==="katakana"&&w==="latin"||p==="kanji"&&w==="latin"||p==="latin"&&(w==="hiragana"||w==="katakana"||w==="kanji")),f=[];for(const p of h){const w=p;w.length===1&&d.has(w)&&f.length>0?f[f.length-1]=f.at(-1)+w:f.push(w)}return f.length>0?f:[t]}return B(t,c,!1,e,(h,f)=>h==="hangul"&&f==="latin"||h==="latin"&&f==="hangul")}if(e.startsWith("sl")){const r=[...t],c=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let p=1;p<c;p++){const w=r[p],$=w===w.toLocaleUpperCase(e),m=Ao.test(w),v=p<c-1&&r[p+1]===r[p+1].toLocaleUpperCase(e);!f&&$||m&&v?(d.push(h),h=w,m&&v&&(d.push(h),h="")):h+=w,f=$}return h&&h.length>0&&d.push(h),d}if(e.startsWith("zh"))return B(t,{han:r=>je.test(r),latin:r=>L.test(r)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=c=>Ue.test(c)||Le.test(c);return B(t,{latin:c=>L.test(c),rtl:c=>r(c)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const r=c=>qt.test(c)||Ft.test(c)||Jt.test(c)||Ht.test(c)||Zt.test(c)||sn.test(c)||rn.test(c)||en.test(c)||on.test(c)||an.test(c)||Qt.test(c)||ln.test(c)||tn.test(c)||Gt.test(c)||Xt.test(c)||nn.test(c);return B(t,{indic:c=>r(c),latin:c=>L.test(c)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return B(t,{cyrillic:r=>X.test(r),latin:r=>L.test(r)},!0,e);if(["ar","fa","he"].includes(e))return B(t,{latin:r=>L.test(r),rtl:r=>Ue.test(r)||Le.test(r)},!1,e);if(e.startsWith("ko"))return B(t,{hangul:r=>Pe.test(r),latin:r=>L.test(r)},!1,e);if(e.startsWith("uz")){if(!X.test(t)&&!L.test(t))return[t];const r=[...t],c=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let p=1;p<c;p++){const w=r[p],$=w===w.toLocaleUpperCase(e);if(Ve.test(w)||Ve.test(r[p-1])){h+=w;continue}!f&&$?(d.push(h),h=w):h+=w,f=$}return h&&h.length>0&&d.push(h),d}const i=[...t],s=i.length,l=[];let a=i[0],u=i[0]===i[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){l.push(r),a=i[r.length],u=a===a.toLocaleUpperCase(e);break}for(let r=1;r<s;r++){const c=i[r],d=c===c.toLocaleUpperCase(e);let h=0;for(const f of n)if(t.startsWith(f,r)){l.push(a,f),h=f.length,a="";const p=f.at(-1);p&&(u=p===p.toLocaleUpperCase(e));break}if(h>0){r+=h-1;continue}!u&&d?(l.push(a),a=c):a+=c,u=d}return a&&l.push(a),l},bo=(t,e,n)=>{const o=[],i=ce.test(t)?t.split(ce).filter(Boolean):[t];for(const s of i){const l=s;if(ce.test(l))o.push(l);else{F.lastIndex=0;const a=F.test(l)?xo(l).filter(Boolean):[l];for(const u of a)if(F.lastIndex=0,F.test(u))o.push(u);else if(e){const r=e.toLowerCase().split("-")[0];o.push(...wt(u,r,n))}else o.push(...gt(u,n))}}return o},Co=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:o=!1,knownAcronyms:i=[],locale:s,normalize:l=!1,separators:a,stripAnsi:u=!1,stripEmoji:r=!1}=e,c=new Set([...i].toSorted((m,v)=>v.length-m.length));let d=t;u&&(d=yo(d)),r&&(d=cn(d));let h;Array.isArray(a)?h=$o(a):a instanceof RegExp?h=a:h=Wt;const f=[];let p=d;const w=h.flags.includes("g")?h:new RegExp(h.source,`${h.flags}g`);for(;p.length>0;){const m=w.exec(p);if(!m){p===".."?f.push(".."):p==="."?f.push("."):p.length>0&&f.push(p);break}const v=m.index,A=m[0],k=A.length,C=p.slice(0,v),j=p.slice(v+k);if(A.startsWith("../"))f.push(".."),p=p.slice(v+3);else if(A.startsWith("./"))f.push("."),p=p.slice(v+2);else if(v===0&&A==="..")f.push(".."),p=p.slice(2);else if(v===0&&A===".")f.push("."),p=p.slice(1);else{C.length>0&&f.push(C);let _=0;for(;(_=A.indexOf("../",_))!==-1;)f.push(".."),_+=3;for(_=0;(_=A.indexOf("./",_))!==-1;)(_===0||A[_-1]!==".")&&f.push("."),_+=2;let g=j;for(;g.startsWith("../");)f.push(".."),g=g.slice(3);for(;g.startsWith("./");)f.push("."),g=g.slice(2);if(g===".."){f.push("..");break}else if(g==="."){f.push(".");break}else p=g}w.lastIndex=0}if(f.length===0){const m=d.split(h).filter(Boolean);f.push(...m)}let $=[];for(const m of f)n||o?$.push(...bo(m,s,c)):s?$.push(...wt(m,s,c)):$.push(...gt(m,c));return l&&($=$.map(m=>c.has(m)?m:s&&m===m.toLocaleUpperCase(s)?m[0]+m.slice(1).toLocaleLowerCase(s):m.toUpperCase()===m&&!c.has(m)?m.slice(0,1)+m.slice(1).toLowerCase():m)),$},ko=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),Eo=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const o=[];let i="",s="";for(let l=0;l<n;l++){const a=t[l];if(ce.test(a)){i?(o.push(i+s+a),i="",s=""):(o.length>0&&o.push(e),i=a);continue}i?(s&&(s+=e),s+=a):(o.length>0&&o.push(e),o.push(a))}return o.join("")},Q=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return Eo(Co(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(o=>{const i=o,s=i.toLowerCase();return n?(n=!1,go(s)):ko(s)}),"")};class Oo extends b{commandName;missingOptions;constructor(e,n){super(`Command "${e}" is missing required options: ${n.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:e,missingOptions:n}),this.name="CommandValidationError",this.commandName=e,this.missingOptions=n,this.hint=`Provide the following required options: ${n.join(", ")}`}}class _o extends b{choices;option;value;constructor(e,n,o){super(`Invalid value "${n}" for option "${e}". Allowed values: ${o.join(", ")}`,"INVALID_CHOICE",{choices:o,option:e,value:n}),this.name="InvalidChoiceError",this.option=e,this.value=n,this.choices=o,this.hint=`Use one of: ${o.map(i=>`--${e} ${i}`).join(", ")}`}}const He=(t,e,n=!1)=>{const o=[],i=e._all??e;for(const s of t){if(!n&&!s.required)continue;const l=s.__camelCaseName__??s.name;if(i[l]===void 0){if(s.type?.name==="Boolean"){e[l]=!1;continue}o.push(s)}}return o},Io=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:pn(t,e)<=t.length/3,z=(t,e)=>{const n=t.toLowerCase();return e.filter(o=>Io(o.toLowerCase(),n))},So=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(o=>{const i=o.startsWith("--");let s=`Found unknown ${i?"option":"argument"} "${o}"`;if(i){const l=z(o.replace("--",""),(e.options??[]).map(a=>a.name));if(l.length>0){const[a,...u]=l.map(r=>`--${r}`);s+=u.length>0?`, did you mean ${a??""} or ${u.join(", ")}?`:`, did you mean ${a??""}?`}}n.push(s)}),n.length>0)throw new Error(n.join(`
2
2
  `))},Lo=(t,e,n)=>{const o=n.__requiredOptions__,i=o?He(o,e,!0):He(t,e,!1);if(i.length>0)throw new Oo(n.name,i.map(s=>s.name));e._unknown&&e._unknown.length>0&&!n.argument&&So(e,n)},Mo=(t,e,n)=>{const o=n.__conflictingOptions__??t.filter(i=>i.conflicts!==void 0);if(o.length>0){const i=o.find(s=>{const l=s.__camelCaseName__??Q(s.name);return Array.isArray(s.conflicts)?s.conflicts.some(a=>e[Q(a)]!==void 0)&&e[l]!==void 0:e[Q(s.conflicts)]!==void 0&&e[l]!==void 0});if(i)throw new ot(i.name,typeof i.conflicts=="string"?i.conflicts:i.conflicts?.[0]??"unknown")}},Po=(t,e)=>{const n=e.options;if(n)for(const o of n){if(!o.choices||o.choices.length===0)continue;const i=o.__camelCaseName__??Q(o.name),s=t[i];if(s==null)continue;const l=Array.isArray(s)?s:[s];for(const a of l){const u=String(a);if(!o.choices.includes(u))throw new _o(o.name,u,o.choices)}}},Uo=t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const i of t.options){if(i.name){const s=e.get(i.name)??[];s.push(i),e.set(i.name,s)}if(typeof i.alias=="string"&&i.alias.length>0){const s=n.get(i.alias)??[];s.push(i),n.set(i.alias,s)}else if(Array.isArray(i.alias)){for(const s of i.alias)if(s.length>0){const l=n.get(s)??[];l.push(i),n.set(s,l)}}}const o=[];for(const[i,s]of e)s.length>1&&o.push(`Duplicate option name "${i}" in command "${t.name}": ${JSON.stringify(s)}`);for(const[i,s]of n)s.length>1&&o.push(`Duplicate option alias "-${i}" used by options ${s.map(l=>`"${l.name}"`).join(", ")} in command "${t.name}"`);if(o.length>0)throw new Error(o.join(`
3
3
  `))},jo=(t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let o;for(let i=1;i<=e.length;i+=1){const s=e[i-1];if(s===void 0||s.startsWith("-"))break;n.push(s);const l=n.join(" ");t.has(l)&&(o={commandPath:[...n],depth:i})}return o?{argv:e.slice(o.depth),commandPath:o.commandPath}:{argv:e,commandPath:void 0}},J=t=>t.join(" "),Ke=(t,e)=>e&&e.length>0?[...e,t]:[t],Vo=/^no-/,Do=t=>{t.options?.forEach(e=>{e.__camelCaseName__=Q(e.name)})},To=t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const o of t.options)e.add(o.name);const n=[];for(const o of t.options)if(o.name.startsWith("no-")){const i=o.name.replace(Vo,"");if(!e.has(i)){if(o.type!==Boolean)throw new Error(`Cannot add negated option "${o.name}" to command "${t.name}" because it is not a boolean.`);const s={...o,defaultValue:o.defaultValue===void 0?!0:!o.defaultValue,name:i};n.push(s),e.add(i)}}n.length>0&&t.options.push(...n)},Ro=(t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,o=new Map;for(const s of e.options)if(s.name.startsWith("no-")){const l=Q(s.name);o.set(l,s)}const i=Object.keys(n).filter(s=>o.has(s));if(i.length!==0)for(const s of i){const l=s.charAt(2);if(!l)continue;const a=l.toLowerCase()+s.slice(3),u=o.get(s);u&&(u.__negated__=!0),n[a]=!n[s],Reflect.deleteProperty(n,s)}},Bo=(t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const i of e.options)i.__camelCaseName__&&i.__negated__===void 0&&i.implies!==void 0&&n.set(i.__camelCaseName__,i);if(n.size===0)return;const{options:o}=t;for(const i of Object.keys(o)){const s=n.get(i);if(s?.implies){const{implies:l}=s;for(const[a,u]of Object.entries(l))o[a]===void 0&&(o[a]=u)}}},zo=()=>!!process.versions.electron,Wo=()=>zo()&&!process.defaultApp,Fo=()=>Wo()?0:1,qo=t=>t.slice(Fo()+1),Go=" ",Jo=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,o)=>n===e[o]),Ho=t=>{if(typeof t=="string")return t.split(Go);const e=be();return Jo(t,e)?qo(t):t},Ko=t=>{const e=s=>{t.error(`Uncaught exception: ${s.message||s}`),s.stack&&t.error(s.stack),W(1)},n=(s,l)=>{if(s instanceof Error)t.error(`Promise rejection: ${s.message||s}`),s.stack&&t.error(s.stack);else{let a;if(typeof s=="string")a=s;else try{a=JSON.stringify(s)}catch{a=String(s)}t.error(`Promise rejection: ${a}`)}W(1)},o=Ie("uncaughtException",e),i=Ie("unhandledRejection",n);return()=>{o(),i()}},Ze=100,Zo=/^[a-z][\w-]*$/i,ke=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new b(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},Ye=(t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new b(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},Ae=(t,e)=>{if(typeof t!="object"||t===null)throw new b(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},ae=t=>{const e=ke(t,"Command name");if(e.length>Ze)throw new b(`Command name is too long (maximum ${String(Ze)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new b(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Zo.test(e))throw new b(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},Yo=1e6,Xo=1e5,Qo=new Set([`
4
4
  `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),es=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArgumentLength??Yo;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Argument is too long (maximum ${String(o)} characters)`);if(n.checkDangerousChars){for(const i of t)if(Qo.has(i))throw new Error(`Argument contains dangerous character: ${i}`)}return n.trim?t.trim():t},Xe=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArguments??Xo;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Too many arguments (maximum ${String(o)})`);return t.map(i=>es(i,n))},ts=/^-([^\d-])$/,ns=/^--(\S+)/,os=/^-([^\d-]{2,})$/,Ne=t=>ts.test(t)||ns.test(t)||os.test(t),ss={access:(t,e)=>xn(t,e),mkdir:(t,e)=>$n(t,e),readdir:t=>vn(t),readFile:(async(t,e)=>e===void 0?De(t):De(t,e)),rm:(t,e)=>yn(t,e),stat:t=>wn(t),writeFile:(t,e,n)=>gn(t,e,n)},is=(t,e,n)=>{const o=e.indexOf("--"),i=o===-1?new Set:new Set(e.slice(o+1)),s=n.filter(u=>u.startsWith("--")&&u!=="--"&&!i.has(u));if(s.length===0)return;const l=(t.options??[]).map(u=>u.name),a=s.flatMap(u=>z(u.slice(2),l).map(r=>`--${r}`));throw new An(s,a)};class Ee{#t;#e;#u;#p;#d;#f;#b;#C;#k;#$;#E;#x;#O;#A=fe;#h;#n;#o;#s;#i;#r;#_=!1;#I;#S=!1;#m;#g;#w;#l=[];#V(){return this.#m===void 0&&(this.#m=[...this.#o.keys()]),this.#m}#L(){return this.#g===void 0&&(this.#g=[...this.#n.keys()]),this.#g}#a(){return this.#w===void 0&&(this.#w=[...this.#V(),...this.#L()]),this.#w}#M(){return this.#l.length===0?re:[...re,...this.#l]}#P(){this.#m=void 0,this.#g=void 0,this.#w=void 0}#N(){if(this.#u===void 0){const e=Ho(this.#e.argv);this.#u=Xe(e,{maxArguments:this.#x}),this.#D()}return this.#u}#y(){return this.#$??he()}#v(e){this.#A=e,this.#y().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){return this.#A}#D(){if(!this.#u)return;let e=!1;for(const n of this.#u){if(n==="--quiet"||n==="-q"){this.#v(Rt),e=!0;break}if(n==="--verbose"||n==="-v"){this.#v(Bt),e=!0;break}if(n==="--debug"){this.#v(T),e=!0;break}}e||this.#v(Object.hasOwn(this.#y(),"DEBUG")?T:fe)}#T(){this.#S||(this.#I=Ko(this.#t),this.#S=!0)}#R(){return{arch:jt(),argv:this.#N(),cwd:this.#p,env:this.#$??he(),exit:this.#k??(e=>W(e??0)),platform:Ut(),stdin:this.#E}}#U(e,n,o,i){this.#c()===T&&this.#t.debug(`command '${i}' found, parsing command args: ${n.join(", ")}`);const{arguments_:s,booleanValues:l,parsedArgs:a}=fo(e,n,this.#M()),u=Object.keys(l).length>0;let r=a;u&&(r={...a,_all:{...a._all,...l}}),Lo(s,r,e);const c=po(e,a,l,o,this.#y());c.runtime=this,c.argv=this.#N(),c.fs=this.#C??ss,c.process=this.#R(),c.console=this.#t;const d=e.options&&e.options.length>0;if(d&&e.options){const h=e.options.filter(f=>f.name.startsWith("no-"));for(const f of h){const p=f.name.slice(3),w=`--${f.name}`,$=`--${p}`,m=n.includes(w),v=n.includes($);if(m&&v)throw new ot(p,f.name)}}return d&&(Ro(c,e),Bo(c,e)),Mo(s,c.options,e),Po(c.options,e),this.#O&&is(e,n,c.rawUnknown),this.#c()===T&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(c.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(c.argument,null,2))),{arguments_:s,booleanValues:l,commandArgs:r,parsedArgs:a,toolbox:c}}async#j(e,n,o){const i=this.getPluginManager();try{!this.#_&&i.hasPlugins()&&(await i.init({cli:this,cwd:this.#p,logger:this.#t}),this.#_=!0),await i.executeLifecycle("execute",n),await i.executeLifecycle("beforeCommand",n);let s;const l=o.global;if(l?.help){const a=this.#n.get("help");if(!a)throw new b("Help command not found","COMMAND_NOT_FOUND");s=await ye(a,n,o)}else if(l?.version??l?.V){const a=this.#n.get("version");if(!a)throw new b("Version command not found","COMMAND_NOT_FOUND");s=await ye(a,n,o)}else s=await ye(e,n,o);return await i.executeLifecycle("afterCommand",n,s),s}catch(s){throw await i.executeErrorHandlers(s,n),s}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new b("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#d=e.trim();const o=n.argv??be(),i=n.cwd??Vt();if(this.#e={...n,argv:o,cwd:i},this.#e.argv&&!Array.isArray(this.#e.argv))throw new b("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new b("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new b("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new b("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});if(typeof this.#e.logger=="object"){const d=["debug","error","info","log","warn"],h=[],f=this.#e.logger;for(const p of d)typeof f[p]!="function"&&h.push(p);if(h.length>0)throw new b(`Logger object is missing required methods: ${h.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:h});this.#t=this.#e.logger}else this.#t={...console,debug:(...d)=>{this.#c()===T&&console.debug(...d)}};this.#f=this.#e.packageVersion,this.#b=this.#e.packageName,this.#p=this.#e.cwd,this.#i="help",this.#r={};const s=n.fs;if(s!==void 0&&(typeof s!="object"||s===null))throw new b("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const l=n.exit;if(l!==void 0&&typeof l!="function")throw new b("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const a=n.env;if(a!==void 0&&(typeof a!="object"||a===null))throw new b("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const u=n.stdin;if(u!==void 0&&typeof u!="string")throw new b("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#C=n.fs,this.#k=n.exit,this.#$=n.env,this.#E=n.stdin??"",this.#x=n.maxArguments,this.#O=n.strictOptions??!1;const r=this.#y().CEREBRO_OUTPUT_LEVEL,c=r===void 0?Number.NaN:Number(r);this.#A=Number.isNaN(c)?fe:c,this.#n=new Map,this.#o=new Map,this.#s=new Map}setCommandSection(e){return this.#r=e,this}getCommandSection(){return this.#r.header||(this.#r.header=`${this.#d}${this.#f?` v${this.#f}`:""}`),this.#r}setDefaultCommand(e){return this.#i=e,this}get defaultCommand(){return this.#i}addCommand(e){Ae(e,"Command"),ae(e.name);const n=typeof e.execute=="function",o=typeof e.loader=="function";if(n&&o)throw new b(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!o)throw new b(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?ae(e.alias):Ye(e.alias,"Command alias").forEach(r=>ae(r))),e.argument&&Ae(e.argument,"Command argument"),e.options&&Ae(e.options,"Command options"),e.commandPath&&(Ye(e.commandPath,"Command commandPath"),e.commandPath.forEach(r=>{ae(r)}));const i=Ke(e.name,e.commandPath),s=J(i);if(this.#o.has(s))throw new b(`Command with path "${s}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const l=Array.isArray(e.commandPath)&&e.commandPath.length>0,a=this.#n.get(e.name),u=a!==void 0&&(a.commandPath===void 0||a.commandPath.length===0);if(!l&&u)throw new b(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)Te(r);if(Uo(e),To(e),Do(e),e.options&&(e.__conflictingOptions__=e.options.filter(r=>r.conflicts!==void 0),e.__requiredOptions__=e.options.filter(r=>r.required===!0)),l&&a!==void 0)this.#n.set(s,e);else{if(!l&&a!==void 0&&!u){const r=Ke(a.name,a.commandPath);this.#n.set(J(r),a)}this.#n.set(e.name,e)}if(this.#o.set(s,i),this.#s.set(s,e),this.#P(),e.alias!==void 0){const r=typeof e.alias=="string"?[e.alias]:e.alias;for(const c of r){if(this.#c()===T&&this.#t.debug("adding alias",c),this.#n.has(c))throw new b(`Command alias "${c}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:c,commandName:e.name});this.#n.set(c,e)}}return this}addGlobalOption(e){const n=e,o=new Set(re.map(s=>s.name)),i=new Set(re.map(s=>s.alias).filter(Boolean));if(o.has(n.name))throw new b(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&i.has(n.alias))throw new b(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(s=>s.name)).has(n.name))throw new b(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",Te(n),this.#l.push(n),this}getGlobalOptions(){return this.#M()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#h?this.#h:(this.#h=new bn(this.#t),this.#h.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#h)}getCliName(){return this.#d}getPackageVersion(){return this.#f}getPackageName(){return this.#b}getCommands(){return this.#n}getCwd(){return this.#p}dispose(){this.#I?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:o=!0,...i}=e;if(!this.#n.has("help")){const{default:m}=await import("../packem_chunks/help-command.js");this.addCommand(new m(this.#n))}const s=this.#L(),l=this.#o;this.#T();const a=this.#N();let u,r=[...a];this.#c()===T&&(this.#t.debug(`process.execPath: ${Dt()}`),this.#t.debug(`process.execArgv: ${Tt().join(" ")}`),this.#t.debug(`process.argv: ${be().join(" ")}`));const c=jo(l,[...a]);if(c.commandPath)u=c.commandPath,r=c.argv;else{if(a.length>1&&a[0]&&a[1]&&!Ne(a[0])&&!Ne(a[1])){const v=[];let A=0;for(;A<a.length;){const C=a[A];if(!C||Ne(C))break;v.push(C),A+=1}const k=J(v);if(v[0]&&!s.includes(v[0])){const C=this.#a(),j=z(k,C);throw new G(k,j)}}let m;try{m=In([null,...s],[...a])}catch(v){if(v instanceof Error&&v.name==="INVALID_COMMAND"&&"command"in v){const A=v.command,k=this.#a(),C=z(A,k);throw new G(A,C)}throw v}m.command&&(u=[m.command],r=m.argv)}if(!u)if(this.#i)u=[this.#i];else{const m=this.#a();throw new G("",m)}const d=J(u),h=this.#o.get(d);let f;if(h){if(f=this.#s.get(d),!f||J(h)!==d){const m=this.#a(),v=z(d,m);throw new G(d,v)}}else{const m=u.at(-1);if(f=m?this.#n.get(m):void 0,!f){const v=this.#a(),A=z(d,v);throw new G(d,A)}}if(typeof f.execute!="function"&&typeof f.loader!="function")return this.#t.error(`Command "${f.name}" has no function to execute.`),o?W(1):void 0;const p=r;let w,$;try{({commandArgs:w,toolbox:$}=this.#U(f,p,i,d))}catch(m){if(this.#t.error(m),o)return W(1);throw m}try{return await this.#j(f,$,w),o?W(0):void 0}catch(m){if(o)return this.#t.error(m),W(1);throw m}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:o=[],...i}=n;ke(e,"Command name");const s=e.split(" ").filter(Boolean),l=J(s),a=this.#o.get(l)?this.#s.get(l):this.#n.get(e);if(!a){const d=this.#a(),h=z(l||e,d);throw new G(e,h)}if(typeof a.execute!="function"&&typeof a.loader!="function")throw new b(`Command "${a.name}" has no function to execute`,"INVALID_COMMAND",{commandName:a.name});const u=[...Xe(o,{maxArguments:this.#x})];this.#c()===T&&this.#t.debug(`running command '${e}' programmatically with args: ${u.join(", ")}`);const{commandArgs:r,toolbox:c}=this.#U(a,u,i,l||e);return this.#j(a,c,r)}clone(e){const n={...this.#e,...e},o=new Ee(this.#d,n);for(const[i,s]of this.#n)o.#n.set(i,s);for(const[i,s]of this.#o)o.#o.set(i,[...s]);for(const[i,s]of this.#s)o.#s.set(i,s);for(const i of this.#l)o.#l.push(i);return o.#i=this.#i,o.#r={...this.#r},o.#P(),o}async getAction(e){ke(e,"Command name");const n=e.split(" ").filter(Boolean),o=J(n),i=this.#o.get(o)?this.#s.get(o):this.#n.get(e);if(!i){const s=this.#a(),l=z(o||e,s);throw new G(e,l)}if(typeof i.execute=="function")return i.execute;if(typeof i.loader=="function")return pt(i);throw new b(`Command "${i.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:i.name})}}const ti=(t,e)=>new Ee(t,e),rs=globalThis.process??Object.create(null),Qe={versions:{}},ie=new Proxy(rs,{get(t,e){if(e in t)return t[e];if(e in Qe)return Qe[e]}}),as=t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`