@kaisers-io/refs 0.18.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.18.1] - 2026-09-20
9
+
10
+ ### Changed
11
+
12
+ - **The README describes what `refs` is for, rather than one thing it does.** It read as a tool for
13
+ looking up a library and diffing two releases. That is one question of several, and the ones it
14
+ left out are the ones people reach for it with: a change you just made and which of your own
15
+ repositories it breaks, source no model has been trained on, a flow that crosses four services.
16
+ Every example is now a prompt you say to an agent, because that is how the tool is used; the CLI
17
+ is shown where typing one is quicker.
18
+
19
+ Two documents are new. [`docs/investigations.md`](https://github.com/kaisers-io/refs/blob/main/docs/investigations.md)
20
+ works six questions through and ends each one with what the answer leaves open, which is the part
21
+ a worked example usually omits. [`docs/install.md`](https://github.com/kaisers-io/refs/blob/main/docs/install.md)
22
+ covers installing the skill without `skills add`, and the platform notes.
23
+
24
+ Seven claims that did not hold were corrected in the process: reading a version from a lockfile
25
+ (refs answers that itself, and says when it cannot), "no per-file request over the network" (a
26
+ blobless checkout fetches history on demand), a file link presented as always clickable (it
27
+ depends on the terminal), `refs sync` described as fetching only what has gone stale (it fetches
28
+ every ref; `--stale-only` is the flag), and three more. The code is unchanged: this release is
29
+ the package page and the documentation that ships beside it.
30
+
8
31
  ## [0.18.0] - 2026-09-20
9
32
 
10
33
  ### Fixed
package/README.md CHANGED
@@ -2,106 +2,95 @@
2
2
 
3
3
  **Real source code for coding agents.**
4
4
 
5
- Ask a coding agent how a library works and it answers from training data that is months
6
- old. Tell it to go look, and the best it finds is a minified bundle in `node_modules`.
7
- Private repositories are worse still. The model has never seen that code at all.
5
+ ## Ask about your dependencies and your team's repositories
8
6
 
9
- `refs` hands it the source. It keeps read-only git checkouts of the repositories you care
10
- about, so your agent reads the code that actually ships.
7
+ ```
8
+ /refs I want to upgrade effect. what changed since the version we use,
9
+ and what do I have to adjust
10
+ ```
11
+
12
+ That takes four steps. The agent reads the version your project depends on, finds the repository behind the package, compares that release with the current one, and then goes back through your own code for the places the change touches. Answers name the file and line they came from, so you can check them.
11
13
 
12
- You say "add zod as a ref". `refs` resolves the npm package to its git repository, clones
13
- it, and works out how the project tags its releases. After that the agent answers "how
14
- does zod implement codecs" by reading zod's own files, and "what changed between v4.0.1
15
- and v4.1.0" by diffing those two tags in the same clone.
14
+ ```
15
+ /refs I changed how our orders API paginates. check billing-worker and
16
+ the admin dashboard: do they call it, and what has to change
17
+ ```
16
18
 
17
- `https` and `ssh` URLs both work, including the `git@host:path` form, so a private repo or
18
- a self-hosted forge is no different from a public one. Private ones use the credentials
19
- your git already has, since refs refuses to take any in the URL.
19
+ This one runs the other way. It starts with a change in your own repository and asks what it reaches. The agent reads the consumers you name, finds the call sites, and tells you which ones your change breaks. None of those repositories are public, and nothing the agent says about them comes from anywhere but the checkout it just read. `refs` keeps them as read-only git checkouts on your machine, through the git credentials you already have.
20
20
 
21
- ## Install
21
+ ## Why not just clone it?
22
22
 
23
- You need Node.js 24.2 or newer, and git. On Windows use
24
- [Git for Windows](https://gitforwindows.org/), because the read-only guards are `sh` scripts
25
- and need the shell it ships with. The CLI behaves the same on all three platforms, and its
26
- full test suite runs on each of them.
23
+ Your agent can already clone a repository. Cloning is the easy part. `refs` keeps the repositories you name, sends a question to the right one, refreshes them when they go stale, and gives the agent a repeatable way to read them.
24
+
25
+ What you save is the bookkeeping. You do not remember where a clone went, paste a path, or open anything first. You say the name, from whichever project you happen to be in.
26
+
27
+ ## You talk to the agent, not to the CLI
28
+
29
+ This package is the CLI. The skill that drives it installs separately:
27
30
 
28
31
  ```bash
29
32
  npm i -g @kaisers-io/refs
30
- refs init # seeds the refs home directory and the git hooks guard
31
- refs doctor # confirms git, node and the setup are in order
33
+ refs init # seeds the refs home and the git hooks guard
34
+ npx skills add kaisers-io/refs # installs the agent skill
35
+ refs doctor # confirms git, node and the setup
32
36
  ```
33
37
 
34
- ## The agent skill
38
+ You need Node.js 24.2 or newer, and git. On Windows use [Git for Windows](https://gitforwindows.org/), because the read-only guards are `sh` scripts and need the shell it ships with. The CLI behaves the same on all three platforms, and its full test suite runs on each of them.
35
39
 
36
- This package is the CLI. The skill that drives it lives in the
37
- [GitHub repository](https://github.com/kaisers-io/refs) and installs separately:
40
+ `/refs` is what reaches the skill in Claude Code. In Codex the same thing is `$refs`. It never activates on its own, so questions that need no source code cost you nothing.
38
41
 
39
- ```bash
40
- npx skills add kaisers-io/refs
42
+ Then talk to the agent:
43
+
44
+ ```
45
+ /refs add npm:effect as a ref
41
46
  ```
42
47
 
43
- Invoke it with `/refs` in Claude Code or `$refs` in Codex. It never activates on its own.
44
- In Claude Code its description also stays out of the context window until you ask for it,
45
- so questions that need no source code cost you nothing.
48
+ It clones the repository, works out how the project tags its releases, and shows you what it found. Nothing enters your configuration until you approve it.
49
+
50
+ That happens once. Effect is a ref from then on, and every later question about it goes straight to the checkout, from any project and any session.
51
+
52
+ Three ways to name the same repository. All of them resolve to the key `github.com/Effect-TS/effect`:
53
+
54
+ | Source | What it is |
55
+ | ------------------------------------- | ------------------------------------------------------------------ |
56
+ | `npm:effect` | The package name. `refs` reads the repository out of the registry. |
57
+ | `https://github.com/Effect-TS/effect` | The repository itself, as you would clone it. |
58
+ | `git@github.com:Effect-TS/effect.git` | The same over ssh. |
46
59
 
47
- The agent route is the one to reach for first. It can search the source, follow what it
48
- finds, and talk with you about it. Its answers name the file and line they came from, so
49
- you can check a claim instead of trusting it, and they are clickable wherever your
50
- terminal or app opens file links.
60
+ The `npm:` prefix says which registry the name belongs to, so a package and a repository that share a name cannot be confused for one another. A private repository or a self-hosted forge works the same way, and the credentials stay in your git configuration because `refs` refuses to take any in the URL.
51
61
 
52
62
  ## Driving the CLI yourself
53
63
 
54
- Useful for scripting, or for checking what the agent did.
64
+ The agent runs these. Typing one yourself is quicker for some of them, and `refs sync` is the one most people reach for. `refs doctor` is the one to run after updating refs: the CLI and the skill each carry a version, and it says when they have drifted apart.
55
65
 
56
66
  ```bash
57
- refs add npm:zod --dry-run --json > proposal.json # clones and proposes, no config entry yet
58
- # open proposal.json and fill in every empty description, including each package's
59
- refs add --proposal proposal.json --json # finalize
67
+ # clones and proposes; nothing is configured yet
68
+ refs add npm:effect --dry-run --json > proposal.json
69
+ # fill in every empty description, including each package's
70
+ refs add --proposal proposal.json --json # finalize
71
+ refs sync --json # fetch every configured ref
60
72
  ```
61
73
 
62
- Finalize rejects a proposal that still has an empty description, which is what keeps refs
63
- from inventing one for you.
74
+ That middle line is the work the agent does for you. A monorepo ships dozens of packages and each wants a description, written from what the source says rather than copied out of a manifest.
64
75
 
65
- You can skip the file when every package already carries a description in its own manifest:
76
+ The [full command reference](https://github.com/kaisers-io/refs/blob/main/docs/commands.md) has every flag, every `--json` shape and every exit code.
66
77
 
67
- ```bash
68
- refs add https://github.com/stevemao/left-pad --description "Left-pad a string." --json
69
- ```
78
+ ## What lives on your machine
70
79
 
71
- Every command takes `--json` for a stable machine-readable envelope, and `--verbose` for
72
- stack traces. Both are global flags, so they are listed under `refs --help` rather than
73
- under each command's own help.
74
-
75
- | Command | What it does |
76
- | -------------- | ------------------------------------------------------------------------------------- |
77
- | `refs init` | Seed or migrate the refs home directory, its config and the git hooks guard. |
78
- | `refs add` | Add a git reference: propose with `--dry-run`, then finalize with `--proposal`. |
79
- | `refs list` | List configured refs with their staleness and missing-checkout status. |
80
- | `refs show` | Show one ref: entry, state, local path, package count. |
81
- | `refs sync` | Fetch configured refs, or re-clone the ones whose checkout went missing. |
82
- | `refs resolve` | Resolve a git url, npm package name, import path or key suffix to its ref or package. |
83
- | `refs tag` | Resolve a version to its git tag through the ref's `tag_format`, or a package's. |
84
- | `refs edit` | Edit one field of a global setting, a ref or a package. |
85
- | `refs remove` | Remove a ref: its config and state entry, and its checkout directory. |
86
- | `refs doctor` | Check the environment and the integrity of what refs manages. |
87
- | `refs migrate` | Migrate the config to the current schema, seeding it if absent. |
88
-
89
- Full reference, including exit codes and `--json` shapes:
90
- [`docs/commands.md`](https://github.com/kaisers-io/refs/blob/main/docs/commands.md).
80
+ Checkouts sit under `~/.kaisers-io/refs/sources/` as ordinary git repositories, in one place rather than one per project, so every session reaches the same collection. You can open them in your editor, grep them, and read them without an agent. Set `REFS_HOME` to keep them somewhere else, on another disk for instance, and everything `refs` owns moves with it: see [configuration](https://github.com/kaisers-io/refs/blob/main/docs/configuration.md). No service holds a copy of your code. What the agent reads is handled under that agent's own model and data settings.
91
81
 
92
- ## Read-only is a promise, not a sandbox
82
+ A checkout is the default branch at the revision you last fetched. It is not necessarily the version you have installed, and it does not refresh itself. `refs sync` fetches, and the skill runs it when a checkout has gone stale.
93
83
 
94
- Every checkout is a reference, not a working copy. `refs` installs git hooks that reject
95
- commits and pushes inside one, and `refs sync` restores a checkout that got dirty anyway.
84
+ ## Read-only is a promise, not a sandbox
96
85
 
97
- Those hooks are a backstop against mistakes. A determined local process can still write
98
- into a checkout, so treat this as a workflow that holds, not as a security boundary.
86
+ Every checkout under `sources/` is reference material. Agents are instructed never to edit, commit or push inside one, and `refs` installs git hooks that reject both. When a checkout gets dirty anyway, `refs sync` restores it.
99
87
 
100
- ## Changelog
88
+ The hooks are a backstop against mistakes, not a security boundary. A determined local process can still write into a checkout.
101
89
 
102
- `CHANGELOG.md` ships inside this package, so npm's "Code" tab shows it without leaving the
103
- package page.
90
+ ## More
104
91
 
105
- ## License
92
+ - [Worked investigations](https://github.com/kaisers-io/refs/blob/main/docs/investigations.md), each ending in what the answer leaves open.
93
+ - [Configuration](https://github.com/kaisers-io/refs/blob/main/docs/configuration.md): `config.toml`, `state.json`, per-ref settings and `REFS_HOME`.
94
+ - [Changelog](https://github.com/kaisers-io/refs/blob/main/CHANGELOG.md).
106
95
 
107
- MIT
96
+ MIT licensed.
package/dist/refs.mjs CHANGED
@@ -325,7 +325,7 @@ sync_ttl = "1h"
325
325
  `));return id(i,a)?[jd]:a},Ld=async(e,t,n)=>{let[r,i]=await Promise.all([Fd(e,t,n),Id(e,t,n)]);return{npm:r,pnpm:i}},Rd=(e,t)=>{let n=0;for(let r of t)if(n<e.length&&e[n]===r)n+=1;else if(r.startsWith(`!`))return!1;return n===e.length},zd=async(e,t)=>{if(!t.touched)return!1;let[n,r]=await Promise.all([Ld(e,t,t.from),Ld(e,t,t.to)]);return!Rd(n.npm,r.npm)||!Rd(n.pnpm,r.pnpm)},Bd=e=>se(e)===`package.json`,Vd=async(e,t,n)=>{let r=await e.run(`git`,[...n],{cwd:t});return r.exitCode===0&&!Dd(r)?r.stdout:void 0},Hd=e=>e.split(`\0`).filter(e=>e.length>0&&Bd(e)),Ud=async(e,t)=>{let n=await Vd(e,t.dir,[`diff`,`--name-only`,`-z`,`--no-renames`,`${t.from}..${t.to}`,`--`,`*package.json`,Md]);return n===void 0?void 0:n.split(`\0`).filter(e=>e.length>0)},Wd=async(e,t)=>{if(t.paths.length===0)return new Set;let n=await Vd(e,t.dir,[`ls-tree`,`-r`,`-z`,`--name-only`,t.rev,`--`,...t.paths]);return n===void 0?void 0:new Set(Hd(n))},Gd=async(e,t)=>{let n=await Vd(e,t.dir,[`show`,`${t.rev}:${t.path}`]);if(n!==void 0)try{let e=JSON.parse(n);return{name:Qu(e)}}catch{return}},Kd=async(e,t,n)=>{let r=[];for(let i of n){let n=await Gd(e,{dir:t.dir,path:i,rev:t.rev});if(n===void 0)return;n.name!==void 0&&r.push(n.name)}return r},qd={changedDirs:[],namesBefore:[]},Jd=(e,t,n)=>zd(e,{...t,touched:n.some(e=>e===`pnpm-workspace.yaml`||e===`package.json`)}),Yd=e=>[...new Set(e.map(e=>m(e)))].filter(e=>e!==`.`).toSorted(),Xd=async(e,t,n)=>{let r=await Wd(e,{dir:t.dir,paths:n,rev:t.from});if(r!==void 0)return Kd(e,{dir:t.dir,rev:t.from},n.filter(e=>r.has(e)))},Zd=async(e,t)=>{if(t.from===t.to)return qd;let n=await Ud(e,t);if(n===void 0||await Jd(e,t,n))return;let r=n.filter(e=>Bd(e));if(r.length>200)return;let i=await Xd(e,t,r);return i===void 0?void 0:{changedDirs:Yd(r),namesBefore:i}},Qd=e=>{let t=e.stderr.trim()||e.stdout.trim()||`exit code ${e.exitCode}`,n=t.split(`
326
326
  `)[0]??t;return n.length<=200?n:`${n.slice(0,200)}…`},$d=(e,t)=>t?`restored`:e.oldSha===e.newSha?`fresh`:`updated`,ef=(e,t)=>{let n=[];if(e&&n.push(`checkout had local changes (managed checkouts are read-only) — discarded and restored to the remote state`),t!==void 0&&n.push(t),n.length!==0)return n.join(` | `)},tf=e=>{let{branchRenamedTo:t,dirty:n,setHeadWarning:r,shas:i}=e,a={...i,status:$d(i,n)};t!==void 0&&(a.branchRenamedTo=t);let o=ef(n,r);return o!==void 0&&(a.warning=o),a},nf=(e,t,n)=>{let r={dirty:t,shas:n};return e.branchRenamedTo!==void 0&&(r.branchRenamedTo=e.branchRenamedTo),e.warning!==void 0&&(r.setHeadWarning=e.warning),r},U=e=>ie(h(e,`.git`)),rf=e=>`refusing to sync ${e}: not a refs-managed checkout`,af=async(e,t,n)=>{if(!U(t))throw z(rf(t));let r=await e.run(`git`,[`config`,`--local`,`--get`,`core.hooksPath`],{cwd:t}),i=r.stdout.trim();if(r.exitCode!==0||i===``||i!==n)throw z(rf(t))},of=/^(?<scheme>[a-z][a-z0-9+.-]*:\/\/)?[\s\S]*@/iu,sf=/(?<scheme>[a-z][a-z0-9+.-]{0,31}:\/\/)[^/\s@]{1,256}@/giu,cf=e=>e.replace(sf,`$<scheme><redacted>@`),lf=/^git@[^:/\s]+:[^\s]+$/u,uf=e=>{try{return new URL(e)}catch{return}},df=e=>e.password===``&&e.username===`git`&&e.protocol===`ssh:`,ff=e=>{if(lf.test(e))return e;let t=uf(e);return t===void 0?e.includes(`@`)?W(e):e:t.username===``&&t.password===``||df(t)?e:`${t.protocol}//<redacted>@${t.host}${t.pathname}${t.search}${t.hash}`},W=e=>{let t=e.replace(of,`$<scheme><redacted>@`);return t.length<=200?t:`${t.slice(0,200)}…`},pf=e=>{let t=cf(e);return t.length<=2e3?t:`${t.slice(0,2e3)}… (truncated)`},mf=/filtering not recognized/iu,hf=e=>e===void 0?{}:{cwd:e},gf=(e,t,n)=>({action:e,args:t,cmd:`git`,...hf(n)}),_f=async(e,t)=>{let n=await e.run(t.cmd,t.args,hf(t.cwd));if(n.exitCode===0)return n;let r=n.stderr.trim()||n.stdout.trim()||`exit code ${n.exitCode}`;throw z(`${t.action} failed: ${pf(r)}`)},vf=async(e,t)=>{let n=[`clone`,`-q`,`-c`,`core.hooksPath=${t.hooksDir}`];t.mode===`blobless`&&n.push(`--filter=blob:none`),n.push(`--`,t.cloneUrl,t.dest);let r=await _f(e,gf(`git clone`,n));return await _f(e,gf(`git config core.hooksPath`,[`config`,`core.hooksPath`,t.hooksDir],t.dest)),t.mode===`blobless`&&mf.test(r.stderr)?{effectiveMode:`full`,warning:`server did not honour the partial-clone filter (blob:none); fell back to a full clone`}:{effectiveMode:t.mode}},yf=async(e,t)=>{let n=await e.run(`git`,[`symbolic-ref`,`--short`,`refs/remotes/origin/HEAD`],{cwd:t});if(n.exitCode!==0)return;let r=n.stdout.trim();return r.startsWith(`origin/`)?r.slice(7):r},bf=async(e,t)=>{let n=await yf(e,t);if(n!==void 0)return n;await e.run(`git`,[`remote`,`set-head`,`origin`,`--auto`],{cwd:t});let r=await yf(e,t);if(r!==void 0)return r;throw z(`could not detect the default branch for checkout: ${t}`)},xf=async(e,t)=>(await _f(e,gf(`git rev-parse HEAD`,[`rev-parse`,`HEAD`],t))).stdout.trim(),Sf=async(e,t)=>(await _f(e,gf(`git status --porcelain`,[`status`,`--porcelain`],t))).stdout.trim()!==``,Cf=async(e,t)=>{await _f(e,gf(`git fetch`,[`fetch`,`--prune`,`--tags`,`origin`],t.dir));let n=await e.run(`git`,[`remote`,`set-head`,`origin`,`--auto`],{cwd:t.dir}),r=await bf(e,t.dir),i={branch:r};return r!==t.defaultBranch&&(i.branchRenamedTo=r),n.exitCode!==0&&(i.warning=`could not refresh origin/HEAD: ${Qd(n)}`),i},wf=e=>[gf(`git reset --hard HEAD (pre-checkout)`,[`reset`,`--hard`,`HEAD`],e),gf(`git clean -fd`,[`clean`,`-fd`],e)],Tf=async(e,t)=>{let{branch:n,dir:r,dirty:i}=t,a=[];i&&a.push(...wf(r)),a.push(gf(`git checkout -B`,[`checkout`,`-B`,n,`origin/${n}`],r),gf(`git reset --hard`,[`reset`,`--hard`,`origin/${n}`],r));for(let t of a)await _f(e,t)},Ef=async(e,t)=>{await af(e,t.dir,t.hooksDir);let n=await xf(e,t.dir),r=await Cf(e,t),i=await Sf(e,t.dir);await Tf(e,{branch:r.branch,dir:t.dir,dirty:i});let a=await xf(e,t.dir);return tf(nf(r,i,{newSha:a,oldSha:n}))},Df=async(e,t,n)=>(await e.run(`git`,[`show-ref`,`--verify`,`--`,`refs/tags/${n}`],{cwd:t})).exitCode===0,Of=[`#!/bin/sh`,`echo "refs: this checkout is a managed read-only reference — commits are blocked" >&2`,`exit 1`,``].join(`
327
327
  `),kf=async e=>{await Promise.all([`pre-commit`,`pre-push`].map(async t=>{await au(h(e.hooksDir,t),Of,493)}))},Af=async(e,t,n)=>{let r=await _f(e,gf(`git tag`,[`tag`,`--sort=-version:refname`],t)),i=r.stdout.split(`
328
- `).map(e=>e.trim()).filter(e=>e!==``),a=r.stdoutTruncated!==!0;return n===void 0?{complete:a,tags:i}:{complete:a&&i.length<=n,tags:i.slice(0,n)}},jf=/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?/u,Mf=/\d+\.\d+\.\d+/gu,Nf=e=>sl.safeParse(e).success,Pf=e=>{let t=e.match(Mf);return t!==null&&t.length>1},Ff=e=>{let t=jf.exec(e);if(!t||Pf(e))return;let[n]=t,r=e.replace(n,`{version}`);if(Nf(r))return r},If=(e,t,n)=>{let r=e.get(t);r===void 0?e.set(t,{count:1,index:n}):r.count+=1},Lf=e=>{let t=new Map;for(let[n,r]of e.entries()){let e=Ff(r);e&&If(t,e,n)}return t},Rf=(e,t)=>e.count>t.count||e.count===t.count&&e.index<t.index,zf=e=>{let t=[...e.entries()],[n]=t;if(n===void 0)return null;let[r,i]=n;return t.slice(1).reduce(({format:e,data:t},[n,r])=>Rf(r,t)?{data:r,format:n}:{data:t,format:e},{data:i,format:r}).format},Bf=e=>{let t=Lf(e);return zf(t)},Vf=(e,t)=>e.replaceAll(`{version}`,()=>t),Hf=async(e,t,n,r)=>{let i=Vf(n,r);if(!await Df(e,t,i))throw L(`tag '${i}' not found in ${t} — check the version or tag_format`);return i},Uf=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]+)?$/u,Wf=/[0-9.]$/u,Gf=[`@`,`-`,`_`,`/`],Kf=`{version}`,qf=(e,t)=>Gf.some(n=>e===`${t}${n}`||e===`${t}${n}v`),Jf=(e,t)=>qf(e.slice(0,e.length-9),t)&&e.endsWith(Kf),Yf=(e,t)=>t!==void 0&&qf(e,t)?2:+(e===``||e===`v`),Xf=(e,t)=>{if(!e.endsWith(t))return;let n=e.slice(0,e.length-t.length);return Wf.test(n)?void 0:n},Zf=(e,t,n)=>{let r=Xf(e,t);if(r===void 0)return;let i=sl.safeParse(`${r}${Kf}`);if(i.success&&Vf(i.data,t)===e)return{format:i.data,rank:Yf(r,n)}},Qf=e=>{let t=e.filter(e=>e.rank>0),n=t.reduce((e,t)=>Math.max(e,t.rank),0),r=new Set(t.filter(e=>e.rank===n).map(e=>e.format)),[i]=[...r];return r.size===1&&i!==void 0?i:null},$f=(e,t,n)=>t.length>64||!Uf.test(t)?null:Qf(e.map(e=>Zf(e,t,n)).filter(e=>e!==void 0)),ep=e=>e.split(`/`).some(e=>e===`.`||e===`..`),tp=e=>e.includes(`\\`),np=e=>e.includes(`%`),rp=/[\u0000-\u001F\u007F]/u,ip=/^ | $/u,ap=/[?#]/u,op=(e,t)=>`not a supported git url: control character ${`U+${(e.codePointAt(t)??0).toString(16).toUpperCase().padStart(4,`0`)}`} at position ${String(t)}`,sp=(e,t)=>{let n=e.search(rp);if(n!==-1)throw z(op(e,n));if(ip.test(e))throw z(`not a supported git url: leading or trailing space`);if(ap.test(e))throw z(`not a supported git url: query or fragment in ${W(t)}`);cp(e,t),lp(e,t)},cp=(e,t)=>{if(tp(e))throw z(`not a supported git url: backslash not allowed in ${W(t)}`)},lp=(e,t)=>{if(ep(e))throw z(`not a supported git url: path traversal segment in ${W(t)}`)},up=(e,t,n)=>{if(e.protocol!==`file:`&&np(t))throw z(`not a supported git url: percent-encoding not supported in ${W(n)}`)},dp=/\.git$/u,fp=e=>e.replace(dp,``),pp=e=>{let t=0,n=e.length;for(;t<n&&e.charAt(t)===`/`;)t+=1;for(;n>t&&e.charAt(n-1)===`/`;)--n;return e.slice(t,n)},mp=/^git@(?<host>[^:/\s]+):(?<path>[^\s]+)$/u,hp=/^git\+/u,gp={"https:":`443`,"ssh:":`22`},_p=e=>{let t=nl.safeParse(e);if(!t.success)throw z(`not a supported git url: derived key '${W(e)}' is invalid`);return t.data},vp=({host:e,port:t,protocol:n})=>{let r=gp[n];return t===``||t===r?e.toLowerCase():`${e.toLowerCase()}_${t}`},yp=e=>{let t=fp(pp(e.path));return _p(`${vp(e)}/${t}`)},bp=e=>{let t=decodeURIComponent(e).split(`/`).filter(e=>e!==``);if(t.length<2)throw z(`not a supported git url: file url path must have at least 2 segments`);let n=t.at(-2)??``,r=t.at(-1)??``;return _p(`local/${n}/${r}`)},xp=(e,t)=>{try{return new URL(e)}catch{throw z(`not a supported git url: ${W(t)}`)}},Sp=e=>{if(e.password!==``)throw z(`not a supported git url: credentials embedded in url`);if(e.protocol===`https:`&&e.username!==``)throw z(`not a supported git url: credentials embedded in https url`)},Cp=(e,t)=>{if(e.protocol===`file:`){if(!t)throw z(`not a supported git url: unsupported protocol ${e.protocol}`);return bp(e.pathname)}if(e.protocol!==`https:`&&e.protocol!==`ssh:`)throw z(`not a supported git url: unsupported protocol ${e.protocol}`);return Sp(e),yp({host:e.hostname,path:e.pathname,port:e.port,protocol:e.protocol})},wp=(e,t)=>{if(np(e))throw z(`not a supported git url: percent-encoding not supported in ${W(t)}`);if(e.includes(`:`))throw z(`not a supported git url: ambiguous ':' in scp-style path ${W(t)}; use the ssh:// url form instead`);if(e.startsWith(`/`)||e.startsWith(`~`))throw z(`not a supported git url: ambiguous absolute/home-relative scp path in ${W(t)}; use the ssh:// url form instead`)},Tp=(e,t)=>{let n=e.groups?.path??``;return wp(n,t),yp({host:e.groups?.host??``,path:n,port:``,protocol:`ssh:`})},Ep=(e,t)=>{let n=t?.allowFileUrls??!1,r=e.replace(hp,``);sp(r,e);let i=mp.exec(r);if(i?.groups!==void 0)return{cloneUrl:r,key:Tp(i,e)};let a=xp(r,e);return up(a,r,e),{cloneUrl:r,key:Cp(a,n)}},Dp=`.git`,Op=e=>e.endsWith(Dp)?e:`${e}${Dp}`,kp=(e,t)=>`https://${e.toLowerCase()}/${pp(t)}`,Ap=(e,t)=>`git@${e.toLowerCase()}:${Op(pp(t))}`,jp=e=>{if(e===`https:`)return`https`;if(e===`ssh:`)return`ssh`;throw z(`not a supported git url: unsupported protocol ${e}`)},Mp=(e,t,n)=>{let r=gp[e.protocol];if(e.port!==``&&e.port!==r)throw z(`cannot apply git_transport=${t} to ${W(n)}: its non-default port ${e.port} cannot be expressed in the ${t} url form — add the repo with an explicit url instead`)},Np=(e,t)=>t===`https`?kp(e.hostname,e.pathname):Ap(e.hostname,e.pathname),Pp=(e,t,n)=>{let r=Ep(t).key;if(r!==n)throw z(`git_transport transform changed repo identity: '${W(e)}' → '${t}' (key '${n}' → '${r}')`);return t},Fp=(e,t)=>{if(t.transport===`ssh`)return t.cloneUrl;let n=e.groups?.host??``,r=e.groups?.path??``;return Pp(t.cloneUrl,kp(n,r),t.originalKey)},Ip=e=>{let t=xp(e.cloneUrl,e.cloneUrl);return jp(t.protocol)===e.transport?e.cloneUrl:(Mp(t,e.transport,e.cloneUrl),Pp(e.cloneUrl,Np(t,e.transport),e.originalKey))},Lp=(e,t)=>{if(e.startsWith(`file:`))return e;let n={cloneUrl:e,originalKey:Ep(e).key,transport:t},r=mp.exec(e);return r?.groups===void 0?Ip(n):Fp(r,n)},Rp=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u,zp=(e,t)=>{if(Rp.test(t))return h(e,`lease-${t}`)},Bp=async(e,t)=>{let n=zp(e,t);n!==void 0&&await(await o(n,`w`,384)).close()},Vp=async(e,t)=>{let n=zp(e,t);if(n===void 0)return`gone`;let r=new Date;try{await ee(n,r,r)}catch(e){if(F(e))return`gone`;throw e}return`renewed`},Hp=async(e,t)=>{let n=zp(e,t);if(n===void 0)return{state:`absent`};try{return{mtimeMs:(await p(n)).mtimeMs,state:`ok`}}catch(e){return{state:F(e)?`absent`:`unreadable`}}},Up=`meta.json`,Wp=e=>{try{return process.kill(e,0),!0}catch(e){return ru(e)!==`ESRCH`}},Gp=e=>{try{return JSON.parse(e)}catch{return}},Kp=async e=>{try{return await s(e,`utf8`)}catch{return}},qp=new Set([`ENOENT`,`ENOTDIR`]),Jp=async e=>{try{return{state:`read`,text:await s(e,`utf8`)}}catch(e){let t=ru(e);return{state:t!==void 0&&qp.has(t)?`missing`:`unreadable`}}},Yp=e=>{if(typeof e!=`string`)return;let t=Date.parse(e);if(!Number.isNaN(t))return t},Xp=e=>{if(typeof e!=`object`||!e)return;let{token:t}=e;if(typeof t==`string`)return t},Zp=e=>{if(!(typeof e!=`number`||!Number.isSafeInteger(e)||e<=0||e>2147483647))return e},Qp=e=>{if(typeof e!=`object`||!e)return;let t=e,n=Zp(t.pid),r=Yp(t.acquired_at);if(n===void 0||r===void 0)return;let i=Xp(e);return{acquiredAtMs:r,pid:n,...i===void 0?{}:{token:i}}},$p=async e=>{let t=await Kp(h(e,Up));if(t!==void 0)return Xp(Gp(t))},em=async e=>{let t=await Jp(h(e,Up));if(t.state!==`read`)return{state:t.state};let n=Qp(Gp(t.text));return n===void 0?{state:`malformed`}:{meta:n,state:`valid`}},tm=async e=>{try{return{mtimeMs:(await p(e)).mtimeMs,state:`ok`}}catch(e){return{state:ru(e)===`ENOENT`?`gone`:`unreadable`}}},nm=async(e,t)=>{let n=h(e,Up),r=`${n}.tmp-${he()}`;await te(r,t,{encoding:`utf8`,mode:384}),await u(r,n)},rm=()=>he(),im=async(e,t)=>{await Bp(e,t),await nm(e,JSON.stringify({acquired_at:new Date().toISOString(),pid:process.pid,token:t}))},am=5e3,om=async(e,t,n)=>{if(t===`unreadable`)return{meta:t,observedAtMs:n,pidState:`unknown`,policy:`unknown`,stale:!1};let r=await tm(e);if(r.state===`gone`)return{meta:t,observedAtMs:n,pidState:`unknown`,policy:`none`,stale:!1};if(r.state===`unreadable`)return{meta:t,observedAtMs:n,pidState:`unknown`,policy:`unknown`,stale:!1};let i=n-r.mtimeMs;return{ageMs:i,budgetMs:am,meta:t,observedAtMs:n,pidState:`unknown`,policy:`grace`,stale:i>am}},sm=async(e,t,n)=>{let r=t.token===void 0?{state:`absent`}:await Hp(e,t.token);return r.state===`unreadable`?{policy:`unknown`}:r.state===`absent`?{ageMs:n-t.acquiredAtMs,budgetMs:6e5,policy:`legacy`}:{ageMs:n-r.mtimeMs,budgetMs:12e4,policy:`lease`}},cm=async(e,t)=>{let n=await em(e);if(n.state!==`valid`)return om(e,n.state,t);let{meta:r}=n,i=await sm(e,r,t),a=!Wp(r.pid),o=i.ageMs!==void 0&&i.budgetMs!==void 0&&i.ageMs>i.budgetMs;return{...i,meta:`valid`,observedAtMs:t,pid:r.pid,pidState:a?`definitely-dead`:`present-or-unknown`,stale:a||o,...r.token===void 0?{}:{token:r.token}}},lm=e=>e.meta===`valid`&&e.pidState===`definitely-dead`&&e.token!==void 0,um=async(e,t)=>await $p(e)===t?await Vp(e,t)===`gone`?`lost`:`renewed`:`lost`,dm=new Set([`EEXIST`,`EPERM`,`EACCES`,`EBUSY`]),fm=new Set([`ENOENT`,`EPERM`,`EACCES`,`EBUSY`]),pm=async e=>{try{return await a(e,{mode:448,recursive:!1}),!0}catch(e){let t=ru(e);if(t!==void 0&&dm.has(t))return!1;throw e}},mm=async(e,t)=>{try{return await u(e,t),!0}catch(e){let t=ru(e);if(t!==void 0&&fm.has(t))return!1;throw e}},hm=e=>a(e,{mode:448,recursive:!0}),gm=`.claims`,_m=`.tombstones`,vm=(e,t)=>({lockPath:h(e,t),locksDir:e,name:t}),ym=e=>h(e.locksDir,gm,e.name),bm=e=>h(e.locksDir,_m,he()),xm=async e=>{await a(h(e,gm),{mode:448,recursive:!0}),await a(h(e,_m),{mode:448,recursive:!0})},Sm=e=>pm(e),Cm=async e=>{try{await f(e)}catch{}},wm=async e=>{let t=bm(e);return await mm(e.lockPath,t)?t:void 0},Tm=async e=>{let t=await cm(e.lockPath,Date.now());if(!lm(t)||await $p(e.lockPath)!==t.token)return!1;let n=await wm(e);return n!==void 0&&(await d(n,{force:!0,recursive:!0}),!0)},Em=async e=>{await xm(e.locksDir);let t=ym(e);if(!await Sm(t))return!1;let n=await Tm(e).then(e=>({ok:!0,stolen:e}),e=>({error:e,ok:!1}));if(await Cm(t),!n.ok)throw n.error;return n.stolen},Dm=async e=>{try{return(await c(e,{withFileTypes:!0})).map(e=>({isDir:e.isDirectory(),name:e.name})).toSorted((e,t)=>e.name.localeCompare(t.name))}catch(e){if(F(e))return[];throw e}},Om=async e=>(await Dm(e)).filter(e=>!e.name.startsWith(`.`)),km=async(e,t,n)=>{let r=await cm(h(e,t.name),n);if(r.policy!==`none`)return{diagnosis:r,isDirectory:t.isDir,kind:`lock`,name:t.name}},Am=async(e,t)=>{let n=h(e,gm),r=await Dm(n);return(await Promise.all(r.map(async e=>({diagnosis:await cm(h(n,e.name),t),isDirectory:e.isDir,kind:`claim`,name:e.name})))).filter(e=>e.diagnosis.policy!==`none`)},jm=async e=>{let t=Date.now(),n=await Om(e.locksDir),[r,i]=await Promise.all([Promise.all(n.map(n=>km(e.locksDir,n,t))),Am(e.locksDir,t)]);return[...r.filter(e=>e!==void 0),...i]},Mm=e=>{let t=Math.floor(e/1e3),n=t%60,r=Math.floor(t/60),i=r%60,a=Math.floor(r/60);return a>0?i===0?`${a}h`:`${a}h ${i}m`:r>0?n===0?`${r}m`:`${r}m ${n}s`:`${n}s`},Nm=e=>e.pid===void 0?`owner unknown (metadata ${e.meta})`:e.pidState===`definitely-dead`?`recorded pid ${e.pid} is not running`:`recorded pid ${e.pid} is present (identity not verified)`,Pm={grace:`created`,lease:`lease renewed`,legacy:`acquired`,none:`observed`,unknown:`observed`},Fm={grace:`from creation, while its metadata has not been published`,lease:`from the last renewal`,legacy:`from acquisition (no renewable lease)`,none:``,unknown:``},Im=e=>{let{ageMs:t,budgetMs:n,policy:r}=e;return t===void 0||n===void 0?``:t<0?`, but its recorded time is in the future — check the system clock`:`, ${Pm[r]} ${Mm(t)} ago; its window is ${Mm(n)} ${Fm[r]}`},Lm=(e,t)=>{if(t.policy===`none`)return`lock ${e} could not be acquired before the timeout, but it was released while the failure was being diagnosed. Retry the operation.`;let n=`lock ${e} is held: ${Nm(t)}`;return lm(t)?`${n}, and refs is entitled to reclaim it — it could not do so before the timeout. Retry; if it persists, run refs doctor.`:t.stale?`${n}${Im(t)}. refs does not reclaim this automatically: only a recorded process the operating system reports as gone is reclaimed, and this one is not. Run refs doctor for what to do about it.`:`${n}${Im(t)}. Retry once the other refs command finishes.`},Rm=(e,t)=>{if(t.stopped)return;let n=setTimeout(()=>{t.stopped||(t.inFlight=zm(e,t))},e.intervalMs);n.unref(),t.timer=n},zm=async(e,t)=>{try{if(await e.renew()===`lost`){t.lost=!0,t.stopped=!0;return}}catch{}Rm(e,t)},Bm=e=>{let t={inFlight:Promise.resolve(),lost:!1,stopped:!1};return Rm(e,t),{ownershipLost:()=>t.lost,stop:async()=>{t.stopped=!0,t.timer!==void 0&&clearTimeout(t.timer),await t.inFlight}}},Vm=/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/u,Hm=async(e,t)=>{try{await im(e,t)}catch(e){if(ru(e)===`ENOENT`)return`retry`;throw e}return t},Um=async(e,t)=>{if(!await pm(e))return;let n=await Hm(e,rm());return n===`retry`?Date.now()>=t?void 0:Um(e,t):n},Wm=async(e,t)=>{if(!await Em(e)){if(Date.now()>=t){let t=await cm(e.lockPath,Date.now());throw su(Lm(e.name,t))}await xe(100)}},Gm=async(e,t)=>{let n=await Um(e.lockPath,t);return n===void 0?(await Wm(e,t),Gm(e,t)):n},Km=async(e,t)=>await $p(e)===t&&(await d(e,{force:!0,recursive:!0}),!0),qm=async e=>{try{return{ok:!0,value:await e()}}catch(e){return{error:e,ok:!1}}},Jm=async(e,t,n,r)=>{await n.stop();let i=await qm(()=>Km(e.lockPath,t));if(!r.ok)throw r.error;if(!i.ok)throw i.error;if(n.ownershipLost()||!i.value)throw su(`lock ${e.name} was lost while the operation was running`);return r.value},Ym=e=>e!==`.`&&e!==`..`&&Vm.test(e),Xm=e=>{if(!Ym(e))throw z(`lock name must not contain "/" or other unsafe characters — only letters, digits, and "_.-" are allowed, and it may not be "." or "..": ${e}`)},G=async(e,t,n,r)=>{Xm(t);let i=vm(e.locksDir,t);await hm(e.locksDir);let a=Date.now()+(r?.timeoutMs??1e4),o=await Gm(i,a),s=Bm({intervalMs:3e4,renew:()=>um(i.lockPath,o)});return Jm(i,o,s,await qm(n))},Zm=sc({directory:j().optional(),url:j().optional()}),Qm=sc({repository:lc([j(),Zm]).optional()}),$m=/^(?:@[a-z0-9-~][a-z0-9._~-]*\/)?[a-z0-9-~][a-z0-9._~-]*$/u,eh=new Set([`node_modules`,`favicon.ico`]),th=e=>L(`package '${e}' has no usable repository field — find the repository and run: refs add <git-url>`),nh=e=>{let[t,n]=e.split(`/`);return n??t??e},rh=e=>{if(e.length>214)throw R(`invalid package name: '${e}' exceeds maximum length of 214 characters`);if(!$m.test(e))throw R(`invalid package name: '${e}' does not match npm naming rules`);let t=nh(e);if(eh.has(t))throw R(`invalid package name: '${e}' uses a reserved name`)},ih=e=>e.replaceAll(`/`,`%2F`),ah=e=>typeof e==`string`?e:e?.url,oh=e=>{if(typeof e==`object`&&e?.directory){let t=cl.safeParse(e.directory);if(t.success)return t.data}},sh=e=>e instanceof Error&&(e.name===`TimeoutError`||e.name===`AbortError`),ch=e=>z(`npm registry did not answer for '${e}' within 10000ms`),lh=async(e,t)=>{try{return await e.json()}catch(e){throw sh(e)?ch(t):z(`invalid npm registry response for '${t}': not parseable JSON`)}},uh=async(e,t)=>{try{return await e(`https://registry.npmjs.org/${ih(t)}`,{signal:AbortSignal.timeout(1e4)})}catch(e){throw sh(e)?ch(t):e}},dh=async(e,t)=>{let n=await uh(e,t);if(n.status===404)throw L(`npm package '${t}' not found`);if(n.status!==200)throw z(`failed to fetch npm package '${t}': status ${n.status}`);let r=await lh(n,t),i=Qm.safeParse(r);if(!i.success)throw z(`invalid npm package response for '${t}'`);return i.data},fh=(e,t)=>{try{return Ep(e)}catch{throw th(t)}},ph=async(e,t)=>{rh(t);let n=await dh(e,t),r=ah(n.repository);if(r===void 0||r===``)throw th(t);let{cloneUrl:i,key:a}=fh(r,t),o=oh(n.repository);return o===void 0?{cloneUrl:i,key:a}:{cloneUrl:i,directory:o,key:a}},mh=(e,t,n)=>{let r=e instanceof RegExp?hh(e,n):e,i=t instanceof RegExp?hh(t,n):t,a=r!==null&&i!=null&&gh(r,i,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+r.length,a[1]),post:n.slice(a[1]+i.length)}},hh=(e,t)=>{let n=t.match(e);return n?n[0]:null},gh=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i<a&&(a=i,o=l),l=n.indexOf(t,u+1);u=c<l&&c>=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},_h=`\0SLASH`+Math.random()+`\0`,vh=`\0OPEN`+Math.random()+`\0`,yh=`\0CLOSE`+Math.random()+`\0`,bh=`\0COMMA`+Math.random()+`\0`,xh=`\0PERIOD`+Math.random()+`\0`,Sh=new RegExp(_h,`g`),Ch=new RegExp(vh,`g`),wh=new RegExp(yh,`g`),Th=new RegExp(bh,`g`),Eh=new RegExp(xh,`g`),Dh=/\\\\/g,Oh=/\\{/g,kh=/\\}/g,Ah=/\\,/g,jh=/\\\./g;function Mh(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Nh(e){return e.replace(Dh,_h).replace(Oh,vh).replace(kh,yh).replace(Ah,bh).replace(jh,xh)}function Ph(e){return e.replace(Sh,`\\`).replace(Ch,`{`).replace(wh,`}`).replace(Th,`,`).replace(Eh,`.`)}function Fh(e){if(!e)return[``];let t=[],n=mh(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:i,post:a}=n,o=r.split(`,`);o[o.length-1]+=`{`+i+`}`;let s=Fh(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function Ih(e,t={}){if(!e)return[];let{max:n=1e5,maxLength:r=4e6}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),Uh(Nh(e),n,r,!0).map(Ph)}function Lh(e){return`{`+e+`}`}function Rh(e){return/^-?0\d/.test(e)}function zh(e,t){return e<=t}function Bh(e,t){return e>=t}function Vh(e,t,n,r,i,a){let o=[],s=0;for(let c=0;c<e.length;c++)for(let l=0;l<n.length;l++){if(o.length>=r)return o;let u=e[c]+t+n[l];if(!a||u){if(s+u.length>i)return o;o.push(u),s+=u.length}}return o}function Hh(e,t,n,r){let i=e.split(/\.\./),a=[];if(i[0]===void 0||i[1]===void 0)return a;let o=Mh(i[0]),s=Mh(i[1]),c=Math.max(i[0].length,i[1].length),l=i.length===3&&i[2]!==void 0?Math.max(Math.abs(Mh(i[2])),1):1,u=zh;s<o&&(l*=-1,u=Bh);let d=i.some(Rh),f=0;for(let e=o;u(e,s)&&a.length<n;e+=l){let n;if(t)n=String.fromCharCode(e),n===`\\`&&(n=``);else if(n=String(e),d){let t=c-n.length;if(t>0){let r=Array(t+1).join(`0`);n=e<0?`-`+r+n.slice(1):r+n}}if(f+n.length>r)break;a.push(n),f+=n.length}return a}function Uh(e,t,n,r){let i=[``],a=!1,o=!0;for(;;){let s=mh(`{`,`}`,e);if(!s)return Vh(i,e,[``],t,n,a);let c=s.pre;if(/\$$/.test(c)){if(i=Vh(i,c+`{`+s.body+`}`,[``],t,n,a&&!s.post.length),o=!1,!s.post.length)break;e=s.post;continue}let l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),d=l||u,f=s.body.indexOf(`,`)>=0;if(!d&&!f){if(s.post.match(/,(?!,).*\}/)){e=s.pre+`{`+s.body+yh+s.post,r=!0;continue}return Vh(i,c+`{`+s.body+`}`+s.post,[``],t,n,a)}o&&=(a=r&&!d,!1);let p;if(d)p=Hh(s.body,u,t,n);else{let r=Fh(s.body);if(r.length===1&&r[0]!==void 0&&(r=Uh(r[0],t,n,!1).map(Lh),r.length===1)){if(i=Vh(i,c+r[0],[``],t,n,a&&!s.post.length),!s.post.length)break;e=s.post;continue}let o=a&&!s.post.length&&!c;for(let e=0;o&&e<i.length;e++)i[e]&&(o=!1);p=[];let l=0;outer:for(let e=0;e<r.length;e++){let i=Uh(r[e],t,n,!1);for(let e=0;e<i.length;e++){let r=i[e];if(!o||r){if(p.length>=t||l+r.length>n)break outer;p.push(r),l+=r.length}}}}if(i=Vh(i,c,p,t,n,a&&!s.post.length),!s.post.length)break;e=s.post}return i}const Wh=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},Gh={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},Kh=e=>e.replace(/[[\]\\-]/g,`\\$&`),qh=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),Jh=e=>e.join(``),Yh=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1){l=!0,a++;continue}if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c){c=!0,a++;continue}if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(Gh))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue WHILE}}if(c=!1,d){t>d?r.push(Kh(d)+`-`+Kh(t)):t===d&&r.push(Kh(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(Kh(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(Kh(t)),a++}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l){let e=r[0].length===2?r[0].slice(-1):r[0];return[qh(e),!1,u-n,!1]}let f=`[`+(l?`^`:``)+Jh(r)+`]`,p=`[`+(l?``:`^`)+Jh(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},Xh=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\])\]/g,`$1$2`).replace(/\\([^/])/g,`$1`):t?e.replace(/\[([^/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,`$1$2`).replace(/\\([^/{}])/g,`$1`);var K;const Zh=new Set([`!`,`?`,`+`,`*`,`@`]),Qh=e=>Zh.has(e),$h=e=>Qh(e.type),eg=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),tg=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),ng=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),rg=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),ig=`(?!\\.)`,ag=new Set([`[`,`.`]),og=new Set([`..`,`.`]),sg=new Set(`().*{}+?[]^$\\!`),cg=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),lg=`[^/]+?`;let ug=0;var dg=class{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;id=++ug;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for(`nodejs.util.inspect.custom`)](){return{"@@type":`AST`,id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.#l=this.type?this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...e){for(let t of e)if(t!==``){if(typeof t!=`string`&&!(t instanceof K&&t.#i===this))throw Error(`invalid part: `+t);this.#r.push(t)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;t<this.#a;t++){let n=e.#r[t];if(!(n instanceof K&&n.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(e){let t=new K(this.type,e);for(let e of this.#r)t.copyIn(e);return t}static#f(e,t,n,r,i){let a=r.maxExtglobRecursion??2,o=!1,s=!1,c=-1,l=!1;if(t.type===null){let u=n,d=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,d+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),d+=n;continue}if(n===`[`){s=!0,c=u,l=!1,d+=n;continue}if(!r.noext&&Qh(n)&&e.charAt(u)===`(`&&i<=a){t.push(d),d=``;let a=new K(n,t);u=K.#f(e,a,u,r,i+1),t.push(a);continue}d+=n}return t.push(d),u}let u=n+1,d=new K(null,t),f=[],p=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,p+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),p+=n;continue}if(n===`[`){s=!0,c=u,l=!1,p+=n;continue}if(!r.noext&&Qh(n)&&e.charAt(u)===`(`&&(i<=a||t&&t.#h(n))){let a=t&&t.#h(n)?0:1;d.push(p),p=``;let o=new K(n,d);d.push(o),u=K.#f(e,o,u,r,i+a);continue}if(n===`|`){d.push(p),p=``,f.push(d),d=new K(null,t);continue}if(n===`)`)return p===``&&t.#r.length===0&&(t.#u=!0),d.push(p),p=``,t.push(...f,d),u;p+=n}return t.type=null,t.#t=void 0,t.#r=[e.substring(n-1)],u}#p(e){return this.#m(e,tg)}#m(e,t=eg){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null)return!1;let n=e.#r[0];return!n||typeof n!=`object`||n.type===null?!1:this.#h(n.type,t)}#h(e,t=ng){return!!t.get(this.type)?.includes(e)}#g(e,t){let n=e.#r[0],r=new K(null,n,this.options);r.#r.push(``),n.push(r),this.#_(e,t)}#_(e,t){let n=e.#r[0];this.#r.splice(t,1,...n.#r);for(let e of n.#r)typeof e==`object`&&(e.#i=this);this.#l=void 0}#v(e){return!!rg.get(this.type)?.has(e)}#y(e){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let t=e.#r[0];return!t||typeof t!=`object`||t.type===null?!1:this.#v(t.type)}#b(e){let t=rg.get(this.type),n=e.#r[0],r=t?.get(n.type);if(!r)return!1;this.#r=n.#r;for(let e of this.#r)typeof e==`object`&&(e.#i=this);this.type=r,this.#l=void 0,this.#u=!1}static fromGlob(e,t={}){let n=new K(null,void 0,t);return K.#f(e,n,0,t,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(e){let t=e??!!this.#c.dot;if(this.#e===this&&(this.#x(),this.#d()),!$h(this)){let n=this.isStart()&&this.isEnd()&&!this.#r.some(e=>typeof e!=`string`),r=this.#r.map(t=>{let[r,i,a,o]=typeof t==`string`?K.#C(t,this.#t,n):t.toRegExpSource(e);return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),i=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&og.has(this.#r[0]))){let n=ag,a=t&&n.has(r.charAt(0))||r.startsWith(`\\.`)&&n.has(r.charAt(2))||r.startsWith(`\\.\\.`)&&n.has(r.charAt(4)),o=!t&&!e&&n.has(r.charAt(0));i=a?`(?!(?:^|/)\\.\\.?(?:$|/))`:o?ig:``}let a=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(a=`(?:$|\\/)`),[i+r+a,Xh(r),this.#t=!!this.#t,this.#n]}let n=this.type===`*`||this.type===`+`,r=this.type===`!`?`(?:(?!(?:`:`(?:`,i=this.#S(t);if(this.isStart()&&this.isEnd()&&!i&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,Xh(this.toString()),!1,!1]}let a=!n||e||t?``:this.#S(!0);a===i&&(a=``),a&&(i=`(?:${i})(?:${a})*?`);let o=``;if(this.type===`!`&&this.#u)o=(this.isStart()&&!t?ig:``)+lg;else{let n=this.type===`!`?`))`+(this.isStart()&&!t&&!e?ig:``)+`[^/]*?)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&a?`)`:this.type===`*`&&a?`)?`:`)${this.type}`;o=r+i+n}return[o,Xh(i),this.#t=!!this.#t,this.#n]}#x(){if($h(this)){let e=0,t=!1;do{t=!0;for(let e=0;e<this.#r.length;e++){let n=this.#r[e];typeof n==`object`&&(n.#x(),this.#m(n)?(t=!1,this.#_(n,e)):this.#p(n)?(t=!1,this.#g(n,e)):this.#y(n)&&(t=!1,this.#b(n)))}}while(!t&&++e<10)}else for(let e of this.#r)typeof e==`object`&&e.#x();this.#l=void 0}#S(e){return this.#r.map(t=>{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#C(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(r){r=!1,i+=(sg.has(c)?`\\`:``)+c;continue}if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?lg:`[^/]*?`,t=!0;continue}if(o=!1,c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=Yh(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}if(c===`?`){i+=`[^/]`,t=!0;continue}i+=cg(c)}return[i,Xh(e),!!t,a]}};K=dg;const fg=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),q=(e,t,n={})=>(Wh(t),!n.nocomment&&t.charAt(0)===`#`?!1:new Rg(t,n).match(e)),pg=/^\*+([^+@!?*[(]*)$/,mg=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),hg=e=>t=>t.endsWith(e),gg=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),_g=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),vg=/^\*+\.\*+$/,yg=e=>!e.startsWith(`.`)&&e.includes(`.`),bg=e=>e!==`.`&&e!==`..`&&e.includes(`.`),xg=/^\.\*+$/,Sg=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),Cg=/^\*+$/,wg=e=>e.length!==0&&!e.startsWith(`.`),Tg=e=>e.length!==0&&e!==`.`&&e!==`..`,Eg=/^\?+([^+@!?*[(]*)?$/,Dg=([e,t=``])=>{let n=jg([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Og=([e,t=``])=>{let n=Mg([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},kg=([e,t=``])=>{let n=Mg([e]);return t?e=>n(e)&&e.endsWith(t):n},Ag=([e,t=``])=>{let n=jg([e]);return t?e=>n(e)&&e.endsWith(t):n},jg=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},Mg=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},Ng=typeof process==`object`&&process?typeof process.env==`object`&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,Pg={win32:{sep:`\\`},posix:{sep:`/`}};q.sep=Ng===`win32`?Pg.win32.sep:Pg.posix.sep;const J=Symbol(`globstar **`);q.GLOBSTAR=J,q.filter=(e,t={})=>n=>q(n,e,t);const Y=(e,t={})=>Object.assign({},e,t);q.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return q;let t=q;return Object.assign((n,r,i={})=>t(n,r,Y(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,Y(e,n))}static defaults(n){return t.defaults(Y(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,Y(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,Y(e,r))}},unescape:(n,r={})=>t.unescape(n,Y(e,r)),escape:(n,r={})=>t.escape(n,Y(e,r)),filter:(n,r={})=>t.filter(n,Y(e,r)),defaults:n=>t.defaults(Y(e,n)),makeRe:(n,r={})=>t.makeRe(n,Y(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,Y(e,r)),match:(n,r,i={})=>t.match(n,r,Y(e,i)),sep:t.sep,GLOBSTAR:J})};const Fg=(e,t={})=>(Wh(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Ih(e,{max:t.braceExpandMax}));q.braceExpand=Fg,q.makeRe=(e,t={})=>new Rg(e,t).makeRe(),q.match=(e,t,n={})=>{let r=new Rg(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const Ig=/[?*]|[+@!]\(.*?\)|\[|\]/,Lg=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var Rg=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){Wh(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||Ng,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!Ig.test(e[2]))&&!Ig.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t of e)for(let e=0;e<t.length;e++)t[e]===`**`&&(t[e]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];(n!==1||r!==``||e[0]!==``)&&(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&!(this.isWindows&&/^[a-z]:$/i.test(r))&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];(e!==1||r!==``||n[0]!==``)&&(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(r){e[t]=[],e[n]=r;break}}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=0,i=0;if(this.isWindows){let n=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),a=!n&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),o=typeof t[0]==`string`&&/^[a-z]:$/i.test(t[0]),s=!o&&t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]),c=a?3:n?0:void 0,l=s?3:o?0:void 0;if(typeof c==`number`&&typeof l==`number`){let[n,a]=[e[c],t[l]];n.toLowerCase()===a.toLowerCase()&&(t[l]=n,i=l,r=c)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(J)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(J,i),o=t.lastIndexOf(J),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length,i+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n<e.length-u;n++){let r=String(e[n]);if(t=!0,r===`.`||r===`..`||!this.options.dot&&r.startsWith(`.`))return!1}return n||t}let d=[[[],0]],f=d[0],p=0,ee=[0];for(let e of c)e===J?(ee.push(p),f=[[],0],d.push(f)):(f[0].push(e),p++);let te=d.length-1,ne=e.length-u;for(let e of d)e[1]=ne-(ee[te--]+e[0].length);return!!this.#t(e,d,r,0,n,0,!!u)}#t(e,t,n,r,i,a,o){let s=t[r];if(!s){for(let t=n;t<e.length;t++){o=!0;let n=e[t];if(n===`.`||n===`..`||!this.options.dot&&n.startsWith(`.`))return!1}return o}let[c,l]=s;for(;n<=l;){if(this.#n(e.slice(0,n+c.length),c,i,n,0)&&a<this.maxGlobstarRecursion){let s=this.#t(e,t,n+c.length,r+1,i,a+1,o);if(s!==!1)return s}let s=e[n];if(s===`.`||s===`..`||!this.options.dot&&s.startsWith(`.`))return!1;n++}return i||null}#n(e,t,n,r,i){let a,o,s,c;for(a=r,o=i,c=e.length,s=t.length;a<c&&o<s;a++,o++){this.debug(`matchOne loop`);let n=t[o],r=e[a];if(this.debug(t,n,r),n===!1||n===J)return!1;let i;if(typeof n==`string`?(i=r===n,this.debug(`string match`,n,r,i)):(i=n.test(r),this.debug(`pattern match`,n,r,i)),!i)return!1}if(a===c&&o===s)return!0;if(a===c)return n;if(o===s)return a===c-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return Fg(this.pattern,this.options)}parse(e){Wh(e);let t=this.options;if(e===`**`)return J;if(e===``)return``;let n,r=null;(n=e.match(Cg))?r=t.dot?Tg:wg:(n=e.match(pg))?r=(t.nocase?t.dot?_g:gg:t.dot?hg:mg)(n[1]):(n=e.match(Eg))?r=(t.nocase?t.dot?Og:Dg:t.dot?kg:Ag)(n):(n=e.match(vg))?r=t.dot?bg:yg:(n=e.match(xg))&&(r=Sg);let i=dg.fromGlob(e,this.options).toMMPattern();return r&&typeof i==`object`&&Reflect.defineProperty(i,"test",{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?`[^/]*?`:t.dot?`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`:`(?:(?!(?:\\/|^)\\.).)*?`,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?Lg(e):e===J?J:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e===J&&a!==J&&(a===void 0?i!==void 0&&i!==J?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==J&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=J))});let i=t.filter(e=>e!==J);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].join(``))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e of i){let i=r;if(n.matchBase&&e.length===1&&(i=[a]),this.matchOne(i,e,t))return n.flipNegate?!0:!this.negate}return!n.flipNegate&&this.negate}static defaults(e){return q.defaults(e).Minimatch}};q.AST=dg,q.Minimatch=Rg,q.escape=fg,q.unescape=Xh;const zg=/[/\\]/u,Bg={kind:`ignore`},Vg=e=>!ce(e)&&e.split(zg).every(e=>e!==`.`&&e!==`..`),Hg=/^!+/u,Ug=/^\.?\/+/u,Wg=e=>{let t=Hg.exec(e)?.[0]??``;return{body:e.slice(t.length).replace(Ug,``),negated:t.length%2==1}},Gg=e=>Wg(e).negated,Kg=e=>Wg(e).body,qg=/[?[\]{}()]/u,Jg=e=>Vg(e)&&!Gg(e)&&!qg.test(e),Yg=(e,t)=>q(e,t),Xg=e=>e.replaceAll(/\/+/gu,`/`).replace(/\/$/u,``),Zg=e=>{let t=Xg(e).split(`/`),n=t.findIndex(e=>e.includes(`*`));return n===-1?Bg:{baseDir:n===0?`.`:t.slice(0,n).join(`/`),kind:`expand-children`,pattern:Xg(e),suffix:t.slice(n+1).join(`/`)}},Qg=e=>{let t=Xg(e).split(`/`).filter(e=>e.includes(`*`));return t.length<=1&&!t.includes(`**`)},$g=e=>{let t=Xg(e).split(`/`),n=t.findIndex(e=>e.includes(`*`));return n<=0?`.`:t.slice(0,n).join(`/`)},e_=e=>Jg(e)?e.includes(`*`)?Qg(e)?Zg(e):{baseDir:$g(e),kind:`expand-recursive`,pattern:Xg(e)}:{dir:e,kind:`probe-dir`,pattern:e}:Bg,t_=new Set([`candidate_not_inspected`,`scan_budget_exhausted`,`manifest_unreadable`,`unsupported_pattern`,`workspace_declaration_unparsed`,`workspace_dir_unreadable`,`workspace_file_unreadable`]),n_=(e,t)=>t?.name?{name:t.name,path:e}:void 0,r_=e=>{let t=e.map(e=>[e.path,e]),n=[...new Map(t).values()];return n.sort((e,t)=>e.path.localeCompare(t.path)),n},i_=e=>!e.diagnostics.some(e=>t_.has(e.kind)),a_=e=>!e.diagnostics.some(e=>e.kind===`no_workspace_declaration`),o_=(e,t)=>e<t?-1:+(e>t),s_=e=>`path`in e?`${e.kind} ${e.path}`:`file`in e?`${e.kind} ${e.file}`:`pattern`in e?`${e.kind} ${e.pattern}`:e.kind,c_=e=>e.toSorted((e,t)=>o_(s_(e),s_(t))),l_=e=>!ce(e)&&!e.split(/[/\\]/u).includes(`..`),u_=(e,t)=>e.kind===`missing`?{kind:`absent`}:e.kind===`outside`?{kind:`unreadable`,reason:`${t} escapes the checkout`}:{kind:`unreadable`,reason:e.code},d_=async(e,t,n)=>{if(!l_(t))return{kind:`unreadable`,reason:`path escapes the checkout`};let r=await f_(e,t);if(`probe`in r)return r.probe;let i=await p_(r.real);return`reason`in i?{kind:`unreadable`,reason:i.reason}:i.found===n?{kind:`match`}:{found:i.found,kind:`mismatch`}},f_=async(e,t)=>{let n=await H(e,h(e,t));if(n.kind!==`inside`)return{probe:u_(n,`path`)};let r=await H(e,h(n.real,`package.json`));return r.kind===`inside`?{real:r.real}:{probe:u_(r,`manifest`)}},p_=async e=>{try{let t=JSON.parse(await s(e,`utf8`));return{found:Qu(t)}}catch(e){return{reason:e.code??`manifest could not be read or interpreted`}}},m_=(e,t)=>{let n=e.filter(e=>e.name===t).map(e=>e.path);return n.length===0?{kind:`absent`}:n.length===1?{kind:`found`,path:n[0]}:{kind:`ambiguous`,paths:n.toSorted(o_)}},h_=`package.json`,g_=/^\.\/[^\s%?#\\]*$/u,__=async e=>{try{return(await p(e)).isDirectory()?`directory`:`file`}catch{return`unverifiable`}},v_=async(e,t)=>{if(!g_.test(t)||t.includes(`*`))return`not_checked`;let n=h(e,t.slice(2)),r=await H(e,n);return r.kind===`inside`?__(r.real):r.kind===`missing`&&await Uu(e,n)?`absent`:`unverifiable`},y_=async(e,t,n)=>Array.isArray(t)?{alternatives:await Promise.all(t.map(t=>b_(e,t,n+1))),kind:`alternatives`}:{branches:await Promise.all(Object.entries(t).map(async([t,r])=>({condition:t,value:await b_(e,r,n+1)}))),kind:`conditions`},b_=async(e,t,n)=>t===null?{kind:`excluded`}:n>8?{kind:`unsupported`,reason:`nested deeper than this reports on`}:typeof t==`string`?{kind:`target`,observed:await v_(e,t),target:t}:typeof t==`object`?y_(e,t,n):{kind:`unsupported`,reason:`unexpected ${typeof t}`},x_=[`main`,`module`,`types`,`typings`],S_=(e,t)=>{let n=x_.filter(e=>typeof t[e]==`string`);return Promise.all(n.map(async n=>({from:n,subpath:`.`,value:await b_(e,C_(t[n]),0)})))},C_=e=>e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)?e:`./${e}`,w_=async(e,t)=>{if(typeof t==`string`||Array.isArray(t))return[{from:`exports`,subpath:`.`,value:await b_(e,t,0)}];if(t===void 0)return[];if(typeof t!=`object`||!t)return[{from:`exports`,subpath:`.`,value:await b_(e,t,0)}];let n=Object.keys(t);return n.length>0&&!n.some(e=>e.startsWith(`.`))?[{from:`exports`,subpath:`.`,value:await b_(e,t,0)}]:Promise.all(Object.entries(t).map(async([t,n])=>({from:`exports`,subpath:t,value:await b_(e,n,0)})))},T_=async(e,t)=>{let n=await H(e,h(e,h_));if(n.kind!==`inside`)return{entries:[],manifest:h_,reason:n.kind,status:`unverifiable`};try{let r=JSON.parse(await s(n.real,`utf8`));return r.name===t?{entries:[...await w_(e,r.exports),...await S_(e,r)],manifest:h_,status:`complete`}:{entries:[],manifest:h_,reason:`manifest no longer names this package`,status:`unverifiable`}}catch(e){return{entries:[],manifest:h_,reason:e.code??`manifest could not be read or interpreted`,status:`unverifiable`}}},E_=vl.partial({description:!0}),D_=N({default_branch:$c,key:nl,tag_format_candidate:sl.nullable(),url:j().min(1)});D_.extend({description:j().default(``),packages:fl(E_)});const O_=D_.extend({description:j().min(1),packages:fl(vl)}),k_=N({effective_clone_mode:al.optional(),head_sha:j().regex(/^[0-9a-f]{40}$/u,`head_sha must be a 40-character lowercase hex string`).optional(),last_error:j().optional(),last_fetched_at:Vc().optional(),pending_proposal_at:Vc().optional()}),A_=N({refs:ul(e=>e.length>0&&!ll.has(e),()=>`state ref key must be non-empty and not "__proto__", "constructor", or "prototype"`,pc(j(),k_)).default({})}),j_=(e,t,n)=>t?.[e]??n[e],M_=async e=>{try{return await s(e.statePath,`utf8`)}catch(e){if(F(e))return;throw e}},N_=e=>{try{return JSON.parse(e)}catch{return}},P_=async e=>{let t=await M_(e);if(t===void 0)return A_.parse({});let n=N_(t);if(n===void 0)return A_.parse({});let r=A_.safeParse(n);return r.success?r.data:A_.parse({})},F_=async(e,t)=>{let n=A_.safeParse(t);if(!n.success)throw z(S(n.error));await au(e.statePath,`${JSON.stringify(n.data,void 0,2)}\n`)},I_=/^\d+\.\d+\.\d+$/u,L_=/^0+(?=\d)/u,R_=(e,t)=>{let n=e.replace(L_,``),r=t.replace(L_,``);return n.length===r.length?n===r?0:n<r?-1:1:n.length<r.length?-1:1},z_=(e,t)=>{if(!I_.test(e)||!I_.test(t))return;let n=e.split(`.`),r=t.split(`.`);return n.map((e,t)=>R_(e,r[t]??``)).find(e=>e!==0)??0},B_=sc({version:j().regex(I_)}),V_=N({checked_at:Vc(),latest_version:j().regex(I_)}),H_=async e=>{try{let t=V_.safeParse(JSON.parse(await s(e.updateCachePath,`utf8`)));return t.success?t.data:void 0}catch{return}},U_=async(e,t)=>{try{await p(e.root),await au(e.updateCachePath,`${JSON.stringify(t,void 0,2)}\n`)}catch{}},W_=(e,t)=>{let n=t-Date.parse(e.checked_at);return n>=0&&n<864e5},G_=async e=>{try{let t=await e(`https://registry.npmjs.org/@kaisers-io%2Frefs/latest`,{signal:AbortSignal.timeout(2e3)});if(t.status!==200)return;let n=B_.safeParse(await t.json());return n.success?n.data.version:void 0}catch{return}},K_=async e=>{let t=await H_(e.home);if(t!==void 0&&W_(t,e.nowMs))return{latest:t.latest_version,refreshed:!1,stale:!1};let n=await G_(e.fetch);return n===void 0?{latest:t?.latest_version,refreshed:!1,stale:!0}:(await U_(e.home,{checked_at:new Date(e.nowMs).toISOString(),latest_version:n}),{latest:n,refreshed:!0,stale:!1})},q_=(e,t)=>{let n=z_(e,t);return n!==void 0&&n<0},J_=(e,t)=>`refs ${t} is available (this is ${e}) — update: npm i -g @kaisers-io/refs@latest`,Y_=e=>{let t=e.REFS_UPDATE_CHECK?.trim();if(t===`0`)return!1;if(t===`1`)return!0},X_=e=>{let t=e.CI?.trim().toLowerCase();return t!==void 0&&t!==``&&t!==`false`&&t!==`0`},Z_={check:!0,notify:!0},Q_=e=>{let t=Y_(e.env);return t===void 0?(e.updates??Z_).check?X_(e.env)?`ci`:`on`:`config`:t?`on`:`env`},$_=e=>Q_(e)===`on`,ev=e=>$_(e)&&(e.updates??Z_).notify,tv=async(e,t)=>{let n=await H(e,h(t,`package.json`));if(n.kind===`inside`)try{let e=JSON.parse(await s(n.real,`utf8`));return{name:Qu(e),version:$u(e)}}catch{return}},nv=async(e,t)=>{let n=await tv(e,h(e,t));if(n===void 0)return{diagnostic:{kind:`manifest_unreadable`,path:t}};let r=n_(t,n);return r!==void 0&&n.version!==void 0?{pkg:r,version:n.version}:r===void 0?{diagnostic:{kind:`manifest_missing_name`,path:t}}:{pkg:r}},rv=e=>Object.fromEntries(e.flatMap(e=>e.pkg===void 0||e.version===void 0?[]:[[e.pkg.path,e.version]])),iv=e=>{let t=[],n=[];for(let r of e)r.diagnostic!==void 0&&t.push(r.diagnostic),r.pkg!==void 0&&n.push(r.pkg);return{diagnostics:t,packages:n,versions:rv(e)}},av=new Set([`ENOENT`,`ENOTDIR`]),ov=async(e,t)=>{let n=await H(e,h(t,`package.json`));if(n.kind===`missing`)return`none`;if(n.kind!==`inside`)return`rejected`;try{return await s(n.real,`utf8`),`manifest`}catch{return`rejected`}},sv=async e=>{try{return{entries:await c(e,{withFileTypes:!0})}}catch(e){return{code:e.code??``}}},cv=e=>Promise.all(e.entries.map(t=>ov(e.repoDir,h(e.fullPath,t.name,e.suffix)))),lv=(e,t,n)=>e.filter((e,r)=>n(t[r])).map(e=>e.name),uv=async e=>{let{baseDir:t,dirs:n,fullPath:r,repoDir:i,suffix:a,symlinks:o}=e,s=e=>ue.join(t===`.`?``:t,e,a),[c,l]=await Promise.all([cv({entries:n,fullPath:r,repoDir:i,suffix:a}),cv({entries:o,fullPath:r,repoDir:i,suffix:a})]);return{diagnostics:[...lv(n,c,e=>e===`rejected`).map(e=>({kind:`manifest_unreadable`,path:s(e)})),...lv(o,l,e=>e!==`none`).map(e=>({kind:`candidate_not_inspected`,path:s(e)}))],dirs:lv(n,c,e=>e===`manifest`).map(e=>s(e))}},dv=async e=>{let t=await nv(e,`.`);return`pkg`in t?[t]:[]},fv=e=>{let t=e.find(e=>e.path===`.`);return t===void 0?[...e]:e.some(e=>e.path!==`.`&&e.name===t.name)?e.filter(e=>e!==t):[...e]},pv=async e=>{let[t]=await dv(e);return t!==void 0&&`pkg`in t?t.pkg:void 0},mv=`package.json`,hv=e=>{let t=Xg(e).split(`/`);return t.includes(`**`)?void 0:t.length},gv=e=>Xg(e).split(`/`).some(e=>e.startsWith(`.`)),_v=e=>e===`.`?0:e.split(`/`).length,vv=e=>{let t=Xg(e),n=new Rg(`${t}/${mv}`),r=new Rg(t);return{couldHold:e=>r.match(e,!0),selects:e=>n.match(ue.join(e,mv))}},yv=e=>({...vv(e),maxDepth:hv(e),selectsHidden:gv(e)}),bv=new Set([`ENOENT`,`ENOTDIR`]),xv=new Set([`.git`,`node_modules`]),Sv=e=>e.some(e=>e.name.toLowerCase()===`package.json`&&!e.isDirectory()),Cv=e=>e.some(e=>e.isSymbolicLink()&&!xv.has(e.name)),wv=async(e,t)=>{let n=await sv(t);return`code`in n?{answer:bv.has(n.code)}:(e.budget.entries-=n.entries.length,e.budget.entries<0||Sv(n.entries)||Cv(n.entries)?{answer:!1}:{entries:n.entries})},Tv=async(e,t,n)=>{if(e.budget.dirs<=0||n>32)return!1;--e.budget.dirs;let r=await wv(e,t);return`answer`in r?r.answer:Ev(e,{dir:t,entries:r.entries},n)},Ev=async(e,t,n)=>{let r=t.entries.filter(e=>e.isDirectory()&&!xv.has(e.name));for(let i of r)if(!await Tv(e,h(t.dir,i.name),n+1))return!1;return!0},Dv=async(e,t)=>{let n=await H(e.repoDir,h(e.repoDir,t));if(n.kind!==`outside`&&n.kind!==`missing`){if(n.kind===`unreadable`){e.diagnostics.push({kind:`candidate_not_inspected`,path:t});return}await Tv(e,n.real,1)||e.diagnostics.push({kind:`candidate_not_inspected`,path:t})}},Ov=()=>({dirs:2e4,entries:2e5}),kv=new Set([`.git`,`node_modules`]),Av=(e,t)=>{e.diagnostics.push({kind:`scan_budget_exhausted`,path:t,pattern:e.pattern})},jv=async(e,t,n)=>{if(!e.selects(t)||n.has(t))return;let r=await ov(e.repoDir,h(e.repoDir,t));r===`manifest`&&e.dirs.push(t),r===`rejected`&&e.diagnostics.push({kind:`manifest_unreadable`,path:t})},Mv=(e,t)=>!e.selectsHidden&&t.excluded.coversSubtree(t.relPath),Nv=async(e,t,n)=>!e.couldHold(n.relPath)||kv.has(t.name)||Mv(e,n)?!1:t.isSymbolicLink()?(Mv(e,n)||await Dv(e,n.relPath),!1):t.isDirectory(),Pv=async(e,t)=>{let n=await sv(h(e.repoDir,t));if(`code`in n){av.has(n.code)||e.diagnostics.push({kind:`workspace_dir_unreadable`,path:t});return}if(e.budget.entries-=n.entries.length,e.budget.entries<0){Av(e,t);return}return n.entries},Fv=async(e,t,n)=>{if(e.budget.dirs<=0){Av(e,t.relPath);return}if(--e.budget.dirs,await jv(e,t.relPath,n),e.maxDepth!==void 0&&_v(t.relPath)>=e.maxDepth)return;let r=await Pv(e,t.relPath);r!==void 0&&await Lv(e,{depth:t.depth,entries:r,relPath:t.relPath},n)},Iv=(e,t)=>ue.join(e===`.`?``:e,t),Lv=async(e,t,n)=>{for(let r of t.entries){let i=Iv(t.relPath,r.name);await Nv(e,r,{excluded:n,relPath:i})&&(t.depth+1>32?Av(e,i):await Fv(e,{depth:t.depth+1,relPath:i},n))}},Rv=async(e,t)=>{let n=await H(e,h(e,t));if(n.kind!==`inside`)return n.kind===`missing`?{diagnostics:[],dirs:[]}:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}},zv=async(e,t,n)=>{let r=await Rv(e,t.baseDir);if(r!==void 0)return r;let i={...yv(t.pattern),budget:n.budget,diagnostics:[],dirs:[],pattern:t.pattern,repoDir:e};return await Fv(i,{depth:1,relPath:t.baseDir},n.excluded),{diagnostics:i.diagnostics,dirs:i.dirs}},Bv=(e,t)=>ue.join(e.baseDir===`.`?``:e.baseDir,t,e.suffix),Vv=(e,t)=>Yg(Bv(t,e.name),t.pattern),Hv=async(e,t)=>{let n=h(e,t),r=await H(e,n);if(r.kind===`missing`)return{result:{diagnostics:[],dirs:[]}};if(r.kind!==`inside`)return{result:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}};let i=await sv(n);return`code`in i?{result:av.has(i.code)?{diagnostics:[],dirs:[]}:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}}:{entries:i.entries}},Uv=async(e,t,n)=>{let{baseDir:r}=t,i=await Hv(e,r);if(`result`in i)return i.result;let a=e=>Vv(e,t)&&!n.has(Bv(t,e.name)),o={entries:i.entries};return uv({baseDir:r,dirs:o.entries.filter(e=>e.isDirectory()&&a(e)),fullPath:h(e,r),repoDir:e,suffix:t.suffix,symlinks:o.entries.filter(e=>e.isSymbolicLink()&&a(e))})},Wv=async(e,t)=>{let n=await ov(e,h(e,t));return n===`manifest`?{diagnostics:[],dirs:[Xg(t)]}:n===`rejected`?{diagnostics:[{kind:`manifest_unreadable`,path:t}],dirs:[]}:{diagnostics:[],dirs:[]}},Gv=(e,t,n)=>{let{excluded:r}=n,i=e_(t.body);return i.kind===`expand-children`?Uv(e,i,r):i.kind===`expand-recursive`?zv(e,i,n):i.kind===`probe-dir`?r.has(Xg(i.dir))?Promise.resolve({diagnostics:[],dirs:[]}):Wv(e,i.dir):Promise.resolve({diagnostics:[{kind:`unsupported_pattern`,pattern:t.declared}],dirs:[]})},Kv=(e,t)=>Yg(Kg(e),Kg(t)),qv=e=>({negations:e.filter(e=>Gg(e)),patterns:e.filter(e=>!Gg(e))}),Jv=e=>{let t=e.reduce((e,t)=>Gg(t)?{negations:[...e.negations,t],patterns:e.patterns}:{negations:e.negations.filter(e=>!Kv(t,e)),patterns:[...e.patterns,t]},{negations:[],patterns:[]});return{negations:t.negations,patterns:t.patterns.filter(e=>!t.negations.some(t=>Kv(e,t)))}},Yv=e=>e.endsWith(`/`)?e:`${e}/`,Xv=(e,t)=>e.some(e=>Yg(Yv(t),Yv(Kg(e)))),Zv=(e,t)=>{let n=Kg(e);return n.endsWith(`/**`)&&Yg(t,n.slice(0,-3))},Qv=e=>({coversSubtree:t=>e.some(e=>Zv(e,t)),has:t=>Xv(e,t)}),$v=e=>{let t=new Set,n=[];for(let r of e)r.dirs.forEach(e=>t.add(e)),n.push(...r.diagnostics);return{diagnostics:n,dirs:[...t]}},ey=async(e,t,n)=>{let{negations:r,patterns:i}=t,a=Qv(r),o=$v(await Promise.all(i.map(t=>Gv(e,{body:Kg(t),declared:t},{budget:n,excluded:a}))));return{diagnostics:o.diagnostics,dirs:o.dirs}},ty=async(e,t)=>{let n=Jv(t.npm),r=qv(t.pnpm),i=Ov(),a=await Promise.all([ey(e,n,i),ey(e,r,i)]);return $v(a)},ny=async e=>{let t=await od(e);if(t.npm.length===0&&t.pnpm.length===0)return{diagnostics:c_([...t.diagnostics,{kind:`no_workspace_declaration`}]),packages:[],versions:{}};let n=await ty(e,t),[r,i]=await Promise.all([dv(e),Promise.all(n.dirs.map(t=>nv(e,t)))]),a=iv([...r,...i]);return{diagnostics:c_([...t.diagnostics,...n.diagnostics,...a.diagnostics]),packages:fv(r_(a.packages)),versions:a.versions}},ry=()=>{},iy={stop:ry,update:ry},ay={frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],interval:80},oy={frames:[`-`,`\\`,`|`,`/`],interval:130},sy=`\r\x1B[K`,cy={24:`\x1B[38;2;7;210;86m`,4:`\x1B[32m`,8:`\x1B[38;5;41m`},ly=/[^ -~]/gu,uy=(e,t)=>t.isTTY===!0&&e.TERM!==`dumb`&&!X_(e)&&e.REFS_PROGRESS?.trim()!==`0`,dy=new Set([`alacritty`,`rxvt-unicode`,`rxvt-unicode-256color`,`xterm-256color`]),fy=(e,t)=>t===`win32`?!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask===`{cmd::Cmder}`||e.TERM_PROGRAM===`Terminus-Sublime`||e.TERM_PROGRAM===`vscode`||e.TERMINAL_EMULATOR===`JetBrains-JediTerm`||dy.has(e.TERM??``):e.TERM!==`linux`,py=(e,t)=>e.replaceAll(ly,`?`).slice(0,Math.max(0,t)),my=(e,t,n)=>{let r=(e.stream.columns??80)-3,i=cy[e.stream.getColorDepth?.(e.env)??1],a=i===void 0?t:`${i}${t}`;return`${sy}${a} ${py(n,r)}`},hy=e=>{if(!uy(e.env,e.stream))return iy;let{frames:t,interval:n}=fy(e.env,e.platform)?ay:oy,r={drawn:!1,index:0,stopped:!1,text:``},i=()=>{e.stream.write(my(e,t[r.index%t.length]??``,r.text)),r.drawn=!0,r.index+=1},a={},o=()=>{i(),a.ticker=setInterval(i,n).unref()};return{stop:()=>{r.stopped=!0,clearTimeout(a.delay),clearInterval(a.ticker),r.drawn&&=(e.stream.write(sy),!1)},update:e=>{r.stopped||(r.text=e,a.delay??=setTimeout(o,100).unref())}}};var gy=`0.18.0`;const _y=async()=>{let e=[];for await(let t of process.stdin)e.push(Buffer.from(t));return Buffer.concat(e).toString(`utf8`)},vy=()=>{try{return ge()}catch{return``}},yy=()=>({cliVersion:gy,cwd:process.cwd(),env:process.env,errLine:e=>{process.stderr.write(`${e}\n`)},fetcher:(e,t)=>fetch(e,t),homedir:vy(),nodeVersion:process.version,out:e=>{process.stdout.write(`${e}\n`)},readStdin:_y,runner:new Ad,spinner:()=>hy({env:process.env,platform:process.platform,stream:process.stderr})});var by=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},xy=class extends by{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},Sy=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new xy(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,t):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Cy(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}var wy=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(e=>Cy(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(t?` `+t:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
328
+ `).map(e=>e.trim()).filter(e=>e!==``),a=r.stdoutTruncated!==!0;return n===void 0?{complete:a,tags:i}:{complete:a&&i.length<=n,tags:i.slice(0,n)}},jf=/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?/u,Mf=/\d+\.\d+\.\d+/gu,Nf=e=>sl.safeParse(e).success,Pf=e=>{let t=e.match(Mf);return t!==null&&t.length>1},Ff=e=>{let t=jf.exec(e);if(!t||Pf(e))return;let[n]=t,r=e.replace(n,`{version}`);if(Nf(r))return r},If=(e,t,n)=>{let r=e.get(t);r===void 0?e.set(t,{count:1,index:n}):r.count+=1},Lf=e=>{let t=new Map;for(let[n,r]of e.entries()){let e=Ff(r);e&&If(t,e,n)}return t},Rf=(e,t)=>e.count>t.count||e.count===t.count&&e.index<t.index,zf=e=>{let t=[...e.entries()],[n]=t;if(n===void 0)return null;let[r,i]=n;return t.slice(1).reduce(({format:e,data:t},[n,r])=>Rf(r,t)?{data:r,format:n}:{data:t,format:e},{data:i,format:r}).format},Bf=e=>{let t=Lf(e);return zf(t)},Vf=(e,t)=>e.replaceAll(`{version}`,()=>t),Hf=async(e,t,n,r)=>{let i=Vf(n,r);if(!await Df(e,t,i))throw L(`tag '${i}' not found in ${t} — check the version or tag_format`);return i},Uf=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]+)?$/u,Wf=/[0-9.]$/u,Gf=[`@`,`-`,`_`,`/`],Kf=`{version}`,qf=(e,t)=>Gf.some(n=>e===`${t}${n}`||e===`${t}${n}v`),Jf=(e,t)=>qf(e.slice(0,e.length-9),t)&&e.endsWith(Kf),Yf=(e,t)=>t!==void 0&&qf(e,t)?2:+(e===``||e===`v`),Xf=(e,t)=>{if(!e.endsWith(t))return;let n=e.slice(0,e.length-t.length);return Wf.test(n)?void 0:n},Zf=(e,t,n)=>{let r=Xf(e,t);if(r===void 0)return;let i=sl.safeParse(`${r}${Kf}`);if(i.success&&Vf(i.data,t)===e)return{format:i.data,rank:Yf(r,n)}},Qf=e=>{let t=e.filter(e=>e.rank>0),n=t.reduce((e,t)=>Math.max(e,t.rank),0),r=new Set(t.filter(e=>e.rank===n).map(e=>e.format)),[i]=[...r];return r.size===1&&i!==void 0?i:null},$f=(e,t,n)=>t.length>64||!Uf.test(t)?null:Qf(e.map(e=>Zf(e,t,n)).filter(e=>e!==void 0)),ep=e=>e.split(`/`).some(e=>e===`.`||e===`..`),tp=e=>e.includes(`\\`),np=e=>e.includes(`%`),rp=/[\u0000-\u001F\u007F]/u,ip=/^ | $/u,ap=/[?#]/u,op=(e,t)=>`not a supported git url: control character ${`U+${(e.codePointAt(t)??0).toString(16).toUpperCase().padStart(4,`0`)}`} at position ${String(t)}`,sp=(e,t)=>{let n=e.search(rp);if(n!==-1)throw z(op(e,n));if(ip.test(e))throw z(`not a supported git url: leading or trailing space`);if(ap.test(e))throw z(`not a supported git url: query or fragment in ${W(t)}`);cp(e,t),lp(e,t)},cp=(e,t)=>{if(tp(e))throw z(`not a supported git url: backslash not allowed in ${W(t)}`)},lp=(e,t)=>{if(ep(e))throw z(`not a supported git url: path traversal segment in ${W(t)}`)},up=(e,t,n)=>{if(e.protocol!==`file:`&&np(t))throw z(`not a supported git url: percent-encoding not supported in ${W(n)}`)},dp=/\.git$/u,fp=e=>e.replace(dp,``),pp=e=>{let t=0,n=e.length;for(;t<n&&e.charAt(t)===`/`;)t+=1;for(;n>t&&e.charAt(n-1)===`/`;)--n;return e.slice(t,n)},mp=/^git@(?<host>[^:/\s]+):(?<path>[^\s]+)$/u,hp=/^git\+/u,gp={"https:":`443`,"ssh:":`22`},_p=e=>{let t=nl.safeParse(e);if(!t.success)throw z(`not a supported git url: derived key '${W(e)}' is invalid`);return t.data},vp=({host:e,port:t,protocol:n})=>{let r=gp[n];return t===``||t===r?e.toLowerCase():`${e.toLowerCase()}_${t}`},yp=e=>{let t=fp(pp(e.path));return _p(`${vp(e)}/${t}`)},bp=e=>{let t=decodeURIComponent(e).split(`/`).filter(e=>e!==``);if(t.length<2)throw z(`not a supported git url: file url path must have at least 2 segments`);let n=t.at(-2)??``,r=t.at(-1)??``;return _p(`local/${n}/${r}`)},xp=(e,t)=>{try{return new URL(e)}catch{throw z(`not a supported git url: ${W(t)}`)}},Sp=e=>{if(e.password!==``)throw z(`not a supported git url: credentials embedded in url`);if(e.protocol===`https:`&&e.username!==``)throw z(`not a supported git url: credentials embedded in https url`)},Cp=(e,t)=>{if(e.protocol===`file:`){if(!t)throw z(`not a supported git url: unsupported protocol ${e.protocol}`);return bp(e.pathname)}if(e.protocol!==`https:`&&e.protocol!==`ssh:`)throw z(`not a supported git url: unsupported protocol ${e.protocol}`);return Sp(e),yp({host:e.hostname,path:e.pathname,port:e.port,protocol:e.protocol})},wp=(e,t)=>{if(np(e))throw z(`not a supported git url: percent-encoding not supported in ${W(t)}`);if(e.includes(`:`))throw z(`not a supported git url: ambiguous ':' in scp-style path ${W(t)}; use the ssh:// url form instead`);if(e.startsWith(`/`)||e.startsWith(`~`))throw z(`not a supported git url: ambiguous absolute/home-relative scp path in ${W(t)}; use the ssh:// url form instead`)},Tp=(e,t)=>{let n=e.groups?.path??``;return wp(n,t),yp({host:e.groups?.host??``,path:n,port:``,protocol:`ssh:`})},Ep=(e,t)=>{let n=t?.allowFileUrls??!1,r=e.replace(hp,``);sp(r,e);let i=mp.exec(r);if(i?.groups!==void 0)return{cloneUrl:r,key:Tp(i,e)};let a=xp(r,e);return up(a,r,e),{cloneUrl:r,key:Cp(a,n)}},Dp=`.git`,Op=e=>e.endsWith(Dp)?e:`${e}${Dp}`,kp=(e,t)=>`https://${e.toLowerCase()}/${pp(t)}`,Ap=(e,t)=>`git@${e.toLowerCase()}:${Op(pp(t))}`,jp=e=>{if(e===`https:`)return`https`;if(e===`ssh:`)return`ssh`;throw z(`not a supported git url: unsupported protocol ${e}`)},Mp=(e,t,n)=>{let r=gp[e.protocol];if(e.port!==``&&e.port!==r)throw z(`cannot apply git_transport=${t} to ${W(n)}: its non-default port ${e.port} cannot be expressed in the ${t} url form — add the repo with an explicit url instead`)},Np=(e,t)=>t===`https`?kp(e.hostname,e.pathname):Ap(e.hostname,e.pathname),Pp=(e,t,n)=>{let r=Ep(t).key;if(r!==n)throw z(`git_transport transform changed repo identity: '${W(e)}' → '${t}' (key '${n}' → '${r}')`);return t},Fp=(e,t)=>{if(t.transport===`ssh`)return t.cloneUrl;let n=e.groups?.host??``,r=e.groups?.path??``;return Pp(t.cloneUrl,kp(n,r),t.originalKey)},Ip=e=>{let t=xp(e.cloneUrl,e.cloneUrl);return jp(t.protocol)===e.transport?e.cloneUrl:(Mp(t,e.transport,e.cloneUrl),Pp(e.cloneUrl,Np(t,e.transport),e.originalKey))},Lp=(e,t)=>{if(e.startsWith(`file:`))return e;let n={cloneUrl:e,originalKey:Ep(e).key,transport:t},r=mp.exec(e);return r?.groups===void 0?Ip(n):Fp(r,n)},Rp=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u,zp=(e,t)=>{if(Rp.test(t))return h(e,`lease-${t}`)},Bp=async(e,t)=>{let n=zp(e,t);n!==void 0&&await(await o(n,`w`,384)).close()},Vp=async(e,t)=>{let n=zp(e,t);if(n===void 0)return`gone`;let r=new Date;try{await ee(n,r,r)}catch(e){if(F(e))return`gone`;throw e}return`renewed`},Hp=async(e,t)=>{let n=zp(e,t);if(n===void 0)return{state:`absent`};try{return{mtimeMs:(await p(n)).mtimeMs,state:`ok`}}catch(e){return{state:F(e)?`absent`:`unreadable`}}},Up=`meta.json`,Wp=e=>{try{return process.kill(e,0),!0}catch(e){return ru(e)!==`ESRCH`}},Gp=e=>{try{return JSON.parse(e)}catch{return}},Kp=async e=>{try{return await s(e,`utf8`)}catch{return}},qp=new Set([`ENOENT`,`ENOTDIR`]),Jp=async e=>{try{return{state:`read`,text:await s(e,`utf8`)}}catch(e){let t=ru(e);return{state:t!==void 0&&qp.has(t)?`missing`:`unreadable`}}},Yp=e=>{if(typeof e!=`string`)return;let t=Date.parse(e);if(!Number.isNaN(t))return t},Xp=e=>{if(typeof e!=`object`||!e)return;let{token:t}=e;if(typeof t==`string`)return t},Zp=e=>{if(!(typeof e!=`number`||!Number.isSafeInteger(e)||e<=0||e>2147483647))return e},Qp=e=>{if(typeof e!=`object`||!e)return;let t=e,n=Zp(t.pid),r=Yp(t.acquired_at);if(n===void 0||r===void 0)return;let i=Xp(e);return{acquiredAtMs:r,pid:n,...i===void 0?{}:{token:i}}},$p=async e=>{let t=await Kp(h(e,Up));if(t!==void 0)return Xp(Gp(t))},em=async e=>{let t=await Jp(h(e,Up));if(t.state!==`read`)return{state:t.state};let n=Qp(Gp(t.text));return n===void 0?{state:`malformed`}:{meta:n,state:`valid`}},tm=async e=>{try{return{mtimeMs:(await p(e)).mtimeMs,state:`ok`}}catch(e){return{state:ru(e)===`ENOENT`?`gone`:`unreadable`}}},nm=async(e,t)=>{let n=h(e,Up),r=`${n}.tmp-${he()}`;await te(r,t,{encoding:`utf8`,mode:384}),await u(r,n)},rm=()=>he(),im=async(e,t)=>{await Bp(e,t),await nm(e,JSON.stringify({acquired_at:new Date().toISOString(),pid:process.pid,token:t}))},am=5e3,om=async(e,t,n)=>{if(t===`unreadable`)return{meta:t,observedAtMs:n,pidState:`unknown`,policy:`unknown`,stale:!1};let r=await tm(e);if(r.state===`gone`)return{meta:t,observedAtMs:n,pidState:`unknown`,policy:`none`,stale:!1};if(r.state===`unreadable`)return{meta:t,observedAtMs:n,pidState:`unknown`,policy:`unknown`,stale:!1};let i=n-r.mtimeMs;return{ageMs:i,budgetMs:am,meta:t,observedAtMs:n,pidState:`unknown`,policy:`grace`,stale:i>am}},sm=async(e,t,n)=>{let r=t.token===void 0?{state:`absent`}:await Hp(e,t.token);return r.state===`unreadable`?{policy:`unknown`}:r.state===`absent`?{ageMs:n-t.acquiredAtMs,budgetMs:6e5,policy:`legacy`}:{ageMs:n-r.mtimeMs,budgetMs:12e4,policy:`lease`}},cm=async(e,t)=>{let n=await em(e);if(n.state!==`valid`)return om(e,n.state,t);let{meta:r}=n,i=await sm(e,r,t),a=!Wp(r.pid),o=i.ageMs!==void 0&&i.budgetMs!==void 0&&i.ageMs>i.budgetMs;return{...i,meta:`valid`,observedAtMs:t,pid:r.pid,pidState:a?`definitely-dead`:`present-or-unknown`,stale:a||o,...r.token===void 0?{}:{token:r.token}}},lm=e=>e.meta===`valid`&&e.pidState===`definitely-dead`&&e.token!==void 0,um=async(e,t)=>await $p(e)===t?await Vp(e,t)===`gone`?`lost`:`renewed`:`lost`,dm=new Set([`EEXIST`,`EPERM`,`EACCES`,`EBUSY`]),fm=new Set([`ENOENT`,`EPERM`,`EACCES`,`EBUSY`]),pm=async e=>{try{return await a(e,{mode:448,recursive:!1}),!0}catch(e){let t=ru(e);if(t!==void 0&&dm.has(t))return!1;throw e}},mm=async(e,t)=>{try{return await u(e,t),!0}catch(e){let t=ru(e);if(t!==void 0&&fm.has(t))return!1;throw e}},hm=e=>a(e,{mode:448,recursive:!0}),gm=`.claims`,_m=`.tombstones`,vm=(e,t)=>({lockPath:h(e,t),locksDir:e,name:t}),ym=e=>h(e.locksDir,gm,e.name),bm=e=>h(e.locksDir,_m,he()),xm=async e=>{await a(h(e,gm),{mode:448,recursive:!0}),await a(h(e,_m),{mode:448,recursive:!0})},Sm=e=>pm(e),Cm=async e=>{try{await f(e)}catch{}},wm=async e=>{let t=bm(e);return await mm(e.lockPath,t)?t:void 0},Tm=async e=>{let t=await cm(e.lockPath,Date.now());if(!lm(t)||await $p(e.lockPath)!==t.token)return!1;let n=await wm(e);return n!==void 0&&(await d(n,{force:!0,recursive:!0}),!0)},Em=async e=>{await xm(e.locksDir);let t=ym(e);if(!await Sm(t))return!1;let n=await Tm(e).then(e=>({ok:!0,stolen:e}),e=>({error:e,ok:!1}));if(await Cm(t),!n.ok)throw n.error;return n.stolen},Dm=async e=>{try{return(await c(e,{withFileTypes:!0})).map(e=>({isDir:e.isDirectory(),name:e.name})).toSorted((e,t)=>e.name.localeCompare(t.name))}catch(e){if(F(e))return[];throw e}},Om=async e=>(await Dm(e)).filter(e=>!e.name.startsWith(`.`)),km=async(e,t,n)=>{let r=await cm(h(e,t.name),n);if(r.policy!==`none`)return{diagnosis:r,isDirectory:t.isDir,kind:`lock`,name:t.name}},Am=async(e,t)=>{let n=h(e,gm),r=await Dm(n);return(await Promise.all(r.map(async e=>({diagnosis:await cm(h(n,e.name),t),isDirectory:e.isDir,kind:`claim`,name:e.name})))).filter(e=>e.diagnosis.policy!==`none`)},jm=async e=>{let t=Date.now(),n=await Om(e.locksDir),[r,i]=await Promise.all([Promise.all(n.map(n=>km(e.locksDir,n,t))),Am(e.locksDir,t)]);return[...r.filter(e=>e!==void 0),...i]},Mm=e=>{let t=Math.floor(e/1e3),n=t%60,r=Math.floor(t/60),i=r%60,a=Math.floor(r/60);return a>0?i===0?`${a}h`:`${a}h ${i}m`:r>0?n===0?`${r}m`:`${r}m ${n}s`:`${n}s`},Nm=e=>e.pid===void 0?`owner unknown (metadata ${e.meta})`:e.pidState===`definitely-dead`?`recorded pid ${e.pid} is not running`:`recorded pid ${e.pid} is present (identity not verified)`,Pm={grace:`created`,lease:`lease renewed`,legacy:`acquired`,none:`observed`,unknown:`observed`},Fm={grace:`from creation, while its metadata has not been published`,lease:`from the last renewal`,legacy:`from acquisition (no renewable lease)`,none:``,unknown:``},Im=e=>{let{ageMs:t,budgetMs:n,policy:r}=e;return t===void 0||n===void 0?``:t<0?`, but its recorded time is in the future — check the system clock`:`, ${Pm[r]} ${Mm(t)} ago; its window is ${Mm(n)} ${Fm[r]}`},Lm=(e,t)=>{if(t.policy===`none`)return`lock ${e} could not be acquired before the timeout, but it was released while the failure was being diagnosed. Retry the operation.`;let n=`lock ${e} is held: ${Nm(t)}`;return lm(t)?`${n}, and refs is entitled to reclaim it — it could not do so before the timeout. Retry; if it persists, run refs doctor.`:t.stale?`${n}${Im(t)}. refs does not reclaim this automatically: only a recorded process the operating system reports as gone is reclaimed, and this one is not. Run refs doctor for what to do about it.`:`${n}${Im(t)}. Retry once the other refs command finishes.`},Rm=(e,t)=>{if(t.stopped)return;let n=setTimeout(()=>{t.stopped||(t.inFlight=zm(e,t))},e.intervalMs);n.unref(),t.timer=n},zm=async(e,t)=>{try{if(await e.renew()===`lost`){t.lost=!0,t.stopped=!0;return}}catch{}Rm(e,t)},Bm=e=>{let t={inFlight:Promise.resolve(),lost:!1,stopped:!1};return Rm(e,t),{ownershipLost:()=>t.lost,stop:async()=>{t.stopped=!0,t.timer!==void 0&&clearTimeout(t.timer),await t.inFlight}}},Vm=/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/u,Hm=async(e,t)=>{try{await im(e,t)}catch(e){if(ru(e)===`ENOENT`)return`retry`;throw e}return t},Um=async(e,t)=>{if(!await pm(e))return;let n=await Hm(e,rm());return n===`retry`?Date.now()>=t?void 0:Um(e,t):n},Wm=async(e,t)=>{if(!await Em(e)){if(Date.now()>=t){let t=await cm(e.lockPath,Date.now());throw su(Lm(e.name,t))}await xe(100)}},Gm=async(e,t)=>{let n=await Um(e.lockPath,t);return n===void 0?(await Wm(e,t),Gm(e,t)):n},Km=async(e,t)=>await $p(e)===t&&(await d(e,{force:!0,recursive:!0}),!0),qm=async e=>{try{return{ok:!0,value:await e()}}catch(e){return{error:e,ok:!1}}},Jm=async(e,t,n,r)=>{await n.stop();let i=await qm(()=>Km(e.lockPath,t));if(!r.ok)throw r.error;if(!i.ok)throw i.error;if(n.ownershipLost()||!i.value)throw su(`lock ${e.name} was lost while the operation was running`);return r.value},Ym=e=>e!==`.`&&e!==`..`&&Vm.test(e),Xm=e=>{if(!Ym(e))throw z(`lock name must not contain "/" or other unsafe characters — only letters, digits, and "_.-" are allowed, and it may not be "." or "..": ${e}`)},G=async(e,t,n,r)=>{Xm(t);let i=vm(e.locksDir,t);await hm(e.locksDir);let a=Date.now()+(r?.timeoutMs??1e4),o=await Gm(i,a),s=Bm({intervalMs:3e4,renew:()=>um(i.lockPath,o)});return Jm(i,o,s,await qm(n))},Zm=sc({directory:j().optional(),url:j().optional()}),Qm=sc({repository:lc([j(),Zm]).optional()}),$m=/^(?:@[a-z0-9-~][a-z0-9._~-]*\/)?[a-z0-9-~][a-z0-9._~-]*$/u,eh=new Set([`node_modules`,`favicon.ico`]),th=e=>L(`package '${e}' has no usable repository field — find the repository and run: refs add <git-url>`),nh=e=>{let[t,n]=e.split(`/`);return n??t??e},rh=e=>{if(e.length>214)throw R(`invalid package name: '${e}' exceeds maximum length of 214 characters`);if(!$m.test(e))throw R(`invalid package name: '${e}' does not match npm naming rules`);let t=nh(e);if(eh.has(t))throw R(`invalid package name: '${e}' uses a reserved name`)},ih=e=>e.replaceAll(`/`,`%2F`),ah=e=>typeof e==`string`?e:e?.url,oh=e=>{if(typeof e==`object`&&e?.directory){let t=cl.safeParse(e.directory);if(t.success)return t.data}},sh=e=>e instanceof Error&&(e.name===`TimeoutError`||e.name===`AbortError`),ch=e=>z(`npm registry did not answer for '${e}' within 10000ms`),lh=async(e,t)=>{try{return await e.json()}catch(e){throw sh(e)?ch(t):z(`invalid npm registry response for '${t}': not parseable JSON`)}},uh=async(e,t)=>{try{return await e(`https://registry.npmjs.org/${ih(t)}`,{signal:AbortSignal.timeout(1e4)})}catch(e){throw sh(e)?ch(t):e}},dh=async(e,t)=>{let n=await uh(e,t);if(n.status===404)throw L(`npm package '${t}' not found`);if(n.status!==200)throw z(`failed to fetch npm package '${t}': status ${n.status}`);let r=await lh(n,t),i=Qm.safeParse(r);if(!i.success)throw z(`invalid npm package response for '${t}'`);return i.data},fh=(e,t)=>{try{return Ep(e)}catch{throw th(t)}},ph=async(e,t)=>{rh(t);let n=await dh(e,t),r=ah(n.repository);if(r===void 0||r===``)throw th(t);let{cloneUrl:i,key:a}=fh(r,t),o=oh(n.repository);return o===void 0?{cloneUrl:i,key:a}:{cloneUrl:i,directory:o,key:a}},mh=(e,t,n)=>{let r=e instanceof RegExp?hh(e,n):e,i=t instanceof RegExp?hh(t,n):t,a=r!==null&&i!=null&&gh(r,i,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+r.length,a[1]),post:n.slice(a[1]+i.length)}},hh=(e,t)=>{let n=t.match(e);return n?n[0]:null},gh=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i<a&&(a=i,o=l),l=n.indexOf(t,u+1);u=c<l&&c>=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},_h=`\0SLASH`+Math.random()+`\0`,vh=`\0OPEN`+Math.random()+`\0`,yh=`\0CLOSE`+Math.random()+`\0`,bh=`\0COMMA`+Math.random()+`\0`,xh=`\0PERIOD`+Math.random()+`\0`,Sh=new RegExp(_h,`g`),Ch=new RegExp(vh,`g`),wh=new RegExp(yh,`g`),Th=new RegExp(bh,`g`),Eh=new RegExp(xh,`g`),Dh=/\\\\/g,Oh=/\\{/g,kh=/\\}/g,Ah=/\\,/g,jh=/\\\./g;function Mh(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Nh(e){return e.replace(Dh,_h).replace(Oh,vh).replace(kh,yh).replace(Ah,bh).replace(jh,xh)}function Ph(e){return e.replace(Sh,`\\`).replace(Ch,`{`).replace(wh,`}`).replace(Th,`,`).replace(Eh,`.`)}function Fh(e){if(!e)return[``];let t=[],n=mh(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:i,post:a}=n,o=r.split(`,`);o[o.length-1]+=`{`+i+`}`;let s=Fh(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function Ih(e,t={}){if(!e)return[];let{max:n=1e5,maxLength:r=4e6}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),Uh(Nh(e),n,r,!0).map(Ph)}function Lh(e){return`{`+e+`}`}function Rh(e){return/^-?0\d/.test(e)}function zh(e,t){return e<=t}function Bh(e,t){return e>=t}function Vh(e,t,n,r,i,a){let o=[],s=0;for(let c=0;c<e.length;c++)for(let l=0;l<n.length;l++){if(o.length>=r)return o;let u=e[c]+t+n[l];if(!a||u){if(s+u.length>i)return o;o.push(u),s+=u.length}}return o}function Hh(e,t,n,r){let i=e.split(/\.\./),a=[];if(i[0]===void 0||i[1]===void 0)return a;let o=Mh(i[0]),s=Mh(i[1]),c=Math.max(i[0].length,i[1].length),l=i.length===3&&i[2]!==void 0?Math.max(Math.abs(Mh(i[2])),1):1,u=zh;s<o&&(l*=-1,u=Bh);let d=i.some(Rh),f=0;for(let e=o;u(e,s)&&a.length<n;e+=l){let n;if(t)n=String.fromCharCode(e),n===`\\`&&(n=``);else if(n=String(e),d){let t=c-n.length;if(t>0){let r=Array(t+1).join(`0`);n=e<0?`-`+r+n.slice(1):r+n}}if(f+n.length>r)break;a.push(n),f+=n.length}return a}function Uh(e,t,n,r){let i=[``],a=!1,o=!0;for(;;){let s=mh(`{`,`}`,e);if(!s)return Vh(i,e,[``],t,n,a);let c=s.pre;if(/\$$/.test(c)){if(i=Vh(i,c+`{`+s.body+`}`,[``],t,n,a&&!s.post.length),o=!1,!s.post.length)break;e=s.post;continue}let l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),d=l||u,f=s.body.indexOf(`,`)>=0;if(!d&&!f){if(s.post.match(/,(?!,).*\}/)){e=s.pre+`{`+s.body+yh+s.post,r=!0;continue}return Vh(i,c+`{`+s.body+`}`+s.post,[``],t,n,a)}o&&=(a=r&&!d,!1);let p;if(d)p=Hh(s.body,u,t,n);else{let r=Fh(s.body);if(r.length===1&&r[0]!==void 0&&(r=Uh(r[0],t,n,!1).map(Lh),r.length===1)){if(i=Vh(i,c+r[0],[``],t,n,a&&!s.post.length),!s.post.length)break;e=s.post;continue}let o=a&&!s.post.length&&!c;for(let e=0;o&&e<i.length;e++)i[e]&&(o=!1);p=[];let l=0;outer:for(let e=0;e<r.length;e++){let i=Uh(r[e],t,n,!1);for(let e=0;e<i.length;e++){let r=i[e];if(!o||r){if(p.length>=t||l+r.length>n)break outer;p.push(r),l+=r.length}}}}if(i=Vh(i,c,p,t,n,a&&!s.post.length),!s.post.length)break;e=s.post}return i}const Wh=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},Gh={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},Kh=e=>e.replace(/[[\]\\-]/g,`\\$&`),qh=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),Jh=e=>e.join(``),Yh=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1){l=!0,a++;continue}if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c){c=!0,a++;continue}if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(Gh))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue WHILE}}if(c=!1,d){t>d?r.push(Kh(d)+`-`+Kh(t)):t===d&&r.push(Kh(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(Kh(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(Kh(t)),a++}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l){let e=r[0].length===2?r[0].slice(-1):r[0];return[qh(e),!1,u-n,!1]}let f=`[`+(l?`^`:``)+Jh(r)+`]`,p=`[`+(l?``:`^`)+Jh(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},Xh=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\])\]/g,`$1$2`).replace(/\\([^/])/g,`$1`):t?e.replace(/\[([^/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,`$1$2`).replace(/\\([^/{}])/g,`$1`);var K;const Zh=new Set([`!`,`?`,`+`,`*`,`@`]),Qh=e=>Zh.has(e),$h=e=>Qh(e.type),eg=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),tg=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),ng=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),rg=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),ig=`(?!\\.)`,ag=new Set([`[`,`.`]),og=new Set([`..`,`.`]),sg=new Set(`().*{}+?[]^$\\!`),cg=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),lg=`[^/]+?`;let ug=0;var dg=class{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;id=++ug;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for(`nodejs.util.inspect.custom`)](){return{"@@type":`AST`,id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.#l=this.type?this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...e){for(let t of e)if(t!==``){if(typeof t!=`string`&&!(t instanceof K&&t.#i===this))throw Error(`invalid part: `+t);this.#r.push(t)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;t<this.#a;t++){let n=e.#r[t];if(!(n instanceof K&&n.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(e){let t=new K(this.type,e);for(let e of this.#r)t.copyIn(e);return t}static#f(e,t,n,r,i){let a=r.maxExtglobRecursion??2,o=!1,s=!1,c=-1,l=!1;if(t.type===null){let u=n,d=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,d+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),d+=n;continue}if(n===`[`){s=!0,c=u,l=!1,d+=n;continue}if(!r.noext&&Qh(n)&&e.charAt(u)===`(`&&i<=a){t.push(d),d=``;let a=new K(n,t);u=K.#f(e,a,u,r,i+1),t.push(a);continue}d+=n}return t.push(d),u}let u=n+1,d=new K(null,t),f=[],p=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,p+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),p+=n;continue}if(n===`[`){s=!0,c=u,l=!1,p+=n;continue}if(!r.noext&&Qh(n)&&e.charAt(u)===`(`&&(i<=a||t&&t.#h(n))){let a=t&&t.#h(n)?0:1;d.push(p),p=``;let o=new K(n,d);d.push(o),u=K.#f(e,o,u,r,i+a);continue}if(n===`|`){d.push(p),p=``,f.push(d),d=new K(null,t);continue}if(n===`)`)return p===``&&t.#r.length===0&&(t.#u=!0),d.push(p),p=``,t.push(...f,d),u;p+=n}return t.type=null,t.#t=void 0,t.#r=[e.substring(n-1)],u}#p(e){return this.#m(e,tg)}#m(e,t=eg){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null)return!1;let n=e.#r[0];return!n||typeof n!=`object`||n.type===null?!1:this.#h(n.type,t)}#h(e,t=ng){return!!t.get(this.type)?.includes(e)}#g(e,t){let n=e.#r[0],r=new K(null,n,this.options);r.#r.push(``),n.push(r),this.#_(e,t)}#_(e,t){let n=e.#r[0];this.#r.splice(t,1,...n.#r);for(let e of n.#r)typeof e==`object`&&(e.#i=this);this.#l=void 0}#v(e){return!!rg.get(this.type)?.has(e)}#y(e){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let t=e.#r[0];return!t||typeof t!=`object`||t.type===null?!1:this.#v(t.type)}#b(e){let t=rg.get(this.type),n=e.#r[0],r=t?.get(n.type);if(!r)return!1;this.#r=n.#r;for(let e of this.#r)typeof e==`object`&&(e.#i=this);this.type=r,this.#l=void 0,this.#u=!1}static fromGlob(e,t={}){let n=new K(null,void 0,t);return K.#f(e,n,0,t,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(e){let t=e??!!this.#c.dot;if(this.#e===this&&(this.#x(),this.#d()),!$h(this)){let n=this.isStart()&&this.isEnd()&&!this.#r.some(e=>typeof e!=`string`),r=this.#r.map(t=>{let[r,i,a,o]=typeof t==`string`?K.#C(t,this.#t,n):t.toRegExpSource(e);return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),i=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&og.has(this.#r[0]))){let n=ag,a=t&&n.has(r.charAt(0))||r.startsWith(`\\.`)&&n.has(r.charAt(2))||r.startsWith(`\\.\\.`)&&n.has(r.charAt(4)),o=!t&&!e&&n.has(r.charAt(0));i=a?`(?!(?:^|/)\\.\\.?(?:$|/))`:o?ig:``}let a=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(a=`(?:$|\\/)`),[i+r+a,Xh(r),this.#t=!!this.#t,this.#n]}let n=this.type===`*`||this.type===`+`,r=this.type===`!`?`(?:(?!(?:`:`(?:`,i=this.#S(t);if(this.isStart()&&this.isEnd()&&!i&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,Xh(this.toString()),!1,!1]}let a=!n||e||t?``:this.#S(!0);a===i&&(a=``),a&&(i=`(?:${i})(?:${a})*?`);let o=``;if(this.type===`!`&&this.#u)o=(this.isStart()&&!t?ig:``)+lg;else{let n=this.type===`!`?`))`+(this.isStart()&&!t&&!e?ig:``)+`[^/]*?)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&a?`)`:this.type===`*`&&a?`)?`:`)${this.type}`;o=r+i+n}return[o,Xh(i),this.#t=!!this.#t,this.#n]}#x(){if($h(this)){let e=0,t=!1;do{t=!0;for(let e=0;e<this.#r.length;e++){let n=this.#r[e];typeof n==`object`&&(n.#x(),this.#m(n)?(t=!1,this.#_(n,e)):this.#p(n)?(t=!1,this.#g(n,e)):this.#y(n)&&(t=!1,this.#b(n)))}}while(!t&&++e<10)}else for(let e of this.#r)typeof e==`object`&&e.#x();this.#l=void 0}#S(e){return this.#r.map(t=>{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#C(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(r){r=!1,i+=(sg.has(c)?`\\`:``)+c;continue}if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?lg:`[^/]*?`,t=!0;continue}if(o=!1,c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=Yh(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}if(c===`?`){i+=`[^/]`,t=!0;continue}i+=cg(c)}return[i,Xh(e),!!t,a]}};K=dg;const fg=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),q=(e,t,n={})=>(Wh(t),!n.nocomment&&t.charAt(0)===`#`?!1:new Rg(t,n).match(e)),pg=/^\*+([^+@!?*[(]*)$/,mg=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),hg=e=>t=>t.endsWith(e),gg=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),_g=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),vg=/^\*+\.\*+$/,yg=e=>!e.startsWith(`.`)&&e.includes(`.`),bg=e=>e!==`.`&&e!==`..`&&e.includes(`.`),xg=/^\.\*+$/,Sg=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),Cg=/^\*+$/,wg=e=>e.length!==0&&!e.startsWith(`.`),Tg=e=>e.length!==0&&e!==`.`&&e!==`..`,Eg=/^\?+([^+@!?*[(]*)?$/,Dg=([e,t=``])=>{let n=jg([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Og=([e,t=``])=>{let n=Mg([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},kg=([e,t=``])=>{let n=Mg([e]);return t?e=>n(e)&&e.endsWith(t):n},Ag=([e,t=``])=>{let n=jg([e]);return t?e=>n(e)&&e.endsWith(t):n},jg=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},Mg=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},Ng=typeof process==`object`&&process?typeof process.env==`object`&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,Pg={win32:{sep:`\\`},posix:{sep:`/`}};q.sep=Ng===`win32`?Pg.win32.sep:Pg.posix.sep;const J=Symbol(`globstar **`);q.GLOBSTAR=J,q.filter=(e,t={})=>n=>q(n,e,t);const Y=(e,t={})=>Object.assign({},e,t);q.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return q;let t=q;return Object.assign((n,r,i={})=>t(n,r,Y(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,Y(e,n))}static defaults(n){return t.defaults(Y(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,Y(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,Y(e,r))}},unescape:(n,r={})=>t.unescape(n,Y(e,r)),escape:(n,r={})=>t.escape(n,Y(e,r)),filter:(n,r={})=>t.filter(n,Y(e,r)),defaults:n=>t.defaults(Y(e,n)),makeRe:(n,r={})=>t.makeRe(n,Y(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,Y(e,r)),match:(n,r,i={})=>t.match(n,r,Y(e,i)),sep:t.sep,GLOBSTAR:J})};const Fg=(e,t={})=>(Wh(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Ih(e,{max:t.braceExpandMax}));q.braceExpand=Fg,q.makeRe=(e,t={})=>new Rg(e,t).makeRe(),q.match=(e,t,n={})=>{let r=new Rg(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const Ig=/[?*]|[+@!]\(.*?\)|\[|\]/,Lg=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var Rg=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){Wh(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||Ng,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!Ig.test(e[2]))&&!Ig.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t of e)for(let e=0;e<t.length;e++)t[e]===`**`&&(t[e]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];(n!==1||r!==``||e[0]!==``)&&(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&!(this.isWindows&&/^[a-z]:$/i.test(r))&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];(e!==1||r!==``||n[0]!==``)&&(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(r){e[t]=[],e[n]=r;break}}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=0,i=0;if(this.isWindows){let n=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),a=!n&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),o=typeof t[0]==`string`&&/^[a-z]:$/i.test(t[0]),s=!o&&t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]),c=a?3:n?0:void 0,l=s?3:o?0:void 0;if(typeof c==`number`&&typeof l==`number`){let[n,a]=[e[c],t[l]];n.toLowerCase()===a.toLowerCase()&&(t[l]=n,i=l,r=c)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(J)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(J,i),o=t.lastIndexOf(J),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length,i+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n<e.length-u;n++){let r=String(e[n]);if(t=!0,r===`.`||r===`..`||!this.options.dot&&r.startsWith(`.`))return!1}return n||t}let d=[[[],0]],f=d[0],p=0,ee=[0];for(let e of c)e===J?(ee.push(p),f=[[],0],d.push(f)):(f[0].push(e),p++);let te=d.length-1,ne=e.length-u;for(let e of d)e[1]=ne-(ee[te--]+e[0].length);return!!this.#t(e,d,r,0,n,0,!!u)}#t(e,t,n,r,i,a,o){let s=t[r];if(!s){for(let t=n;t<e.length;t++){o=!0;let n=e[t];if(n===`.`||n===`..`||!this.options.dot&&n.startsWith(`.`))return!1}return o}let[c,l]=s;for(;n<=l;){if(this.#n(e.slice(0,n+c.length),c,i,n,0)&&a<this.maxGlobstarRecursion){let s=this.#t(e,t,n+c.length,r+1,i,a+1,o);if(s!==!1)return s}let s=e[n];if(s===`.`||s===`..`||!this.options.dot&&s.startsWith(`.`))return!1;n++}return i||null}#n(e,t,n,r,i){let a,o,s,c;for(a=r,o=i,c=e.length,s=t.length;a<c&&o<s;a++,o++){this.debug(`matchOne loop`);let n=t[o],r=e[a];if(this.debug(t,n,r),n===!1||n===J)return!1;let i;if(typeof n==`string`?(i=r===n,this.debug(`string match`,n,r,i)):(i=n.test(r),this.debug(`pattern match`,n,r,i)),!i)return!1}if(a===c&&o===s)return!0;if(a===c)return n;if(o===s)return a===c-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return Fg(this.pattern,this.options)}parse(e){Wh(e);let t=this.options;if(e===`**`)return J;if(e===``)return``;let n,r=null;(n=e.match(Cg))?r=t.dot?Tg:wg:(n=e.match(pg))?r=(t.nocase?t.dot?_g:gg:t.dot?hg:mg)(n[1]):(n=e.match(Eg))?r=(t.nocase?t.dot?Og:Dg:t.dot?kg:Ag)(n):(n=e.match(vg))?r=t.dot?bg:yg:(n=e.match(xg))&&(r=Sg);let i=dg.fromGlob(e,this.options).toMMPattern();return r&&typeof i==`object`&&Reflect.defineProperty(i,"test",{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?`[^/]*?`:t.dot?`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`:`(?:(?!(?:\\/|^)\\.).)*?`,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?Lg(e):e===J?J:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e===J&&a!==J&&(a===void 0?i!==void 0&&i!==J?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==J&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=J))});let i=t.filter(e=>e!==J);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].join(``))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e of i){let i=r;if(n.matchBase&&e.length===1&&(i=[a]),this.matchOne(i,e,t))return n.flipNegate?!0:!this.negate}return!n.flipNegate&&this.negate}static defaults(e){return q.defaults(e).Minimatch}};q.AST=dg,q.Minimatch=Rg,q.escape=fg,q.unescape=Xh;const zg=/[/\\]/u,Bg={kind:`ignore`},Vg=e=>!ce(e)&&e.split(zg).every(e=>e!==`.`&&e!==`..`),Hg=/^!+/u,Ug=/^\.?\/+/u,Wg=e=>{let t=Hg.exec(e)?.[0]??``;return{body:e.slice(t.length).replace(Ug,``),negated:t.length%2==1}},Gg=e=>Wg(e).negated,Kg=e=>Wg(e).body,qg=/[?[\]{}()]/u,Jg=e=>Vg(e)&&!Gg(e)&&!qg.test(e),Yg=(e,t)=>q(e,t),Xg=e=>e.replaceAll(/\/+/gu,`/`).replace(/\/$/u,``),Zg=e=>{let t=Xg(e).split(`/`),n=t.findIndex(e=>e.includes(`*`));return n===-1?Bg:{baseDir:n===0?`.`:t.slice(0,n).join(`/`),kind:`expand-children`,pattern:Xg(e),suffix:t.slice(n+1).join(`/`)}},Qg=e=>{let t=Xg(e).split(`/`).filter(e=>e.includes(`*`));return t.length<=1&&!t.includes(`**`)},$g=e=>{let t=Xg(e).split(`/`),n=t.findIndex(e=>e.includes(`*`));return n<=0?`.`:t.slice(0,n).join(`/`)},e_=e=>Jg(e)?e.includes(`*`)?Qg(e)?Zg(e):{baseDir:$g(e),kind:`expand-recursive`,pattern:Xg(e)}:{dir:e,kind:`probe-dir`,pattern:e}:Bg,t_=new Set([`candidate_not_inspected`,`scan_budget_exhausted`,`manifest_unreadable`,`unsupported_pattern`,`workspace_declaration_unparsed`,`workspace_dir_unreadable`,`workspace_file_unreadable`]),n_=(e,t)=>t?.name?{name:t.name,path:e}:void 0,r_=e=>{let t=e.map(e=>[e.path,e]),n=[...new Map(t).values()];return n.sort((e,t)=>e.path.localeCompare(t.path)),n},i_=e=>!e.diagnostics.some(e=>t_.has(e.kind)),a_=e=>!e.diagnostics.some(e=>e.kind===`no_workspace_declaration`),o_=(e,t)=>e<t?-1:+(e>t),s_=e=>`path`in e?`${e.kind} ${e.path}`:`file`in e?`${e.kind} ${e.file}`:`pattern`in e?`${e.kind} ${e.pattern}`:e.kind,c_=e=>e.toSorted((e,t)=>o_(s_(e),s_(t))),l_=e=>!ce(e)&&!e.split(/[/\\]/u).includes(`..`),u_=(e,t)=>e.kind===`missing`?{kind:`absent`}:e.kind===`outside`?{kind:`unreadable`,reason:`${t} escapes the checkout`}:{kind:`unreadable`,reason:e.code},d_=async(e,t,n)=>{if(!l_(t))return{kind:`unreadable`,reason:`path escapes the checkout`};let r=await f_(e,t);if(`probe`in r)return r.probe;let i=await p_(r.real);return`reason`in i?{kind:`unreadable`,reason:i.reason}:i.found===n?{kind:`match`}:{found:i.found,kind:`mismatch`}},f_=async(e,t)=>{let n=await H(e,h(e,t));if(n.kind!==`inside`)return{probe:u_(n,`path`)};let r=await H(e,h(n.real,`package.json`));return r.kind===`inside`?{real:r.real}:{probe:u_(r,`manifest`)}},p_=async e=>{try{let t=JSON.parse(await s(e,`utf8`));return{found:Qu(t)}}catch(e){return{reason:e.code??`manifest could not be read or interpreted`}}},m_=(e,t)=>{let n=e.filter(e=>e.name===t).map(e=>e.path);return n.length===0?{kind:`absent`}:n.length===1?{kind:`found`,path:n[0]}:{kind:`ambiguous`,paths:n.toSorted(o_)}},h_=`package.json`,g_=/^\.\/[^\s%?#\\]*$/u,__=async e=>{try{return(await p(e)).isDirectory()?`directory`:`file`}catch{return`unverifiable`}},v_=async(e,t)=>{if(!g_.test(t)||t.includes(`*`))return`not_checked`;let n=h(e,t.slice(2)),r=await H(e,n);return r.kind===`inside`?__(r.real):r.kind===`missing`&&await Uu(e,n)?`absent`:`unverifiable`},y_=async(e,t,n)=>Array.isArray(t)?{alternatives:await Promise.all(t.map(t=>b_(e,t,n+1))),kind:`alternatives`}:{branches:await Promise.all(Object.entries(t).map(async([t,r])=>({condition:t,value:await b_(e,r,n+1)}))),kind:`conditions`},b_=async(e,t,n)=>t===null?{kind:`excluded`}:n>8?{kind:`unsupported`,reason:`nested deeper than this reports on`}:typeof t==`string`?{kind:`target`,observed:await v_(e,t),target:t}:typeof t==`object`?y_(e,t,n):{kind:`unsupported`,reason:`unexpected ${typeof t}`},x_=[`main`,`module`,`types`,`typings`],S_=(e,t)=>{let n=x_.filter(e=>typeof t[e]==`string`);return Promise.all(n.map(async n=>({from:n,subpath:`.`,value:await b_(e,C_(t[n]),0)})))},C_=e=>e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)?e:`./${e}`,w_=async(e,t)=>{if(typeof t==`string`||Array.isArray(t))return[{from:`exports`,subpath:`.`,value:await b_(e,t,0)}];if(t===void 0)return[];if(typeof t!=`object`||!t)return[{from:`exports`,subpath:`.`,value:await b_(e,t,0)}];let n=Object.keys(t);return n.length>0&&!n.some(e=>e.startsWith(`.`))?[{from:`exports`,subpath:`.`,value:await b_(e,t,0)}]:Promise.all(Object.entries(t).map(async([t,n])=>({from:`exports`,subpath:t,value:await b_(e,n,0)})))},T_=async(e,t)=>{let n=await H(e,h(e,h_));if(n.kind!==`inside`)return{entries:[],manifest:h_,reason:n.kind,status:`unverifiable`};try{let r=JSON.parse(await s(n.real,`utf8`));return r.name===t?{entries:[...await w_(e,r.exports),...await S_(e,r)],manifest:h_,status:`complete`}:{entries:[],manifest:h_,reason:`manifest no longer names this package`,status:`unverifiable`}}catch(e){return{entries:[],manifest:h_,reason:e.code??`manifest could not be read or interpreted`,status:`unverifiable`}}},E_=vl.partial({description:!0}),D_=N({default_branch:$c,key:nl,tag_format_candidate:sl.nullable(),url:j().min(1)});D_.extend({description:j().default(``),packages:fl(E_)});const O_=D_.extend({description:j().min(1),packages:fl(vl)}),k_=N({effective_clone_mode:al.optional(),head_sha:j().regex(/^[0-9a-f]{40}$/u,`head_sha must be a 40-character lowercase hex string`).optional(),last_error:j().optional(),last_fetched_at:Vc().optional(),pending_proposal_at:Vc().optional()}),A_=N({refs:ul(e=>e.length>0&&!ll.has(e),()=>`state ref key must be non-empty and not "__proto__", "constructor", or "prototype"`,pc(j(),k_)).default({})}),j_=(e,t,n)=>t?.[e]??n[e],M_=async e=>{try{return await s(e.statePath,`utf8`)}catch(e){if(F(e))return;throw e}},N_=e=>{try{return JSON.parse(e)}catch{return}},P_=async e=>{let t=await M_(e);if(t===void 0)return A_.parse({});let n=N_(t);if(n===void 0)return A_.parse({});let r=A_.safeParse(n);return r.success?r.data:A_.parse({})},F_=async(e,t)=>{let n=A_.safeParse(t);if(!n.success)throw z(S(n.error));await au(e.statePath,`${JSON.stringify(n.data,void 0,2)}\n`)},I_=/^\d+\.\d+\.\d+$/u,L_=/^0+(?=\d)/u,R_=(e,t)=>{let n=e.replace(L_,``),r=t.replace(L_,``);return n.length===r.length?n===r?0:n<r?-1:1:n.length<r.length?-1:1},z_=(e,t)=>{if(!I_.test(e)||!I_.test(t))return;let n=e.split(`.`),r=t.split(`.`);return n.map((e,t)=>R_(e,r[t]??``)).find(e=>e!==0)??0},B_=sc({version:j().regex(I_)}),V_=N({checked_at:Vc(),latest_version:j().regex(I_)}),H_=async e=>{try{let t=V_.safeParse(JSON.parse(await s(e.updateCachePath,`utf8`)));return t.success?t.data:void 0}catch{return}},U_=async(e,t)=>{try{await p(e.root),await au(e.updateCachePath,`${JSON.stringify(t,void 0,2)}\n`)}catch{}},W_=(e,t)=>{let n=t-Date.parse(e.checked_at);return n>=0&&n<864e5},G_=async e=>{try{let t=await e(`https://registry.npmjs.org/@kaisers-io%2Frefs/latest`,{signal:AbortSignal.timeout(2e3)});if(t.status!==200)return;let n=B_.safeParse(await t.json());return n.success?n.data.version:void 0}catch{return}},K_=async e=>{let t=await H_(e.home);if(t!==void 0&&W_(t,e.nowMs))return{latest:t.latest_version,refreshed:!1,stale:!1};let n=await G_(e.fetch);return n===void 0?{latest:t?.latest_version,refreshed:!1,stale:!0}:(await U_(e.home,{checked_at:new Date(e.nowMs).toISOString(),latest_version:n}),{latest:n,refreshed:!0,stale:!1})},q_=(e,t)=>{let n=z_(e,t);return n!==void 0&&n<0},J_=(e,t)=>`refs ${t} is available (this is ${e}) — update: npm i -g @kaisers-io/refs@latest`,Y_=e=>{let t=e.REFS_UPDATE_CHECK?.trim();if(t===`0`)return!1;if(t===`1`)return!0},X_=e=>{let t=e.CI?.trim().toLowerCase();return t!==void 0&&t!==``&&t!==`false`&&t!==`0`},Z_={check:!0,notify:!0},Q_=e=>{let t=Y_(e.env);return t===void 0?(e.updates??Z_).check?X_(e.env)?`ci`:`on`:`config`:t?`on`:`env`},$_=e=>Q_(e)===`on`,ev=e=>$_(e)&&(e.updates??Z_).notify,tv=async(e,t)=>{let n=await H(e,h(t,`package.json`));if(n.kind===`inside`)try{let e=JSON.parse(await s(n.real,`utf8`));return{name:Qu(e),version:$u(e)}}catch{return}},nv=async(e,t)=>{let n=await tv(e,h(e,t));if(n===void 0)return{diagnostic:{kind:`manifest_unreadable`,path:t}};let r=n_(t,n);return r!==void 0&&n.version!==void 0?{pkg:r,version:n.version}:r===void 0?{diagnostic:{kind:`manifest_missing_name`,path:t}}:{pkg:r}},rv=e=>Object.fromEntries(e.flatMap(e=>e.pkg===void 0||e.version===void 0?[]:[[e.pkg.path,e.version]])),iv=e=>{let t=[],n=[];for(let r of e)r.diagnostic!==void 0&&t.push(r.diagnostic),r.pkg!==void 0&&n.push(r.pkg);return{diagnostics:t,packages:n,versions:rv(e)}},av=new Set([`ENOENT`,`ENOTDIR`]),ov=async(e,t)=>{let n=await H(e,h(t,`package.json`));if(n.kind===`missing`)return`none`;if(n.kind!==`inside`)return`rejected`;try{return await s(n.real,`utf8`),`manifest`}catch{return`rejected`}},sv=async e=>{try{return{entries:await c(e,{withFileTypes:!0})}}catch(e){return{code:e.code??``}}},cv=e=>Promise.all(e.entries.map(t=>ov(e.repoDir,h(e.fullPath,t.name,e.suffix)))),lv=(e,t,n)=>e.filter((e,r)=>n(t[r])).map(e=>e.name),uv=async e=>{let{baseDir:t,dirs:n,fullPath:r,repoDir:i,suffix:a,symlinks:o}=e,s=e=>ue.join(t===`.`?``:t,e,a),[c,l]=await Promise.all([cv({entries:n,fullPath:r,repoDir:i,suffix:a}),cv({entries:o,fullPath:r,repoDir:i,suffix:a})]);return{diagnostics:[...lv(n,c,e=>e===`rejected`).map(e=>({kind:`manifest_unreadable`,path:s(e)})),...lv(o,l,e=>e!==`none`).map(e=>({kind:`candidate_not_inspected`,path:s(e)}))],dirs:lv(n,c,e=>e===`manifest`).map(e=>s(e))}},dv=async e=>{let t=await nv(e,`.`);return`pkg`in t?[t]:[]},fv=e=>{let t=e.find(e=>e.path===`.`);return t===void 0?[...e]:e.some(e=>e.path!==`.`&&e.name===t.name)?e.filter(e=>e!==t):[...e]},pv=async e=>{let[t]=await dv(e);return t!==void 0&&`pkg`in t?t.pkg:void 0},mv=`package.json`,hv=e=>{let t=Xg(e).split(`/`);return t.includes(`**`)?void 0:t.length},gv=e=>Xg(e).split(`/`).some(e=>e.startsWith(`.`)),_v=e=>e===`.`?0:e.split(`/`).length,vv=e=>{let t=Xg(e),n=new Rg(`${t}/${mv}`),r=new Rg(t);return{couldHold:e=>r.match(e,!0),selects:e=>n.match(ue.join(e,mv))}},yv=e=>({...vv(e),maxDepth:hv(e),selectsHidden:gv(e)}),bv=new Set([`ENOENT`,`ENOTDIR`]),xv=new Set([`.git`,`node_modules`]),Sv=e=>e.some(e=>e.name.toLowerCase()===`package.json`&&!e.isDirectory()),Cv=e=>e.some(e=>e.isSymbolicLink()&&!xv.has(e.name)),wv=async(e,t)=>{let n=await sv(t);return`code`in n?{answer:bv.has(n.code)}:(e.budget.entries-=n.entries.length,e.budget.entries<0||Sv(n.entries)||Cv(n.entries)?{answer:!1}:{entries:n.entries})},Tv=async(e,t,n)=>{if(e.budget.dirs<=0||n>32)return!1;--e.budget.dirs;let r=await wv(e,t);return`answer`in r?r.answer:Ev(e,{dir:t,entries:r.entries},n)},Ev=async(e,t,n)=>{let r=t.entries.filter(e=>e.isDirectory()&&!xv.has(e.name));for(let i of r)if(!await Tv(e,h(t.dir,i.name),n+1))return!1;return!0},Dv=async(e,t)=>{let n=await H(e.repoDir,h(e.repoDir,t));if(n.kind!==`outside`&&n.kind!==`missing`){if(n.kind===`unreadable`){e.diagnostics.push({kind:`candidate_not_inspected`,path:t});return}await Tv(e,n.real,1)||e.diagnostics.push({kind:`candidate_not_inspected`,path:t})}},Ov=()=>({dirs:2e4,entries:2e5}),kv=new Set([`.git`,`node_modules`]),Av=(e,t)=>{e.diagnostics.push({kind:`scan_budget_exhausted`,path:t,pattern:e.pattern})},jv=async(e,t,n)=>{if(!e.selects(t)||n.has(t))return;let r=await ov(e.repoDir,h(e.repoDir,t));r===`manifest`&&e.dirs.push(t),r===`rejected`&&e.diagnostics.push({kind:`manifest_unreadable`,path:t})},Mv=(e,t)=>!e.selectsHidden&&t.excluded.coversSubtree(t.relPath),Nv=async(e,t,n)=>!e.couldHold(n.relPath)||kv.has(t.name)||Mv(e,n)?!1:t.isSymbolicLink()?(Mv(e,n)||await Dv(e,n.relPath),!1):t.isDirectory(),Pv=async(e,t)=>{let n=await sv(h(e.repoDir,t));if(`code`in n){av.has(n.code)||e.diagnostics.push({kind:`workspace_dir_unreadable`,path:t});return}if(e.budget.entries-=n.entries.length,e.budget.entries<0){Av(e,t);return}return n.entries},Fv=async(e,t,n)=>{if(e.budget.dirs<=0){Av(e,t.relPath);return}if(--e.budget.dirs,await jv(e,t.relPath,n),e.maxDepth!==void 0&&_v(t.relPath)>=e.maxDepth)return;let r=await Pv(e,t.relPath);r!==void 0&&await Lv(e,{depth:t.depth,entries:r,relPath:t.relPath},n)},Iv=(e,t)=>ue.join(e===`.`?``:e,t),Lv=async(e,t,n)=>{for(let r of t.entries){let i=Iv(t.relPath,r.name);await Nv(e,r,{excluded:n,relPath:i})&&(t.depth+1>32?Av(e,i):await Fv(e,{depth:t.depth+1,relPath:i},n))}},Rv=async(e,t)=>{let n=await H(e,h(e,t));if(n.kind!==`inside`)return n.kind===`missing`?{diagnostics:[],dirs:[]}:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}},zv=async(e,t,n)=>{let r=await Rv(e,t.baseDir);if(r!==void 0)return r;let i={...yv(t.pattern),budget:n.budget,diagnostics:[],dirs:[],pattern:t.pattern,repoDir:e};return await Fv(i,{depth:1,relPath:t.baseDir},n.excluded),{diagnostics:i.diagnostics,dirs:i.dirs}},Bv=(e,t)=>ue.join(e.baseDir===`.`?``:e.baseDir,t,e.suffix),Vv=(e,t)=>Yg(Bv(t,e.name),t.pattern),Hv=async(e,t)=>{let n=h(e,t),r=await H(e,n);if(r.kind===`missing`)return{result:{diagnostics:[],dirs:[]}};if(r.kind!==`inside`)return{result:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}};let i=await sv(n);return`code`in i?{result:av.has(i.code)?{diagnostics:[],dirs:[]}:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}}:{entries:i.entries}},Uv=async(e,t,n)=>{let{baseDir:r}=t,i=await Hv(e,r);if(`result`in i)return i.result;let a=e=>Vv(e,t)&&!n.has(Bv(t,e.name)),o={entries:i.entries};return uv({baseDir:r,dirs:o.entries.filter(e=>e.isDirectory()&&a(e)),fullPath:h(e,r),repoDir:e,suffix:t.suffix,symlinks:o.entries.filter(e=>e.isSymbolicLink()&&a(e))})},Wv=async(e,t)=>{let n=await ov(e,h(e,t));return n===`manifest`?{diagnostics:[],dirs:[Xg(t)]}:n===`rejected`?{diagnostics:[{kind:`manifest_unreadable`,path:t}],dirs:[]}:{diagnostics:[],dirs:[]}},Gv=(e,t,n)=>{let{excluded:r}=n,i=e_(t.body);return i.kind===`expand-children`?Uv(e,i,r):i.kind===`expand-recursive`?zv(e,i,n):i.kind===`probe-dir`?r.has(Xg(i.dir))?Promise.resolve({diagnostics:[],dirs:[]}):Wv(e,i.dir):Promise.resolve({diagnostics:[{kind:`unsupported_pattern`,pattern:t.declared}],dirs:[]})},Kv=(e,t)=>Yg(Kg(e),Kg(t)),qv=e=>({negations:e.filter(e=>Gg(e)),patterns:e.filter(e=>!Gg(e))}),Jv=e=>{let t=e.reduce((e,t)=>Gg(t)?{negations:[...e.negations,t],patterns:e.patterns}:{negations:e.negations.filter(e=>!Kv(t,e)),patterns:[...e.patterns,t]},{negations:[],patterns:[]});return{negations:t.negations,patterns:t.patterns.filter(e=>!t.negations.some(t=>Kv(e,t)))}},Yv=e=>e.endsWith(`/`)?e:`${e}/`,Xv=(e,t)=>e.some(e=>Yg(Yv(t),Yv(Kg(e)))),Zv=(e,t)=>{let n=Kg(e);return n.endsWith(`/**`)&&Yg(t,n.slice(0,-3))},Qv=e=>({coversSubtree:t=>e.some(e=>Zv(e,t)),has:t=>Xv(e,t)}),$v=e=>{let t=new Set,n=[];for(let r of e)r.dirs.forEach(e=>t.add(e)),n.push(...r.diagnostics);return{diagnostics:n,dirs:[...t]}},ey=async(e,t,n)=>{let{negations:r,patterns:i}=t,a=Qv(r),o=$v(await Promise.all(i.map(t=>Gv(e,{body:Kg(t),declared:t},{budget:n,excluded:a}))));return{diagnostics:o.diagnostics,dirs:o.dirs}},ty=async(e,t)=>{let n=Jv(t.npm),r=qv(t.pnpm),i=Ov(),a=await Promise.all([ey(e,n,i),ey(e,r,i)]);return $v(a)},ny=async e=>{let t=await od(e);if(t.npm.length===0&&t.pnpm.length===0)return{diagnostics:c_([...t.diagnostics,{kind:`no_workspace_declaration`}]),packages:[],versions:{}};let n=await ty(e,t),[r,i]=await Promise.all([dv(e),Promise.all(n.dirs.map(t=>nv(e,t)))]),a=iv([...r,...i]);return{diagnostics:c_([...t.diagnostics,...n.diagnostics,...a.diagnostics]),packages:fv(r_(a.packages)),versions:a.versions}},ry=()=>{},iy={stop:ry,update:ry},ay={frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],interval:80},oy={frames:[`-`,`\\`,`|`,`/`],interval:130},sy=`\r\x1B[K`,cy={24:`\x1B[38;2;7;210;86m`,4:`\x1B[32m`,8:`\x1B[38;5;41m`},ly=/[^ -~]/gu,uy=(e,t)=>t.isTTY===!0&&e.TERM!==`dumb`&&!X_(e)&&e.REFS_PROGRESS?.trim()!==`0`,dy=new Set([`alacritty`,`rxvt-unicode`,`rxvt-unicode-256color`,`xterm-256color`]),fy=(e,t)=>t===`win32`?!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask===`{cmd::Cmder}`||e.TERM_PROGRAM===`Terminus-Sublime`||e.TERM_PROGRAM===`vscode`||e.TERMINAL_EMULATOR===`JetBrains-JediTerm`||dy.has(e.TERM??``):e.TERM!==`linux`,py=(e,t)=>e.replaceAll(ly,`?`).slice(0,Math.max(0,t)),my=(e,t,n)=>{let r=(e.stream.columns??80)-3,i=cy[e.stream.getColorDepth?.(e.env)??1],a=i===void 0?t:`${i}${t}`;return`${sy}${a} ${py(n,r)}`},hy=e=>{if(!uy(e.env,e.stream))return iy;let{frames:t,interval:n}=fy(e.env,e.platform)?ay:oy,r={drawn:!1,index:0,stopped:!1,text:``},i=()=>{e.stream.write(my(e,t[r.index%t.length]??``,r.text)),r.drawn=!0,r.index+=1},a={},o=()=>{i(),a.ticker=setInterval(i,n).unref()};return{stop:()=>{r.stopped=!0,clearTimeout(a.delay),clearInterval(a.ticker),r.drawn&&=(e.stream.write(sy),!1)},update:e=>{r.stopped||(r.text=e,a.delay??=setTimeout(o,100).unref())}}};var gy=`0.18.1`;const _y=async()=>{let e=[];for await(let t of process.stdin)e.push(Buffer.from(t));return Buffer.concat(e).toString(`utf8`)},vy=()=>{try{return ge()}catch{return``}},yy=()=>({cliVersion:gy,cwd:process.cwd(),env:process.env,errLine:e=>{process.stderr.write(`${e}\n`)},fetcher:(e,t)=>fetch(e,t),homedir:vy(),nodeVersion:process.version,out:e=>{process.stdout.write(`${e}\n`)},readStdin:_y,runner:new Ad,spinner:()=>hy({env:process.env,platform:process.platform,stream:process.stderr})});var by=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},xy=class extends by{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},Sy=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new xy(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,t):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Cy(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}var wy=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(e=>Cy(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(t?` `+t:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
329
329
  `)}displayWidth(e){return Se(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
330
330
  `+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
331
331
  `)}},Ty=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=Oy(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new xy(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,t):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?Dy(this.name().replace(/^no-/,``)):Dy(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Ey=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function Dy(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Oy(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaisers-io/refs",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "Gives coding agents the real source of your dependencies, not a guess.",
5
5
  "keywords": [
6
6
  "ai",