@kaisers-io/refs 0.19.1 → 0.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/refs.mjs +110 -108
  3. package/package.json +3 -3
package/dist/refs.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import{access as e,chmod as t,constants as n,copyFile as r,lstat as i,mkdir as a,open as o,readFile as s,readdir as c,realpath as l,rename as u,rm as d,rmdir as f,stat as p,utimes as m,writeFile as h}from"node:fs/promises";import ee,{constants as g,existsSync as te,realpathSync as ne}from"node:fs";import re,{basename as ie,dirname as _,isAbsolute as ae,join as v,parse as oe,posix as se,relative as ce,resolve as le,sep as ue,win32 as de}from"node:path";import{createHash as fe,randomUUID as pe}from"node:crypto";import{homedir as me}from"node:os";import{setTimeout as he}from"node:timers/promises";import{EventEmitter as ge,once as _e}from"node:events";import ve,{spawn as ye}from"node:child_process";import y from"node:process";import{stripVTControlCharacters as be}from"node:util";const xe=/[\u0000-\u0020\u007F~^:?*[\\]/u,Se=e=>e.length>0&&!e.startsWith(`.`)&&!e.endsWith(`.lock`),Ce=e=>e.length===0||e===`HEAD`||e.startsWith(`-`)||xe.test(e)||e.includes(`..`)||e.includes(`@{`)||e.endsWith(`.`)||e.endsWith(`/`)||e.startsWith(`/`)?!1:e.split(`/`).every(e=>Se(e));function we(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Te(e,t=`|`){return e.map(e=>Ye(e)).join(t)}function Ee(e,t){return typeof t==`bigint`?t.toString():t}var De=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Oe(e){return new De(e)}function ke(e){return e==null}function Ae(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function je(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Me(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ne(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Pe(e){return Ne(e._zod.def)??e._zod.def.shape}function Fe(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Me(this,t,e),e},enumerable:!0,configurable:!0})}function Ie(e,t,n){t in e?Me(e,t,n):e[t]=n}function Le(e,t,n,r){let i=Pe(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Fe(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Ie(e,a,r?r(n.value,a):n.value))}}function Re(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Fe(e,n,()=>t[n]):Ie(e,n,r.value))}}function b(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ze(e){return JSON.stringify(e)}function Be(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const Ve=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function He(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Ue=/* @__PURE__*/ Oe(()=>{if(Lt.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function We(e){if(He(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return He(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Ge(e){return We(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Ke=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function qe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Je(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function x(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ye(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Xe(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const Ze={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Qe={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function $e(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return Le(i,e,et(e,t)),Je(e,b(n,{shape:i,checks:[]}))}function et(e,t){let n=Pe(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function tt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(et(e,t)),a={};return Le(a,e,Reflect.ownKeys(Pe(e)).filter(e=>!i.has(e))),Je(e,b(n,{shape:a,checks:[]}))}function nt(e,t){if(!We(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Pe(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Je(e,b(e._zod.def,{shape:rt(e,t)}))}function rt(e,t){let n={};return Le(n,e,Reflect.ownKeys(Pe(e))),Re(n,t),n}function it(e,t){if(!We(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Je(e,b(e._zod.def,{shape:rt(e,t)}))}function at(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return Le(n,e,Reflect.ownKeys(Pe(e))),Le(n,t,Reflect.ownKeys(Pe(t))),Je(e,b(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ot(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(et(t,n)):void 0,o={};return Le(o,t,Reflect.ownKeys(Pe(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),Je(t,b(t._zod.def,{shape:o,checks:[]}))}function st(e,t,n){let r=n?new Set(et(t,n)):void 0,i={};return Le(i,t,Reflect.ownKeys(Pe(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),Je(t,b(t._zod.def,{shape:i}))}function ct(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function lt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ut(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function dt(e){return typeof e==`string`?e:e?.message}function ft(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function pt(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function mt(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:dt(e.inst?._zod.def?.error?.(e))??dt(a?.(e))??dt(t?.error?.(e))??dt(n.customError?.(e))??dt(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}const ht=/[\uD800-\uDBFF]/;function gt(e){let t=e.length;if(!ht.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function _t(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function vt(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function yt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function bt(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):wt(e,n,r.value)}}function xt(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function St(e,t,n){return xt(e,t,n,!1)}/* @__NO_SIDE_EFFECTS__ */
2
+ import{access as e,chmod as t,constants as n,copyFile as r,lstat as i,mkdir as a,open as o,readFile as s,readdir as c,realpath as l,rename as u,rm as d,rmdir as f,stat as p,utimes as m,writeFile as h}from"node:fs/promises";import ee,{constants as te,existsSync as ne,realpathSync as re}from"node:fs";import g,{basename as ie,dirname as _,isAbsolute as ae,join as v,parse as oe,posix as se,relative as ce,resolve as le,sep as ue,win32 as de}from"node:path";import{createHash as fe,randomUUID as pe}from"node:crypto";import{homedir as me}from"node:os";import{setTimeout as he}from"node:timers/promises";import{EventEmitter as ge,once as _e}from"node:events";import ve,{spawn as ye}from"node:child_process";import y from"node:process";import{stripVTControlCharacters as be}from"node:util";const xe=/[\u0000-\u0020\u007F~^:?*[\\]/u,Se=e=>e.length>0&&!e.startsWith(`.`)&&!e.endsWith(`.lock`),Ce=e=>e.length===0||e===`HEAD`||e.startsWith(`-`)||xe.test(e)||e.includes(`..`)||e.includes(`@{`)||e.endsWith(`.`)||e.endsWith(`/`)||e.startsWith(`/`)?!1:e.split(`/`).every(e=>Se(e));function we(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Te(e,t=`|`){return e.map(e=>Ye(e)).join(t)}function Ee(e,t){return typeof t==`bigint`?t.toString():t}var De=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Oe(e){return new De(e)}function ke(e){return e==null}function Ae(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function je(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Me(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ne(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Pe(e){return Ne(e._zod.def)??e._zod.def.shape}function Fe(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Me(this,t,e),e},enumerable:!0,configurable:!0})}function Ie(e,t,n){t in e?Me(e,t,n):e[t]=n}function Le(e,t,n,r){let i=Pe(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Fe(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Ie(e,a,r?r(n.value,a):n.value))}}function Re(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Fe(e,n,()=>t[n]):Ie(e,n,r.value))}}function b(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ze(e){return JSON.stringify(e)}function Be(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const Ve=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function He(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Ue=/* @__PURE__*/ Oe(()=>{if(w.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function We(e){if(He(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return He(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Ge(e){return We(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Ke=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function qe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Je(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function x(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ye(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Xe(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const Ze={safeint:[-(2**53-1),2**53-1],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Qe={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function $e(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return Le(i,e,et(e,t)),Je(e,b(n,{shape:i,checks:[]}))}function et(e,t){let n=Pe(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function tt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(et(e,t)),a={};return Le(a,e,Reflect.ownKeys(Pe(e)).filter(e=>!i.has(e))),Je(e,b(n,{shape:a,checks:[]}))}function nt(e,t){if(!We(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Pe(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Je(e,b(e._zod.def,{shape:rt(e,t)}))}function rt(e,t){let n={};return Le(n,e,Reflect.ownKeys(Pe(e))),Re(n,t),n}function it(e,t){if(!We(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Je(e,b(e._zod.def,{shape:rt(e,t)}))}function at(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return Le(n,e,Reflect.ownKeys(Pe(e))),Le(n,t,Reflect.ownKeys(Pe(t))),Je(e,b(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ot(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(et(t,n)):void 0,o={};return Le(o,t,Reflect.ownKeys(Pe(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),Je(t,b(t._zod.def,{shape:o,checks:[]}))}function st(e,t,n){let r=n?new Set(et(t,n)):void 0,i={};return Le(i,t,Reflect.ownKeys(Pe(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),Je(t,b(t._zod.def,{shape:i}))}function ct(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function lt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ut(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function dt(e){return typeof e==`string`?e:e?.message}function ft(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function pt(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function mt(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:dt(e.inst?._zod.def?.error?.(e))??dt(a?.(e))??dt(t?.error?.(e))??dt(n.customError?.(e))??dt(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}const ht=/[\uD800-\uDBFF]/;function gt(e){let t=e.length;if(!ht.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function _t(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function vt(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function yt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function bt(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):wt(e,n,r.value)}}function xt(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function St(e,t,n){return xt(e,t,n,!1)}/* @__NO_SIDE_EFFECTS__ */
3
3
  function Ct(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return xt(this,n,r(this))},set(e){xt(this,n,e)}})}return t}function wt(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:xt(this,t,n.bind(this))},set(e){xt(this,t,e)}})}function Tt(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let Et,Dt=!1;const Ot={configurable:!0,get(){Dt=!0}};function S(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&Et!==e._zod?Et=void 0:(Et=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Ot);let e=Dt;Dt=!1;try{let r=n(this);return Dt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Dt||=e,r}catch(n){throw delete this[t],Dt||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function kt(e,t,n,r){let i=Tt(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function At(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var jt;const Mt={value:void 0,enumerable:!1};let Nt=`captureStackTrace`in Error?Error:null;function Pt(e){let t=Nt;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Nt=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}/* @__NO_SIDE_EFFECTS__ */
4
- function C(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=/* @__PURE__ */ new Set}a.prototype=i;let o=n,s=o&&/* @__PURE__ */ new WeakSet;function c(n,r){if(!n._zod){Mt.value=new a(r);try{Object.defineProperty(n,"_zod",Mt)}finally{Mt.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),bt(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Pt(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Ft=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},It=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(jt=globalThis).__zod_globalConfig??(jt.__zod_globalConfig={});const Lt=globalThis.__zod_globalConfig;function Rt(e){return e&&Object.assign(Lt,e),Lt}function zt(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ee,2),e.message}function Bt(e){this._zod.message=e}const Vt={get:zt,set:Bt,enumerable:!0,configurable:!0},Ht={value:void 0,enumerable:!1},Ut=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),Wt=/* @__PURE__ */ C(`$ZodError`,(e,t)=>{e.name=`$ZodError`,Ht.value=t,Object.defineProperty(e,"issues",Ht),Ht.value=void 0,Object.defineProperty(e,"message",Vt);let n=Object.getPrototypeOf(e);Ut.has(n)||(Ut.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function Gt(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Kt(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Gt(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function qt(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Jt(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function w(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${Jt(e.path)}`);return t.join(`
5
- `)}function Yt(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Xt=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Ft;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>mt(e,o,Rt())));throw Ve(n,a?.callee??t),n}return s.value};return t},Zt=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>mt(e,o,Rt())));throw Ve(n,a?.callee??t),n}return s.value};return t},Qt=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Ft;return a.issues.length?$t(e,a.issues,i):{success:!0,data:a.value}};function $t(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>mt(e,n,Rt()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const en=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?$t(e,a.issues,i):{success:!0,data:a.value}},tn=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),nn=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),rn=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==tn)return!0;if(r.definite===!0&&n===void 0)return!1}return an(e,t,n)});function an(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[nn]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Ft;return a.issues.length===0}const on=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},sn=e=>{let t=Xt(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Yt(n,a))};return n},cn=e=>{let t=Xt(e),n=(e,r,i,a)=>t(e,r,i,Yt(n,a));return n},ln=e=>{let t=Zt(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Yt(n,a))};return n},un=e=>{let t=Zt(e),n=async(e,r,i,a)=>await t(e,r,i,Yt(n,a));return n},dn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Qt(e)(t,n,i)},fn=e=>(t,n,r)=>Qt(e)(t,n,r),pn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return en(e)(t,n,i)},mn=e=>async(t,n,r)=>en(e)(t,n,r),hn=/^[cC][0-9a-z]{6,}$/,gn=/^[0-9a-z]+$/,_n=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,vn=/^[0-9a-vA-V]{20}$/,yn=/^[A-Za-z0-9]{27}$/,bn=/^[a-zA-Z0-9_-]{21}$/;function xn(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Sn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Cn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,wn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Tn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function En(){return/* @__PURE__ */ RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const Dn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,On=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,kn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,An=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,jn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Mn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Nn=/^https?$/,Pn=/^\+[1-9]\d{6,14}$/,Fn=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function In(e){return RegExp(`^${e}$`)}const Ln=/*@__PURE__*/ In(Fn);function Rn(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function zn(e){return RegExp(`^${Rn(e)}$`)}function Bn(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Rn({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Rn({precision:e.precision})}`:n;return RegExp(`^${Fn}T(?:${r})$`)}const Vn=/^[\s\S]{0,}$/,Hn=/^-?\d+$/,Un=/^-?\d+(?:\.\d+)?$/,Wn=/^(?:true|false)$/i,Gn=/^[^A-Z]*$/,Kn=/^[^a-z]*$/,T=/*@__PURE__*/ C(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),qn=e=>{let t=e.value;return!ke(t)&&t.length!==void 0},Jn={number:`number`,bigint:`bigint`,object:`date`},Yn=/*@__PURE__*/ C(`$ZodCheckLessThan`,(e,t)=>{T.init(e,t);let n=Jn[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Jn[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Xn=/*@__PURE__*/ C(`$ZodCheckGreaterThan`,(e,t)=>{T.init(e,t);let n=Jn[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Jn[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Zn=/*@__PURE__*/ C(`$ZodCheckMultipleOf`,(e,t)=>{T.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):je(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Qn=/*@__PURE__*/ C(`$ZodCheckNumberFormat`,(e,t)=>{T.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ze[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),$n=/*@__PURE__*/ C(`$ZodCheckMaxLength`,(e,t)=>{var n;T.init(e,t),(n=e._zod.def).when??(n.when=qn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?gt(r):i)<=t.maximum)return;let a=_t(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),er=/*@__PURE__*/ C(`$ZodCheckMinLength`,(e,t)=>{var n;T.init(e,t),(n=e._zod.def).when??(n.when=qn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?gt(r):i)>=t.minimum)return;let a=_t(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),tr=/*@__PURE__*/ C(`$ZodCheckLengthEquals`,(e,t)=>{var n;T.init(e,t),(n=e._zod.def).when??(n.when=qn),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?gt(r):i;if(a===t.length)return;let o=_t(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),nr=/*@__PURE__*/ C(`$ZodCheckStringFormat`,(e,t)=>{var n,r;T.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),rr=/*@__PURE__*/ C(`$ZodCheckRegex`,(e,t)=>{nr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ir=/*@__PURE__*/ C(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Gn,nr.init(e,t)}),ar=/*@__PURE__*/ C(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Kn,nr.init(e,t)}),or=/*@__PURE__*/ C(`$ZodCheckIncludes`,(e,t)=>{T.init(e,t);let n=qe(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),sr=/*@__PURE__*/ C(`$ZodCheckStartsWith`,(e,t)=>{T.init(e,t);let n=RegExp(`^${qe(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),cr=/*@__PURE__*/ C(`$ZodCheckEndsWith`,(e,t)=>{T.init(e,t);let n=RegExp(`.*${qe(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),lr=/*@__PURE__*/ C(`$ZodCheckOverwrite`,(e,t)=>{T.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var ur=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
4
+ function C(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=/* @__PURE__ */ new Set}a.prototype=i;let o=n,s=o&&/* @__PURE__ */ new WeakSet;function c(n,r){if(!n._zod){Mt.value=new a(r);try{Object.defineProperty(n,"_zod",Mt)}finally{Mt.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),bt(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Pt(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Ft=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},It=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(jt=globalThis).__zod_globalConfig??(jt.__zod_globalConfig={});const w=globalThis.__zod_globalConfig;function Lt(e){return e&&Object.assign(w,e),w}function Rt(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ee,2),e.message}function zt(e){this._zod.message=e}const Bt={get:Rt,set:zt,enumerable:!0,configurable:!0},Vt={value:void 0,enumerable:!1},Ht=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),Ut=/* @__PURE__ */ C(`$ZodError`,(e,t)=>{e.name=`$ZodError`,Vt.value=t,Object.defineProperty(e,"issues",Vt),Vt.value=void 0,Object.defineProperty(e,"message",Bt);let n=Object.getPrototypeOf(e);Ht.has(n)||(Ht.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function Wt(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Gt(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Wt(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Kt(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function qt(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function T(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${qt(e.path)}`);return t.join(`
5
+ `)}function Jt(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Yt=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Ft;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>mt(e,o,Lt())));throw Ve(n,a?.callee??t),n}return s.value};return t},Xt=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>mt(e,o,Lt())));throw Ve(n,a?.callee??t),n}return s.value};return t},Zt=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Ft;return a.issues.length?Qt(e,a.issues,i):{success:!0,data:a.value}};function Qt(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>mt(e,n,Lt()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const $t=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Qt(e,a.issues,i):{success:!0,data:a.value}},en=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),tn=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),nn=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==en)return!0;if(r.definite===!0&&n===void 0)return!1}return rn(e,t,n)});function rn(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[tn]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Ft;return a.issues.length===0}const an=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},on=e=>{let t=Yt(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Jt(n,a))};return n},sn=e=>{let t=Yt(e),n=(e,r,i,a)=>t(e,r,i,Jt(n,a));return n},cn=e=>{let t=Xt(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Jt(n,a))};return n},ln=e=>{let t=Xt(e),n=async(e,r,i,a)=>await t(e,r,i,Jt(n,a));return n},un=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Zt(e)(t,n,i)},dn=e=>(t,n,r)=>Zt(e)(t,n,r),fn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return $t(e)(t,n,i)},pn=e=>async(t,n,r)=>$t(e)(t,n,r),mn=/^[cC][0-9a-z]{6,}$/,hn=/^[0-9a-z]+$/,gn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,_n=/^[0-9a-vA-V]{20}$/,vn=/^[A-Za-z0-9]{27}$/,yn=/^[a-zA-Z0-9_-]{21}$/;function bn(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const xn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Sn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Cn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,wn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Tn(){return/* @__PURE__ */ RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const En=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Dn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,On=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,kn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,An=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,jn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Mn=/^https?$/,Nn=/^\+[1-9]\d{6,14}$/,Pn=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function Fn(e){return RegExp(`^${e}$`)}const In=/*@__PURE__*/ Fn(Pn);function Ln(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Rn(e){return RegExp(`^${Ln(e)}$`)}function zn(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Ln({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Ln({precision:e.precision})}`:n;return RegExp(`^${Pn}T(?:${r})$`)}const Bn=/^[\s\S]{0,}$/,Vn=/^-?\d+$/,Hn=/^-?\d+(?:\.\d+)?$/,Un=/^(?:true|false)$/i,Wn=/^[^A-Z]*$/,Gn=/^[^a-z]*$/,E=/*@__PURE__*/ C(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Kn=e=>{let t=e.value;return!ke(t)&&t.length!==void 0},qn={number:`number`,bigint:`bigint`,object:`date`},Jn=/*@__PURE__*/ C(`$ZodCheckLessThan`,(e,t)=>{E.init(e,t);let n=qn[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:qn[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Yn=/*@__PURE__*/ C(`$ZodCheckGreaterThan`,(e,t)=>{E.init(e,t);let n=qn[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:qn[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Xn=/*@__PURE__*/ C(`$ZodCheckMultipleOf`,(e,t)=>{E.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):je(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Zn=/*@__PURE__*/ C(`$ZodCheckNumberFormat`,(e,t)=>{E.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ze[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Qn=/*@__PURE__*/ C(`$ZodCheckMaxLength`,(e,t)=>{var n;E.init(e,t),(n=e._zod.def).when??(n.when=Kn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?gt(r):i)<=t.maximum)return;let a=_t(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$n=/*@__PURE__*/ C(`$ZodCheckMinLength`,(e,t)=>{var n;E.init(e,t),(n=e._zod.def).when??(n.when=Kn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?gt(r):i)>=t.minimum)return;let a=_t(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),er=/*@__PURE__*/ C(`$ZodCheckLengthEquals`,(e,t)=>{var n;E.init(e,t),(n=e._zod.def).when??(n.when=Kn),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?gt(r):i;if(a===t.length)return;let o=_t(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),tr=/*@__PURE__*/ C(`$ZodCheckStringFormat`,(e,t)=>{var n,r;E.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),nr=/*@__PURE__*/ C(`$ZodCheckRegex`,(e,t)=>{tr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),rr=/*@__PURE__*/ C(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Wn,tr.init(e,t)}),ir=/*@__PURE__*/ C(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Gn,tr.init(e,t)}),ar=/*@__PURE__*/ C(`$ZodCheckIncludes`,(e,t)=>{E.init(e,t);let n=qe(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),or=/*@__PURE__*/ C(`$ZodCheckStartsWith`,(e,t)=>{E.init(e,t);let n=RegExp(`^${qe(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),sr=/*@__PURE__*/ C(`$ZodCheckEndsWith`,(e,t)=>{E.init(e,t);let n=RegExp(`.*${qe(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),cr=/*@__PURE__*/ C(`$ZodCheckOverwrite`,(e,t)=>{E.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var lr=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
6
6
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
7
- `)}\n};`)(...Object.values(this.closed))}};const dr={major:4,minor:6,patch:7},E=/*@__PURE__*/ C(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=dr;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=ct(t),a;for(let o of n){if(o._zod.def.when){if(lt(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Ft;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(pt(t.issues,n,e),i||=ct(t,n))});else{if(t.issues.length===n)continue;pt(t.issues,n,e),i||=ct(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(ct(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Ft;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Ft;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return St(this,`~standard`,mr(this))},set"~standard"(e){xt(this,`~standard`,e)}}),fr=(e,t)=>e.issues.length?{issues:e.issues.map(e=>mt(e,t,Rt()))}:{value:e.value};async function pr(e,t){let n={async:!0};return fr(await e._zod.run({value:t,issues:[]},n),n)}function mr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return fr(r,n)}catch{}return pr(e,t)},vendor:`zod`,version:1}}const hr=/*@__PURE__*/ C(`$ZodString`,(e,t)=>{E.init(e,t),e._zod.pattern=t.pattern??Vn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),D=/*@__PURE__*/ C(`$ZodStringFormat`,(e,t)=>{nr.init(e,t),hr.init(e,t)}),gr=/*@__PURE__*/ C(`$ZodGUID`,(e,t)=>{t.pattern??=Cn,D.init(e,t)}),_r=/*@__PURE__*/ C(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=wn(e)}else t.pattern??=wn();D.init(e,t)}),vr=/*@__PURE__*/ C(`$ZodEmail`,(e,t)=>{t.pattern??=Tn,D.init(e,t)});function yr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function br(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?yr(e)||2:xr(e,t)}function xr(e,t){if(!t.normalize&&t.protocol?.source===Nn.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}const Sr=/[\t\n\r]/g;function Cr(e){return e.replace(Sr,``)}function wr(e,t){return t.lastIndex=0,t.test(e.hostname)}function Tr(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const Er=/*@__PURE__*/ C(`$ZodURL`,(e,t)=>{D.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=br(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Cr(r);return}t.hostname&&!wr(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Tr(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Cr(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Dr=/*@__PURE__*/ C(`$ZodEmoji`,(e,t)=>{t.pattern??=En(),D.init(e,t)}),Or=/*@__PURE__*/ C(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?bn:xn(t.length),D.init(e,t)}),kr=/*@__PURE__*/ C(`$ZodCUID`,(e,t)=>{t.pattern??=hn,D.init(e,t)}),Ar=/*@__PURE__*/ C(`$ZodCUID2`,(e,t)=>{t.pattern??=gn,D.init(e,t)}),jr=/*@__PURE__*/ C(`$ZodULID`,(e,t)=>{t.pattern??=_n,D.init(e,t)}),Mr=/*@__PURE__*/ C(`$ZodXID`,(e,t)=>{t.pattern??=vn,D.init(e,t)}),Nr=/*@__PURE__*/ C(`$ZodKSUID`,(e,t)=>{t.pattern??=yn,D.init(e,t)}),Pr=/*@__PURE__*/ C(`$ZodISODateTime`,(e,t)=>{t.pattern??=Bn(t),D.init(e,t)}),Fr=/*@__PURE__*/ C(`$ZodISODate`,(e,t)=>{t.pattern??=Ln,D.init(e,t)}),Ir=/*@__PURE__*/ C(`$ZodISOTime`,(e,t)=>{t.pattern??=zn(t),D.init(e,t)}),Lr=/*@__PURE__*/ C(`$ZodISODuration`,(e,t)=>{t.pattern??=Sn,D.init(e,t)}),Rr=/*@__PURE__*/ C(`$ZodIPv4`,(e,t)=>{t.pattern??=Dn,D.init(e,t)}),zr=/^[0-9a-fA-F:.]+$/;function Br(e){return zr.test(e)?yr(`http://[${e}]`):!1}const Vr=/*@__PURE__*/ C(`$ZodIPv6`,(e,t)=>{t.pattern??=On,D.init(e,t),e._zod.check=n=>{Br(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Hr=/*@__PURE__*/ C(`$ZodCIDRv4`,(e,t)=>{t.pattern??=kn,D.init(e,t)});function Ur(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Br(n)}const Wr=/*@__PURE__*/ C(`$ZodCIDRv6`,(e,t)=>{t.pattern??=An,D.init(e,t),e._zod.check=n=>{Ur(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Gr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Kr=/^[0-9a-zA-Z+/]*={0,2}$/,qr=/*@__PURE__*/ C(`$ZodBase64`,(e,t)=>{t.pattern??=Kr,D.init(e,t),e._zod.check=n=>{Gr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Jr=/^[A-Za-z0-9_-]*$/;function Yr(e){if(!Jr.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Gr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const Xr=/*@__PURE__*/ C(`$ZodBase64URL`,(e,t)=>{t.pattern??=Jr,D.init(e,t),e._zod.check=n=>{Yr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Zr=/*@__PURE__*/ C(`$ZodE164`,(e,t)=>{t.pattern??=Pn,D.init(e,t)});function Qr(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const $r=/*@__PURE__*/ C(`$ZodJWT`,(e,t)=>{D.init(e,t),e._zod.check=n=>{Qr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ei=/*@__PURE__*/ C(`$ZodNumber`,(e,t)=>{E.init(e,t),e._zod.pattern=Un,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),ti=/*@__PURE__*/ C(`$ZodNumberFormat`,(e,t)=>{Qn.init(e,t),ei.init(e,t)}),ni=/*@__PURE__*/ C(`$ZodBoolean`,(e,t)=>{E.init(e,t),e._zod.pattern=Wn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),ri=/*@__PURE__*/ C(`$ZodUnknown`,(e,t)=>{E.init(e,t),e._zod.parse=e=>e}),ii=/*@__PURE__*/ C(`$ZodNever`,(e,t)=>{E.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ai(e,t){let n=ft(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of ft(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,pt(n.issues,t,e),n}}return i(n,a)}}const oi=e=>Array.isArray(e)?e.length:-1;function si(e,t,n){e.issues.length&&t.issues.push(...ut(n,e.issues)),t.value[n]=e.value}const ci=/*@__PURE__*/ C(`$ZodArray`,(e,t)=>{E.init(e,t);let n=Lt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>si(t,r,e)));else if(si(c,r,e),s&&c.issues.length!==0&&ct(c))break}return o.length?Promise.all(o).then(()=>r):r},ai(e,oi)});function li(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...ut(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}const ui=[];function di(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ui,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Xe(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function fi(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(ct(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>li(e,n,i,t,d,f))):li(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const pi=/*@__PURE__*/ C(`$ZodObject`,(e,t)=>{E.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=Oe(()=>di(t));S(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Me(n,e,/* @__PURE__ */ new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=He,o=t.catchall,s,c=Lt.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(ct(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>li(n,t,e,r,a,o))):li(s,t,e,r,a,o)}return o?fi(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),mi=/*@__PURE__*/ C(`$ZodObjectJIT`,(e,t)=>{pi.init(e,t);let n=e._zod.parse,r=Oe(()=>di(t)),i=Lt.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new ur([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
7
+ `)}\n};`)(...Object.values(this.closed))}};const ur={major:4,minor:6,patch:7},D=/*@__PURE__*/ C(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ur;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=ct(t),a;for(let o of n){if(o._zod.def.when){if(lt(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Ft;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(pt(t.issues,n,e),i||=ct(t,n))});else{if(t.issues.length===n)continue;pt(t.issues,n,e),i||=ct(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(ct(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Ft;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Ft;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return St(this,`~standard`,pr(this))},set"~standard"(e){xt(this,`~standard`,e)}}),dr=(e,t)=>e.issues.length?{issues:e.issues.map(e=>mt(e,t,Lt()))}:{value:e.value};async function fr(e,t){let n={async:!0};return dr(await e._zod.run({value:t,issues:[]},n),n)}function pr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return dr(r,n)}catch{}return fr(e,t)},vendor:`zod`,version:1}}const mr=/*@__PURE__*/ C(`$ZodString`,(e,t)=>{D.init(e,t),e._zod.pattern=t.pattern??Bn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),O=/*@__PURE__*/ C(`$ZodStringFormat`,(e,t)=>{tr.init(e,t),mr.init(e,t)}),hr=/*@__PURE__*/ C(`$ZodGUID`,(e,t)=>{t.pattern??=Sn,O.init(e,t)}),gr=/*@__PURE__*/ C(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Cn(e)}else t.pattern??=Cn();O.init(e,t)}),_r=/*@__PURE__*/ C(`$ZodEmail`,(e,t)=>{t.pattern??=wn,O.init(e,t)});function vr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function yr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?vr(e)||2:br(e,t)}function br(e,t){if(!t.normalize&&t.protocol?.source===Mn.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}const xr=/[\t\n\r]/g;function Sr(e){return e.replace(xr,``)}function Cr(e,t){return t.lastIndex=0,t.test(e.hostname)}function wr(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const Tr=/*@__PURE__*/ C(`$ZodURL`,(e,t)=>{O.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=yr(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Sr(r);return}t.hostname&&!Cr(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!wr(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Sr(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Er=/*@__PURE__*/ C(`$ZodEmoji`,(e,t)=>{t.pattern??=Tn(),O.init(e,t)}),Dr=/*@__PURE__*/ C(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?yn:bn(t.length),O.init(e,t)}),Or=/*@__PURE__*/ C(`$ZodCUID`,(e,t)=>{t.pattern??=mn,O.init(e,t)}),kr=/*@__PURE__*/ C(`$ZodCUID2`,(e,t)=>{t.pattern??=hn,O.init(e,t)}),Ar=/*@__PURE__*/ C(`$ZodULID`,(e,t)=>{t.pattern??=gn,O.init(e,t)}),jr=/*@__PURE__*/ C(`$ZodXID`,(e,t)=>{t.pattern??=_n,O.init(e,t)}),Mr=/*@__PURE__*/ C(`$ZodKSUID`,(e,t)=>{t.pattern??=vn,O.init(e,t)}),Nr=/*@__PURE__*/ C(`$ZodISODateTime`,(e,t)=>{t.pattern??=zn(t),O.init(e,t)}),Pr=/*@__PURE__*/ C(`$ZodISODate`,(e,t)=>{t.pattern??=In,O.init(e,t)}),Fr=/*@__PURE__*/ C(`$ZodISOTime`,(e,t)=>{t.pattern??=Rn(t),O.init(e,t)}),Ir=/*@__PURE__*/ C(`$ZodISODuration`,(e,t)=>{t.pattern??=xn,O.init(e,t)}),Lr=/*@__PURE__*/ C(`$ZodIPv4`,(e,t)=>{t.pattern??=En,O.init(e,t)}),Rr=/^[0-9a-fA-F:.]+$/;function zr(e){return Rr.test(e)?vr(`http://[${e}]`):!1}const Br=/*@__PURE__*/ C(`$ZodIPv6`,(e,t)=>{t.pattern??=Dn,O.init(e,t),e._zod.check=n=>{zr(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Vr=/*@__PURE__*/ C(`$ZodCIDRv4`,(e,t)=>{t.pattern??=On,O.init(e,t)});function Hr(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:zr(n)}const Ur=/*@__PURE__*/ C(`$ZodCIDRv6`,(e,t)=>{t.pattern??=kn,O.init(e,t),e._zod.check=n=>{Hr(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Wr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Gr=/^[0-9a-zA-Z+/]*={0,2}$/,Kr=/*@__PURE__*/ C(`$ZodBase64`,(e,t)=>{t.pattern??=Gr,O.init(e,t),e._zod.check=n=>{Wr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),qr=/^[A-Za-z0-9_-]*$/;function Jr(e){if(!qr.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Wr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const Yr=/*@__PURE__*/ C(`$ZodBase64URL`,(e,t)=>{t.pattern??=qr,O.init(e,t),e._zod.check=n=>{Jr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Xr=/*@__PURE__*/ C(`$ZodE164`,(e,t)=>{t.pattern??=Nn,O.init(e,t)});function Zr(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const Qr=/*@__PURE__*/ C(`$ZodJWT`,(e,t)=>{O.init(e,t),e._zod.check=n=>{Zr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),$r=/*@__PURE__*/ C(`$ZodNumber`,(e,t)=>{D.init(e,t),e._zod.pattern=Hn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),ei=/*@__PURE__*/ C(`$ZodNumberFormat`,(e,t)=>{Zn.init(e,t),$r.init(e,t)}),ti=/*@__PURE__*/ C(`$ZodBoolean`,(e,t)=>{D.init(e,t),e._zod.pattern=Un,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),ni=/*@__PURE__*/ C(`$ZodUnknown`,(e,t)=>{D.init(e,t),e._zod.parse=e=>e}),ri=/*@__PURE__*/ C(`$ZodNever`,(e,t)=>{D.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ii(e,t){let n=ft(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of ft(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,pt(n.issues,t,e),n}}return i(n,a)}}const ai=e=>Array.isArray(e)?e.length:-1;function oi(e,t,n){e.issues.length&&t.issues.push(...ut(n,e.issues)),t.value[n]=e.value}const si=/*@__PURE__*/ C(`$ZodArray`,(e,t)=>{D.init(e,t);let n=w.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>oi(t,r,e)));else if(oi(c,r,e),s&&c.issues.length!==0&&ct(c))break}return o.length?Promise.all(o).then(()=>r):r},ii(e,ai)});function ci(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...ut(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}const li=[];function ui(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:li,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Xe(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function di(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(ct(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ci(e,n,i,t,d,f))):ci(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const fi=/*@__PURE__*/ C(`$ZodObject`,(e,t)=>{D.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=Oe(()=>ui(t));S(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Me(n,e,/* @__PURE__ */ new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=He,o=t.catchall,s,c=w.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(ct(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>ci(n,t,e,r,a,o))):ci(s,t,e,r,a,o)}return o?di(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),pi=/*@__PURE__*/ C(`$ZodObjectJIT`,(e,t)=>{fi.init(e,t);let n=e._zod.parse,r=Oe(()=>ui(t)),i=w.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new lr([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
8
8
  let ${e}_ab = false;
9
9
  for (let i = 0; i < ${e}.issues.length; i++) {
10
10
  const iss = ${e}.issues[i];
@@ -54,65 +54,65 @@ function C(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=
54
54
  newResult[${r}] = ${n}.value;
55
55
  }
56
56
 
57
- `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=He,c=!Lt.jitless,l=c&&Ue.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?fi([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function hi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!ct(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>mt(e,r,Rt())))}),t)}const gi=/*@__PURE__*/ C(`$ZodUnion`,(e,t)=>{E.init(e,t),S(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),S(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),S(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),S(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Ae(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>hi(t,r,e,i)):hi(o,r,e,i)}}),_i=/*@__PURE__*/ C(`$ZodIntersection`,(e,t)=>{E.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>yi(e,t,n)):yi(e,i,a)}});function vi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(We(e)&&We(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=vi(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=vi(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function yi(e,t,n){let r=/* @__PURE__ */ new Map,i,a=/* @__PURE__ */ new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=vi(t.value,n.value);if(!c.valid){if(ct(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const bi=/*@__PURE__*/ C(`$ZodRecord`,(e,t)=>{E.init(e,t);let n=Lt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!We(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=/* @__PURE__ */ new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>mt(e,i,Rt())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...ut(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...ut(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Un.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>mt(e,i,Rt())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...ut(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...ut(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),xi=/*@__PURE__*/ C(`$ZodEnum`,(e,t)=>{E.init(e,t);let n=we(t.entries),r=new Set(n);e._zod.values=r,S(e,`pattern`,e=>{let t=we(e.def.entries).filter(e=>Ke.has(typeof e));return RegExp(t.length?`^(${t.map(e=>qe(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Si=/*@__PURE__*/ C(`$ZodTransform`,(e,t)=>{E.init(e,t),e._zod.optin=`optional`,Lt.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new It(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Ft;return n.value=i,n}});function Ci(e,t){return e.value=t.issues.length?void 0:t.value,e}const wi=/*@__PURE__*/ C(`$ZodOptional`,(e,t)=>{E.init(e,t),S(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,S(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?/* @__PURE__ */ new Set([...t,void 0]):void 0}),S(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Ae(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Ci(e,t)):Ci(e,r)}return t.innerType._zod.run(e,n)}}),Ti=/*@__PURE__*/ C(`$ZodExactOptional`,(e,t)=>{wi.init(e,t),S(e,`values`,e=>e.def.innerType._zod.values),S(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ei=/*@__PURE__*/ C(`$ZodNullable`,(e,t)=>{E.init(e,t),S(e,`optin`,e=>e.def.innerType._zod.optin),S(e,`optout`,e=>e.def.innerType._zod.optout),S(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Ae(t.source)}|null)$`):void 0}),S(e,`values`,e=>e.def.innerType._zod.values?/* @__PURE__ */ new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Di=/*@__PURE__*/ C(`$ZodDefault`,(e,t)=>{E.init(e,t),e._zod.optin=`defaulted`,S(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Oi(e,t)):Oi(r,t)}});function Oi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ki=/*@__PURE__*/ C(`$ZodPrefault`,(e,t)=>{E.init(e,t),e._zod.optin=`defaulted`,S(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ai=/*@__PURE__*/ C(`$ZodNonOptional`,(e,t)=>{E.init(e,t),S(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>ji(t,e)):ji(i,e)}});function ji(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Mi(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>mt(e,r,Rt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Ni=/*@__PURE__*/ C(`$ZodCatch`,(e,t)=>{E.init(e,t),S(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),S(e,`optout`,e=>e.def.innerType._zod.optout),S(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Mi(e,r,t,n)):Mi(e,r,t,n)}}),Pi=/*@__PURE__*/ C(`$ZodPipe`,(e,t)=>{E.init(e,t),S(e,`values`,e=>e.def.in._zod.values),S(e,`optin`,e=>e.def.in._zod.optin),S(e,`optout`,e=>e.def.out._zod.optout),S(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Fi(e,t.in,n)):Fi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Fi(e,t.out,n)):Fi(r,t.out,n)}});function Fi(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Ii=/*@__PURE__*/ C(`$ZodPreprocess`,(e,t)=>{Pi.init(e,t)}),Li=/*@__PURE__*/ C(`$ZodReadonly`,(e,t)=>{E.init(e,t),S(e,`propValues`,e=>e.def.innerType._zod.propValues),S(e,`values`,e=>e.def.innerType._zod.values),S(e,`optin`,e=>e.def.innerType?._zod?.optin),S(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ri):Ri(r)}});function Ri(e){return e.memo||(e.value=Object.freeze(e.value)),e}const zi=/*@__PURE__*/ C(`$ZodCustom`,(e,t)=>{T.init(e,t),E.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Bi(t,n,r,e));Bi(i,n,r,e)}});function Bi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(yt(e))}}var Vi=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const Hi=`~memo`,Ui=[];function Wi(e){return typeof e==`object`&&!!e}function Gi(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const Ki=/*@__PURE__*/ new WeakMap;function qi(e,t,n){let r=Ki.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=qi(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?qi(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Ne(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?qi(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Ji(e,i)}function Ji(e,t){return t!==1&&Ki.set(e,t===2),t}function Yi(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let Xi;const Zi=[],Qi={alloc(e,t,n){let r=Xi;if(!r)return n;Xi=void 0;let i={value:n,issues:null};return r.set(t.value,i),Zi.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&ea(n,e.value))throw new Vi;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=qi(e,/* @__PURE__ */ new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!Wi(l))return t(s,c);let u=c[Hi];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[Hi]=u);let d;i===c?d=a:(d=Yi(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Gi(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;Xi=d;let p=Zi.length,m=t(s,c);Xi=void 0;let h=Zi.length>p?Zi.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Gi(e.issues):Ui),e)):(h&&(h.issues=m.issues.length?Gi(m.issues):Ui),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function $i(){return Qi}function ea(e,t){let n=e[Hi]?.backEdges;return n!==void 0&&Wi(t)&&n.has(t)}const ta=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(vt(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Ye(e.values[0])}`:`Invalid option: expected one of ${Te(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Te(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function na(){return{localeError:ta()}}var ra,ia=class{constructor(){this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function aa(){return new ia}(ra=globalThis).__zod_globalRegistry??(ra.__zod_globalRegistry=aa());const oa=globalThis.__zod_globalRegistry;function sa(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
58
- function ca(e,t){return new e(sa({type:`string`,...x(t)}))}// @__NO_SIDE_EFFECTS__
59
- function la(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
60
- function ua(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
61
- function da(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
62
- function fa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...x(t)})}// @__NO_SIDE_EFFECTS__
63
- function pa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...x(t)})}// @__NO_SIDE_EFFECTS__
64
- function ma(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...x(t)})}// @__NO_SIDE_EFFECTS__
65
- function ha(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
66
- function ga(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
67
- function _a(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
68
- function va(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
69
- function ya(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
70
- function ba(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
71
- function xa(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
72
- function Sa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
73
- function Ca(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
74
- function wa(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
75
- function Ta(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
76
- function Ea(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
77
- function Da(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
78
- function Oa(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
79
- function ka(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
80
- function Aa(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
81
- function ja(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...x(t)})}// @__NO_SIDE_EFFECTS__
82
- function Ma(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...x(t)})}// @__NO_SIDE_EFFECTS__
83
- function Na(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...x(t)})}// @__NO_SIDE_EFFECTS__
84
- function Pa(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...x(t)})}// @__NO_SIDE_EFFECTS__
85
- function Fa(e,t){return new e(sa({type:`number`,checks:[],...x(t)}))}// @__NO_SIDE_EFFECTS__
86
- function Ia(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...x(t)})}// @__NO_SIDE_EFFECTS__
87
- function La(e,t){return new e({type:`boolean`,...x(t)})}// @__NO_SIDE_EFFECTS__
88
- function Ra(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
89
- function za(e,t){return new e({type:`never`,...x(t)})}// @__NO_SIDE_EFFECTS__
90
- function Ba(e,t){return new Yn({check:`less_than`,...x(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
91
- function Va(e,t){return new Yn({check:`less_than`,...x(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
92
- function Ha(e,t){return new Xn({check:`greater_than`,...x(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
93
- function Ua(e,t){return new Xn({check:`greater_than`,...x(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
94
- function Wa(e,t){return new Zn({check:`multiple_of`,...x(t),value:e})}// @__NO_SIDE_EFFECTS__
95
- function Ga(e,t){return new $n({check:`max_length`,...x(t),maximum:e})}// @__NO_SIDE_EFFECTS__
96
- function Ka(e,t){return new er({check:`min_length`,...x(t),minimum:e})}// @__NO_SIDE_EFFECTS__
97
- function qa(e,t){return new tr({check:`length_equals`,...x(t),length:e})}// @__NO_SIDE_EFFECTS__
98
- function Ja(e,t){return new rr({check:`string_format`,format:`regex`,...x(t),pattern:e})}// @__NO_SIDE_EFFECTS__
99
- function Ya(e){return new ir({check:`string_format`,format:`lowercase`,...x(e)})}// @__NO_SIDE_EFFECTS__
100
- function Xa(e){return new ar({check:`string_format`,format:`uppercase`,...x(e)})}// @__NO_SIDE_EFFECTS__
101
- function Za(e,t){return new or({check:`string_format`,format:`includes`,...x(t),includes:e})}// @__NO_SIDE_EFFECTS__
102
- function Qa(e,t){return new sr({check:`string_format`,format:`starts_with`,...x(t),prefix:e})}// @__NO_SIDE_EFFECTS__
103
- function $a(e,t){return new cr({check:`string_format`,format:`ends_with`,...x(t),suffix:e})}// @__NO_SIDE_EFFECTS__
104
- function eo(e){return new lr({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
105
- function to(e){return/* @__PURE__ */ eo(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
106
- function no(){return/* @__PURE__ */ eo(e=>e.trim())}// @__NO_SIDE_EFFECTS__
107
- function ro(){return/* @__PURE__ */ eo(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
108
- function io(){return/* @__PURE__ */ eo(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
109
- function ao(){return/* @__PURE__ */ eo(e=>Be(e))}// @__NO_SIDE_EFFECTS__
110
- function oo(e,t,n){return new e({type:`array`,element:t,...x(n)})}// @__NO_SIDE_EFFECTS__
111
- function so(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...x(n)})}// @__NO_SIDE_EFFECTS__
112
- function co(e,t){let n=/* @__PURE__ */ lo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(yt(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(yt(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
113
- function lo(e,t){let n=new T({check:`custom`,...x(t)});return n._zod.check=e,n}function uo(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Me(e,t,n[t]);return e}function fo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??oa,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function po(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function O(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,O(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&uo(o.schema,c),t.io===`input`&&k(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function mo(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function ho(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${mo(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+mo(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
57
+ `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=He,c=!w.jitless,l=c&&Ue.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?di([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function mi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!ct(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>mt(e,r,Lt())))}),t)}const hi=/*@__PURE__*/ C(`$ZodUnion`,(e,t)=>{D.init(e,t),S(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),S(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),S(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),S(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Ae(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>mi(t,r,e,i)):mi(o,r,e,i)}}),gi=/*@__PURE__*/ C(`$ZodIntersection`,(e,t)=>{D.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>vi(e,t,n)):vi(e,i,a)}});function _i(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(We(e)&&We(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=_i(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=_i(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function vi(e,t,n){let r=/* @__PURE__ */ new Map,i,a=/* @__PURE__ */ new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=_i(t.value,n.value);if(!c.valid){if(ct(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const yi=/*@__PURE__*/ C(`$ZodRecord`,(e,t)=>{D.init(e,t);let n=w.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!We(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=/* @__PURE__ */ new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>mt(e,i,Lt())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...ut(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...ut(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Hn.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>mt(e,i,Lt())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...ut(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...ut(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),bi=/*@__PURE__*/ C(`$ZodEnum`,(e,t)=>{D.init(e,t);let n=we(t.entries),r=new Set(n);e._zod.values=r,S(e,`pattern`,e=>{let t=we(e.def.entries).filter(e=>Ke.has(typeof e));return RegExp(t.length?`^(${t.map(e=>qe(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),xi=/*@__PURE__*/ C(`$ZodTransform`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,w.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new It(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Ft;return n.value=i,n}});function Si(e,t){return e.value=t.issues.length?void 0:t.value,e}const Ci=/*@__PURE__*/ C(`$ZodOptional`,(e,t)=>{D.init(e,t),S(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,S(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?/* @__PURE__ */ new Set([...t,void 0]):void 0}),S(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Ae(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Si(e,t)):Si(e,r)}return t.innerType._zod.run(e,n)}}),wi=/*@__PURE__*/ C(`$ZodExactOptional`,(e,t)=>{Ci.init(e,t),S(e,`values`,e=>e.def.innerType._zod.values),S(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ti=/*@__PURE__*/ C(`$ZodNullable`,(e,t)=>{D.init(e,t),S(e,`optin`,e=>e.def.innerType._zod.optin),S(e,`optout`,e=>e.def.innerType._zod.optout),S(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Ae(t.source)}|null)$`):void 0}),S(e,`values`,e=>e.def.innerType._zod.values?/* @__PURE__ */ new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ei=/*@__PURE__*/ C(`$ZodDefault`,(e,t)=>{D.init(e,t),e._zod.optin=`defaulted`,S(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Di(e,t)):Di(r,t)}});function Di(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Oi=/*@__PURE__*/ C(`$ZodPrefault`,(e,t)=>{D.init(e,t),e._zod.optin=`defaulted`,S(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),ki=/*@__PURE__*/ C(`$ZodNonOptional`,(e,t)=>{D.init(e,t),S(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ai(t,e)):Ai(i,e)}});function Ai(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function ji(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>mt(e,r,Lt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Mi=/*@__PURE__*/ C(`$ZodCatch`,(e,t)=>{D.init(e,t),S(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),S(e,`optout`,e=>e.def.innerType._zod.optout),S(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>ji(e,r,t,n)):ji(e,r,t,n)}}),Ni=/*@__PURE__*/ C(`$ZodPipe`,(e,t)=>{D.init(e,t),S(e,`values`,e=>e.def.in._zod.values),S(e,`optin`,e=>e.def.in._zod.optin),S(e,`optout`,e=>e.def.out._zod.optout),S(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Pi(e,t.in,n)):Pi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Pi(e,t.out,n)):Pi(r,t.out,n)}});function Pi(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Fi=/*@__PURE__*/ C(`$ZodPreprocess`,(e,t)=>{Ni.init(e,t)}),Ii=/*@__PURE__*/ C(`$ZodReadonly`,(e,t)=>{D.init(e,t),S(e,`propValues`,e=>e.def.innerType._zod.propValues),S(e,`values`,e=>e.def.innerType._zod.values),S(e,`optin`,e=>e.def.innerType?._zod?.optin),S(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Li):Li(r)}});function Li(e){return e.memo||(e.value=Object.freeze(e.value)),e}const Ri=/*@__PURE__*/ C(`$ZodCustom`,(e,t)=>{E.init(e,t),D.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>zi(t,n,r,e));zi(i,n,r,e)}});function zi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(yt(e))}}var Bi=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const Vi=`~memo`,Hi=[];function Ui(e){return typeof e==`object`&&!!e}function Wi(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const Gi=/*@__PURE__*/ new WeakMap;function Ki(e,t,n){let r=Gi.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=Ki(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?Ki(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Ne(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Ki(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),qi(e,i)}function qi(e,t){return t!==1&&Gi.set(e,t===2),t}function Ji(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let Yi;const Xi=[],Zi={alloc(e,t,n){let r=Yi;if(!r)return n;Yi=void 0;let i={value:n,issues:null};return r.set(t.value,i),Xi.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&$i(n,e.value))throw new Bi;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Ki(e,/* @__PURE__ */ new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!Ui(l))return t(s,c);let u=c[Vi];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[Vi]=u);let d;i===c?d=a:(d=Ji(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Wi(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;Yi=d;let p=Xi.length,m=t(s,c);Yi=void 0;let h=Xi.length>p?Xi.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Wi(e.issues):Hi),e)):(h&&(h.issues=m.issues.length?Wi(m.issues):Hi),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Qi(){return Zi}function $i(e,t){let n=e[Vi]?.backEdges;return n!==void 0&&Ui(t)&&n.has(t)}const ea=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(vt(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Ye(e.values[0])}`:`Invalid option: expected one of ${Te(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Te(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function ta(){return{localeError:ea()}}var na,ra=class{constructor(){this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ia(){return new ra}(na=globalThis).__zod_globalRegistry??(na.__zod_globalRegistry=ia());const aa=globalThis.__zod_globalRegistry;function oa(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
58
+ function sa(e,t){return new e(oa({type:`string`,...x(t)}))}// @__NO_SIDE_EFFECTS__
59
+ function ca(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
60
+ function la(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
61
+ function ua(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
62
+ function da(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...x(t)})}// @__NO_SIDE_EFFECTS__
63
+ function fa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...x(t)})}// @__NO_SIDE_EFFECTS__
64
+ function pa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...x(t)})}// @__NO_SIDE_EFFECTS__
65
+ function ma(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
66
+ function ha(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
67
+ function ga(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
68
+ function _a(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
69
+ function va(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
70
+ function ya(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
71
+ function ba(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
72
+ function xa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
73
+ function Sa(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
74
+ function Ca(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
75
+ function wa(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
76
+ function Ta(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
77
+ function Ea(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
78
+ function Da(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
79
+ function Oa(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
80
+ function ka(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...x(t)})}// @__NO_SIDE_EFFECTS__
81
+ function Aa(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...x(t)})}// @__NO_SIDE_EFFECTS__
82
+ function ja(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...x(t)})}// @__NO_SIDE_EFFECTS__
83
+ function Ma(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...x(t)})}// @__NO_SIDE_EFFECTS__
84
+ function Na(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...x(t)})}// @__NO_SIDE_EFFECTS__
85
+ function Pa(e,t){return new e(oa({type:`number`,checks:[],...x(t)}))}// @__NO_SIDE_EFFECTS__
86
+ function Fa(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...x(t)})}// @__NO_SIDE_EFFECTS__
87
+ function Ia(e,t){return new e({type:`boolean`,...x(t)})}// @__NO_SIDE_EFFECTS__
88
+ function La(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
89
+ function Ra(e,t){return new e({type:`never`,...x(t)})}// @__NO_SIDE_EFFECTS__
90
+ function za(e,t){return new Jn({check:`less_than`,...x(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
91
+ function Ba(e,t){return new Jn({check:`less_than`,...x(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
92
+ function Va(e,t){return new Yn({check:`greater_than`,...x(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
93
+ function Ha(e,t){return new Yn({check:`greater_than`,...x(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
94
+ function Ua(e,t){return new Xn({check:`multiple_of`,...x(t),value:e})}// @__NO_SIDE_EFFECTS__
95
+ function Wa(e,t){return new Qn({check:`max_length`,...x(t),maximum:e})}// @__NO_SIDE_EFFECTS__
96
+ function Ga(e,t){return new $n({check:`min_length`,...x(t),minimum:e})}// @__NO_SIDE_EFFECTS__
97
+ function Ka(e,t){return new er({check:`length_equals`,...x(t),length:e})}// @__NO_SIDE_EFFECTS__
98
+ function qa(e,t){return new nr({check:`string_format`,format:`regex`,...x(t),pattern:e})}// @__NO_SIDE_EFFECTS__
99
+ function Ja(e){return new rr({check:`string_format`,format:`lowercase`,...x(e)})}// @__NO_SIDE_EFFECTS__
100
+ function Ya(e){return new ir({check:`string_format`,format:`uppercase`,...x(e)})}// @__NO_SIDE_EFFECTS__
101
+ function Xa(e,t){return new ar({check:`string_format`,format:`includes`,...x(t),includes:e})}// @__NO_SIDE_EFFECTS__
102
+ function Za(e,t){return new or({check:`string_format`,format:`starts_with`,...x(t),prefix:e})}// @__NO_SIDE_EFFECTS__
103
+ function Qa(e,t){return new sr({check:`string_format`,format:`ends_with`,...x(t),suffix:e})}// @__NO_SIDE_EFFECTS__
104
+ function $a(e){return new cr({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
105
+ function eo(e){return/* @__PURE__ */ $a(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
106
+ function to(){return/* @__PURE__ */ $a(e=>e.trim())}// @__NO_SIDE_EFFECTS__
107
+ function no(){return/* @__PURE__ */ $a(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
108
+ function ro(){return/* @__PURE__ */ $a(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
109
+ function io(){return/* @__PURE__ */ $a(e=>Be(e))}// @__NO_SIDE_EFFECTS__
110
+ function ao(e,t,n){return new e({type:`array`,element:t,...x(n)})}// @__NO_SIDE_EFFECTS__
111
+ function oo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...x(n)})}// @__NO_SIDE_EFFECTS__
112
+ function so(e,t){let n=/* @__PURE__ */ co(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(yt(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(yt(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
113
+ function co(e,t){let n=new E({check:`custom`,...x(t)});return n._zod.check=e,n}function lo(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Me(e,t,n[t]);return e}function uo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??aa,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function fo(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function k(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,k(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&lo(o.schema,c),t.io===`input`&&A(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function po(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function mo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${po(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+po(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
114
114
 
115
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function go(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;go(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const _o=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),vo=[`oneOf`,`anyOf`];function yo(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function bo(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!_o.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??yo(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Me(n,r,e.length===1?e[0]:bo(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=yo(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function xo(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of _o)if(t in e)return;let n=t.filter(e=>vo.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=bo(t);else{let e=n[0],i=vo.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>bo([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,uo(e,r))}function So(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):uo(i,s),uo(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())go(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])xo(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}uo(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Me(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:wo(t,`input`,e.processors),output:wo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function k(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return k(r.element,n);if(r.type===`set`)return k(r.valueType,n);if(r.type===`lazy`)return k(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return k(r.innerType,n);if(r.type===`intersection`)return k(r.left,n)||k(r.right,n);if(r.type===`record`||r.type===`map`)return k(r.keyType,n)||k(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:k(r.in,n)||k(r.out,n);if(r.type===`object`){for(let e in r.shape)if(k(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(k(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(k(e,n))return!0;return!!(r.rest&&k(r.rest,n))}return!1}const Co=(e,t={})=>n=>{let r=fo({...n,processors:t});return O(e,r),ho(r,e),So(r,e)},wo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=fo({...i??{},target:a,io:t,processors:n});return O(e,o),ho(o,e),So(o,e)},To=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Eo=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Do=(e,t)=>{To(e,`minimum`,t),Eo(e,`maximum`,t)},Oo=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},ko=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},Ao=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},jo=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Mo=(e,t)=>To(e,`minimum`,t.minimum),No=(e,t)=>Eo(e,`maximum`,t.maximum),Po=e=>(t,n)=>{jo(t,n.format);let[r,i]=e[n.format];To(t,`minimum`,r),Eo(t,`maximum`,i)},Fo={greater_than:(e,t)=>To(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Eo(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Oo(e,t.value),number_format:Po(Ze),bigint_format:Po(Qe),min_length:Mo,max_length:No,length_equals:(e,t)=>Do(e,t.length),min_size:Mo,max_size:No,size_equals:(e,t)=>Do(e,t.size),string_format:(e,t)=>{jo(e,t.format),t.pattern&&ko(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Ao(e,t.mime)};function Io(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Fo[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&To(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&To(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Eo(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Eo(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Oo(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Ao(t,i.mime);for(let e of i.patterns??[])ko(t,e);return t}const Lo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ro=/* @__PURE__ */ new Map([[Kr,jn],[Jr,Mn]]),zo=e=>Ro.get(e)??e,Bo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Io(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Lo[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(zo);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Vo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Io(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):po(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Ho=(e,t,n,r)=>{n.type=`boolean`},Uo=(e,t,n,r)=>{n.not={}},Wo=(e,t,n,r)=>{let i=e._zod.def,a=we(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Go=(e,t,n,r)=>{po(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Ko=(e,t,n,r)=>{po(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},qo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Io(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=O(a.element,t,{...r,path:[...r.path,`items`]})};function Jo(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Jo(t.out):t.type===`catch`?Jo(t.innerType):e._zod.optin}const Yo=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&po(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Me(i.properties,e,O(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Jo(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=O(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Xo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>O(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Zo=(e,t,n,r)=>{let i=e._zod.def,a=O(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=O(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Qo(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Qo(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Qo(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Un:Hn).source)),p}const $o=/* @__PURE__ */ new WeakMap;function es(e){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=/* @__PURE__ */ new Map;for(let r of $o.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Qo(t,a,/* @__PURE__ */ new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}const ts=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Io(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=O(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Me(i.patternProperties,zo(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=O(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=$o.get(t);n||(n=[],$o.set(t,n),t.deferred.push(()=>es(t))),n.push(e)}i.additionalProperties=O(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Jo(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},ns=(e,t,n,r)=>{let i=e._zod.def,a=O(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},rs=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},is=Symbol();function as(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(po(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),is):JSON.parse(o)}const os=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=as(i.defaultValue,e,t,n,r);o!==is&&(n.default=o)},ss=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=as(i.defaultValue,e,t,n,r);o!==is&&(n._prefault=o)},cs=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{po(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},ls=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;O(o,t,r);let s=t.seen.get(e);s.ref=o},us=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ds=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},fs=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function ps(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const A=/*@__PURE__*/ C(`ZodError`,(e,t)=>{Wt.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);fs.has(n)||(fs.add(n),ps(n,`format`,e=>t=>qt(e,t)),ps(n,`flatten`,e=>t=>Kt(e,t)),ps(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ee,2)}),ps(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ee,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),ms=/* @__PURE__ */ Xt(A),hs=/* @__PURE__ */ Zt(A),gs=/* @__PURE__ */ Qt(A),_s=/* @__PURE__ */ en(A),vs=/* @__PURE__ */ sn(A),ys=/* @__PURE__ */ cn(A),bs=/* @__PURE__ */ ln(A),xs=/* @__PURE__ */ un(A),Ss=/* @__PURE__ */ dn(A),Cs=/* @__PURE__ */ fn(A),ws=/* @__PURE__ */ pn(A),Ts=/* @__PURE__ */ mn(A);function Es(){Lt.localeError||Rt(na())}function Ds(){Lt.memoizer||Rt({memoizer:$i()})}const j=/*@__PURE__*/ C(`ZodType`,(e,t)=>(Es(),E.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(b(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Je(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Uc(e,t))},superRefine(e,t){return this.check(Wc(e,t))},overwrite(e){return this.check(/* @__PURE__ */ eo(e))},optional(){return wc(this)},exactOptional(){return Ec(this)},nullable(){return Oc(this)},nullish(){return wc(Oc(this))},nonoptional(e){return Pc(this,e)},array(){return uc(this)},or(e){return mc([this,e])},and(e){return gc(this,e)},transform(e){return Rc(this,Sc(e))},default(e){return Ac(this,e)},prefault(e){return Mc(this,e)},catch(e){return Ic(this,e)},pipe(e){return Rc(this,e)},readonly(){return Vc(this)},describe(e){let t=this.clone();return oa.add(t,{description:e}),t},meta(...e){if(e.length===0)return oa.get(this);let t=this.clone();return oa.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return St(this,`~standard`,{...mr(this),jsonSchema:{input:wo(this,`input`),output:wo(this,`output`)}})},set"~standard"(e){xt(this,`~standard`,e)},parse:function e(t,n){return ms(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await hs(this,t,n,{callee:e})},safeParse(e,t){return gs(this,e,t)},async safeParseAsync(e,t){return _s(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){xt(this,`spa`,e)},validate(e,t){return rn(this,e,t)},validateAsync(e,t){return on(this,e,t)},encode:function e(t,n){return vs(this,t,n,{callee:e})},decode:function e(t,n){return ys(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await bs(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await xs(this,t,n,{callee:e})},safeEncode(e,t){return Ss(this,e,t)},safeDecode(e,t){return Cs(this,e,t)},async safeEncodeAsync(e,t){return ws(this,e,t)},async safeDecodeAsync(e,t){return Ts(this,e,t)},toJSONSchema(e){return Co(this,{})(e)},get description(){return oa.get(this)?.description},get _def(){return this._zod.def}}),Os=/*@__PURE__*/ C(`_ZodString`,(e,t)=>{hr.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r)},/*@__PURE__*/ Ct({format:e=>Io(e).format??null,minLength:e=>Io(e).minimum??null,maxLength:e=>Io(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ Ja(...e))},includes(...e){return this.check(/* @__PURE__ */ Za(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Qa(...e))},endsWith(...e){return this.check(/* @__PURE__ */ $a(...e))},min(...e){return this.check(/* @__PURE__ */ Ka(...e))},max(...e){return this.check(/* @__PURE__ */ Ga(...e))},length(...e){return this.check(/* @__PURE__ */ qa(...e))},nonempty(...e){return this.check(/* @__PURE__ */ Ka(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Ya(e))},uppercase(e){return this.check(/* @__PURE__ */ Xa(e))},trim(){return this.check(/* @__PURE__ */ no())},normalize(...e){return this.check(/* @__PURE__ */ to(...e))},toLowerCase(){return this.check(/* @__PURE__ */ ro())},toUpperCase(){return this.check(/* @__PURE__ */ io())},slugify(){return this.check(/* @__PURE__ */ ao())}})),ks=/*@__PURE__*/ C(`ZodString`,(e,t)=>{hr.init(e,t),Os.init(e,t)},{email(e){return this.check(/* @__PURE__ */ la(Ps,e))},url(e){return this.check(/* @__PURE__ */ ha(Ls,e))},jwt(e){return this.check(/* @__PURE__ */ Aa(Qs,e))},emoji(e){return this.check(/* @__PURE__ */ ga(Rs,e))},guid(e){return this.check(/* @__PURE__ */ ua(Fs,e))},uuid(e){return this.check(/* @__PURE__ */ da(Is,e))},uuidv4(e){return this.check(/* @__PURE__ */ fa(Is,e))},uuidv6(e){return this.check(/* @__PURE__ */ pa(Is,e))},uuidv7(e){return this.check(/* @__PURE__ */ ma(Is,e))},nanoid(e){return this.check(/* @__PURE__ */ _a(zs,e))},cuid(e){return this.check(/* @__PURE__ */ va(Bs,e))},cuid2(e){return this.check(/* @__PURE__ */ ya(Vs,e))},ulid(e){return this.check(/* @__PURE__ */ ba(Hs,e))},base64(e){return this.check(/* @__PURE__ */ Da(Ys,e))},base64url(e){return this.check(/* @__PURE__ */ Oa(Xs,e))},xid(e){return this.check(/* @__PURE__ */ xa(Us,e))},ksuid(e){return this.check(/* @__PURE__ */ Sa(Ws,e))},ipv4(e){return this.check(/* @__PURE__ */ Ca(Gs,e))},ipv6(e){return this.check(/* @__PURE__ */ wa(Ks,e))},cidrv4(e){return this.check(/* @__PURE__ */ Ta(qs,e))},cidrv6(e){return this.check(/* @__PURE__ */ Ea(Js,e))},e164(e){return this.check(/* @__PURE__ */ ka(Zs,e))},datetime(e){return this.check(/* @__PURE__ */ ja(As,e))},date(e){return this.check(/* @__PURE__ */ Ma(js,e))},time(e){return this.check(/* @__PURE__ */ Na(Ms,e))},duration(e){return this.check(/* @__PURE__ */ Pa(Ns,e))}});function M(e){return/* @__PURE__ */ ca(ks,e)}const N=/*@__PURE__*/ C(`ZodStringFormat`,(e,t)=>{D.init(e,t),Os.init(e,t)}),As=/*@__PURE__*/ C(`ZodISODateTime`,(e,t)=>{Pr.init(e,t),N.init(e,t)}),js=/*@__PURE__*/ C(`ZodISODate`,(e,t)=>{Fr.init(e,t),N.init(e,t)}),Ms=/*@__PURE__*/ C(`ZodISOTime`,(e,t)=>{Ir.init(e,t),N.init(e,t)}),Ns=/*@__PURE__*/ C(`ZodISODuration`,(e,t)=>{Lr.init(e,t),N.init(e,t)}),Ps=/*@__PURE__*/ C(`ZodEmail`,(e,t)=>{vr.init(e,t),N.init(e,t)}),Fs=/*@__PURE__*/ C(`ZodGUID`,(e,t)=>{gr.init(e,t),N.init(e,t)}),Is=/*@__PURE__*/ C(`ZodUUID`,(e,t)=>{_r.init(e,t),N.init(e,t)}),Ls=/*@__PURE__*/ C(`ZodURL`,(e,t)=>{Er.init(e,t),N.init(e,t)}),Rs=/*@__PURE__*/ C(`ZodEmoji`,(e,t)=>{Dr.init(e,t),N.init(e,t)}),zs=/*@__PURE__*/ C(`ZodNanoID`,(e,t)=>{Or.init(e,t),N.init(e,t)}),Bs=/*@__PURE__*/ C(`ZodCUID`,(e,t)=>{kr.init(e,t),N.init(e,t)}),Vs=/*@__PURE__*/ C(`ZodCUID2`,(e,t)=>{Ar.init(e,t),N.init(e,t)}),Hs=/*@__PURE__*/ C(`ZodULID`,(e,t)=>{jr.init(e,t),N.init(e,t)}),Us=/*@__PURE__*/ C(`ZodXID`,(e,t)=>{Mr.init(e,t),N.init(e,t)}),Ws=/*@__PURE__*/ C(`ZodKSUID`,(e,t)=>{Nr.init(e,t),N.init(e,t)}),Gs=/*@__PURE__*/ C(`ZodIPv4`,(e,t)=>{Rr.init(e,t),N.init(e,t)}),Ks=/*@__PURE__*/ C(`ZodIPv6`,(e,t)=>{Vr.init(e,t),N.init(e,t)}),qs=/*@__PURE__*/ C(`ZodCIDRv4`,(e,t)=>{Hr.init(e,t),N.init(e,t)}),Js=/*@__PURE__*/ C(`ZodCIDRv6`,(e,t)=>{Wr.init(e,t),N.init(e,t)}),Ys=/*@__PURE__*/ C(`ZodBase64`,(e,t)=>{qr.init(e,t),N.init(e,t)}),Xs=/*@__PURE__*/ C(`ZodBase64URL`,(e,t)=>{Xr.init(e,t),N.init(e,t)}),Zs=/*@__PURE__*/ C(`ZodE164`,(e,t)=>{Zr.init(e,t),N.init(e,t)}),Qs=/*@__PURE__*/ C(`ZodJWT`,(e,t)=>{$r.init(e,t),N.init(e,t)}),$s=/*@__PURE__*/ C(`ZodNumber`,(e,t)=>{ei.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vo(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ Ct({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Io(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Io(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Io(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Io(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ Ha(e,t))},gte(e,t){return this.check(/* @__PURE__ */ Ua(e,t))},min(e,t){return this.check(/* @__PURE__ */ Ua(e,t))},lt(e,t){return this.check(/* @__PURE__ */ Ba(e,t))},lte(e,t){return this.check(/* @__PURE__ */ Va(e,t))},max(e,t){return this.check(/* @__PURE__ */ Va(e,t))},int(e){return this.check(nc(e))},safe(e){return this.check(nc(e))},positive(e){return this.check(/* @__PURE__ */ Ha(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ Ua(0,e))},negative(e){return this.check(/* @__PURE__ */ Ba(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ Va(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ Wa(e,t))},step(e,t){return this.check(/* @__PURE__ */ Wa(e,t))},finite(){return this}}));function ec(e){return/* @__PURE__ */ Fa($s,e)}const tc=/*@__PURE__*/ C(`ZodNumberFormat`,(e,t)=>{ti.init(e,t),$s.init(e,t)});function nc(e){return/* @__PURE__ */ Ia(tc,e)}const rc=/*@__PURE__*/ C(`ZodBoolean`,(e,t)=>{ni.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r)});function ic(e){return/* @__PURE__ */ La(rc,e)}const ac=/*@__PURE__*/ C(`ZodUnknown`,(e,t)=>{ri.init(e,t),j.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function oc(){return/* @__PURE__ */ Ra(ac)}const sc=/*@__PURE__*/ C(`ZodNever`,(e,t)=>{ii.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r)});function cc(e){return/* @__PURE__ */ za(sc,e)}const lc=/*@__PURE__*/ C(`ZodArray`,(e,t)=>{Ds(),ci.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ Ka(e,t))},nonempty(e){return this.check(/* @__PURE__ */ Ka(1,e))},max(e,t){return this.check(/* @__PURE__ */ Ga(e,t))},length(e,t){return this.check(/* @__PURE__ */ qa(e,t))},unwrap(){return this.element}});function uc(e,t){return/* @__PURE__ */ oo(lc,e,t)}const dc=/*@__PURE__*/ C(`ZodObject`,(e,t)=>{Ds(),mi.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),kt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return bc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(b(this._zod.def,{catchall:e}))},passthrough(){return this.clone(b(this._zod.def,{catchall:oc()}))},loose(){return this.clone(b(this._zod.def,{catchall:oc()}))},strict(){return this.clone(b(this._zod.def,{catchall:cc()}))},strip(){return this.clone(b(this._zod.def,{catchall:void 0}))},extend(e){return nt(this,e)},safeExtend(e){return it(this,e)},merge(e){return at(this,e)},pick(e){return $e(this,e)},omit(e){return tt(this,e)},partial(...e){return ot(Cc,this,e[0])},exactPartial(...e){return ot(Tc,this,e[0],`exactPartial`)},required(...e){return st(Nc,this,e[0])}});function P(e,t){return new dc({type:`object`,shape:e,catchall:cc(),...x(t)})}function fc(e,t){return new dc({type:`object`,shape:e,catchall:oc(),...x(t)})}const pc=/*@__PURE__*/ C(`ZodUnion`,(e,t)=>{gi.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),e.options=t.options});function mc(e,t){return new pc({type:`union`,options:e,...x(t)})}const hc=/*@__PURE__*/ C(`ZodIntersection`,(e,t)=>{_i.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r)});function gc(e,t){return new hc({type:`intersection`,left:e,right:t})}const _c=/*@__PURE__*/ C(`ZodRecord`,(e,t)=>{Ds(),bi.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function vc(e,t,n){return!t||!t._zod?new _c({type:`record`,keyType:M(),valueType:e,...x(t)}):new _c({type:`record`,keyType:e,valueType:t,...x(n)})}const yc=/*@__PURE__*/ C(`ZodEnum`,(e,t)=>{xi.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new yc({...t,checks:[],...x(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new yc({...t,checks:[],...x(r),entries:i})}});function bc(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new yc({type:`enum`,entries:n,...x(t)})}const xc=/*@__PURE__*/ C(`ZodTransform`,(e,t)=>{Ds(),Si.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new It(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(yt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(yt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Sc(e){return new xc({type:`transform`,transform:e})}const Cc=/*@__PURE__*/ C(`ZodOptional`,(e,t)=>{wi.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wc(e){return new Cc({type:`optional`,innerType:e})}const Tc=/*@__PURE__*/ C(`ZodExactOptional`,(e,t)=>{Ti.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ec(e){return new Tc({type:`optional`,innerType:e})}const Dc=/*@__PURE__*/ C(`ZodNullable`,(e,t)=>{Ei.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Oc(e){return new Dc({type:`nullable`,innerType:e})}const kc=/*@__PURE__*/ C(`ZodDefault`,(e,t)=>{Di.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ac(e,t){return new kc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ge(t)}})}const jc=/*@__PURE__*/ C(`ZodPrefault`,(e,t)=>{ki.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mc(e,t){return new jc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ge(t)}})}const Nc=/*@__PURE__*/ C(`ZodNonOptional`,(e,t)=>{Ai.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pc(e,t){return new Nc({type:`nonoptional`,innerType:e,...x(t)})}const Fc=/*@__PURE__*/ C(`ZodCatch`,(e,t)=>{Ni.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ic(e,t){return new Fc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:At(t)})}const Lc=/*@__PURE__*/ C(`ZodPipe`,(e,t)=>{Pi.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e.in=t.in,e.out=t.out});function Rc(e,t){return new Lc({type:`pipe`,in:e,out:t})}const zc=/*@__PURE__*/ C(`ZodPreprocess`,(e,t)=>{Lc.init(e,t),Ii.init(e,t)}),Bc=/*@__PURE__*/ C(`ZodReadonly`,(e,t)=>{Li.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vc(e){return new Bc({type:`readonly`,innerType:e})}const Hc=/*@__PURE__*/ C(`ZodCustom`,(e,t)=>{zi.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Go(e,t,n,r)});function Uc(e,t={}){return/* @__PURE__ */ so(Hc,e,t)}function Wc(e,t){return/* @__PURE__ */ co(e,t)}function Gc(e,t){return new zc({type:`pipe`,in:Sc(e),out:t})}function Kc(e){return/* @__PURE__ */ ja(As,e)}const qc=[`blobless`,`full`],Jc=[`ssh`,`https`],Yc=/^(?!\.{1,2}$)[^/\\%:]+$/u,Xc=/^[a-z0-9][a-z0-9.-]*(?:_[1-9]\d{0,4})?$/u,Zc=/^(?<amount>[1-9]\d{0,3})(?<unit>[mhd])$/u,Qc={d:864e5,h:36e5,m:6e4},$c=e=>e!==``&&/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/u.test(e),el=e=>{if(e===void 0)return!0;let t=Number(e);return t>=1&&t<=65535},tl=e=>{let[t=``,n]=e.split(`_`);return el(n)?t.split(`.`).every(e=>$c(e)):!1},nl=e=>e.length>0&&e.isWellFormed(),rl=M().refine(nl,`must be non-empty text that survives being written to the config`),il=rl.refine(Ce,`must be a name git accepts for a branch (git check-ref-format --branch)`),al=e=>{let[t,...n]=e.split(`/`);return t===void 0||n.length<2||!Xc.test(t)||!tl(t)?!1:n.every(e=>Yc.test(e))},ol=e=>Yc.test(e),sl=M().refine(e=>nl(e)&&al(e),`ref key must be host/path…/repo with safe, non-empty segments`).brand(),cl=M().regex(Zc,`duration must be <n>m, <n>h, or <n>d`).brand(),ll=e=>{let t=Zc.exec(e);if(t===null)throw Error(`invalid duration: ${e}`);let{amount:n,unit:r}=t.groups??{};if(!n||!r)throw Error(`invalid duration: ${e}`);return Number(n)*Qc[r]},ul=bc(qc),dl=bc(Jc),fl=rl.refine(e=>e.includes(`{version}`),`tag format must contain {version}`),pl=rl.refine(e=>{if(e===`.`)return!0;let t=e.split(`/`);return t.length>0&&t.every(e=>Yc.test(e)&&e!==`.`)},`package path must be "." or a normalized relative path without traversal`),ml=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]),hl=(e,t,n)=>Gc((n,r)=>{if(typeof n==`object`&&n)for(let i of Reflect.ownKeys(n))typeof i==`string`&&e(i)||r.addIssue({code:`custom`,message:t(String(i)),path:[String(i)]});return n},n),gl=e=>nl(e)&&!ml.has(e),_l=e=>hl(gl,()=>`package key must be non-empty, storable text, and not "__proto__", "constructor", or "prototype"`,vc(M().min(1),e)),vl=e=>gl(e),yl={clone_mode:`blobless`,git_transport:`https`,sync_ttl:`1h`},bl=P({clone_mode:ul.default(yl.clone_mode),git_transport:dl.default(yl.git_transport),sync_ttl:cl.default(cl.parse(yl.sync_ttl))}),xl=P((e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.removeDefault().optional()])))(bl.shape)),Sl=P({name:rl,path:pl}),Cl=P({description:rl,path:pl,tag_format:fl.optional()}),wl=P({declined_packages:uc(Sl).optional(),default_branch:rl,description:rl,packages:_l(Cl).optional(),tag_format:fl.optional(),url:rl,...xl.shape}),Tl=fc({cli_version:rl,schema_version:ec().int().positive()}),El=hl(e=>sl.safeParse(e).success,()=>`ref key must be host/path…/repo with safe, non-empty segments`,vc(M(),wl)),Dl=P({check:ic().default(!0),notify:ic().default(!0)}),Ol=P({meta:Tl,refs:El.default({}),settings:bl,updates:Dl.optional()});
115
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function ho(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;ho(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const go=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),_o=[`oneOf`,`anyOf`];function vo(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function yo(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!go.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??vo(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Me(n,r,e.length===1?e[0]:yo(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=vo(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function bo(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of go)if(t in e)return;let n=t.filter(e=>_o.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=yo(t);else{let e=n[0],i=_o.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>yo([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,lo(e,r))}function xo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):lo(i,s),lo(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())ho(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])bo(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}lo(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Me(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Co(t,`input`,e.processors),output:Co(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function A(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return A(r.element,n);if(r.type===`set`)return A(r.valueType,n);if(r.type===`lazy`)return A(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return A(r.innerType,n);if(r.type===`intersection`)return A(r.left,n)||A(r.right,n);if(r.type===`record`||r.type===`map`)return A(r.keyType,n)||A(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:A(r.in,n)||A(r.out,n);if(r.type===`object`){for(let e in r.shape)if(A(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(A(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(A(e,n))return!0;return!!(r.rest&&A(r.rest,n))}return!1}const So=(e,t={})=>n=>{let r=uo({...n,processors:t});return k(e,r),mo(r,e),xo(r,e)},Co=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=uo({...i??{},target:a,io:t,processors:n});return k(e,o),mo(o,e),xo(o,e)},wo=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},To=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Eo=(e,t)=>{wo(e,`minimum`,t),To(e,`maximum`,t)},Do=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Oo=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},ko=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Ao=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},jo=(e,t)=>wo(e,`minimum`,t.minimum),Mo=(e,t)=>To(e,`maximum`,t.maximum),No=e=>(t,n)=>{Ao(t,n.format);let[r,i]=e[n.format];wo(t,`minimum`,r),To(t,`maximum`,i)},Po={greater_than:(e,t)=>wo(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>To(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Do(e,t.value),number_format:No(Ze),bigint_format:No(Qe),min_length:jo,max_length:Mo,length_equals:(e,t)=>Eo(e,t.length),min_size:jo,max_size:Mo,size_equals:(e,t)=>Eo(e,t.size),string_format:(e,t)=>{Ao(e,t.format),t.pattern&&Oo(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>ko(e,t.mime)};function j(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Po[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&wo(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&wo(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&To(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&To(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Do(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&ko(t,i.mime);for(let e of i.patterns??[])Oo(t,e);return t}const Fo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Io=/* @__PURE__ */ new Map([[Gr,An],[qr,jn]]),Lo=e=>Io.get(e)??e,Ro=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=j(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Fo[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Lo);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},zo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=j(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):fo(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Bo=(e,t,n,r)=>{n.type=`boolean`},Vo=(e,t,n,r)=>{n.not={}},Ho=(e,t,n,r)=>{let i=we(e._zod.def.entries);i.length===0?n.not={}:(i.every(e=>typeof e==`number`)&&(n.type=`number`),i.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=i)},Uo=(e,t,n,r)=>{fo(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Wo=(e,t,n,r)=>{fo(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Go=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=j(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=k(a.element,t,{...r,path:[...r.path,`items`]})};function Ko(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Ko(t.out):t.type===`catch`?Ko(t.innerType):e._zod.optin}const qo=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&fo(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Me(i.properties,e,k(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Ko(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=k(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Jo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>k(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Yo=(e,t,n,r)=>{let i=e._zod.def,a=k(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=k(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Xo(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Xo(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Xo(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Hn:Vn).source)),p}const Zo=/* @__PURE__ */ new WeakMap;function Qo(e){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=/* @__PURE__ */ new Map;for(let r of Zo.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Xo(t,a,/* @__PURE__ */ new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}const $o=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=j(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=k(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Me(i.patternProperties,Lo(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=k(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Zo.get(t);n||(n=[],Zo.set(t,n),t.deferred.push(()=>Qo(t))),n.push(e)}i.additionalProperties=k(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Ko(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},es=(e,t,n,r)=>{let i=e._zod.def,a=k(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ts=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ns=Symbol();function rs(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(fo(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),ns):JSON.parse(o)}const is=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=rs(i.defaultValue,e,t,n,r);o!==ns&&(n.default=o)},as=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=rs(i.defaultValue,e,t,n,r);o!==ns&&(n._prefault=o)},os=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{fo(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},ss=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;k(o,t,r);let s=t.seen.get(e);s.ref=o},cs=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ls=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},us=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function ds(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const M=/*@__PURE__*/ C(`ZodError`,(e,t)=>{Ut.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);us.has(n)||(us.add(n),ds(n,`format`,e=>t=>Kt(e,t)),ds(n,`flatten`,e=>t=>Gt(e,t)),ds(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ee,2)}),ds(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ee,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),fs=/* @__PURE__ */ Yt(M),ps=/* @__PURE__ */ Xt(M),ms=/* @__PURE__ */ Zt(M),hs=/* @__PURE__ */ $t(M),gs=/* @__PURE__ */ on(M),_s=/* @__PURE__ */ sn(M),vs=/* @__PURE__ */ cn(M),ys=/* @__PURE__ */ ln(M),bs=/* @__PURE__ */ un(M),xs=/* @__PURE__ */ dn(M),Ss=/* @__PURE__ */ fn(M),Cs=/* @__PURE__ */ pn(M);function ws(){w.localeError||Lt(ta())}function Ts(){w.memoizer||Lt({memoizer:Qi()})}const N=/*@__PURE__*/ C(`ZodType`,(e,t)=>(ws(),D.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(b(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Je(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Vc(e,t))},superRefine(e,t){return this.check(Hc(e,t))},overwrite(e){return this.check(/* @__PURE__ */ $a(e))},optional(){return Sc(this)},exactOptional(){return wc(this)},nullable(){return Ec(this)},nullish(){return Sc(Ec(this))},nonoptional(e){return Mc(this,e)},array(){return cc(this)},or(e){return fc([this,e])},and(e){return mc(this,e)},transform(e){return Ic(this,bc(e))},default(e){return Oc(this,e)},prefault(e){return Ac(this,e)},catch(e){return Pc(this,e)},pipe(e){return Ic(this,e)},readonly(){return zc(this)},describe(e){let t=this.clone();return aa.add(t,{description:e}),t},meta(...e){if(e.length===0)return aa.get(this);let t=this.clone();return aa.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return St(this,`~standard`,{...pr(this),jsonSchema:{input:Co(this,`input`),output:Co(this,`output`)}})},set"~standard"(e){xt(this,`~standard`,e)},parse:function e(t,n){return fs(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ps(this,t,n,{callee:e})},safeParse(e,t){return ms(this,e,t)},async safeParseAsync(e,t){return hs(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){xt(this,`spa`,e)},validate(e,t){return nn(this,e,t)},validateAsync(e,t){return an(this,e,t)},encode:function e(t,n){return gs(this,t,n,{callee:e})},decode:function e(t,n){return _s(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await vs(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await ys(this,t,n,{callee:e})},safeEncode(e,t){return bs(this,e,t)},safeDecode(e,t){return xs(this,e,t)},async safeEncodeAsync(e,t){return Ss(this,e,t)},async safeDecodeAsync(e,t){return Cs(this,e,t)},toJSONSchema(e){return So(this,{})(e)},get description(){return aa.get(this)?.description},get _def(){return this._zod.def}}),Es=/*@__PURE__*/ C(`_ZodString`,(e,t)=>{mr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r)},/*@__PURE__*/ Ct({format:e=>j(e).format??null,minLength:e=>j(e).minimum??null,maxLength:e=>j(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ qa(...e))},includes(...e){return this.check(/* @__PURE__ */ Xa(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Za(...e))},endsWith(...e){return this.check(/* @__PURE__ */ Qa(...e))},min(...e){return this.check(/* @__PURE__ */ Ga(...e))},max(...e){return this.check(/* @__PURE__ */ Wa(...e))},length(...e){return this.check(/* @__PURE__ */ Ka(...e))},nonempty(...e){return this.check(/* @__PURE__ */ Ga(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Ja(e))},uppercase(e){return this.check(/* @__PURE__ */ Ya(e))},trim(){return this.check(/* @__PURE__ */ to())},normalize(...e){return this.check(/* @__PURE__ */ eo(...e))},toLowerCase(){return this.check(/* @__PURE__ */ no())},toUpperCase(){return this.check(/* @__PURE__ */ ro())},slugify(){return this.check(/* @__PURE__ */ io())}})),Ds=/*@__PURE__*/ C(`ZodString`,(e,t)=>{mr.init(e,t),Es.init(e,t)},{email(e){return this.check(/* @__PURE__ */ ca(Ms,e))},url(e){return this.check(/* @__PURE__ */ ma(Fs,e))},jwt(e){return this.check(/* @__PURE__ */ ka(Xs,e))},emoji(e){return this.check(/* @__PURE__ */ ha(Is,e))},guid(e){return this.check(/* @__PURE__ */ la(Ns,e))},uuid(e){return this.check(/* @__PURE__ */ ua(Ps,e))},uuidv4(e){return this.check(/* @__PURE__ */ da(Ps,e))},uuidv6(e){return this.check(/* @__PURE__ */ fa(Ps,e))},uuidv7(e){return this.check(/* @__PURE__ */ pa(Ps,e))},nanoid(e){return this.check(/* @__PURE__ */ ga(Ls,e))},cuid(e){return this.check(/* @__PURE__ */ _a(Rs,e))},cuid2(e){return this.check(/* @__PURE__ */ va(zs,e))},ulid(e){return this.check(/* @__PURE__ */ ya(Bs,e))},base64(e){return this.check(/* @__PURE__ */ Ea(qs,e))},base64url(e){return this.check(/* @__PURE__ */ Da(Js,e))},xid(e){return this.check(/* @__PURE__ */ ba(Vs,e))},ksuid(e){return this.check(/* @__PURE__ */ xa(Hs,e))},ipv4(e){return this.check(/* @__PURE__ */ Sa(Us,e))},ipv6(e){return this.check(/* @__PURE__ */ Ca(Ws,e))},cidrv4(e){return this.check(/* @__PURE__ */ wa(Gs,e))},cidrv6(e){return this.check(/* @__PURE__ */ Ta(Ks,e))},e164(e){return this.check(/* @__PURE__ */ Oa(Ys,e))},datetime(e){return this.check(/* @__PURE__ */ Aa(Os,e))},date(e){return this.check(/* @__PURE__ */ ja(ks,e))},time(e){return this.check(/* @__PURE__ */ Ma(As,e))},duration(e){return this.check(/* @__PURE__ */ Na(js,e))}});function P(e){return/* @__PURE__ */ sa(Ds,e)}const F=/*@__PURE__*/ C(`ZodStringFormat`,(e,t)=>{O.init(e,t),Es.init(e,t)}),Os=/*@__PURE__*/ C(`ZodISODateTime`,(e,t)=>{Nr.init(e,t),F.init(e,t)}),ks=/*@__PURE__*/ C(`ZodISODate`,(e,t)=>{Pr.init(e,t),F.init(e,t)}),As=/*@__PURE__*/ C(`ZodISOTime`,(e,t)=>{Fr.init(e,t),F.init(e,t)}),js=/*@__PURE__*/ C(`ZodISODuration`,(e,t)=>{Ir.init(e,t),F.init(e,t)}),Ms=/*@__PURE__*/ C(`ZodEmail`,(e,t)=>{_r.init(e,t),F.init(e,t)}),Ns=/*@__PURE__*/ C(`ZodGUID`,(e,t)=>{hr.init(e,t),F.init(e,t)}),Ps=/*@__PURE__*/ C(`ZodUUID`,(e,t)=>{gr.init(e,t),F.init(e,t)}),Fs=/*@__PURE__*/ C(`ZodURL`,(e,t)=>{Tr.init(e,t),F.init(e,t)}),Is=/*@__PURE__*/ C(`ZodEmoji`,(e,t)=>{Er.init(e,t),F.init(e,t)}),Ls=/*@__PURE__*/ C(`ZodNanoID`,(e,t)=>{Dr.init(e,t),F.init(e,t)}),Rs=/*@__PURE__*/ C(`ZodCUID`,(e,t)=>{Or.init(e,t),F.init(e,t)}),zs=/*@__PURE__*/ C(`ZodCUID2`,(e,t)=>{kr.init(e,t),F.init(e,t)}),Bs=/*@__PURE__*/ C(`ZodULID`,(e,t)=>{Ar.init(e,t),F.init(e,t)}),Vs=/*@__PURE__*/ C(`ZodXID`,(e,t)=>{jr.init(e,t),F.init(e,t)}),Hs=/*@__PURE__*/ C(`ZodKSUID`,(e,t)=>{Mr.init(e,t),F.init(e,t)}),Us=/*@__PURE__*/ C(`ZodIPv4`,(e,t)=>{Lr.init(e,t),F.init(e,t)}),Ws=/*@__PURE__*/ C(`ZodIPv6`,(e,t)=>{Br.init(e,t),F.init(e,t)}),Gs=/*@__PURE__*/ C(`ZodCIDRv4`,(e,t)=>{Vr.init(e,t),F.init(e,t)}),Ks=/*@__PURE__*/ C(`ZodCIDRv6`,(e,t)=>{Ur.init(e,t),F.init(e,t)}),qs=/*@__PURE__*/ C(`ZodBase64`,(e,t)=>{Kr.init(e,t),F.init(e,t)}),Js=/*@__PURE__*/ C(`ZodBase64URL`,(e,t)=>{Yr.init(e,t),F.init(e,t)}),Ys=/*@__PURE__*/ C(`ZodE164`,(e,t)=>{Xr.init(e,t),F.init(e,t)}),Xs=/*@__PURE__*/ C(`ZodJWT`,(e,t)=>{Qr.init(e,t),F.init(e,t)}),Zs=/*@__PURE__*/ C(`ZodNumber`,(e,t)=>{$r.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zo(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ Ct({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=j(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=j(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=j(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>j(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ Va(e,t))},gte(e,t){return this.check(/* @__PURE__ */ Ha(e,t))},min(e,t){return this.check(/* @__PURE__ */ Ha(e,t))},lt(e,t){return this.check(/* @__PURE__ */ za(e,t))},lte(e,t){return this.check(/* @__PURE__ */ Ba(e,t))},max(e,t){return this.check(/* @__PURE__ */ Ba(e,t))},int(e){return this.check(ec(e))},safe(e){return this.check(ec(e))},positive(e){return this.check(/* @__PURE__ */ Va(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ Ha(0,e))},negative(e){return this.check(/* @__PURE__ */ za(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ Ba(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ Ua(e,t))},step(e,t){return this.check(/* @__PURE__ */ Ua(e,t))},finite(){return this}}));function Qs(e){return/* @__PURE__ */ Pa(Zs,e)}const $s=/*@__PURE__*/ C(`ZodNumberFormat`,(e,t)=>{ei.init(e,t),Zs.init(e,t)});function ec(e){return/* @__PURE__ */ Fa($s,e)}const tc=/*@__PURE__*/ C(`ZodBoolean`,(e,t)=>{ti.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r)});function nc(e){return/* @__PURE__ */ Ia(tc,e)}const rc=/*@__PURE__*/ C(`ZodUnknown`,(e,t)=>{ni.init(e,t),N.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ic(){return/* @__PURE__ */ La(rc)}const ac=/*@__PURE__*/ C(`ZodNever`,(e,t)=>{ri.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vo(e,t,n,r)});function oc(e){return/* @__PURE__ */ Ra(ac,e)}const sc=/*@__PURE__*/ C(`ZodArray`,(e,t)=>{Ts(),si.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Go(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ Ga(e,t))},nonempty(e){return this.check(/* @__PURE__ */ Ga(1,e))},max(e,t){return this.check(/* @__PURE__ */ Wa(e,t))},length(e,t){return this.check(/* @__PURE__ */ Ka(e,t))},unwrap(){return this.element}});function cc(e,t){return/* @__PURE__ */ ao(sc,e,t)}const lc=/*@__PURE__*/ C(`ZodObject`,(e,t)=>{Ts(),pi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),kt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return vc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(b(this._zod.def,{catchall:e}))},passthrough(){return this.clone(b(this._zod.def,{catchall:ic()}))},loose(){return this.clone(b(this._zod.def,{catchall:ic()}))},strict(){return this.clone(b(this._zod.def,{catchall:oc()}))},strip(){return this.clone(b(this._zod.def,{catchall:void 0}))},extend(e){return nt(this,e)},safeExtend(e){return it(this,e)},merge(e){return at(this,e)},pick(e){return $e(this,e)},omit(e){return tt(this,e)},partial(...e){return ot(xc,this,e[0])},exactPartial(...e){return ot(Cc,this,e[0],`exactPartial`)},required(...e){return st(jc,this,e[0])}});function I(e,t){return new lc({type:`object`,shape:e,catchall:oc(),...x(t)})}function uc(e,t){return new lc({type:`object`,shape:e,catchall:ic(),...x(t)})}const dc=/*@__PURE__*/ C(`ZodUnion`,(e,t)=>{hi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r),e.options=t.options});function fc(e,t){return new dc({type:`union`,options:e,...x(t)})}const pc=/*@__PURE__*/ C(`ZodIntersection`,(e,t)=>{gi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r)});function mc(e,t){return new pc({type:`intersection`,left:e,right:t})}const hc=/*@__PURE__*/ C(`ZodRecord`,(e,t)=>{Ts(),yi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function gc(e,t,n){return!t||!t._zod?new hc({type:`record`,keyType:P(),valueType:e,...x(t)}):new hc({type:`record`,keyType:e,valueType:t,...x(n)})}const _c=/*@__PURE__*/ C(`ZodEnum`,(e,t)=>{bi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new _c({...t,checks:[],...x(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new _c({...t,checks:[],...x(r),entries:i})}});function vc(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new _c({type:`enum`,entries:n,...x(t)})}const yc=/*@__PURE__*/ C(`ZodTransform`,(e,t)=>{Ts(),xi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new It(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(yt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(yt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function bc(e){return new yc({type:`transform`,transform:e})}const xc=/*@__PURE__*/ C(`ZodOptional`,(e,t)=>{Ci.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Sc(e){return new xc({type:`optional`,innerType:e})}const Cc=/*@__PURE__*/ C(`ZodExactOptional`,(e,t)=>{wi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wc(e){return new Cc({type:`optional`,innerType:e})}const Tc=/*@__PURE__*/ C(`ZodNullable`,(e,t)=>{Ti.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ec(e){return new Tc({type:`nullable`,innerType:e})}const Dc=/*@__PURE__*/ C(`ZodDefault`,(e,t)=>{Ei.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Oc(e,t){return new Dc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ge(t)}})}const kc=/*@__PURE__*/ C(`ZodPrefault`,(e,t)=>{Oi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ac(e,t){return new kc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ge(t)}})}const jc=/*@__PURE__*/ C(`ZodNonOptional`,(e,t)=>{ki.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mc(e,t){return new jc({type:`nonoptional`,innerType:e,...x(t)})}const Nc=/*@__PURE__*/ C(`ZodCatch`,(e,t)=>{Mi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Pc(e,t){return new Nc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:At(t)})}const Fc=/*@__PURE__*/ C(`ZodPipe`,(e,t)=>{Ni.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e.in=t.in,e.out=t.out});function Ic(e,t){return new Fc({type:`pipe`,in:e,out:t})}const Lc=/*@__PURE__*/ C(`ZodPreprocess`,(e,t)=>{Fc.init(e,t),Fi.init(e,t)}),Rc=/*@__PURE__*/ C(`ZodReadonly`,(e,t)=>{Ii.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zc(e){return new Rc({type:`readonly`,innerType:e})}const Bc=/*@__PURE__*/ C(`ZodCustom`,(e,t)=>{Ri.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r)});function Vc(e,t={}){return/* @__PURE__ */ oo(Bc,e,t)}function Hc(e,t){return/* @__PURE__ */ so(e,t)}function Uc(e,t){return new Lc({type:`pipe`,in:bc(e),out:t})}function Wc(e){return/* @__PURE__ */ Aa(Os,e)}const Gc=[`blobless`,`full`],Kc=[`ssh`,`https`],qc=/^(?!\.{1,2}$)[^/\\%:]+$/u,Jc=/^[a-z0-9][a-z0-9.-]*(?:_[1-9]\d{0,4})?$/u,Yc=/^(?<amount>[1-9]\d{0,3})(?<unit>[mhd])$/u,Xc={d:864e5,h:36e5,m:6e4},Zc=e=>e!==``&&/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/u.test(e),Qc=e=>{if(e===void 0)return!0;let t=Number(e);return t>=1&&t<=65535},$c=e=>{let[t=``,n]=e.split(`_`);return Qc(n)?t.split(`.`).every(e=>Zc(e)):!1},el=e=>e.length>0&&e.isWellFormed(),tl=P().refine(el,`must be non-empty text that survives being written to the config`),nl=tl.refine(Ce,`must be a name git accepts for a branch (git check-ref-format --branch)`),rl=e=>{let[t,...n]=e.split(`/`);return t===void 0||n.length<2||!Jc.test(t)||!$c(t)?!1:n.every(e=>qc.test(e))},il=e=>qc.test(e),al=P().refine(e=>el(e)&&rl(e),`ref key must be host/path…/repo with safe, non-empty segments`).brand(),ol=P().regex(Yc,`duration must be <n>m, <n>h, or <n>d`).brand(),sl=e=>{let t=Yc.exec(e);if(t===null)throw Error(`invalid duration: ${e}`);let{amount:n,unit:r}=t.groups??{};if(!n||!r)throw Error(`invalid duration: ${e}`);return Number(n)*Xc[r]},cl=vc(Gc),ll=vc(Kc),ul=tl.refine(e=>e.includes(`{version}`),`tag format must contain {version}`),dl=tl.refine(e=>{if(e===`.`)return!0;let t=e.split(`/`);return t.length>0&&t.every(e=>qc.test(e)&&e!==`.`)},`package path must be "." or a normalized relative path without traversal`),fl=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]),pl=(e,t,n)=>Uc((n,r)=>{if(typeof n==`object`&&n)for(let i of Reflect.ownKeys(n))typeof i==`string`&&e(i)||r.addIssue({code:`custom`,message:t(String(i)),path:[String(i)]});return n},n),ml=e=>el(e)&&!fl.has(e),hl=e=>pl(ml,()=>`package key must be non-empty, storable text, and not "__proto__", "constructor", or "prototype"`,gc(P().min(1),e)),gl=e=>ml(e),_l={clone_mode:`blobless`,git_transport:`https`,sync_ttl:`1h`},vl=I({clone_mode:cl.default(_l.clone_mode),git_transport:ll.default(_l.git_transport),sync_ttl:ol.default(ol.parse(_l.sync_ttl))}),yl=I((e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.removeDefault().optional()])))(vl.shape)),bl=I({name:tl,path:dl}),xl=I({description:tl,path:dl,tag_format:ul.optional()}),Sl=I({declined_packages:cc(bl).optional(),default_branch:tl,description:tl,packages:hl(xl).optional(),tag_format:ul.optional(),url:tl,...yl.shape}),Cl=uc({cli_version:tl,schema_version:Qs().int().positive()}),wl=pl(e=>al.safeParse(e).success,()=>`ref key must be host/path…/repo with safe, non-empty segments`,gc(P(),Sl)),Tl=I({check:nc().default(!0),notify:nc().default(!0)}),El=I({meta:Cl,refs:wl.default({}),settings:vl,updates:Tl.optional()});
116
116
  /*!
117
117
  * Copyright (c) Squirrel Chat et al., All rights reserved.
118
118
  * SPDX-License-Identifier: BSD-3-Clause
@@ -140,9 +140,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
140
140
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
141
141
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
142
142
  */
143
- function kl(e,t){let n=e.slice(0,t).split(/\r?\n/);return[n.length,n.pop().length+1]}function Al(e,t,n){let r=e.split(/\r?\n/),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
143
+ function Dl(e,t){let n=e.slice(0,t).split(/\r?\n/);return[n.length,n.pop().length+1]}function Ol(e,t,n){let r=e.split(/\r?\n/),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
144
144
  `,e===t&&(i+=` `.repeat(a+n+2),i+=`^
145
- `))}return i}var F=class e extends Error{line;column;codeblock;constructor(e,t){let[n,r]=kl(t.toml,t.ptr),i=Al(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}static x(t,n,r){throw new e(t,{toml:n.s,ptr:r??n.p})}};
145
+ `))}return i}var L=class e extends Error{line;column;codeblock;constructor(e,t){let[n,r]=Dl(t.toml,t.ptr),i=Ol(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}static x(t,n,r){throw new e(t,{toml:n.s,ptr:r??n.p})}};
146
146
  /*!
147
147
  * Copyright (c) Squirrel Chat et al., All rights reserved.
148
148
  * SPDX-License-Identifier: BSD-3-Clause
@@ -170,8 +170,8 @@ function kl(e,t){let n=e.slice(0,t).split(/\r?\n/);return[n.length,n.pop().lengt
170
170
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
171
171
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
172
172
  */
173
- function jl(e){let t=e.p,n=e.s.charCodeAt(e.p++),r=n,i=n===39,a=n===e.s.charCodeAt(e.p)&&n===e.s.charCodeAt(e.p+1);a&&((n=e.s.charCodeAt(e.p+=2))===10?e.p++:n===13&&e.s.charCodeAt(e.p+1)===10&&(e.p+=2));let o=``,s=e.p,c=0;for(;e.p<e.s.length;e.p++)if(n=e.s.charCodeAt(e.p),a&&(n===10||n===13&&e.s.charCodeAt(e.p+1)===10))c&&=3;else if(n<32&&n!==9||n===127)F.x(`control characters are not allowed in strings`,e);else if((!c||c===3)&&n===r&&(!a||e.s.charCodeAt(e.p+1)===r&&e.s.charCodeAt(e.p+2)===r)){if(a&&(e.s.charCodeAt(e.p+3)===r&&e.p++,e.s.charCodeAt(e.p+3)===r&&e.p++),!c){let t=e.s.slice(s,e.p);o=o?o+t:t}return e.p+=a?3:1,o}else if(!c)!i&&n===92&&(o+=e.s.slice(s,s=e.p),c=1);else if(c===1){if(n===120||n===117||n===85){let t=e.p++-1,r=0,i=n===120?2:n===117?4:8;for(let t=0;t<i;t++,e.p++){let t=e.s.charCodeAt(e.p),n=t>=48&&t<=57?t-48:t>=65&&t<=70?t-65+10:t>=97&&t<=102?t-97+10:-1;n<0&&F.x(`invalid non-hex character in unicode escape`,e),r=r<<4|n}(r<0||r>1114111||r>=55296&&r<=57343)&&F.x(`invalid unicode escape`,e,t),o+=String.fromCodePoint(r),s=e.p--,c=0}else a&&(n===32||n===9)?c=2:(n===98?o+=`\b`:n===116?o+=` `:n===110?o+=`
174
- `:n===102?o+=`\f`:n===114?o+=`\r`:n===101?o+=`\x1B`:n===34?o+=`"`:n===92?o+=`\\`:F.x(`unrecognised escape sequence`,e),s=e.p+1,c=0)}else n!==32&&n!==9&&(c===2&&F.x(`invalid escape: only line-ending whitespace may be escaped`,e,s),c=+(!i&&n===92),s=e.p);F.x(`unfinished string`,e,t)}
173
+ function kl(e){let t=e.p,n=e.s.charCodeAt(e.p++),r=n,i=n===39,a=n===e.s.charCodeAt(e.p)&&n===e.s.charCodeAt(e.p+1);a&&((n=e.s.charCodeAt(e.p+=2))===10?e.p++:n===13&&e.s.charCodeAt(e.p+1)===10&&(e.p+=2));let o=``,s=e.p,c=0;for(;e.p<e.s.length;e.p++)if(n=e.s.charCodeAt(e.p),a&&(n===10||n===13&&e.s.charCodeAt(e.p+1)===10))c&&=3;else if(n<32&&n!==9||n===127)L.x(`control characters are not allowed in strings`,e);else if((!c||c===3)&&n===r&&(!a||e.s.charCodeAt(e.p+1)===r&&e.s.charCodeAt(e.p+2)===r)){if(a&&(e.s.charCodeAt(e.p+3)===r&&e.p++,e.s.charCodeAt(e.p+3)===r&&e.p++),!c){let t=e.s.slice(s,e.p);o=o?o+t:t}return e.p+=a?3:1,o}else if(!c)!i&&n===92&&(o+=e.s.slice(s,s=e.p),c=1);else if(c===1){if(n===120||n===117||n===85){let t=e.p++-1,r=0,i=n===120?2:n===117?4:8;for(let t=0;t<i;t++,e.p++){let t=e.s.charCodeAt(e.p),n=t>=48&&t<=57?t-48:t>=65&&t<=70?t-65+10:t>=97&&t<=102?t-97+10:-1;n<0&&L.x(`invalid non-hex character in unicode escape`,e),r=r<<4|n}(r<0||r>1114111||r>=55296&&r<=57343)&&L.x(`invalid unicode escape`,e,t),o+=String.fromCodePoint(r),s=e.p--,c=0}else a&&(n===32||n===9)?c=2:(n===98?o+=`\b`:n===116?o+=` `:n===110?o+=`
174
+ `:n===102?o+=`\f`:n===114?o+=`\r`:n===101?o+=`\x1B`:n===34?o+=`"`:n===92?o+=`\\`:L.x(`unrecognised escape sequence`,e),s=e.p+1,c=0)}else n!==32&&n!==9&&(c===2&&L.x(`invalid escape: only line-ending whitespace may be escaped`,e,s),c=+(!i&&n===92),s=e.p);L.x(`unfinished string`,e,t)}
175
175
  /*!
176
176
  * Copyright (c) Squirrel Chat et al., All rights reserved.
177
177
  * SPDX-License-Identifier: BSD-3-Clause
@@ -199,7 +199,7 @@ function jl(e){let t=e.p,n=e.s.charCodeAt(e.p++),r=n,i=n===39,a=n===e.s.charCode
199
199
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
200
200
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
201
201
  */
202
- let Ml=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;var Nl=class e extends Date{#e=!1;#t=!1;#n=null;constructor(e,t,n){let r=!0,i=!0,a=`Z`,o;if(typeof e==`string`){if(t)prep:{if(t<3){if(+e.slice(11,13)>23){e=``;break prep}t===2?(a=null,e+=`Z`):(o=e.charCodeAt(e.length-1))!==90&&o!==122&&(a=e.slice(e.length-6)),n&&(e=e.slice(0,10)+`T`+e.slice(11))}else t===4&&(e=+e.slice(0,2)>23?``:`0000-01-01T${e}Z`);r=t!==4,i=t!==3}else{let t=e.match(Ml);t?(t[1]||(r=!1,e=`0000-01-01T${e}`),i=!!t[2],i&&e[10]===` `&&(e=e.replace(` `,`T`)),t[2]&&+t[2]>23?e=``:(a=t[3]||null,!a&&i&&(e+=`Z`))):e=``}}super(e),isNaN(this.getTime())||(this.#e=r,this.#t=i,this.#n=a)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`||this.#n===`z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,(/* @__PURE__ */ new Date(this.getTime()-t*6e4)).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}};
202
+ let Al=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;var jl=class e extends Date{#e=!1;#t=!1;#n=null;constructor(e,t,n){let r=!0,i=!0,a=`Z`,o;if(typeof e==`string`){if(t)e:{if(t<3){if(+e.slice(11,13)>23){e=``;break e}t===2?(a=null,e+=`Z`):(o=e.charCodeAt(e.length-1))!==90&&o!==122&&(a=e.slice(e.length-6)),n&&(e=e.slice(0,10)+`T`+e.slice(11))}else t===4&&(e=+e.slice(0,2)>23?``:`0000-01-01T${e}Z`);r=t!==4,i=t!==3}else{let t=e.match(Al);t?(t[1]||(r=!1,e=`0000-01-01T${e}`),i=!!t[2],i&&e[10]===` `&&(e=e.replace(` `,`T`)),t[2]&&+t[2]>23?e=``:(a=t[3]||null,!a&&i&&(e+=`Z`))):e=``}}super(e),isNaN(this.getTime())||(this.#e=r,this.#t=i,this.#n=a)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`||this.#n===`z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,(/* @__PURE__ */ new Date(this.getTime()-t*6e4)).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}};
203
203
  /*!
204
204
  * Copyright (c) Squirrel Chat et al., All rights reserved.
205
205
  * SPDX-License-Identifier: BSD-3-Clause
@@ -227,7 +227,7 @@ let Ml=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[
227
227
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
228
228
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
229
229
  */
230
- function I(e,t=10){return t===16?e>47&&e<58||e>64&&e<71||e>96&&e<103:e>47&&e<48+t}function Pl(e,t){return e===32||e===9||e===10||e===13||t&&(e===t||e===44)||e===35}function Fl(e,t){let n=e.p,r=e.s.charCodeAt(e.p);if(r===91||r===123){e.d--||F.x(`document contains excessively nested structures. aborting.`,e);let t=r===91?Kl(e):Gl(e);return e.d++,t}return r===34||r===39?jl(e):r===116?((e.s.charCodeAt(++e.p)!==114||e.s.charCodeAt(++e.p)!==117||e.s.charCodeAt(++e.p)!==101)&&F.x(`invalid value`,e,n),e.p++,!0):r===102?((e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==108||e.s.charCodeAt(++e.p)!==115||e.s.charCodeAt(++e.p)!==101)&&F.x(`invalid value`,e,n),e.p++,!1):r===43||r===45?Il(e,e.p,e.s.charCodeAt(++e.p),44-r,t):e.s.charCodeAt(e.p+4)===45&&e.s.charCodeAt(e.p+7)===45?zl(e,r,t):e.s.charCodeAt(e.p+2)===58?Bl(e,r,t):Il(e,e.p,r,0,t)}function Il(e,t,n,r,i){let a=n,o=0,s=!1;if(a===105)return(e.s.charCodeAt(++e.p)!==110||e.s.charCodeAt(++e.p)!==102)&&F.x(`invalid value`,e,t),e.p++,(r||1)/0;if(a===110)return(e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==110)&&F.x(`invalid value`,e,t),e.p++,NaN;if(a===48){if(++e.p>=e.s.length||Pl(a=e.s.charCodeAt(e.p),i))return e.bi===!0?0n:0;if(!r){if(a===120)return Ll(e,t,16,i);if(a===98)return Ll(e,t,2,i);if(a===111)return Ll(e,t,8,i)}a===46?o=2:a===101||a===69?o=4:F.x(`illegal leading zero`,e,t)}else I(a)||F.x(`invalid value`,e,t);for(;++e.p<e.s.length&&(a=e.s.charCodeAt(e.p),!Pl(a,i));)o||=1,a===95?(o&1||F.x(`illegal underscore`,e),o+=11,s=!0):o===1&&a===46?o=2:(o===1||o===3)&&(a===101||a===69)?o=4:o===4&&(a===43||a===45)?o=6:I(a)?o>9?o-=11:o&1||o++:F.x(`illegal character in numeric literal`,e);if(!o){let t=(n-48)*(r||1);return e.bi===!0?BigInt(t):t}o&1||F.x(`unfinished numeric value`,e,t);let c=e.s.slice(t,e.p);return s&&(c=c.replaceAll(`_`,``)),o>1?parseFloat(c):Rl(e,c,10,t)}function Ll(e,t,n,r){let i,a=1;for(;++e.p<e.s.length&&(i=e.s.charCodeAt(e.p),!Pl(i,r));)i===95?(a&1&&F.x(`illegal underscore`,e),a=3):I(i,n)?a&1&&a--:F.x(`illegal character in numeric literal`,e);a&1&&F.x(`unfinished numeric value`,e);let o=e.s.slice(t+2,e.p);return a&&(o=o.replaceAll(`_`,``)),Rl(e,o,n,t)}function Rl(e,t,n,r){if(e.bi!==!0)int:{let i=parseInt(t,n);if(!Number.isSafeInteger(i)){if(e.bi)break int;F.x(`integer value cannot be represented losslessly`,e,r)}return i}return BigInt(n===10?t:(n===2?`0b`:n===8?`0o`:`0x`)+t)}function zl(e,t,n){let r=e.p++,i;if(!I(t)||!I(e.s.charCodeAt(e.p++))||!I(e.s.charCodeAt(e.p++))||!I(e.s.charCodeAt(e.p++)))return Il(e,e.p=r,t,0,n);if(e.p+=5,I(e.s.charCodeAt(e.p++))||F.x(`invalid date-time: date part is malformed`,e,r),e.p>=e.s.length||((t=e.s.charCodeAt(e.p))!==32||(i=!0,!I(e.s.charCodeAt(e.p+1))))&&t!==84&&t!==116)return Vl(e,e.s.slice(r,e.p),3,!1,r);if(e.s.charCodeAt(e.p+=3)!==58&&F.x(`invalid date-time: time part is malformed`,e,r),e.s.charCodeAt(e.p+=3)===58&&(e.p+=3),e.s.charCodeAt(e.p)===46)for(;I(e.s.charCodeAt(++e.p)););if(t=e.s.charCodeAt(e.p)){if(t===90||t===122)return Vl(e,e.s.slice(r,++e.p),1,i,r,`[+00:00]`);if(t===43||t===45)return Vl(e,e.s.slice(r,e.p+=6),1,i,r,!e.ld&&`[`+e.s.slice(e.p-6,e.p)+`]`)}return Vl(e,e.s.slice(r,e.p),2,i,r)}function Bl(e,t,n){let r=e.p;if(!I(t)||!I(e.s.charCodeAt(++e.p)))return Il(e,--e.p,t,0,n);if(e.s.charCodeAt(e.p+=4)===58&&(e.p+=3),e.s.charCodeAt(e.p)===46)for(;I(e.s.charCodeAt(++e.p)););return Vl(e,e.s.slice(r,e.p),4,!1,r)}function Vl(e,t,n,r,i,a){if(e.ld){let a=new Nl(t,n,r);return a.isValid()||F.x(`invalid date`,e,i),a}try{switch(a&&(t+=a),n){case 1:return Temporal.ZonedDateTime.from(t);case 2:return Temporal.PlainDateTime.from(t);case 3:return Temporal.PlainDate.from(t);case 4:return Temporal.PlainTime.from(t)}}catch(t){F.x(t instanceof Error?t.message:``+t,e,i)}}
230
+ function R(e,t=10){return t===16?e>47&&e<58||e>64&&e<71||e>96&&e<103:e>47&&e<48+t}function Ml(e,t){return e===32||e===9||e===10||e===13||t&&(e===t||e===44)||e===35}function Nl(e,t){let n=e.p,r=e.s.charCodeAt(e.p);if(r===91||r===123){e.d--||L.x(`document contains excessively nested structures. aborting.`,e);let t=r===91?Wl(e):Ul(e);return e.d++,t}return r===34||r===39?kl(e):r===116?((e.s.charCodeAt(++e.p)!==114||e.s.charCodeAt(++e.p)!==117||e.s.charCodeAt(++e.p)!==101)&&L.x(`invalid value`,e,n),e.p++,!0):r===102?((e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==108||e.s.charCodeAt(++e.p)!==115||e.s.charCodeAt(++e.p)!==101)&&L.x(`invalid value`,e,n),e.p++,!1):r===43||r===45?Pl(e,e.p,e.s.charCodeAt(++e.p),44-r,t):e.s.charCodeAt(e.p+4)===45&&e.s.charCodeAt(e.p+7)===45?Ll(e,r,t):e.s.charCodeAt(e.p+2)===58?Rl(e,r,t):Pl(e,e.p,r,0,t)}function Pl(e,t,n,r,i){let a=n,o=0,s=!1;if(a===105)return(e.s.charCodeAt(++e.p)!==110||e.s.charCodeAt(++e.p)!==102)&&L.x(`invalid value`,e,t),e.p++,(r||1)/0;if(a===110)return(e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==110)&&L.x(`invalid value`,e,t),e.p++,NaN;if(a===48){if(++e.p>=e.s.length||Ml(a=e.s.charCodeAt(e.p),i))return e.bi===!0?0n:0;if(!r){if(a===120)return Fl(e,t,16,i);if(a===98)return Fl(e,t,2,i);if(a===111)return Fl(e,t,8,i)}a===46?o=2:a===101||a===69?o=4:L.x(`illegal leading zero`,e,t)}else R(a)||L.x(`invalid value`,e,t);for(;++e.p<e.s.length&&(a=e.s.charCodeAt(e.p),!Ml(a,i));)o||=1,a===95?(o&1||L.x(`illegal underscore`,e),o+=11,s=!0):o===1&&a===46?o=2:(o===1||o===3)&&(a===101||a===69)?o=4:o===4&&(a===43||a===45)?o=6:R(a)?o>9?o-=11:o&1||o++:L.x(`illegal character in numeric literal`,e);if(!o){let t=(n-48)*(r||1);return e.bi===!0?BigInt(t):t}o&1||L.x(`unfinished numeric value`,e,t);let c=e.s.slice(t,e.p);return s&&(c=c.replaceAll(`_`,``)),o>1?parseFloat(c):Il(e,c,10,t)}function Fl(e,t,n,r){let i,a=1;for(;++e.p<e.s.length&&(i=e.s.charCodeAt(e.p),!Ml(i,r));)i===95?(a&1&&L.x(`illegal underscore`,e),a=3):R(i,n)?a&1&&a--:L.x(`illegal character in numeric literal`,e);a&1&&L.x(`unfinished numeric value`,e);let o=e.s.slice(t+2,e.p);return a&&(o=o.replaceAll(`_`,``)),Il(e,o,n,t)}function Il(e,t,n,r){if(e.bi!==!0)e:{let i=parseInt(t,n);if(!Number.isSafeInteger(i)){if(e.bi)break e;L.x(`integer value cannot be represented losslessly`,e,r)}return i}return BigInt(n===10?t:(n===2?`0b`:n===8?`0o`:`0x`)+t)}function Ll(e,t,n){let r=e.p++,i;if(!R(t)||!R(e.s.charCodeAt(e.p++))||!R(e.s.charCodeAt(e.p++))||!R(e.s.charCodeAt(e.p++)))return Pl(e,e.p=r,t,0,n);if(e.p+=5,R(e.s.charCodeAt(e.p++))||L.x(`invalid date-time: date part is malformed`,e,r),e.p>=e.s.length||((t=e.s.charCodeAt(e.p))!==32||(i=!0,!R(e.s.charCodeAt(e.p+1))))&&t!==84&&t!==116)return zl(e,e.s.slice(r,e.p),3,!1,r);if(e.s.charCodeAt(e.p+=3)!==58&&L.x(`invalid date-time: time part is malformed`,e,r),e.s.charCodeAt(e.p+=3)===58&&(e.p+=3),e.s.charCodeAt(e.p)===46)for(;R(e.s.charCodeAt(++e.p)););if(t=e.s.charCodeAt(e.p)){if(t===90||t===122)return zl(e,e.s.slice(r,++e.p),1,i,r,`[+00:00]`);if(t===43||t===45)return zl(e,e.s.slice(r,e.p+=6),1,i,r,!e.ld&&`[`+e.s.slice(e.p-6,e.p)+`]`)}return zl(e,e.s.slice(r,e.p),2,i,r)}function Rl(e,t,n){let r=e.p;if(!R(t)||!R(e.s.charCodeAt(++e.p)))return Pl(e,--e.p,t,0,n);if(e.s.charCodeAt(e.p+=4)===58&&(e.p+=3),e.s.charCodeAt(e.p)===46)for(;R(e.s.charCodeAt(++e.p)););return zl(e,e.s.slice(r,e.p),4,!1,r)}function zl(e,t,n,r,i,a){if(e.ld){let a=new jl(t,n,r);return a.isValid()||L.x(`invalid date`,e,i),a}try{switch(a&&(t+=a),n){case 1:return Temporal.ZonedDateTime.from(t);case 2:return Temporal.PlainDateTime.from(t);case 3:return Temporal.PlainDate.from(t);case 4:return Temporal.PlainTime.from(t)}}catch(t){L.x(t instanceof Error?t.message:``+t,e,i)}}
231
231
  /*!
232
232
  * Copyright (c) Squirrel Chat et al., All rights reserved.
233
233
  * SPDX-License-Identifier: BSD-3-Clause
@@ -255,7 +255,7 @@ function I(e,t=10){return t===16?e>47&&e<58||e>64&&e<71||e>96&&e<103:e>47&&e<48+
255
255
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
256
256
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
257
257
  */
258
- function Hl(e){for(;e.p<e.s.length;e.p++){let t=e.s.charCodeAt(e.p);if(t===10)break;if(t===13&&e.s.charCodeAt(e.p+1)===10){e.p++;break}(t<32&&t!==9||t===127)&&F.x(`control characters are not allowed in comments`,e)}}function Ul(e,t,n){let r;for(;e.p<e.s.length;){for(;e.p<e.s.length&&((r=e.s.charCodeAt(e.p))===32||r===9||!t&&(r===10||r===13&&e.s.charCodeAt(e.p+1)===10));)e.p++;if(n||r!==35)break;Hl(e)}}
258
+ function Bl(e){for(;e.p<e.s.length;e.p++){let t=e.s.charCodeAt(e.p);if(t===10)break;if(t===13&&e.s.charCodeAt(e.p+1)===10){e.p++;break}(t<32&&t!==9||t===127)&&L.x(`control characters are not allowed in comments`,e)}}function Vl(e,t,n){let r;for(;e.p<e.s.length;){for(;e.p<e.s.length&&((r=e.s.charCodeAt(e.p))===32||r===9||!t&&(r===10||r===13&&e.s.charCodeAt(e.p+1)===10));)e.p++;if(n||r!==35)break;Bl(e)}}
259
259
  /*!
260
260
  * Copyright (c) Squirrel Chat et al., All rights reserved.
261
261
  * SPDX-License-Identifier: BSD-3-Clause
@@ -283,7 +283,7 @@ function Hl(e){for(;e.p<e.s.length;e.p++){let t=e.s.charCodeAt(e.p);if(t===10)br
283
283
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
284
284
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
285
285
  */
286
- function Wl(e,t=61){let n,r=0,i=[],a,o=e.s.charCodeAt(n=e.p);do if(o===t)return r||F.x(`unexpected end of key`,e),r===1&&i.push(e.s.slice(a,e.p)),e.p++,i;else o===46?(r||F.x(`illegal empty bare key`,e),r===1&&i.push(e.s.slice(a,e.p)),r=0):!r&&(o===34||o===39)?(o===e.s.charCodeAt(e.p+1)&&o===e.s.charCodeAt(e.p+2)&&F.x(`illegal quoted key: multiline strings are not allowed`,e),i.push(jl(e)),r=2,e.p--):o===32||o===9?r===1&&(i.push(e.s.slice(a,e.p)),r=2):r===2||o<48&&o!==45||o>57&&o<65||o>90&&o<97&&o!==95||o>122?F.x(`illegal character in key`,e):r||(r=1,a=e.p);while(o=e.s.charCodeAt(++e.p));F.x(`incomplete key-value: cannot find end of key`,e,n)}function Gl(e){let t=e.p++,n=Object.create(null),r=/* @__PURE__ */ new Set,i;for(;e.p<e.s.length;){if(Ul(e),(i=e.s.charCodeAt(e.p))===125)return e.p++,n;let t,a=n,o=!1,s=e.p,c=Wl(e);for(let n=0;n<c.length;n++){n&&(a=o?a[t]:a[t]=Object.create(null)),t=c[n],(o=Object.hasOwn(a,t))&&(typeof a[t]!=`object`||r.has(a[t]))&&F.x(`trying to redefine an already defined value`,e,s);let i=t===`__proto__`;if(e.uk&&(i||t===`constructor`)){a=e.uk!==1&&F.x(`document contains an unsafe property`,e,s);break}!o&&i&&Object.defineProperty(a,t,{enumerable:!0,configurable:!0,writable:!0})}o&&F.x(`trying to redefine an already defined value`,e,s),Ul(e,!0,!0);let l=Fl(e,125);if(a&&typeof(a[t]=l)==`object`&&r.add(l),Ul(e),(i=e.s.charCodeAt(e.p++))===125)return n;i!==44&&F.x(`expected comma or end of structure`,e,e.p-1)}F.x(`unfinished table`,e,t)}function Kl(e){let t=e.p++,n=[],r;for(;e.p<e.s.length;){if(Ul(e),(r=e.s.charCodeAt(e.p))===93)return e.p++,n;if(n.push(Fl(e,93)),Ul(e),(r=e.s.charCodeAt(e.p++))===93)return n;r!==44&&F.x(`expected comma or end of structure`,e,e.p-1)}F.x(`unfinished array`,e,t)}
286
+ function Hl(e,t=61){let n,r=0,i=[],a,o=e.s.charCodeAt(n=e.p);do if(o===t)return r||L.x(`unexpected end of key`,e),r===1&&i.push(e.s.slice(a,e.p)),e.p++,i;else o===46?(r||L.x(`illegal empty bare key`,e),r===1&&i.push(e.s.slice(a,e.p)),r=0):!r&&(o===34||o===39)?(o===e.s.charCodeAt(e.p+1)&&o===e.s.charCodeAt(e.p+2)&&L.x(`illegal quoted key: multiline strings are not allowed`,e),i.push(kl(e)),r=2,e.p--):o===32||o===9?r===1&&(i.push(e.s.slice(a,e.p)),r=2):r===2||o<48&&o!==45||o>57&&o<65||o>90&&o<97&&o!==95||o>122?L.x(`illegal character in key`,e):r||(r=1,a=e.p);while(o=e.s.charCodeAt(++e.p));L.x(`incomplete key-value: cannot find end of key`,e,n)}function Ul(e){let t=e.p++,n=Object.create(null),r=/* @__PURE__ */ new Set,i;for(;e.p<e.s.length;){if(Vl(e),(i=e.s.charCodeAt(e.p))===125)return e.p++,n;let t,a=n,o=!1,s=e.p,c=Hl(e);for(let n=0;n<c.length;n++){n&&(a=o?a[t]:a[t]=Object.create(null)),t=c[n],(o=Object.hasOwn(a,t))&&(typeof a[t]!=`object`||r.has(a[t]))&&L.x(`trying to redefine an already defined value`,e,s);let i=t===`__proto__`;if(e.uk&&(i||t===`constructor`)){a=e.uk!==1&&L.x(`document contains an unsafe property`,e,s);break}!o&&i&&Object.defineProperty(a,t,{enumerable:!0,configurable:!0,writable:!0})}o&&L.x(`trying to redefine an already defined value`,e,s),Vl(e,!0,!0);let l=Nl(e,125);if(a&&typeof(a[t]=l)==`object`&&r.add(l),Vl(e),(i=e.s.charCodeAt(e.p++))===125)return n;i!==44&&L.x(`expected comma or end of structure`,e,e.p-1)}L.x(`unfinished table`,e,t)}function Wl(e){let t=e.p++,n=[],r;for(;e.p<e.s.length;){if(Vl(e),(r=e.s.charCodeAt(e.p))===93)return e.p++,n;if(n.push(Nl(e,93)),Vl(e),(r=e.s.charCodeAt(e.p++))===93)return n;r!==44&&L.x(`expected comma or end of structure`,e,e.p-1)}L.x(`unfinished array`,e,t)}
287
287
  /*!
288
288
  * Copyright (c) Squirrel Chat et al., All rights reserved.
289
289
  * SPDX-License-Identifier: BSD-3-Clause
@@ -311,7 +311,7 @@ function Wl(e,t=61){let n,r=0,i=[],a,o=e.s.charCodeAt(n=e.p);do if(o===t)return
311
311
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
312
312
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
313
313
  */
314
- function ql(e,t,n,r,i){let a=n,o=r,s,c=!1,l;for(let n=0;n<t.length;n++){if(n){if(a=c?a[s]:a[s]=Object.create(null),o=(l=o[s]).c,i===0&&(l.t===1||l.t===2))return null;if(l.t===2){let e=a.length-1;a=a[e],o=o[e].c}}if(s=t[n],(c=Object.hasOwn(a,s))&&o[s]?.t===0&&o[s]?.d)return null;if(!c){let r=s===`__proto__`;if(e.uk&&(r||s===`constructor`))return!1;r&&(Object.defineProperty(a,s,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(o,s,{enumerable:!0,configurable:!0,writable:!0})),o[s]={t:n<t.length-1&&i===2?3:i,d:!1,i:0,c:Object.create(null)}}}if(l=o[s],l.t!==i&&(i!==1||l.t!==3)||(i===2&&(l.d||(l.d=!0,a[s]=[]),a[s].push(a=Object.create(null)),l.c[l.i++]=l={t:1,d:!1,i:0,c:Object.create(null)}),l.d))return null;if(l.d=!0,i===1)a=c?a[s]:a[s]=Object.create(null);else if(i===0&&c)return null;return[s,a,l.c]}function Jl(e,t,n){(t===null||e.uk===2)&&F.x(t===null?`trying to redefine an already defined table or value`:`document contains an unsafe property`,e,n)}function Yl(e,t={}){let n={s:e,p:0,d:t.maxDepth??1e3,bi:t.integersAsBigInt??!1,ld:t.useLegacyDate??!0,uk:t.unsafeKeyBehaviour===`throw`?2:+(t.unsafeKeyBehaviour===`drop`)},r=Object.create(null),i=Object.create(null),a,o=!1,s=r,c=i;for(e.charCodeAt(0)===65279&&n.p++,Ul(n);n.p<e.length;){if(e.charCodeAt(n.p)===91){let t=e.charCodeAt(++n.p)===91;a=n.p+=+t,o=!1;let l=Wl(n,93);t&&(e.charCodeAt(n.p)!==93&&F.x(`expected end of table array declaration`,n),n.p++);let u=ql(n,l,r,i,t?2:1);u?(c=u[2],s=u[1]):(Jl(n,u,a),o=!0)}else{a=n.p;let e=ql(n,Wl(n),s,c,0);!e&&!o&&Jl(n,e,a),Ul(n,!0,!0);let t=Fl(n,void 0);e&&!o&&(e[1][e[0]]=t)}Ul(n,!0),n.p<e.length&&(a=e.charCodeAt(n.p))!==10&&(a!==13||e.charCodeAt(n.p+1)!==10)&&F.x(`each key-value declaration must be followed by an end-of-line`,n),Ul(n)}return r}
314
+ function Gl(e,t,n,r,i){let a=n,o=r,s,c=!1,l;for(let n=0;n<t.length;n++){if(n){if(a=c?a[s]:a[s]=Object.create(null),o=(l=o[s]).c,i===0&&(l.t===1||l.t===2))return null;if(l.t===2){let e=a.length-1;a=a[e],o=o[e].c}}if(s=t[n],(c=Object.hasOwn(a,s))&&o[s]?.t===0&&o[s]?.d)return null;if(!c){let r=s===`__proto__`;if(e.uk&&(r||s===`constructor`))return!1;r&&(Object.defineProperty(a,s,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(o,s,{enumerable:!0,configurable:!0,writable:!0})),o[s]={t:n<t.length-1&&i===2?3:i,d:!1,i:0,c:Object.create(null)}}}if(l=o[s],l.t!==i&&(i!==1||l.t!==3)||(i===2&&(l.d||(l.d=!0,a[s]=[]),a[s].push(a=Object.create(null)),l.c[l.i++]=l={t:1,d:!1,i:0,c:Object.create(null)}),l.d))return null;if(l.d=!0,i===1)a=c?a[s]:a[s]=Object.create(null);else if(i===0&&c)return null;return[s,a,l.c]}function Kl(e,t,n){(t===null||e.uk===2)&&L.x(t===null?`trying to redefine an already defined table or value`:`document contains an unsafe property`,e,n)}function ql(e,t={}){let n={s:e,p:0,d:t.maxDepth??1e3,bi:t.integersAsBigInt??!1,ld:t.useLegacyDate??!0,uk:t.unsafeKeyBehaviour===`throw`?2:+(t.unsafeKeyBehaviour===`drop`)},r=Object.create(null),i=Object.create(null),a,o=!1,s=r,c=i;for(e.charCodeAt(0)===65279&&n.p++,Vl(n);n.p<e.length;){if(e.charCodeAt(n.p)===91){let t=e.charCodeAt(++n.p)===91;a=n.p+=+t,o=!1;let l=Hl(n,93);t&&(e.charCodeAt(n.p)!==93&&L.x(`expected end of table array declaration`,n),n.p++);let u=Gl(n,l,r,i,t?2:1);u?(c=u[2],s=u[1]):(Kl(n,u,a),o=!0)}else{a=n.p;let e=Gl(n,Hl(n),s,c,0);!e&&!o&&Kl(n,e,a),Vl(n,!0,!0);let t=Nl(n,void 0);e&&!o&&(e[1][e[0]]=t)}Vl(n,!0),n.p<e.length&&(a=e.charCodeAt(n.p))!==10&&(a!==13||e.charCodeAt(n.p+1)!==10)&&L.x(`each key-value declaration must be followed by an end-of-line`,n),Vl(n)}return r}
315
315
  /*!
316
316
  * Copyright (c) Squirrel Chat et al., All rights reserved.
317
317
  * SPDX-License-Identifier: BSD-3-Clause
@@ -339,11 +339,11 @@ function ql(e,t,n,r,i){let a=n,o=r,s,c=!1,l;for(let n=0;n<t.length;n++){if(n){if
339
339
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
340
340
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
341
341
  */
342
- let Xl=/^[a-z0-9-_]+$/i,Zl=!!``.isWellFormed;function Ql(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(typeof e.getUTCDate==`function`&&e instanceof Date)return`date`;if(globalThis.Temporal){if(e.until){if(e instanceof Temporal.ZonedDateTime)return`temporal/tz+uc`;if(e instanceof Temporal.PlainDateTime||e instanceof Temporal.PlainDate)return`temporal/uc`;if(e instanceof Temporal.PlainTime||e instanceof Temporal.Instant)return`temporal`;if(e instanceof Temporal.PlainYearMonth)return`temporal/x`}else if(e.toPlainDate&&e instanceof Temporal.PlainMonthDay||e.negated&&e instanceof Temporal.Duration)return`temporal/x`}}return t}function $l(e){for(let t=0;t<e.length;t++)if(Ql(e[t])!==`object`)return!1;return e.length!=0}function eu(e){return JSON.stringify(e).replaceAll(``,`\\u007f`)}function tu(e){return eu(Zl?e.toWellFormed():e)}function nu(e){if(Xl.test(e))return e;if(Zl&&!e.isWellFormed())throw RangeError(`key contains illegal lone surrogates`);return eu(e)}function ru(e,t,n,r,i){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);switch(t){case`number`:if(isNaN(e))return`nan`;if(e===1/0)return`inf`;if(e===-1/0)return`-inf`;if(Number.isInteger(e)&&(r||!Number.isSafeInteger(e)))return e.toFixed(1);case`bigint`:case`boolean`:case`temporal`:return e.toString();case`string`:return tu(e);case`date`:if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString();case`object`:return iu(e,n,r,i);case`array`:return au(e,n,r,i);case`temporal/tz+uc`:if(i){let t=e.timeZoneId,n=t.charCodeAt(0);if(n!==43&&n!==45&&(n!==85&&n!==71&&n!==90&&n!==69||t!==`UTC`&&t!==`UCT`&&t!==`Universal`&&t!==`Zulu`&&!t.startsWith(`GMT`)&&t!==`Greenwich`&&!t.startsWith(`Etc/`)))throw TypeError(`Temporal objects with an IANA timezone are not allowed in Temporal strict mode`)}case`temporal/uc`:if(i&&e.calendarId!==`iso8601`)throw TypeError(`Temporal objects with a non-default calendar are not allowed in Temporal strict mode`);return e.toString({calendarName:`never`,timeZoneName:`never`});case`temporal/x`:throw TypeError(`Unsupported `+e[Symbol.toStringTag])}}function iu(e,t,n,r){let i=Object.keys(e);if(i.length===0)return`{}`;let a=`{ `;for(let o=0;o<i.length;o++){let s=i[o];o&&(a+=`, `),a+=nu(s)+` = `+ru(e[s],Ql(e[s]),t-1,n,r)}return a+` }`}function au(e,t,n,r){if(e.length===0)return`[]`;let i=`[ `;for(let a=0;a<e.length;a++){if(a&&(i+=`, `),e[a]===null||e[a]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);i+=ru(e[a],Ql(e[a]),t-1,n,r)}return i+` ]`}function ou(e,t,n,r,i){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``;for(let o=0;o<e.length;o++)a+=`${a&&`
343
- `}[[${t}]]\n`,a+=su(0,e[o],t,n,r,i);return a}function su(e,t,n,r,i,a){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let o=``,s=``,c=Object.keys(t);for(let e=0;e<c.length;e++){let l=c[e];if(t[l]!==null&&t[l]!==void 0){let e=Ql(t[l]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let c=nu(l);if(e===`array`&&$l(t[l]))s+=(s&&`
344
- `)+ou(t[l],n?`${n}.${c}`:c,r-1,i,a);else if(e===`object`){let e=n?`${n}.${c}`:c;s+=(s&&`
345
- `)+su(e,t[l],e,r-1,i,a)}else o+=c,o+=` = `,o+=ru(t[l],e,r,i,a),o+=`
346
- `}}return e&&(o||!s)&&(o=o?`[${e}]\n${o}`:`[${e}]`),o&&s?`${o}\n${s}`:o||s}function cu(e,{maxDepth:t=1e3,numbersAsFloat:n=!1,strictTemporal:r=!1}={}){if(Ql(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let i=su(0,e,``,t,n,r);return i[i.length-1]===`
342
+ let Jl=/^[a-z0-9-_]+$/i,Yl=!!``.isWellFormed;function Xl(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(typeof e.getUTCDate==`function`&&e instanceof Date)return`date`;if(globalThis.Temporal){if(e.until){if(e instanceof Temporal.ZonedDateTime)return`temporal/tz+uc`;if(e instanceof Temporal.PlainDateTime||e instanceof Temporal.PlainDate)return`temporal/uc`;if(e instanceof Temporal.PlainTime||e instanceof Temporal.Instant)return`temporal`;if(e instanceof Temporal.PlainYearMonth)return`temporal/x`}else if(e.toPlainDate&&e instanceof Temporal.PlainMonthDay||e.negated&&e instanceof Temporal.Duration)return`temporal/x`}}return t}function Zl(e){for(let t=0;t<e.length;t++)if(Xl(e[t])!==`object`)return!1;return e.length!=0}function Ql(e){return JSON.stringify(e).replaceAll(``,`\\u007f`)}function $l(e){return Ql(Yl?e.toWellFormed():e)}function eu(e){if(Jl.test(e))return e;if(Yl&&!e.isWellFormed())throw RangeError(`key contains illegal lone surrogates`);return Ql(e)}function tu(e,t,n,r,i){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);switch(t){case`number`:if(isNaN(e))return`nan`;if(e===1/0)return`inf`;if(e===-1/0)return`-inf`;if(Number.isInteger(e)&&(r||!Number.isSafeInteger(e)))return e.toFixed(1);case`bigint`:case`boolean`:case`temporal`:return e.toString();case`string`:return $l(e);case`date`:if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString();case`object`:return nu(e,n,r,i);case`array`:return ru(e,n,r,i);case`temporal/tz+uc`:if(i){let t=e.timeZoneId,n=t.charCodeAt(0);if(n!==43&&n!==45&&(n!==85&&n!==71&&n!==90&&n!==69||t!==`UTC`&&t!==`UCT`&&t!==`Universal`&&t!==`Zulu`&&!t.startsWith(`GMT`)&&t!==`Greenwich`&&!t.startsWith(`Etc/`)))throw TypeError(`Temporal objects with an IANA timezone are not allowed in Temporal strict mode`)}case`temporal/uc`:if(i&&e.calendarId!==`iso8601`)throw TypeError(`Temporal objects with a non-default calendar are not allowed in Temporal strict mode`);return e.toString({calendarName:`never`,timeZoneName:`never`});case`temporal/x`:throw TypeError(`Unsupported `+e[Symbol.toStringTag])}}function nu(e,t,n,r){let i=Object.keys(e);if(i.length===0)return`{}`;let a=`{ `;for(let o=0;o<i.length;o++){let s=i[o];o&&(a+=`, `),a+=eu(s)+` = `+tu(e[s],Xl(e[s]),t-1,n,r)}return a+` }`}function ru(e,t,n,r){if(e.length===0)return`[]`;let i=`[ `;for(let a=0;a<e.length;a++){if(a&&(i+=`, `),e[a]===null||e[a]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);i+=tu(e[a],Xl(e[a]),t-1,n,r)}return i+` ]`}function iu(e,t,n,r,i){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``;for(let o=0;o<e.length;o++)a+=`${a&&`
343
+ `}[[${t}]]\n`,a+=au(0,e[o],t,n,r,i);return a}function au(e,t,n,r,i,a){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let o=``,s=``,c=Object.keys(t);for(let e=0;e<c.length;e++){let l=c[e];if(t[l]!==null&&t[l]!==void 0){let e=Xl(t[l]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let c=eu(l);if(e===`array`&&Zl(t[l]))s+=(s&&`
344
+ `)+iu(t[l],n?`${n}.${c}`:c,r-1,i,a);else if(e===`object`){let e=n?`${n}.${c}`:c;s+=(s&&`
345
+ `)+au(e,t[l],e,r-1,i,a)}else o+=c,o+=` = `,o+=tu(t[l],e,r,i,a),o+=`
346
+ `}}return e&&(o||!s)&&(o=o?`[${e}]\n${o}`:`[${e}]`),o&&s?`${o}\n${s}`:o||s}function ou(e,{maxDepth:t=1e3,numbersAsFloat:n=!1,strictTemporal:r=!1}={}){if(Xl(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let i=au(0,e,``,t,n,r);return i[i.length-1]===`
347
347
  `?i:i+`
348
348
  `}
349
349
  /*!
@@ -373,7 +373,7 @@ let Xl=/^[a-z0-9-_]+$/i,Zl=!!``.isWellFormed;function Ql(e){let t=typeof e;if(t=
373
373
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
374
374
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
375
375
  */
376
- const lu=g.O_NOFOLLOW??0,uu=e=>{if(typeof e==`object`&&e&&`code`in e){let{code:t}=e;if(typeof t==`string`)return t}},L=e=>uu(e)===`ENOENT`,du=g.O_WRONLY|g.O_CREAT|g.O_EXCL|lu,fu=async(e,t,n=384)=>{await a(_(e),{mode:448,recursive:!0});let r=`${e}.tmp-${pe()}`;await h(r,t,{encoding:`utf8`,flag:du,mode:n}),await u(r,e)},pu={CONFLICT:5,NOT_FOUND:4,OK:0,UNEXPECTED:1,USAGE:2,VALIDATION:3};var R=class extends Error{code;exitCode;reason;constructor(e,t,n,r){super(n,r),this.code=t,this.exitCode=e,this.name=`RefsError`,r?.reason!==void 0&&(this.reason=r.reason)}};const mu=e=>new R(pu.CONFLICT,`conflict`,e),z=(e,t)=>new R(pu.NOT_FOUND,`not_found`,e,t===void 0?void 0:{reason:t}),B=e=>new R(pu.USAGE,`usage`,e),V=e=>new R(pu.VALIDATION,`validation`,e),hu=(e,t,n)=>n&&t!==void 0?`${e}\n${t}`:e,gu=(e,t)=>e instanceof R?{code:e.code,exitCode:e.exitCode,message:hu(e.message,e.stack,t.verbose),...e.reason===void 0?{}:{reason:e.reason}}:e instanceof Error?{code:`unexpected`,exitCode:pu.UNEXPECTED,message:hu(e.message,e.stack,t.verbose)}:{code:`unexpected`,exitCode:pu.UNEXPECTED,message:String(e)},_u=e=>{let t=`line ${String(e.line)}, column ${String(e.column)}`,{codeblock:n,message:r}=e;return n!==``&&!r.endsWith(n)?`could not be parsed (${t})`:`${r.slice(0,r.length-n.length).trim()} (${t})`},vu=e=>typeof e==`object`&&!!e&&!Array.isArray(e),yu=(e,t)=>vu(e)?e:t,bu=async e=>{try{return await s(e.configPath,`utf8`)}catch(e){throw L(e)?z(`no config found — run: refs init`):e}},xu=(e,t)=>{try{return Yl(e)}catch(e){throw e instanceof F?V(`invalid TOML in ${t}: ${_u(e)}`):e}},Su=e=>typeof e==`number`&&Number.isInteger(e)&&e>=1,Cu=e=>{let{meta:t}=e;if(!vu(t))return;let n=t.schema_version;if(Su(n))return n},wu=(e,t)=>{let n=Cu(e);if(n===void 0)throw V(`config schema version is missing or invalid in ${t} — run: refs migrate`);if(n>1)throw V(`config schema ${n} is newer than this CLI supports — upgrade refs`);if(n<1)throw V(`config schema ${n} is older than expected 1 — run: refs migrate`)},H=async e=>{let t=await bu(e),n=xu(t,e.configPath);wu(n,e.configPath);let r=Ol.safeParse(n);if(!r.success)throw V(w(r.error));return r.data},Tu=(e,t)=>{try{Yl(e)}catch{throw V(`refusing to write a config that could not be read back: ${t}`)}return e},Eu=async(e,t)=>{let n=Ol.safeParse(t);if(!n.success)throw V(w(n.error));let r=Tu(cu(n.data),e.configPath);await fu(e.configPath,r)},Du=async e=>{try{return await p(e),!0}catch(e){if(L(e))return!1;throw e}},Ou=async(e,t)=>await Du(e.configPath)?`noop`:(await fu(e.configPath,`# refs configuration
376
+ const su=te.O_NOFOLLOW??0,cu=e=>{if(typeof e==`object`&&e&&`code`in e){let{code:t}=e;if(typeof t==`string`)return t}},z=e=>cu(e)===`ENOENT`,lu=te.O_WRONLY|te.O_CREAT|te.O_EXCL|su,uu=async(e,t,n=384)=>{await a(_(e),{mode:448,recursive:!0});let r=`${e}.tmp-${pe()}`;await h(r,t,{encoding:`utf8`,flag:lu,mode:n}),await u(r,e)},du={CONFLICT:5,NOT_FOUND:4,OK:0,UNEXPECTED:1,USAGE:2,VALIDATION:3};var fu=class extends Error{code;exitCode;reason;constructor(e,t,n,r){super(n,r),this.code=t,this.exitCode=e,this.name=`RefsError`,r?.reason!==void 0&&(this.reason=r.reason)}};const pu=e=>new fu(du.CONFLICT,`conflict`,e),mu=(e,t)=>new fu(du.NOT_FOUND,`not_found`,e,t===void 0?void 0:{reason:t}),B=e=>new fu(du.USAGE,`usage`,e),V=e=>new fu(du.VALIDATION,`validation`,e),hu=(e,t,n)=>n&&t!==void 0?`${e}\n${t}`:e,gu=(e,t)=>e instanceof fu?{code:e.code,exitCode:e.exitCode,message:hu(e.message,e.stack,t.verbose),...e.reason===void 0?{}:{reason:e.reason}}:e instanceof Error?{code:`unexpected`,exitCode:du.UNEXPECTED,message:hu(e.message,e.stack,t.verbose)}:{code:`unexpected`,exitCode:du.UNEXPECTED,message:String(e)},_u=e=>{let t=`line ${String(e.line)}, column ${String(e.column)}`,{codeblock:n,message:r}=e;return n!==``&&!r.endsWith(n)?`could not be parsed (${t})`:`${r.slice(0,r.length-n.length).trim()} (${t})`},vu=e=>typeof e==`object`&&!!e&&!Array.isArray(e),yu=(e,t)=>vu(e)?e:t,bu=async e=>{try{return await s(e.configPath,`utf8`)}catch(e){throw z(e)?mu(`no config found — run: refs init`):e}},xu=(e,t)=>{try{return ql(e)}catch(e){throw e instanceof L?V(`invalid TOML in ${t}: ${_u(e)}`):e}},Su=e=>typeof e==`number`&&Number.isInteger(e)&&e>=1,Cu=e=>{let{meta:t}=e;if(!vu(t))return;let n=t.schema_version;if(Su(n))return n},wu=(e,t)=>{let n=Cu(e);if(n===void 0)throw V(`config schema version is missing or invalid in ${t} — run: refs migrate`);if(n>1)throw V(`config schema ${n} is newer than this CLI supports — upgrade refs`);if(n<1)throw V(`config schema ${n} is older than expected 1 — run: refs migrate`)},H=async e=>{let t=await bu(e),n=xu(t,e.configPath);wu(n,e.configPath);let r=El.safeParse(n);if(!r.success)throw V(T(r.error));return r.data},Tu=(e,t)=>{try{ql(e)}catch{throw V(`refusing to write a config that could not be read back: ${t}`)}return e},Eu=async(e,t)=>{let n=El.safeParse(t);if(!n.success)throw V(T(n.error));let r=Tu(ou(n.data),e.configPath);await uu(e.configPath,r)},Du=async e=>{try{return await p(e),!0}catch(e){if(z(e))return!1;throw e}},Ou=async(e,t)=>await Du(e.configPath)?`noop`:(await uu(e.configPath,`# refs configuration
377
377
  #
378
378
  # Every global setting under [settings] can also be set per-ref: add the same
379
379
  # key directly inside a [refs."host/owner/repo"] table to override it just for
@@ -404,90 +404,92 @@ sync_ttl = "1h"
404
404
  # tag_format = "v{version}"
405
405
  # # Per-ref overrides of [settings] go in the same table, e.g.:
406
406
  # # clone_mode = "full"
407
- `.replaceAll(`{{CLI_VERSION}}`,t)),`seeded`),U=e=>{let t=le(e.REFS_HOME??v(me(),`.kaisers-io`,`refs`));return{cacheDir:v(t,`cache`),configPath:v(t,`config.toml`),hooksDir:v(t,`hooks`),locksDir:v(t,`locks`),root:t,sourcesDir:v(t,`sources`),statePath:v(t,`state.json`),updateCachePath:v(t,`cache`,`update-check.json`)}},ku=(e,t)=>v(e.sourcesDir,...t.split(`/`)),Au=e=>`${e.configPath}.bak`,ju=e=>{let t=[],n=e;for(;!te(n);){let e=_(n);if(e===n)break;t.unshift(ie(n)),n=e}return{ancestor:n,missing:t}},Mu=e=>{let{ancestor:t,missing:n}=ju(e),r=ne(t);return n.length===0?r:v(r,...n)},Nu=(e,t,n)=>{let r=Mu(e),i=Mu(t),a=ce(r,i),o=a===`..`||a.startsWith(`..`+ue);if(a===``||o||ae(a))throw V(`path escapes ${n} (containment violation): ${t}`)},Pu=(e,t)=>{Nu(e.sourcesDir,t,`sources directory`)},Fu=(e,t)=>{let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];t===void 0?n[e]=r:vu(t)&&vu(r)&&(n[e]=Fu(t,r))}return n},Iu={meta:{},refs:{},settings:{}},Lu=async e=>{try{return await bu(e)}catch(e){if(e instanceof R&&e.code===`not_found`)return;throw e}},Ru=e=>{if(e!==void 0&&e>1)throw V(`config schema ${e} is newer than this CLI supports — upgrade refs`)},zu=async(e,t,n)=>{let r=yu(t.meta,{}),i={...t,meta:{...r,cli_version:n}},a=Ol.safeParse(i);if(!a.success){let t=w(a.error);throw V(`config in ${e.configPath} is at the current schema version but does not validate: ${t}`)}r.cli_version!==n&&await fu(e.configPath,cu(i))},Bu=async(e,t,n)=>{await r(e.configPath,Au(e));let i=Fu(t,Iu),a=yu(i.meta,{}),o={...i,meta:{...a,cli_version:n,schema_version:1}},s=Ol.safeParse(o);if(!s.success)throw V(`config in ${e.configPath} is malformed beyond automatic migration (backup preserved at ${Au(e)}): ${w(s.error)}`);await fu(e.configPath,cu(o))},Vu=async(e,t,n)=>{let r=xu(t,e.configPath),i=Cu(r);return Ru(i),i===1?(await zu(e,r,n),`noop`):(await Bu(e,r,n),`migrated`)},Hu=async(e,t)=>{let n=await Lu(e);return n===void 0?(await Ou(e,t),`seeded`):Vu(e,n,t)},Uu=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),Wu=e=>e.code??String(e),Gu=async e=>{try{return await i(e),!0}catch{return!1}},Ku=(e,t)=>{let n=ce(e,t);return n===``||n!==`..`&&!n.startsWith(`..`+ue)&&!ae(n)},qu=async e=>{try{return{real:await l(e)}}catch(e){return{code:Wu(e)}}},W=async(e,t)=>{let n=await qu(e);if(`code`in n)return{code:n.code,kind:`unreadable`};let r=await qu(t);return`code`in r?Uu.has(r.code)?await Gu(t)?{code:r.code,kind:`unreadable`}:{kind:`missing`}:{code:r.code,kind:`unreadable`}:Ku(n.real,r.real)?{kind:`inside`,real:r.real}:{kind:`outside`}},Ju=/* @__PURE__ */ new Set([`/`,ue]),Yu=e=>{let t=oe(e).root.length,n=e.length;for(;n>t&&Ju.has(e.charAt(n-1));)--n;return e.slice(0,n)},Xu=async(e,t)=>{let n=Yu(t);for(let t=await W(e,n);;){if(t.kind!==`missing`||_(n)===n)return t.kind===`inside`;n=_(n),t=await W(e,n)}},Zu=/^\s*-\s+["']?(?<pattern>[^"'#]+)["']?/u,Qu=/^packages:\s*(?:#.*)?$/u,$u=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ed=e=>{if(Array.isArray(e))return e.filter(e=>typeof e==`string`);if(!$u(e))return[];let{packages:t}=e;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]},td=Symbol(`end-of-section`),nd=e=>{let t=e.trim();if(t&&!t.startsWith(`-`)&&t.includes(`:`)&&!Qu.test(e))return td;if(!t.startsWith(`-`))return;let n=Zu.exec(e)?.groups?.pattern?.trim();if(n)return n},rd=e=>{let t=[];for(let n of e){let e=nd(n);if(e===td)break;e!==void 0&&t.push(e)}return t},id=e=>{let t=e.findIndex(e=>Qu.test(e));return t===-1?[]:rd(e.slice(t+1))},ad=e=>{let{name:t}=e;if(typeof t==`string`)return t},od=e=>{let{version:t}=e;return typeof t==`string`?t:void 0},sd=async(e,t)=>{let n=await W(e,t);if(n.kind===`missing`)return{ok:!0};if(n.kind!==`inside`)return{ok:!1};try{return{content:await s(n.real,`utf8`),ok:!0}}catch{return{ok:!1}}},cd=async(e,t)=>{let n=await sd(e,t);return n.ok?n.content===void 0?{ok:!0,patterns:[]}:ld(n.content):{ok:!1,patterns:[]}},ld=e=>{try{let t=JSON.parse(e);return{ok:!0,patterns:ed(t.workspaces)}}catch{return{ok:!1,patterns:[]}}},ud=/^packages:/mu,dd=(e,t)=>t.length===0&&ud.test(e),fd=async(e,t)=>{let n=await sd(e,t);if(!n.ok)return{ok:!1,patterns:[]};if(n.content===void 0)return{ok:!0,patterns:[]};let r=id(n.content.split(`
407
+ `.replaceAll(`{{CLI_VERSION}}`,t)),`seeded`),U=e=>{let t=le(e.REFS_HOME??v(me(),`.kaisers-io`,`refs`));return{cacheDir:v(t,`cache`),configPath:v(t,`config.toml`),hooksDir:v(t,`hooks`),locksDir:v(t,`locks`),root:t,sourcesDir:v(t,`sources`),statePath:v(t,`state.json`),updateCachePath:v(t,`cache`,`update-check.json`)}},ku=(e,t)=>v(e.sourcesDir,...t.split(`/`)),Au=e=>`${e.configPath}.bak`,ju=e=>{let t=[],n=e;for(;!ne(n);){let e=_(n);if(e===n)break;t.unshift(ie(n)),n=e}return{ancestor:n,missing:t}},Mu=e=>{let{ancestor:t,missing:n}=ju(e),r=re(t);return n.length===0?r:v(r,...n)},Nu=(e,t,n)=>{let r=Mu(e),i=Mu(t),a=ce(r,i),o=a===`..`||a.startsWith(`..`+ue);if(a===``||o||ae(a))throw V(`path escapes ${n} (containment violation): ${t}`)},Pu=(e,t)=>{Nu(e.sourcesDir,t,`sources directory`)},Fu=(e,t)=>{let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];t===void 0?n[e]=r:vu(t)&&vu(r)&&(n[e]=Fu(t,r))}return n},Iu={meta:{},refs:{},settings:{}},Lu=async e=>{try{return await bu(e)}catch(e){if(e instanceof fu&&e.code===`not_found`)return;throw e}},Ru=e=>{if(e!==void 0&&e>1)throw V(`config schema ${e} is newer than this CLI supports — upgrade refs`)},zu=async(e,t,n)=>{let r=yu(t.meta,{}),i={...t,meta:{...r,cli_version:n}},a=El.safeParse(i);if(!a.success){let t=T(a.error);throw V(`config in ${e.configPath} is at the current schema version but does not validate: ${t}`)}r.cli_version!==n&&await uu(e.configPath,ou(i))},Bu=async(e,t,n)=>{await r(e.configPath,Au(e));let i=Fu(t,Iu),a=yu(i.meta,{}),o={...i,meta:{...a,cli_version:n,schema_version:1}},s=El.safeParse(o);if(!s.success)throw V(`config in ${e.configPath} is malformed beyond automatic migration (backup preserved at ${Au(e)}): ${T(s.error)}`);await uu(e.configPath,ou(o))},Vu=async(e,t,n)=>{let r=xu(t,e.configPath),i=Cu(r);return Ru(i),i===1?(await zu(e,r,n),`noop`):(await Bu(e,r,n),`migrated`)},Hu=async(e,t)=>{let n=await Lu(e);return n===void 0?(await Ou(e,t),`seeded`):Vu(e,n,t)},Uu=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),Wu=e=>e.code??String(e),Gu=async e=>{try{return await i(e),!0}catch{return!1}},Ku=(e,t)=>{let n=ce(e,t);return n===``||n!==`..`&&!n.startsWith(`..`+ue)&&!ae(n)},qu=async e=>{try{return{real:await l(e)}}catch(e){return{code:Wu(e)}}},W=async(e,t)=>{let n=await qu(e);if(`code`in n)return{code:n.code,kind:`unreadable`};let r=await qu(t);return`code`in r?Uu.has(r.code)?await Gu(t)?{code:r.code,kind:`unreadable`}:{kind:`missing`}:{code:r.code,kind:`unreadable`}:Ku(n.real,r.real)?{kind:`inside`,real:r.real}:{kind:`outside`}},Ju=/* @__PURE__ */ new Set([`/`,ue]),Yu=e=>{let t=oe(e).root.length,n=e.length;for(;n>t&&Ju.has(e.charAt(n-1));)--n;return e.slice(0,n)},Xu=async(e,t)=>{let n=Yu(t);for(let t=await W(e,n);;){if(t.kind!==`missing`||_(n)===n)return t.kind===`inside`;n=_(n),t=await W(e,n)}},Zu=/^\s*-\s+["']?(?<pattern>[^"'#]+)["']?/u,Qu=/^packages:\s*(?:#.*)?$/u,$u=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ed=e=>{if(Array.isArray(e))return e.filter(e=>typeof e==`string`);if(!$u(e))return[];let{packages:t}=e;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]},td=Symbol(`end-of-section`),nd=e=>{let t=e.trim();if(t&&!t.startsWith(`-`)&&t.includes(`:`)&&!Qu.test(e))return td;if(!t.startsWith(`-`))return;let n=Zu.exec(e)?.groups?.pattern?.trim();if(n)return n},rd=e=>{let t=[];for(let n of e){let e=nd(n);if(e===td)break;e!==void 0&&t.push(e)}return t},id=e=>{let t=e.findIndex(e=>Qu.test(e));return t===-1?[]:rd(e.slice(t+1))},ad=e=>{let{name:t}=e;if(typeof t==`string`)return t},od=e=>{let{version:t}=e;return typeof t==`string`?t:void 0},sd=async(e,t)=>{let n=await W(e,t);if(n.kind===`missing`)return{ok:!0};if(n.kind!==`inside`)return{ok:!1};try{return{content:await s(n.real,`utf8`),ok:!0}}catch{return{ok:!1}}},cd=async(e,t)=>{let n=await sd(e,t);return n.ok?n.content===void 0?{ok:!0,patterns:[]}:ld(n.content):{ok:!1,patterns:[]}},ld=e=>{try{let t=JSON.parse(e);return{ok:!0,patterns:ed(t.workspaces)}}catch{return{ok:!1,patterns:[]}}},ud=/^packages:/mu,dd=(e,t)=>t.length===0&&ud.test(e),fd=async(e,t)=>{let n=await sd(e,t);if(!n.ok)return{ok:!1,patterns:[]};if(n.content===void 0)return{ok:!0,patterns:[]};let r=id(n.content.split(`
408
408
  `));return{ok:!0,patterns:r,unparsed:dd(n.content,r)}},pd=async e=>{let[t,n]=await Promise.all([cd(e,v(e,`package.json`)),fd(e,v(e,`pnpm-workspace.yaml`))]),r=[];return t.ok||r.push({file:`package.json`,kind:`workspace_file_unreadable`}),n.ok||r.push({file:`pnpm-workspace.yaml`,kind:`workspace_file_unreadable`}),n.unparsed===!0&&r.push({file:`pnpm-workspace.yaml`,kind:`workspace_declaration_unparsed`}),{diagnostics:r,npm:t.patterns,pnpm:n.patterns}},md=/* @__PURE__ */ new Set;let hd=!1;const gd=()=>{for(let e of md)try{e.kill(`SIGKILL`)}catch{}},_d=[`SIGINT`,`SIGTERM`,`SIGHUP`,`SIGBREAK`],vd=e=>{let t=()=>{gd(),process.removeListener(e,t),process.kill(process.pid,e)};process.on(e,t)},yd=()=>{hd||(hd=!0,_d.forEach(e=>{vd(e)}),process.on(`exit`,gd))},bd=()=>{let e=[],t=0,n=!1;return{finish:()=>({text:Buffer.concat(e).toString(`utf8`),truncated:n}),push:r=>{if(n)return;let i=67108864-t;r.length<=i?(e.push(r),t+=r.length):(i>0&&e.push(r.subarray(0,i)),n=!0)}}},xd=(e,t)=>[e.replace(/\r?\n$/u,``),t].filter(e=>e!==``).join(`
409
409
  `),Sd=(e,t,n)=>{let r=e;return t.truncated&&(r=xd(r,`refs: stdout exceeded 67108864 bytes, truncated`)),n.truncated&&(r=xd(r,`refs: stderr exceeded 67108864 bytes, truncated`)),r},Cd=/^[a-z]:[\\/]/iu,wd=[`-A`,`-o`,`pid=`,`-o`,`ppid=`],Td=e=>{let t=/* @__PURE__ */ new Map;for(let n of e.split(`
410
410
  `)){let e=n.trim().split(/\s+/u).map(Number);if(e.length===2&&e.every(e=>Number.isSafeInteger(e))){let[n=0,r=0]=e;t.set(r,[...t.get(r)??[],n])}}return t},Ed=(e,t)=>{let n=[],r=[t];for(let i=r.shift();i!==void 0;i=r.shift())for(let a of e.get(i)??[])!n.includes(a)&&a!==t&&(n.push(a),r.push(a));return n},Dd=async(e,t)=>{let n=await e(`ps`,wd);if(n.exitCode===0)return Ed(Td(n.stdout),t)},Od=(e,t)=>{try{process.kill(e,t)}catch{}},kd=e=>e!==void 0&&Cd.test(e)?de.join(e,`System32`,`taskkill.exe`):void 0,Ad=async(e,t)=>{let n=kd(e.systemRoot);n===void 0?Od(e.pid,t):await e.exec(n,[`/PID`,String(e.pid),`/T`,`/F`])},jd=async(e,t)=>{if(e.rootAlive()){let n=await Dd(e.exec,e.pid);e.listFailed=e.listFailed===!0||n===void 0;for(let t of n??[])e.seen.add(t);Od(e.pid,t)}for(let n of e.seen)Od(n,t)},Md=async(e,t)=>{e.platform===`win32`?e.rootAlive()&&await Ad(e,t):await jd(e,t)},Nd=[`-A`,`-o`,`pid=`,`-o`,`stat=`],Pd=e=>{try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}},Fd=async e=>{let t=await e(`ps`,Nd);if(t.exitCode!==0)return;let n=/* @__PURE__ */ new Set;for(let e of t.stdout.split(`
411
- `)){let t=e.trim().split(/\s+/u);t.length===2&&t[1]?.startsWith(`Z`)===!0&&n.add(Number(t[0]))}return n},Id=async e=>{if(e.rootAlive())return!0;let t=[...e.seen].filter(e=>Pd(e));if(t.length===0)return!1;let n=await Fd(e.exec);return n===void 0||t.some(e=>!n.has(e))},Ld=async(e,t)=>{let n=Date.now()+t,r=await Id(e);for(;r&&Date.now()<n;)await he(100),r=await Id(e);return!r},Rd=2e3,zd={markedTimedOut:()=>!1,settle:()=>Promise.resolve(!0)},Bd=(e,t)=>({exec:e.exec,pid:t,platform:process.platform,rootAlive:()=>e.child.exitCode===null&&e.child.signalCode===null,seen:/* @__PURE__ */ new Set,systemRoot:process.env.SystemRoot}),Vd=e=>{e.stdout?.destroy(),e.stderr?.destroy()},Hd=async e=>{await Md(e,`SIGTERM`);let t=await Ld(e,Rd);return t||=(await Md(e,`SIGKILL`),await Ld(e,1e3)),t&&e.listFailed!==!0},Ud=e=>{let{child:t}=e;if(e.timeoutMs===void 0||t.pid===void 0)return zd;let n=Bd(e,t.pid),r,i,a=setTimeout(()=>{r=Hd(n),i=setTimeout(()=>{Vd(t)},Rd)},e.timeoutMs);return{markedTimedOut:()=>r!==void 0,settle:async()=>(clearTimeout(a),clearTimeout(i),await r??!0)}},Wd=(e,t)=>t?e:{...e,cleanupUncertain:!0,stderr:xd(e.stderr,`refs: processes the command started may still be running`)},Gd=/* @__PURE__ */ new Set([`--attr-source`,`--config-env`,`--git-dir`,`--namespace`,`--work-tree`,`-C`,`-c`]),Kd=(e,t)=>{let n=0,r=t===void 0?void 0:le(t);for(;e[n]?.startsWith(`-`)===!0;)e[n]===`-C`&&(r=le(r??`.`,e[n+1]??``)),n+=Gd.has(e[n]??``)?2:1;return{...r===void 0?{}:{dir:r},rest:e.slice(n)}},qd=`\0not a regular file`,Jd=g.O_RDONLY|(g.O_NONBLOCK??0),Yd=async e=>{let t=await o(e,Jd).catch(e=>e.code===`ENOENT`);if(typeof t==`boolean`)return t?void 0:qd;try{return(await t.stat()).isFile()?await t.readFile(`latin1`):qd}finally{await t.close()}},Xd=async e=>{try{let t=await Promise.all([...e.keys()].map(e=>Yd(e)));return[...e.values()].every((e,n)=>t[n]===e)}catch{return!1}},Zd=(e,t)=>JSON.stringify([le(e??`.`),Object.entries(t).toSorted(([e],[t])=>e.localeCompare(t))]);var Qd=class{#e=/* @__PURE__ */ new Map;async lookup(e){let t=this.#e.get(e);if(t===void 0||!await Xd(t.snapshots))this.#e.delete(e);else return t}store(e,t){[...t.snapshots.values()].includes(qd)||this.#e.set(e,t)}};const $d=/^hook\.(?<label>.*)\.(?:command|event)$/u,ef=/^include(?:if\..*)?\.path$/u,tf=String.raw`^include(if\..*)?\.path$`,nf=`file:`;var rf=class extends Error{name=`InventoryRefusalError`};const af=e=>{throw new rf(`refs did not start git: refs disables configured hooks by label, and ${e}`)},of=e=>{let t=e.indexOf(`
411
+ `)){let t=e.trim().split(/\s+/u);t.length===2&&t[1]?.startsWith(`Z`)===!0&&n.add(Number(t[0]))}return n},Id=async e=>{if(e.rootAlive())return!0;let t=[...e.seen].filter(e=>Pd(e));if(t.length===0)return!1;let n=await Fd(e.exec);return n===void 0||t.some(e=>!n.has(e))},Ld=async(e,t)=>{let n=Date.now()+t,r=await Id(e);for(;r&&Date.now()<n;)await he(100),r=await Id(e);return!r},Rd=2e3,zd={markedTimedOut:()=>!1,settle:()=>Promise.resolve(!0)},Bd=(e,t)=>({exec:e.exec,pid:t,platform:process.platform,rootAlive:()=>e.child.exitCode===null&&e.child.signalCode===null,seen:/* @__PURE__ */ new Set,systemRoot:process.env.SystemRoot}),Vd=e=>{e.stdout?.destroy(),e.stderr?.destroy()},Hd=async e=>{await Md(e,`SIGTERM`);let t=await Ld(e,Rd);return t||=(await Md(e,`SIGKILL`),await Ld(e,1e3)),t&&e.listFailed!==!0},Ud=e=>{let{child:t}=e;if(e.timeoutMs===void 0||t.pid===void 0)return zd;let n=Bd(e,t.pid),r,i,a=setTimeout(()=>{r=Hd(n),i=setTimeout(()=>{Vd(t)},Rd)},e.timeoutMs);return{markedTimedOut:()=>r!==void 0,settle:async()=>(clearTimeout(a),clearTimeout(i),await r??!0)}},Wd=(e,t)=>t?e:{...e,cleanupUncertain:!0,stderr:xd(e.stderr,`refs: processes the command started may still be running`)},Gd=/* @__PURE__ */ new Set([`--attr-source`,`--config-env`,`--git-dir`,`--namespace`,`--work-tree`,`-C`,`-c`]),Kd=(e,t)=>{let n=0,r=t===void 0?void 0:le(t);for(;e[n]?.startsWith(`-`)===!0;)e[n]===`-C`&&(r=le(r??`.`,e[n+1]??``)),n+=Gd.has(e[n]??``)?2:1;return{...r===void 0?{}:{dir:r},rest:e.slice(n)}},qd=`\0not a regular file`,Jd=te.O_RDONLY|(te.O_NONBLOCK??0),Yd=async e=>{let t=await o(e,Jd).catch(e=>e.code===`ENOENT`);if(typeof t==`boolean`)return t?void 0:qd;try{return(await t.stat()).isFile()?await t.readFile(`latin1`):qd}finally{await t.close()}},Xd=async e=>{try{let t=await Promise.all([...e.keys()].map(e=>Yd(e)));return[...e.values()].every((e,n)=>t[n]===e)}catch{return!1}},Zd=(e,t)=>JSON.stringify([le(e??`.`),Object.entries(t).toSorted(([e],[t])=>e.localeCompare(t))]);var Qd=class{#e=/* @__PURE__ */ new Map;async lookup(e){let t=this.#e.get(e);if(t===void 0||!await Xd(t.snapshots))this.#e.delete(e);else return t}store(e,t){[...t.snapshots.values()].includes(qd)||this.#e.set(e,t)}};const $d=/^hook\.(?<label>.*)\.(?:command|event)$/u,ef=/^include(?:if\..*)?\.path$/u,tf=String.raw`^include(if\..*)?\.path$`,nf=`file:`;var rf=class extends Error{name=`InventoryRefusalError`};const af=e=>{throw new rf(`refs did not start git: refs disables configured hooks by label, and ${e}`)},of=e=>{let t=e.indexOf(`
412
412
  `);return t===-1?{key:e,value:``}:{key:e.slice(0,t),value:e.slice(t+1)}},sf=async(e,t)=>{let n=await e(t),r=n.exitCode===1&&n.stdout===``;return n.exitCode!==0&&!(r&&t.includes(`--get-regexp`))&&af(`reading the configuration failed: ${n.stderr.trim()}`),n.stdoutTruncated===!0&&af(`the configuration listing was cut short`),n.stdout},cf=e=>e.split(`\0`).filter(Boolean),lf=(e,t)=>{let n=$d.exec(t)?.groups?.label;n!==void 0&&(n.includes(`=`)&&af(`the hook label ${JSON.stringify(n)} contains '=', which -c cannot express`),e.labels.add(n))},uf=async e=>{try{return await l(e)}catch{return le(e)}},df=async(e,t)=>{let n=await uf(e);t.some(t=>Ku(t,e)||Ku(t,n))&&af(`the include ${e} lies inside the checkout this command writes`)},ff=async(e,t)=>{let n;try{n=await Yd(t)}catch{af(`the include ${t} cannot be inspected`)}return e.snapshots.has(t)||e.snapshots.set(t,n),n!==void 0},pf=async(e,t)=>{let n=await sf(e,[`config`,`--file`,t,`--no-includes`,`--null`,`--type=path`,`--get-regexp`,tf]);return cf(n).map(e=>of(e).value).map(e=>ae(e)?e:v(_(t),e))},mf=async(e,t)=>{t.direct||(e.includes.push(t.file),await df(t.file,e.roots))},hf=async(e,t)=>{(t.depth>10||e.files.size>=64)&&af(`the include graph is deeper or wider than refs follows`),await mf(e,t);let n=await ff(e,t.file),r=await uf(t.file);return e.files.has(r)||!n?!1:(e.files.add(r),!0)},gf=async(e,t,n)=>{if(!await hf(t,n))return;let r=[`config`,`--file`,n.file,`--no-includes`,`--null`,`--list`];for(let n of cf(await sf(e,r)))lf(t,of(n).key);for(let r of await pf(e,n.file))await gf(e,t,{depth:n.depth+1,direct:!1,file:r})},_f=e=>{let t=e.split(`\0`),n=[];for(let e=0;e+1<t.length;e+=2)
413
413
  /* v8 ignore next -- the loop guard proves both indices are in range */
414
- n.push({origin:t[e]??``,...of(t[e+1]??``)});return n},vf=e=>e.filter(e=>!e.origin.startsWith(nf)&&ef.test(e.key)).map(e=>ae(e.value)?e.value:af(`the include ${JSON.stringify(e.value)} is relative but set outside a file`)),yf=e=>{let{dir:t,rest:n}=Kd(e.args,e.cwd),r=n[0]===`clone`?n.at(-1):void 0;return[...t===void 0?[]:[t],...r===void 0?[]:[le(t??`.`,r)]]},bf=async(e,t,n)=>{let r={files:/* @__PURE__ */ new Set,includes:[],labels:/* @__PURE__ */ new Set,roots:n,snapshots:/* @__PURE__ */ new Map},i=_f(await sf(e,[`config`,`--list`,`--no-includes`,`--null`,`--show-origin`]));for(let e of i)lf(r,e.key);let a=i.filter(e=>e.origin.startsWith(nf)).map(e=>le(t.cwd??`.`,e.origin.slice(5))),o=[...[...new Set(a)].map(e=>({depth:0,direct:!0,file:e})),...vf(i).map(e=>({depth:1,direct:!1,file:e}))];for(let t of o)await gf(e,r,t);return r},xf=async(e,t)=>{let n=yf(t),r=await t.cache?.store.lookup(t.cache.key);if(r!==void 0){for(let e of r.includes)await df(e,n);return r.labels}let i=await bf(e,t,n);return t.cache?.store.store(t.cache.key,i),i.labels},Sf=async(e,t)=>{try{return{args:[...await xf(e,t)].flatMap(e=>[`-c`,`hook.${e}.enabled=false`])}}catch(e){if(e instanceof rf)return{refusal:e.message};throw e}},Cf=/^git version (?<major>\d+)\.(?<minor>\d+)/u,wf={major:2,minor:54},Tf=e=>{let t=Cf.exec(e.trim())?.groups,n=Number(t?.major??0),r=Number(t?.minor??0);return n>wf.major||n===wf.major&&r>=wf.minor},Ef=e=>e.length===1&&e[0]===`--version`,Df=(e,t)=>{if(!Tf(t.version))return Promise.resolve({args:[]});let{GIT_CONFIG:n,...r}=process.env,{cache:i,version:a,...o}=t;return Sf(t=>e(t,r),{...o,...i===void 0?{}:{cache:{key:Zd(t.cwd,r),store:i}}})},Of=[`-c`,`core.fsmonitor=`,...[`post-checkout`,`post-index-change`,`pre-auto-gc`,`reference-transaction`].flatMap(e=>[`-c`,`hook.${e}.enabled=false`])],kf=(e,t)=>e===`git`?[...Of,...t]:t;var Af=class{#e;#t;#n=new Qd;constructor(e){this.#e=(t,n,r)=>e(t,kf(t,n),r)}async run(e,t,n){if(e!==`git`||Ef(t))return this.#e(e,t,n);this.#t??=this.#r();let r=await Df(e=>this.#e(`git`,e,n),{args:t,cache:this.#n,version:await this.#t,...n?.cwd===void 0?{}:{cwd:n.cwd}});return`refusal`in r?{exitCode:1,stderr:r.refusal,stdout:``}:this.#e(e,[...r.args,...t],n)}async#r(){return(await this.#e(`git`,[`--version`])).stdout}};const jf=e=>e===`win32`?de:se,Mf=(e,t)=>{let n=Object.keys(e).find(e=>t===`win32`?e.toUpperCase()===`PATH`:e===`PATH`);return n===void 0?``:e[n]??``},Nf=e=>e.replace(/^["'](?<inner>.*)["']$/su,`$<inner>`),Pf=(e,t)=>{let n=jf(t);return Mf(e,t).split(n.delimiter).map(e=>t===`win32`?Nf(e):e).filter(e=>e.length>0&&n.isAbsolute(e)).filter(e=>t!==`win32`||/^(?:[a-z]:[\\/]|[\\/]{2})/iu.test(e))},Ff=(e,t)=>{if(t!==`win32`)return[e];let n=[`${e}.com`,`${e}.exe`];return de.extname(e)===``?n:[e,...n]},If=async(t,n)=>{try{return(await p(t)).isFile()?(await e(t,n===`win32`?g.F_OK:g.X_OK),!0):!1}catch{return!1}},Lf=(e,t)=>t===`win32`?/[\\/:]/u.test(e):e.includes(`/`),Rf=async(e,t,n)=>{if(Lf(e,n))return e;let r=jf(n),i=Pf(t,n).flatMap(t=>Ff(e,n).map(e=>r.join(t,e)));return i[(await Promise.all(i.map(e=>If(e,n)))).indexOf(!0)]},zf=/* @__PURE__ */ new Map,Bf=(e,t,n=process.platform)=>{let r=[n,e,Mf(t,n)].join(`\0`),i=zf.get(r)??Rf(e,t,n);return zf.set(r,i),i},Vf=/* @__PURE__ */ new Set([`GIT_ALTERNATE_OBJECT_DIRECTORIES`,`GIT_COMMON_DIR`,`GIT_CONFIG`,`GIT_DIR`,`GIT_GRAFT_FILE`,`GIT_IMPLICIT_WORK_TREE`,`GIT_INDEX_FILE`,`GIT_INTERNAL_SUPER_PREFIX`,`GIT_NO_REPLACE_OBJECTS`,`GIT_OBJECT_DIRECTORY`,`GIT_PREFIX`,`GIT_REPLACE_REF_BASE`,`GIT_SHALLOW_FILE`,`GIT_WORK_TREE`]),Hf=(e,t)=>Vf.has(t===`win32`?e.toUpperCase():e),Uf=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!Hf(e,t))),Wf=`GIT_TERMINAL_PROMPT`,Gf=(e,t)=>t===`win32`?Object.keys(e).some(e=>e.toUpperCase()===Wf):e[Wf]!==void 0,Kf=(e,t=process.platform)=>Gf(e,t)?e:{...e,[Wf]:`0`},qf=(e,t)=>Uf(Kf(e),t),Jf=e=>e===void 0?{}:{cwd:e},Yf=(e,t)=>xd(e,`refs: command timed out after ${String(t)}ms`),Xf=(e,t)=>({exitCode:124,stderr:Yf(e,t),stdout:``,timedOut:!0}),Zf=(e,t)=>{let n=ye(e.file??e.cmd,e.args,{...Jf(e.cwd),env:e.env,shell:!1,stdio:[`ignore`,`pipe`,`pipe`]});md.add(n);let r=bd(),i=bd();return n.stdout.on(`data`,e=>{r.push(e)}),n.stderr.on(`data`,e=>{i.push(e)}),{child:n,stderrCollector:i,stdoutCollector:r,timeout:Ud({child:n,exec:t,timeoutMs:e.timeoutMs})}},Qf=(e,t)=>{try{return Zf(e,t)}catch(e){return{exitCode:127,stderr:tp(e),stdout:``}}},$f=async(e,t)=>{let n=await Bf(e.cmd,e.env);return n===void 0?{exitCode:127,stderr:`spawn ${e.cmd} ENOENT: not in an absolute PATH directory (refs never runs a program from the working directory)`,stdout:``}:Qf({...e,file:n},t)},ep=e=>!(`child`in e),tp=e=>e instanceof Error?e.message:String(e),np=async e=>{try{let[t]=await _e(e,`close`);return{code:t}}catch(e){return{code:null,errorMessage:tp(e)}}},rp=e=>e===null?1:e,ip=e=>e.stdoutTruncated===!0,ap=(e,t)=>t.truncated?{...e,stdoutTruncated:!0}:e,op=e=>e.timedOut?ap(Wd(Xf(e.stderr.text,e.timeoutMs),e.treeEnded),e.stdout):e.errorMessage===void 0?ap({exitCode:rp(e.code),stderr:Sd(e.stderr.text,e.stdout,e.stderr),stdout:e.stdout.text},e.stdout):ap({exitCode:127,stderr:xd(e.stderr.text,e.errorMessage),stdout:e.stdout.text},e.stdout);var sp=class{#e;#t;#n=new Af((e,t,n)=>this.#r(e,t,n));constructor(e){this.#e=e?.defaultTimeoutMs,this.#t=qf(e?.env??process.env,process.platform)}run(e,t,n){return yd(),this.#n.run(e,t,n)}async#r(e,t,n){let r=n?.timeoutMs??this.#e,i={args:t,cmd:e,cwd:n?.cwd,env:this.#t,timeoutMs:r},a=await $f(i,(e,t)=>this.#r(e,t,{timeoutMs:5e3}));if(ep(a))return a;let o=await np(a.child);md.delete(a.child);let s=await a.timeout.settle();return op({code:o.code,errorMessage:o.errorMessage,stderr:a.stderrCollector.finish(),stdout:a.stdoutCollector.finish(),timedOut:a.timeout.markedTimedOut(),timeoutMs:r,treeEnded:s})}};const cp=`\0unreadable`,lp=`pnpm-workspace.yaml`,up=async(e,t)=>{let n=await e.run(`git`,[`ls-tree`,`-z`,`--name-only`,t.rev,`--`,t.path],{cwd:t.dir});return n.exitCode===0&&!ip(n)?n.stdout.includes(t.path):void 0},dp=async(e,t)=>{let n=await up(e,t);if(n===void 0)return{kind:`unreadable`};if(!n)return{kind:`absent`};let r=await e.run(`git`,[`show`,`${t.rev}:${t.path}`],{cwd:t.dir});return r.exitCode===0&&!ip(r)?{contents:r.stdout}:{kind:`unreadable`}},fp=async(e,t,n)=>{let r=await dp(e,{dir:t.dir,path:`package.json`,rev:n});if(`kind`in r)return r.kind===`absent`?[]:[cp];try{let e=JSON.parse(r.contents);return ed(e.workspaces)}catch{return[cp]}},pp=async(e,t,n)=>{let r=await dp(e,{dir:t.dir,path:lp,rev:n});if(`kind`in r)return r.kind===`absent`?[]:[cp];let{contents:i}=r,a=id(i.split(`
414
+ n.push({origin:t[e]??``,...of(t[e+1]??``)});return n},vf=e=>e.filter(e=>!e.origin.startsWith(nf)&&ef.test(e.key)).map(e=>ae(e.value)?e.value:af(`the include ${JSON.stringify(e.value)} is relative but set outside a file`)),yf=e=>{let{dir:t,rest:n}=Kd(e.args,e.cwd),r=n[0]===`clone`?n.at(-1):void 0;return[...t===void 0?[]:[t],...r===void 0?[]:[le(t??`.`,r)]]},bf=async(e,t,n)=>{let r={files:/* @__PURE__ */ new Set,includes:[],labels:/* @__PURE__ */ new Set,roots:n,snapshots:/* @__PURE__ */ new Map},i=_f(await sf(e,[`config`,`--list`,`--no-includes`,`--null`,`--show-origin`]));for(let e of i)lf(r,e.key);let a=i.filter(e=>e.origin.startsWith(nf)).map(e=>le(t.cwd??`.`,e.origin.slice(5))),o=[...[...new Set(a)].map(e=>({depth:0,direct:!0,file:e})),...vf(i).map(e=>({depth:1,direct:!1,file:e}))];for(let t of o)await gf(e,r,t);return r},xf=async(e,t)=>{let n=yf(t),r=await t.cache?.store.lookup(t.cache.key);if(r!==void 0){for(let e of r.includes)await df(e,n);return r.labels}let i=await bf(e,t,n);return t.cache?.store.store(t.cache.key,i),i.labels},Sf=async(e,t)=>{try{return{args:[...await xf(e,t)].flatMap(e=>[`-c`,`hook.${e}.enabled=false`])}}catch(e){if(e instanceof rf)return{refusal:e.message};throw e}},Cf=/^git version (?<major>\d+)\.(?<minor>\d+)/u,wf={major:2,minor:54},Tf=e=>{let t=Cf.exec(e.trim())?.groups,n=Number(t?.major??0),r=Number(t?.minor??0);return n>wf.major||n===wf.major&&r>=wf.minor},Ef=e=>e.length===1&&e[0]===`--version`,Df=(e,t)=>{if(!Tf(t.version))return Promise.resolve({args:[]});let{GIT_CONFIG:n,...r}=process.env,{cache:i,version:a,...o}=t;return Sf(t=>e(t,r),{...o,...i===void 0?{}:{cache:{key:Zd(t.cwd,r),store:i}}})},Of=[`-c`,`core.fsmonitor=`,...[`post-checkout`,`post-index-change`,`pre-auto-gc`,`reference-transaction`].flatMap(e=>[`-c`,`hook.${e}.enabled=false`])],kf=(e,t)=>e===`git`?[...Of,...t]:t;var Af=class{#e;#t;#n=new Qd;constructor(e){this.#e=(t,n,r)=>e(t,kf(t,n),r)}async run(e,t,n){if(e!==`git`||Ef(t))return this.#e(e,t,n);this.#t??=this.#r();let r=await Df(e=>this.#e(`git`,e,n),{args:t,cache:this.#n,version:await this.#t,...n?.cwd===void 0?{}:{cwd:n.cwd}});return`refusal`in r?{exitCode:1,stderr:r.refusal,stdout:``}:this.#e(e,[...r.args,...t],n)}async#r(){return(await this.#e(`git`,[`--version`])).stdout}};const jf=e=>e===`win32`?de:se,Mf=(e,t)=>{let n=Object.keys(e).find(e=>t===`win32`?e.toUpperCase()===`PATH`:e===`PATH`);return n===void 0?``:e[n]??``},Nf=e=>e.replace(/^["'](?<inner>.*)["']$/su,`$<inner>`),Pf=(e,t)=>{let n=jf(t);return Mf(e,t).split(n.delimiter).map(e=>t===`win32`?Nf(e):e).filter(e=>e.length>0&&n.isAbsolute(e)).filter(e=>t!==`win32`||/^(?:[a-z]:[\\/]|[\\/]{2})/iu.test(e))},Ff=(e,t)=>{if(t!==`win32`)return[e];let n=[`${e}.com`,`${e}.exe`];return de.extname(e)===``?n:[e,...n]},If=async(t,n)=>{try{return(await p(t)).isFile()?(await e(t,n===`win32`?te.F_OK:te.X_OK),!0):!1}catch{return!1}},Lf=(e,t)=>t===`win32`?/[\\/:]/u.test(e):e.includes(`/`),Rf=async(e,t,n)=>{if(Lf(e,n))return e;let r=jf(n),i=Pf(t,n).flatMap(t=>Ff(e,n).map(e=>r.join(t,e)));return i[(await Promise.all(i.map(e=>If(e,n)))).indexOf(!0)]},zf=/* @__PURE__ */ new Map,Bf=(e,t,n=process.platform)=>{let r=[n,e,Mf(t,n)].join(`\0`),i=zf.get(r)??Rf(e,t,n);return zf.set(r,i),i},Vf=/* @__PURE__ */ new Set([`GIT_ALTERNATE_OBJECT_DIRECTORIES`,`GIT_COMMON_DIR`,`GIT_CONFIG`,`GIT_DIR`,`GIT_GRAFT_FILE`,`GIT_IMPLICIT_WORK_TREE`,`GIT_INDEX_FILE`,`GIT_INTERNAL_SUPER_PREFIX`,`GIT_NO_REPLACE_OBJECTS`,`GIT_OBJECT_DIRECTORY`,`GIT_PREFIX`,`GIT_REPLACE_REF_BASE`,`GIT_SHALLOW_FILE`,`GIT_WORK_TREE`]),Hf=(e,t)=>Vf.has(t===`win32`?e.toUpperCase():e),Uf=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>!Hf(e,t))),Wf=`GIT_TERMINAL_PROMPT`,Gf=(e,t)=>t===`win32`?Object.keys(e).some(e=>e.toUpperCase()===Wf):e[Wf]!==void 0,Kf=(e,t=process.platform)=>Gf(e,t)?e:{...e,[Wf]:`0`},qf=(e,t)=>Uf(Kf(e),t),Jf=e=>e===void 0?{}:{cwd:e},Yf=(e,t)=>xd(e,`refs: command timed out after ${String(t)}ms`),Xf=(e,t)=>({exitCode:124,stderr:Yf(e,t),stdout:``,timedOut:!0}),Zf=(e,t)=>{let n=ye(e.file??e.cmd,e.args,{...Jf(e.cwd),env:e.env,shell:!1,stdio:[`ignore`,`pipe`,`pipe`]});md.add(n);let r=bd(),i=bd();return n.stdout.on(`data`,e=>{r.push(e)}),n.stderr.on(`data`,e=>{i.push(e)}),{child:n,stderrCollector:i,stdoutCollector:r,timeout:Ud({child:n,exec:t,timeoutMs:e.timeoutMs})}},Qf=(e,t)=>{try{return Zf(e,t)}catch(e){return{exitCode:127,stderr:tp(e),stdout:``}}},$f=async(e,t)=>{let n=await Bf(e.cmd,e.env);return n===void 0?{exitCode:127,stderr:`spawn ${e.cmd} ENOENT: not in an absolute PATH directory (refs never runs a program from the working directory)`,stdout:``}:Qf({...e,file:n},t)},ep=e=>!(`child`in e),tp=e=>e instanceof Error?e.message:String(e),np=async e=>{try{let[t]=await _e(e,`close`);return{code:t}}catch(e){return{code:null,errorMessage:tp(e)}}},rp=e=>e===null?1:e,ip=e=>e.stdoutTruncated===!0,ap=(e,t)=>t.truncated?{...e,stdoutTruncated:!0}:e,op=e=>e.timedOut?ap(Wd(Xf(e.stderr.text,e.timeoutMs),e.treeEnded),e.stdout):e.errorMessage===void 0?ap({exitCode:rp(e.code),stderr:Sd(e.stderr.text,e.stdout,e.stderr),stdout:e.stdout.text},e.stdout):ap({exitCode:127,stderr:xd(e.stderr.text,e.errorMessage),stdout:e.stdout.text},e.stdout);var sp=class{#e;#t;#n=new Af((e,t,n)=>this.#r(e,t,n));constructor(e){this.#e=e?.defaultTimeoutMs,this.#t=qf(e?.env??process.env,process.platform)}run(e,t,n){return yd(),this.#n.run(e,t,n)}async#r(e,t,n){let r=n?.timeoutMs??this.#e,i={args:t,cmd:e,cwd:n?.cwd,env:this.#t,timeoutMs:r},a=await $f(i,(e,t)=>this.#r(e,t,{timeoutMs:5e3}));if(ep(a))return a;let o=await np(a.child);md.delete(a.child);let s=await a.timeout.settle();return op({code:o.code,errorMessage:o.errorMessage,stderr:a.stderrCollector.finish(),stdout:a.stdoutCollector.finish(),timedOut:a.timeout.markedTimedOut(),timeoutMs:r,treeEnded:s})}};const cp=`\0unreadable`,lp=`pnpm-workspace.yaml`,up=async(e,t)=>{let n=await e.run(`git`,[`ls-tree`,`-z`,`--name-only`,t.rev,`--`,t.path],{cwd:t.dir});return n.exitCode===0&&!ip(n)?n.stdout.includes(t.path):void 0},dp=async(e,t)=>{let n=await up(e,t);if(n===void 0)return{kind:`unreadable`};if(!n)return{kind:`absent`};let r=await e.run(`git`,[`show`,`${t.rev}:${t.path}`],{cwd:t.dir});return r.exitCode===0&&!ip(r)?{contents:r.stdout}:{kind:`unreadable`}},fp=async(e,t,n)=>{let r=await dp(e,{dir:t.dir,path:`package.json`,rev:n});if(`kind`in r)return r.kind===`absent`?[]:[cp];try{let e=JSON.parse(r.contents);return ed(e.workspaces)}catch{return[cp]}},pp=async(e,t,n)=>{let r=await dp(e,{dir:t.dir,path:lp,rev:n});if(`kind`in r)return r.kind===`absent`?[]:[cp];let{contents:i}=r,a=id(i.split(`
415
415
  `));return dd(i,a)?[cp]:a},mp=async(e,t,n)=>{let[r,i]=await Promise.all([fp(e,t,n),pp(e,t,n)]);return{npm:r,pnpm:i}},hp=(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},gp=async(e,t)=>{if(!t.touched)return!1;let[n,r]=await Promise.all([mp(e,t,t.from),mp(e,t,t.to)]);return!hp(n.npm,r.npm)||!hp(n.pnpm,r.pnpm)},_p=e=>ie(e)===`package.json`,vp=async(e,t,n)=>{let r=await e.run(`git`,[...n],{cwd:t});return r.exitCode===0&&!ip(r)?r.stdout:void 0},yp=e=>e.split(`\0`).filter(e=>e.length>0&&_p(e)),bp=async(e,t)=>{let n=await vp(e,t.dir,[`diff`,`--name-only`,`-z`,`--no-renames`,`${t.from}..${t.to}`,`--`,`*package.json`,lp]);return n===void 0?void 0:n.split(`\0`).filter(e=>e.length>0)},xp=async(e,t)=>{if(t.paths.length===0)return/* @__PURE__ */ new Set;let n=await vp(e,t.dir,[`ls-tree`,`-r`,`-z`,`--name-only`,t.rev,`--`,...t.paths]);return n===void 0?void 0:new Set(yp(n))},Sp=async(e,t)=>{let n=await vp(e,t.dir,[`show`,`${t.rev}:${t.path}`]);if(n!==void 0)try{let e=JSON.parse(n);return{name:ad(e)}}catch{return}},Cp=async(e,t,n)=>{let r=[];for(let i of n){let n=await Sp(e,{dir:t.dir,path:i,rev:t.rev});if(n===void 0)return;n.name!==void 0&&r.push(n.name)}return r},wp={changedDirs:[],namesBefore:[]},Tp=(e,t,n)=>gp(e,{...t,touched:n.some(e=>e===`pnpm-workspace.yaml`||e===`package.json`)}),Ep=e=>[...new Set(e.map(e=>_(e)))].filter(e=>e!==`.`).toSorted(),Dp=async(e,t,n)=>{let r=await xp(e,{dir:t.dir,paths:n,rev:t.from});if(r!==void 0)return Cp(e,{dir:t.dir,rev:t.from},n.filter(e=>r.has(e)))},Op=async(e,t)=>{if(t.from===t.to)return wp;let n=await bp(e,t);if(n===void 0||await Tp(e,t,n))return;let r=n.filter(e=>_p(e));if(r.length>200)return;let i=await Dp(e,t,r);return i===void 0?void 0:{changedDirs:Ep(r),namesBefore:i}},kp=(e,t)=>({run:(n,r,i)=>e.run(n,n===`git`?[`-c`,`core.hooksPath=${t}`,...r]:r,i)}),Ap=e=>{let t=e.stderr.trim()||e.stdout.trim()||`exit code ${e.exitCode}`,n=t.split(`
416
- `)[0]??t;return n.length<=200?n:`${n.slice(0,200)}…`},jp=(e,t)=>t?`restored`:e.oldSha===e.newSha?`fresh`:`updated`,Mp=(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(` | `)},Np=e=>{let{branchRenamedTo:t,dirty:n,setHeadWarning:r,shas:i}=e,a={...i,status:jp(i,n)};t!==void 0&&(a.branchRenamedTo=t);let o=Mp(n,r);return o!==void 0&&(a.warning=o),a},Pp=(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},Fp=`REFS_GIT_TIMEOUT`,Ip=/^\d+$/u,Lp=e=>{let t=e.REFS_GIT_TIMEOUT?.trim()??``,n=Ip.test(t)?Number(t):900;if(n!==0)return Math.min(n*1e3,2147483647)},Rp=/^(?<scheme>[a-z][a-z0-9+.-]*:\/\/)?[\s\S]*@/iu,zp=/(?<scheme>[a-z][a-z0-9+.-]{0,31}:\/\/)[^/\s@]{1,256}@/giu,Bp=e=>e.replaceAll(zp,`$<scheme><redacted>@`),Vp=/^git@[^:/\s]+:[^\s]+$/u,Hp=e=>{try{return new URL(e)}catch{return}},Up=e=>e.password===``&&e.username===`git`&&e.protocol===`ssh:`,Wp=e=>{if(Vp.test(e))return e;let t=Hp(e);return t===void 0?e.includes(`@`)?G(e):e:t.username===``&&t.password===``||Up(t)?e:`${t.protocol}//<redacted>@${t.host}${t.pathname}${t.search}${t.hash}`},G=e=>{let t=e.replace(Rp,`$<scheme><redacted>@`);return t.length<=200?t:`${t.slice(0,200)}…`},Gp=e=>{let t=Bp(e);return t.length<=2e3?t:`${t.slice(0,2e3)}… (truncated)`},Kp=/terminal prompts disabled/iu,qp=`git needed credentials and refs does not let git prompt for them: configure a git credential helper or GIT_ASKPASS, or set ${Wf}=1 to type them in a terminal`,Jp=`set ${Fp} to a number of seconds to allow longer, or ${Fp}=0 for no limit`,Yp=e=>e===void 0?{}:{cwd:e},Xp=(e,t,n)=>({action:e,args:t,cmd:`git`,...Yp(n)}),Zp=(e,t)=>e.timedOut===!0?Jp:Kp.test(t)?qp:void 0,Qp=(e,t)=>{let n=t.stderr.trim()||t.stdout.trim()||`exit code ${t.exitCode}`,r=Zp(t,n),i=`${e} failed: ${Gp(n)}`;return r===void 0?i:`${i} — ${r}`},$p=async(e,t)=>{let n=await e.run(t.cmd,t.args,Yp(t.cwd));if(n.exitCode===0)return n;throw V(Qp(t.action,n))},K=e=>te(v(e,`.git`)),em=e=>`refusing to sync ${e}: not a refs-managed checkout`,tm=async(e,t,n)=>{if(!K(t))throw V(em(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 V(em(t))},nm=async e=>{try{return await i(e),!0}catch(e){return e.code!==`ENOENT`}},rm=async(e,t)=>!t&&await nm(v(e,`.git`)),im=e=>{let t=!1;return{runner:{run:async(n,r,i)=>{let a=await e.run(n,r,i);return t||=a.cleanupUncertain===!0,a}},uncertain:()=>t}},am=`.git.refs-quarantined`,om=async(e,t,n)=>{try{return await tm(e,t,n),!0}catch{return!1}},sm=async(e,t,n)=>{if(await e.run(`git`,[`config`,`--local`,`--unset`,`core.hooksPath`],{cwd:t}),!await om(e,t,n))return`unmarked it`;try{await u(v(t,`.git`),v(t,am))}catch{return}return await om(e,t,n)?void 0:`moved its .git to ${am}, because its marker could not be unset`},cm=async(e,t)=>{let n=await sm(e.runner,e.dest,e.hooksDir),r=`${t instanceof Error?t.message:String(t)} — processes the clone started may still be running, so refs left ${e.dest} in place`;return V(n===void 0?`${r}, but could not unmark it, so a later refs run may adopt it: remove it once they have exited`:`${r} and ${n}; refs will not use it, remove it once they have exited`)},lm=async(e,t)=>await rm(e.dest,e.existed)?e.uncertain?cm(e,t):(await d(e.dest,{force:!0,maxRetries:3,recursive:!0}),t):t,um=async(e,t,n)=>{let r=await nm(t.dest),i=im(e);try{let r=await $p(i.runner,Xp(`git clone`,n));return await $p(e,Xp(`git config core.hooksPath`,[`config`,`core.hooksPath`,t.hooksDir],t.dest)),r}catch(n){let a={dest:t.dest,existed:r,hooksDir:t.hooksDir,runner:e,uncertain:i.uncertain()};throw await lm(a,n)}},dm=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},fm=async(e,t)=>{let n=await dm(e,t);if(n!==void 0)return n;await e.run(`git`,[`remote`,`set-head`,`origin`,`--auto`],{cwd:t});let r=await dm(e,t);if(r!==void 0)return r;throw V(`could not detect the default branch for checkout: ${t}`)},pm=async e=>{await Promise.all([`pre-commit`,`pre-push`].map(async t=>{await fu(v(e.hooksDir,t),`#!/bin/sh
416
+ `)[0]??t;return n.length<=200?n:`${n.slice(0,200)}…`},jp=(e,t)=>t?`restored`:e.oldSha===e.newSha?`fresh`:`updated`,Mp=(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(` | `)},Np=e=>{let{branchRenamedTo:t,dirty:n,setHeadWarning:r,shas:i}=e,a={...i,status:jp(i,n)};t!==void 0&&(a.branchRenamedTo=t);let o=Mp(n,r);return o!==void 0&&(a.warning=o),a},Pp=(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},Fp=`REFS_GIT_TIMEOUT`,Ip=/^\d+$/u,Lp=e=>{let t=e.REFS_GIT_TIMEOUT?.trim()??``,n=Ip.test(t)?Number(t):900;if(n!==0)return Math.min(n*1e3,0x7fffffff)},Rp=/^(?<scheme>[a-z][a-z0-9+.-]*:\/\/)?[\s\S]*@/iu,zp=/(?<scheme>[a-z][a-z0-9+.-]{0,31}:\/\/)[^/\s@]{1,256}@/giu,Bp=e=>e.replaceAll(zp,`$<scheme><redacted>@`),Vp=/^git@[^:/\s]+:[^\s]+$/u,Hp=e=>{try{return new URL(e)}catch{return}},Up=e=>e.password===``&&e.username===`git`&&e.protocol===`ssh:`,Wp=e=>{if(Vp.test(e))return e;let t=Hp(e);return t===void 0?e.includes(`@`)?G(e):e:t.username===``&&t.password===``||Up(t)?e:`${t.protocol}//<redacted>@${t.host}${t.pathname}${t.search}${t.hash}`},G=e=>{let t=e.replace(Rp,`$<scheme><redacted>@`);return t.length<=200?t:`${t.slice(0,200)}…`},Gp=e=>{let t=Bp(e);return t.length<=2e3?t:`${t.slice(0,2e3)}… (truncated)`},Kp=/terminal prompts disabled/iu,qp=`git needed credentials and refs does not let git prompt for them: configure a git credential helper or GIT_ASKPASS, or set ${Wf}=1 to type them in a terminal`,Jp=`set ${Fp} to a number of seconds to allow longer, or ${Fp}=0 for no limit`,Yp=e=>e===void 0?{}:{cwd:e},Xp=(e,t,n)=>({action:e,args:t,cmd:`git`,...Yp(n)}),Zp=(e,t)=>e.timedOut===!0?Jp:Kp.test(t)?qp:void 0,Qp=(e,t)=>{let n=t.stderr.trim()||t.stdout.trim()||`exit code ${t.exitCode}`,r=Zp(t,n),i=`${e} failed: ${Gp(n)}`;return r===void 0?i:`${i} — ${r}`},$p=async(e,t)=>{let n=await e.run(t.cmd,t.args,Yp(t.cwd));if(n.exitCode===0)return n;throw V(Qp(t.action,n))},K=e=>ne(v(e,`.git`)),em=e=>`refusing to sync ${e}: not a refs-managed checkout`,tm=async(e,t,n)=>{if(!K(t))throw V(em(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 V(em(t))},nm=async e=>{try{return await i(e),!0}catch(e){return e.code!==`ENOENT`}},rm=async(e,t)=>!t&&await nm(v(e,`.git`)),im=e=>{let t=!1;return{runner:{run:async(n,r,i)=>{let a=await e.run(n,r,i);return t||=a.cleanupUncertain===!0,a}},uncertain:()=>t}},am=`.git.refs-quarantined`,om=async(e,t,n)=>{try{return await tm(e,t,n),!0}catch{return!1}},sm=async(e,t,n)=>{if(await e.run(`git`,[`config`,`--local`,`--unset`,`core.hooksPath`],{cwd:t}),!await om(e,t,n))return`unmarked it`;try{await u(v(t,`.git`),v(t,am))}catch{return}return await om(e,t,n)?void 0:`moved its .git to ${am}, because its marker could not be unset`},cm=async(e,t)=>{let n=await sm(e.runner,e.dest,e.hooksDir),r=`${t instanceof Error?t.message:String(t)} — processes the clone started may still be running, so refs left ${e.dest} in place`;return V(n===void 0?`${r}, but could not unmark it, so a later refs run may adopt it: remove it once they have exited`:`${r} and ${n}; refs will not use it, remove it once they have exited`)},lm=async(e,t)=>await rm(e.dest,e.existed)?e.uncertain?cm(e,t):(await d(e.dest,{force:!0,maxRetries:3,recursive:!0}),t):t,um=async(e,t,n)=>{let r=await nm(t.dest),i=im(e);try{let r=await $p(i.runner,Xp(`git clone`,n));return await $p(e,Xp(`git config core.hooksPath`,[`config`,`core.hooksPath`,t.hooksDir],t.dest)),r}catch(n){let a={dest:t.dest,existed:r,hooksDir:t.hooksDir,runner:e,uncertain:i.uncertain()};throw await lm(a,n)}},dm=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},fm=async(e,t)=>{let n=await dm(e,t);if(n!==void 0)return n;await e.run(`git`,[`remote`,`set-head`,`origin`,`--auto`],{cwd:t});let r=await dm(e,t);if(r!==void 0)return r;throw V(`could not detect the default branch for checkout: ${t}`)},pm=async e=>{await Promise.all([`pre-commit`,`pre-push`].map(async t=>{await uu(v(e.hooksDir,t),`#!/bin/sh
417
417
  echo "refs: this checkout is a managed read-only reference — commits are blocked" >&2
418
418
  exit 1
419
419
  `,493)}))},mm=/filtering not recognized/iu,hm=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 um(e,t,n);return t.mode!==`blobless`||!mm.test(r.stderr)?{effectiveMode:t.mode}:{effectiveMode:`full`,warning:`server did not honour the partial-clone filter (blob:none); fell back to a full clone`}},gm=async(e,t)=>(await $p(e,Xp(`git rev-parse HEAD`,[`rev-parse`,`HEAD`],t))).stdout.trim(),_m=async(e,t)=>(await $p(e,Xp(`git status --porcelain`,[`status`,`--porcelain`],t))).stdout.trim()!==``,vm=async(e,t)=>{await $p(e,Xp(`git fetch`,[`fetch`,`--prune`,`--tags`,`origin`],t.dir));let n=await e.run(`git`,[`remote`,`set-head`,`origin`,`--auto`],{cwd:t.dir}),r=await fm(e,t.dir),i={branch:r};return r!==t.defaultBranch&&(i.branchRenamedTo=r),n.exitCode!==0&&(i.warning=`could not refresh origin/HEAD: ${Ap(n)}`),i},ym=e=>[Xp(`git reset --hard HEAD (pre-checkout)`,[`reset`,`--hard`,`HEAD`],e),Xp(`git clean -fd`,[`clean`,`-fd`],e)],bm=async(e,t)=>{let{branch:n,dir:r,dirty:i}=t,a=[];i&&a.push(...ym(r)),a.push(Xp(`git checkout -B`,[`checkout`,`-B`,n,`origin/${n}`],r),Xp(`git reset --hard`,[`reset`,`--hard`,`origin/${n}`],r));for(let t of a)await $p(e,t)},xm=async(e,t)=>{await tm(e,t.dir,t.hooksDir);let n=await gm(e,t.dir),r=await vm(e,t),i=await _m(e,t.dir);await bm(e,{branch:r.branch,dir:t.dir,dirty:i});let a=await gm(e,t.dir);return Np(Pp(r,i,{newSha:a,oldSha:n}))},Sm=async(e,t,n)=>(await e.run(`git`,[`show-ref`,`--verify`,`--`,`refs/tags/${n}`],{cwd:t})).exitCode===0,Cm=async(e,t,n)=>{let r=await $p(e,Xp(`git tag`,[`tag`,`--sort=-version:refname`],t)),i=r.stdout.split(`
420
- `).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)}},wm=/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?/u,Tm=/\d+\.\d+\.\d+/gu,Em=e=>fl.safeParse(e).success,Dm=e=>{let t=e.match(Tm);return t!==null&&t.length>1},Om=e=>{let t=wm.exec(e);if(!t||Dm(e))return;let[n]=t,r=e.replace(n,`{version}`);if(Em(r))return r},km=(e,t,n)=>{let r=e.get(t);r===void 0?e.set(t,{count:1,index:n}):r.count+=1},Am=e=>{let t=/* @__PURE__ */ new Map;for(let[n,r]of e.entries()){let e=Om(r);e&&km(t,e,n)}return t},jm=(e,t)=>e.count>t.count||e.count===t.count&&e.index<t.index,Mm=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])=>jm(r,t)?{data:r,format:n}:{data:t,format:e},{data:i,format:r}).format},Nm=e=>{let t=Am(e);return Mm(t)},Pm=(e,t)=>e.replaceAll(`{version}`,()=>t),Fm=async(e,t,n,r)=>{let i=Pm(n,r);if(!await Sm(e,t,i))throw z(`tag '${i}' not found in ${t} — check the version or tag_format`);return i},Im=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]+)?$/u,Lm=/[0-9.]$/u,Rm=[`@`,`-`,`_`,`/`],zm=`{version}`,Bm=(e,t)=>Rm.some(n=>e===`${t}${n}`||e===`${t}${n}v`),Vm=(e,t)=>Bm(e.slice(0,e.length-9),t)&&e.endsWith(zm),Hm=(e,t)=>t!==void 0&&Bm(e,t)?2:+(e===``||e===`v`),Um=(e,t)=>{if(!e.endsWith(t))return;let n=e.slice(0,e.length-t.length);return Lm.test(n)?void 0:n},Wm=(e,t,n)=>{let r=Um(e,t);if(r===void 0)return;let i=fl.safeParse(`${r}${zm}`);if(i.success&&Pm(i.data,t)===e)return{format:i.data,rank:Hm(r,n)}},Gm=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},Km=(e,t,n)=>t.length>64||!Im.test(t)?null:Gm(e.map(e=>Wm(e,t,n)).filter(e=>e!==void 0)),qm=e=>e.split(`/`).some(e=>e===`.`||e===`..`),Jm=e=>e.includes(`\\`),Ym=e=>e.includes(`%`),Xm=/[\u0000-\u001F\u007F]/u,Zm=/^ | $/u,Qm=/[?#]/u,$m=(e,t)=>`not a supported git url: control character ${`U+${(e.codePointAt(t)??0).toString(16).toUpperCase().padStart(4,`0`)}`} at position ${String(t)}`,eh=(e,t)=>{let n=e.search(Xm);if(n!==-1)throw V($m(e,n));if(Zm.test(e))throw V(`not a supported git url: leading or trailing space`);if(Qm.test(e))throw V(`not a supported git url: query or fragment in ${G(t)}`);th(e,t),nh(e,t)},th=(e,t)=>{if(Jm(e))throw V(`not a supported git url: backslash not allowed in ${G(t)}`)},nh=(e,t)=>{if(qm(e))throw V(`not a supported git url: path traversal segment in ${G(t)}`)},rh=(e,t,n)=>{if(e.protocol!==`file:`&&Ym(t))throw V(`not a supported git url: percent-encoding not supported in ${G(n)}`)},ih=/\.git$/u,ah=e=>e.replace(ih,``),oh=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)},sh=/^git@(?<host>[^:/\s]+):(?<path>[^\s]+)$/u,ch=/^git\+/u,lh={"https:":`443`,"ssh:":`22`},uh=e=>{let t=sl.safeParse(e);if(!t.success)throw V(`not a supported git url: derived key '${G(e)}' is invalid`);return t.data},dh=({host:e,port:t,protocol:n})=>{let r=lh[n];return t===``||t===r?e.toLowerCase():`${e.toLowerCase()}_${t}`},fh=e=>{let t=ah(oh(e.path));return uh(`${dh(e)}/${t}`)},ph=e=>{let t=decodeURIComponent(e).split(`/`).filter(e=>e!==``);if(t.length<2)throw V(`not a supported git url: file url path must have at least 2 segments`);let n=t.at(-2)??``,r=t.at(-1)??``;return uh(`local/${n}/${r}`)},mh=(e,t)=>{try{return new URL(e)}catch{throw V(`not a supported git url: ${G(t)}`)}},hh=e=>{if(e.password!==``)throw V(`not a supported git url: credentials embedded in url`);if(e.protocol===`https:`&&e.username!==``)throw V(`not a supported git url: credentials embedded in https url`)},gh=(e,t)=>{if(e.protocol===`file:`){if(!t)throw V(`not a supported git url: unsupported protocol ${e.protocol}`);return ph(e.pathname)}if(e.protocol!==`https:`&&e.protocol!==`ssh:`)throw V(`not a supported git url: unsupported protocol ${e.protocol}`);return hh(e),fh({host:e.hostname,path:e.pathname,port:e.port,protocol:e.protocol})},_h=(e,t)=>{if(Ym(e))throw V(`not a supported git url: percent-encoding not supported in ${G(t)}`);if(e.includes(`:`))throw V(`not a supported git url: ambiguous ':' in scp-style path ${G(t)}; use the ssh:// url form instead`);if(e.startsWith(`/`)||e.startsWith(`~`))throw V(`not a supported git url: ambiguous absolute/home-relative scp path in ${G(t)}; use the ssh:// url form instead`)},vh=(e,t)=>{let n=e.groups?.path??``;return _h(n,t),fh({host:e.groups?.host??``,path:n,port:``,protocol:`ssh:`})},yh=(e,t)=>{let n=t?.allowFileUrls??!1,r=e.replace(ch,``);eh(r,e);let i=sh.exec(r);if(i?.groups!==void 0)return{cloneUrl:r,key:vh(i,e)};let a=mh(r,e);return rh(a,r,e),{cloneUrl:r,key:gh(a,n)}},bh=`.git`,xh=e=>e.endsWith(bh)?e:`${e}${bh}`,Sh=(e,t)=>`https://${e.toLowerCase()}/${oh(t)}`,Ch=(e,t)=>`git@${e.toLowerCase()}:${xh(oh(t))}`,wh=e=>{if(e===`https:`)return`https`;if(e===`ssh:`)return`ssh`;throw V(`not a supported git url: unsupported protocol ${e}`)},Th=(e,t,n)=>{let r=lh[e.protocol];if(e.port!==``&&e.port!==r)throw V(`cannot apply git_transport=${t} to ${G(n)}: its non-default port ${e.port} cannot be expressed in the ${t} url form — add the repo with an explicit url instead`)},Eh=(e,t)=>t===`https`?Sh(e.hostname,e.pathname):Ch(e.hostname,e.pathname),Dh=(e,t,n)=>{let r=yh(t).key;if(r!==n)throw V(`git_transport transform changed repo identity: '${G(e)}' → '${t}' (key '${n}' → '${r}')`);return t},Oh=(e,t)=>{if(t.transport===`ssh`)return t.cloneUrl;let n=e.groups?.host??``,r=e.groups?.path??``;return Dh(t.cloneUrl,Sh(n,r),t.originalKey)},kh=e=>{let t=mh(e.cloneUrl,e.cloneUrl);return wh(t.protocol)===e.transport?e.cloneUrl:(Th(t,e.transport,e.cloneUrl),Dh(e.cloneUrl,Eh(t,e.transport),e.originalKey))},Ah=(e,t)=>{if(e.startsWith(`file:`))return e;let n={cloneUrl:e,originalKey:yh(e).key,transport:t},r=sh.exec(e);return r?.groups===void 0?kh(n):Oh(r,n)},jh=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u,Mh=(e,t)=>{if(jh.test(t))return v(e,`lease-${t}`)},Nh=async(e,t)=>{let n=Mh(e,t);
420
+ `).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)}},wm=/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?/u,Tm=/\d+\.\d+\.\d+/gu,Em=e=>ul.safeParse(e).success,Dm=e=>{let t=e.match(Tm);return t!==null&&t.length>1},Om=e=>{let t=wm.exec(e);if(!t||Dm(e))return;let[n]=t,r=e.replace(n,`{version}`);if(Em(r))return r},km=(e,t,n)=>{let r=e.get(t);r===void 0?e.set(t,{count:1,index:n}):r.count+=1},Am=e=>{let t=/* @__PURE__ */ new Map;for(let[n,r]of e.entries()){let e=Om(r);e&&km(t,e,n)}return t},jm=(e,t)=>e.count>t.count||e.count===t.count&&e.index<t.index,Mm=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])=>jm(r,t)?{data:r,format:n}:{data:t,format:e},{data:i,format:r}).format},Nm=e=>{let t=Am(e);return Mm(t)},Pm=(e,t)=>e.replaceAll(`{version}`,()=>t),Fm=async(e,t,n,r)=>{let i=Pm(n,r);if(!await Sm(e,t,i))throw mu(`tag '${i}' not found in ${t} — check the version or tag_format`);return i},Im=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]+)?$/u,Lm=/[0-9.]$/u,Rm=[`@`,`-`,`_`,`/`],zm=`{version}`,Bm=(e,t)=>Rm.some(n=>e===`${t}${n}`||e===`${t}${n}v`),Vm=(e,t)=>Bm(e.slice(0,e.length-9),t)&&e.endsWith(zm),Hm=(e,t)=>t!==void 0&&Bm(e,t)?2:+(e===``||e===`v`),Um=(e,t)=>{if(!e.endsWith(t))return;let n=e.slice(0,e.length-t.length);return Lm.test(n)?void 0:n},Wm=(e,t,n)=>{let r=Um(e,t);if(r===void 0)return;let i=ul.safeParse(`${r}${zm}`);if(i.success&&Pm(i.data,t)===e)return{format:i.data,rank:Hm(r,n)}},Gm=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},Km=(e,t,n)=>t.length>64||!Im.test(t)?null:Gm(e.map(e=>Wm(e,t,n)).filter(e=>e!==void 0)),qm=e=>e.split(`/`).some(e=>e===`.`||e===`..`),Jm=e=>e.includes(`\\`),Ym=e=>e.includes(`%`),Xm=/[\u0000-\u001F\u007F]/u,Zm=/^ | $/u,Qm=/[?#]/u,$m=(e,t)=>`not a supported git url: control character ${`U+${(e.codePointAt(t)??0).toString(16).toUpperCase().padStart(4,`0`)}`} at position ${String(t)}`,eh=(e,t)=>{let n=e.search(Xm);if(n!==-1)throw V($m(e,n));if(Zm.test(e))throw V(`not a supported git url: leading or trailing space`);if(Qm.test(e))throw V(`not a supported git url: query or fragment in ${G(t)}`);th(e,t),nh(e,t)},th=(e,t)=>{if(Jm(e))throw V(`not a supported git url: backslash not allowed in ${G(t)}`)},nh=(e,t)=>{if(qm(e))throw V(`not a supported git url: path traversal segment in ${G(t)}`)},rh=(e,t,n)=>{if(e.protocol!==`file:`&&Ym(t))throw V(`not a supported git url: percent-encoding not supported in ${G(n)}`)},ih=/\.git$/u,ah=e=>e.replace(ih,``),oh=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)},sh=/^git@(?<host>[^:/\s]+):(?<path>[^\s]+)$/u,ch=/^git\+/u,lh={"https:":`443`,"ssh:":`22`},uh=e=>{let t=al.safeParse(e);if(!t.success)throw V(`not a supported git url: derived key '${G(e)}' is invalid`);return t.data},dh=({host:e,port:t,protocol:n})=>{let r=lh[n];return t===``||t===r?e.toLowerCase():`${e.toLowerCase()}_${t}`},fh=e=>{let t=ah(oh(e.path));return uh(`${dh(e)}/${t}`)},ph=e=>{let t=decodeURIComponent(e).split(`/`).filter(e=>e!==``);if(t.length<2)throw V(`not a supported git url: file url path must have at least 2 segments`);let n=t.at(-2)??``,r=t.at(-1)??``;return uh(`local/${n}/${r}`)},mh=(e,t)=>{try{return new URL(e)}catch{throw V(`not a supported git url: ${G(t)}`)}},hh=e=>{if(e.password!==``)throw V(`not a supported git url: credentials embedded in url`);if(e.protocol===`https:`&&e.username!==``)throw V(`not a supported git url: credentials embedded in https url`)},gh=(e,t)=>{if(e.protocol===`file:`){if(!t)throw V(`not a supported git url: unsupported protocol ${e.protocol}`);return ph(e.pathname)}if(e.protocol!==`https:`&&e.protocol!==`ssh:`)throw V(`not a supported git url: unsupported protocol ${e.protocol}`);return hh(e),fh({host:e.hostname,path:e.pathname,port:e.port,protocol:e.protocol})},_h=(e,t)=>{if(Ym(e))throw V(`not a supported git url: percent-encoding not supported in ${G(t)}`);if(e.includes(`:`))throw V(`not a supported git url: ambiguous ':' in scp-style path ${G(t)}; use the ssh:// url form instead`);if(e.startsWith(`/`)||e.startsWith(`~`))throw V(`not a supported git url: ambiguous absolute/home-relative scp path in ${G(t)}; use the ssh:// url form instead`)},vh=(e,t)=>{let n=e.groups?.path??``;return _h(n,t),fh({host:e.groups?.host??``,path:n,port:``,protocol:`ssh:`})},yh=(e,t)=>{let n=t?.allowFileUrls??!1,r=e.replace(ch,``);eh(r,e);let i=sh.exec(r);if(i?.groups!==void 0)return{cloneUrl:r,key:vh(i,e)};let a=mh(r,e);return rh(a,r,e),{cloneUrl:r,key:gh(a,n)}},bh=`.git`,xh=e=>e.endsWith(bh)?e:`${e}${bh}`,Sh=(e,t)=>`https://${e.toLowerCase()}/${oh(t)}`,Ch=(e,t)=>`git@${e.toLowerCase()}:${xh(oh(t))}`,wh=e=>{if(e===`https:`)return`https`;if(e===`ssh:`)return`ssh`;throw V(`not a supported git url: unsupported protocol ${e}`)},Th=(e,t,n)=>{let r=lh[e.protocol];if(e.port!==``&&e.port!==r)throw V(`cannot apply git_transport=${t} to ${G(n)}: its non-default port ${e.port} cannot be expressed in the ${t} url form — add the repo with an explicit url instead`)},Eh=(e,t)=>t===`https`?Sh(e.hostname,e.pathname):Ch(e.hostname,e.pathname),Dh=(e,t,n)=>{let r=yh(t).key;if(r!==n)throw V(`git_transport transform changed repo identity: '${G(e)}' → '${t}' (key '${n}' → '${r}')`);return t},Oh=(e,t)=>{if(t.transport===`ssh`)return t.cloneUrl;let n=e.groups?.host??``,r=e.groups?.path??``;return Dh(t.cloneUrl,Sh(n,r),t.originalKey)},kh=e=>{let t=mh(e.cloneUrl,e.cloneUrl);return wh(t.protocol)===e.transport?e.cloneUrl:(Th(t,e.transport,e.cloneUrl),Dh(e.cloneUrl,Eh(t,e.transport),e.originalKey))},Ah=(e,t)=>{if(e.startsWith(`file:`))return e;let n={cloneUrl:e,originalKey:yh(e).key,transport:t},r=sh.exec(e);return r?.groups===void 0?kh(n):Oh(r,n)},jh=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u,Mh=(e,t)=>{if(jh.test(t))return v(e,`lease-${t}`)},Nh=async(e,t)=>{let n=Mh(e,t);
421
421
  /* v8 ignore next 3 -- `token` here is always this process's own `randomUUID()`; the guard exists
422
422
  for the read path, where the token comes off disk. */
423
423
  n!==void 0&&await(await o(n,`w`,384)).close()},Ph=async(e,t)=>{let n=Mh(e,t);
424
424
  /* v8 ignore next 3 -- as in `createLeaseSidecar`: the heartbeat only ever renews with the token
425
425
  its own acquisition minted. */
426
- if(n===void 0)return`gone`;let r=/* @__PURE__ */ new Date;try{await m(n,r,r)}catch(e){if(L(e))return`gone`;throw e}return`renewed`},Fh=async(e,t)=>{let n=Mh(e,t);if(n===void 0)return{state:`absent`};try{return{mtimeMs:(await p(n)).mtimeMs,state:`ok`}}catch(e){return{state:L(e)?`absent`:`unreadable`}}},Ih=`meta.json`,Lh=e=>{try{return process.kill(e,0),!0}catch(e){return uu(e)!==`ESRCH`}},Rh=e=>{try{return JSON.parse(e)}catch{return}},zh=async e=>{try{return await s(e,`utf8`)}catch{return}},Bh=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),Vh=async e=>{try{return{state:`read`,text:await s(e,`utf8`)}}catch(e){let t=uu(e);return{state:t!==void 0&&Bh.has(t)?`missing`:`unreadable`}}},Hh=e=>{if(typeof e!=`string`)return;let t=Date.parse(e);if(!Number.isNaN(t))return t},Uh=e=>{if(typeof e!=`object`||!e)return;let{token:t}=e;if(typeof t==`string`)return t},Wh=e=>{if(!(typeof e!=`number`||!Number.isSafeInteger(e)||e<=0||e>2147483647))return e},Gh=e=>{if(typeof e!=`object`||!e)return;let t=e,n=Wh(t.pid),r=Hh(t.acquired_at);if(n===void 0||r===void 0)return;let i=Uh(e);return{acquiredAtMs:r,pid:n,...i===void 0?{}:{token:i}}},Kh=async e=>{let t=await zh(v(e,Ih));if(t!==void 0)return Uh(Rh(t))},qh=async e=>{let t=await Vh(v(e,Ih));if(t.state!==`read`)return{state:t.state};let n=Gh(Rh(t.text));return n===void 0?{state:`malformed`}:{meta:n,state:`valid`}},Jh=async e=>{try{return{mtimeMs:(await p(e)).mtimeMs,state:`ok`}}catch(e){return{state:uu(e)===`ENOENT`?`gone`:`unreadable`}}},Yh=async(e,t)=>{let n=v(e,Ih),r=`${n}.tmp-${pe()}`;await h(r,t,{encoding:`utf8`,mode:384}),await u(r,n)},Xh=()=>pe(),Zh=async(e,t)=>{await Nh(e,t),await Yh(e,JSON.stringify({acquired_at:(/* @__PURE__ */ new Date()).toISOString(),pid:process.pid,token:t}))},Qh=5e3,$h=async(e,t,n)=>{if(t===`unreadable`)return{meta:t,observedAtMs:n,pidState:`unknown`,policy:`unknown`,stale:!1};let r=await Jh(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:Qh,meta:t,observedAtMs:n,pidState:`unknown`,policy:`grace`,stale:i>Qh}},eg=async(e,t,n)=>{let r=t.token===void 0?{state:`absent`}:await Fh(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`}},tg=async(e,t)=>{let n=await qh(e);if(n.state!==`valid`)return $h(e,n.state,t);let{meta:r}=n,i=await eg(e,r,t),a=!Lh(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}}},ng=e=>e.meta===`valid`&&e.pidState===`definitely-dead`&&e.token!==void 0,rg=async(e,t)=>await Kh(e)===t?await Ph(e,t)===`gone`?`lost`:`renewed`:`lost`,ig=/* @__PURE__ */ new Set([`EEXIST`,`EPERM`,`EACCES`,`EBUSY`]),ag=/* @__PURE__ */ new Set([`ENOENT`,`EPERM`,`EACCES`,`EBUSY`]),og=async e=>{try{return await a(e,{mode:448,recursive:!1}),!0}catch(e){let t=uu(e);if(t!==void 0&&ig.has(t))return!1;throw e}},sg=async(e,t)=>{try{return await u(e,t),!0}catch(e){let t=uu(e);if(t!==void 0&&ag.has(t))return!1;throw e}},cg=e=>a(e,{mode:448,recursive:!0}),lg=`.claims`,ug=`.tombstones`,dg=(e,t)=>({lockPath:v(e,t),locksDir:e,name:t}),fg=e=>v(e.locksDir,lg,e.name),pg=e=>v(e.locksDir,ug,pe()),mg=async e=>{await a(v(e,lg),{mode:448,recursive:!0}),await a(v(e,ug),{mode:448,recursive:!0})},hg=e=>og(e),gg=async e=>{try{await f(e)}catch{}},_g=async e=>{let t=pg(e);return await sg(e.lockPath,t)?t:void 0},vg=async e=>{let t=await tg(e.lockPath,Date.now());if(!ng(t)||await Kh(e.lockPath)!==t.token)return!1;let n=await _g(e);return n!==void 0&&(await d(n,{force:!0,recursive:!0}),!0)},yg=async e=>{await mg(e.locksDir);let t=fg(e);if(!await hg(t))return!1;let n=await vg(e).then(e=>({ok:!0,stolen:e}),e=>({error:e,ok:!1}));if(await gg(t),!n.ok)throw n.error;return n.stolen},bg=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(L(e))return[];throw e}},xg=async e=>(await bg(e)).filter(e=>!e.name.startsWith(`.`)),Sg=async(e,t,n)=>{let r=await tg(v(e,t.name),n);if(r.policy!==`none`)return{diagnosis:r,isDirectory:t.isDir,kind:`lock`,name:t.name}},Cg=async(e,t)=>{let n=v(e,lg),r=await bg(n);return(await Promise.all(r.map(async e=>({diagnosis:await tg(v(n,e.name),t),isDirectory:e.isDir,kind:`claim`,name:e.name})))).filter(e=>e.diagnosis.policy!==`none`)},wg=async e=>{let t=Date.now(),n=await xg(e.locksDir),[r,i]=await Promise.all([Promise.all(n.map(n=>Sg(e.locksDir,n,t))),Cg(e.locksDir,t)]);return[...r.filter(e=>e!==void 0),...i]},Tg=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`},Eg=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)`,Dg={grace:`created`,lease:`lease renewed`,legacy:`acquired`,none:`observed`,unknown:`observed`},Og={grace:`from creation, while its metadata has not been published`,lease:`from the last renewal`,legacy:`from acquisition (no renewable lease)`,none:``,unknown:``},kg=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`:`, ${Dg[r]} ${Tg(t)} ago; its window is ${Tg(n)} ${Og[r]}`},Ag=(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: ${Eg(t)}`;return ng(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}${kg(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}${kg(t)}. Retry once the other refs command finishes.`},jg=(e,t)=>{if(t.stopped)return;let n=setTimeout(()=>{t.stopped||(t.inFlight=Mg(e,t))},e.intervalMs);n.unref(),t.timer=n},Mg=async(e,t)=>{try{if(await e.renew()===`lost`){t.lost=!0,t.stopped=!0;return}}catch{}jg(e,t)},Ng=e=>{let t={inFlight:Promise.resolve(),lost:!1,stopped:!1};return jg(e,t),{ownershipLost:()=>t.lost,stop:async()=>{t.stopped=!0,t.timer!==void 0&&clearTimeout(t.timer),await t.inFlight}}},Pg=/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/u,Fg=async(e,t)=>{try{await Zh(e,t)}catch(e){if(uu(e)===`ENOENT`)return`retry`;throw e}return t},Ig=async(e,t)=>{if(!await og(e))return;let n=await Fg(e,Xh());return n===`retry`?Date.now()>=t?void 0:Ig(e,t):n},Lg=async(e,t)=>{if(!await yg(e)){if(Date.now()>=t){let t=await tg(e.lockPath,Date.now());throw mu(Ag(e.name,t))}await he(100)}},Rg=async(e,t)=>{let n=await Ig(e.lockPath,t);return n===void 0?(await Lg(e,t),Rg(e,t)):n},zg=async(e,t)=>await Kh(e)===t&&(await d(e,{force:!0,recursive:!0}),!0),Bg=async e=>{try{return{ok:!0,value:await e()}}catch(e){return{error:e,ok:!1}}},Vg=async(e,t,n,r)=>{await n.stop();let i=await Bg(()=>zg(e.lockPath,t));if(!r.ok)throw r.error;if(!i.ok)throw i.error;if(n.ownershipLost()||!i.value)throw mu(`lock ${e.name} was lost while the operation was running`);return r.value},Hg=e=>e!==`.`&&e!==`..`&&Pg.test(e),Ug=e=>{if(!Hg(e))throw V(`lock name must not contain "/" or other unsafe characters — only letters, digits, and "_.-" are allowed, and it may not be "." or "..": ${e}`)},q=async(e,t,n,r)=>{Ug(t);let i=dg(e.locksDir,t);await cg(e.locksDir);let a=Date.now()+(r?.timeoutMs??1e4),o=await Rg(i,a),s=Ng({intervalMs:3e4,renew:()=>rg(i.lockPath,o)});return Vg(i,o,s,await Bg(n))},Wg=fc({directory:M().optional(),url:M().optional()}),Gg=fc({repository:mc([M(),Wg]).optional()}),Kg=/^(?:@[a-z0-9-~][a-z0-9._~-]*\/)?[a-z0-9-~][a-z0-9._~-]*$/u,qg=/* @__PURE__ */ new Set([`node_modules`,`favicon.ico`]),Jg=e=>z(`package '${e}' has no usable repository field — find the repository and run: refs add <git-url>`),Yg=e=>{let[t,n]=e.split(`/`);return n??t??e},Xg=e=>{if(e.length>214)throw B(`invalid package name: '${e}' exceeds maximum length of 214 characters`);if(!Kg.test(e))throw B(`invalid package name: '${e}' does not match npm naming rules`);let t=Yg(e);if(qg.has(t))throw B(`invalid package name: '${e}' uses a reserved name`)},Zg=e=>e.replaceAll(`/`,`%2F`),Qg=e=>typeof e==`string`?e:e?.url,$g=e=>{if(typeof e==`object`&&e?.directory){let t=pl.safeParse(e.directory);if(t.success)return t.data}},e_=e=>e instanceof Error&&(e.name===`TimeoutError`||e.name===`AbortError`),t_=e=>V(`npm registry did not answer for '${e}' within 10000ms`),n_=async(e,t)=>{try{return await e.json()}catch(e){throw e_(e)?t_(t):V(`invalid npm registry response for '${t}': not parseable JSON`)}},r_=async(e,t)=>{try{return await e(`https://registry.npmjs.org/${Zg(t)}`,{signal:AbortSignal.timeout(1e4)})}catch(e){throw e_(e)?t_(t):e}},i_=async(e,t)=>{let n=await r_(e,t);if(n.status===404)throw z(`npm package '${t}' not found`);if(n.status!==200)throw V(`failed to fetch npm package '${t}': status ${n.status}`);let r=await n_(n,t),i=Gg.safeParse(r);if(!i.success)throw V(`invalid npm package response for '${t}'`);return i.data},a_=(e,t)=>{try{return yh(e)}catch{throw Jg(t)}},o_=async(e,t)=>{Xg(t);let n=await i_(e,t),r=Qg(n.repository);if(r===void 0||r===``)throw Jg(t);let{cloneUrl:i,key:a}=a_(r,t),o=$g(n.repository);return o===void 0?{cloneUrl:i,key:a}:{cloneUrl:i,directory:o,key:a}},s_=(e,t,n)=>{let r=e instanceof RegExp?c_(e,n):e,i=t instanceof RegExp?c_(t,n):t,a=r!==null&&i!=null&&l_(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)}},c_=(e,t)=>{let n=t.match(e);return n?n[0]:null},l_=(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},u_=`\0SLASH`+Math.random()+`\0`,d_=`\0OPEN`+Math.random()+`\0`,f_=`\0CLOSE`+Math.random()+`\0`,p_=`\0COMMA`+Math.random()+`\0`,m_=`\0PERIOD`+Math.random()+`\0`,h_=new RegExp(u_,`g`),g_=new RegExp(d_,`g`),__=new RegExp(f_,`g`),v_=new RegExp(p_,`g`),y_=new RegExp(m_,`g`),b_=/\\\\/g,x_=/\\{/g,S_=/\\}/g,C_=/\\,/g,w_=/\\\./g;function T_(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function E_(e){return e.replace(b_,u_).replace(x_,d_).replace(S_,f_).replace(C_,p_).replace(w_,m_)}function D_(e){return e.replace(h_,`\\`).replace(g_,`{`).replace(__,`}`).replace(v_,`,`).replace(y_,`.`)}function O_(e,t){for(let n=0;n<t.length;n++)e.push(t[n])}function k_(e){let t=[],n=``;for(;;){let r=s_(`{`,`}`,e);if(!r){let r=e.split(`,`);return r[0]=n+r[0],O_(t,r),t}let{pre:i,body:a,post:o}=r,s=i.split(`,`);if(s[0]=n+s[0],s[s.length-1]+=`{`+a+`}`,!o.length)return O_(t,s),t;n=s.pop(),O_(t,s),e=o}}function A_(e,t={}){if(!e)return[];let{max:n=1e5,maxLength:r=4e6,maxDepth:i=1e3,maxRewrites:a=1e3}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),L_(E_(e),n,r,i,0,a,!0).map(D_)}function j_(e){return`{`+e+`}`}function M_(e){return/^-?0\d/.test(e)}function N_(e,t){return e<=t}function P_(e,t){return e>=t}function F_(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 I_(e,t,n,r){let i=e.split(/\.\./),a=[];
426
+ if(n===void 0)return`gone`;let r=/* @__PURE__ */ new Date;try{await m(n,r,r)}catch(e){if(z(e))return`gone`;throw e}return`renewed`},Fh=async(e,t)=>{let n=Mh(e,t);if(n===void 0)return{state:`absent`};try{return{mtimeMs:(await p(n)).mtimeMs,state:`ok`}}catch(e){return{state:z(e)?`absent`:`unreadable`}}},Ih=`meta.json`,Lh=e=>{try{return process.kill(e,0),!0}catch(e){return cu(e)!==`ESRCH`}},Rh=e=>{try{return JSON.parse(e)}catch{return}},zh=async e=>{try{return await s(e,`utf8`)}catch{return}},Bh=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),Vh=async e=>{try{return{state:`read`,text:await s(e,`utf8`)}}catch(e){let t=cu(e);return{state:t!==void 0&&Bh.has(t)?`missing`:`unreadable`}}},Hh=e=>{if(typeof e!=`string`)return;let t=Date.parse(e);if(!Number.isNaN(t))return t},Uh=e=>{if(typeof e!=`object`||!e)return;let{token:t}=e;if(typeof t==`string`)return t},Wh=e=>{if(!(typeof e!=`number`||!Number.isSafeInteger(e)||e<=0||e>0x7fffffff))return e},Gh=e=>{if(typeof e!=`object`||!e)return;let t=e,n=Wh(t.pid),r=Hh(t.acquired_at);if(n===void 0||r===void 0)return;let i=Uh(e);return{acquiredAtMs:r,pid:n,...i===void 0?{}:{token:i}}},Kh=async e=>{let t=await zh(v(e,Ih));if(t!==void 0)return Uh(Rh(t))},qh=async e=>{let t=await Vh(v(e,Ih));if(t.state!==`read`)return{state:t.state};let n=Gh(Rh(t.text));return n===void 0?{state:`malformed`}:{meta:n,state:`valid`}},Jh=async e=>{try{return{mtimeMs:(await p(e)).mtimeMs,state:`ok`}}catch(e){return{state:cu(e)===`ENOENT`?`gone`:`unreadable`}}},Yh=async(e,t)=>{let n=v(e,Ih),r=`${n}.tmp-${pe()}`;await h(r,t,{encoding:`utf8`,mode:384}),await u(r,n)},Xh=()=>pe(),Zh=async(e,t)=>{await Nh(e,t),await Yh(e,JSON.stringify({acquired_at:(/* @__PURE__ */ new Date()).toISOString(),pid:process.pid,token:t}))},Qh=5e3,$h=async(e,t,n)=>{if(t===`unreadable`)return{meta:t,observedAtMs:n,pidState:`unknown`,policy:`unknown`,stale:!1};let r=await Jh(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:Qh,meta:t,observedAtMs:n,pidState:`unknown`,policy:`grace`,stale:i>Qh}},eg=async(e,t,n)=>{let r=t.token===void 0?{state:`absent`}:await Fh(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`}},tg=async(e,t)=>{let n=await qh(e);if(n.state!==`valid`)return $h(e,n.state,t);let{meta:r}=n,i=await eg(e,r,t),a=!Lh(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}}},ng=e=>e.meta===`valid`&&e.pidState===`definitely-dead`&&e.token!==void 0,rg=async(e,t)=>await Kh(e)===t?await Ph(e,t)===`gone`?`lost`:`renewed`:`lost`,ig=/* @__PURE__ */ new Set([`EEXIST`,`EPERM`,`EACCES`,`EBUSY`]),ag=/* @__PURE__ */ new Set([`ENOENT`,`EPERM`,`EACCES`,`EBUSY`]),og=async e=>{try{return await a(e,{mode:448,recursive:!1}),!0}catch(e){let t=cu(e);if(t!==void 0&&ig.has(t))return!1;throw e}},sg=async(e,t)=>{try{return await u(e,t),!0}catch(e){let t=cu(e);if(t!==void 0&&ag.has(t))return!1;throw e}},cg=e=>a(e,{mode:448,recursive:!0}),lg=`.claims`,ug=`.tombstones`,dg=(e,t)=>({lockPath:v(e,t),locksDir:e,name:t}),fg=e=>v(e.locksDir,lg,e.name),pg=e=>v(e.locksDir,ug,pe()),mg=async e=>{await a(v(e,lg),{mode:448,recursive:!0}),await a(v(e,ug),{mode:448,recursive:!0})},hg=e=>og(e),gg=async e=>{try{await f(e)}catch{}},_g=async e=>{let t=pg(e);return await sg(e.lockPath,t)?t:void 0},vg=async e=>{let t=await tg(e.lockPath,Date.now());if(!ng(t)||await Kh(e.lockPath)!==t.token)return!1;let n=await _g(e);return n!==void 0&&(await d(n,{force:!0,recursive:!0}),!0)},yg=async e=>{await mg(e.locksDir);let t=fg(e);if(!await hg(t))return!1;let n=await vg(e).then(e=>({ok:!0,stolen:e})).catch(e=>({error:e,ok:!1}));if(await gg(t),!n.ok)throw n.error;return n.stolen},bg=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(z(e))return[];throw e}},xg=async e=>(await bg(e)).filter(e=>!e.name.startsWith(`.`)),Sg=async(e,t,n)=>{let r=await tg(v(e,t.name),n);if(r.policy!==`none`)return{diagnosis:r,isDirectory:t.isDir,kind:`lock`,name:t.name}},Cg=async(e,t)=>{let n=v(e,lg),r=await bg(n);return(await Promise.all(r.map(async e=>({diagnosis:await tg(v(n,e.name),t),isDirectory:e.isDir,kind:`claim`,name:e.name})))).filter(e=>e.diagnosis.policy!==`none`)},wg=async e=>{let t=Date.now(),n=await xg(e.locksDir),[r,i]=await Promise.all([Promise.all(n.map(n=>Sg(e.locksDir,n,t))),Cg(e.locksDir,t)]);return[...r.filter(e=>e!==void 0),...i]},Tg=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`},Eg=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)`,Dg={grace:`created`,lease:`lease renewed`,legacy:`acquired`,none:`observed`,unknown:`observed`},Og={grace:`from creation, while its metadata has not been published`,lease:`from the last renewal`,legacy:`from acquisition (no renewable lease)`,none:``,unknown:``},kg=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`:`, ${Dg[r]} ${Tg(t)} ago; its window is ${Tg(n)} ${Og[r]}`},Ag=(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: ${Eg(t)}`;return ng(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}${kg(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}${kg(t)}. Retry once the other refs command finishes.`},jg=(e,t)=>{if(t.stopped)return;let n=setTimeout(()=>{t.stopped||(t.inFlight=Mg(e,t))},e.intervalMs);n.unref(),t.timer=n},Mg=async(e,t)=>{try{if(await e.renew()===`lost`){t.lost=!0,t.stopped=!0;return}}catch{}jg(e,t)},Ng=e=>{let t={inFlight:Promise.resolve(),lost:!1,stopped:!1};return jg(e,t),{ownershipLost:()=>t.lost,stop:async()=>{t.stopped=!0,t.timer!==void 0&&clearTimeout(t.timer),await t.inFlight}}},Pg=/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/u,Fg=async(e,t)=>{try{await Zh(e,t)}catch(e){if(cu(e)===`ENOENT`)return`retry`;throw e}return t},Ig=async(e,t)=>{if(!await og(e))return;let n=await Fg(e,Xh());return n===`retry`?Date.now()>=t?void 0:Ig(e,t):n},Lg=async(e,t)=>{if(!await yg(e)){if(Date.now()>=t){let t=await tg(e.lockPath,Date.now());throw pu(Ag(e.name,t))}await he(100)}},Rg=async(e,t)=>{let n=await Ig(e.lockPath,t);return n===void 0?(await Lg(e,t),Rg(e,t)):n},zg=async(e,t)=>await Kh(e)===t&&(await d(e,{force:!0,recursive:!0}),!0),Bg=async e=>{try{return{ok:!0,value:await e()}}catch(e){return{error:e,ok:!1}}},Vg=async(e,t,n,r)=>{await n.stop();let i=await Bg(()=>zg(e.lockPath,t));if(!r.ok)throw r.error;if(!i.ok)throw i.error;if(n.ownershipLost()||!i.value)throw pu(`lock ${e.name} was lost while the operation was running`);return r.value},Hg=e=>e!==`.`&&e!==`..`&&Pg.test(e),Ug=e=>{if(!Hg(e))throw V(`lock name must not contain "/" or other unsafe characters — only letters, digits, and "_.-" are allowed, and it may not be "." or "..": ${e}`)},q=async(e,t,n,r)=>{Ug(t);let i=dg(e.locksDir,t);await cg(e.locksDir);let a=Date.now()+(r?.timeoutMs??1e4),o=await Rg(i,a),s=Ng({intervalMs:3e4,renew:()=>rg(i.lockPath,o)});return Vg(i,o,s,await Bg(n))},Wg=uc({directory:P().optional(),url:P().optional()}),Gg=uc({repository:fc([P(),Wg]).optional()}),Kg=/^(?:@[a-z0-9-~][a-z0-9._~-]*\/)?[a-z0-9-~][a-z0-9._~-]*$/u,qg=/* @__PURE__ */ new Set([`node_modules`,`favicon.ico`]),Jg=e=>mu(`package '${e}' has no usable repository field — find the repository and run: refs add <git-url>`),Yg=e=>{let[t,n]=e.split(`/`);return n??t??e},Xg=e=>{if(e.length>214)throw B(`invalid package name: '${e}' exceeds maximum length of 214 characters`);if(!Kg.test(e))throw B(`invalid package name: '${e}' does not match npm naming rules`);let t=Yg(e);if(qg.has(t))throw B(`invalid package name: '${e}' uses a reserved name`)},Zg=e=>e.replaceAll(`/`,`%2F`),Qg=e=>typeof e==`string`?e:e?.url,$g=e=>{if(typeof e==`object`&&e?.directory){let t=dl.safeParse(e.directory);if(t.success)return t.data}},e_=e=>e instanceof Error&&(e.name===`TimeoutError`||e.name===`AbortError`),t_=e=>V(`npm registry did not answer for '${e}' within 10000ms`),n_=async(e,t)=>{try{return await e.json()}catch(e){throw e_(e)?t_(t):V(`invalid npm registry response for '${t}': not parseable JSON`)}},r_=async(e,t)=>{try{return await e(`https://registry.npmjs.org/${Zg(t)}`,{signal:AbortSignal.timeout(1e4)})}catch(e){throw e_(e)?t_(t):e}},i_=async(e,t)=>{let n=await r_(e,t);if(n.status===404)throw mu(`npm package '${t}' not found`);if(n.status!==200)throw V(`failed to fetch npm package '${t}': status ${n.status}`);let r=await n_(n,t),i=Gg.safeParse(r);if(!i.success)throw V(`invalid npm package response for '${t}'`);return i.data},a_=(e,t)=>{try{return yh(e)}catch{throw Jg(t)}},o_=async(e,t)=>{Xg(t);let n=await i_(e,t),r=Qg(n.repository);if(r===void 0||r===``)throw Jg(t);let{cloneUrl:i,key:a}=a_(r,t),o=$g(n.repository);return o===void 0?{cloneUrl:i,key:a}:{cloneUrl:i,directory:o,key:a}},s_=(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},c_=`\0SLASH`+Math.random().toFixed(16)+`\0`,l_=`\0OPEN`+Math.random().toFixed(16)+`\0`,u_=`\0CLOSE`+Math.random().toFixed(16)+`\0`,d_=`\0COMMA`+Math.random().toFixed(16)+`\0`,f_=`\0PERIOD`+Math.random().toFixed(16)+`\0`,p_=new RegExp(c_,`g`),m_=new RegExp(l_,`g`),h_=new RegExp(u_,`g`),g_=new RegExp(d_,`g`),__=new RegExp(f_,`g`),v_=/\\\\/g,y_=/\\{/g,b_=/\\}/g,x_=/\\,/g,S_=/\\\./g;function C_(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function w_(e){return e.replace(v_,c_).replace(y_,l_).replace(b_,u_).replace(x_,d_).replace(S_,f_)}function T_(e){return e.replace(p_,`\\`).replace(m_,`{`).replace(h_,`}`).replace(g_,`,`).replace(__,`.`)}function E_(e,t){for(let n=0;n<t.length;n++)e.push(t[n])}function D_(e,t,n){if(n.remaining<0)return;let r=s_(`{`,`}`,t),i=r!==void 0&&t.indexOf(`{`)<r[0];if(n.remaining-=r&&!i?r[1]+1:e.length,!(!r||n.remaining<0))return{end:r[1],pre:e.slice(0,r[0]),body:e.slice(r[0]+1,r[1]),post:e.slice(r[1]+1),unmatched:i}}function O_(e,t){t.remaining-=e.length;let n=[];for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);r===123?n.push(t):r===125&&n.length&&n.pop()}let r=``,i=0;for(let t=0;t<n.length;t++){let a=n[t];r+=e.slice(i,a)+`\0`,i=a+1}return r+e.slice(i)}function k_(e,t){if(t.remaining-=e.length,t.remaining<0)return!1;let n=!1;for(let t=e.length-1;t>=0;t--){let r=e.charCodeAt(t);if(r===125)n=!0;else if(r===10||r===13||r===8232||r===8233)n=!1;else if(r===44&&n&&e.charCodeAt(t+1)!==44)return!0}return!1}function A_(e,t){let n=[],r=``;for(;;){let i=D_(e,e,t);if(t.remaining<0)return;if(!i){let t=e.split(`,`);return t[0]=r+t[0],E_(n,t),n}let{pre:a,body:o,post:s}=i,c=a.split(`,`);if(c[0]=r+c[0],c[c.length-1]+=`{`+o+`}`,!s.length)return E_(n,c),n;r=c.pop(),E_(n,c),e=s}}function j_(e,t){return e===void 0||isNaN(e)?t:e}function M_(e,t={}){if(!e)return[];let n=j_(t.max,1e5),r=j_(t.maxLength,4e6),i=j_(t.maxDepth,1e3),a=j_(t.maxRewrites,1e3),o=j_(t.maxSteps,2e7);return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),z_(w_(e),n,r,i,0,a,{remaining:o},!0).map(T_)}function N_(e){return`{`+e+`}`}function P_(e){return/^-?0\d/.test(e)}function F_(e,t){return e<=t}function I_(e,t){return e>=t}function L_(e,t,n,r,i,a,o){let s=[],c=0,l;e:for(let o=0;o<e.length;o++){let u=e[o]+t,d=n;a&&!u&&(l||=n.filter(e=>e),d=l);for(let e=0;e<d.length;e++){if(s.length>=r)break e;let t=u+d[e];if(c+t.length>i)break e;s.push(t),c+=t.length}}return o.remaining-=s.length,s}function R_(e,t,n,r,i){let a=e.split(/\.\./),o=[];
427
427
  /* c8 ignore start */
428
- if(i[0]===void 0||i[1]===void 0)return a;
428
+ if(a[0]===void 0||a[1]===void 0)return o;
429
429
  /* c8 ignore stop */
430
- let o=T_(i[0]),s=T_(i[1]),c=Math.max(i[0].length,i[1].length),l=i.length===3&&i[2]!==void 0?Math.max(Math.abs(T_(i[2])),1):1,u=N_;s<o&&(l*=-1,u=P_);let d=i.some(M_),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 L_(e,t,n,r,i,a,o){if(i>r)return[e];let s=[``],c=0,l=!1,u=!0;for(;;){let d=s_(`{`,`}`,e);if(!d)return F_(s,e,[``],t,n,l);let f=d.pre;if(/\$$/.test(f)){if(s=F_(s,f+`{`+d.body+`}`,[``],t,n,l&&!d.post.length),u=!1,!d.post.length)break;e=d.post;continue}let p=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(d.body),m=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(d.body),h=p||m,ee=d.body.indexOf(`,`)>=0;if(!h&&!ee){if(c<a&&d.post.match(/,(?!,).*\}/)){c++,e=d.pre+`{`+d.body+f_+d.post,o=!0;continue}return F_(s,f+`{`+d.body+`}`+d.post,[``],t,n,l)}u&&=(l=o&&!h,!1);let g;if(h)g=I_(d.body,m,t,n);else{let o=k_(d.body);if(o.length===1&&o[0]!==void 0&&(o=L_(o[0],t,n,r,i+1,a,!1).map(j_),o.length===1)){if(s=F_(s,f+o[0],[``],t,n,l&&!d.post.length),!d.post.length)break;e=d.post;continue}let c=l&&!d.post.length&&!f;for(let e=0;c&&e<s.length;e++)s[e]&&(c=!1);g=[];let u=0;outer:for(let e=0;e<o.length;e++){let s=L_(o[e],t,n,r,i+1,a,!1);for(let e=0;e<s.length;e++){let r=s[e];if(!c||r){if(g.length>=t||u+r.length>n)break outer;g.push(r),u+=r.length}}}}if(s=F_(s,f,g,t,n,l&&!d.post.length),!d.post.length)break;e=d.post}return s}const R_=(e,t)=>e===t?{t:`lit`,ch:String(e)}:{t:`class`,re:RegExp(`^[${e}-${t}]$`)},z_=(e,t)=>t.map(t=>[R_(e,e),...t]),B_=(e,t)=>{if(!e)return[[]];let n=+e[0],r=+t[0],i=e.slice(1),a=t.slice(1);if(n===r)return z_(n,B_(i,a));let o=`0`.repeat(i.length),s=`9`.repeat(i.length),c=[];i!==o&&c.push(...z_(n++,B_(i,s)));let l=a===s?[]:z_(r--,B_(o,a));return n<=r&&c.push([R_(n,r),...Array.from(i,()=>R_(0,9))]),c.push(...l),c},V_=(e,t,n)=>{if(n)return B_(String(e).padStart(n,`0`),String(t).padStart(n,`0`));let r=[];for(let n=String(e).length;n<=String(t).length;n++){let i=Math.max(e,n===1?0:10**(n-1)),a=Math.min(t,10**n-1);r.push(...B_(String(i),String(a)))}return r},H_=(e,t)=>{let n=Number(e),r=Number(t);if(!Number.isSafeInteger(n)||!Number.isSafeInteger(r))return;n>r&&([n,r]=[r,n]);let i=/^-?0\d/.test(e)||/^-?0\d/.test(t)?Math.max(e.length,t.length):0,a=[];if(n<0){let e=V_(Math.max(-r,1),-n,i&&i-1);a.push(...e.map(e=>[{t:`lit`,ch:`-`},...e]))}return r>=0&&a.push(...V_(Math.max(n,0),r,i)),a},U_={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`],"[:alpha:]":[`\\p{L}\\p{Nl}`],"[:ascii:]":[`\\x00-\\x7f`],"[:blank:]":[`\\p{Zs}\\t`],"[:cntrl:]":[`\\p{Cc}`],"[:digit:]":[`\\p{Nd}`],"[:graph:]":[`\\p{Z}\\p{C}`,!0],"[:lower:]":[`\\p{Ll}`],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}\\p{S}`],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`],"[:upper:]":[`\\p{Lu}`],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`],"[:xdigit:]":[`A-Fa-f0-9`]},W_=e=>e.replace(/[[\]\\-]/g,`\\$&`),G_=/$./,K_=(e,t,n=!1,r)=>{let i=e=>{let t=r?e.normalize(r):e;return[...t].length===1?t:e},a=t;
430
+ let s=C_(a[0]),c=C_(a[1]),l=Math.max(a[0].length,a[1].length),u=a.length===3&&a[2]!==void 0?Math.max(Math.abs(C_(a[2])),1):1,d=F_;c<s&&(u*=-1,d=I_);let f=a.some(P_),p=f?l:1,m=0;for(let e=s;d(e,c)&&o.length<n;e+=u){if(i.remaining-=p,i.remaining<0)return;let n;if(t)n=String.fromCharCode(e),n===`\\`&&(n=``);else if(n=String(e),f){let t=l-n.length;if(t>0){let r=Array(t+1).join(`0`);n=e<0?`-`+r+n.slice(1):r+n}}if(m+n.length>r)break;o.push(n),m+=n.length}return o}function z_(e,t,n,r,i,a,o,s){if(o.remaining-=16,i>r)return[e];let c=[``],l=0,u=!1,d=!0,f=e;for(;;){let p=D_(e,f,o);if(!p)return L_(c,e,[``],t,n,u,o);p.unmatched&&(f=O_(f,o));let m=p.pre,h=()=>L_(c,m+`{`+p.body+`}`+p.post,[``],t,n,u,o);if(/\$$/.test(m)){if(c=L_(c,m+`{`+p.body+`}`,[``],t,n,u&&!p.post.length,o),d=!1,!p.post.length)break;e=p.post,f=f.slice(p.end+1);continue}let ee=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(p.body),te=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(p.body),ne=ee||te,re=p.body.indexOf(`,`)>=0;if(!ne&&!re){if(l<a&&k_(p.post,o)){l++,e=p.pre+`{`+p.body+u_+p.post,f=f.slice(0,p.end)+u_+f.slice(p.end+1),s=!0;continue}return h()}d&&=(u=s&&!ne,!1);let g;if(ne){if(g=R_(p.body,te,t,n,o),!g)return h()}else{let s=A_(p.body,o);if(!s)return h();if(s.length===1&&s[0]!==void 0){if(s=z_(s[0],t,n,r,i+1,a,o,!1).map(N_),o.remaining<0)return h();
431
+ /* c8 ignore start */
432
+ if(s.length===1){let r=L_(c,m+s[0],[``],t,n,u&&!p.post.length,o);if(o.remaining<0)return h();if(c=r,!p.post.length)break;e=p.post,f=f.slice(p.end+1);continue}}let l=u&&!p.post.length&&!m;for(let e=0;l&&e<c.length;e++)c[e]&&(l=!1);g=[];let d=0;e:for(let e=0;e<s.length;e++){let c=z_(s[e],t,n,r,i+1,a,o,!1);if(o.remaining<0)return h();for(let e=0;e<c.length;e++){let r=c[e];if(!l||r){if(g.length>=t||d+r.length>n)break e;g.push(r),d+=r.length}}}}let ie=L_(c,m,g,t,n,u&&!p.post.length,o);if(o.remaining<0)return h();if(c=ie,!p.post.length)break;e=p.post,f=f.slice(p.end+1)}return c}const B_=(e,t)=>e===t?{t:`lit`,ch:String(e)}:{t:`class`,re:RegExp(`^[${e}-${t}]$`)},V_=(e,t)=>t.map(t=>[B_(e,e),...t]),H_=(e,t)=>{if(!e)return[[]];let n=+e[0],r=+t[0],i=e.slice(1),a=t.slice(1);if(n===r)return V_(n,H_(i,a));let o=`0`.repeat(i.length),s=`9`.repeat(i.length),c=[];i!==o&&c.push(...V_(n++,H_(i,s)));let l=a===s?[]:V_(r--,H_(o,a));return n<=r&&c.push([B_(n,r),...Array.from(i,()=>B_(0,9))]),c.push(...l),c},U_=(e,t,n)=>{if(n)return H_(String(e).padStart(n,`0`),String(t).padStart(n,`0`));let r=[];for(let n=String(e).length;n<=String(t).length;n++){let i=Math.max(e,n===1?0:10**(n-1)),a=Math.min(t,10**n-1);r.push(...H_(String(i),String(a)))}return r},W_=(e,t)=>{let n=Number(e),r=Number(t);if(!Number.isSafeInteger(n)||!Number.isSafeInteger(r))return;n>r&&([n,r]=[r,n]);let i=/^-?0\d/.test(e)||/^-?0\d/.test(t)?Math.max(e.length,t.length):0,a=[];if(n<0){let e=U_(Math.max(-r,1),-n,i&&i-1);a.push(...e.map(e=>[{t:`lit`,ch:`-`},...e]))}return r>=0&&a.push(...U_(Math.max(n,0),r,i)),a},G_={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`],"[:alpha:]":[`\\p{L}\\p{Nl}`],"[:ascii:]":[`\\x00-\\x7f`],"[:blank:]":[`\\p{Zs}\\t`],"[:cntrl:]":[`\\p{Cc}`],"[:digit:]":[`\\p{Nd}`],"[:graph:]":[`\\p{Z}\\p{C}`,!0],"[:lower:]":[`\\p{Ll}`],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}\\p{S}`],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`],"[:upper:]":[`\\p{Lu}`],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`],"[:xdigit:]":[`A-Fa-f0-9`]},K_=e=>e.replace(/[[\]\\-]/g,`\\$&`),q_=/$./,J_=(e,t,n=!1,r)=>{let i=e=>{let t=r?e.normalize(r):e;return[...t].length===1?t:e},a=t;
431
433
  /* c8 ignore start */
432
434
  if(e.charAt(a)!==`[`)throw Error(`not in a brace expression`);
433
435
  /* c8 ignore stop */
434
- let o=[],s=[],c=a+1,l=!1,u=!1,d=!1,f=a,p=``;WHILE:for(;c<e.length;){let t=String.fromCodePoint(e.codePointAt(c));if((t===`!`||t===`^`)&&c===a+1){d=!0,c++;continue}if(t===`]`&&l&&!u){f=c+1;break}if(l=!0,t===`\\`&&!u){u=!0,c++;continue}if(t===`[`&&!u){for(let[t,[n,r]]of Object.entries(U_))if(e.startsWith(t,c)){if(p)return[G_,e.length-a];c+=t.length,r?s.push(n):o.push(n);continue WHILE}}u=!1;let n=i(t);p?(n.codePointAt(0)>p.codePointAt(0)?o.push(W_(p)+`-`+W_(n)):n===p&&o.push(W_(n)),p=``,c+=t.length):e.startsWith(`-]`,c+t.length)?(o.push(W_(n+`-`)),c+=t.length+1):e.startsWith(`-`,c+t.length)?(p=n,c+=t.length+1):(o.push(W_(n)),c+=t.length)}if(f<c)return[G_,0];if(!o.length&&!s.length)return[G_,e.length-a];let m=`[`+(d?`^`:``)+o.join(``)+`]`,h=`[`+(d?``:`^`)+s.join(``)+`]`,ee=`^`+(o.length&&s.length?`(`+m+`|`+h+`)`:o.length?m:h);return[new RegExp(ee,n?`iu`:`u`),f-a]},q_={t:`match`,id:0},J_=e=>({t:`lit`,ch:e}),Y_=e=>e.replace(/[\\^$.*+?()[\]{}|/]/g,`\\$&`),X_=e=>RegExp(`^${Y_(e)}$`,`iu`),Z_=/* @__PURE__ */ new Map,Q_=e=>{let t=Z_.get(e);return t||(t=X_(e),Z_.size>=1e3&&Z_.clear(),Z_.set(e,t)),t},$_=(e,t)=>{if(t===e.ch)return!0;if(!e.re)return!1;let n=t.charCodeAt(0);if(n>=128)return e.re.test(t);let r=e.ascii??=/* @__PURE__ */ new Uint8Array(128);return r[n]||=e.re.test(t)?1:2,r[n]===1},ev=(e,t,n,r,i)=>{let a=[];for(let o=0;o<e.length;){let s=String.fromCodePoint(e.codePointAt(o));if(i){let t=s===`\\`&&e.startsWith(i,o+1)?1:0;if(t||s===i){let n=o+t+i.length,r=e.indexOf(i,n),s=/^(-?\d+)\.\.(-?\d+)$/.exec(e.slice(n,r)),c=r!==-1&&s&&H_(s[1],s[2]);if(c){a.push({t:`ext`,type:`@`,alts:c}),o=r+i.length;continue}}}if(s===`\\`){let t=e.codePointAt(o+1),n=t===void 0?s:String.fromCodePoint(t);a.push(J_(n)),o+=1+n.length}else{if(s===`[`){let[n,i]=K_(e,o,t,r);if(i){a.push({t:`class`,re:n}),o+=i;continue}}!n&&`!?+*@`.includes(s)&&e[o+1]===`(`?(a.push({t:`open`,type:s}),o+=2):(a.push(!n&&s===`|`?{t:`bar`}:!n&&s===`)`?{t:`close`}:s===`*`?{t:`star`}:s===`?`?{t:`any`}:J_(s)),o+=s.length)}}return a},tv=e=>{let t=/* @__PURE__ */ new Map,n=[];return e.forEach((e,r)=>{e.t===`open`?n.push(r):e.t===`close`&&n.length&&t.set(n.pop(),r)}),t},nv=(e,t,n,r,i)=>{let a=[],o=[a];for(let s=n;s<r;s++){let n=e[s],r=t.get(s);if(n.t===`open`&&r!==void 0){let i=nv(e,t,s+1,r,!1);a.push({t:`ext`,type:n.type,alts:i}),s=r}else n.t===`bar`&&!i?o.push(a=[]):n.t===`open`?a.push(J_(n.type),J_(`(`)):n.t===`bar`?a.push(J_(`|`)):n.t===`close`?a.push(J_(`)`)):a.push(n)}return o},rv=(e,t)=>{let n=[],r=``,i=()=>{for(let e of r.normalize(t))n.push(J_(e));r=``};for(let a of e)a.t===`lit`?r+=a.ch:(i(),n.push(a.t===`ext`?{...a,alts:a.alts.map(e=>rv(e,t))}:a));return i(),n},iv=(e,t)=>{let n=1,r=e=>({t:`split`,id:n++,out:e}),i=(e,t)=>e.reduceRight((e,t)=>a(t,e),t),a=(e,a)=>{switch(e.t){case`lit`:let r=t?Q_(e.ch):void 0;return{t:`lit`,id:n++,ch:e.ch,re:r,next:a};case`any`:case`star`:return{t:e.t,id:n++,next:a};case`class`:return{t:`class`,id:n++,re:e.re,next:a}}let o=t=>e.alts.map(e=>i(e,t));switch(e.type){case`@`:return r(o(a));case`?`:return r([a,...o(a)]);case`!`:return{t:`neg`,id:n++,sub:r(o(q_)),next:a}}let s=r([]),c=r(o(s));return s.out.push(a,c),e.type===`*`?s:c};return[i(e,q_),n]},av=e=>{let t=[],n=/* @__PURE__ */ new Set,r=e=>e.t===`match`?`match`:String(e.id),i=(e,a)=>{if(e.t===`match`||n.has(e))return;n.add(e);let o=n=>t.push(`${a}${e.id}: ${n}`);switch(e.t){case`split`:o(`split -> ${e.out.map(r).join(`, `)}`);for(let t of e.out)i(t,a);return;case`neg`:return o(`!(${r(e.sub)}) -> ${r(e.next)}`),i(e.sub,a+` `),i(e.next,a);case`lit`:o(`${JSON.stringify(e.ch)} -> ${r(e.next)}`);break;case`class`:o(`${e.re} -> ${r(e.next)}`);break;default:o(`${e.t===`any`?`?`:`*`} -> ${r(e.next)}`)}i(e.next,a)};return i(e,``),[`start -> ${r(e)}`,...t].join(`
435
- `)};var ov=class{gen;threads=[];match=!1;runs=[];ids=[];constructor(e){this.gen=e}get dead(){return!this.threads.length&&!this.match&&!this.runs.length}};const sv=(e,t)=>e.ids.length!==t.ids.length||e.runs.length!==t.runs.length||e.ids.some((e,n)=>e!==t.ids[n])?!1:e.runs.every(e=>t.runs.some(t=>t.neg===e.neg&&sv(t.state,e.state))),cv=e=>({has:new Float64Array(e),seen:new Float64Array(e),gen:0});var lv=class{dots;dotStart;#e;constructor(e,t,n){this.dots=e,this.dotStart=t,this.#e=n}state(){return new ov(++this.#e.gen)}done(e){return e.ids=e.threads.map(e=>e.id).sort((e,t)=>e-t),e.match&&e.ids.unshift(q_.id),e}#t(e,t){let{seen:n}=this.#e;return n[t.id]!==e.gen&&(n[t.id]=e.gen,!0)}#n(e,t){let{has:n}=this.#e;return n[t.id]!==e.gen&&(n[t.id]=e.gen,e.threads.push(t),!0)}restricted(e,t){return t&&(this.dots||this.dotStart&&e===0)}add(e,t,n,r){switch(t.t){case`split`:if(!this.#t(e,t))return;for(let i of t.out)this.add(e,i,n,r);return;case`neg`:if(!this.#t(e,t))return;let i=this.state();return this.add(i,t.sub,n,!1),this.done(i),this.addRun(e,{t:`run`,neg:t,state:i},n,r);case`star`:if(this.restricted(n,r))return;this.#n(e,t)&&this.add(e,t.next,n,r);return;case`match`:e.match=!0;return;default:this.#n(e,t)}}addRun(e,t,n,r){for(let n of e.runs)if(n.neg===t.neg&&sv(n.state,t.state))return;e.runs.push(t),t.state.match||this.add(e,t.neg.next,n,r)}step(e,t,n,r){let i=this.state();for(let a of e.threads)switch(a.t){case`lit`:$_(a,t)&&this.add(i,a.next,n+1,r);break;case`any`:this.restricted(n,r)||this.add(i,a.next,n+1,r);break;case`class`:!this.restricted(n,r)&&a.re.test(t)&&this.add(i,a.next,n+1,r);break;case`star`:this.restricted(n,r)||this.add(i,a,n+1,r)}if(!this.restricted(n,r))for(let a of e.runs){if(a.state.dead){this.addRun(i,a,n+1,r);continue}let e=this.step(a.state,t,n,!1);this.addRun(i,{t:`run`,neg:a.neg,state:e},n+1,r)}return this.done(i)}};const uv=e=>{let t=e.ids.join();return e.runs.length?`${t}|${e.runs.map(e=>`${e.neg.id}(${uv(e.state)})`).sort().join(`|`)}`:t};var dv=class{#e;#t=/* @__PURE__ */ new Map;#n=0;#r;#i;#a;#o;constructor(e,t){this.#e=e,this.#a=new lv(!1,!1,t),this.#o=new lv(!1,!0,t)}#s(e){return{state:e,match:e.match,dead:e.dead,next:/* @__PURE__ */ new Map}}#c(e){let t=uv(e),n=this.#t.get(t);if(n)return n;this.#n>262144&&this.#l();let r=this.#s(e);return this.#t.set(t,r),this.#n+=t.length+1,r}#l(){this.#t.clear(),this.#n=0,this.#r=void 0,this.#i=void 0}start(e){if(e){if(this.#i)return this.#i;let e=this.#o.state();return this.#o.add(e,this.#e,0,!0),this.#i=this.#s(this.#o.done(e))}if(this.#r)return this.#r;let t=this.#a.state();return this.#a.add(t,this.#e,0,!0),this.#r=this.#c(this.#a.done(t))}next(e,t){let n=t.charCodeAt(0),r=n<128?void 0:e.next.get(t);if(r)return r;let i=e===this.#i?this.#c(this.#o.step(e.state,t,0,!0)):this.#c(this.#a.step(e.state,t,1,!0));return n<128?(e.ascii||(e.ascii=Array(128),this.#n+=128),e.ascii[n]=i):e.next.set(t,i),this.#n++,i}};const fv=e=>{let t=[];for(let n=e;n.t!==`match`;n=n.next){if(n.t===`split`||n.t===`neg`)return;t.push(n)}return t},pv=(e,t,n,r)=>{let i=0,a=n,o=-1,s=0;for(;a<r;){let n=e[i];if(n?.t===`star`){o=i++,s=a;continue}let r=t[a];if(n&&(n.t===`any`||n.t===`lit`&&$_(n,r)||n.t===`class`&&n.re.test(r)))i++,a++;else{if(o===-1)return!1;i=o+1,a=++s}}for(;e[i]?.t===`star`;)i++;return i===e.length},mv=e=>{let t=0,n=0;for(let r of e){let[e,i]=hv(r);t+=e,n+=i}return[t,n]},hv=e=>{if(e.t===`star`)return[0,1/0];if(e.t!==`ext`)return[1,1];if(e.type===`!`)return[0,1/0];let t=e.alts.map(mv),n=Math.min(...t.map(e=>e[0])),r=Math.max(...t.map(e=>e[1])),i=r===0?0:1/0;return e.type===`@`?[n,r]:e.type===`?`?[0,r]:e.type===`*`?[0,i]:[n,i]},gv=(e,t,n)=>{for(let r=0;r<e.length;r++)if(!$_(e[r],t[n+r]))return!1;return!0},_v=/[/\ud800-\udfff]/,vv=/[\ud800-\udfff]/,yv=e=>vv.test(e)?[...e]:e,bv=e=>{if(e.includes(`/`))throw Error(`can only match a single path portion, got: `+e)};var xv=class{pattern;options;#e;#t;#n;#r;#i;#a=!1;#o;#s;#c=!1;#l=0;#u=1/0;#d=[];#f=[];#p;#m;#h=!1;#g;#_;constructor(e,t={}){if(e.includes(`/`))throw Error(`can only match a single path portion, got pattern: `+e);this.pattern=e,this.options=t;let{nocase:n=!1,noext:r=!1,normalize:i}=t;this.#_=i===!0?`NFC`:i||void 0;let a=/^[?*+@]\(\)$/.test(e),o=ev(e,n,r||a,this.#_,t.rangeMark),[s]=nv(o,tv(o),0,o.length,!0);this.#_&&(s=rv(s,this.#_));let[c,l]=iv(s,n);if(this.#e=c,this.#t=l,s.every(e=>e.t===`lit`))this.#i=s.map(e=>e.ch).join(``),this.#a=n;else{let e=e=>e.t===`lit`?n?{ch:e.ch,re:Q_(e.ch)}:{ch:e.ch}:void 0;for(let t of s){let n=e(t);if(!n)break;this.#d.push(n)}for(let t=s.length-1;t>=0;t--){let n=e(s[t]);if(!n)break;this.#f.unshift(n)}this.#h=!!(this.#d.length||this.#f.length),n||(this.#p=this.#d.map(e=>e.ch).join(``),this.#m=this.#f.map(e=>e.ch).join(``)),this.#s=fv(this.#e)?.slice(this.#d.length,-this.#f.length||void 0),this.#c=!!this.#s?.every(e=>e.t===`star`||e.t===`any`);let[t,r]=mv(s);this.#l=t,this.#u=r}}test(e){return this.#_?(bv(e),this.#v(e.normalize(this.#_))):_v.test(e)?(bv(e),this.#v(e,[...e])):this.#v(e,e)}testUnchecked(e){return this.#v(this.#_?e.normalize(this.#_):e)}#v(e,t){if(this.#i!==void 0)return this.#a?(this.#o??=X_(this.#i)).test(e):e===this.#i;let n=this.#l,r=this.#u;if(t===void 0){let i=e.length,a=i+1>>1;if(i<n||a>r)return!1;(a<n||i>r)&&(t=yv(e))}if(t!==void 0&&(t.length<n||t.length>r))return!1;let i=this.#d.length;if(this.#h){if(this.#p!==void 0&&this.#m!==void 0){if(!e.startsWith(this.#p)||!e.endsWith(this.#m))return!1}else{t??=yv(e);let n=t.length-this.#f.length;if(!gv(this.#d,t,0)||!gv(this.#f,t,n))return!1}}let a=!this.options.dot&&e.startsWith(`.`);if(this.#s){if(e===`.`||e===`..`||a&&!i)return!1;if(this.#c)return!0;t??=yv(e);let n=t.length-this.#f.length;return pv(this.#s,t,i,n)}if(t??=yv(e),e===`.`||e===`..`){this.#n??=cv(this.#t);let e=this.#r??=new lv(!0,!1,this.#n),n=e.state();e.add(n,this.#e,0,!0);let r=e.done(n);for(let n=0;n<t.length;n++)r=e.step(r,t[n],n,!0);return r.match}this.#n??=cv(this.#t);let o=this.#g??=new dv(this.#e,this.#n),s=o.start(a),c=t===e;for(let n=0;n<t.length;n++){if(s.dead)return!1;let r=c?e.charCodeAt(n):t[n].charCodeAt(0);s=s.ascii?.[r]??o.next(s,t[n])}return s.match}toString(){return av(this.#e)}};const Sv=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},Cv=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),wv=(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`),J=(e,t,n={})=>(Sv(t),!n.nocomment&&t.charAt(0)===`#`?!1:Ev(t,n).match(e)),Tv=/* @__PURE__ */ new Map,Ev=(e,t)=>{let n=e+`\0`+JSON.stringify(t),r=Tv.get(n);return r?Tv.delete(n):(r=new Xv(e,{...t}),Tv.size>=256&&Tv.delete(Tv.keys().next().value)),Tv.set(n,r),r},Dv=typeof process==`object`&&process?process.env?.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,Ov={win32:{sep:`\\`},posix:{sep:`/`}};J.sep=Dv===`win32`?Ov.win32.sep:Ov.posix.sep;const Y=Symbol(`globstar **`);J.GLOBSTAR=Y,J.filter=(e,t={})=>n=>J(n,e,t);const kv=(e,t={})=>Object.assign({},e,t);J.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return J;let t=J;return Object.assign((n,r,i={})=>t(n,r,kv(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,kv(e,n))}static defaults(n){return t.defaults(kv(e,n)).Minimatch}},unescape:(n,r={})=>t.unescape(n,kv(e,r)),escape:(n,r={})=>t.escape(n,kv(e,r)),filter:(n,r={})=>t.filter(n,kv(e,r)),defaults:n=>t.defaults(kv(e,n)),braceExpand:(n,r={})=>t.braceExpand(n,kv(e,r)),match:(n,r,i={})=>t.match(n,r,kv(e,i)),sep:t.sep,GLOBSTAR:Y})};const Av=(e,t={})=>(Sv(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:A_(e,{max:t.braceExpandMax}));J.braceExpand=Av;const jv=/(?<![\\$])\{(-?\d+)\.\.(-?\d+)\}/g;J.match=(e,t,n={})=>{let r=new Xv(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const Mv=/[?*]|[+@!]\(.*?\)|\[|\]/,Nv=(e,t)=>{let n=t+1;(e.charAt(n)===`!`||e.charAt(n)===`^`)&&n++;let r=!1;for(;n<e.length;n++){let t=e.charAt(n);if(t===`]`&&r)return n;r=!0,t===`\\`&&n++}return-1},Pv=(e,t)=>{if(!t&&(e===`+()`||e===`@()`))return e;let n=``;for(let r=0;r<e.length;r++){let i=e.charAt(r);if(i===`\\`)n+=e.charAt(++r)||i;else if(i===`*`||i===`?`)return;else if(i===`[`){let t=Nv(e,r);if(t===-1){n+=i;continue}let a=e.slice(r+1,t);if(a.startsWith(`\\`)&&(a=a.slice(1)),[...a].length!==1||`!^`.includes(e.charAt(r+1)))return;n+=a,r=t}else if(!t&&`+@!`.includes(i)&&e.charAt(r+1)===`(`&&e.includes(`)`,r+2))return;else n+=i}return n},Fv=e=>{if(/^[?*+@]\(\)$/.test(e)||e.includes(`[:`))return!1;let t=0;for(let n=0;n<e.length;n++){let r=e.charAt(n);if(r===`\\`){if(++n===e.length)return!1}else if(r===`[`){let t=Nv(e,n);t!==-1&&(n=t)}else if(`+@!?*`.includes(r)&&e.charAt(n+1)===`(`)t++,n++;else if(r===`)`){if(!t--)return!1}else if(r===`|`&&!t)return!1}return!t};let Iv,Lv;const Rv=(e,t)=>typeof e==`string`?t===e:t!==``&&e.testUnchecked(t),zv=(e,t,n,r,i)=>Rv(e,t)?n:r!==void 0&&Rv(e,r)?i:-1,Bv=e=>e===`.`||e===`..`,Vv=e=>typeof e==`string`&&/^[a-z]:$/i.test(e),Hv=e=>typeof e==`string`&&/^unc$/i.test(e),Uv=e=>{if(e[0]!==``||e[1]!==``)return-1;let t=e[2]===`?`?Hv(e[3])?4:-1:2,n=e[t],r=e[t+1];return t!==-1&&n!==void 0&&n!==``&&n!==Y&&r!==void 0&&r!==``&&r!==Y?t:-1},Wv=(e,t)=>!Bv(e)&&(t||!e.startsWith(`.`)),Gv=(e,t,n,r,i)=>{for(let a=t;a<n;){if(e.charCodeAt(a)===46){if(!r)return!0;let t=e.charCodeAt(a+1)===46?a+2:a+1;if(t>=n||Kv(e.charCodeAt(t),i))return!0}let t=qv(e,a,i);if(t===-1)return!1;for(a=t+1;a<n&&Kv(e.charCodeAt(a),i);)a++}return!1},Kv=(e,t)=>t===`/`?e===47:t===`\\`?e===92:e===47||e===92,qv=(e,t,n)=>{if(n!==`both`)return e.indexOf(n,t);let r=e.indexOf(`/`,t),i=e.indexOf(`\\`,t);return r===-1?i:i===-1?r:Math.min(r,i)},Jv=(e,t,n)=>n===`both`?Math.max(e.lastIndexOf(`/`,t),e.lastIndexOf(`\\`,t)):e.lastIndexOf(n,t),Yv={};var Xv=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;#e;#t;#n;#r;#i=[];#a=[];#o=[];#s=/* @__PURE__ */ new Map;#c=!1;#l;#u=/* @__PURE__ */ new WeakMap;constructor(e,t={}){Sv(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||Dv,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.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.#e=!this.preserveMultipleSlashes,this.#n=(t.optimizationLevel??1)>=2;let n=t.normalize;this.#r=n===!0?`NFC`:n||void 0,this.make();let r=this.set.map(e=>this.#f(e));this.#o=this.set.map((e,t)=>this.#e&&e.length-1>r[t]),this.#i=this.set.map((e,t)=>{let n=this.#o[t]?e.length-1:e.length,i=e.slice(r[t]+1,n).filter(e=>typeof e==`string`&&!!e);return[...new Set(i)]}),this.#t=this.#i.some(e=>e.length),this.#a=this.set.map((e,n)=>{let[i,a,o]=e;if(this.#o[n]&&e.length===2&&i===Y&&a!==Y)return`tail`;if(this.#o[n]&&t.matchBase&&e.length===1&&i!==Y&&i!==``)return`base`;if(this.#e&&r[n]===-1){if(e.length===3&&i===Y&&o===Y&&a!==Y&&a!==``&&this.maxGlobstarRecursion>0)return`mid`;if(e.length===2&&a===Y&&i!==Y&&i!==``)return`head`}})}#d(e){return this.#r?e.normalize(this.#r):e}#f(e){if(!this.isWindows)return-1;if(Vv(e[0]))return 0;if(e[0]===``&&e[1]===``&&e[2]===`?`&&Vv(e[3]))return 3;let t=Uv(e);return t===-1?-1:t+1}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}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.#w())];let n=this.globSet.map(e=>this.#T(e));this.globParts=this.preprocess(n),this.#c=!0;let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[2]===`?`&&Hv(e[3])?6:4,n=e[0]===``&&e[1]===``&&(e[2]===`?`||!Mv.test(e[2]))&&e.slice(3,t).every(e=>!Mv.test(e)),r=/^[a-z]:/i.test(e[0]);if(n)return[...e.slice(0,t).map(e=>this.#d(e)),...e.slice(t).map(e=>this.parse(e))];if(r)return[this.#d(e[0]),...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(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]===`?`&&(Vv(t[3])||Hv(this.globParts[e][3]))&&(Hv(this.globParts[e][3])&&(t[3]=`UNC`),t[2]=`?`)}t.noext||this.mergeRows(),this.#c=!1,this.set.forEach((e,t)=>{for(let n=0;n<e.length;n++)e[n]===Yv&&(e[n]=this.parse(this.globParts[t][n]))})}mergeRows(){let e=!0;for(;e;){e=!1;let t=Math.max(0,...this.set.map(e=>e.length));for(let n=0;n<t;n++){let t=/* @__PURE__ */ new Map;this.set.forEach((e,r)=>{if(!(e[n]instanceof xv||e[n]===Yv)||!Fv(this.globParts[r][n]))return;let i=[...this.globParts[r]];i[n]=``;let a=`${e.length}/${i.join(`/`)}`,o=t.get(a);o?o.push(r):t.set(a,[r])});let r=/* @__PURE__ */ new Set;for(let e of t.values()){if(e.length<2)continue;let[t,...i]=e,a=`@(${e.map(e=>this.globParts[e][n]).join(`|`)})`;this.globParts[t][n]=a,this.set[t][n]=this.parse(a);for(let e of i)r.add(e)}r.size&&(e=!0,this.set=this.set.filter((e,t)=>!r.has(t)),this.globParts=this.globParts.filter((e,t)=>!r.has(t)))}}}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=>{let t=this.#f(e)+1;return e=e.reduce((e,n)=>{let r=e[e.length-1];return n===`**`&&r===`**`?e:n===`..`&&e.length>t&&r&&r!==`..`&&r!==`.`&&r!==`**`?(e.pop(),e):(e.push(n),e)},[]),e.length===0?[``]:e})}#p(e){let t=!this.isWindows||!e.includes(`\\`)?`/`:e.includes(`/`)?`both`:`\\`,n=this.#e?0:-1,r=``,i=0,a,o=0,s=!!this.options.dot;ROWS:for(let c=0;c<this.set.length;c++){let l=this.set[c],u=l[l.length-1],d=n!==-1&&this.#o[c]&&u!==Y;if(d&&n===0){let s=Jv(e,e.length,t);if(i=s+1,r=e.slice(i),r===``&&s>=0){let n=s;for(;n>0&&Kv(e.charCodeAt(n-1),t);)n--;o=n===0?0:Jv(e,n-1,t)+1,a=e.slice(o,n)}let c=this.#n&&(Bv(r)||r===``&&a!==void 0&&Bv(a));n=c?-1:1,d=!c}let f=-1;if(d&&typeof u==`string`&&(f=zv(u,r,i,a,o),f===-1))continue;if(this.#t){for(let t of this.#i[c])if(!e.includes(t))continue ROWS}if(d&&typeof u==`object`&&(f=zv(u,r,i,a,o),f===-1))continue;let p=this.#a[c];if(p===`base`&&d)return`yes`;if(p===`tail`&&d){if(this.#n&&Gv(e,0,f,!0,t))return`maybe`;if(!Gv(e,0,f,s,t))return`yes`}else if(p===`mid`||p===`head`){let n=this.#h(e,l,p===`head`,s,t);if(n!==`no`)return n}else return`maybe`}return`no`}#m(e,t,n){let r=!!this.options.dot,i=e.length;if(n===`head`){if(i<2||!Rv(t[0],e[0]))return!1;for(let t=1;t<i;t++)if(!Wv(e[t],r))return!1;return!0}let a=t[1];if(n===`tail`){let t=i-1;if(!Rv(a,e[t])&&(e[t]!==``||i===1||!Rv(a,e[--t])))return!1;for(let n=0;n<t;n++)if(!Wv(e[n],r))return!1;return!0}for(let t=0;t<i;t++){if(Rv(a,e[t])&&t+1<i){let n=t+1;for(;n<i&&Wv(e[n],r);)n++;if(n===i)return!0}if(!Wv(e[t],r))return!1}return!1}#h(e,t,n,r,i){if(this.#n&&Gv(e,0,e.length,!0,i))return`maybe`;let a=t[+!n],o=0;for(let t=qv(e,o,i);t!==-1;t=qv(e,o,i)){let s=t+1;for(;s<e.length&&Kv(e.charCodeAt(s),i);)s++;if((typeof a==`string`?t-o===a.length&&e.startsWith(a,o):t>o&&a.testUnchecked(e.slice(o,t)))&&!Gv(e,s,e.length,r,i))return`yes`;if(n||Gv(e,o,s,r,i))return`no`;o=s}return`no`}#g(e){let t=Iv;return t?.f===e&&t.isWindows===this.isWindows&&t.preserveMultipleSlashes===this.preserveMultipleSlashes&&t.normalize===this.#r?t:void 0}#_(e){let{isWindows:t,preserveMultipleSlashes:n}=this,r=this.#T(t?e.split(`\\`).join(`/`):e),i=this.#r;return i&&(r=r.map(e=>e.normalize(i))),Iv={f:e,isWindows:t,preserveMultipleSlashes:n,normalize:i,parts:r},Iv}#v(e){let t=[...e],n=!1;do{if(n=!1,!this.preserveMultipleSlashes){for(let e=1;e<t.length-1;e++){let r=t[e];e===1&&r===``&&t[0]===``||r!==`.`&&r!==``||(n=!0,t.splice(e,1),e--)}t[0]===`.`&&t.length===2&&(t[1]===`.`||t[1]===``)&&(n=!0,t.pop())}let e=this.#f(t)+1,r=e;for(;(r=t.indexOf(`..`,r+1))!==-1;){let i=t[r-1];i&&i!==`.`&&i!==`..`&&i!==`**`&&(n=!0,t.splice(r-1,2),r=Math.max(r-2,e))}}while(n);return t.length===0?[``]:t}firstPhasePreProcess(e){let{braceExpandMax:t=1e5}=this.options,n=0,r=!1;do{r=!1;for(let i of e){let a=-1;for(;(a=i.indexOf(`**`,a+1))!==-1;){let o=a;for(;i[o+1]===`**`;)o++;o>a&&i.splice(a+1,o-a);let s=i[a+1],c=i[a+2],l=i[a+3];if(s!==`..`||!c||c===`.`||c===`..`||!l||l===`.`||l===`..`)continue;let u=i.length-1;if(e.length>=t||n+u>1e6)throw RangeError(`optimizationLevel 2: too many patterns from '**/..'`);r=!0,i.splice(a,1);let d=i.slice(0);d[a]=`**`,n+=u,e.push(d),a--}if(!this.preserveMultipleSlashes){for(let e=1;e<i.length-1;e++){let t=i[e];e===1&&t===``&&i[0]===``||t!==`.`&&t!==``||(r=!0,i.splice(e,1),e--)}i[0]===`.`&&i.length===2&&(i[1]===`.`||i[1]===``)&&(r=!0,i.pop())}let o=this.#f(i)+1,s=o;for(;(s=i.indexOf(`..`,s+1))!==-1;){let e=i[s-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){r=!0;let e=s===1&&i[s+1]===`**`?[`.`]:[];i.splice(s-1,2,...e),i.length===0&&i.push(``),s=Math.max(s-2,o)}}}}while(r);return e}secondPhasePreProcess(e){let t=/* @__PURE__ */ new Set,n=e.filter(e=>{let n=e.join(`/`);return!t.has(n)&&(t.add(n),!0)}),r=/* @__PURE__ */ new Map;for(let e of n){let t=[];for(let n=0;n<e.length;n++)e[n]===`*`&&t.push(n);t.length&&r.set(t.join(`,`),t)}if(!r.size||n.length*r.size>1e5)return n;let{dot:i}=this.options;return n.filter(e=>{for(let n of r.values()){if(n[n.length-1]>=e.length)continue;let r=[...e],a=!0,o=!1;for(let t of n){let n=e[t];if(n!==`*`){if(!n||n===`**`||!i&&n.startsWith(`.`)){a=!1;break}r[t]=`*`,o=!0}}if(a&&o&&t.has(r.join(`/`)))return!1}return!0})}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}#y(e,t,n,r){let i=0,a=0,o=this.isWindows?Uv(t):-1,s=o===-1?-1:Uv(n);if(s!==-1){let e=n[s],r=n[s+1];typeof e!=`string`||typeof r!=`string`?(i=o,a=s):t[o].toLowerCase()===e.toLowerCase()&&t[o+1].toLowerCase()===r.toLowerCase()&&(i=o+2,a=s+2)}else if(this.isWindows){let t=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),r=!t&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),o=typeof n[0]==`string`&&/^[a-z]:$/i.test(n[0]),s=!o&&n[0]===``&&n[1]===``&&n[2]===`?`&&typeof n[3]==`string`&&/^[a-z]:$/i.test(n[3]),c=r?3:t?0:void 0,l=s?3:o?0:void 0;if(typeof c==`number`&&typeof l==`number`){let[t,r]=[e[c],n[l]];t.toLowerCase()===r.toLowerCase()&&(a=l+1,i=c+1)}}return e=t,n.includes(Y)?this.#b(e,n,r,i,a):this.#C(e,n,r,i,a)}#b(e,t,n,r,i){let{head:a,body:o,tail:s,segments:c}=this.#x(t,n,i);if(a.length){let t=r+a.length;if(!this.#C(e,a,n,r,0,t))return!1;r+=a.length,i+=a.length}let l=0;if(s.length){if(s.length+r>e.length)return!1;let t=e.length-s.length;if(this.#C(e,s,n,t,0))l=s.length;else{if(e[e.length-1]!==``||r+s.length===e.length||(t--,!this.#C(e,s,n,t,0)))return!1;l=s.length+1}}if(!o.length){let t=!!l;for(let n=r;n<e.length-l;n++){let r=String(e[n]);if(t=!0,r===`.`||r===`..`||!this.options.dot&&r.startsWith(`.`))return!1}return n||t}return!!this.#S(e,c,e.length-l,r,0,n,0,!!l,/* @__PURE__ */ new Set)}#x(e,t,n){let r=this.#u.get(e);r||(r=[],this.#u.set(e,r));let i=n*2+ +!!t,a=r[i];if(a)return a;let o=e.indexOf(Y,n),s=e.lastIndexOf(Y),c=e.slice(n,o),l=e.slice(o+1,t?void 0:s),u=t?[]:e.slice(s+1),d=[[[],0]],f=d[0],p=0,m=[0];for(let e of l)e===Y?(m.push(p),f=[[],0],d.push(f)):(f[0].push(e),p++);d.forEach((e,t)=>{e[1]=p-m[t]});let h={head:c,body:l,tail:u,segments:d};return r[i]=h,h}#S(e,t,n,r,i,a,o,s,c){let l=t[i];if(!l){if(a)return r>=n||r===n-1&&e[r]===``;for(let t=r;t<n;t++){s=!0;let n=e[t];if(n===`.`||n===`..`||!this.options.dot&&n.startsWith(`.`))return!1}return s}let[u,d]=l,f=a?n:n-d;for(;r<=f;){let l=i*(e.length+1)+r;if(c.has(l))return!1;if(c.add(l),this.#C(e,u,a,r,0,r+u.length)&&o<this.maxGlobstarRecursion){let l=this.#S(e,t,n,r+u.length,i+1,a,o+1,s,c);if(l!==!1)return l}if(r===f)break;let d=e[r];if(d===`.`||d===`..`||!this.options.dot&&d.startsWith(`.`))return!1;r++}return a||null}#C(e,t,n,r,i,a=e.length){let o,s,c,l;for(o=r,s=i,l=Math.min(a,e.length),c=t.length;o<l&&s<c;o++,s++){let n=t[s],r=e[o];
436
+ let o=[],s=[],c=a+1,l=!1,u=!1,d=!1,f=a,p=``;e:for(;c<e.length;){let t=String.fromCodePoint(e.codePointAt(c));if((t===`!`||t===`^`)&&c===a+1){d=!0,c++;continue}if(t===`]`&&l&&!u){f=c+1;break}if(l=!0,t===`\\`&&!u){u=!0,c++;continue}if(t===`[`&&!u){for(let[t,[n,r]]of Object.entries(G_))if(e.startsWith(t,c)){if(p)return[q_,e.length-a];c+=t.length,r?s.push(n):o.push(n);continue e}}u=!1;let n=i(t);p?(n.codePointAt(0)>p.codePointAt(0)?o.push(K_(p)+`-`+K_(n)):n===p&&o.push(K_(n)),p=``,c+=t.length):e.startsWith(`-]`,c+t.length)?(o.push(K_(n+`-`)),c+=t.length+1):e.startsWith(`-`,c+t.length)?(p=n,c+=t.length+1):(o.push(K_(n)),c+=t.length)}if(f<c)return[q_,0];if(!o.length&&!s.length)return[q_,e.length-a];let m=`[`+(d?`^`:``)+o.join(``)+`]`,h=`[`+(d?``:`^`)+s.join(``)+`]`,ee=`^`+(o.length&&s.length?`(`+m+`|`+h+`)`:o.length?m:h);return[new RegExp(ee,n?`iu`:`u`),f-a]},Y_={t:`match`,id:0},X_=e=>({t:`lit`,ch:e}),Z_=e=>e.replace(/[\\^$.*+?()[\]{}|/]/g,`\\$&`),Q_=e=>RegExp(`^${Z_(e)}$`,`iu`),$_=/* @__PURE__ */ new Map,ev=e=>{let t=$_.get(e);return t||(t=Q_(e),$_.size>=1e3&&$_.clear(),$_.set(e,t)),t},tv=(e,t)=>{if(t===e.ch)return!0;if(!e.re)return!1;let n=t.charCodeAt(0);if(n>=128)return e.re.test(t);let r=e.ascii??=/* @__PURE__ */ new Uint8Array(128);return r[n]||=e.re.test(t)?1:2,r[n]===1},nv=(e,t,n,r,i)=>{let a=[];for(let o=0;o<e.length;){let s=String.fromCodePoint(e.codePointAt(o));if(i){let t=s===`\\`&&e.startsWith(i,o+1)?1:0;if(t||s===i){let n=o+t+i.length,r=e.indexOf(i,n),s=/^(-?\d+)\.\.(-?\d+)$/.exec(e.slice(n,r)),c=r!==-1&&s&&W_(s[1],s[2]);if(c){a.push({t:`ext`,type:`@`,alts:c}),o=r+i.length;continue}}}if(s===`\\`){let t=e.codePointAt(o+1),n=t===void 0?s:String.fromCodePoint(t);a.push(X_(n)),o+=1+n.length}else{if(s===`[`){let[n,i]=J_(e,o,t,r);if(i){a.push({t:`class`,re:n}),o+=i;continue}}!n&&`!?+*@`.includes(s)&&e[o+1]===`(`?(a.push({t:`open`,type:s}),o+=2):(a.push(!n&&s===`|`?{t:`bar`}:!n&&s===`)`?{t:`close`}:s===`*`?{t:`star`}:s===`?`?{t:`any`}:X_(s)),o+=s.length)}}return a},rv=e=>{let t=/* @__PURE__ */ new Map,n=[];return e.forEach((e,r)=>{e.t===`open`?n.push(r):e.t===`close`&&n.length&&t.set(n.pop(),r)}),t},iv=(e,t,n,r,i)=>{let a=[],o=[a];for(let s=n;s<r;s++){let n=e[s],r=t.get(s);if(n.t===`open`&&r!==void 0){let i=iv(e,t,s+1,r,!1);a.push({t:`ext`,type:n.type,alts:i}),s=r}else n.t===`bar`&&!i?o.push(a=[]):n.t===`open`?a.push(X_(n.type),X_(`(`)):n.t===`bar`?a.push(X_(`|`)):n.t===`close`?a.push(X_(`)`)):a.push(n)}return o},av=(e,t)=>{let n=[],r=``,i=()=>{for(let e of r.normalize(t))n.push(X_(e));r=``};for(let a of e)a.t===`lit`?r+=a.ch:(i(),n.push(a.t===`ext`?{...a,alts:a.alts.map(e=>av(e,t))}:a));return i(),n},ov=(e,t)=>{let n=1,r=e=>({t:`split`,id:n++,out:e}),i=(e,t)=>e.reduceRight((e,t)=>a(t,e),t),a=(e,a)=>{switch(e.t){case`lit`:let r=t?ev(e.ch):void 0;return{t:`lit`,id:n++,ch:e.ch,re:r,next:a};case`any`:case`star`:return{t:e.t,id:n++,next:a};case`class`:return{t:`class`,id:n++,re:e.re,next:a}}let o=t=>e.alts.map(e=>i(e,t));switch(e.type){case`@`:return r(o(a));case`?`:return r([a,...o(a)]);case`!`:return{t:`neg`,id:n++,sub:r(o(Y_)),next:a}}let s=r([]),c=r(o(s));return s.out.push(a,c),e.type===`*`?s:c};return[i(e,Y_),n]},sv=e=>{let t=[],n=/* @__PURE__ */ new Set,r=e=>e.t===`match`?`match`:String(e.id),i=(e,a)=>{if(e.t===`match`||n.has(e))return;n.add(e);let o=n=>t.push(`${a}${e.id}: ${n}`);switch(e.t){case`split`:o(`split -> ${e.out.map(r).join(`, `)}`);for(let t of e.out)i(t,a);return;case`neg`:return o(`!(${r(e.sub)}) -> ${r(e.next)}`),i(e.sub,a+` `),i(e.next,a);case`lit`:o(`${JSON.stringify(e.ch)} -> ${r(e.next)}`);break;case`class`:o(`${e.re} -> ${r(e.next)}`);break;default:o(`${e.t===`any`?`?`:`*`} -> ${r(e.next)}`)}i(e.next,a)};return i(e,``),[`start -> ${r(e)}`,...t].join(`
437
+ `)};var cv=class{gen;threads=[];match=!1;runs=[];ids=[];constructor(e){this.gen=e}get dead(){return!this.threads.length&&!this.match&&!this.runs.length}};const lv=(e,t)=>e.ids.length!==t.ids.length||e.runs.length!==t.runs.length||e.ids.some((e,n)=>e!==t.ids[n])?!1:e.runs.every(e=>t.runs.some(t=>t.neg===e.neg&&lv(t.state,e.state))),uv=e=>({has:new Float64Array(e),seen:new Float64Array(e),gen:0});var dv=class{dots;dotStart;#e;constructor(e,t,n){this.dots=e,this.dotStart=t,this.#e=n}state(){return new cv(++this.#e.gen)}done(e){return e.ids=e.threads.map(e=>e.id).sort((e,t)=>e-t),e.match&&e.ids.unshift(Y_.id),e}#t(e,t){let{seen:n}=this.#e;return n[t.id]!==e.gen&&(n[t.id]=e.gen,!0)}#n(e,t){let{has:n}=this.#e;return n[t.id]!==e.gen&&(n[t.id]=e.gen,e.threads.push(t),!0)}restricted(e,t){return t&&(this.dots||this.dotStart&&e===0)}add(e,t,n,r){switch(t.t){case`split`:if(!this.#t(e,t))return;for(let i of t.out)this.add(e,i,n,r);return;case`neg`:if(!this.#t(e,t))return;let i=this.state();return this.add(i,t.sub,n,!1),this.done(i),this.addRun(e,{t:`run`,neg:t,state:i},n,r);case`star`:if(this.restricted(n,r))return;this.#n(e,t)&&this.add(e,t.next,n,r);return;case`match`:e.match=!0;return;default:this.#n(e,t)}}addRun(e,t,n,r){for(let n of e.runs)if(n.neg===t.neg&&lv(n.state,t.state))return;e.runs.push(t),t.state.match||this.add(e,t.neg.next,n,r)}step(e,t,n,r){let i=this.state();for(let a of e.threads)switch(a.t){case`lit`:tv(a,t)&&this.add(i,a.next,n+1,r);break;case`any`:this.restricted(n,r)||this.add(i,a.next,n+1,r);break;case`class`:!this.restricted(n,r)&&a.re.test(t)&&this.add(i,a.next,n+1,r);break;case`star`:this.restricted(n,r)||this.add(i,a,n+1,r)}if(!this.restricted(n,r))for(let a of e.runs){if(a.state.dead){this.addRun(i,a,n+1,r);continue}let e=this.step(a.state,t,n,!1);this.addRun(i,{t:`run`,neg:a.neg,state:e},n+1,r)}return this.done(i)}};const fv=e=>{let t=e.ids.join();return e.runs.length?`${t}|${e.runs.map(e=>`${e.neg.id}(${fv(e.state)})`).sort().join(`|`)}`:t};var pv=class{#e;#t=/* @__PURE__ */ new Map;#n=0;#r;#i;#a;#o;constructor(e,t){this.#e=e,this.#a=new dv(!1,!1,t),this.#o=new dv(!1,!0,t)}#s(e){return{state:e,match:e.match,dead:e.dead,next:/* @__PURE__ */ new Map}}#c(e){let t=fv(e),n=this.#t.get(t);if(n)return n;this.#n>262144&&this.#l();let r=this.#s(e);return this.#t.set(t,r),this.#n+=t.length+1,r}#l(){this.#t.clear(),this.#n=0,this.#r=void 0,this.#i=void 0}start(e){if(e){if(this.#i)return this.#i;let e=this.#o.state();return this.#o.add(e,this.#e,0,!0),this.#i=this.#s(this.#o.done(e))}if(this.#r)return this.#r;let t=this.#a.state();return this.#a.add(t,this.#e,0,!0),this.#r=this.#c(this.#a.done(t))}next(e,t){let n=t.charCodeAt(0),r=n<128?void 0:e.next.get(t);if(r)return r;let i=e===this.#i?this.#c(this.#o.step(e.state,t,0,!0)):this.#c(this.#a.step(e.state,t,1,!0));return n<128?(e.ascii||(e.ascii=Array(128),this.#n+=128),e.ascii[n]=i):e.next.set(t,i),this.#n++,i}};const mv=e=>{let t=[];for(let n=e;n.t!==`match`;n=n.next){if(n.t===`split`||n.t===`neg`)return;t.push(n)}return t},hv=(e,t,n,r)=>{let i=0,a=n,o=-1,s=0;for(;a<r;){let n=e[i];if(n?.t===`star`){o=i++,s=a;continue}let r=t[a];if(n&&(n.t===`any`||n.t===`lit`&&tv(n,r)||n.t===`class`&&n.re.test(r)))i++,a++;else{if(o===-1)return!1;i=o+1,a=++s}}for(;e[i]?.t===`star`;)i++;return i===e.length},gv=e=>{let t=0,n=0;for(let r of e){let[e,i]=_v(r);t+=e,n+=i}return[t,n]},_v=e=>{if(e.t===`star`)return[0,1/0];if(e.t!==`ext`)return[1,1];if(e.type===`!`)return[0,1/0];let t=e.alts.map(gv),n=Math.min(...t.map(e=>e[0])),r=Math.max(...t.map(e=>e[1])),i=r===0?0:1/0;return e.type===`@`?[n,r]:e.type===`?`?[0,r]:e.type===`*`?[0,i]:[n,i]},vv=(e,t,n)=>{for(let r=0;r<e.length;r++)if(!tv(e[r],t[n+r]))return!1;return!0},yv=/[/\ud800-\udfff]/,bv=/[\ud800-\udfff]/,xv=e=>bv.test(e)?[...e]:e,Sv=e=>{if(e.includes(`/`))throw Error(`can only match a single path portion, got: `+e)};var Cv=class{pattern;options;#e;#t;#n;#r;#i;#a=!1;#o;#s;#c=!1;#l=0;#u=1/0;#d=[];#f=[];#p;#m;#h=!1;#g;#_;constructor(e,t={}){if(e.includes(`/`))throw Error(`can only match a single path portion, got pattern: `+e);this.pattern=e,this.options=t;let{nocase:n=!1,noext:r=!1,normalize:i}=t;this.#_=i===!0?`NFC`:i||void 0;let a=/^[?*+@]\(\)$/.test(e),o=nv(e,n,r||a,this.#_,t.rangeMark),[s]=iv(o,rv(o),0,o.length,!0);this.#_&&(s=av(s,this.#_));let[c,l]=ov(s,n);if(this.#e=c,this.#t=l,s.every(e=>e.t===`lit`))this.#i=s.map(e=>e.ch).join(``),this.#a=n;else{let e=e=>e.t===`lit`?n?{ch:e.ch,re:ev(e.ch)}:{ch:e.ch}:void 0;for(let t of s){let n=e(t);if(!n)break;this.#d.push(n)}for(let t=s.length-1;t>=0;t--){let n=e(s[t]);if(!n)break;this.#f.unshift(n)}this.#h=!!(this.#d.length||this.#f.length),n||(this.#p=this.#d.map(e=>e.ch).join(``),this.#m=this.#f.map(e=>e.ch).join(``)),this.#s=mv(this.#e)?.slice(this.#d.length,-this.#f.length||void 0),this.#c=!!this.#s?.every(e=>e.t===`star`||e.t===`any`);let[t,r]=gv(s);this.#l=t,this.#u=r}}test(e){return this.#_?(Sv(e),this.#v(e.normalize(this.#_))):yv.test(e)?(Sv(e),this.#v(e,[...e])):this.#v(e,e)}testUnchecked(e){return this.#v(this.#_?e.normalize(this.#_):e)}#v(e,t){if(this.#i!==void 0)return this.#a?(this.#o??=Q_(this.#i)).test(e):e===this.#i;let n=this.#l,r=this.#u;if(t===void 0){let i=e.length,a=i+1>>1;if(i<n||a>r)return!1;(a<n||i>r)&&(t=xv(e))}if(t!==void 0&&(t.length<n||t.length>r))return!1;let i=this.#d.length;if(this.#h){if(this.#p!==void 0&&this.#m!==void 0){if(!e.startsWith(this.#p)||!e.endsWith(this.#m))return!1}else{t??=xv(e);let n=t.length-this.#f.length;if(!vv(this.#d,t,0)||!vv(this.#f,t,n))return!1}}let a=!this.options.dot&&e.startsWith(`.`);if(this.#s){if(e===`.`||e===`..`||a&&!i)return!1;if(this.#c)return!0;t??=xv(e);let n=t.length-this.#f.length;return hv(this.#s,t,i,n)}if(t??=xv(e),e===`.`||e===`..`){this.#n??=uv(this.#t);let e=this.#r??=new dv(!0,!1,this.#n),n=e.state();e.add(n,this.#e,0,!0);let r=e.done(n);for(let n=0;n<t.length;n++)r=e.step(r,t[n],n,!0);return r.match}this.#n??=uv(this.#t);let o=this.#g??=new pv(this.#e,this.#n),s=o.start(a),c=t===e;for(let n=0;n<t.length;n++){if(s.dead)return!1;let r=c?e.charCodeAt(n):t[n].charCodeAt(0);s=s.ascii?.[r]??o.next(s,t[n])}return s.match}toString(){return sv(this.#e)}};const wv=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},Tv=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>{let r=n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),i=r.charAt(0);return i===`#`?(t?`[#]`:`\\#`)+r.slice(1):i===`!`?(t?`@(!)`:`\\!`)+r.slice(1):r},Ev=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>t&&e.startsWith(`@(!)`)?`!`+Ev(e.slice(4),{windowsPathsNoEscape:t,magicalBraces:n}):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`),Dv=1e5,Ov=`allowWindowsEscape`,J=(e,t,n)=>(wv(t),!n?.nocomment&&t.charAt(0)===`#`?!1:zv(t,n).match(e));let kv=/* @__PURE__ */ new Map,Av=/* @__PURE__ */ new Map,jv=0,Mv=0;const Nv=4096,Pv=e=>{let t=e.pattern.length;for(let n of e.globSet)if(t+=n.length+1,t>Nv)break;return t},Fv=e=>e===void 0?0:e?2:1,Iv=new Map(Object.keys({nobrace:0,nocomment:0,nonegate:0,noglobstar:0,noext:0,nonull:0,partial:0,dot:0,nocase:0,nocaseMagicOnly:0,magicalBraces:0,matchBase:0,flipNegate:0,preserveMultipleSlashes:0,windowsNoMagicRoot:0}).map((e,t)=>[e,24*3**t])),Lv=e=>{let t=0,n=!1;for(let r in e){let i=e[r];switch(r){case`windowsPathsNoEscape`:i&&(n=!0);break;case Ov:i===!1&&(n=!0);break;case`platform`:{let n=i||Bv;if(n===Bv)break;if(n===`darwin`)t+=3;else if(n===`win32`)t+=6;else if(n===`linux`)t+=9;else return JSON.stringify(e);break}case`optimizationLevel`:if(i===void 0)break;t+=i>=2?1:i>=1?0:2;break;case`braceExpandMax`:if(i!==void 0&&i!==Dv)return JSON.stringify(e);break;case`maxGlobstarRecursion`:if(i!==void 0&&i!==200)return JSON.stringify(e);break;case`normalize`:if(i!==void 0)return JSON.stringify(e);break;default:t+=(Iv.get(r)??0)*Fv(i)}}return n?t+12:t},Rv=e=>{let t={};for(let n in e)t[n]=e[n];return t},zv=(e,t)=>{let n=t?Lv(t):0,r=kv.get(n)?.get(e);if(r)return r;r=Av.get(n)?.get(e)??new fy(e,Rv(t));let i=Pv(r);if(i>Nv)return r;(jv>=256||Mv+i>32768)&&(Av=kv,kv=/* @__PURE__ */ new Map,jv=0,Mv=0);let a=kv.get(n);return a||kv.set(n,a=/* @__PURE__ */ new Map),a.set(e,r),jv++,Mv+=i,r},Bv=typeof process==`object`&&process?process.env?.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,Vv={win32:{sep:`\\`},posix:{sep:`/`}};J.sep=Bv===`win32`?Vv.win32.sep:Vv.posix.sep;const Y=Symbol(`globstar **`);J.GLOBSTAR=Y,J.filter=(e,t)=>{let n;return r=>(n??=zv(e,t)).match(r)};const Hv=(e,t={})=>Object.assign({},e,t);J.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return J;let t=J;return Object.assign((n,r,i={})=>t(n,r,Hv(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,Hv(e,n))}static defaults(n){return t.defaults(Hv(e,n)).Minimatch}},unescape:(n,r={})=>t.unescape(n,Hv(e,r)),escape:(n,r={})=>t.escape(n,Hv(e,r)),filter:(n,r={})=>t.filter(n,Hv(e,r)),defaults:n=>t.defaults(Hv(e,n)),braceExpand:(n,r={})=>t.braceExpand(n,Hv(e,r)),match:(n,r,i={})=>t.match(n,r,Hv(e,i)),sep:t.sep,GLOBSTAR:Y})};const Uv=(e,t={})=>{if(wv(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e))return[e];let n=e.replace(/\\\\/g,`\\\\\\\\`);return(t.windowsPathsNoEscape||t[Ov]===!1)&&(n=n.replace(/\[([{}])\]/g,`[\\$1]`)),M_(n,{max:t.braceExpandMax})};J.braceExpand=Uv;const Wv=/(?<![\\$])\{(-?\d+)\.\.(-?\d+)\}/g,Gv=(e,t)=>{let n=[];for(let r=0;r<e.length;r++){let i=e.charAt(r);if(i===`\\`)r++;else if(i===t){if(n.some(e=>e!==`@`&&e!==`?`))return!0}else e.charAt(r+1)===`(`&&`!?+*@`.includes(i)?(n.push(i),r++):i===`)`&&n.pop()}return!1};J.match=(e,t,n={})=>{let r=new fy(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const Kv=/[?*]|[+@!]\(.*?\)|\[|\]/,qv=(e,t)=>{let n=t+1;(e.charAt(n)===`!`||e.charAt(n)===`^`)&&n++;let r=!1;for(;n<e.length;n++){let t=e.charAt(n);if(t===`]`&&r)return n;r=!0,t===`\\`&&n++}return-1},Jv=(e,t)=>{if(!t&&(e===`+()`||e===`@()`))return e;let n=``;for(let r=0;r<e.length;r++){let i=e.charAt(r);if(i===`\\`)n+=e.charAt(++r)||i;else if(i===`*`||i===`?`)return;else if(i===`[`){let t=qv(e,r);if(t===-1){n+=i;continue}let a=e.slice(r+1,t);if(a.startsWith(`\\`)&&(a=a.slice(1)),[...a].length!==1||`!^`.includes(e.charAt(r+1)))return;n+=a,r=t}else if(!t&&`+@!`.includes(i)&&e.charAt(r+1)===`(`&&e.includes(`)`,r+2))return;else n+=i}return n},Yv=e=>{let t=0;for(let n=0;n<e.length-1;n++){let r=e.charAt(n);r===`\\`?n++:`+@!?*`.includes(r)&&e.charAt(n+1)===`(`&&(t++,n++)}return t},Xv=e=>{if(Yv(e)>256)throw TypeError(`pattern has too many extglobs`)},Zv=e=>{if(/^[?*+@]\(\)$/.test(e)||e.includes(`[:`))return!1;let t=0;for(let n=0;n<e.length;n++){let r=e.charAt(n);if(r===`\\`){if(++n===e.length)return!1}else if(r===`[`){let t=qv(e,n);t!==-1&&(n=t)}else if(`+@!?*`.includes(r)&&e.charAt(n+1)===`(`)t++,n++;else if(r===`)`){if(!t--)return!1}else if(r===`|`&&!t)return!1}return!t};let Qv,$v;const ey=(e,t)=>typeof e==`string`?t===e:t!==``&&e.testUnchecked(t),ty=(e,t,n,r,i)=>ey(e,t)?n:r!==void 0&&ey(e,r)?i:-1,ny=e=>e===`.`||e===`..`,ry=e=>typeof e==`string`&&/^[a-z]:$/i.test(e),iy=e=>typeof e==`string`&&/^unc$/i.test(e),ay=e=>{if(e[0]!==``||e[1]!==``)return-1;let t=e[2]===`?`?iy(e[3])?4:-1:2,n=e[t],r=e[t+1];return t!==-1&&n!==void 0&&n!==``&&n!==Y&&r!==void 0&&r!==``&&r!==Y?t:-1},oy=(e,t)=>!ny(e)&&(t||!e.startsWith(`.`)),sy=(e,t,n,r,i)=>{for(let a=t;a<n;){if(e.charCodeAt(a)===46){if(!r)return!0;let t=e.charCodeAt(a+1)===46?a+2:a+1;if(t>=n||cy(e.charCodeAt(t),i))return!0}let t=ly(e,a,i);if(t===-1)return!1;for(a=t+1;a<n&&cy(e.charCodeAt(a),i);)a++}return!1},cy=(e,t)=>t===`/`?e===47:t===`\\`?e===92:e===47||e===92,ly=(e,t,n)=>{if(n!==`both`)return e.indexOf(n,t);let r=e.indexOf(`/`,t),i=e.indexOf(`\\`,t);return r===-1?i:i===-1?r:Math.min(r,i)},uy=(e,t,n)=>n===`both`?Math.max(e.lastIndexOf(`/`,t),e.lastIndexOf(`\\`,t)):e.lastIndexOf(n,t),dy={};var fy=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;#e;#t;#n;#r;#i=[];#a=[];#o=[];#s=/* @__PURE__ */ new Map;#c=!1;#l;#u=/* @__PURE__ */ new WeakMap;constructor(e,t={}){wv(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||Bv,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[Ov]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,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.#e=!this.preserveMultipleSlashes,this.#n=(t.optimizationLevel??1)>=2;let n=t.normalize;this.#r=n===!0?`NFC`:n||void 0,this.make();let r=this.set.map(e=>this.#f(e));this.#o=this.set.map((e,t)=>this.#e&&e.length-1>r[t]),this.#i=this.set.map((e,t)=>{let n=this.#o[t]?e.length-1:e.length,i=e.slice(r[t]+1,n).filter(e=>typeof e==`string`&&!!e);return[...new Set(i)]}),this.#t=this.#i.some(e=>e.length),this.#a=this.set.map((e,n)=>{let[i,a,o]=e;if(this.#o[n]&&e.length===2&&i===Y&&a!==Y)return`tail`;if(this.#o[n]&&t.matchBase&&e.length===1&&i!==Y&&i!==``)return`base`;if(this.#e&&r[n]===-1){if(e.length===3&&i===Y&&o===Y&&a!==Y&&a!==``&&this.maxGlobstarRecursion>0)return`mid`;if(e.length===2&&a===Y&&i!==Y&&i!==``)return`head`}})}#d(e){return this.#r?e.normalize(this.#r):e}#f(e){if(!this.isWindows)return-1;if(ry(e[0]))return 0;if(e[0]===``&&e[1]===``&&e[2]===`?`&&ry(e[3]))return 3;let t=ay(e);return t===-1?-1:t+1}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}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.#T())];let n=this.globSet.map(e=>this.#E(e));this.globParts=this.preprocess(n),this.#c=!0;let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[2]===`?`&&iy(e[3])?6:4,n=e[0]===``&&e[1]===``&&(e[2]===`?`||!Kv.test(e[2]))&&e.slice(3,t).every(e=>!Kv.test(e)),r=/^[a-z]:/i.test(e[0]);if(n)return[...e.slice(0,t).map(e=>this.#d(e)),...e.slice(t).map(e=>this.parse(e))];if(r)return[this.#d(e[0]),...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(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]===`?`&&(ry(t[3])||iy(this.globParts[e][3]))&&(iy(this.globParts[e][3])&&(t[3]=`UNC`),t[2]=`?`)}t.noext||this.mergeRows(),this.#c=!1,this.set.forEach((e,t)=>{for(let n=0;n<e.length;n++)e[n]===dy&&(e[n]=this.parse(this.globParts[t][n]))})}mergeRows(){let e=!0;for(;e;){if(e=!1,this.set.length<2)return;let t=this.#p(),n=Math.max(0,...this.set.map(e=>e.length));for(let r=0;r<n;r++){let n=/* @__PURE__ */ new Map,i=this.set.length+1;this.set.forEach((e,a)=>{if(!(e[r]instanceof Cv||e[r]===dy)||!Zv(this.globParts[a][r]))return;let{pre:o,suf:s}=t[a],c=o[r]*i+s[r+1],l=n.get(c);l?l.push(a):n.set(c,[a])});let a=/* @__PURE__ */ new Set;for(let e of n.values()){if(e.length<2)continue;let[t,...n]=e,i=`@(${e.map(e=>this.globParts[e][r]).join(`|`)})`;if(!(Yv(i)>256)){this.globParts[t][r]=i,this.set[t][r]=this.parse(i);for(let e of n)a.add(e)}}if(a.size){if(e=!0,this.set=this.set.filter((e,t)=>!a.has(t)),this.globParts=this.globParts.filter((e,t)=>!a.has(t)),this.set.length<2)return;t=this.#p()}}}}#p(){let e=/* @__PURE__ */ new Map,t=this.globParts.map(t=>t.map(t=>{let n=e.get(t);return n===void 0&&e.set(t,n=e.size),n})),n=e.size,r=Math.max(0,...t.map(e=>e.length)),i=t.map(e=>({pre:[0],suf:Array(e.length+1).fill(0)}));for(let e=0;e<r;e++){let r=/* @__PURE__ */ new Map;t.forEach((t,a)=>{if(e>=t.length)return;let{pre:o}=i[a],s=o[e]*n+t[e],c=r.get(s);c===void 0&&r.set(s,c=r.size+1),o.push(c)})}for(let e=r-1;e>=0;e--){let r=/* @__PURE__ */ new Map;t.forEach((t,a)=>{if(e>=t.length)return;let{suf:o}=i[a],s=o[e+1]*n+t[e],c=r.get(s);c===void 0&&r.set(s,c=r.size+1),o[e]=c})}return i}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=>{let t=this.#f(e)+1;return e=e.reduce((e,n)=>{let r=e[e.length-1];return n===`**`&&r===`**`?e:n===`..`&&e.length>t&&r&&r!==`..`&&r!==`.`&&r!==`**`?(e.pop(),e):(e.push(n),e)},[]),e.length===0?[``]:e})}#m(e){let t=!this.isWindows||!e.includes(`\\`)?`/`:e.includes(`/`)?`both`:`\\`,n=this.#e?0:-1,r=``,i=0,a,o=0,s=!!this.options.dot;e:for(let c=0;c<this.set.length;c++){let l=this.set[c],u=l[l.length-1],d=n!==-1&&this.#o[c]&&u!==Y;if(d&&n===0){let s=uy(e,e.length,t);if(i=s+1,r=e.slice(i),r===``&&s>=0){let n=s;for(;n>0&&cy(e.charCodeAt(n-1),t);)n--;o=n===0?0:uy(e,n-1,t)+1,a=e.slice(o,n)}let c=this.#n&&(ny(r)||r===``&&a!==void 0&&ny(a));n=c?-1:1,d=!c}let f=-1;if(d&&typeof u==`string`&&(f=ty(u,r,i,a,o),f===-1))continue;if(this.#t){for(let t of this.#i[c])if(!e.includes(t))continue e}if(d&&typeof u==`object`&&(f=ty(u,r,i,a,o),f===-1))continue;let p=this.#a[c];if(p===`base`&&d)return`yes`;if(p===`tail`&&d){if(this.#n&&sy(e,0,f,!0,t))return`maybe`;if(!sy(e,0,f,s,t))return`yes`}else if(p===`mid`||p===`head`){let n=this.#g(e,l,p===`head`,s,t);if(n!==`no`)return n}else return`maybe`}return`no`}#h(e,t,n){let r=!!this.options.dot,i=e.length;if(n===`head`){if(i<2||!ey(t[0],e[0]))return!1;for(let t=1;t<i;t++)if(!oy(e[t],r))return!1;return!0}let a=t[1];if(n===`tail`){let t=i-1;if(!ey(a,e[t])&&(e[t]!==``||i===1||!ey(a,e[--t])))return!1;for(let n=0;n<t;n++)if(!oy(e[n],r))return!1;return!0}for(let t=0;t<i;t++){if(ey(a,e[t])&&t+1<i){let n=t+1;for(;n<i&&oy(e[n],r);)n++;if(n===i)return!0}if(!oy(e[t],r))return!1}return!1}#g(e,t,n,r,i){if(this.#n&&sy(e,0,e.length,!0,i))return`maybe`;let a=t[+!n],o=0;for(let t=ly(e,o,i);t!==-1;t=ly(e,o,i)){let s=t+1;for(;s<e.length&&cy(e.charCodeAt(s),i);)s++;if((typeof a==`string`?t-o===a.length&&e.startsWith(a,o):t>o&&a.testUnchecked(e.slice(o,t)))&&!sy(e,s,e.length,r,i))return`yes`;if(n||sy(e,o,s,r,i))return`no`;o=s}return`no`}#_(e){let t=Qv;return t?.f===e&&t.isWindows===this.isWindows&&t.preserveMultipleSlashes===this.preserveMultipleSlashes&&t.normalize===this.#r?t:void 0}#v(e){let{isWindows:t,preserveMultipleSlashes:n}=this,r=this.#E(t?e.split(`\\`).join(`/`):e),i=this.#r;return i&&(r=r.map(e=>e.normalize(i))),Qv={f:e,isWindows:t,preserveMultipleSlashes:n,normalize:i,parts:r},Qv}#y(e){let t=[...e],n=!1;do{if(n=!1,!this.preserveMultipleSlashes){for(let e=1;e<t.length-1;e++){let r=t[e];e===1&&r===``&&t[0]===``||r!==`.`&&r!==``||(n=!0,t.splice(e,1),e--)}t[0]===`.`&&t.length===2&&(t[1]===`.`||t[1]===``)&&(n=!0,t.pop())}let e=this.#f(t)+1,r=e;for(;(r=t.indexOf(`..`,r+1))!==-1;){let i=t[r-1];i&&i!==`.`&&i!==`..`&&i!==`**`&&(n=!0,t.splice(r-1,2),r=Math.max(r-2,e))}}while(n);return t.length===0?[``]:t}firstPhasePreProcess(e){let{braceExpandMax:t=Dv}=this.options,n=0,r=!1;do{r=!1;for(let i of e){let a=-1;for(;(a=i.indexOf(`**`,a+1))!==-1;){let o=a;for(;i[o+1]===`**`;)o++;o>a&&i.splice(a+1,o-a);let s=i[a+1],c=i[a+2],l=i[a+3];if(s!==`..`||!c||c===`.`||c===`..`||!l||l===`.`||l===`..`)continue;let u=i.length-1;if(e.length>=t||n+u>1e6)throw RangeError(`optimizationLevel 2: too many patterns from '**/..'`);r=!0,i.splice(a,1);let d=i.slice(0);d[a]=`**`,n+=u,e.push(d),a--}if(!this.preserveMultipleSlashes){for(let e=1;e<i.length-1;e++){let t=i[e];e===1&&t===``&&i[0]===``||t!==`.`&&t!==``||(r=!0,i.splice(e,1),e--)}i[0]===`.`&&i.length===2&&(i[1]===`.`||i[1]===``)&&(r=!0,i.pop())}let o=this.#f(i)+1,s=o;for(;(s=i.indexOf(`..`,s+1))!==-1;){let e=i[s-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){r=!0;let e=s===1&&i[s+1]===`**`?[`.`]:[];i.splice(s-1,2,...e),i.length===0&&i.push(``),s=Math.max(s-2,o)}}}}while(r);return e}secondPhasePreProcess(e){let t=/* @__PURE__ */ new Set,n=e.filter(e=>{let n=e.join(`/`);return!t.has(n)&&(t.add(n),!0)}),r=/* @__PURE__ */ new Map;for(let e of n){let t=[];for(let n=0;n<e.length;n++)e[n]===`*`&&t.push(n);t.length&&r.set(t.join(`,`),t)}if(!r.size||n.length*r.size>1e5)return n;let{dot:i}=this.options;return n.filter(e=>{for(let n of r.values()){if(n[n.length-1]>=e.length)continue;let r=[...e],a=!0,o=!1;for(let t of n){let n=e[t];if(n!==`*`){if(!n||n===`**`||!i&&n.startsWith(`.`)){a=!1;break}r[t]=`*`,o=!0}}if(a&&o&&t.has(r.join(`/`)))return!1}return!0})}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}#b(e,t,n,r){let i=0,a=0,o=this.isWindows?ay(t):-1,s=o===-1?-1:ay(n);if(s!==-1){let e=n[s],r=n[s+1];typeof e!=`string`||typeof r!=`string`?(i=o,a=s):t[o].toLowerCase()===e.toLowerCase()&&t[o+1].toLowerCase()===r.toLowerCase()&&(i=o+2,a=s+2)}else if(this.isWindows){let t=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),r=!t&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),o=typeof n[0]==`string`&&/^[a-z]:$/i.test(n[0]),s=!o&&n[0]===``&&n[1]===``&&n[2]===`?`&&typeof n[3]==`string`&&/^[a-z]:$/i.test(n[3]),c=r?3:t?0:void 0,l=s?3:o?0:void 0;if(typeof c==`number`&&typeof l==`number`){let[t,r]=[e[c],n[l]];t.toLowerCase()===r.toLowerCase()&&(a=l+1,i=c+1)}}return e=t,n.includes(Y)?this.#x(e,n,r,i,a):this.#w(e,n,r,i,a)}#x(e,t,n,r,i){let{head:a,body:o,tail:s,segments:c}=this.#S(t,n,i);if(a.length){let t=r+a.length;if(!this.#w(e,a,n,r,0,t))return!1;r+=a.length,i+=a.length}let l=0;if(s.length){if(s.length+r>e.length)return!1;let t=e.length-s.length;if(this.#w(e,s,n,t,0))l=s.length;else{if(e[e.length-1]!==``||r+s.length===e.length||(t--,!this.#w(e,s,n,t,0)))return!1;l=s.length+1}}if(!o.length){let t=!!l;for(let n=r;n<e.length-l;n++){let r=String(e[n]);if(t=!0,r===`.`||r===`..`||!this.options.dot&&r.startsWith(`.`))return!1}return n||t}return!!this.#C(e,c,e.length-l,r,0,n,0,!!l,/* @__PURE__ */ new Set)}#S(e,t,n){let r=this.#u.get(e);r||(r=[],this.#u.set(e,r));let i=n*2+ +!!t,a=r[i];if(a)return a;let o=e.indexOf(Y,n),s=e.lastIndexOf(Y),c=e.slice(n,o),l=e.slice(o+1,t?void 0:s),u=t?[]:e.slice(s+1),d=[[[],0]],f=d[0],p=0,m=[0];for(let e of l)e===Y?(m.push(p),f=[[],0],d.push(f)):(f[0].push(e),p++);d.forEach((e,t)=>{e[1]=p-m[t]});let h={head:c,body:l,tail:u,segments:d};return r[i]=h,h}#C(e,t,n,r,i,a,o,s,c){let l=t[i];if(!l){if(a)return r>=n||r===n-1&&e[r]===``;for(let t=r;t<n;t++){s=!0;let n=e[t];if(n===`.`||n===`..`||!this.options.dot&&n.startsWith(`.`))return!1}return s}let[u,d]=l,f=a?n:n-d;for(;r<=f;){let l=i*(e.length+1)+r;if(c.has(l))return!1;if(c.add(l),this.#w(e,u,a,r,0,r+u.length)&&o<this.maxGlobstarRecursion){let l=this.#C(e,t,n,r+u.length,i+1,a,o+1,s,c);if(l!==!1)return l}if(r===f)break;let d=e[r];if(d===`.`||d===`..`||!this.options.dot&&d.startsWith(`.`))return!1;r++}return a||null}#w(e,t,n,r,i,a=e.length){let o,s,c,l;for(o=r,s=i,l=Math.min(a,e.length),c=t.length;o<l&&s<c;o++,s++){let n=t[s],r=e[o];
436
438
  /* c8 ignore stop */
437
- if(n===!1||n===Y||!Rv(n,r))return!1}if(o===l&&s===c)return!0;if(o===l)return n;if(s===c)return o===l-1&&e[o]===``;throw Error(`wtf?`)
439
+ if(n===!1||n===Y||!ey(n,r))return!1}if(o===l&&s===c)return!0;if(o===l)return n;if(s===c)return o===l-1&&e[o]===``;throw Error(`wtf?`)
438
440
  /* c8 ignore stop */
439
- }braceExpand(){return Av(this.pattern,this.options)}#w(){let{pattern:e}=this;if(this.options.nobrace)return this.braceExpand();let t=57344;for(;e.includes(String.fromCharCode(t));)if(++t>63743)return this.braceExpand();let n=String.fromCharCode(t),r=!1,i=e.replace(jv,(e,t,i)=>{let a=Number(t),o=Number(i);return!Number.isSafeInteger(a)||!Number.isSafeInteger(o)||Math.abs(a-o)+1<100?e:(r=!0,`${n}${t}..${i}${n}`)});if(!r)return this.braceExpand();let a=Av(i,this.options);for(let e of a)for(let t of e.split(`/`)){let e=t.indexOf(`[`);if(e!==-1&&e<t.lastIndexOf(n))return this.braceExpand()}return this.#l=n,a}parse(e){Sv(e);let t=this.options;if(e===`**`)return Y;if(e===``)return``;let{nocase:n,nocaseMagicOnly:r,noext:i=!1,dot:a,normalize:o}=t,s=this.#l,c=s&&e.includes(s)?void 0:Pv(e,i);if(c!==void 0&&(!n||r||e.toUpperCase()===e.toLowerCase()))return this.#d(c);if(this.#c)return Yv;let l=this.#s.get(e);return l||(l=new xv(e,{nocase:n,noext:i,dot:a,normalize:o,...s&&{rangeMark:s}}),this.#s.set(e,l)),l}#T(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options,r=this.#g(e);if(!r){if(!t&&!this.#r&&(this.#e||this.#t)&&Lv!==e){Lv=e;let t=this.#p(e);if(t===`no`)return!n.flipNegate&&this.negate;if(t===`yes`)return n.flipNegate?!0:!this.negate}r=this.#_(e)}let i=r.parts,a=this.#n?r.resolved??=this.#v(i):i,o=this.set,s=i[i.length-1];if(!s)for(let e=i.length-2;!s&&e>=0;e--)s=i[e];for(let e=0;e<o.length;e++){let r=o[e],c=t?void 0:this.#a[e];if(c===`base`?Rv(r[0],s):c?this.#m(a,r,c):n.matchBase&&r.length===1?this.#y([s],[s],r,t):this.#y(i,a,r,t))return n.flipNegate?!0:!this.negate}return!n.flipNegate&&this.negate}static defaults(e){return J.defaults(e).Minimatch}};J.Minimatch=Xv,J.escape=Cv,J.unescape=wv;const Zv=/[/\\]/u,Qv={kind:`ignore`},$v=e=>!ae(e)&&e.split(Zv).every(e=>e!==`.`&&e!==`..`),ey=/^!+/u,ty=/^\.?\/+/u,ny=e=>{let t=ey.exec(e)?.[0]??``;return{body:e.slice(t.length).replace(ty,``),negated:t.length%2==1}},ry=e=>ny(e).negated,iy=e=>ny(e).body,ay=/[?[\]{}()]/u,oy=e=>$v(e)&&!ry(e)&&!ay.test(e),sy=(e,t)=>J(e,t),cy=e=>e.replaceAll(/\/+/gu,`/`).replace(/\/$/u,``),ly=e=>{let t=cy(e).split(`/`),n=t.findIndex(e=>e.includes(`*`));return n===-1?Qv:{baseDir:n===0?`.`:t.slice(0,n).join(`/`),kind:`expand-children`,pattern:cy(e),suffix:t.slice(n+1).join(`/`)}},uy=e=>{let t=cy(e).split(`/`).filter(e=>e.includes(`*`));return t.length<=1&&!t.includes(`**`)},dy=e=>{let t=cy(e).split(`/`),n=t.findIndex(e=>e.includes(`*`));return n<=0?`.`:t.slice(0,n).join(`/`)},fy=e=>oy(e)?e.includes(`*`)?uy(e)?ly(e):{baseDir:dy(e),kind:`expand-recursive`,pattern:cy(e)}:{dir:e,kind:`probe-dir`,pattern:e}:Qv,py=/* @__PURE__ */ new Set([`candidate_not_inspected`,`scan_budget_exhausted`,`manifest_unreadable`,`unsupported_pattern`,`workspace_declaration_unparsed`,`workspace_dir_unreadable`,`workspace_file_unreadable`]),my=(e,t)=>t?.name?{name:t.name,path:e}:void 0,hy=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},gy=e=>!e.diagnostics.some(e=>py.has(e.kind)),_y=e=>!e.diagnostics.some(e=>e.kind===`no_workspace_declaration`),vy=(e,t)=>e<t?-1:+(e>t),yy=e=>`path`in e?`${e.kind} ${e.path}`:`file`in e?`${e.kind} ${e.file}`:`pattern`in e?`${e.kind} ${e.pattern}`:e.kind,by=e=>e.toSorted((e,t)=>vy(yy(e),yy(t))),xy=e=>!ae(e)&&!e.split(/[/\\]/u).includes(`..`),Sy=(e,t)=>e.kind===`missing`?{kind:`absent`}:e.kind===`outside`?{kind:`unreadable`,reason:`${t} escapes the checkout`}:{kind:`unreadable`,reason:e.code},Cy=async(e,t,n)=>{if(!xy(t))return{kind:`unreadable`,reason:`path escapes the checkout`};let r=await wy(e,t);if(`probe`in r)return r.probe;let i=await Ty(r.real);return`reason`in i?{kind:`unreadable`,reason:i.reason}:i.found===n?{kind:`match`}:{found:i.found,kind:`mismatch`}},wy=async(e,t)=>{let n=await W(e,v(e,t));if(n.kind!==`inside`)return{probe:Sy(n,`path`)};let r=await W(e,v(n.real,`package.json`));return r.kind===`inside`?{real:r.real}:{probe:Sy(r,`manifest`)}},Ty=async e=>{try{let t=JSON.parse(await s(e,`utf8`));return{found:ad(t)}}catch(e){return{reason:e.code??`manifest could not be read or interpreted`}}},Ey=(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(vy)}},Dy=`package.json`,Oy=/^\.\/[^\s%?#\\]*$/u,ky=async e=>{try{return(await p(e)).isDirectory()?`directory`:`file`}catch{return`unverifiable`}},Ay=async(e,t)=>{if(!Oy.test(t)||t.includes(`*`))return`not_checked`;let n=v(e,t.slice(2)),r=await W(e,n);return r.kind===`inside`?ky(r.real):r.kind===`missing`&&await Xu(e,n)?`absent`:`unverifiable`},jy=async(e,t,n)=>Array.isArray(t)?{alternatives:await Promise.all(t.map(t=>My(e,t,n+1))),kind:`alternatives`}:{branches:await Promise.all(Object.entries(t).map(async([t,r])=>({condition:t,value:await My(e,r,n+1)}))),kind:`conditions`},My=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 Ay(e,t),target:t}:typeof t==`object`?jy(e,t,n):{kind:`unsupported`,reason:`unexpected ${typeof t}`},Ny=[`main`,`module`,`types`,`typings`],Py=(e,t)=>{let n=Ny.filter(e=>typeof t[e]==`string`);return Promise.all(n.map(async n=>({from:n,subpath:`.`,value:await My(e,Fy(t[n]),0)})))},Fy=e=>e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)?e:`./${e}`,Iy=async(e,t)=>{if(typeof t==`string`||Array.isArray(t))return[{from:`exports`,subpath:`.`,value:await My(e,t,0)}];if(t===void 0)return[];if(typeof t!=`object`||!t)return[{from:`exports`,subpath:`.`,value:await My(e,t,0)}];let n=Object.keys(t);return n.length>0&&!n.some(e=>e.startsWith(`.`))?[{from:`exports`,subpath:`.`,value:await My(e,t,0)}]:Promise.all(Object.entries(t).map(async([t,n])=>({from:`exports`,subpath:t,value:await My(e,n,0)})))},Ly=async(e,t)=>{let n=await W(e,v(e,Dy));if(n.kind!==`inside`)return{entries:[],manifest:Dy,reason:n.kind,status:`unverifiable`};try{let r=JSON.parse(await s(n.real,`utf8`));return r.name===t?{entries:[...await Iy(e,r.exports),...await Py(e,r)],manifest:Dy,status:`complete`}:{entries:[],manifest:Dy,reason:`manifest no longer names this package`,status:`unverifiable`}}catch(e){return{entries:[],manifest:Dy,reason:e.code??`manifest could not be read or interpreted`,status:`unverifiable`}}},Ry=Cl.partial({description:!0}),zy=P({default_branch:il,key:sl,tag_format_candidate:fl.nullable(),url:M().min(1)});zy.extend({description:M().default(``),packages:_l(Ry)});const By=zy.extend({description:M().min(1),packages:_l(Cl)}),Vy=P({effective_clone_mode:ul.optional(),head_sha:M().regex(/^[0-9a-f]{40}$/u,`head_sha must be a 40-character lowercase hex string`).optional(),last_error:M().optional(),last_fetched_at:Kc().optional(),pending_proposal_at:Kc().optional()}),Hy=P({refs:hl(e=>e.length>0&&!ml.has(e),()=>`state ref key must be non-empty and not "__proto__", "constructor", or "prototype"`,vc(M(),Vy)).default({})}),Uy=(e,t,n)=>t?.[e]??n[e],Wy=async e=>{try{return await s(e.statePath,`utf8`)}catch(e){if(L(e))return;throw e}},Gy=e=>{try{return JSON.parse(e)}catch{return}},Ky=async e=>{let t=await Wy(e);if(t===void 0)return Hy.parse({});let n=Gy(t);if(n===void 0)return Hy.parse({});let r=Hy.safeParse(n);return r.success?r.data:Hy.parse({})},qy=async(e,t)=>{let n=Hy.safeParse(t);if(!n.success)throw V(w(n.error));await fu(e.statePath,`${JSON.stringify(n.data,void 0,2)}\n`)},Jy=/^\d+\.\d+\.\d+$/u,Yy=/^0+(?=\d)/u,Xy=(e,t)=>{let n=e.replace(Yy,``),r=t.replace(Yy,``);return n.length===r.length?n===r?0:n<r?-1:1:n.length<r.length?-1:1},Zy=(e,t)=>{if(!Jy.test(e)||!Jy.test(t))return;let n=e.split(`.`),r=t.split(`.`);return n.map((e,t)=>Xy(e,r[t]??``)).find(e=>e!==0)??0},Qy=fc({version:M().regex(Jy)}),$y=P({checked_at:Kc(),latest_version:M().regex(Jy)}),eb=async e=>{try{let t=$y.safeParse(JSON.parse(await s(e.updateCachePath,`utf8`)));return t.success?t.data:void 0}catch{return}},tb=async(e,t)=>{try{await p(e.root),await fu(e.updateCachePath,`${JSON.stringify(t,void 0,2)}\n`)}catch{}},nb=(e,t)=>{let n=t-Date.parse(e.checked_at);return n>=0&&n<864e5},rb=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=Qy.safeParse(await t.json());return n.success?n.data.version:void 0}catch{return}},ib=async e=>{let t=await eb(e.home);if(t!==void 0&&nb(t,e.nowMs))return{latest:t.latest_version,refreshed:!1,stale:!1};let n=await rb(e.fetch);return n===void 0?{latest:t?.latest_version,refreshed:!1,stale:!0}:(await tb(e.home,{checked_at:new Date(e.nowMs).toISOString(),latest_version:n}),{latest:n,refreshed:!0,stale:!1})},ab=(e,t)=>{let n=Zy(e,t);return n!==void 0&&n<0},ob=(e,t)=>`refs ${t} is available (this is ${e}) — update: npm i -g @kaisers-io/refs@latest`,sb=e=>{let t=e.REFS_UPDATE_CHECK?.trim();if(t===`0`)return!1;if(t===`1`)return!0},cb=e=>{let t=e.CI?.trim().toLowerCase();return t!==void 0&&t!==``&&t!==`false`&&t!==`0`},lb={check:!0,notify:!0},ub=e=>{let t=sb(e.env);return t===void 0?(e.updates??lb).check?cb(e.env)?`ci`:`on`:`config`:t?`on`:`env`},db=e=>ub(e)===`on`,fb=e=>db(e)&&(e.updates??lb).notify,pb=async(e,t)=>{let n=await W(e,v(t,`package.json`));if(n.kind===`inside`)try{let e=JSON.parse(await s(n.real,`utf8`));return{name:ad(e),version:od(e)}}catch{return}},mb=async(e,t)=>{let n=await pb(e,v(e,t));if(n===void 0)return{diagnostic:{kind:`manifest_unreadable`,path:t}};let r=my(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}},hb=e=>Object.fromEntries(e.flatMap(e=>e.pkg===void 0||e.version===void 0?[]:[[e.pkg.path,e.version]])),gb=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:hb(e)}},_b=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),vb=async(e,t)=>{let n=await W(e,v(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`}},yb=async e=>{try{return{entries:await c(e,{withFileTypes:!0})}}catch(e){return{code:e.code??``}}},bb=e=>Promise.all(e.entries.map(t=>vb(e.repoDir,v(e.fullPath,t.name,e.suffix)))),xb=(e,t,n)=>e.filter((e,r)=>n(t[r])).map(e=>e.name),Sb=async e=>{let{baseDir:t,dirs:n,fullPath:r,repoDir:i,suffix:a,symlinks:o}=e,s=e=>se.join(t===`.`?``:t,e,a),[c,l]=await Promise.all([bb({entries:n,fullPath:r,repoDir:i,suffix:a}),bb({entries:o,fullPath:r,repoDir:i,suffix:a})]);return{diagnostics:[...xb(n,c,e=>e===`rejected`).map(e=>({kind:`manifest_unreadable`,path:s(e)})),...xb(o,l,e=>e!==`none`).map(e=>({kind:`candidate_not_inspected`,path:s(e)}))],dirs:xb(n,c,e=>e===`manifest`).map(e=>s(e))}},Cb=async e=>{let t=await mb(e,`.`);return`pkg`in t?[t]:[]},wb=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]},Tb=async e=>{let[t]=await Cb(e);return t!==void 0&&`pkg`in t?t.pkg:void 0},Eb=`package.json`,Db=e=>{let t=cy(e).split(`/`);return t.includes(`**`)?void 0:t.length},Ob=e=>cy(e).split(`/`).some(e=>e.startsWith(`.`)),kb=e=>e===`.`?0:e.split(`/`).length,Ab=e=>{let t=cy(e),n=new Xv(`${t}/${Eb}`),r=new Xv(t);return{couldHold:e=>r.match(e,!0),selects:e=>n.match(se.join(e,Eb))}},jb=e=>({...Ab(e),maxDepth:Db(e),selectsHidden:Ob(e)}),Mb=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),Nb=/* @__PURE__ */ new Set([`.git`,`node_modules`]),Pb=e=>e.some(e=>e.name.toLowerCase()===`package.json`&&!e.isDirectory()),Fb=e=>e.some(e=>e.isSymbolicLink()&&!Nb.has(e.name)),Ib=async(e,t)=>{let n=await yb(t);return`code`in n?{answer:Mb.has(n.code)}:(e.budget.entries-=n.entries.length,e.budget.entries<0||Pb(n.entries)||Fb(n.entries)?{answer:!1}:{entries:n.entries})},Lb=async(e,t,n)=>{if(e.budget.dirs<=0||n>32)return!1;--e.budget.dirs;let r=await Ib(e,t);return`answer`in r?r.answer:Rb(e,{dir:t,entries:r.entries},n)},Rb=async(e,t,n)=>{let r=t.entries.filter(e=>e.isDirectory()&&!Nb.has(e.name));for(let i of r)if(!await Lb(e,v(t.dir,i.name),n+1))return!1;return!0},zb=async(e,t)=>{let n=await W(e.repoDir,v(e.repoDir,t));n.kind!==`outside`&&n.kind!==`missing`&&(n.kind===`unreadable`?e.diagnostics.push({kind:`candidate_not_inspected`,path:t}):await Lb(e,n.real,1)||e.diagnostics.push({kind:`candidate_not_inspected`,path:t}))},Bb=()=>({dirs:2e4,entries:2e5}),Vb=/* @__PURE__ */ new Set([`.git`,`node_modules`]),Hb=(e,t)=>{e.diagnostics.push({kind:`scan_budget_exhausted`,path:t,pattern:e.pattern})},Ub=async(e,t,n)=>{if(!e.selects(t)||n.has(t))return;let r=await vb(e.repoDir,v(e.repoDir,t));r===`manifest`&&e.dirs.push(t),r===`rejected`&&e.diagnostics.push({kind:`manifest_unreadable`,path:t})},Wb=(e,t)=>!e.selectsHidden&&t.excluded.coversSubtree(t.relPath),Gb=async(e,t,n)=>!e.couldHold(n.relPath)||Vb.has(t.name)||Wb(e,n)?!1:t.isSymbolicLink()?(Wb(e,n)||await zb(e,n.relPath),!1):t.isDirectory(),Kb=async(e,t)=>{let n=await yb(v(e.repoDir,t));if(`code`in n)_b.has(n.code)||e.diagnostics.push({kind:`workspace_dir_unreadable`,path:t});else if(e.budget.entries-=n.entries.length,e.budget.entries<0)Hb(e,t);else return n.entries},qb=async(e,t,n)=>{if(e.budget.dirs<=0){Hb(e,t.relPath);return}if(--e.budget.dirs,await Ub(e,t.relPath,n),e.maxDepth!==void 0&&kb(t.relPath)>=e.maxDepth)return;let r=await Kb(e,t.relPath);r!==void 0&&await Yb(e,{depth:t.depth,entries:r,relPath:t.relPath},n)},Jb=(e,t)=>se.join(e===`.`?``:e,t),Yb=async(e,t,n)=>{for(let r of t.entries){let i=Jb(t.relPath,r.name);await Gb(e,r,{excluded:n,relPath:i})&&(t.depth+1>32?Hb(e,i):await qb(e,{depth:t.depth+1,relPath:i},n))}},Xb=async(e,t)=>{let n=await W(e,v(e,t));if(n.kind!==`inside`)return n.kind===`missing`?{diagnostics:[],dirs:[]}:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}},Zb=async(e,t,n)=>{let r=await Xb(e,t.baseDir);if(r!==void 0)return r;let i={...jb(t.pattern),budget:n.budget,diagnostics:[],dirs:[],pattern:t.pattern,repoDir:e};return await qb(i,{depth:1,relPath:t.baseDir},n.excluded),{diagnostics:i.diagnostics,dirs:i.dirs}},Qb=(e,t)=>se.join(e.baseDir===`.`?``:e.baseDir,t,e.suffix),$b=(e,t)=>sy(Qb(t,e.name),t.pattern),ex=async(e,t)=>{let n=v(e,t),r=await W(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 yb(n);return`code`in i?{result:_b.has(i.code)?{diagnostics:[],dirs:[]}:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}}:{entries:i.entries}},tx=async(e,t,n)=>{let{baseDir:r}=t,i=await ex(e,r);if(`result`in i)return i.result;let a=e=>$b(e,t)&&!n.has(Qb(t,e.name)),o={entries:i.entries};return Sb({baseDir:r,dirs:o.entries.filter(e=>e.isDirectory()&&a(e)),fullPath:v(e,r),repoDir:e,suffix:t.suffix,symlinks:o.entries.filter(e=>e.isSymbolicLink()&&a(e))})},nx=async(e,t)=>{let n=await vb(e,v(e,t));return n===`manifest`?{diagnostics:[],dirs:[cy(t)]}:n===`rejected`?{diagnostics:[{kind:`manifest_unreadable`,path:t}],dirs:[]}:{diagnostics:[],dirs:[]}},rx=(e,t,n)=>{let{excluded:r}=n,i=fy(t.body);return i.kind===`expand-children`?tx(e,i,r):i.kind===`expand-recursive`?Zb(e,i,n):i.kind===`probe-dir`?r.has(cy(i.dir))?Promise.resolve({diagnostics:[],dirs:[]}):nx(e,i.dir):Promise.resolve({diagnostics:[{kind:`unsupported_pattern`,pattern:t.declared}],dirs:[]})},ix=(e,t)=>sy(iy(e),iy(t)),ax=e=>({negations:e.filter(e=>ry(e)),patterns:e.filter(e=>!ry(e))}),ox=e=>{let t=e.reduce((e,t)=>ry(t)?{negations:[...e.negations,t],patterns:e.patterns}:{negations:e.negations.filter(e=>!ix(t,e)),patterns:[...e.patterns,t]},{negations:[],patterns:[]});return{negations:t.negations,patterns:t.patterns.filter(e=>!t.negations.some(t=>ix(e,t)))}},sx=e=>e.endsWith(`/`)?e:`${e}/`,cx=(e,t)=>e.some(e=>sy(sx(t),sx(iy(e)))),lx=(e,t)=>{let n=iy(e);return n.endsWith(`/**`)&&sy(t,n.slice(0,-3))},ux=e=>({coversSubtree:t=>e.some(e=>lx(e,t)),has:t=>cx(e,t)}),dx=e=>{let t=/* @__PURE__ */ new Set,n=[];for(let r of e)r.dirs.forEach(e=>t.add(e)),n.push(...r.diagnostics);return{diagnostics:n,dirs:[...t]}},fx=async(e,t,n)=>{let{negations:r,patterns:i}=t,a=ux(r),o=dx(await Promise.all(i.map(t=>rx(e,{body:iy(t),declared:t},{budget:n,excluded:a}))));return{diagnostics:o.diagnostics,dirs:o.dirs}},px=async(e,t)=>{let n=ox(t.npm),r=ax(t.pnpm),i=Bb(),a=await Promise.all([fx(e,n,i),fx(e,r,i)]);return dx(a)},mx=async e=>{let t=await pd(e);if(t.npm.length===0&&t.pnpm.length===0)return{diagnostics:by([...t.diagnostics,{kind:`no_workspace_declaration`}]),packages:[],versions:{}};let n=await px(e,t),[r,i]=await Promise.all([Cb(e),Promise.all(n.dirs.map(t=>mb(e,t)))]),a=gb([...r,...i]);return{diagnostics:by([...t.diagnostics,...n.diagnostics,...a.diagnostics]),packages:wb(hy(a.packages)),versions:a.versions}},hx=()=>{},gx={stop:hx,update:hx},_x={frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],interval:80},vx={frames:[`-`,`\\`,`|`,`/`],interval:130},yx=`\r\x1B[K`,bx={24:`\x1B[38;2;7;210;86m`,4:`\x1B[32m`,8:`\x1B[38;5;41m`},xx=/[^ -~]/gu,Sx=(e,t)=>t.isTTY===!0&&e.TERM!==`dumb`&&!cb(e)&&e.REFS_PROGRESS?.trim()!==`0`,Cx=/* @__PURE__ */ new Set([`alacritty`,`rxvt-unicode`,`rxvt-unicode-256color`,`xterm-256color`]),wx=(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`||Cx.has(e.TERM??``):e.TERM!==`linux`,Tx=(e,t)=>e.replaceAll(xx,`?`).slice(0,Math.max(0,t)),Ex=(e,t,n)=>{let r=(e.stream.columns??80)-3,i=bx[e.stream.getColorDepth?.(e.env)??1],a=i===void 0?t:`${i}${t}`;return`${yx}${a} ${Tx(n,r)}`},Dx=e=>{if(!Sx(e.env,e.stream))return gx;let{frames:t,interval:n}=wx(e.env,e.platform)?_x:vx,r={drawn:!1,index:0,stopped:!1,text:``},i=()=>{e.stream.write(Ex(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(yx),!1)},update:e=>{r.stopped||(r.text=e,a.delay??=setTimeout(o,100).unref())}}};var Ox=`0.19.1`;const kx=async()=>{let e=[];for await(let t of process.stdin)e.push(Buffer.from(t));return Buffer.concat(e).toString(`utf8`)},Ax=()=>{try{return me()}catch{return``}},jx=()=>({cliVersion:Ox,cwd:process.cwd(),env:process.env,errLine:e=>{process.stderr.write(`${e}\n`)},fetcher:(e,t)=>fetch(e,t),homedir:Ax(),nodeVersion:process.version,out:e=>{process.stdout.write(`${e}\n`)},readStdin:kx,runner:new sp({defaultTimeoutMs:Lp(process.env),env:process.env}),spinner:()=>Dx({env:process.env,platform:process.platform,stream:process.stderr})});var Mx=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}},Nx=class extends Mx{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},Px=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 Nx(`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 Fx(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}var Ix=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=>Fx(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=/* @__PURE__ */ 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(`
441
+ }braceExpand(){return Uv(this.pattern,this.options)}#T(){let{pattern:e}=this;if(this.options.nobrace)return this.braceExpand();let t=57344;for(;e.includes(String.fromCharCode(t));)if(++t>63743)return this.braceExpand();let n=String.fromCharCode(t),r=!1,i=e.replace(Wv,(e,t,i)=>{let a=Number(t),o=Number(i);return!Number.isSafeInteger(a)||!Number.isSafeInteger(o)||Math.abs(a-o)+1<100?e:(r=!0,`${n}${t}..${i}${n}`)});if(!r)return this.braceExpand();let a=Uv(i,this.options);for(let e of a)for(let t of e.split(`/`)){let e=t.indexOf(`[`);if(e!==-1&&e<t.lastIndexOf(n)||!this.options.noext&&Gv(t,n))return this.braceExpand()}return this.#l=n,a}parse(e){wv(e);let t=this.options;if(e===`**`)return Y;if(e===``)return``;let{nocase:n,nocaseMagicOnly:r,noext:i=!1,dot:a,normalize:o}=t,s=this.#l,c=s&&e.includes(s)?void 0:Jv(e,i);if(c!==void 0&&(!n||r||e.toUpperCase()===e.toLowerCase()))return this.#d(c);if(this.#c)return dy;let l=this.#s.get(e);return l||(i||Xv(e),l=new Cv(e,{nocase:n,noext:i,dot:a,normalize:o,...s&&{rangeMark:s}}),this.#s.set(e,l)),l}#E(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options,r=this.#_(e);if(!r){if(!t&&!this.#r&&(this.#e||this.#t)&&$v!==e){$v=e;let t=this.#m(e);if(t===`no`)return!n.flipNegate&&this.negate;if(t===`yes`)return n.flipNegate?!0:!this.negate}r=this.#v(e)}let i=r.parts,a=this.#n?r.resolved??=this.#y(i):i,o=this.set,s=i[i.length-1];if(!s)for(let e=i.length-2;!s&&e>=0;e--)s=i[e];for(let e=0;e<o.length;e++){let r=o[e],c=t?void 0:this.#a[e];if(c===`base`?ey(r[0],s):c?this.#h(a,r,c):n.matchBase&&r.length===1?this.#b([s],[s],r,t):this.#b(i,a,r,t))return n.flipNegate?!0:!this.negate}return!n.flipNegate&&this.negate}static defaults(e){return J.defaults(e).Minimatch}};J.Minimatch=fy,J.escape=Tv,J.unescape=Ev;const py=/[/\\]/u,my={kind:`ignore`},hy=e=>!ae(e)&&e.split(py).every(e=>e!==`.`&&e!==`..`),gy=/^!+/u,_y=/^\.?\/+/u,vy=e=>{let t=gy.exec(e)?.[0]??``;return{body:e.slice(t.length).replace(_y,``),negated:t.length%2==1}},yy=e=>vy(e).negated,by=e=>vy(e).body,xy=/[?[\]{}()]/u,Sy=e=>hy(e)&&!yy(e)&&!xy.test(e),Cy=(e,t)=>J(e,t),wy=e=>e.replaceAll(/\/+/gu,`/`).replace(/\/$/u,``),Ty=e=>{let t=wy(e).split(`/`),n=t.findIndex(e=>e.includes(`*`));return n===-1?my:{baseDir:n===0?`.`:t.slice(0,n).join(`/`),kind:`expand-children`,pattern:wy(e),suffix:t.slice(n+1).join(`/`)}},Ey=e=>{let t=wy(e).split(`/`).filter(e=>e.includes(`*`));return t.length<=1&&!t.includes(`**`)},Dy=e=>{let t=wy(e).split(`/`),n=t.findIndex(e=>e.includes(`*`));return n<=0?`.`:t.slice(0,n).join(`/`)},Oy=e=>Sy(e)?e.includes(`*`)?Ey(e)?Ty(e):{baseDir:Dy(e),kind:`expand-recursive`,pattern:wy(e)}:{dir:e,kind:`probe-dir`,pattern:e}:my,ky=/* @__PURE__ */ new Set([`candidate_not_inspected`,`scan_budget_exhausted`,`manifest_unreadable`,`unsupported_pattern`,`workspace_declaration_unparsed`,`workspace_dir_unreadable`,`workspace_file_unreadable`]),Ay=(e,t)=>t?.name?{name:t.name,path:e}:void 0,jy=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},My=e=>!e.diagnostics.some(e=>ky.has(e.kind)),Ny=e=>!e.diagnostics.some(e=>e.kind===`no_workspace_declaration`),Py=(e,t)=>e<t?-1:+(e>t),Fy=e=>`path`in e?`${e.kind} ${e.path}`:`file`in e?`${e.kind} ${e.file}`:`pattern`in e?`${e.kind} ${e.pattern}`:e.kind,Iy=e=>e.toSorted((e,t)=>Py(Fy(e),Fy(t))),Ly=e=>!ae(e)&&!e.split(/[/\\]/u).includes(`..`),Ry=(e,t)=>e.kind===`missing`?{kind:`absent`}:e.kind===`outside`?{kind:`unreadable`,reason:`${t} escapes the checkout`}:{kind:`unreadable`,reason:e.code},zy=async(e,t,n)=>{if(!Ly(t))return{kind:`unreadable`,reason:`path escapes the checkout`};let r=await By(e,t);if(`probe`in r)return r.probe;let i=await Vy(r.real);return`reason`in i?{kind:`unreadable`,reason:i.reason}:i.found===n?{kind:`match`}:{found:i.found,kind:`mismatch`}},By=async(e,t)=>{let n=await W(e,v(e,t));if(n.kind!==`inside`)return{probe:Ry(n,`path`)};let r=await W(e,v(n.real,`package.json`));return r.kind===`inside`?{real:r.real}:{probe:Ry(r,`manifest`)}},Vy=async e=>{try{let t=JSON.parse(await s(e,`utf8`));return{found:ad(t)}}catch(e){return{reason:e.code??`manifest could not be read or interpreted`}}},Hy=(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(Py)}},Uy=`package.json`,Wy=/^\.\/[^\s%?#\\]*$/u,Gy=async e=>{try{return(await p(e)).isDirectory()?`directory`:`file`}catch{return`unverifiable`}},Ky=async(e,t)=>{if(!Wy.test(t)||t.includes(`*`))return`not_checked`;let n=v(e,t.slice(2)),r=await W(e,n);return r.kind===`inside`?Gy(r.real):r.kind===`missing`&&await Xu(e,n)?`absent`:`unverifiable`},qy=async(e,t,n)=>Array.isArray(t)?{alternatives:await Promise.all(t.map(t=>Jy(e,t,n+1))),kind:`alternatives`}:{branches:await Promise.all(Object.entries(t).map(async([t,r])=>({condition:t,value:await Jy(e,r,n+1)}))),kind:`conditions`},Jy=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 Ky(e,t),target:t}:typeof t==`object`?qy(e,t,n):{kind:`unsupported`,reason:`unexpected ${typeof t}`},Yy=[`main`,`module`,`types`,`typings`],Xy=(e,t)=>{let n=Yy.filter(e=>typeof t[e]==`string`);return Promise.all(n.map(async n=>({from:n,subpath:`.`,value:await Jy(e,Zy(t[n]),0)})))},Zy=e=>e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)?e:`./${e}`,Qy=async(e,t)=>{if(typeof t==`string`||Array.isArray(t))return[{from:`exports`,subpath:`.`,value:await Jy(e,t,0)}];if(t===void 0)return[];if(typeof t!=`object`||!t)return[{from:`exports`,subpath:`.`,value:await Jy(e,t,0)}];let n=Object.keys(t);return n.length>0&&!n.some(e=>e.startsWith(`.`))?[{from:`exports`,subpath:`.`,value:await Jy(e,t,0)}]:Promise.all(Object.entries(t).map(async([t,n])=>({from:`exports`,subpath:t,value:await Jy(e,n,0)})))},$y=async(e,t)=>{let n=await W(e,v(e,Uy));if(n.kind!==`inside`)return{entries:[],manifest:Uy,reason:n.kind,status:`unverifiable`};try{let r=JSON.parse(await s(n.real,`utf8`));return r.name===t?{entries:[...await Qy(e,r.exports),...await Xy(e,r)],manifest:Uy,status:`complete`}:{entries:[],manifest:Uy,reason:`manifest no longer names this package`,status:`unverifiable`}}catch(e){return{entries:[],manifest:Uy,reason:e.code??`manifest could not be read or interpreted`,status:`unverifiable`}}},eb=xl.partial({description:!0}),tb=I({default_branch:nl,key:al,tag_format_candidate:ul.nullable(),url:P().min(1)});tb.extend({description:P().default(``),packages:hl(eb)});const nb=tb.extend({description:P().min(1),packages:hl(xl)}),rb=I({effective_clone_mode:cl.optional(),head_sha:P().regex(/^[0-9a-f]{40}$/u,`head_sha must be a 40-character lowercase hex string`).optional(),last_error:P().optional(),last_fetched_at:Wc().optional(),pending_proposal_at:Wc().optional()}),ib=I({refs:pl(e=>e.length>0&&!fl.has(e),()=>`state ref key must be non-empty and not "__proto__", "constructor", or "prototype"`,gc(P(),rb)).default({})}),ab=(e,t,n)=>t?.[e]??n[e],ob=async e=>{try{return await s(e.statePath,`utf8`)}catch(e){if(z(e))return;throw e}},sb=e=>{try{return JSON.parse(e)}catch{return}},cb=async e=>{let t=await ob(e);if(t===void 0)return ib.parse({});let n=sb(t);if(n===void 0)return ib.parse({});let r=ib.safeParse(n);return r.success?r.data:ib.parse({})},lb=async(e,t)=>{let n=ib.safeParse(t);if(!n.success)throw V(T(n.error));await uu(e.statePath,`${JSON.stringify(n.data,void 0,2)}\n`)},ub=/^\d+\.\d+\.\d+$/u,db=/^0+(?=\d)/u,fb=(e,t)=>{let n=e.replace(db,``),r=t.replace(db,``);return n.length===r.length?n===r?0:n<r?-1:1:n.length<r.length?-1:1},pb=(e,t)=>{if(!ub.test(e)||!ub.test(t))return;let n=e.split(`.`),r=t.split(`.`);return n.map((e,t)=>fb(e,r[t]??``)).find(e=>e!==0)??0},mb=uc({version:P().regex(ub)}),hb=I({checked_at:Wc(),latest_version:P().regex(ub)}),gb=async e=>{try{let t=hb.safeParse(JSON.parse(await s(e.updateCachePath,`utf8`)));return t.success?t.data:void 0}catch{return}},_b=async(e,t)=>{try{await p(e.root),await uu(e.updateCachePath,`${JSON.stringify(t,void 0,2)}\n`)}catch{}},vb=(e,t)=>{let n=t-Date.parse(e.checked_at);return n>=0&&n<864e5},yb=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=mb.safeParse(await t.json());return n.success?n.data.version:void 0}catch{return}},bb=async e=>{let t=await gb(e.home);if(t!==void 0&&vb(t,e.nowMs))return{latest:t.latest_version,refreshed:!1,stale:!1};let n=await yb(e.fetch);return n===void 0?{latest:t?.latest_version,refreshed:!1,stale:!0}:(await _b(e.home,{checked_at:new Date(e.nowMs).toISOString(),latest_version:n}),{latest:n,refreshed:!0,stale:!1})},xb=(e,t)=>{let n=pb(e,t);return n!==void 0&&n<0},Sb=(e,t)=>`refs ${t} is available (this is ${e}) — update: npm i -g @kaisers-io/refs@latest`,Cb=e=>{let t=e.REFS_UPDATE_CHECK?.trim();if(t===`0`)return!1;if(t===`1`)return!0},wb=e=>{let t=e.CI?.trim().toLowerCase();return t!==void 0&&t!==``&&t!==`false`&&t!==`0`},Tb={check:!0,notify:!0},Eb=e=>{let t=Cb(e.env);return t===void 0?(e.updates??Tb).check?wb(e.env)?`ci`:`on`:`config`:t?`on`:`env`},Db=e=>Eb(e)===`on`,Ob=e=>Db(e)&&(e.updates??Tb).notify,kb=async(e,t)=>{let n=await W(e,v(t,`package.json`));if(n.kind===`inside`)try{let e=JSON.parse(await s(n.real,`utf8`));return{name:ad(e),version:od(e)}}catch{return}},Ab=async(e,t)=>{let n=await kb(e,v(e,t));if(n===void 0)return{diagnostic:{kind:`manifest_unreadable`,path:t}};let r=Ay(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}},jb=e=>Object.fromEntries(e.flatMap(e=>e.pkg===void 0||e.version===void 0?[]:[[e.pkg.path,e.version]])),Mb=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:jb(e)}},Nb=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),Pb=async(e,t)=>{let n=await W(e,v(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`}},Fb=async e=>{try{return{entries:await c(e,{withFileTypes:!0})}}catch(e){return{code:e.code??``}}},Ib=e=>Promise.all(e.entries.map(t=>Pb(e.repoDir,v(e.fullPath,t.name,e.suffix)))),Lb=(e,t,n)=>e.filter((e,r)=>n(t[r])).map(e=>e.name),Rb=async e=>{let{baseDir:t,dirs:n,fullPath:r,repoDir:i,suffix:a,symlinks:o}=e,s=e=>se.join(t===`.`?``:t,e,a),[c,l]=await Promise.all([Ib({entries:n,fullPath:r,repoDir:i,suffix:a}),Ib({entries:o,fullPath:r,repoDir:i,suffix:a})]);return{diagnostics:[...Lb(n,c,e=>e===`rejected`).map(e=>({kind:`manifest_unreadable`,path:s(e)})),...Lb(o,l,e=>e!==`none`).map(e=>({kind:`candidate_not_inspected`,path:s(e)}))],dirs:Lb(n,c,e=>e===`manifest`).map(e=>s(e))}},zb=async e=>{let t=await Ab(e,`.`);return`pkg`in t?[t]:[]},Bb=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]},Vb=async e=>{let[t]=await zb(e);return t!==void 0&&`pkg`in t?t.pkg:void 0},Hb=`package.json`,Ub=e=>{let t=wy(e).split(`/`);return t.includes(`**`)?void 0:t.length},Wb=e=>wy(e).split(`/`).some(e=>e.startsWith(`.`)),Gb=e=>e===`.`?0:e.split(`/`).length,Kb=e=>{let t=wy(e),n=new fy(`${t}/${Hb}`),r=new fy(t);return{couldHold:e=>r.match(e,!0),selects:e=>n.match(se.join(e,Hb))}},qb=e=>({...Kb(e),maxDepth:Ub(e),selectsHidden:Wb(e)}),Jb=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),Yb=/* @__PURE__ */ new Set([`.git`,`node_modules`]),Xb=e=>e.some(e=>e.name.toLowerCase()===`package.json`&&!e.isDirectory()),Zb=e=>e.some(e=>e.isSymbolicLink()&&!Yb.has(e.name)),Qb=async(e,t)=>{let n=await Fb(t);return`code`in n?{answer:Jb.has(n.code)}:(e.budget.entries-=n.entries.length,e.budget.entries<0||Xb(n.entries)||Zb(n.entries)?{answer:!1}:{entries:n.entries})},$b=async(e,t,n)=>{if(e.budget.dirs<=0||n>32)return!1;--e.budget.dirs;let r=await Qb(e,t);return`answer`in r?r.answer:ex(e,{dir:t,entries:r.entries},n)},ex=async(e,t,n)=>{let r=t.entries.filter(e=>e.isDirectory()&&!Yb.has(e.name));for(let i of r)if(!await $b(e,v(t.dir,i.name),n+1))return!1;return!0},tx=async(e,t)=>{let n=await W(e.repoDir,v(e.repoDir,t));n.kind!==`outside`&&n.kind!==`missing`&&(n.kind===`unreadable`?e.diagnostics.push({kind:`candidate_not_inspected`,path:t}):await $b(e,n.real,1)||e.diagnostics.push({kind:`candidate_not_inspected`,path:t}))},nx=()=>({dirs:2e4,entries:2e5}),rx=/* @__PURE__ */ new Set([`.git`,`node_modules`]),ix=(e,t)=>{e.diagnostics.push({kind:`scan_budget_exhausted`,path:t,pattern:e.pattern})},ax=async(e,t,n)=>{if(!e.selects(t)||n.has(t))return;let r=await Pb(e.repoDir,v(e.repoDir,t));r===`manifest`&&e.dirs.push(t),r===`rejected`&&e.diagnostics.push({kind:`manifest_unreadable`,path:t})},ox=(e,t)=>!e.selectsHidden&&t.excluded.coversSubtree(t.relPath),sx=async(e,t,n)=>!e.couldHold(n.relPath)||rx.has(t.name)||ox(e,n)?!1:t.isSymbolicLink()?(ox(e,n)||await tx(e,n.relPath),!1):t.isDirectory(),cx=async(e,t)=>{let n=await Fb(v(e.repoDir,t));if(`code`in n)Nb.has(n.code)||e.diagnostics.push({kind:`workspace_dir_unreadable`,path:t});else if(e.budget.entries-=n.entries.length,e.budget.entries<0)ix(e,t);else return n.entries},lx=async(e,t,n)=>{if(e.budget.dirs<=0){ix(e,t.relPath);return}if(--e.budget.dirs,await ax(e,t.relPath,n),e.maxDepth!==void 0&&Gb(t.relPath)>=e.maxDepth)return;let r=await cx(e,t.relPath);r!==void 0&&await dx(e,{depth:t.depth,entries:r,relPath:t.relPath},n)},ux=(e,t)=>se.join(e===`.`?``:e,t),dx=async(e,t,n)=>{for(let r of t.entries){let i=ux(t.relPath,r.name);await sx(e,r,{excluded:n,relPath:i})&&(t.depth+1>32?ix(e,i):await lx(e,{depth:t.depth+1,relPath:i},n))}},fx=async(e,t)=>{let n=await W(e,v(e,t));if(n.kind!==`inside`)return n.kind===`missing`?{diagnostics:[],dirs:[]}:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}},px=async(e,t,n)=>{let r=await fx(e,t.baseDir);if(r!==void 0)return r;let i={...qb(t.pattern),budget:n.budget,diagnostics:[],dirs:[],pattern:t.pattern,repoDir:e};return await lx(i,{depth:1,relPath:t.baseDir},n.excluded),{diagnostics:i.diagnostics,dirs:i.dirs}},mx=(e,t)=>se.join(e.baseDir===`.`?``:e.baseDir,t,e.suffix),hx=(e,t)=>Cy(mx(t,e.name),t.pattern),gx=async(e,t)=>{let n=v(e,t),r=await W(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 Fb(n);return`code`in i?{result:Nb.has(i.code)?{diagnostics:[],dirs:[]}:{diagnostics:[{kind:`workspace_dir_unreadable`,path:t}],dirs:[]}}:{entries:i.entries}},_x=async(e,t,n)=>{let{baseDir:r}=t,i=await gx(e,r);if(`result`in i)return i.result;let a=e=>hx(e,t)&&!n.has(mx(t,e.name)),o={entries:i.entries};return Rb({baseDir:r,dirs:o.entries.filter(e=>e.isDirectory()&&a(e)),fullPath:v(e,r),repoDir:e,suffix:t.suffix,symlinks:o.entries.filter(e=>e.isSymbolicLink()&&a(e))})},vx=async(e,t)=>{let n=await Pb(e,v(e,t));return n===`manifest`?{diagnostics:[],dirs:[wy(t)]}:n===`rejected`?{diagnostics:[{kind:`manifest_unreadable`,path:t}],dirs:[]}:{diagnostics:[],dirs:[]}},yx=(e,t,n)=>{let{excluded:r}=n,i=Oy(t.body);return i.kind===`expand-children`?_x(e,i,r):i.kind===`expand-recursive`?px(e,i,n):i.kind===`probe-dir`?r.has(wy(i.dir))?Promise.resolve({diagnostics:[],dirs:[]}):vx(e,i.dir):Promise.resolve({diagnostics:[{kind:`unsupported_pattern`,pattern:t.declared}],dirs:[]})},bx=(e,t)=>Cy(by(e),by(t)),xx=e=>({negations:e.filter(e=>yy(e)),patterns:e.filter(e=>!yy(e))}),Sx=e=>{let t=e.reduce((e,t)=>yy(t)?{negations:[...e.negations,t],patterns:e.patterns}:{negations:e.negations.filter(e=>!bx(t,e)),patterns:[...e.patterns,t]},{negations:[],patterns:[]});return{negations:t.negations,patterns:t.patterns.filter(e=>!t.negations.some(t=>bx(e,t)))}},Cx=e=>e.endsWith(`/`)?e:`${e}/`,wx=(e,t)=>e.some(e=>Cy(Cx(t),Cx(by(e)))),Tx=(e,t)=>{let n=by(e);return n.endsWith(`/**`)&&Cy(t,n.slice(0,-3))},Ex=e=>({coversSubtree:t=>e.some(e=>Tx(e,t)),has:t=>wx(e,t)}),Dx=e=>{let t=/* @__PURE__ */ new Set,n=[];for(let r of e)r.dirs.forEach(e=>t.add(e)),n.push(...r.diagnostics);return{diagnostics:n,dirs:[...t]}},Ox=async(e,t,n)=>{let{negations:r,patterns:i}=t,a=Ex(r),o=Dx(await Promise.all(i.map(t=>yx(e,{body:by(t),declared:t},{budget:n,excluded:a}))));return{diagnostics:o.diagnostics,dirs:o.dirs}},kx=async(e,t)=>{let n=Sx(t.npm),r=xx(t.pnpm),i=nx(),a=await Promise.all([Ox(e,n,i),Ox(e,r,i)]);return Dx(a)},Ax=async e=>{let t=await pd(e);if(t.npm.length===0&&t.pnpm.length===0)return{diagnostics:Iy([...t.diagnostics,{kind:`no_workspace_declaration`}]),packages:[],versions:{}};let n=await kx(e,t),[r,i]=await Promise.all([zb(e),Promise.all(n.dirs.map(t=>Ab(e,t)))]),a=Mb([...r,...i]);return{diagnostics:Iy([...t.diagnostics,...n.diagnostics,...a.diagnostics]),packages:Bb(jy(a.packages)),versions:a.versions}},jx=()=>{},Mx={stop:jx,update:jx},Nx={frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],interval:80},Px={frames:[`-`,`\\`,`|`,`/`],interval:130},Fx=`\r\x1B[K`,Ix={24:`\x1B[38;2;7;210;86m`,4:`\x1B[32m`,8:`\x1B[38;5;41m`},Lx=/[^ -~]/gu,Rx=(e,t)=>t.isTTY===!0&&e.TERM!==`dumb`&&!wb(e)&&e.REFS_PROGRESS?.trim()!==`0`,zx=/* @__PURE__ */ new Set([`alacritty`,`rxvt-unicode`,`rxvt-unicode-256color`,`xterm-256color`]),Bx=(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`||zx.has(e.TERM??``):e.TERM!==`linux`,Vx=(e,t)=>e.replaceAll(Lx,`?`).slice(0,Math.max(0,t)),Hx=(e,t,n)=>{let r=(e.stream.columns??80)-3,i=Ix[e.stream.getColorDepth?.(e.env)??1],a=i===void 0?t:`${i}${t}`;return`${Fx}${a} ${Vx(n,r)}`},Ux=e=>{if(!Rx(e.env,e.stream))return Mx;let{frames:t,interval:n}=Bx(e.env,e.platform)?Nx:Px,r={drawn:!1,index:0,stopped:!1,text:``},i=()=>{e.stream.write(Hx(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(Fx),!1)},update:e=>{r.stopped||(r.text=e,a.delay??=setTimeout(o,100).unref())}}};var Wx=`0.19.2`;const Gx=async()=>{let e=[];for await(let t of process.stdin)e.push(Buffer.from(t));return Buffer.concat(e).toString(`utf8`)},Kx=()=>{try{return me()}catch{return``}},qx=()=>({cliVersion:Wx,cwd:process.cwd(),env:process.env,errLine:e=>{process.stderr.write(`${e}\n`)},fetcher:(e,t)=>fetch(e,t),homedir:Kx(),nodeVersion:process.version,out:e=>{process.stdout.write(`${e}\n`)},readStdin:Gx,runner:new sp({defaultTimeoutMs:Lp(process.env),env:process.env}),spinner:()=>Ux({env:process.env,platform:process.platform,stream:process.stderr})});var Jx=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}},Yx=class extends Jx{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},Xx=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 Yx(`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 Zx(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}var Qx=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).helpGroup(n.helpGroupHeading)):n.short&&!r&&t.push(e.createOption(n.short,n.description).helpGroup(n.helpGroupHeading))}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=>Zx(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=/* @__PURE__ */ 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(`
440
442
  `)}displayWidth(e){return be(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,`
441
443
  `+` `.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(`
442
- `)}},Lx=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=Bx(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 Nx(`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?zx(this.name().replace(/^no-/,``)):zx(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}},Rx=class{constructor(e){this.positiveOptions=/* @__PURE__ */ new Map,this.negativeOptions=/* @__PURE__ */ new Map,this.dualOptions=/* @__PURE__ */ 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 zx(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Bx(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}
444
+ `)}},$x=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\p{ID_Continue}\.\.\.[>\]]$/u.test(e),this.mandatory=!1;let n=nS(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 Yx(`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?tS(this.name().replace(/^no-/,``)):tS(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}},eS=class{constructor(e){this.positiveOptions=/* @__PURE__ */ new Map,this.negativeOptions=/* @__PURE__ */ new Map,this.dualOptions=/* @__PURE__ */ 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 tS(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function nS(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}
443
445
  - a short flag is a single dash and a single character
444
446
  - either use a single dash and a single character (for a short flag)
445
447
  - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):r.test(t)?Error(`${n}
446
448
  - too many short flags`):i.test(t)?Error(`${n}
447
449
  - too many long flags`):Error(`${n}
448
- - unrecognised flag format`)}if(t===void 0&&n===void 0)throw Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}function Vx(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++){let a;a=e[i-1]===t[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+a),i>1&&r>1&&e[i-1]===t[r-2]&&e[i-2]===t[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[e.length][t.length]}function Hx(e,t){if(!t||t.length===0)return``;t=Array.from(new Set(t));let n=e.startsWith(`--`);n&&(e=e.slice(2),t=t.map(e=>e.slice(2)));let r=[],i=3;return t.forEach(t=>{if(t.length<=1)return;let n=Vx(e,t),a=Math.max(e.length,t.length);(a-n)/a>.4&&(n<i?(i=n,r=[t]):n===i&&r.push(t))}),r.sort((e,t)=>e.localeCompare(t)),n&&(r=r.map(e=>`--${e}`)),r.length>1?`\n(Did you mean one of ${r.join(`, `)}?)`:r.length===1?`\n(Did you mean ${r[0]}?)`:``}var Ux=class e extends ge{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||``,this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description=``,this._summary=``,this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>y.stdout.write(e),writeErr:e=>y.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>y.stdout.isTTY?y.stdout.columns:void 0,getErrHelpWidth:()=>y.stderr.isTTY?y.stderr.columns:void 0,getOutHasColors:()=>Gx()??(y.stdout.isTTY&&y.stdout.hasColors?.()),getErrHasColors:()=>Gx()??(y.stderr.isTTY&&y.stderr.hasColors?.()),stripColor:e=>be(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let r=t,i=n;typeof r==`object`&&r&&(i=r,r=null),i||={};let[,a,o]=e.match(/([^ ]+) *(.*)/),s=this.createCommand(a);return r&&(s.description(r),s._executableHandler=!0),i.isDefault&&(this._defaultCommandName=s._name),s._hidden=!!(i.noHelp||i.hidden),s._executableFile=i.executableFile||null,o&&s.arguments(o),this._registerCommand(s),s.parent=this,s.copyInheritedSettings(this),r?this:s}createCommand(t){return new e(t)}createHelp(){return Object.assign(new Ix,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!=`string`&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw Error(`Command passed to .addCommand() must have a name
449
- - specify the name in Command constructor or using .name()`);return t||={},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new Px(e,t)}argument(e,t,n,r){let i=this.createArgument(e,t);return typeof n==`function`?i.default(r).argParser(n):i.default(n),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e==`boolean`)return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let[,n,r]=(e??`help [command]`).match(/([^ ]+) *(.*)/),i=t??`display help for command`,a=this.createCommand(n);return a.helpOption(!1),r&&a.arguments(r),i&&a.description(i),this._addImplicitHelpCommand=!0,this._helpCommand=a,(e||t)&&this._initCommandGroup(a),this}addHelpCommand(e,t){return typeof e==`object`?(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this):(this.helpCommand(e,t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand(`help`))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=[`preSubcommand`,`preAction`,`postAction`];if(!n.includes(e))throw Error(`Unexpected value for event passed to hook : '${e}'.
450
- Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return this._exitCallback=e||(e=>{if(e.code!==`commander.executeSubCommandAsync`)throw e}),this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new Mx(e,t,n)),y.exit(e)}action(e){let t=t=>{let n=this.registeredArguments.length,r=t.slice(0,n);return r[n]=this._storeOptionsAsProperties?this:this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new Lx(e,t)}_callParseArg(e,t,n,r){try{return e.parseArg(t,n)}catch(e){if(e.code===`commander.invalidArgument`){let t=`${r} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
451
- - already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=e=>[e.name()].concat(e.aliases()),n=t(e).find(e=>this._findCommand(e));if(n){let r=t(this._findCommand(n)).join(`|`),i=t(e).join(`|`);throw Error(`cannot add command '${i}' as already have command '${r}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,`default`);let r=(t,r,i)=>{t==null&&e.presetArg!==void 0&&(t=e.presetArg);let a=this.getOptionValue(n);t!==null&&e.parseArg?t=this._callParseArg(e,t,a,r):t!==null&&e.variadic&&(t=e._collectValue(t,a)),t??=e.negate?!1:e.isBoolean()||e.optional?!0:``,this.setOptionValueWithSource(n,t,i)};return this.on(`option:`+t,t=>{let n=`error: option '${e.flags}' argument '${t}' is invalid.`;r(t,n,`cli`)}),e.envVar&&this.on(`optionEnv:`+t,t=>{let n=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;r(t,n,`env`)}),this}_optionEx(e,t,n,r,i){if(typeof t==`object`&&t instanceof Lx)throw Error(`To add an Option object use addOption() instead of option() or requiredOption()`);let a=this.createOption(t,n);if(a.makeOptionMandatory(!!e.mandatory),typeof r==`function`)a.default(i).argParser(r);else if(r instanceof RegExp){let e=r;r=(t,n)=>{let r=e.exec(t);return r?r[0]:n},a.default(i).argParser(r)}else a.default(r);return this.addOption(a)}option(e,t,n,r){return this._optionEx({},e,t,n,r)}requiredOption(e,t,n,r){return this._optionEx({mandatory:!0},e,t,n,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw Error(`call .storeOptionsAsProperties() before adding options`);if(Object.keys(this._optionValues).length)throw Error(`call .storeOptionsAsProperties() before setting option values`);return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw Error(`first parameter to parse must be array or undefined`);if(t||={},e===void 0&&t.from===void 0){y.versions?.electron&&(t.from=`electron`);let e=y.execArgv??[];(e.includes(`-e`)||e.includes(`--eval`)||e.includes(`-p`)||e.includes(`--print`))&&(t.from=`eval`)}e===void 0&&(e=y.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case`node`:this._scriptPath=e[1],n=e.slice(2);break;case`electron`:y.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case`user`:n=e.slice(0);break;case`eval`:n=e.slice(1);break;default:throw Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||`program`,n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?(this.options.filter(e=>e.negate&&e.defaultValue===void 0&&this.getOptionValue(e.attributeName())===void 0).forEach(e=>{let t=e.long.replace(/^--no-/,`--`);this._findOption(t)||this.setOptionValueWithSource(e.attributeName(),!0,`default`)}),this.saveStateBeforeParse()):this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
450
+ - unrecognised flag format`)}if(t===void 0&&n===void 0)throw Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}function rS(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++){let a;a=e[i-1]===t[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+a),i>1&&r>1&&e[i-1]===t[r-2]&&e[i-2]===t[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[e.length][t.length]}function iS(e,t){if(!t||t.length===0)return``;t=Array.from(new Set(t));let n=e.startsWith(`--`);n&&(e=e.slice(2),t=t.map(e=>e.slice(2)));let r=[],i=3;return t.forEach(t=>{if(t.length<=1)return;let n=rS(e,t),a=Math.max(e.length,t.length);(a-n)/a>.4&&(n<i?(i=n,r=[t]):n===i&&r.push(t))}),r.sort((e,t)=>e.localeCompare(t)),n&&(r=r.map(e=>`--${e}`)),r.length>1?`\n(Did you mean one of ${r.join(`, `)}?)`:r.length===1?`\n(Did you mean ${r[0]}?)`:``}var aS=class e extends ge{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||``,this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description=``,this._summary=``,this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>y.stdout.write(e),writeErr:e=>y.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>y.stdout.isTTY?y.stdout.columns:void 0,getErrHelpWidth:()=>y.stderr.isTTY?y.stderr.columns:void 0,getOutHasColors:()=>sS()??(y.stdout.isTTY&&y.stdout.hasColors?.()),getErrHasColors:()=>sS()??(y.stderr.isTTY&&y.stderr.hasColors?.()),stripColor:e=>be(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let r=t,i=n;typeof r==`object`&&r&&(i=r,r=null),i||={};let[,a,o]=e.match(/([^ ]+) *(.*)/),s=this.createCommand(a);return r&&(s.description(r),s._executableHandler=!0),i.isDefault&&(this._defaultCommandName=s._name),s._hidden=!!(i.noHelp||i.hidden),s._executableFile=i.executableFile||null,o&&s.arguments(o),this._registerCommand(s),s.parent=this,s.copyInheritedSettings(this),r?this:s}createCommand(t){return new e(t)}createHelp(){return Object.assign(new Qx,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!=`string`&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw Error(`Command passed to .addCommand() must have a name
451
+ - specify the name in Command constructor or using .name()`);return t||={},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new Xx(e,t)}argument(e,t,n,r){let i=this.createArgument(e,t);return typeof n==`function`?i.default(r).argParser(n):i.default(n),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e==`boolean`)return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let[,n,r]=(e??`help [command]`).match(/([^ ]+) *(.*)/),i=t??`display help for command`,a=this.createCommand(n);return a.helpOption(!1),r&&a.arguments(r),i&&a.description(i),this._addImplicitHelpCommand=!0,this._helpCommand=a,(e||t)&&this._initCommandGroup(a),this}addHelpCommand(e,t){return typeof e==`object`?(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this):(this.helpCommand(e,t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand(`help`))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=[`preSubcommand`,`preAction`,`postAction`];if(!n.includes(e))throw Error(`Unexpected value for event passed to hook : '${e}'.
452
+ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return this._exitCallback=e||(e=>{if(e.code!==`commander.executeSubCommandAsync`)throw e}),this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new Jx(e,t,n)),y.exit(e)}action(e){let t=t=>{let n=this.registeredArguments.length,r=t.slice(0,n);return r[n]=this._storeOptionsAsProperties?this:this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new $x(e,t)}_callParseArg(e,t,n,r){try{return e.parseArg(t,n)}catch(e){if(e.code===`commander.invalidArgument`){let t=`${r} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
453
+ - already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=e=>[e.name()].concat(e.aliases()),n=t(e).find(e=>this._findCommand(e));if(n){let r=t(this._findCommand(n)).join(`|`),i=t(e).join(`|`);throw Error(`cannot add command '${i}' as already have command '${r}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,`default`);let r=(t,r,i)=>{t==null&&e.presetArg!==void 0&&(t=e.presetArg);let a=this.getOptionValue(n);t!==null&&e.parseArg?t=this._callParseArg(e,t,a,r):t!==null&&e.variadic&&(t=e._collectValue(t,a)),t??=e.negate?!1:e.isBoolean()||e.optional?!0:``,this.setOptionValueWithSource(n,t,i)};return this.on(`option:`+t,t=>{let n=`error: option '${e.flags}' argument '${t}' is invalid.`;r(t,n,`cli`)}),e.envVar&&this.on(`optionEnv:`+t,t=>{let n=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;r(t,n,`env`)}),this}_optionEx(e,t,n,r,i){if(typeof t==`object`&&t instanceof $x)throw Error(`To add an Option object use addOption() instead of option() or requiredOption()`);let a=this.createOption(t,n);if(a.makeOptionMandatory(!!e.mandatory),typeof r==`function`)a.default(i).argParser(r);else if(r instanceof RegExp){let e=r;r=(t,n)=>{let r=e.exec(t);return r?r[0]:n},a.default(i).argParser(r)}else a.default(r);return this.addOption(a)}option(e,t,n,r){return this._optionEx({},e,t,n,r)}requiredOption(e,t,n,r){return this._optionEx({mandatory:!0},e,t,n,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw Error(`call .storeOptionsAsProperties() before adding options`);if(Object.keys(this._optionValues).length)throw Error(`call .storeOptionsAsProperties() before setting option values`);return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{Object.hasOwn(n._optionValueSources,e)&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw Error(`first parameter to parse must be array or undefined`);if(t||={},e===void 0&&t.from===void 0){y.versions?.electron&&(t.from=`electron`);let e=y.execArgv??[];(e.includes(`-e`)||e.includes(`--eval`)||e.includes(`-p`)||e.includes(`--print`))&&(t.from=`eval`)}e===void 0&&(e=y.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case`node`:this._scriptPath=e[1],n=e.slice(2);break;case`electron`:y.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case`user`:n=e.slice(0);break;case`eval`:n=e.slice(1);break;default:throw Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||`program`,n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?(this.options.filter(e=>e.negate&&e.defaultValue===void 0&&this.getOptionValue(e.attributeName())===void 0).forEach(e=>{let t=e.long.replace(/^--no-/,`--`);this._findOption(t)||this.setOptionValueWithSource(e.attributeName(),!0,`default`)}),this.saveStateBeforeParse()):this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
452
454
  - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(ee.existsSync(e))return;let r=`'${e}' does not exist
453
455
  - if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
454
456
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
455
- - ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let n=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function r(e,t){let r=re.resolve(e,t);if(ee.existsSync(r))return r;if(n.includes(re.extname(t)))return;let i=n.find(e=>ee.existsSync(`${r}${e}`));if(i)return`${r}${i}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||``;if(this._scriptPath){let e;try{e=ee.realpathSync(this._scriptPath)}catch{e=this._scriptPath}a=re.resolve(re.dirname(e),a)}if(a){let t=r(a,i);if(!t&&!e._executableFile&&this._scriptPath){let n=re.basename(this._scriptPath,re.extname(this._scriptPath));n!==this._name&&(t=r(a,`${n}-${e._name}`))}i=t||i}let o=n.includes(re.extname(i)),s;y.platform===`win32`?(this._checkForMissingExecutable(i,a,e._name),t.unshift(i),t=Wx(y.execArgv).concat(t),s=ve.spawn(y.execPath,t,{stdio:`inherit`})):o?(t.unshift(i),t=Wx(y.execArgv).concat(t),s=ve.spawn(y.argv[0],t,{stdio:`inherit`})):s=ve.spawn(i,t,{stdio:`inherit`}),s.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{y.on(e,()=>{s.killed===!1&&s.exitCode===null&&s.kill(e)})});let c=this._exitCallback;s.on(`close`,e=>{e??=1,c?c(new Mx(e,`commander.executeSubCommandAsync`,`(close)`)):y.exit(e)}),s.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(i,a,e._name);else if(t.code===`EACCES`)throw Error(`'${i}' not executable`);if(!c)y.exit(1);else{let e=new Mx(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,c(e)}}),this.runningCommand=s}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)!==void 0&&this.getOptionValueSource(t)!=="default"});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l)))this.emit(`option:${o.name()}`,l);else{if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
456
- `),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in y.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,y.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Rx(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=Hx(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=e.length,i=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${r}: ${e.join(`, `)}.`;this.error(i,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=Hx(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>Fx(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=re.basename(e,re.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(y.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
457
- Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function Wx(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function Gx(){if(y.env.NO_COLOR||y.env.FORCE_COLOR===`0`||y.env.FORCE_COLOR===`false`)return!1;if(y.env.FORCE_COLOR||y.env.CLICOLOR_FORCE!==void 0)return!0}new Ux;const Kx=[],qx=/\p{Cc}/gu,Jx=/[^\P{Cc}\n]/gu,Yx=e=>e.replaceAll(qx,`?`),Xx=e=>e.replaceAll(Jx,`?`),Zx=e=>Array.isArray(e)?e:[e],Qx=e=>e===void 0?Kx:[e],$x=e=>e instanceof Error?e.message:String(e),X=e=>{let t=e.optsWithGlobals();return{json:t.json===!0,verbose:t.verbose===!0}},Z=(e,t,n,r,i)=>{if(t.json){let t={data:r,ok:!0,warnings:i??Kx};e.out(JSON.stringify(t))}else{for(let t of Zx(n))e.out(Yx(t));for(let t of i??Kx)e.errLine(Yx(`refs: warning: ${t}`))}},eS=(e,t,n)=>{if(t.json){let t={error:{code:n.code,message:n.message,...n.reason===void 0?{}:{reason:n.reason}},ok:!1};e.out(JSON.stringify(t))}else e.errLine(Xx(`refs: ${n.message}`))},tS=(e,t)=>{e.errLine(Yx(`refs: ${t}`))},nS=async(e,t,n)=>{let r=t.json?gx:e.spinner();try{return await n(r)}finally{r.stop()}},Q=(e,t,n)=>async()=>{try{await n()}catch(n){let r=gu(n,{verbose:t.verbose});eS(e,t,r),process.exitCode=r.exitCode}},rS=/\p{Cc}/u,iS=e=>!rS.test(e)&&e.isWellFormed(),aS=e=>`'${e.replaceAll(`'`,String.raw`'\''`)}'`,oS=e=>typeof e==`string`?void 0:e[1],sS=e=>typeof e==`string`?e:`${e[0]}=${aS(e[1])}`,cS=(e,t)=>{if(![...e.map(e=>oS(e)).filter(e=>e!==void 0),...t].every(e=>iS(e)))return;let n=t.some(e=>e.startsWith(`-`))?[`--`]:[];return[`refs edit`,...e.map(e=>sS(e)),...n,...t.map(e=>aS(e))].join(` `)},lS=e=>{let t=typeof e==`string`?[e]:e;return t.every(e=>iS(e))?`rm -rf -- ${t.map(e=>aS(e)).join(` `)}`:void 0},uS=e=>iS(e)?`rmdir -- ${aS(e)}`:void 0,dS=e=>({path:e.path}),fS=e=>e.filter(e=>e.path!==`.`),pS=e=>e.find(e=>e.path===`.`),mS=e=>{let t=pS(e);return t===void 0?{}:{[t.name]:dS(t)}},hS=(e,t,n)=>{let r=fS(e),i=mS(e);return r.length>0?{...i,...Object.fromEntries(r.map(e=>[e.name,dS(e)]))}:n===void 0?i:{...i,[n]:{path:t??`.`}}},gS=e=>{let t=e.description??``;return e.tag_format===void 0?{description:t,path:e.path}:{description:t,path:e.path,tag_format:e.tag_format}},_S=(e,t)=>{let n=Object.entries(e);if(n.length!==0)return Object.fromEntries(n.map(([e,n])=>[e,gS(e===t.rootPackageName?yS(n,t.refDescription):n)]))},vS=(e,t)=>{let[n]=Object.keys(mS(e));if(n!==void 0)return t[n]?.path===`.`?n:void 0},yS=(e,t)=>({...e,description:t}),bS=(e,t)=>Object.keys(e).filter(e=>e!==t).toSorted(),xS=(e,t,n)=>{if(bS(e,n).length===0)return;let r=Object.keys(e).toSorted().map(e=>Yx(e)).join(`, `);throw V(`refs add --description cannot describe a package: it has one description, about the repository. Run the two-phase flow instead:
458
- refs add ${aS(t)} --dry-run --json > proposal.json\nFill in the ref's own description, and one written from its own source for each package below, then:
457
+ - ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let n=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function r(e,t){let r=g.resolve(e,t);if(ee.existsSync(r))return r;if(n.includes(g.extname(t)))return;let i=n.find(e=>ee.existsSync(`${r}${e}`));if(i)return`${r}${i}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||``;if(this._scriptPath){let e;try{e=ee.realpathSync(this._scriptPath)}catch{e=this._scriptPath}a=g.resolve(g.dirname(e),a)}if(a){let t=r(a,i);if(!t&&!e._executableFile&&this._scriptPath){let n=g.basename(this._scriptPath,g.extname(this._scriptPath));n!==this._name&&(t=r(a,`${n}-${e._name}`))}i=t||i}let o=n.includes(g.extname(i)),s;y.platform===`win32`?(this._checkForMissingExecutable(i,a,e._name),t.unshift(i),t=oS(y.execArgv).concat(t),s=ve.spawn(y.execPath,t,{stdio:`inherit`})):o?(t.unshift(i),t=oS(y.execArgv).concat(t),s=ve.spawn(y.argv[0],t,{stdio:`inherit`})):s=ve.spawn(i,t,{stdio:`inherit`}),s.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{y.on(e,()=>{s.killed===!1&&s.exitCode===null&&s.kill(e)})});let c=this._exitCallback;s.on(`close`,e=>{e??=1,c?c(new Jx(e,`commander.executeSubCommandAsync`,`(close)`)):y.exit(e)}),s.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(i,a,e._name);else if(t.code===`EACCES`)throw Error(`'${i}' not executable`);if(!c)y.exit(1);else{let e=new Jx(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,c(e)}}),this.runningCommand=s}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)!==void 0&&this.getOptionValueSource(t)!=="default"});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)([eE][+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l)))this.emit(`option:${o.name()}`,l);else{if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
458
+ `),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in y.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,y.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new eS(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=iS(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=e.length,i=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${r}: ${e.join(`, `)}.`;this.error(i,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=iS(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>Zx(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=g.basename(e,g.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(y.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
459
+ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function oS(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk|-wait)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function sS(){if(y.env.NO_COLOR||y.env.FORCE_COLOR===`0`||y.env.FORCE_COLOR===`false`)return!1;if(y.env.FORCE_COLOR||y.env.CLICOLOR_FORCE!==void 0)return!0}new aS;const cS=[],lS=/\p{Cc}/gu,uS=/[^\P{Cc}\n]/gu,dS=e=>e.replaceAll(lS,`?`),fS=e=>e.replaceAll(uS,`?`),pS=e=>Array.isArray(e)?e:[e],mS=e=>e===void 0?cS:[e],hS=e=>e instanceof Error?e.message:String(e),X=e=>{let t=e.optsWithGlobals();return{json:t.json===!0,verbose:t.verbose===!0}},Z=(e,t,n,r,i)=>{if(t.json){let t={data:r,ok:!0,warnings:i??cS};e.out(JSON.stringify(t))}else{for(let t of pS(n))e.out(dS(t));for(let t of i??cS)e.errLine(dS(`refs: warning: ${t}`))}},gS=(e,t,n)=>{if(t.json){let t={error:{code:n.code,message:n.message,...n.reason===void 0?{}:{reason:n.reason}},ok:!1};e.out(JSON.stringify(t))}else e.errLine(fS(`refs: ${n.message}`))},_S=(e,t)=>{e.errLine(dS(`refs: ${t}`))},vS=async(e,t,n)=>{let r=t.json?Mx:e.spinner();try{return await n(r)}finally{r.stop()}},Q=(e,t,n)=>async()=>{try{await n()}catch(n){let r=gu(n,{verbose:t.verbose});gS(e,t,r),process.exitCode=r.exitCode}},yS=/\p{Cc}/u,bS=e=>!yS.test(e)&&e.isWellFormed(),xS=e=>`'${e.replaceAll(`'`,String.raw`'\''`)}'`,SS=e=>typeof e==`string`?void 0:e[1],CS=e=>typeof e==`string`?e:`${e[0]}=${xS(e[1])}`,wS=(e,t)=>{if(![...e.map(e=>SS(e)).filter(e=>e!==void 0),...t].every(e=>bS(e)))return;let n=t.some(e=>e.startsWith(`-`))?[`--`]:[];return[`refs edit`,...e.map(e=>CS(e)),...n,...t.map(e=>xS(e))].join(` `)},TS=e=>{let t=typeof e==`string`?[e]:e;return t.every(e=>bS(e))?`rm -rf -- ${t.map(e=>xS(e)).join(` `)}`:void 0},ES=e=>bS(e)?`rmdir -- ${xS(e)}`:void 0,DS=e=>({path:e.path}),OS=e=>e.filter(e=>e.path!==`.`),kS=e=>e.find(e=>e.path===`.`),AS=e=>{let t=kS(e);return t===void 0?{}:{[t.name]:DS(t)}},jS=(e,t,n)=>{let r=OS(e),i=AS(e);return r.length>0?{...i,...Object.fromEntries(r.map(e=>[e.name,DS(e)]))}:n===void 0?i:{...i,[n]:{path:t??`.`}}},MS=e=>{let t=e.description??``;return e.tag_format===void 0?{description:t,path:e.path}:{description:t,path:e.path,tag_format:e.tag_format}},NS=(e,t)=>{let n=Object.entries(e);if(n.length!==0)return Object.fromEntries(n.map(([e,n])=>[e,MS(e===t.rootPackageName?FS(n,t.refDescription):n)]))},PS=(e,t)=>{let[n]=Object.keys(AS(e));if(n!==void 0)return t[n]?.path===`.`?n:void 0},FS=(e,t)=>({...e,description:t}),IS=(e,t)=>Object.keys(e).filter(e=>e!==t).toSorted(),LS=(e,t,n)=>{if(IS(e,n).length===0)return;let r=Object.keys(e).toSorted().map(e=>dS(e)).join(`, `);throw V(`refs add --description cannot describe a package: it has one description, about the repository. Run the two-phase flow instead:
460
+ refs add ${xS(t)} --dry-run --json > proposal.json\nFill in the ref's own description, and one written from its own source for each package below, then:
459
461
  refs add --proposal proposal.json
460
- packages to describe: ${r}`)},SS=e=>{if(Object.keys(e).length!==0)return e},CS=e=>{let t={default_branch:e.default_branch,description:e.description,url:e.url};return e.packages!==void 0&&(t.packages=e.packages),e.tag_format!==void 0&&(t.tag_format=e.tag_format),t},wS=`ref.`,TS=`${wS}_`,ES=`${TS}_`,DS=e=>`${ES}${fe(`sha256`).update(e,`utf8`).digest(`hex`)}`,OS=e=>{let t=e.includes(`_`)?`${TS}${e.replaceAll(`_`,`_u`).replaceAll(`/`,`_s`)}`:`${wS}${e.replaceAll(`/`,`_`)}`;return Buffer.byteLength(t,`utf8`)<=212&&Hg(t)?t:DS(e)},kS=e=>e.REFS_ALLOW_FILE_URLS===`1`,AS=(e,t)=>{let n=yh(t,{allowFileUrls:kS(e.env)});return{cloneUrl:n.cloneUrl,key:n.key}},jS=async(e,t)=>{if(t===``)throw B(`refs add npm: requires a package name, e.g. npm:left-pad`);tS(e,`resolving npm package '${t}'…`);let n=await o_(e.fetcher,t),r={cloneUrl:n.cloneUrl,key:n.key,npmPkgName:t};return n.directory!==void 0&&(r.npmDirectory=n.directory),r},MS=(e,t)=>t.startsWith(`npm:`)?jS(e,t.slice(4)):Promise.resolve(AS(e,t)),NS=(e,t)=>{if(e.npmPkgName===void 0)return e;let n=Uy(`git_transport`,void 0,t);return{...e,cloneUrl:Ah(e.cloneUrl,n)}},PS=e=>`ref '${e}' already exists — use refs edit or refs remove`,FS=(e,t)=>{if(e.refs[t]!==void 0)throw mu(PS(t))},IS=async e=>{try{return await c(e,{withFileTypes:!0})}catch(e){if(L(e))return;throw e}},LS=e=>e.filter(e=>e.isDirectory()).map(e=>e.name),RS=async(e,t)=>{let n=await IS(e);if(n===void 0)return{kind:`stop`};let r=LS(n);if(r.includes(t))return{kind:`continue`,nextDir:v(e,t)};let i=r.find(e=>e.toLowerCase()===t.toLowerCase());return i===void 0?{kind:`stop`}:{kind:`collision`,name:i}},zS=async(e,t,n)=>{let[r,...i]=t;if(r===void 0)return;let a=await RS(e,r);if(a.kind!==`stop`)return a.kind===`collision`?[...n,a.name].join(`/`):zS(a.nextDir,i,[...n,r])},BS=[],VS=async(e,t)=>{let n=await zS(e.sourcesDir,t.split(`/`),BS);if(n!==void 0)throw mu(`checkout path for '${t}' collides case-insensitively with existing '${n}'`)},HS=(e,t,n)=>{let r=n.scan.versions[e];return r===void 0?null:Km(n.tags,r,t)},US=e=>{let t=e.scan.packages.find(e=>e.path===`.`);if(t===void 0)return e.counted;let n=HS(`.`,t.name,{scan:e.scan,tags:e.tags});return n===null||Vm(n,t.name)?e.counted:n},WS=e=>e.format===null||e.format===e.refFormat||!Vm(e.format,e.name)?e.entry:{...e.entry,tag_format:e.format},GS=e=>{let t={scan:e.scan,tags:e.tags};return Object.fromEntries(Object.entries(e.packages).map(([n,r])=>[n,WS({entry:r,format:HS(r.path,n,t),name:n,refFormat:e.refFormat})]))},KS=e=>{switch(e.kind){case`candidate_not_inspected`:case`manifest_missing_name`:case`manifest_unreadable`:case`workspace_dir_unreadable`:return e.path;case`workspace_declaration_unparsed`:case`workspace_file_unreadable`:return e.file;case`unsupported_pattern`:return e.pattern;case`scan_budget_exhausted`:return`${e.pattern} at ${e.path}`;case`no_workspace_declaration`:return}},qS=e=>e.diagnostics.filter(e=>!gy({diagnostics:[e],packages:[],versions:{}})).map(e=>{let t=KS(e);return t===void 0?e.kind:`${t}: ${e.kind}`}).toSorted().join(`, `),JS=(e,t,n)=>`checkout at ${e} points at '${G(t)}' — expected '${G(n)}'; remove the checkout directory or run refs remove before retrying`,YS=e=>e.exitCode===0?e.stdout.trim():`(no origin remote)`,XS=(e,t)=>{try{return yh(e,{allowFileUrls:t}).key}catch{return}},ZS=async(e,t)=>{let n=await e.run(`git`,[`remote`,`get-url`,`origin`],{cwd:t.dest}),r=YS(n),i=XS(t.expectedUrl,t.allowFileUrls),a=XS(r,t.allowFileUrls);if(i===void 0||a!==i)throw mu(JS(t.dest,r,t.expectedUrl))},QS=e=>{let t=lS(e);return`checkout at ${e} exists but is not refs-managed — remove it ${t===void 0?`by hand`:`(${t})`} and retry`},$S=async(e,t)=>{let n=await e.run(`git`,[`config`,`--local`,`core.hooksPath`],{cwd:t.dest});if(n.exitCode!==0||n.stdout.trim()!==t.hooksDir)throw mu(QS(t.dest))},eC=async(e,t)=>{await a(_(t.dest),{recursive:!0}),tS(e,`cloning ${G(t.cloneUrl)} into ${t.dest}…`);let n=await hm(e.runner,t);return n.warning===void 0?{effectiveMode:n.effectiveMode}:{effectiveMode:n.effectiveMode,warning:n.warning}},tC=async(e,t)=>(Pu(t.home,t.dest),K(t.dest)?(await ZS(e.runner,{allowFileUrls:t.allowFileUrls,dest:t.dest,expectedUrl:t.cloneUrl}),await $S(e.runner,{dest:t.dest,hooksDir:t.hooksDir}),{}):eC(e,t)),nC=(e,t)=>`checkout for '${e}' at ${t} is missing or corrupt (git rev-parse HEAD failed) — run: refs remove ${aS(e)}, then refs add <source> --dry-run again`,rC=(e,t,n)=>`checkout for '${e}' at ${t} has a HEAD sha refs cannot store yet (${n.length} hex chars, expected 40) — only SHA-1 repositories are supported for now; \`--object-format=sha256\` repositories are not yet supported`,iC=async(e,t)=>{await ZS(e,t),await $S(e,{dest:t.dest,hooksDir:t.hooksDir});let n=await e.run(`git`,[`rev-parse`,`HEAD`],{cwd:t.dest});if(n.exitCode!==0)throw V(nC(t.key,t.dest));let r=n.stdout.trim();if(!Vy.shape.head_sha.safeParse(r).success)throw V(rC(t.key,t.dest,r));return r},aC=/^hook\.(?<label>.+)\.command$/u,oC=/^hook\.(?<label>.+)\.enabled$/u,sC=/^filter\..+\.(?:clean|smudge|process)$/u,cC=`core.fsmonitor`,lC=/^core\.fsmonitor$/u,uC=/^git version (?<major>\d+)\.(?<minor>\d+)/u,dC={major:2,minor:54},fC=/* @__PURE__ */ new Set([``,`0`,`1`,`false`,`no`,`off`,`on`,`true`,`yes`]),pC=e=>{let t=e.split(`\0`),n=[];for(let e=0;e+1<t.length;e+=2){
462
+ packages to describe: ${r}`)},RS=e=>{if(Object.keys(e).length!==0)return e},zS=e=>{let t={default_branch:e.default_branch,description:e.description,url:e.url};return e.packages!==void 0&&(t.packages=e.packages),e.tag_format!==void 0&&(t.tag_format=e.tag_format),t},BS=`ref.`,VS=`${BS}_`,HS=`${VS}_`,US=e=>`${HS}${fe(`sha256`).update(e,`utf8`).digest(`hex`)}`,WS=e=>{let t=e.includes(`_`)?`${VS}${e.replaceAll(`_`,`_u`).replaceAll(`/`,`_s`)}`:`${BS}${e.replaceAll(`/`,`_`)}`;return Buffer.byteLength(t,`utf8`)<=212&&Hg(t)?t:US(e)},GS=e=>e.REFS_ALLOW_FILE_URLS===`1`,KS=(e,t)=>{let n=yh(t,{allowFileUrls:GS(e.env)});return{cloneUrl:n.cloneUrl,key:n.key}},qS=async(e,t)=>{if(t===``)throw B(`refs add npm: requires a package name, e.g. npm:left-pad`);_S(e,`resolving npm package '${t}'…`);let n=await o_(e.fetcher,t),r={cloneUrl:n.cloneUrl,key:n.key,npmPkgName:t};return n.directory!==void 0&&(r.npmDirectory=n.directory),r},JS=(e,t)=>t.startsWith(`npm:`)?qS(e,t.slice(4)):Promise.resolve(KS(e,t)),YS=(e,t)=>{if(e.npmPkgName===void 0)return e;let n=ab(`git_transport`,void 0,t);return{...e,cloneUrl:Ah(e.cloneUrl,n)}},XS=e=>`ref '${e}' already exists — use refs edit or refs remove`,ZS=(e,t)=>{if(e.refs[t]!==void 0)throw pu(XS(t))},QS=async e=>{try{return await c(e,{withFileTypes:!0})}catch(e){if(z(e))return;throw e}},$S=e=>e.filter(e=>e.isDirectory()).map(e=>e.name),eC=async(e,t)=>{let n=await QS(e);if(n===void 0)return{kind:`stop`};let r=$S(n);if(r.includes(t))return{kind:`continue`,nextDir:v(e,t)};let i=r.find(e=>e.toLowerCase()===t.toLowerCase());return i===void 0?{kind:`stop`}:{kind:`collision`,name:i}},tC=async(e,t,n)=>{let[r,...i]=t;if(r===void 0)return;let a=await eC(e,r);if(a.kind!==`stop`)return a.kind===`collision`?[...n,a.name].join(`/`):tC(a.nextDir,i,[...n,r])},nC=[],rC=async(e,t)=>{let n=await tC(e.sourcesDir,t.split(`/`),nC);if(n!==void 0)throw pu(`checkout path for '${t}' collides case-insensitively with existing '${n}'`)},iC=(e,t,n)=>{let r=n.scan.versions[e];return r===void 0?null:Km(n.tags,r,t)},aC=e=>{let t=e.scan.packages.find(e=>e.path===`.`);if(t===void 0)return e.counted;let n=iC(`.`,t.name,{scan:e.scan,tags:e.tags});return n===null||Vm(n,t.name)?e.counted:n},oC=e=>e.format===null||e.format===e.refFormat||!Vm(e.format,e.name)?e.entry:{...e.entry,tag_format:e.format},sC=e=>{let t={scan:e.scan,tags:e.tags};return Object.fromEntries(Object.entries(e.packages).map(([n,r])=>[n,oC({entry:r,format:iC(r.path,n,t),name:n,refFormat:e.refFormat})]))},cC=e=>{switch(e.kind){case`candidate_not_inspected`:case`manifest_missing_name`:case`manifest_unreadable`:case`workspace_dir_unreadable`:return e.path;case`workspace_declaration_unparsed`:case`workspace_file_unreadable`:return e.file;case`unsupported_pattern`:return e.pattern;case`scan_budget_exhausted`:return`${e.pattern} at ${e.path}`;case`no_workspace_declaration`:return}},lC=e=>e.diagnostics.filter(e=>!My({diagnostics:[e],packages:[],versions:{}})).map(e=>{let t=cC(e);return t===void 0?e.kind:`${t}: ${e.kind}`}).toSorted().join(`, `),uC=(e,t,n)=>`checkout at ${e} points at '${G(t)}' — expected '${G(n)}'; remove the checkout directory or run refs remove before retrying`,dC=e=>e.exitCode===0?e.stdout.trim():`(no origin remote)`,fC=(e,t)=>{try{return yh(e,{allowFileUrls:t}).key}catch{return}},pC=async(e,t)=>{let n=await e.run(`git`,[`remote`,`get-url`,`origin`],{cwd:t.dest}),r=dC(n),i=fC(t.expectedUrl,t.allowFileUrls),a=fC(r,t.allowFileUrls);if(i===void 0||a!==i)throw pu(uC(t.dest,r,t.expectedUrl))},mC=e=>{let t=TS(e);return`checkout at ${e} exists but is not refs-managed — remove it ${t===void 0?`by hand`:`(${t})`} and retry`},hC=async(e,t)=>{let n=await e.run(`git`,[`config`,`--local`,`core.hooksPath`],{cwd:t.dest});if(n.exitCode!==0||n.stdout.trim()!==t.hooksDir)throw pu(mC(t.dest))},gC=async(e,t)=>{await a(_(t.dest),{recursive:!0}),_S(e,`cloning ${G(t.cloneUrl)} into ${t.dest}…`);let n=await hm(e.runner,t);return n.warning===void 0?{effectiveMode:n.effectiveMode}:{effectiveMode:n.effectiveMode,warning:n.warning}},_C=async(e,t)=>(Pu(t.home,t.dest),K(t.dest)?(await pC(e.runner,{allowFileUrls:t.allowFileUrls,dest:t.dest,expectedUrl:t.cloneUrl}),await hC(e.runner,{dest:t.dest,hooksDir:t.hooksDir}),{}):gC(e,t)),vC=(e,t)=>`checkout for '${e}' at ${t} is missing or corrupt (git rev-parse HEAD failed) — run: refs remove ${xS(e)}, then refs add <source> --dry-run again`,yC=(e,t,n)=>`checkout for '${e}' at ${t} has a HEAD sha refs cannot store yet (${n.length} hex chars, expected 40) — only SHA-1 repositories are supported for now; \`--object-format=sha256\` repositories are not yet supported`,bC=async(e,t)=>{await pC(e,t),await hC(e,{dest:t.dest,hooksDir:t.hooksDir});let n=await e.run(`git`,[`rev-parse`,`HEAD`],{cwd:t.dest});if(n.exitCode!==0)throw V(vC(t.key,t.dest));let r=n.stdout.trim();if(!rb.shape.head_sha.safeParse(r).success)throw V(yC(t.key,t.dest,r));return r},xC=/^hook\.(?<label>.+)\.command$/u,SC=/^hook\.(?<label>.+)\.enabled$/u,CC=/^filter\..+\.(?:clean|smudge|process)$/u,wC=`core.fsmonitor`,TC=/^core\.fsmonitor$/u,EC=/^git version (?<major>\d+)\.(?<minor>\d+)/u,DC={major:2,minor:54},OC=/* @__PURE__ */ new Set([``,`0`,`1`,`false`,`no`,`off`,`on`,`true`,`yes`]),kC=e=>{let t=e.split(`\0`),n=[];for(let e=0;e+1<t.length;e+=2){
461
463
  /* v8 ignore next 2 -- the loop guard already proves both indices are in range; the fallbacks
462
464
  exist only because `noUncheckedIndexedAccess` cannot see that. */
463
465
  let r=t[e+1]??``,i=t[e]??``,a=r.indexOf(`
464
- `),o=a===-1?r:r.slice(0,a),s=a===-1?``:r.slice(a+1);n.push({key:o,scope:i,value:s})}return n},mC=e=>{let t=/* @__PURE__ */ new Map;for(let n of e){let e=oC.exec(n.key)?.groups?.label;e!==void 0&&t.set(e,n.value!==`false`)}return new Set([...t].filter(([,e])=>!e).map(([e])=>e))},hC=e=>{let t=uC.exec(e?.trim()??``)?.groups;if(t===void 0)return!0;let n=Number(t.major);return n>dC.major||n===dC.major&&Number(t.minor)>=dC.minor},gC=e=>{let t=e.findLast(e=>e.key===cC)?.value;return t!==void 0&&!fC.has(t.trim().toLowerCase())},_C=(e,t)=>{let n=aC.exec(e.key)?.groups?.label;return n===void 0?sC.test(e.key):t.hooksRun&&!t.disabled.has(n)},vC=(e,t)=>{let n=pC(e).filter(e=>e.scope!==`local`),r={disabled:mC(n),hooksRun:hC(t)},i=n.filter(e=>_C(e,r)).map(e=>e.key);return gC(n)&&i.push(cC),[...new Set(i)]},yC=[[sC,`a filter is selected by a checkout's own .gitattributes and stays enabled, because turning it off would change what the checkout contains`],[aC,`a configured hook fires on the events refs causes and nothing disabled it: refs switches those events off and disables each label it finds`],[lC,`fsmonitor runs a command in the worktree`]],bC=e=>{let t=yC.filter(([t])=>e.some(e=>t.test(e))).map(([,e])=>e);return`${e.join(`, `)}: git runs these itself and the managed hooks path does not cover them — ${t.join(`; `)}. Whether one of them reaches a checkout's content depends on the command, which refs cannot decide for you`},xC=`git-exec-surfaces`,SC=e=>({detail:`${e}, so this could not be checked`,name:xC,status:`warn`}),CC=async(e,t,n)=>{let r=await e.runner.run(`git`,[`config`,`--list`,`-z`,`--show-scope`],{cwd:t});if(r.exitCode!==0)return SC(`the git configuration could not be read`);if(r.stdoutTruncated===!0)return SC(`the git configuration was too large to read whole`);let i=vC(r.stdout,n);return i.length===0?{detail:`no configured hook, filter or fsmonitor command that refs leaves enabled`,name:xC,status:`ok`}:{detail:bC(i),name:xC,status:`warn`}},wC=async(e,t)=>{let n=await e.runner.run(`git`,[`--version`],{cwd:t}),r=n.exitCode===0?n.stdout:void 0,i=await CC(e,t,r);return i.status===`ok`?void 0:`${xC}: ${i.detail}`},TC=e=>gy(e)?void 0:`workspace detection could not fully inspect the declared workspaces (${qS(e)}) — members may be missing from the detected packages; the repository's own workspace declaration is what settles it`,EC=(e,t)=>{let n=hS(e.packages,t.resolved.npmDirectory,t.resolved.npmPkgName),r=US({counted:t.countedTagFormat,scan:e,tags:t.tags}),i=GS({packages:n,refFormat:r,scan:e,tags:t.tags}),a=vS(e.packages,i),o=TC(e);return{defaultBranch:t.defaultBranch,...o===void 0?{}:{detectionWarning:o},packages:i,...a===void 0?{}:{rootPackageName:a},tagFormatCandidate:r}},DC=e=>e.complete?Nm(e.tags):null,OC=async(e,t)=>{let{dest:n,resolved:r}=t,i=await fm(e.runner,n),a=await Cm(e.runner,n),o=DC(a);tS(e,`detecting workspace packages…`);let s=await mx(n),c=a.complete?a.tags:[];return EC(s,{countedTagFormat:o,defaultBranch:i,resolved:r,tags:c})},kC=(e,t)=>q(t.home,OS(t.resolved.key),async()=>{let n=await wC(e,t.home.root),r=await tC(e,{allowFileUrls:kS(e.env),cloneUrl:t.resolved.cloneUrl,dest:t.dest,home:t.home,hooksDir:t.home.hooksDir,mode:t.cloneMode}),i={fields:await OC(e,t),...n===void 0?{}:{execSurfacesWarning:n}};return r.effectiveMode!==void 0&&(i.effectiveMode=r.effectiveMode),r.warning!==void 0&&(i.warning=r.warning),i}),AC=(e,t)=>{if(!Ce(e.defaultBranch))throw V(`this repository's HEAD names a branch git will not accept: ${JSON.stringify(e.defaultBranch)}. refs cannot synchronise a ref with that default branch — the name comes from the repository, so there is nothing to correct in this command.`);return{default_branch:e.defaultBranch,description:``,key:t.key,packages:e.packages,tag_format_candidate:e.tagFormatCandidate,url:t.cloneUrl}},jC=e=>{let{effectiveMode:t,execSurfacesWarning:n,fields:r,warning:i}=e.cloneResult;return{dest:e.dest,...n===void 0?{}:{execSurfacesWarning:n},proposal:AC(r,e.resolved),...r.detectionWarning===void 0?{}:{detectionWarning:r.detectionWarning},...r.rootPackageName===void 0?{}:{rootPackageName:r.rootPackageName},...t===void 0?{}:{effectiveCloneMode:t},...i===void 0?{}:{warning:i}}},MC=async(e,t)=>{let n=U(e.env),r=await H(n),i=NS(await MS(e,t),r.settings);FS(r,i.key),await VS(n,i.key);let a=ku(n,i.key),o=Uy(`clone_mode`,void 0,r.settings),s=await kC(e,{cloneMode:o,dest:a,home:n,resolved:i});return jC({cloneResult:s,dest:a,resolved:i})},NC=(e,t,n)=>q(e,`home`,async()=>{let r=await H(e);FS(r,t);let i=await Ky(e),a=i.refs[t],o=n??a?.effective_clone_mode,s={...a,pending_proposal_at:(/* @__PURE__ */ new Date()).toISOString()};o!==void 0&&(s.effective_clone_mode=o),i.refs[t]=s,await qy(e,i)}),PC=(e,t)=>{let n=Ol.safeParse(e);if(!n.success)throw V(w(n.error));let r=Hy.safeParse(t);if(!r.success)throw V(w(r.error));return{config:n.data,state:r.data}},FC=async(e,t)=>{let n=await H(e.home);FS(n,e.ref.key);let r=CS(e.ref);n.refs[e.ref.key]=r;let i=await Ky(e.home);return i.refs[e.ref.key]={effective_clone_mode:e.effectiveCloneMode??i.refs[e.ref.key]?.effective_clone_mode??Uy(`clone_mode`,void 0,n.settings),head_sha:t,last_fetched_at:(/* @__PURE__ */ new Date()).toISOString()},{...PC(n,i),entry:r}},IC=async(e,t)=>{let n=kS(e.env),r=await q(t.home,OS(t.ref.key),()=>(Pu(t.home,t.dest),iC(e.runner,{allowFileUrls:n,dest:t.dest,expectedUrl:t.ref.url,hooksDir:t.home.hooksDir,key:t.ref.key})));return q(t.home,`home`,async()=>{let{config:e,entry:n,state:i}=await FC(t,r);return await qy(t.home,i),await Eu(t.home,e),{entry:n,key:t.ref.key}})},LC=(e,t)=>t===`-`?e.readStdin():s(t,`utf8`),RC=e=>{try{return JSON.parse(e)}catch{throw V(`invalid JSON in proposal: the document could not be parsed`)}},zC=e=>typeof e==`object`&&!!e&&!Array.isArray(e),BC=e=>zC(e)&&`ok`in e&&!(`key`in e),VC=e=>{if(!BC(e))return e;if(e.ok===!1)throw V(`proposal file contains a failed refs envelope (ok is false) — re-run the dry-run`);if(zC(e.data))return e.data;throw V(`proposal file is a refs envelope without a usable data object — re-run the dry-run`)},HC=e=>e.code===`unrecognized_keys`,UC=e=>e.path.length===0,WC=(e,t)=>{let n=t.toSorted().map(e=>`"${e}"`).join(`, `);return e===``?`✖ unrecognized key(s) in proposal: ${n}`:`✖ unrecognized key(s) in proposal at ${e}: ${n}`},GC=e=>{let t=/* @__PURE__ */ new Map;for(let n of e){let e=Jt(n.path);t.set(e,[...t.get(e)??[],...n.keys])}return[...t.entries()].toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>WC(e,t))},KC=e=>`✖ invalid proposal: ${e.message}`,qC=e=>{let t=e.issues.filter(e=>HC(e)),n=e.issues.filter(e=>!HC(e)),r=n.filter(e=>UC(e));if(t.length===0&&r.length===0)return w(e);let i=n.filter(e=>!UC(e)),a=[...GC(t),...r.map(e=>KC(e))];return i.length>0&&a.push(w({issues:i})),a.join(`
465
- `)},JC=e=>{let t=By.safeParse(e);if(!t.success)throw V(qC(t.error));return t.data},YC=async(e,t)=>{let n=await LC(e,t);return JC(VC(RC(n)))},XC=(e,t)=>[`refs add: dry-run proposal ready for '${e}' (checkout: ${t})`,`next: review the proposal, then run refs add --proposal <file> to finalize`],ZC=e=>[...Qx(e.execSurfacesWarning),...Qx(e.warning),...Qx(e.detectionWarning)],QC=async(e,t)=>{let n=await MC(e,t),r=U(e.env);await NC(r,n.proposal.key,n.effectiveCloneMode);let i=ZC(n);return{data:n.proposal,human:XC(n.proposal.key,n.dest),warnings:i}},$C=e=>[`refs add: '${e}' added to config`],ew=e=>{let t={default_branch:e.default_branch,description:e.description,key:e.key,url:e.url};e.tag_format_candidate!==null&&(t.tag_format=e.tag_format_candidate);let n=SS(e.packages);return n!==void 0&&(t.packages=n),t},tw=async(e,t)=>{let n=await YC(e,t),r=U(e.env),i=ku(r,n.key);if(!K(i))throw z(`no checkout found at ${i} — run: refs add <source> --dry-run first`);let a=ew(n),{entry:o,key:s}=await IC(e,{dest:i,home:r,ref:a});return{data:{entry:o,key:s},human:$C(s),warnings:[]}},nw=(e,t,n)=>{xS(e.proposal.packages,n,e.rootPackageName);let r={default_branch:e.proposal.default_branch,description:t,key:e.proposal.key,url:e.proposal.url};e.proposal.tag_format_candidate!==null&&(r.tag_format=e.proposal.tag_format_candidate);let i=_S(e.proposal.packages,{refDescription:t,...e.rootPackageName===void 0?{}:{rootPackageName:e.rootPackageName}});return i!==void 0&&(r.packages=i),r},rw=async(e,t,n)=>{let r=await MC(e,t),i=U(e.env);await NC(i,r.proposal.key,r.effectiveCloneMode);let a=nw(r,n,t),o={dest:r.dest,home:i,ref:a};r.effectiveCloneMode!==void 0&&(o.effectiveCloneMode=r.effectiveCloneMode);let{entry:s,key:c}=await IC(e,o);return{data:{entry:s,key:c},human:$C(c),warnings:ZC(r)}},iw=e=>{let t=[e.dryRun,e.proposal!==void 0,e.description!==void 0].filter(Boolean).length;if(t>1)throw B(`refs add: use only one of --dry-run, --proposal, or --description`);if(t===0)throw B(`refs add needs --dry-run, --proposal, or --description`)},aw=e=>{if(e===void 0||e===``)throw B(`refs add requires <source> (a git url or npm:<package>)`);return e},ow=(e,t)=>(iw(t),t.proposal===void 0?t.description===void 0?QC(e,aw(t.source)):rw(e,aw(t.source),t.description):tw(e,t.proposal)),sw=(e,t)=>{let n={dryRun:t.dryRun===!0};return e!==void 0&&(n.source=e),t.proposal!==void 0&&(n.proposal=t.proposal),t.description!==void 0&&(n.description=t.description),n},cw=(e,t)=>{e.command(`add`).description(`Add a git reference in two phases: propose (--dry-run), then finalize (--proposal).`).argument(`[source]`,`git url or npm:<package> (omit when finalizing with --proposal)`).option(`--dry-run`,`resolve and clone the source, writing a reviewable proposal`).option(`--proposal <file>`,`finalize from a completed proposal JSON file (- for stdin)`).option(`--description <text>`,`one-shot: dry-run then finalize immediately with this description`).action((e,n,r)=>{let i=X(r);return Q(t,i,async()=>{let r=await ow(t,sw(e,n));Z(t,i,r.human,r.data,r.warnings)})()})},lw=async e=>{let t=await e.runner.run(`git`,[`--version`]);return t.exitCode===0?{detail:t.stdout.trim(),name:`git`,status:`ok`}:{detail:t.stderr.trim()||`git --version exited with code ${t.exitCode}`,name:`git`,status:`fail`}},uw=/^v(?<major>\d+)\.(?<minor>\d+)/u,dw=e=>{let t=uw.exec(e),n=t?.groups?.major,r=t?.groups?.minor;if(n!==void 0&&r!==void 0)return{major:Number(n),minor:Number(r)}},fw=e=>e===void 0?!1:e.major>24||e.major===24&&e.minor>=2,pw=e=>{let{nodeVersion:t}=e;return fw(dw(t))?{detail:t,name:`node`,status:`ok`}:{detail:`${t} does not satisfy the required range >=24.2`,name:`node`,status:`fail`}},mw=()=>Ol.parse({meta:{cli_version:`0.0.0`,schema_version:1},refs:{},settings:{}}),hw=async e=>{try{return{config:await H(e)}}catch(e){return{config:mw(),errorMessage:$x(e)}}},gw=e=>e===void 0?{detail:`config is present and matches the current schema`,name:`config`,status:`ok`}:{detail:e,name:`config`,status:`fail`},_w={ci:`update check is off in CI — set REFS_UPDATE_CHECK=1 to run it here anyway`,config:`update check is off ([updates].check = false in config.toml)`,env:`update check is off (REFS_UPDATE_CHECK=0)`},vw=(e,t,n)=>{if(ab(e,t)){let r=n?` (npm was unreachable just now; this was its last answer)`:``;return{detail:`${ob(e,t)}${r}`,name:`cli-update`,status:`warn`}}return n?{detail:`could not reach npm to check; its last answer was ${t}, which this CLI (${e}) already has`,name:`cli-update`,status:`warn`}:{detail:`this CLI (${e}) is npm's latest published release`,name:`cli-update`,status:`ok`}},yw=async(e,t)=>{let n=ub({env:e.env,updates:t.updates});if(n!==`on`)return{detail:_w[n],name:`cli-update`,status:`ok`};let{latest:r,stale:i}=await ib({fetch:e.fetcher,home:U(e.env),nowMs:Date.now()});return r===void 0?{detail:`could not reach npm to learn the latest published version — not a fault of your setup, and nothing else depends on it`,name:`cli-update`,status:`warn`}:vw(e.cliVersion,r,i)},bw=e=>{let t=0,n=[];return{acquire:()=>{if(t<e)return t+=1,Promise.resolve();let{promise:r,resolve:i}=Promise.withResolvers();return n.push(()=>{t+=1,i()}),r},release:()=>{--t;let e=n.shift();e!==void 0&&e()}}},xw=async(e,t)=>{await e.acquire();try{return await t()}finally{e.release()}},Sw=(e,t,n)=>{let r=bw(t);return Promise.all(e.map(e=>xw(r,()=>n(e))))},Cw=(e,t)=>Object.keys(t.refs).map(e=>sl.parse(e)).map(t=>({dest:ku(e,t),key:t})).filter(e=>K(e.dest)),ww=[`pre-commit`,`pre-push`],Tw=async(t,r)=>{try{return await e(v(t.hooksDir,r),n.X_OK),!0}catch{return!1}},Ew=async e=>{let t=await Promise.all(ww.map(t=>Tw(e,t)));return ww.filter((e,n)=>!t[n])},Dw=async e=>{try{return(await c(e.hooksDir)).filter(e=>!ww.includes(e)).toSorted()}catch(e){if(L(e))return[];throw e}},Ow=async(e,t,n)=>{let r=await e.runner.run(`git`,[`config`,`--local`,`--get`,`core.hooksPath`],{cwd:n});return r.exitCode===0&&r.stdout.trim()===t.hooksDir},kw=(e,t)=>`${t.map(e=>`hooks/${e}`).join(`, `)}: not installed by refs — this is the directory git resolves hook names against for every managed checkout, so nothing whose provenance refs cannot account for belongs in it; remove: ${lS(t.map(t=>v(e,t)))}`,Aw=e=>{let t=[];return e.unexpected.length>0&&t.push(kw(e.hooksDir,e.unexpected)),e.missingHooks.length>0&&t.push(`${e.missingHooks.map(e=>`hooks/${e}`).join(`, `)} missing or not executable — run: refs init`),e.badKeys.length>0&&t.push(`core.hooksPath not set for: ${e.badKeys.join(`, `)} — run: refs init`),t},jw=e=>{let t=Aw(e);return t.length>0?{detail:t.join(`; `),name:`hooks-guard`,status:`fail`}:{detail:`${ww.map(e=>`hooks/${e}`).join(`, `)} present; ${e.checkoutCount} checkout(s) guarded`,name:`hooks-guard`,status:`ok`}},Mw=async(e,t,n)=>{let r=Cw(t,n),[i,a,o]=await Promise.all([Ew(t),Dw(t),Sw(r,8,n=>Ow(e,t,n.dest))]),s=r.filter((e,t)=>!o[t]).map(e=>e.key);return jw({badKeys:s,checkoutCount:r.length,hooksDir:t.hooksDir,missingHooks:i,unexpected:a})},Nw=async(e,t)=>{let n=await e.run(`git`,[`status`,`--porcelain`],{cwd:t.dest});return n.exitCode===0?{broken:!1,detail:``,dirty:n.stdout.trim()!==``,key:t.key}:{broken:!0,detail:n.stderr.trim(),dirty:!1,key:t.key}},Pw=e=>{let t=e.filter(e=>e.broken);if(t.length>0)return{detail:t.map(e=>`${e.key}: git status failed — ${e.detail}`).join(`; `),name:`dirty-checkouts`,status:`fail`};let n=e.filter(e=>e.dirty).map(e=>e.key);return n.length===0?{detail:`no local changes in any checkout`,name:`dirty-checkouts`,status:`ok`}:{detail:`local changes will be discarded on next sync: ${n.join(`, `)}`,name:`dirty-checkouts`,status:`warn`}},Fw=async(e,t,n)=>{let r=Cw(t,n),i=await Sw(r,8,t=>Nw(e.runner,t));return Pw(i)},Iw=async e=>{try{return await Ky(e)}catch{return Hy.parse({})}},Lw=async e=>{try{return(await c(e,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(e){if(L(e))return[];throw e}},Rw=async(e,t)=>{if(K(e))return[[...t]];let n=await Lw(e);return(await Promise.all(n.map(n=>Rw(v(e,n),[...t,n])))).flat()},zw=(e,t,n)=>{let r=e.refs[t]?.pending_proposal_at;return r!==void 0&&n-Date.parse(r)<864e5},Bw=(e,t,n)=>{if(zw(t,e.key,n))return`${e.key}: pending add`;let r=lS(e.dest);return r===void 0?`${e.key}: orphan — its path cannot be put into a pasteable command; remove it by hand`:`${e.key}: orphan — remove with: ${r}`},Vw=(e,t)=>({dest:v(e.sourcesDir,...t),key:t.join(`/`)}),Hw=async(e,t,n)=>{let r=(await Rw(e.sourcesDir,[])).map(t=>Vw(e,t)).filter(e=>!Object.hasOwn(t.refs,e.key));if(r.length===0)return{detail:`no orphaned checkouts under sources/`,name:`orphans`,status:`ok`};let i=Date.now();return{detail:r.map(e=>Bw(e,n,i)).join(`; `),name:`orphans`,status:`warn`}},Uw=e=>{let t=(e??``).lastIndexOf(`/`);return t===-1?`.`:(e??``).slice(0,t)},Ww=e=>{let[t=`.`,...n]=e,r=t.split(`/`),i=r.length;for(let e of n){let t=e.split(`/`),n=0;for(;n<i&&n<t.length&&r[n]===t[n];)n+=1;i=n}return i===0?`.`:r.slice(0,i).join(`/`)},Gw=e=>Sl.safeParse({name:e.name,path:e.path}).success,Kw=(e,t,n)=>cS([[`--package`,e.name],`--decline`,[`--path`,n]],[t]),qw=(e,t,n)=>cS([[`--package`,e.name],`--create`,[`--path`,n],[`--description`,`<what it is>`]],[t]),Jw=(e,t)=>{let{path:n}=e;if(n===void 0||!Gw(e))return{};let r=Kw(e,t,n),i=vl(e.name)?qw(e,t,n):void 0;return r===void 0?{}:i===void 0?{decline:r}:{decline:r,register:i}},Yw=(e,t)=>{let n=pl.safeParse(e.path);if(!n.success)return{};let r=cS([[`--package`,e.name]],[t,`path`,n.data]);return r===void 0?{}:{repoint:r}},Xw=(e,t)=>{let n=cS([[`--package`,e.name],`--remove`],[t]);return n===void 0?{}:{unregister:n}},Zw=(e,t)=>e.status===`unregistered`?Jw(e,t):e.status===`relocated`?Yw(e,t):e.status===`missing`?Xw(e,t):{},Qw=`(unknown)`,$w=`no single-line command can carry these values, so none is offered — 'refs doctor --json' has them exactly`,eT=(e,t)=>{let{decline:n,register:r}=Jw(e,t);if(n!==void 0)return r===void 0?`Its name is one the packages table cannot hold, so it cannot be registered — if that is the answer, record it: ${n}`:`To register it (replace the description first): ${r}. If it should not be: ${n}`},tT=(e,t)=>{let n=`${e.name}: declared in this checkout but not registered — it cannot be resolved by name until it is`,{path:r}=e;if(r===void 0)return`${n}. Declared at several paths (${(e.candidates??[]).join(`, `)}) — pick one`;if(!Gw(e))return`${n}. Its name or path is one the configuration cannot hold, so there is no command for it — report it and leave it unregistered`;let i=eT(e,t);return i===void 0?`${n}. ${$w} — report it and leave it unregistered`:`${n}. ${i}`},nT=(e,t,n)=>{let r=`${e.name}: moved to ${e.path??Qw} — update the entry's path (${n})`,{repoint:i}=Zw(e,t);return i===void 0?r:`${r}. To fix it: ${i}`},rT=(e,t,n)=>{let r=`${e.name}: gone from this repo's workspaces (${n}) — repoint the entry if it moved out of them`,{unregister:i}=Zw(e,t);return i===void 0?`${r}; ${$w}, so unregister it by hand`:`${r}, or unregister it: ${i}`},iT=(e,t)=>{let n=`configured: ${e.configured_path??Qw}`;if(e.status===`relocated`)return nT(e,t,n);if(e.status===`missing`)return rT(e,t,n);if(e.status===`ambiguous`){let t=(e.candidates??[]).join(`, `);return`${e.name}: declared at several paths (${t}) — point the entry at one (${n})`}return`${e.name}: could not be checked — ${e.reason??`(no reason given)`} (${n})`},aT=(e,t)=>e.status===`unregistered`?tT(e,t):iT(e,t),oT=e=>`could not check for unregistered packages — ${e}`,sT=e=>`…and ${e} more finding(s) — act on the ones above (register, repoint or decline) and run the check again to see the rest`,cT=e=>{let t=e.length-10;return t<=0?[...e]:[...e.slice(0,10),sT(t)]},lT=e=>{let t=/* @__PURE__ */ new Map;for(let n of e){let[e=`.`]=Uw(n.path).split(`/`);t.set(e,[...t.get(e)??[],n])}return t},uT=e=>e.path===void 0,dT=(e,t,n)=>{if(e.length<3)return e.map(e=>({candidates:1,dir:n,line:tT(e,t)}));let r=Ww(e.map(e=>Uw(e.path)));return[{candidates:e.length,dir:r,line:`${r}: ${e.length} unregistered package(s) the configuration does not have`}]},fT=e=>{let t=e.reduce((e,t)=>e+t.candidates,0),n=new Set(e.flatMap(e=>e.dir===void 0?[]:[e.dir])).size;return`…and ${t} more unregistered package(s)${n===0?``:` in ${n} director(ies)`} — 'refs doctor --json' lists every candidate`},pT=(e,t)=>{let n=e.filter(e=>uT(e)).map(e=>({candidates:1,line:tT(e,t)})),r=[...lT(e.filter(e=>!uT(e)))].toSorted(([e],[t])=>e.localeCompare(t)).flatMap(([e,n])=>dT(n,t,e)),i=[...n,...r],a=i.slice(10);return a.length===0?i.map(e=>e.line):[...i.slice(0,10).map(e=>e.line),fT(a)]},mT=(e,t)=>e.reason===void 0?[...cT((e.packages??[]).map(e=>aT(e,t))),...pT(e.discovery??[],t),...e.discovery_incomplete===void 0?[]:[oT(e.discovery_incomplete)]]:[`could not be checked — ${e.reason}`],hT=e=>{let t;return()=>(t??=mx(e),t)},gT=async(e,t,n)=>{let r=await Tb(e);if(r===void 0||t.some(e=>e.packageName===r.name))return{issues:[]};let i=await n();if(!gy(i))return{incomplete:qS(i),issues:[]};let a=Ey(i.packages,r.name);return a.kind===`ambiguous`?{issues:[{candidates:a.paths,name:r.name,status:`unregistered`}]}:{issues:a.kind===`found`?[{name:r.name,path:a.path,status:`unregistered`}]:[]}},_T=e=>{let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n.name,[...t.get(n.name)??[],n.path]);return t},vT=(e,t)=>{let n=new Set(e.changedDirs),r=t.filter(e=>!n.has(e.path)).map(e=>e.name);return/* @__PURE__ */ new Set([...e.namesBefore,...r])},yT=(e,t)=>t.length===1&&t[0]!==void 0?{name:e,path:t[0],status:`unregistered`}:{candidates:[...t],name:e,status:`unregistered`},bT=async(e,t,n)=>{if(t.kind===`arrivals`&&t.changedDirs.length===0)return{issues:[]};let r=await n();if(!gy(r))return{incomplete:qS(r),issues:[]};let i=new Set(e.map(e=>e.packageName)),a=r.packages.filter(e=>e.path!==`.`),o=t.kind===`all`?void 0:vT(t,a);return{issues:[..._T(a)].filter(([e])=>!i.has(e)).filter(([e])=>o===void 0||!o.has(e)).map(([e,t])=>yT(e,t)).toSorted((e,t)=>e.name.localeCompare(t.name))}},xT=(e,t)=>{if(t.length===0)return{issues:[...e],suppressed:[]};let n=(e,n)=>t.some(t=>t.name===e&&t.path===n),r=[];return{issues:e.flatMap(e=>{if(e.status!==`unregistered`)return[e];let t=e.path===void 0?e.candidates??[]:[e.path],i=t.filter(t=>!n(e.name,t)),a=t.filter(t=>n(e.name,t));return r.push(...a.map(t=>({name:e.name,path:t}))),i.length===0?[]:[yT(e.name,i)]}),suppressed:r}},ST=e=>e!==`unmaterialized`&&e!==`verified`,CT=/* @__PURE__ */ new Set([`ambiguous`,`missing`,`relocated`]),wT=(e,t={})=>{let{declined:n=[],discoveryIncomplete:r}=t,i=e.filter(e=>e.status!==`unregistered`),a=e.filter(e=>e.status===`unregistered`);return{...n.length===0?{}:{declined:[...n]},...a.length===0?{}:{discovery:a},...r===void 0?{}:{discovery_incomplete:r},...i.length===0?{}:{packages:i},status:TT(i,r)}},TT=(e,t)=>e.some(e=>CT.has(e.status))?`drift`:e.length===0&&t===void 0?`ok`:`unknown`,ET=(e,t)=>({path:e.configuredPath,reason:t,status:`unverifiable`}),DT=(e,t)=>_y(t)?{configuredPath:e.configuredPath,path:null,status:`missing`}:ET(e,`this repo declares no workspaces, so there was nowhere to search`),OT=(e,t)=>t===e.configuredPath,kT=e=>e.packages.filter(e=>e.path!==`.`),AT=(e,t)=>{let n=Ey(kT(t),e.packageName);return n.kind===`ambiguous`?{candidates:n.paths,configuredPath:e.configuredPath,path:null,status:`ambiguous`}:gy(t)?n.kind===`absent`?DT(e,t):OT(e,n.path)?ET(e,`the checkout changed while it was being inspected`):{configuredPath:e.configuredPath,path:n.path,status:`relocated`}:ET(e,n.kind===`found`?`workspace detection was incomplete, so the new location is not confirmed unique`:`workspace detection was incomplete`)},jT=e=>{let t=new Map(Object.entries(e??{}));return[...t.keys()].toSorted().flatMap(e=>{let n=t.get(e);return n===void 0?[]:[{configuredPath:n.path,packageName:e}]})},MT=async(e,t)=>{let n=await Cy(e,t.configuredPath,t.packageName);if(n.kind===`match`)return{path:t.configuredPath,status:`verified`};if(n.kind===`unreadable`)return{path:t.configuredPath,reason:n.reason,status:`unverifiable`}},NT=e=>e.flatMap(e=>e.settled===void 0?[]:[{outcome:e.settled,query:e.query}]),PT=async(e,t,n)=>{let r=await Promise.all(t.map(async t=>({query:t,settled:await MT(e,t)})));if(r.every(e=>e.settled!==void 0))return NT(r);let i=await n();return r.map(e=>({outcome:e.settled??AT(e.query,i),query:e.query}))},FT=e=>{let{outcome:t,query:n}=e;return ST(t.status)?[{...t.candidates===void 0?{}:{candidates:t.candidates},configured_path:n.configuredPath,name:n.packageName,...t.status===`relocated`&&t.path!==null?{path:t.path}:{},...t.reason===void 0?{}:{reason:t.reason},status:t.status}]:[]},IT=(e,t)=>{let n=new Set(e.map(e=>e.name));return[...e,...t.filter(e=>!n.has(e.name))]},LT=async(e,t,n)=>{let r=jT(t.packages),[i]=r;if(i===void 0)return{status:`ok`};let a=hT(e);try{let[i,o,s]=await Promise.all([PT(e,r,a),gT(e,r,a),bT(r,n,a)]),c=xT([...i.flatMap(e=>FT(e)),...IT(o.issues,s.issues)],t.declined_packages??[]);return wT(c.issues,{declined:c.suppressed,...(s.incomplete??o.incomplete)===void 0?{}:{discoveryIncomplete:s.incomplete??o.incomplete}})}catch(e){return{reason:$x(e),status:`unknown`}}},RT=async(e,t,n)=>{try{return await q(e,OS(n.key),()=>LT(n.dest,t.refs[n.key]??{},{kind:`all`}),{timeoutMs:100})}catch(e){if(e instanceof R&&e.code===`conflict`)return{reason:`another refs process is holding this ref`,status:`unknown`};throw e}},zT=e=>e===0?``:` (${e} declined package(s) not reported)`,BT=(e,t)=>e.unhealthy.length===0?`every configured package path resolves in ${t} checkout(s)`:e.unhealthy.join(`; `),VT=(e,t)=>{let{declined:n,discovery:r,findings:i}=e;return{detail:[BT(e,t)+zT(n),...r].join(`; `),...i.length===0?{}:{findings:i},name:`config-drift`,status:e.unhealthy.length===0?`ok`:`warn`}},HT=async(e,t,n)=>{let[r,...i]=n;if(r===void 0)return{declined:0,discovery:[],findings:[],unhealthy:[]};let a=await RT(e,t,r),o=await HT(e,t,i);return WT(o,{key:r.key,report:a})},UT=(e,t)=>({...e,...Zw(e,t)}),WT=(e,t)=>{let{key:n,report:r}=t,i=e=>e.map(e=>`${n}: ${e}`),a=r.discovery??[],o=r.packages??[],s=[...o,...a];return{declined:(r.declined??[]).length+e.declined,discovery:[...i(mT({discovery:a,status:`ok`},n)),...e.discovery],findings:s.length===0?e.findings:[{key:n,packages:s.map(e=>UT(e,n))},...e.findings],unhealthy:[...i(mT({...r.discovery_incomplete===void 0?{}:{discovery_incomplete:r.discovery_incomplete},...r.reason===void 0?{}:{reason:r.reason},packages:o,status:r.status},n)),...e.unhealthy]}},GT=async(e,t)=>{let n=Cw(e,t);return VT(await HT(e,t,n),n.length)},KT=`home-modes`,qT=e=>[{expected:448,label:`the refs home`,path:e.root},{expected:448,label:`sources/`,path:e.sourcesDir},{expected:448,label:`locks/`,path:e.locksDir},{expected:448,label:`hooks/`,path:e.hooksDir},{expected:384,label:`config.toml`,path:e.configPath},{expected:384,label:`state.json`,path:e.statePath}],JT=e=>(e&511).toString(8).padStart(3,`0`),YT=e=>e instanceof Error&&`code`in e?String(e.code):`unknown`,XT=async e=>{try{let[t,n]=await Promise.all([p(e),i(e)]);return{kind:`mode`,mode:t.mode&511,symlink:n.isSymbolicLink()}}catch(e){let t=YT(e);return t===`ENOENT`?{kind:`absent`}:{kind:`unreadable`,reason:t}}},ZT=async e=>{let t=await XT(e.path);if(t.kind===`absent`)return;if(t.kind===`unreadable`)return{repairable:!1,text:`${e.label} could not be inspected (${t.reason})`};if(!(t.mode&63))return;let n=t.symlink?` — a symlink; fix it where it points`:``;return{repairable:!t.symlink,text:`${e.label} is ${JT(t.mode)} (expected ${JT(e.expected)})${n}`}},QT=e=>e.some(e=>e.repairable)?` — run: refs init`:``,$T=async e=>{if(process.platform===`win32`)return{detail:`not applicable on this platform — the mode bits do not say who may write`,name:KT,status:`ok`};let t=(await Promise.all(qT(e).map(e=>ZT(e)))).filter(e=>e!==void 0);return t.length===0?{detail:`no group or other permission bits on anything refs owns`,name:KT,status:`ok`}:{detail:`${t.map(e=>e.text).join(`; `)}${QT(t)}`,name:KT,status:`warn`}},eE=e=>{let{diagnosis:t}=e;return e.kind===`claim`||!e.isDirectory||t.pidState===`definitely-dead`||t.stale||t.meta===`malformed`||t.meta===`unreadable`||t.policy===`unknown`?!1:t.ageMs===void 0||t.ageMs>=0},tE=e=>{let{ageMs:t,budgetMs:n,policy:r}=e;return r===`unknown`?`, state could not be read`:t===void 0||n===void 0?``:t<0?`, recorded time is in the future — check the system clock`:`, ${Tg(t)} into a ${Tg(n)} window`},nE=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} present`,rE=(e,t)=>{let n=v(e.locksDir,lg,t.name),r=t.diagnosis.ageMs===void 0?``:` for ${Tg(t.diagnosis.ageMs)}`,i=uS(n),a=i===void 0?`remove that directory by hand — its path cannot be put into a pasteable command`:`${iE}: ${i}`;return`steal claim on ${t.name}: present${r}. Stealing this lock is blocked while it is here. A reclaim in progress clears it within a moment; if it stays, ${a}`},iE=`stop every refs process using this home — including suspended ones — and then run`,aE=(e,t)=>{let{diagnosis:n}=t;if(ng(n))return`, reclaimable now`;if(!n.stale&&t.isDirectory)return``;let r=v(e.locksDir,t.name),i=lS(r);return i===void 0?`, not automatically reclaimable — and its path cannot be put into a pasteable command, so it has to be removed by hand`:`, not automatically reclaimable — if it is genuinely abandoned, ${iE}: ${i}`},oE=(e,t)=>{let{diagnosis:n}=t,r=t.isDirectory?``:`not a directory, `,i=aE(e,t);return`${t.name}: ${r}${nE(n)}${tE(n)}${i}`},sE=async e=>{let t=await wg(e),[n]=t;return n===void 0?{detail:`no locks held`,name:`locks`,status:`ok`}:{detail:t.map(t=>t.kind===`claim`?rE(e,t):oE(e,t)).join(`; `),name:`locks`,status:t.every(e=>eE(e))?`ok`:`warn`}},cE=`npm i -g @kaisers-io/refs@latest`,lE=/^---\r?\n(?<body>[\s\S]*?)\r?\n---/u,uE=/^\s*cli_version:\s*["']?(?<version>[^"'\s]+)["']?\s*$/mu,dE=e=>{let t=lE.exec(e)?.groups?.body;if(t!==void 0)return uE.exec(t)?.groups?.version},fE=(e,t)=>{if(e.length>32)return`unknown`;if(e===t)return`match`;let n=Zy(e,t);return n===void 0?`unknown`:n===0?`match`:n>0?`cli-older`:`skill-older`},pE={"cli-older":(e,t)=>`the refs skill targets CLI ${e} but this CLI is ${t} — update the CLI: ${cE}`,match:(e,t)=>`the refs skill is installed and matches this CLI (${t})`,"skill-older":(e,t,n)=>`the refs skill targets CLI ${e} but this CLI is ${t} — update the skill: ${n}`,unknown:(e,t,n)=>`the refs skill does not declare a version this CLI (${t}) can compare — reinstall both: ${cE} and ${n}`},mE=e=>{let{cliVersion:t,hint:n,label:r,skillVersion:i}=e;if(i===void 0)return{detail:`the refs skill (${r}) predates the version gate — update it: ${n}`,name:`skill`,status:`warn`};let a=fE(i,t);return{detail:`${r}: ${pE[a](i,t,n)}`,name:`skill`,status:a===`match`?`ok`:`warn`}},hE=`local`,gE=/^[\w.+-]+$/u,_E=e=>e!==`.`&&e!==`..`&&gE.test(e),vE=(e,t)=>{let n=Zy(e,t);return n===void 0?e===t?0:e<t?-1:1:n},yE=e=>{let t=e.filter(e=>_E(e));return t.includes(hE)?hE:t.toSorted((e,t)=>vE(t,e))[0]},bE=[`.agents`,`skills`,`refs`,`SKILL.md`],xE=[`skills`,`refs`,`SKILL.md`],SE=[`.claude`,`skills`,`refs`,`SKILL.md`],CE=`npx skills add kaisers-io/refs`,wE=(e,t)=>e===void 0?void 0:{display:t,path:e},TE=e=>{let{dirName:t,env:n,home:r,overrideName:i}=e,a=n[i]?.trim();return a!==void 0&&a.length>0?{display:a,path:a}:wE(r===void 0?void 0:v(r,t),`~/${t}`)},EE=e=>e.homedir.length>0?e.homedir:void 0,DE=e=>TE({dirName:`.codex`,env:e.env,home:EE(e),overrideName:`CODEX_HOME`}),OE=e=>{let t=EE(e);return[{label:`shared ~/.agents`,root:wE(t,`~/.agents`),segments:bE},{label:`Claude Code`,root:TE({dirName:`.claude`,env:e.env,home:t,overrideName:`CLAUDE_CONFIG_DIR`}),segments:xE},{label:`Codex`,root:DE(e),segments:xE},{label:`project ./.agents`,root:wE(e.cwd,`./.agents`),segments:bE},{label:`project ./.claude`,root:wE(e.cwd,`./.claude`),segments:SE}].flatMap(({label:e,root:t,segments:n})=>t===void 0?[]:[{display:t.display,hint:CE,label:e,path:v(t.path,...n)}])},kE=[`plugins`,`cache`],AE=`kaisers-io`,jE=`refs`,ME=`Codex plugin ${jE}@${AE} (enabled state not checked)`,NE=[`refs`,`SKILL.md`],PE=async e=>{try{return(await c(e,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}},FE=[...kE,AE,jE],IE=e=>[e.display,...FE].join(`/`),LE=async e=>{let t=v(e.path,...FE),n=yE(await PE(t));if(n===void 0)return[];let r=v(t,n,...NE);return[{display:IE(e),hint:`codex plugin marketplace upgrade`,label:ME,path:r}]},RE=async e=>{let{hint:t,label:n,path:r}=e;try{let e=await l(r);return{hint:t,label:n,realPath:e,source:await s(e,`utf8`)}}catch{return}},zE=e=>{let t=/* @__PURE__ */ new Map;for(let n of e)t.has(n.realPath)||t.set(n.realPath,n);return[...t.values()]},BE=e=>({detail:`refs skill not found in the locations this check knows about (${e.join(`, `)}) — an install anywhere else is invisible here and still works; if it really is missing: ${CE}`,name:`skill`,status:`warn`}),VE=async e=>{let t=DE(e),n=t===void 0?[]:await LE(t),r=[...OE(e),...n],i=await Promise.all(r.map(e=>RE(e))),a=zE(i.filter(e=>e!==void 0)).map(t=>mE({cliVersion:e.cliVersion,hint:t.hint,label:t.label,skillVersion:dE(t.source)})),o=t===void 0?[]:[IE(t)],s=/* @__PURE__ */ new Set([...r.map(e=>e.display),...o]);return a.find(e=>e.status!==`ok`)??a[0]??BE([...s])},HE=/^(?<user>[^/\s@]+)@(?<host>[^:/\s]+):/u,UE=e=>e===``?{}:{user:e},WE=e=>e===``?{}:{port:e},GE=e=>{try{let t=new URL(e);return t.protocol===`ssh:`?{host:t.hostname,...UE(t.username),...WE(t.port)}:void 0}catch{return}},KE=e=>{let t=HE.exec(e),n=t?.groups?.host;return n===void 0?GE(e):{host:n,user:t?.groups?.user??`git`}},qE=e=>e.port===void 0?e.host:`${e.host}:${e.port}`,JE=e=>e.user===void 0?qE(e):`${e.user}@${qE(e)}`,YE=e=>{let t=Object.values(e.refs).map(e=>KE(e.url)).filter(e=>e!==void 0),n=/* @__PURE__ */ new Map;for(let e of t)n.set(JE(e),e);return[...n.values()].toSorted((e,t)=>JE(e).localeCompare(JE(t)))},XE=/Permission denied/u,ZE=[/Could not resolve hostname/u,/Connection refused/u,/Host key verification failed/u,/timed out/u],QE=e=>e.user===void 0?e.host:`${e.user}@${e.host}`,$E=e=>{let t=[`-o`,`ConnectTimeout=5`,`-o`,`BatchMode=yes`],n=QE(e);return e.port===void 0?[...t,`-T`,n]:[...t,`-p`,e.port,`-T`,n]},eD=async(e,t,n)=>{let r=JE(t),i=await e.runner.run(`ssh`,$E(t),{timeoutMs:n});return i.timedOut===!0?{host:r,outcome:`timeout`}:XE.test(i.stderr)?{host:r,outcome:`denied`}:ZE.some(e=>e.test(i.stderr))?{detail:i.stderr.trim(),host:r,outcome:`connection-warn`}:{host:r,outcome:`ok`}},tD=(e,t)=>{let n=e.filter(e=>e.outcome===`timeout`).map(e=>e.host);if(n.length!==0)return{detail:`ssh probe timed out after ${t/1e3}s: ${n.join(`, `)}`,name:`ssh-auth`,status:`fail`}},nD=e=>{let t=e.filter(e=>e.outcome===`denied`).map(e=>e.host);if(t.length!==0)return{detail:`ssh permission denied for: ${t.join(`, `)}`,name:`ssh-auth`,status:`fail`}},rD=e=>{let t=e.filter(e=>e.outcome===`connection-warn`);if(t.length!==0)return{detail:`ssh connection issue, treated as warn: ${t.map(e=>`${e.host} (${e.detail??``})`).join(`; `)}`,name:`ssh-auth`,status:`warn`}},iD=e=>({detail:`ssh auth ok for: ${e.map(e=>e.host).join(`, `)}`,name:`ssh-auth`,status:`ok`}),aD=(e,t)=>tD(e,t)??nD(e)??rD(e)??iD(e),oD=async(e,t,n)=>{let r=YE(t);if(r.length===0)return;let i=n?.timeoutMs??1e4,a=await Promise.all(r.map(t=>eD(e,t,i)));return aD(a,i)},sD=async e=>{try{return await e.run()}catch(t){return{detail:`check crashed: ${$x(t)}`,name:e.name,status:`fail`}}},cD={"cli-update":`Checking for a newer refs release`,config:`Checking the config`,"config-drift":`Comparing registered packages with the checkouts`,"dirty-checkouts":`Looking for local changes in checkouts`,git:`Checking Git`,"git-exec-surfaces":`Checking what Git is configured to run`,"hooks-guard":`Checking the checkout protection hooks`,locks:`Checking locks`,node:`Checking Node.js`,orphans:`Looking for orphaned checkouts`,skill:`Checking the installed skill`,"ssh-auth":`Checking SSH authentication`},lD=async(e,t)=>{let[n,...r]=e;if(n===void 0)return[];t.update(cD[n.name]??`Running the ${n.name} check`);let i=await sD(n),a=await lD(r,t);return i===void 0?a:[i,...a]},uD=e=>{let{configLoad:t,ctx:n,home:r,state:i}=e,a={};return[{name:`git`,run:async()=>{let e=await lw(n);return e.status===`ok`&&(a.versionLine=e.detail),e}},{name:`git-exec-surfaces`,run:()=>CC(n,r.root,a.versionLine)},{name:`node`,run:()=>Promise.resolve(pw(n))},{name:`config`,run:()=>Promise.resolve(gw(t.errorMessage))},{name:`home-modes`,run:()=>$T(r)},{name:`hooks-guard`,run:()=>Mw(n,r,t.config)},{name:`dirty-checkouts`,run:()=>Fw(n,r,t.config)},{name:`config-drift`,run:()=>GT(r,t.config)},{name:`orphans`,run:()=>Hw(r,t.config,i)},{name:`locks`,run:()=>sE(r)},{name:`skill`,run:()=>VE(n)},{name:`cli-update`,run:()=>yw(n,t.config)},{name:`ssh-auth`,run:()=>oD(n,t.config)}]},dD=async(e,t)=>{t.update(`Reading config and state`);let n=U(e.env),r=await hw(n),i=await Iw(n);return lD(uD({configLoad:r,ctx:e,home:n,state:i}),t)},fD={fail:`FAIL`,ok:`OK`,warn:`WARN`},pD=e=>e.map(e=>`[${fD[e.status]}] ${e.name}: ${e.detail}`),mD=e=>e.some(e=>e.status===`fail`),hD=(e,t)=>{e.command(`doctor`).description(`Run environment/integrity checks (git, node, config, hooks, checkouts, drift, locks, ssh).`).action((e,n)=>{let r=X(n);return Q(t,r,async()=>{let e=await nS(t,r,e=>dD(t,e));Z(t,r,pD(e),{checks:e}),mD(e)&&(process.exitCode=pu.UNEXPECTED)})()})},gD=(e,t)=>{let n=e.refs[t];
466
+ `),o=a===-1?r:r.slice(0,a),s=a===-1?``:r.slice(a+1);n.push({key:o,scope:i,value:s})}return n},AC=e=>{let t=/* @__PURE__ */ new Map;for(let n of e){let e=SC.exec(n.key)?.groups?.label;e!==void 0&&t.set(e,n.value!==`false`)}return new Set([...t].filter(([,e])=>!e).map(([e])=>e))},jC=e=>{let t=EC.exec(e?.trim()??``)?.groups;if(t===void 0)return!0;let n=Number(t.major);return n>DC.major||n===DC.major&&Number(t.minor)>=DC.minor},MC=e=>{let t=e.findLast(e=>e.key===wC)?.value;return t!==void 0&&!OC.has(t.trim().toLowerCase())},NC=(e,t)=>{let n=xC.exec(e.key)?.groups?.label;return n===void 0?CC.test(e.key):t.hooksRun&&!t.disabled.has(n)},PC=(e,t)=>{let n=kC(e).filter(e=>e.scope!==`local`),r={disabled:AC(n),hooksRun:jC(t)},i=n.filter(e=>NC(e,r)).map(e=>e.key);return MC(n)&&i.push(wC),[...new Set(i)]},FC=[[CC,`a filter is selected by a checkout's own .gitattributes and stays enabled, because turning it off would change what the checkout contains`],[xC,`a configured hook fires on the events refs causes and nothing disabled it: refs switches those events off and disables each label it finds`],[TC,`fsmonitor runs a command in the worktree`]],IC=e=>{let t=FC.filter(([t])=>e.some(e=>t.test(e))).map(([,e])=>e);return`${e.join(`, `)}: git runs these itself and the managed hooks path does not cover them — ${t.join(`; `)}. Whether one of them reaches a checkout's content depends on the command, which refs cannot decide for you`},LC=`git-exec-surfaces`,RC=e=>({detail:`${e}, so this could not be checked`,name:LC,status:`warn`}),zC=async(e,t,n)=>{let r=await e.runner.run(`git`,[`config`,`--list`,`-z`,`--show-scope`],{cwd:t});if(r.exitCode!==0)return RC(`the git configuration could not be read`);if(r.stdoutTruncated===!0)return RC(`the git configuration was too large to read whole`);let i=PC(r.stdout,n);return i.length===0?{detail:`no configured hook, filter or fsmonitor command that refs leaves enabled`,name:LC,status:`ok`}:{detail:IC(i),name:LC,status:`warn`}},BC=async(e,t)=>{let n=await e.runner.run(`git`,[`--version`],{cwd:t}),r=n.exitCode===0?n.stdout:void 0,i=await zC(e,t,r);return i.status===`ok`?void 0:`${LC}: ${i.detail}`},VC=e=>My(e)?void 0:`workspace detection could not fully inspect the declared workspaces (${lC(e)}) — members may be missing from the detected packages; the repository's own workspace declaration is what settles it`,HC=(e,t)=>{let n=jS(e.packages,t.resolved.npmDirectory,t.resolved.npmPkgName),r=aC({counted:t.countedTagFormat,scan:e,tags:t.tags}),i=sC({packages:n,refFormat:r,scan:e,tags:t.tags}),a=PS(e.packages,i),o=VC(e);return{defaultBranch:t.defaultBranch,...o===void 0?{}:{detectionWarning:o},packages:i,...a===void 0?{}:{rootPackageName:a},tagFormatCandidate:r}},UC=e=>e.complete?Nm(e.tags):null,WC=async(e,t)=>{let{dest:n,resolved:r}=t,i=await fm(e.runner,n),a=await Cm(e.runner,n),o=UC(a);_S(e,`detecting workspace packages…`);let s=await Ax(n),c=a.complete?a.tags:[];return HC(s,{countedTagFormat:o,defaultBranch:i,resolved:r,tags:c})},GC=(e,t)=>q(t.home,WS(t.resolved.key),async()=>{let n=await BC(e,t.home.root),r=await _C(e,{allowFileUrls:GS(e.env),cloneUrl:t.resolved.cloneUrl,dest:t.dest,home:t.home,hooksDir:t.home.hooksDir,mode:t.cloneMode}),i={fields:await WC(e,t),...n===void 0?{}:{execSurfacesWarning:n}};return r.effectiveMode!==void 0&&(i.effectiveMode=r.effectiveMode),r.warning!==void 0&&(i.warning=r.warning),i}),KC=(e,t)=>{if(!Ce(e.defaultBranch))throw V(`this repository's HEAD names a branch git will not accept: ${JSON.stringify(e.defaultBranch)}. refs cannot synchronise a ref with that default branch — the name comes from the repository, so there is nothing to correct in this command.`);return{default_branch:e.defaultBranch,description:``,key:t.key,packages:e.packages,tag_format_candidate:e.tagFormatCandidate,url:t.cloneUrl}},qC=e=>{let{effectiveMode:t,execSurfacesWarning:n,fields:r,warning:i}=e.cloneResult;return{dest:e.dest,...n===void 0?{}:{execSurfacesWarning:n},proposal:KC(r,e.resolved),...r.detectionWarning===void 0?{}:{detectionWarning:r.detectionWarning},...r.rootPackageName===void 0?{}:{rootPackageName:r.rootPackageName},...t===void 0?{}:{effectiveCloneMode:t},...i===void 0?{}:{warning:i}}},JC=async(e,t)=>{let n=U(e.env),r=await H(n),i=YS(await JS(e,t),r.settings);ZS(r,i.key),await rC(n,i.key);let a=ku(n,i.key),o=ab(`clone_mode`,void 0,r.settings),s=await GC(e,{cloneMode:o,dest:a,home:n,resolved:i});return qC({cloneResult:s,dest:a,resolved:i})},YC=(e,t,n)=>q(e,`home`,async()=>{let r=await H(e);ZS(r,t);let i=await cb(e),a=i.refs[t],o=n??a?.effective_clone_mode,s={...a,pending_proposal_at:(/* @__PURE__ */ new Date()).toISOString()};o!==void 0&&(s.effective_clone_mode=o),i.refs[t]=s,await lb(e,i)}),XC=(e,t)=>{let n=El.safeParse(e);if(!n.success)throw V(T(n.error));let r=ib.safeParse(t);if(!r.success)throw V(T(r.error));return{config:n.data,state:r.data}},ZC=async(e,t)=>{let n=await H(e.home);ZS(n,e.ref.key);let r=zS(e.ref);n.refs[e.ref.key]=r;let i=await cb(e.home);return i.refs[e.ref.key]={effective_clone_mode:e.effectiveCloneMode??i.refs[e.ref.key]?.effective_clone_mode??ab(`clone_mode`,void 0,n.settings),head_sha:t,last_fetched_at:(/* @__PURE__ */ new Date()).toISOString()},{...XC(n,i),entry:r}},QC=async(e,t)=>{let n=GS(e.env),r=await q(t.home,WS(t.ref.key),()=>(Pu(t.home,t.dest),bC(e.runner,{allowFileUrls:n,dest:t.dest,expectedUrl:t.ref.url,hooksDir:t.home.hooksDir,key:t.ref.key})));return q(t.home,`home`,async()=>{let{config:e,entry:n,state:i}=await ZC(t,r);return await lb(t.home,i),await Eu(t.home,e),{entry:n,key:t.ref.key}})},$C=(e,t)=>t===`-`?e.readStdin():s(t,`utf8`),ew=e=>{try{return JSON.parse(e)}catch{throw V(`invalid JSON in proposal: the document could not be parsed`)}},tw=e=>typeof e==`object`&&!!e&&!Array.isArray(e),nw=e=>tw(e)&&`ok`in e&&!(`key`in e),rw=e=>{if(!nw(e))return e;if(e.ok===!1)throw V(`proposal file contains a failed refs envelope (ok is false) — re-run the dry-run`);if(tw(e.data))return e.data;throw V(`proposal file is a refs envelope without a usable data object — re-run the dry-run`)},iw=e=>e.code===`unrecognized_keys`,aw=e=>e.path.length===0,ow=(e,t)=>{let n=t.toSorted().map(e=>`"${e}"`).join(`, `);return e===``?`✖ unrecognized key(s) in proposal: ${n}`:`✖ unrecognized key(s) in proposal at ${e}: ${n}`},sw=e=>{let t=/* @__PURE__ */ new Map;for(let n of e){let e=qt(n.path);t.set(e,[...t.get(e)??[],...n.keys])}return[...t.entries()].toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>ow(e,t))},cw=e=>`✖ invalid proposal: ${e.message}`,lw=e=>{let t=e.issues.filter(e=>iw(e)),n=e.issues.filter(e=>!iw(e)),r=n.filter(e=>aw(e));if(t.length===0&&r.length===0)return T(e);let i=n.filter(e=>!aw(e)),a=[...sw(t),...r.map(e=>cw(e))];return i.length>0&&a.push(T({issues:i})),a.join(`
467
+ `)},uw=e=>{let t=nb.safeParse(e);if(!t.success)throw V(lw(t.error));return t.data},dw=async(e,t)=>{let n=await $C(e,t);return uw(rw(ew(n)))},fw=(e,t)=>[`refs add: dry-run proposal ready for '${e}' (checkout: ${t})`,`next: review the proposal, then run refs add --proposal <file> to finalize`],pw=e=>[...mS(e.execSurfacesWarning),...mS(e.warning),...mS(e.detectionWarning)],mw=async(e,t)=>{let n=await JC(e,t),r=U(e.env);await YC(r,n.proposal.key,n.effectiveCloneMode);let i=pw(n);return{data:n.proposal,human:fw(n.proposal.key,n.dest),warnings:i}},hw=e=>[`refs add: '${e}' added to config`],gw=e=>{let t={default_branch:e.default_branch,description:e.description,key:e.key,url:e.url};e.tag_format_candidate!==null&&(t.tag_format=e.tag_format_candidate);let n=RS(e.packages);return n!==void 0&&(t.packages=n),t},_w=async(e,t)=>{let n=await dw(e,t),r=U(e.env),i=ku(r,n.key);if(!K(i))throw mu(`no checkout found at ${i} — run: refs add <source> --dry-run first`);let a=gw(n),{entry:o,key:s}=await QC(e,{dest:i,home:r,ref:a});return{data:{entry:o,key:s},human:hw(s),warnings:[]}},vw=(e,t,n)=>{LS(e.proposal.packages,n,e.rootPackageName);let r={default_branch:e.proposal.default_branch,description:t,key:e.proposal.key,url:e.proposal.url};e.proposal.tag_format_candidate!==null&&(r.tag_format=e.proposal.tag_format_candidate);let i=NS(e.proposal.packages,{refDescription:t,...e.rootPackageName===void 0?{}:{rootPackageName:e.rootPackageName}});return i!==void 0&&(r.packages=i),r},yw=async(e,t,n)=>{let r=await JC(e,t),i=U(e.env);await YC(i,r.proposal.key,r.effectiveCloneMode);let a=vw(r,n,t),o={dest:r.dest,home:i,ref:a};r.effectiveCloneMode!==void 0&&(o.effectiveCloneMode=r.effectiveCloneMode);let{entry:s,key:c}=await QC(e,o);return{data:{entry:s,key:c},human:hw(c),warnings:pw(r)}},bw=e=>{let t=[e.dryRun,e.proposal!==void 0,e.description!==void 0].filter(Boolean).length;if(t>1)throw B(`refs add: use only one of --dry-run, --proposal, or --description`);if(t===0)throw B(`refs add needs --dry-run, --proposal, or --description`)},xw=e=>{if(e===void 0||e===``)throw B(`refs add requires <source> (a git url or npm:<package>)`);return e},Sw=(e,t)=>(bw(t),t.proposal===void 0?t.description===void 0?mw(e,xw(t.source)):yw(e,xw(t.source),t.description):_w(e,t.proposal)),Cw=(e,t)=>{let n={dryRun:t.dryRun===!0};return e!==void 0&&(n.source=e),t.proposal!==void 0&&(n.proposal=t.proposal),t.description!==void 0&&(n.description=t.description),n},ww=(e,t)=>{e.command(`add`).description(`Add a git reference in two phases: propose (--dry-run), then finalize (--proposal).`).argument(`[source]`,`git url or npm:<package> (omit when finalizing with --proposal)`).option(`--dry-run`,`resolve and clone the source, writing a reviewable proposal`).option(`--proposal <file>`,`finalize from a completed proposal JSON file (- for stdin)`).option(`--description <text>`,`one-shot: dry-run then finalize immediately with this description`).action((e,n,r)=>{let i=X(r);return Q(t,i,async()=>{let r=await Sw(t,Cw(e,n));Z(t,i,r.human,r.data,r.warnings)})()})},Tw=async e=>{let t=await e.runner.run(`git`,[`--version`]);return t.exitCode===0?{detail:t.stdout.trim(),name:`git`,status:`ok`}:{detail:t.stderr.trim()||`git --version exited with code ${t.exitCode}`,name:`git`,status:`fail`}},Ew=/^v(?<major>\d+)\.(?<minor>\d+)/u,Dw=e=>{let t=Ew.exec(e),n=t?.groups?.major,r=t?.groups?.minor;if(n!==void 0&&r!==void 0)return{major:Number(n),minor:Number(r)}},Ow=e=>e===void 0?!1:e.major>24||e.major===24&&e.minor>=2,kw=e=>{let{nodeVersion:t}=e;return Ow(Dw(t))?{detail:t,name:`node`,status:`ok`}:{detail:`${t} does not satisfy the required range >=24.2`,name:`node`,status:`fail`}},Aw=()=>El.parse({meta:{cli_version:`0.0.0`,schema_version:1},refs:{},settings:{}}),jw=async e=>{try{return{config:await H(e)}}catch(e){return{config:Aw(),errorMessage:hS(e)}}},Mw=e=>e===void 0?{detail:`config is present and matches the current schema`,name:`config`,status:`ok`}:{detail:e,name:`config`,status:`fail`},Nw={ci:`update check is off in CI — set REFS_UPDATE_CHECK=1 to run it here anyway`,config:`update check is off ([updates].check = false in config.toml)`,env:`update check is off (REFS_UPDATE_CHECK=0)`},Pw=(e,t,n)=>{if(xb(e,t)){let r=n?` (npm was unreachable just now; this was its last answer)`:``;return{detail:`${Sb(e,t)}${r}`,name:`cli-update`,status:`warn`}}return n?{detail:`could not reach npm to check; its last answer was ${t}, which this CLI (${e}) already has`,name:`cli-update`,status:`warn`}:{detail:`this CLI (${e}) is npm's latest published release`,name:`cli-update`,status:`ok`}},Fw=async(e,t)=>{let n=Eb({env:e.env,updates:t.updates});if(n!==`on`)return{detail:Nw[n],name:`cli-update`,status:`ok`};let{latest:r,stale:i}=await bb({fetch:e.fetcher,home:U(e.env),nowMs:Date.now()});return r===void 0?{detail:`could not reach npm to learn the latest published version — not a fault of your setup, and nothing else depends on it`,name:`cli-update`,status:`warn`}:Pw(e.cliVersion,r,i)},Iw=e=>{let t=0,n=[];return{acquire:()=>{if(t<e)return t+=1,Promise.resolve();let{promise:r,resolve:i}=Promise.withResolvers();return n.push(()=>{t+=1,i()}),r},release:()=>{--t;let e=n.shift();e!==void 0&&e()}}},Lw=async(e,t)=>{await e.acquire();try{return await t()}finally{e.release()}},Rw=(e,t,n)=>{let r=Iw(t);return Promise.all(e.map(e=>Lw(r,()=>n(e))))},zw=(e,t)=>Object.keys(t.refs).map(e=>al.parse(e)).map(t=>({dest:ku(e,t),key:t})).filter(e=>K(e.dest)),Bw=[`pre-commit`,`pre-push`],Vw=async(t,r)=>{try{return await e(v(t.hooksDir,r),n.X_OK),!0}catch{return!1}},Hw=async e=>{let t=await Promise.all(Bw.map(t=>Vw(e,t)));return Bw.filter((e,n)=>!t[n])},Uw=async e=>{try{return(await c(e.hooksDir)).filter(e=>!Bw.includes(e)).toSorted()}catch(e){if(z(e))return[];throw e}},Ww=async(e,t,n)=>{let r=await e.runner.run(`git`,[`config`,`--local`,`--get`,`core.hooksPath`],{cwd:n});return r.exitCode===0&&r.stdout.trim()===t.hooksDir},Gw=(e,t)=>`${t.map(e=>`hooks/${e}`).join(`, `)}: not installed by refs — this is the directory git resolves hook names against for every managed checkout, so nothing whose provenance refs cannot account for belongs in it; remove: ${TS(t.map(t=>v(e,t)))}`,Kw=e=>{let t=[];return e.unexpected.length>0&&t.push(Gw(e.hooksDir,e.unexpected)),e.missingHooks.length>0&&t.push(`${e.missingHooks.map(e=>`hooks/${e}`).join(`, `)} missing or not executable — run: refs init`),e.badKeys.length>0&&t.push(`core.hooksPath not set for: ${e.badKeys.join(`, `)} — run: refs init`),t},qw=e=>{let t=Kw(e);return t.length>0?{detail:t.join(`; `),name:`hooks-guard`,status:`fail`}:{detail:`${Bw.map(e=>`hooks/${e}`).join(`, `)} present; ${e.checkoutCount} checkout(s) guarded`,name:`hooks-guard`,status:`ok`}},Jw=async(e,t,n)=>{let r=zw(t,n),[i,a,o]=await Promise.all([Hw(t),Uw(t),Rw(r,8,n=>Ww(e,t,n.dest))]),s=r.filter((e,t)=>!o[t]).map(e=>e.key);return qw({badKeys:s,checkoutCount:r.length,hooksDir:t.hooksDir,missingHooks:i,unexpected:a})},Yw=async(e,t)=>{let n=await e.run(`git`,[`status`,`--porcelain`],{cwd:t.dest});return n.exitCode===0?{broken:!1,detail:``,dirty:n.stdout.trim()!==``,key:t.key}:{broken:!0,detail:n.stderr.trim(),dirty:!1,key:t.key}},Xw=e=>{let t=e.filter(e=>e.broken);if(t.length>0)return{detail:t.map(e=>`${e.key}: git status failed — ${e.detail}`).join(`; `),name:`dirty-checkouts`,status:`fail`};let n=e.filter(e=>e.dirty).map(e=>e.key);return n.length===0?{detail:`no local changes in any checkout`,name:`dirty-checkouts`,status:`ok`}:{detail:`local changes will be discarded on next sync: ${n.join(`, `)}`,name:`dirty-checkouts`,status:`warn`}},Zw=async(e,t,n)=>{let r=zw(t,n),i=await Rw(r,8,t=>Yw(e.runner,t));return Xw(i)},Qw=async e=>{try{return await cb(e)}catch{return ib.parse({})}},$w=async e=>{try{return(await c(e,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(e){if(z(e))return[];throw e}},eT=async(e,t)=>{if(K(e))return[[...t]];let n=await $w(e);return(await Promise.all(n.map(n=>eT(v(e,n),[...t,n])))).flat()},tT=(e,t,n)=>{let r=e.refs[t]?.pending_proposal_at;return r!==void 0&&n-Date.parse(r)<864e5},nT=(e,t,n)=>{if(tT(t,e.key,n))return`${e.key}: pending add`;let r=TS(e.dest);return r===void 0?`${e.key}: orphan — its path cannot be put into a pasteable command; remove it by hand`:`${e.key}: orphan — remove with: ${r}`},rT=(e,t)=>({dest:v(e.sourcesDir,...t),key:t.join(`/`)}),iT=async(e,t,n)=>{let r=(await eT(e.sourcesDir,[])).map(t=>rT(e,t)).filter(e=>!Object.hasOwn(t.refs,e.key));if(r.length===0)return{detail:`no orphaned checkouts under sources/`,name:`orphans`,status:`ok`};let i=Date.now();return{detail:r.map(e=>nT(e,n,i)).join(`; `),name:`orphans`,status:`warn`}},aT=e=>{let t=(e??``).lastIndexOf(`/`);return t===-1?`.`:(e??``).slice(0,t)},oT=e=>{let[t=`.`,...n]=e,r=t.split(`/`),i=r.length;for(let e of n){let t=e.split(`/`),n=0;for(;n<i&&n<t.length&&r[n]===t[n];)n+=1;i=n}return i===0?`.`:r.slice(0,i).join(`/`)},sT=e=>bl.safeParse({name:e.name,path:e.path}).success,cT=(e,t,n)=>wS([[`--package`,e.name],`--decline`,[`--path`,n]],[t]),lT=(e,t,n)=>wS([[`--package`,e.name],`--create`,[`--path`,n],[`--description`,`<what it is>`]],[t]),uT=(e,t)=>{let{path:n}=e;if(n===void 0||!sT(e))return{};let r=cT(e,t,n),i=gl(e.name)?lT(e,t,n):void 0;return r===void 0?{}:i===void 0?{decline:r}:{decline:r,register:i}},dT=(e,t)=>{let n=dl.safeParse(e.path);if(!n.success)return{};let r=wS([[`--package`,e.name]],[t,`path`,n.data]);return r===void 0?{}:{repoint:r}},fT=(e,t)=>{let n=wS([[`--package`,e.name],`--remove`],[t]);return n===void 0?{}:{unregister:n}},pT=(e,t)=>e.status===`unregistered`?uT(e,t):e.status===`relocated`?dT(e,t):e.status===`missing`?fT(e,t):{},mT=`(unknown)`,hT=`no single-line command can carry these values, so none is offered — 'refs doctor --json' has them exactly`,gT=(e,t)=>{let{decline:n,register:r}=uT(e,t);if(n!==void 0)return r===void 0?`Its name is one the packages table cannot hold, so it cannot be registered — if that is the answer, record it: ${n}`:`To register it (replace the description first): ${r}. If it should not be: ${n}`},_T=(e,t)=>{let n=`${e.name}: declared in this checkout but not registered — it cannot be resolved by name until it is`,{path:r}=e;if(r===void 0)return`${n}. Declared at several paths (${(e.candidates??[]).join(`, `)}) — pick one`;if(!sT(e))return`${n}. Its name or path is one the configuration cannot hold, so there is no command for it — report it and leave it unregistered`;let i=gT(e,t);return i===void 0?`${n}. ${hT} — report it and leave it unregistered`:`${n}. ${i}`},vT=(e,t,n)=>{let r=`${e.name}: moved to ${e.path??mT} — update the entry's path (${n})`,{repoint:i}=pT(e,t);return i===void 0?r:`${r}. To fix it: ${i}`},yT=(e,t,n)=>{let r=`${e.name}: gone from this repo's workspaces (${n}) — repoint the entry if it moved out of them`,{unregister:i}=pT(e,t);return i===void 0?`${r}; ${hT}, so unregister it by hand`:`${r}, or unregister it: ${i}`},bT=(e,t)=>{let n=`configured: ${e.configured_path??mT}`;if(e.status===`relocated`)return vT(e,t,n);if(e.status===`missing`)return yT(e,t,n);if(e.status===`ambiguous`){let t=(e.candidates??[]).join(`, `);return`${e.name}: declared at several paths (${t}) — point the entry at one (${n})`}return`${e.name}: could not be checked — ${e.reason??`(no reason given)`} (${n})`},xT=(e,t)=>e.status===`unregistered`?_T(e,t):bT(e,t),ST=e=>`could not check for unregistered packages — ${e}`,CT=e=>`…and ${e} more finding(s) — act on the ones above (register, repoint or decline) and run the check again to see the rest`,wT=e=>{let t=e.length-10;return t<=0?[...e]:[...e.slice(0,10),CT(t)]},TT=e=>{let t=/* @__PURE__ */ new Map;for(let n of e){let[e=`.`]=aT(n.path).split(`/`);t.set(e,[...t.get(e)??[],n])}return t},ET=e=>e.path===void 0,DT=(e,t,n)=>{if(e.length<3)return e.map(e=>({candidates:1,dir:n,line:_T(e,t)}));let r=oT(e.map(e=>aT(e.path)));return[{candidates:e.length,dir:r,line:`${r}: ${e.length} unregistered package(s) the configuration does not have`}]},OT=e=>{let t=e.reduce((e,t)=>e+t.candidates,0),n=new Set(e.flatMap(e=>e.dir===void 0?[]:[e.dir])).size;return`…and ${t} more unregistered package(s)${n===0?``:` in ${n} director(ies)`} — 'refs doctor --json' lists every candidate`},kT=(e,t)=>{let n=e.filter(e=>ET(e)).map(e=>({candidates:1,line:_T(e,t)})),r=[...TT(e.filter(e=>!ET(e)))].toSorted(([e],[t])=>e.localeCompare(t)).flatMap(([e,n])=>DT(n,t,e)),i=[...n,...r],a=i.slice(10);return a.length===0?i.map(e=>e.line):[...i.slice(0,10).map(e=>e.line),OT(a)]},AT=(e,t)=>e.reason===void 0?[...wT((e.packages??[]).map(e=>xT(e,t))),...kT(e.discovery??[],t),...e.discovery_incomplete===void 0?[]:[ST(e.discovery_incomplete)]]:[`could not be checked — ${e.reason}`],jT=e=>{let t;return()=>(t??=Ax(e),t)},MT=async(e,t,n)=>{let r=await Vb(e);if(r===void 0||t.some(e=>e.packageName===r.name))return{issues:[]};let i=await n();if(!My(i))return{incomplete:lC(i),issues:[]};let a=Hy(i.packages,r.name);return a.kind===`ambiguous`?{issues:[{candidates:a.paths,name:r.name,status:`unregistered`}]}:{issues:a.kind===`found`?[{name:r.name,path:a.path,status:`unregistered`}]:[]}},NT=e=>{let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n.name,[...t.get(n.name)??[],n.path]);return t},PT=(e,t)=>{let n=new Set(e.changedDirs),r=t.filter(e=>!n.has(e.path)).map(e=>e.name);return/* @__PURE__ */ new Set([...e.namesBefore,...r])},FT=(e,t)=>t.length===1&&t[0]!==void 0?{name:e,path:t[0],status:`unregistered`}:{candidates:[...t],name:e,status:`unregistered`},IT=async(e,t,n)=>{if(t.kind===`arrivals`&&t.changedDirs.length===0)return{issues:[]};let r=await n();if(!My(r))return{incomplete:lC(r),issues:[]};let i=new Set(e.map(e=>e.packageName)),a=r.packages.filter(e=>e.path!==`.`),o=t.kind===`all`?void 0:PT(t,a);return{issues:[...NT(a)].filter(([e])=>!i.has(e)).filter(([e])=>o===void 0||!o.has(e)).map(([e,t])=>FT(e,t)).toSorted((e,t)=>e.name.localeCompare(t.name))}},LT=(e,t)=>{if(t.length===0)return{issues:[...e],suppressed:[]};let n=(e,n)=>t.some(t=>t.name===e&&t.path===n),r=[];return{issues:e.flatMap(e=>{if(e.status!==`unregistered`)return[e];let t=e.path===void 0?e.candidates??[]:[e.path],i=t.filter(t=>!n(e.name,t)),a=t.filter(t=>n(e.name,t));return r.push(...a.map(t=>({name:e.name,path:t}))),i.length===0?[]:[FT(e.name,i)]}),suppressed:r}},RT=e=>e!==`unmaterialized`&&e!==`verified`,zT=/* @__PURE__ */ new Set([`ambiguous`,`missing`,`relocated`]),BT=(e,t={})=>{let{declined:n=[],discoveryIncomplete:r}=t,i=e.filter(e=>e.status!==`unregistered`),a=e.filter(e=>e.status===`unregistered`);return{...n.length===0?{}:{declined:[...n]},...a.length===0?{}:{discovery:a},...r===void 0?{}:{discovery_incomplete:r},...i.length===0?{}:{packages:i},status:VT(i,r)}},VT=(e,t)=>e.some(e=>zT.has(e.status))?`drift`:e.length===0&&t===void 0?`ok`:`unknown`,HT=(e,t)=>({path:e.configuredPath,reason:t,status:`unverifiable`}),UT=(e,t)=>Ny(t)?{configuredPath:e.configuredPath,path:null,status:`missing`}:HT(e,`this repo declares no workspaces, so there was nowhere to search`),WT=(e,t)=>t===e.configuredPath,GT=e=>e.packages.filter(e=>e.path!==`.`),KT=(e,t)=>{let n=Hy(GT(t),e.packageName);return n.kind===`ambiguous`?{candidates:n.paths,configuredPath:e.configuredPath,path:null,status:`ambiguous`}:My(t)?n.kind===`absent`?UT(e,t):WT(e,n.path)?HT(e,`the checkout changed while it was being inspected`):{configuredPath:e.configuredPath,path:n.path,status:`relocated`}:HT(e,n.kind===`found`?`workspace detection was incomplete, so the new location is not confirmed unique`:`workspace detection was incomplete`)},qT=e=>{let t=new Map(Object.entries(e??{}));return[...t.keys()].toSorted().flatMap(e=>{let n=t.get(e);return n===void 0?[]:[{configuredPath:n.path,packageName:e}]})},JT=async(e,t)=>{let n=await zy(e,t.configuredPath,t.packageName);if(n.kind===`match`)return{path:t.configuredPath,status:`verified`};if(n.kind===`unreadable`)return{path:t.configuredPath,reason:n.reason,status:`unverifiable`}},YT=e=>e.flatMap(e=>e.settled===void 0?[]:[{outcome:e.settled,query:e.query}]),XT=async(e,t,n)=>{let r=await Promise.all(t.map(async t=>({query:t,settled:await JT(e,t)})));if(r.every(e=>e.settled!==void 0))return YT(r);let i=await n();return r.map(e=>({outcome:e.settled??KT(e.query,i),query:e.query}))},ZT=e=>{let{outcome:t,query:n}=e;return RT(t.status)?[{...t.candidates===void 0?{}:{candidates:t.candidates},configured_path:n.configuredPath,name:n.packageName,...t.status===`relocated`&&t.path!==null?{path:t.path}:{},...t.reason===void 0?{}:{reason:t.reason},status:t.status}]:[]},QT=(e,t)=>{let n=new Set(e.map(e=>e.name));return[...e,...t.filter(e=>!n.has(e.name))]},$T=async(e,t,n)=>{let r=qT(t.packages),[i]=r;if(i===void 0)return{status:`ok`};let a=jT(e);try{let[i,o,s]=await Promise.all([XT(e,r,a),MT(e,r,a),IT(r,n,a)]),c=LT([...i.flatMap(e=>ZT(e)),...QT(o.issues,s.issues)],t.declined_packages??[]);return BT(c.issues,{declined:c.suppressed,...(s.incomplete??o.incomplete)===void 0?{}:{discoveryIncomplete:s.incomplete??o.incomplete}})}catch(e){return{reason:hS(e),status:`unknown`}}},eE=async(e,t,n)=>{try{return await q(e,WS(n.key),()=>$T(n.dest,t.refs[n.key]??{},{kind:`all`}),{timeoutMs:100})}catch(e){if(e instanceof fu&&e.code===`conflict`)return{reason:`another refs process is holding this ref`,status:`unknown`};throw e}},tE=e=>e===0?``:` (${e} declined package(s) not reported)`,nE=(e,t)=>e.unhealthy.length===0?`every configured package path resolves in ${t} checkout(s)`:e.unhealthy.join(`; `),rE=(e,t)=>{let{declined:n,discovery:r,findings:i}=e;return{detail:[nE(e,t)+tE(n),...r].join(`; `),...i.length===0?{}:{findings:i},name:`config-drift`,status:e.unhealthy.length===0?`ok`:`warn`}},iE=async(e,t,n)=>{let[r,...i]=n;if(r===void 0)return{declined:0,discovery:[],findings:[],unhealthy:[]};let a=await eE(e,t,r),o=await iE(e,t,i);return oE(o,{key:r.key,report:a})},aE=(e,t)=>({...e,...pT(e,t)}),oE=(e,t)=>{let{key:n,report:r}=t,i=e=>e.map(e=>`${n}: ${e}`),a=r.discovery??[],o=r.packages??[],s=[...o,...a];return{declined:(r.declined??[]).length+e.declined,discovery:[...i(AT({discovery:a,status:`ok`},n)),...e.discovery],findings:s.length===0?e.findings:[{key:n,packages:s.map(e=>aE(e,n))},...e.findings],unhealthy:[...i(AT({...r.discovery_incomplete===void 0?{}:{discovery_incomplete:r.discovery_incomplete},...r.reason===void 0?{}:{reason:r.reason},packages:o,status:r.status},n)),...e.unhealthy]}},sE=async(e,t)=>{let n=zw(e,t);return rE(await iE(e,t,n),n.length)},cE=`home-modes`,lE=e=>[{expected:448,label:`the refs home`,path:e.root},{expected:448,label:`sources/`,path:e.sourcesDir},{expected:448,label:`locks/`,path:e.locksDir},{expected:448,label:`hooks/`,path:e.hooksDir},{expected:384,label:`config.toml`,path:e.configPath},{expected:384,label:`state.json`,path:e.statePath}],uE=e=>(e&511).toString(8).padStart(3,`0`),dE=e=>e instanceof Error&&`code`in e?String(e.code):`unknown`,fE=async e=>{try{let[t,n]=await Promise.all([p(e),i(e)]);return{kind:`mode`,mode:t.mode&511,symlink:n.isSymbolicLink()}}catch(e){let t=dE(e);return t===`ENOENT`?{kind:`absent`}:{kind:`unreadable`,reason:t}}},pE=async e=>{let t=await fE(e.path);if(t.kind===`absent`)return;if(t.kind===`unreadable`)return{repairable:!1,text:`${e.label} could not be inspected (${t.reason})`};if(!(t.mode&63))return;let n=t.symlink?` — a symlink; fix it where it points`:``;return{repairable:!t.symlink,text:`${e.label} is ${uE(t.mode)} (expected ${uE(e.expected)})${n}`}},mE=e=>e.some(e=>e.repairable)?` — run: refs init`:``,hE=async e=>{if(process.platform===`win32`)return{detail:`not applicable on this platform — the mode bits do not say who may write`,name:cE,status:`ok`};let t=(await Promise.all(lE(e).map(e=>pE(e)))).filter(e=>e!==void 0);return t.length===0?{detail:`no group or other permission bits on anything refs owns`,name:cE,status:`ok`}:{detail:`${t.map(e=>e.text).join(`; `)}${mE(t)}`,name:cE,status:`warn`}},gE=e=>{let{diagnosis:t}=e;return e.kind===`claim`||!e.isDirectory||t.pidState===`definitely-dead`||t.stale||t.meta===`malformed`||t.meta===`unreadable`||t.policy===`unknown`?!1:t.ageMs===void 0||t.ageMs>=0},_E=e=>{let{ageMs:t,budgetMs:n,policy:r}=e;return r===`unknown`?`, state could not be read`:t===void 0||n===void 0?``:t<0?`, recorded time is in the future — check the system clock`:`, ${Tg(t)} into a ${Tg(n)} window`},vE=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} present`,yE=(e,t)=>{let n=v(e.locksDir,lg,t.name),r=t.diagnosis.ageMs===void 0?``:` for ${Tg(t.diagnosis.ageMs)}`,i=ES(n),a=i===void 0?`remove that directory by hand — its path cannot be put into a pasteable command`:`${bE}: ${i}`;return`steal claim on ${t.name}: present${r}. Stealing this lock is blocked while it is here. A reclaim in progress clears it within a moment; if it stays, ${a}`},bE=`stop every refs process using this home — including suspended ones — and then run`,xE=(e,t)=>{let{diagnosis:n}=t;if(ng(n))return`, reclaimable now`;if(!n.stale&&t.isDirectory)return``;let r=v(e.locksDir,t.name),i=TS(r);return i===void 0?`, not automatically reclaimable — and its path cannot be put into a pasteable command, so it has to be removed by hand`:`, not automatically reclaimable — if it is genuinely abandoned, ${bE}: ${i}`},SE=(e,t)=>{let{diagnosis:n}=t,r=t.isDirectory?``:`not a directory, `,i=xE(e,t);return`${t.name}: ${r}${vE(n)}${_E(n)}${i}`},CE=async e=>{let t=await wg(e),[n]=t;return n===void 0?{detail:`no locks held`,name:`locks`,status:`ok`}:{detail:t.map(t=>t.kind===`claim`?yE(e,t):SE(e,t)).join(`; `),name:`locks`,status:t.every(e=>gE(e))?`ok`:`warn`}},wE=`npm i -g @kaisers-io/refs@latest`,TE=/^---\r?\n(?<body>[\s\S]*?)\r?\n---/u,EE=/^\s*cli_version:\s*["']?(?<version>[^"'\s]+)["']?\s*$/mu,DE=e=>{let t=TE.exec(e)?.groups?.body;if(t!==void 0)return EE.exec(t)?.groups?.version},OE=(e,t)=>{if(e.length>32)return`unknown`;if(e===t)return`match`;let n=pb(e,t);return n===void 0?`unknown`:n===0?`match`:n>0?`cli-older`:`skill-older`},kE={"cli-older":(e,t)=>`the refs skill targets CLI ${e} but this CLI is ${t} — update the CLI: ${wE}`,match:(e,t)=>`the refs skill is installed and matches this CLI (${t})`,"skill-older":(e,t,n)=>`the refs skill targets CLI ${e} but this CLI is ${t} — update the skill: ${n}`,unknown:(e,t,n)=>`the refs skill does not declare a version this CLI (${t}) can compare — reinstall both: ${wE} and ${n}`},AE=e=>{let{cliVersion:t,hint:n,label:r,skillVersion:i}=e;if(i===void 0)return{detail:`the refs skill (${r}) predates the version gate — update it: ${n}`,name:`skill`,status:`warn`};let a=OE(i,t);return{detail:`${r}: ${kE[a](i,t,n)}`,name:`skill`,status:a===`match`?`ok`:`warn`}},jE=`local`,ME=/^[\w.+-]+$/u,NE=e=>e!==`.`&&e!==`..`&&ME.test(e),PE=(e,t)=>{let n=pb(e,t);return n===void 0?e===t?0:e<t?-1:1:n},FE=e=>{let t=e.filter(e=>NE(e));return t.includes(jE)?jE:t.toSorted((e,t)=>PE(t,e))[0]},IE=[`.agents`,`skills`,`refs`,`SKILL.md`],LE=[`skills`,`refs`,`SKILL.md`],RE=[`.claude`,`skills`,`refs`,`SKILL.md`],zE=`npx skills add kaisers-io/refs`,BE=(e,t)=>e===void 0?void 0:{display:t,path:e},VE=e=>{let{dirName:t,env:n,home:r,overrideName:i}=e,a=n[i]?.trim();return a!==void 0&&a.length>0?{display:a,path:a}:BE(r===void 0?void 0:v(r,t),`~/${t}`)},HE=e=>e.homedir.length>0?e.homedir:void 0,UE=e=>VE({dirName:`.codex`,env:e.env,home:HE(e),overrideName:`CODEX_HOME`}),WE=e=>{let t=HE(e);return[{label:`shared ~/.agents`,root:BE(t,`~/.agents`),segments:IE},{label:`Claude Code`,root:VE({dirName:`.claude`,env:e.env,home:t,overrideName:`CLAUDE_CONFIG_DIR`}),segments:LE},{label:`Codex`,root:UE(e),segments:LE},{label:`project ./.agents`,root:BE(e.cwd,`./.agents`),segments:IE},{label:`project ./.claude`,root:BE(e.cwd,`./.claude`),segments:RE}].flatMap(({label:e,root:t,segments:n})=>t===void 0?[]:[{display:t.display,hint:zE,label:e,path:v(t.path,...n)}])},GE=[`plugins`,`cache`],KE=`kaisers-io`,qE=`refs`,JE=`Codex plugin ${qE}@${KE} (enabled state not checked)`,YE=[`refs`,`SKILL.md`],XE=async e=>{try{return(await c(e,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}},ZE=[...GE,KE,qE],QE=e=>[e.display,...ZE].join(`/`),$E=async e=>{let t=v(e.path,...ZE),n=FE(await XE(t));if(n===void 0)return[];let r=v(t,n,...YE);return[{display:QE(e),hint:`codex plugin marketplace upgrade`,label:JE,path:r}]},eD=async e=>{let{hint:t,label:n,path:r}=e;try{let e=await l(r);return{hint:t,label:n,realPath:e,source:await s(e,`utf8`)}}catch{return}},tD=e=>{let t=/* @__PURE__ */ new Map;for(let n of e)t.has(n.realPath)||t.set(n.realPath,n);return[...t.values()]},nD=e=>({detail:`refs skill not found in the locations this check knows about (${e.join(`, `)}) — an install anywhere else is invisible here and still works; if it really is missing: ${zE}`,name:`skill`,status:`warn`}),rD=async e=>{let t=UE(e),n=t===void 0?[]:await $E(t),r=[...WE(e),...n],i=await Promise.all(r.map(e=>eD(e))),a=tD(i.filter(e=>e!==void 0)).map(t=>AE({cliVersion:e.cliVersion,hint:t.hint,label:t.label,skillVersion:DE(t.source)})),o=t===void 0?[]:[QE(t)],s=/* @__PURE__ */ new Set([...r.map(e=>e.display),...o]);return a.find(e=>e.status!==`ok`)??a[0]??nD([...s])},iD=/^(?<user>[^/\s@]+)@(?<host>[^:/\s]+):/u,aD=e=>e===``?{}:{user:e},oD=e=>e===``?{}:{port:e},sD=e=>{try{let t=new URL(e);return t.protocol===`ssh:`?{host:t.hostname,...aD(t.username),...oD(t.port)}:void 0}catch{return}},cD=e=>{let t=iD.exec(e),n=t?.groups?.host;return n===void 0?sD(e):{host:n,user:t?.groups?.user??`git`}},lD=e=>e.port===void 0?e.host:`${e.host}:${e.port}`,uD=e=>e.user===void 0?lD(e):`${e.user}@${lD(e)}`,dD=e=>{let t=Object.values(e.refs).map(e=>cD(e.url)).filter(e=>e!==void 0),n=/* @__PURE__ */ new Map;for(let e of t)n.set(uD(e),e);return[...n.values()].toSorted((e,t)=>uD(e).localeCompare(uD(t)))},fD=/Permission denied/u,pD=[/Could not resolve hostname/u,/Connection refused/u,/Host key verification failed/u,/timed out/u],mD=e=>e.user===void 0?e.host:`${e.user}@${e.host}`,hD=e=>{let t=[`-o`,`ConnectTimeout=5`,`-o`,`BatchMode=yes`],n=mD(e);return e.port===void 0?[...t,`-T`,n]:[...t,`-p`,e.port,`-T`,n]},gD=async(e,t,n)=>{let r=uD(t),i=await e.runner.run(`ssh`,hD(t),{timeoutMs:n});return i.timedOut===!0?{host:r,outcome:`timeout`}:fD.test(i.stderr)?{host:r,outcome:`denied`}:pD.some(e=>e.test(i.stderr))?{detail:i.stderr.trim(),host:r,outcome:`connection-warn`}:{host:r,outcome:`ok`}},_D=(e,t)=>{let n=e.filter(e=>e.outcome===`timeout`).map(e=>e.host);if(n.length!==0)return{detail:`ssh probe timed out after ${t/1e3}s: ${n.join(`, `)}`,name:`ssh-auth`,status:`fail`}},vD=e=>{let t=e.filter(e=>e.outcome===`denied`).map(e=>e.host);if(t.length!==0)return{detail:`ssh permission denied for: ${t.join(`, `)}`,name:`ssh-auth`,status:`fail`}},yD=e=>{let t=e.filter(e=>e.outcome===`connection-warn`);if(t.length!==0)return{detail:`ssh connection issue, treated as warn: ${t.map(e=>`${e.host} (${e.detail??``})`).join(`; `)}`,name:`ssh-auth`,status:`warn`}},bD=e=>({detail:`ssh auth ok for: ${e.map(e=>e.host).join(`, `)}`,name:`ssh-auth`,status:`ok`}),xD=(e,t)=>_D(e,t)??vD(e)??yD(e)??bD(e),SD=async(e,t,n)=>{let r=dD(t);if(r.length===0)return;let i=n?.timeoutMs??1e4,a=await Promise.all(r.map(t=>gD(e,t,i)));return xD(a,i)},CD=async e=>{try{return await e.run()}catch(t){return{detail:`check crashed: ${hS(t)}`,name:e.name,status:`fail`}}},wD={"cli-update":`Checking for a newer refs release`,config:`Checking the config`,"config-drift":`Comparing registered packages with the checkouts`,"dirty-checkouts":`Looking for local changes in checkouts`,git:`Checking Git`,"git-exec-surfaces":`Checking what Git is configured to run`,"hooks-guard":`Checking the checkout protection hooks`,locks:`Checking locks`,node:`Checking Node.js`,orphans:`Looking for orphaned checkouts`,skill:`Checking the installed skill`,"ssh-auth":`Checking SSH authentication`},TD=async(e,t)=>{let[n,...r]=e;if(n===void 0)return[];t.update(wD[n.name]??`Running the ${n.name} check`);let i=await CD(n),a=await TD(r,t);return i===void 0?a:[i,...a]},ED=e=>{let{configLoad:t,ctx:n,home:r,state:i}=e,a={};return[{name:`git`,run:async()=>{let e=await Tw(n);return e.status===`ok`&&(a.versionLine=e.detail),e}},{name:`git-exec-surfaces`,run:()=>zC(n,r.root,a.versionLine)},{name:`node`,run:()=>Promise.resolve(kw(n))},{name:`config`,run:()=>Promise.resolve(Mw(t.errorMessage))},{name:`home-modes`,run:()=>hE(r)},{name:`hooks-guard`,run:()=>Jw(n,r,t.config)},{name:`dirty-checkouts`,run:()=>Zw(n,r,t.config)},{name:`config-drift`,run:()=>sE(r,t.config)},{name:`orphans`,run:()=>iT(r,t.config,i)},{name:`locks`,run:()=>CE(r)},{name:`skill`,run:()=>rD(n)},{name:`cli-update`,run:()=>Fw(n,t.config)},{name:`ssh-auth`,run:()=>SD(n,t.config)}]},DD=async(e,t)=>{t.update(`Reading config and state`);let n=U(e.env),r=await jw(n),i=await Qw(n);return TD(ED({configLoad:r,ctx:e,home:n,state:i}),t)},OD={fail:`FAIL`,ok:`OK`,warn:`WARN`},kD=e=>e.map(e=>`[${OD[e.status]}] ${e.name}: ${e.detail}`),AD=e=>e.some(e=>e.status===`fail`),jD=(e,t)=>{e.command(`doctor`).description(`Run environment/integrity checks (git, node, config, hooks, checkouts, drift, locks, ssh).`).action((e,n)=>{let r=X(n);return Q(t,r,async()=>{let e=await vS(t,r,e=>DD(t,e));Z(t,r,kD(e),{checks:e}),AD(e)&&(process.exitCode=du.UNEXPECTED)})()})},MD=(e,t)=>{let n=e.refs[t];
466
468
  /* v8 ignore next 3 -- per the doc comment above: `matchRefKey`/`routeQuery` only ever produce
467
469
  keys present in `config.refs`, so this guard exists purely for `noUncheckedIndexedAccess`. */
468
- if(n===void 0)throw Error(`internal: matched ref key '${t}' is missing from config.refs`);return n},_D=(e,t)=>{if(!K(e))throw z(`checkout for '${t}' is missing — run: refs sync ${aS(t)}`)},vD=(e,t,n)=>{let{packages:r}=e,i=r!==void 0&&Object.hasOwn(r,n)?r[n]:void 0;if(i===void 0)throw z(`no package '${n}' registered on ref '${t}'`);return i},yD=`never`,bD=(e,t,n)=>e===void 0||n-Date.parse(e)>t,xD=(e,t)=>`${e} ${t}${e===1?``:`s`} ago`,SD=(e,t)=>{if(e===void 0)return yD;let n=t-Date.parse(e);if(Number.isNaN(n))return yD;let r=Math.floor(n/1e3);if(r<60)return`just now`;let i=Math.floor(r/60);if(i<60)return xD(i,`minute`);let a=Math.floor(i/60);if(a<24)return xD(a,`hour`);let o=Math.floor(a/24);return o<365?xD(o,`day`):xD(Math.floor(o/365),`year`)},CD=e=>{let t=SD(e.lastFetchedAt,e.now),n=[`synced: ${t}`];return e.stale&&t!==yD&&n.push(`status: stale`),e.missing&&n.push(`missing: checkout not found — run: refs sync`),n},wD=(e,t,n)=>{let r=e.state.refs[t],i=ll(Uy(`sync_ttl`,n,e.settings)),a=Object.keys(n.packages??{}).toSorted();return{clone_mode:Uy(`clone_mode`,n,e.settings),description:n.description,key:t,...r?.last_fetched_at===void 0?{}:{last_fetched_at:r.last_fetched_at},missing:!K(ku(e.home,sl.parse(t))),...e.includePackages?{packages:a}:{},packages_count:a.length,stale:bD(r?.last_fetched_at,i,e.now)}},TD=e=>{let t={home:e.home,includePackages:e.includePackages,now:e.now,settings:e.config.settings,state:e.state};return Object.entries(e.config.refs).map(([e,n])=>wD(t,e,n)).toSorted((e,t)=>e.key.localeCompare(t.key))},ED=async(e,t,n)=>{let r=U(e.env),i=await H(r),a=await Ky(r);return TD({config:i,home:r,includePackages:t,now:n,state:a})},DD=(e,t)=>[`ref: ${e.key}`,`description: ${e.description}`,...CD({lastFetchedAt:e.last_fetched_at,missing:e.missing,now:t,stale:e.stale})],OD=(e,t)=>e.length===0?[`no refs configured — run: refs add <source>`]:e.reduce((e,n,r)=>(r>0&&e.push(``),e.push(...DD(n,t)),e),[]),kD=e=>e.split(`/`),AD=(e,t)=>{let n=kD(e);if(t.length>n.length)return!1;let r=n.length-t.length;return t.every((e,t)=>e===n[r+t])},jD=(e,t)=>{if(Object.hasOwn(e.refs,t))return sl.parse(t);let n=kD(t),r=Object.keys(e.refs).filter(e=>AD(e,n)).toSorted(),[i]=r;if(i===void 0)throw z(`no ref matches '${t}'`);if(r.length>1)throw B(`'${t}' matches more than one ref: ${r.join(`, `)}`);return sl.parse(i)},MD=(e,t)=>{e.command(`list`).description(`List configured refs with their staleness/missing checkout status.`).option(`--packages`,`include each ref's package names in --json output (off by default)`).action((e,n)=>{let r=X(n);return Q(t,r,async()=>{let n=Date.now(),i=await ED(t,e.packages===!0,n);Z(t,r,OD(i,n),i)})()})},ND=e=>e===void 0?null:e,PD=(e,t)=>e.name===t.name&&e.path===t.path,FD=(e,t)=>{let n=(e.declined_packages??[]).filter(e=>!PD(e,t));if(n.length===0){let{declined_packages:t,...n}=e;return n}return{...e,declined_packages:n}},ID=(e,t)=>`package '${e.name}' at '${e.path}' is already declined on ref '${t}'`,LD=(e,t)=>`package '${e.name}' at '${e.path}' is not declined on ref '${t}' — nothing to undo`,RD=(e,t)=>`package '${e}' is registered on ref '${t}' — declining applies to packages the configuration does not have; unregister it first with --remove`,zD=(e,t,n)=>{if(Object.hasOwn(e.packages??{},t.name))throw V(RD(t.name,n));let r=e.declined_packages??[];if(r.some(e=>PD(e,t)))throw V(ID(t,n));return{...e,declined_packages:[...r,t]}},BD=e=>{if(e.declined)return zD(e.entry,e.record,e.key);if(!(e.entry.declined_packages??[]).some(t=>PD(t,e.record)))throw V(LD(e.record,e.key));return FD(e.entry,e.record)},VD=(e,t)=>{let n=U(e.env);return q(n,`home`,async()=>{let e=await H(n),r=jD(e,t.query),i=gD(e,r),a=Sl.safeParse({name:t.packageName,path:t.path});if(!a.success)throw V(w(a.error));let o=a.data,s=BD({declined:t.declined,entry:i,key:r,record:o});return await Eu(n,{...e,refs:{...e.refs,[r]:s}}),{declined:t.declined,field:`declined_packages`,key:r,new:t.declined?o:null,old:t.declined?null:o}})},HD=`packages`,UD=()=>Object.keys(Cl.shape).toSorted().join(`, `),WD=e=>`unknown package field '${e}' — valid fields: ${UD()}`,GD=e=>Object.hasOwn(Cl.shape,e),KD=(e,t,n)=>{if(!GD(t))throw B(WD(t));let r=e[t],i=Cl.safeParse({...e,[t]:n});if(!i.success)throw V(w(i.error));return{field:t,newValue:i.data[t],oldValue:r,updated:i.data}},qD=async e=>{let t=vD(e.entry,e.key,e.packageName),n=KD(t,e.field,e.value),r={...e.entry,packages:{...e.entry.packages,[e.packageName]:n.updated}};return await Eu(e.home,{...e.config,refs:{...e.config.refs,[e.key]:r}}),{field:n.field,key:e.key,new:ND(n.newValue),old:ND(n.oldValue)}},JD=(e,t)=>`package '${e}' is already registered on ref '${t}' — edit its fields instead`,YD=(e,t)=>{let n=U(e.env);return q(n,`home`,async()=>{let e=await H(n),r=jD(e,t.query),i=gD(e,r);if(Object.hasOwn(i.packages??{},t.packageName))throw V(JD(t.packageName,r));let a=wl.safeParse({...FD(i,{name:t.packageName,path:t.path}),packages:{...i.packages,[t.packageName]:{description:t.description,path:t.path}}});if(!a.success)throw V(w(a.error));return await Eu(n,{...e,refs:{...e.refs,[r]:a.data}}),{created:!0,field:HD,key:r,new:{description:t.description,name:t.packageName,path:t.path},old:null}})},XD=(e,t)=>`package '${e}' is not registered on ref '${t}' — nothing to remove`,ZD=(e,t)=>{let n=U(e.env);return q(n,`home`,async()=>{let e=await H(n),r=jD(e,t.query),i=gD(e,r),a=i.packages??{};if(!Object.hasOwn(a,t.packageName))throw V(XD(t.packageName,r));let{[t.packageName]:o,...s}=a,c=Object.keys(s).length===0?QD(i):{...i,packages:s};return await Eu(n,{...e,refs:{...e.refs,[r]:c}}),{field:HD,key:r,new:null,old:{description:o?.description??``,name:t.packageName,path:o?.path??``},removed:!0}})},QD=e=>{let{packages:t,...n}=e;return n},$D=e=>e.second===void 0&&e.value===void 0,eO=e=>{let{description:t,path:n}=e.create,{packageName:r}=e;if(r===void 0||t===void 0||n===void 0||!$D(e))throw B(`--create registers a new package: it needs --package <name>, --path <path> and --description <text>, and takes no <field> <value> arguments`);return{description:t,packageName:r,path:n}},tO=e=>{let{packageName:t}=e;if(t===void 0||e.create.path!==void 0||!$D(e)||e.create.description!==void 0)throw B(`--remove unregisters a package: it needs --package <name>, and takes no <field> <value> arguments, no --path and no --description`);return{packageName:t}},nO=e=>{let{packageName:t}=e,{path:n}=e.create;if(t===void 0||n===void 0||!$D(e)||e.create.description!==void 0)throw B(`--decline and --undecline record a decision about one package at one path: each needs --package <name> and --path <path>, and takes no <field> <value> arguments and no --description`);return{packageName:t,path:n}},rO=[`create`,`remove`,`decline`,`undecline`],iO=e=>{let t=rO.filter(t=>e[t]===!0);if(t.length>1)throw B(`use one of --create, --remove, --decline or --undecline: they are different answers about the same package, and running two at once would guess which one was meant`);return t[0]},aO=(e,t,n)=>t===`create`?YD(e,{...eO(n),query:n.first}):t===`remove`?ZD(e,{...tO(n),query:n.first}):VD(e,{...nO(n),declined:t===`decline`,query:n.first}),oO=`packages`,sO=()=>Object.keys(wl.shape).filter(e=>e!==oO).toSorted().join(`, `),cO=e=>`unknown ref field '${e}' — valid fields: ${sO()}`,lO=e=>Object.hasOwn(wl.shape,e),uO=(e,t,n)=>`failed to rewrite git remote at ${e} to '${G(t)}': ${n.trim()}`,dO=async(e,t)=>{if(Pu(t.home,t.dest),!K(t.dest))return;let n=await e.runner.run(`git`,[`remote`,`set-url`,`--`,`origin`,t.cloneUrl],{cwd:t.dest});if(n.exitCode!==0)throw V(uO(t.dest,t.cloneUrl,n.stderr))},fO=async(e,t)=>{let n=yh(t.value,{allowFileUrls:kS(e.env)});if(n.key!==t.key)throw V(`new url derives a different key — remove and re-add instead`);let r=ku(t.home,t.key);return await dO(e,{cloneUrl:n.cloneUrl,dest:r,home:t.home}),{...t.entry,url:n.cloneUrl}},pO=(e,t,n)=>{if(t===`default_branch`&&!Ce(n))throw V(`'${n}' is not a name git accepts for a branch, so refs could not synchronise this ref`);let r={...e,[t]:n},i=wl.safeParse(r);if(!i.success)throw V(w(i.error));return i.data},mO=(e,t)=>t.field===`url`?fO(e,{entry:t.entry,home:t.home,key:t.key,value:t.value}):Promise.resolve(pO(t.entry,t.field,t.value)),hO=async(e,t)=>{let{field:n}=t;if(n===oO)throw B(`use --package <name> <field> <value>`);if(!lO(n))throw B(cO(n));let r=t.entry[n],i=await mO(e,{entry:t.entry,field:n,home:t.home,key:t.key,value:t.value});return{new:i[n],old:r,updated:i}},gO=(e,t)=>{let n=U(e.env),{field:r,opts:i,query:a,value:o}=t;return q(n,`home`,async()=>{let t=await H(n),s=jD(t,a),c=gD(t,s);if(i.packageName!==void 0)return qD({config:t,entry:c,field:r,home:n,key:s,packageName:i.packageName,value:o});let l=await hO(e,{entry:c,field:r,home:n,key:s,value:o});return await Eu(n,{...t,refs:{...t.refs,[s]:l.updated}}),{field:r,key:s,new:ND(l.new),old:ND(l.old)}})},_O=`settings`,vO=[],yO=()=>Object.keys(bl.shape).toSorted().join(`, `),bO=e=>`unknown setting '${e}' — valid settings: ${yO()}`,xO=e=>Object.hasOwn(bl.shape,e),SO=e=>`note: 'settings' addressed the global settings, not ${e} — use the full ref key to edit that ref`,CO=e=>{try{let t=jD(e,_O);return[SO(`ref '${t}'`)]}catch(e){if(e instanceof R&&e.code===`usage`)return[SO("one of several matching refs — see `refs list`")];if(e instanceof R&&e.code===`not_found`)return vO;throw e}},wO=e=>({data:{field:e.key,key:_O,new:ND(e.parsed[e.key]),old:ND(e.old)},warnings:CO(e.config)}),TO=(e,t)=>{let n=U(e.env);return q(n,`home`,async()=>{let e=await H(n);if(!xO(t.key))throw B(bO(t.key));let r=e.settings[t.key],i={...e.settings,[t.key]:t.value},a=bl.safeParse(i);if(!a.success)throw V(w(a.error));return await Eu(n,{...e,settings:a.data}),wO({config:e,key:t.key,old:r,parsed:a.data})})},EO=[],DO=e=>{let t={};return e.package!==void 0&&(t.packageName=e.package),t},OO=e=>{if(e.second===void 0||e.value===void 0)throw B(`missing <field> and <value> — see 'refs edit --help'`);return{field:e.second,value:e.value}},kO=(e,t,n)=>{if(t.opts.packageName!==void 0)throw B(`--package is not valid with 'refs edit settings ...' — it only applies to ref/package edits`);return TO(e,n)},AO=async(e,t)=>{if(t.create.description!==void 0||t.create.path!==void 0)throw B(`--path and --description only apply to the package modes — to change one field of a registered package use: refs edit <ref> <field> <value> --package <name>`);let{field:n,value:r}=OO(t);return t.first===`settings`?kO(e,t,{key:n,value:r}):{data:await gO(e,{field:n,opts:t.opts,query:t.first,value:r}),warnings:EO}},jO=async(e,t)=>{let n=iO(t.create);return n===void 0?AO(e,t):{data:await aO(e,n,{create:t.create,first:t.first,packageName:t.opts.packageName,second:t.second,value:t.value}),warnings:EO}},MO=e=>e==null?`(unset)`:String(e),NO=(e,t)=>{let n=t?e.new:e.old,r=t?`declined`:`no longer declining`;return`${e.key}: ${r} '${n.name}' at ${n.path}`},PO=e=>{if(e.created===!0){let t=e.new;return`${e.key}: registered '${t.name}' at ${t.path}`}if(e.removed===!0){let t=e.old;return`${e.key}: unregistered '${t.name}' (was at ${t.path})`}return e.declined===void 0?void 0:NO(e,e.declined)},FO=e=>{let t=PO(e);return t===void 0?[`${e.key}: ${e.field} '${MO(e.old)}' -> '${MO(e.new)}'`]:[t]},IO=(e,t)=>{e.command(`edit`).description(`Edit one field: 'refs edit settings <key> <value>' for a global setting, or 'refs edit <ref> <field> <value> [--package <name>]' for a ref or package field. With --create, registers a package the config does not have yet; with --remove, unregisters one it has; with --decline, records that a package the checkout declares is deliberately not registered, so drift stops reporting it.`).argument(`<ref-or-settings>`,`a ref key/unique suffix, or the literal 'settings'`).argument(`[field-or-key]`,`field to edit (or, in settings mode, the setting key)`).argument(`[value]`,`the new value`).option(`--package <name>`,`edit this package's field instead of a top-level ref field`).option(`--create`,`register --package as a new package on this ref`).option(`--remove`,`unregister --package from this ref, leaving the checkout alone`).option(`--decline`,`record that --package at --path is deliberately not registered`).option(`--undecline`,`withdraw a decline, so the package is reported again`).option(`--path <path>`,`with --create/--decline/--undecline: the package path, relative to the checkout root`).option(`--description <text>`,`with --create: what the package is`).action((e,n,r,i,a)=>{let o=X(a);return Q(t,o,async()=>{let{data:a,warnings:s}=await jO(t,{create:i,first:e,opts:DO(i),second:n,value:r});Z(t,o,FO(a),a,s)})()})},LO=`Install the agent skill: npx skills add kaisers-io/refs (from a local clone: npx skills add <path-to-this-repo> --skill refs)`,RO={migrated:`migrated`,noop:`unchanged`,seeded:`seeded`},zO=async e=>{await a(e,{mode:448,recursive:!0}),(await i(e)).isSymbolicLink()||await t(e,448)},BO=async e=>{try{await t(e,384)}catch(e){if(!L(e))throw e}},VO=async e=>{for(let t of[e.root,e.sourcesDir,e.locksDir,e.hooksDir])await zO(t);await Promise.all([BO(e.configPath),BO(e.statePath)])},HO=async e=>{let t=U(e.env);return await VO(t),{config:await q(t,`home`,async()=>{let e=await Hu(t,Ox);return await pm(t),e}),home:t.root,skill_hint:LO}},UO=(e,t)=>{e.command(`init`).description(`Seed or migrate the refs home directory, its config, and the git hooks guard.`).action((e,n)=>{let r=X(n);return Q(t,r,async()=>{let e=await HO(t);Z(t,r,[`home: ${e.home}`,`config: ${RO[e.config]}`,``,LO],e)})()})},WO=async e=>{let t=U(e.env),n=await q(t,`home`,()=>Hu(t,Ox));return n===`migrated`?{backup:Au(t),result:n}:{backup:null,result:n}},GO=e=>e.result===`migrated`&&e.backup!==null?`config migrated (backup: ${ie(e.backup)})`:e.result===`seeded`?`config seeded`:`config up to date`,KO=(e,t)=>{e.command(`migrate`).description(`Migrate the refs config to the current schema, seeding it if absent.`).action((e,n)=>{let r=X(n);return Q(t,r,async()=>{let e=await WO(t);Z(t,r,GO(e),e)})()})},qO=async e=>{try{return await i(e),!0}catch(e){if(L(e))return!1;throw e}},JO=async e=>{try{return await c(e)}catch(e){if(L(e))return;throw e}},YO=async e=>{try{return(await i(e)).isDirectory()}catch(e){if(L(e))return;throw e}},XO=/* @__PURE__ */ new Set([`EEXIST`,`ENOTEMPTY`]),ZO=async e=>{try{return await f(e),!0}catch(e){if(L(e))return!0;if(XO.has(uu(e)))return!1;throw e}},QO=async e=>{let t=await JO(e);return t===void 0?!0:t.length>0?!1:ZO(e)},$O=async e=>{let t=await YO(e);return t===void 0?!0:t?QO(e):!1},ek=async(e,t)=>{t!==e.sourcesDir&&await $O(t)&&await ek(e,_(t))},tk=async(e,t)=>await qO(t)?(Pu(e,t),await d(t,{force:!0,recursive:!0}),await ek(e,_(t)),{removedCheckout:!0}):{removedCheckout:!1,warning:`checkout was already missing`},nk=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),rk=async(e,t)=>{let n=await H(e),r={...n,refs:nk(n.refs,t)};await Eu(e,r);let i=await Ky(e),a={...i,refs:nk(i.refs,t)};await qy(e,a)},ik=async(e,t)=>{let n=U(e.env),r=await H(n),i=jD(r,t),a=ku(n,i),{removedCheckout:o,warning:s}=await q(n,OS(i),()=>tk(n,a));return await q(n,`home`,()=>rk(n,i)),{data:{key:i,removed_checkout:o},warnings:Qx(s)}},ak=e=>e.removed_checkout?[`removed ${e.key} (checkout deleted)`]:[`removed ${e.key} (checkout was already missing)`],ok=(e,t)=>{e.command(`remove`).description(`Remove a configured ref: its config/state entry AND its checkout directory.`).argument(`<ref>`,`full ref key or a unique suffix, e.g. zod`).action((e,n,r)=>{let i=X(r);return Q(t,i,async()=>{let{data:n,warnings:r}=await ik(t,e);Z(t,i,ak(n),n,r)})()})},sk=async e=>{let t=await Cy(e.checkoutDir,e.configuredPath,e.packageName);return t.kind===`match`?{path:e.configuredPath,status:`verified`}:t.kind===`unreadable`?{path:e.configuredPath,reason:t.reason,status:`unverifiable`}:ck(e)},ck=async e=>AT(e,await mx(e.checkoutDir)),lk=async e=>{try{return await q(e.home,OS(e.key),()=>sk(e),e.lockTimeoutMs===void 0?void 0:{timeoutMs:e.lockTimeoutMs})}catch(t){if(t instanceof R&&t.code===`conflict`)return{path:e.configuredPath,reason:`could not acquire the ref lock in time`,status:`unverifiable`};throw t}},uk=async e=>{if(!K(e.checkoutDir))return{path:e.configuredPath,status:`unmaterialized`};let t=await Cy(e.checkoutDir,e.configuredPath,e.packageName);return t.kind===`match`?{path:e.configuredPath,status:`verified`}:t.kind===`unreadable`?{path:e.configuredPath,reason:t.reason,status:`unverifiable`}:(e.onProbed?.(),lk(e))},dk=(e,t)=>({local_path:null,name:e,path:null,reason:t,status:`unverifiable`}),fk=async e=>{if(!e.checkoutManaged)return dk(e.packageName,e.checkoutReason);let t=await uk(e),n=(t.status===`verified`||t.status===`relocated`)&&t.path!==null?await Ly(v(e.checkoutDir,t.path),e.packageName):void 0;return{...t.candidates===void 0?{}:{candidates:t.candidates},...t.configuredPath===void 0?{}:{configured_path:t.configuredPath},...n===void 0?{}:{entry_points:n},local_path:t.path===null?null:v(e.checkoutDir,t.path),name:e.packageName,path:t.path,...t.reason===void 0?{}:{reason:t.reason},status:t.status}},pk=e=>e.kind===`target`?[{observed:e.observed,target:e.target}]:e.kind===`alternatives`?e.alternatives.flatMap(e=>pk(e)):e.kind===`conditions`?e.branches.flatMap(e=>pk(e.value)):[],mk=e=>{if(e.length===0)return[];let t=e.filter(e=>e.observed===`not_checked`||e.observed===`unverifiable`).length,n=e.length-t,r=t===0?``:`, ${t} not inspected`;return n===0?[`entry points: none of the ${e.length} declared target(s) was inspected`]:[`entry points: ${n} declared target(s) absent here${r}`]},hk=e=>{if(e.status!==`complete`)return[`entry points: could not be read (${e.reason??`unknown`})`];let t=e.entries.flatMap(e=>pk(e.value)),n=t.filter(e=>e.observed===`file`||e.observed===`directory`);if(n.length===0)return mk(t);let r=n.slice(0,3).map(e=>e.target),i=n.length-r.length;return[`entry points present: ${r.join(`, `)}${i===0?``:` (+${i} more)`}`]},gk=e=>[`package: ${e.name}`,`package path: ${e.local_path??`(unknown)`}`,...e.status===`verified`?[]:[`package status: ${e.status}`],...e.configured_path===void 0?[]:[`configured path: ${e.configured_path}`],...e.candidates===void 0?[]:[`candidates: ${e.candidates.join(`, `)}`],...e.reason===void 0?[]:[`reason: ${e.reason}`],...e.entry_points===void 0?[]:hk(e.entry_points)],_k=`node_modules`,vk=[`.pnp.cjs`,`.pnp.js`],yk=e=>!ae(e)&&e.split(`/`).every(e=>ol(e)),bk=function*(e){let t=le(e);for(;;){ie(t)!==_k&&(yield v(t,_k));let e=_(t);if(e===t)return;t=e}},xk=async e=>{if(await wk(e)!==`absent`)try{let t=JSON.parse(await s(e,`utf8`)),{name:n,version:r}=typeof t==`object`&&t?t:{};return typeof r!=`string`||r===``?{package_json:e,reason:`manifest_has_no_version`,status:`unverifiable`}:{...typeof n==`string`?{name:n}:{},package_json:e,status:`found`,version:r}}catch{return{package_json:e,reason:`manifest_unreadable`,status:`unverifiable`}}},Sk=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),Ck=async e=>{try{return(await c(e)).length===0}catch{return!1}},wk=async e=>{try{return await p(e),`present`}catch(e){let t=typeof e==`object`&&e&&`code`in e&&typeof e.code==`string`?e.code:void 0;return t!==void 0&&Sk.has(t)?`absent`:`unreadable`}},Tk=async e=>{for(let t of bk(e)){let e=_(t);if((await Promise.all(vk.map(t=>wk(v(e,t))))).includes(`present`))return!0}return!1},Ek=async e=>{try{return await p(e)}catch(t){if(L(t))return;throw B(`--project could not be read: ${e} (${uu(t)??`unknown`})`)}},Dk=async e=>{let t=await Ek(e);if(t===void 0)throw B(`--project path does not exist: ${e}`);if(!t.isDirectory())throw B(`--project must be a directory: ${e}`)},Ok=async e=>{let t=await wk(e);if(t===`unreadable`)return{reason:`slot_unreadable`,status:`unverifiable`};if(t===`absent`)return;let n=await xk(v(e,`package.json`));return n===void 0?await Ck(e)?void 0:{reason:`installed_without_manifest`,status:`unverifiable`}:n},kk=async(e,t)=>{if(!yk(t))return{reason:`unsupported_package_name`,status:`unverifiable`};for(let n of bk(e)){let e=await Ok(v(n,...t.split(`/`)));if(e!==void 0)return e}return await Tk(e)?{reason:`yarn_pnp`,status:`unsupported_layout`}:{status:`not_materialized`}},Ak={'"':`"`,"\\":`\\`,b:`\b`,n:`
469
- `,t:` `},jk={'"':`"`,"\\":`\\`},Mk=/* @__PURE__ */ new Set([` `,` `]),$=Symbol(`malformed git config`),Nk=e=>e!==void 0&&!e.quoted&&Mk.has(e.char),Pk=e=>{let t=0,n=e.length;for(;t<n&&Nk(e[t]);)t+=1;for(;n>t&&Nk(e[n-1]);)--n;return e.slice(t,n).map(e=>e.char).join(``)},Fk=e=>{let t=[],n=!1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i===`\\`){r+=1;let n=Ak[e[r]??``];if(n===void 0)return $;t.push({char:n,quoted:!0})}else if(i===`"`)n=!n;else if(!n&&(i===`#`||i===`;`))return Pk(t);else t.push({char:i??``,quoted:n})}return n?$:Pk(t)},Ik=e=>{let t=``;for(let n=0;n<e.length;n+=1){let r=e[n];if(r===`\\`){n+=1;let r=jk[e[n]??``];if(r===void 0)return $;t+=r}else t+=r??``}return t},Lk=/^[ \t]+|[ \t]+$/gu,Rk=e=>e.replaceAll(Lk,``),zk=/^\[[ \t]*(?<section>[A-Za-z0-9.-]+)[ \t]*(?:"(?<subsection>(?:[^"\\]|\\.)*)")?[ \t]*\]/u,Bk=/^(?<name>[A-Za-z][A-Za-z0-9-]*)[ \t]*(?:=[ \t]*(?<value>.*))?$/u,Vk=function*(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;i+=1){let a=e[i];if(a===`
470
+ if(n===void 0)throw Error(`internal: matched ref key '${t}' is missing from config.refs`);return n},ND=(e,t)=>{if(!K(e))throw mu(`checkout for '${t}' is missing — run: refs sync ${xS(t)}`)},PD=(e,t,n)=>{let{packages:r}=e,i=r!==void 0&&Object.hasOwn(r,n)?r[n]:void 0;if(i===void 0)throw mu(`no package '${n}' registered on ref '${t}'`);return i},FD=`never`,ID=(e,t,n)=>e===void 0||n-Date.parse(e)>t,LD=(e,t)=>`${e} ${t}${e===1?``:`s`} ago`,RD=(e,t)=>{if(e===void 0)return FD;let n=t-Date.parse(e);if(Number.isNaN(n))return FD;let r=Math.floor(n/1e3);if(r<60)return`just now`;let i=Math.floor(r/60);if(i<60)return LD(i,`minute`);let a=Math.floor(i/60);if(a<24)return LD(a,`hour`);let o=Math.floor(a/24);return o<365?LD(o,`day`):LD(Math.floor(o/365),`year`)},zD=e=>{let t=RD(e.lastFetchedAt,e.now),n=[`synced: ${t}`];return e.stale&&t!==FD&&n.push(`status: stale`),e.missing&&n.push(`missing: checkout not found — run: refs sync`),n},BD=(e,t,n)=>{let r=e.state.refs[t],i=sl(ab(`sync_ttl`,n,e.settings)),a=Object.keys(n.packages??{}).toSorted();return{clone_mode:ab(`clone_mode`,n,e.settings),description:n.description,key:t,...r?.last_fetched_at===void 0?{}:{last_fetched_at:r.last_fetched_at},missing:!K(ku(e.home,al.parse(t))),...e.includePackages?{packages:a}:{},packages_count:a.length,stale:ID(r?.last_fetched_at,i,e.now)}},VD=e=>{let t={home:e.home,includePackages:e.includePackages,now:e.now,settings:e.config.settings,state:e.state};return Object.entries(e.config.refs).map(([e,n])=>BD(t,e,n)).toSorted((e,t)=>e.key.localeCompare(t.key))},HD=async(e,t,n)=>{let r=U(e.env),i=await H(r),a=await cb(r);return VD({config:i,home:r,includePackages:t,now:n,state:a})},UD=(e,t)=>[`ref: ${e.key}`,`description: ${e.description}`,...zD({lastFetchedAt:e.last_fetched_at,missing:e.missing,now:t,stale:e.stale})],WD=(e,t)=>e.length===0?[`no refs configured — run: refs add <source>`]:e.reduce((e,n,r)=>(r>0&&e.push(``),e.push(...UD(n,t)),e),[]),GD=e=>e.split(`/`),KD=(e,t)=>{let n=GD(e);if(t.length>n.length)return!1;let r=n.length-t.length;return t.every((e,t)=>e===n[r+t])},qD=(e,t)=>{if(Object.hasOwn(e.refs,t))return al.parse(t);let n=GD(t),r=Object.keys(e.refs).filter(e=>KD(e,n)).toSorted(),[i]=r;if(i===void 0)throw mu(`no ref matches '${t}'`);if(r.length>1)throw B(`'${t}' matches more than one ref: ${r.join(`, `)}`);return al.parse(i)},JD=(e,t)=>{e.command(`list`).description(`List configured refs with their staleness/missing checkout status.`).option(`--packages`,`include each ref's package names in --json output (off by default)`).action((e,n)=>{let r=X(n);return Q(t,r,async()=>{let n=Date.now(),i=await HD(t,e.packages===!0,n);Z(t,r,WD(i,n),i)})()})},YD=e=>e===void 0?null:e,XD=(e,t)=>e.name===t.name&&e.path===t.path,ZD=(e,t)=>{let n=(e.declined_packages??[]).filter(e=>!XD(e,t));if(n.length===0){let{declined_packages:t,...n}=e;return n}return{...e,declined_packages:n}},QD=(e,t)=>`package '${e.name}' at '${e.path}' is already declined on ref '${t}'`,$D=(e,t)=>`package '${e.name}' at '${e.path}' is not declined on ref '${t}' — nothing to undo`,eO=(e,t)=>`package '${e}' is registered on ref '${t}' — declining applies to packages the configuration does not have; unregister it first with --remove`,tO=(e,t,n)=>{if(Object.hasOwn(e.packages??{},t.name))throw V(eO(t.name,n));let r=e.declined_packages??[];if(r.some(e=>XD(e,t)))throw V(QD(t,n));return{...e,declined_packages:[...r,t]}},nO=e=>{if(e.declined)return tO(e.entry,e.record,e.key);if(!(e.entry.declined_packages??[]).some(t=>XD(t,e.record)))throw V($D(e.record,e.key));return ZD(e.entry,e.record)},rO=(e,t)=>{let n=U(e.env);return q(n,`home`,async()=>{let e=await H(n),r=qD(e,t.query),i=MD(e,r),a=bl.safeParse({name:t.packageName,path:t.path});if(!a.success)throw V(T(a.error));let o=a.data,s=nO({declined:t.declined,entry:i,key:r,record:o});return await Eu(n,{...e,refs:{...e.refs,[r]:s}}),{declined:t.declined,field:`declined_packages`,key:r,new:t.declined?o:null,old:t.declined?null:o}})},iO=`packages`,aO=()=>Object.keys(xl.shape).toSorted().join(`, `),oO=e=>`unknown package field '${e}' — valid fields: ${aO()}`,sO=e=>Object.hasOwn(xl.shape,e),cO=(e,t,n)=>{if(!sO(t))throw B(oO(t));let r=e[t],i=xl.safeParse({...e,[t]:n});if(!i.success)throw V(T(i.error));return{field:t,newValue:i.data[t],oldValue:r,updated:i.data}},lO=async e=>{let t=PD(e.entry,e.key,e.packageName),n=cO(t,e.field,e.value),r={...e.entry,packages:{...e.entry.packages,[e.packageName]:n.updated}};return await Eu(e.home,{...e.config,refs:{...e.config.refs,[e.key]:r}}),{field:n.field,key:e.key,new:YD(n.newValue),old:YD(n.oldValue)}},uO=(e,t)=>`package '${e}' is already registered on ref '${t}' — edit its fields instead`,dO=(e,t)=>{let n=U(e.env);return q(n,`home`,async()=>{let e=await H(n),r=qD(e,t.query),i=MD(e,r);if(Object.hasOwn(i.packages??{},t.packageName))throw V(uO(t.packageName,r));let a=Sl.safeParse({...ZD(i,{name:t.packageName,path:t.path}),packages:{...i.packages,[t.packageName]:{description:t.description,path:t.path}}});if(!a.success)throw V(T(a.error));return await Eu(n,{...e,refs:{...e.refs,[r]:a.data}}),{created:!0,field:iO,key:r,new:{description:t.description,name:t.packageName,path:t.path},old:null}})},fO=(e,t)=>`package '${e}' is not registered on ref '${t}' — nothing to remove`,pO=(e,t)=>{let n=U(e.env);return q(n,`home`,async()=>{let e=await H(n),r=qD(e,t.query),i=MD(e,r),a=i.packages??{};if(!Object.hasOwn(a,t.packageName))throw V(fO(t.packageName,r));let{[t.packageName]:o,...s}=a,c=Object.keys(s).length===0?mO(i):{...i,packages:s};return await Eu(n,{...e,refs:{...e.refs,[r]:c}}),{field:iO,key:r,new:null,old:{description:o?.description??``,name:t.packageName,path:o?.path??``},removed:!0}})},mO=e=>{let{packages:t,...n}=e;return n},hO=e=>e.second===void 0&&e.value===void 0,gO=e=>{let{description:t,path:n}=e.create,{packageName:r}=e;if(r===void 0||t===void 0||n===void 0||!hO(e))throw B(`--create registers a new package: it needs --package <name>, --path <path> and --description <text>, and takes no <field> <value> arguments`);return{description:t,packageName:r,path:n}},_O=e=>{let{packageName:t}=e;if(t===void 0||e.create.path!==void 0||!hO(e)||e.create.description!==void 0)throw B(`--remove unregisters a package: it needs --package <name>, and takes no <field> <value> arguments, no --path and no --description`);return{packageName:t}},vO=e=>{let{packageName:t}=e,{path:n}=e.create;if(t===void 0||n===void 0||!hO(e)||e.create.description!==void 0)throw B(`--decline and --undecline record a decision about one package at one path: each needs --package <name> and --path <path>, and takes no <field> <value> arguments and no --description`);return{packageName:t,path:n}},yO=[`create`,`remove`,`decline`,`undecline`],bO=e=>{let t=yO.filter(t=>e[t]===!0);if(t.length>1)throw B(`use one of --create, --remove, --decline or --undecline: they are different answers about the same package, and running two at once would guess which one was meant`);return t[0]},xO=(e,t,n)=>t===`create`?dO(e,{...gO(n),query:n.first}):t===`remove`?pO(e,{..._O(n),query:n.first}):rO(e,{...vO(n),declined:t===`decline`,query:n.first}),SO=`packages`,CO=()=>Object.keys(Sl.shape).filter(e=>e!==SO).toSorted().join(`, `),wO=e=>`unknown ref field '${e}' — valid fields: ${CO()}`,TO=e=>Object.hasOwn(Sl.shape,e),EO=(e,t,n)=>`failed to rewrite git remote at ${e} to '${G(t)}': ${n.trim()}`,DO=async(e,t)=>{if(Pu(t.home,t.dest),!K(t.dest))return;let n=await e.runner.run(`git`,[`remote`,`set-url`,`--`,`origin`,t.cloneUrl],{cwd:t.dest});if(n.exitCode!==0)throw V(EO(t.dest,t.cloneUrl,n.stderr))},OO=async(e,t)=>{let n=yh(t.value,{allowFileUrls:GS(e.env)});if(n.key!==t.key)throw V(`new url derives a different key — remove and re-add instead`);let r=ku(t.home,t.key);return await DO(e,{cloneUrl:n.cloneUrl,dest:r,home:t.home}),{...t.entry,url:n.cloneUrl}},kO=(e,t,n)=>{if(t===`default_branch`&&!Ce(n))throw V(`'${n}' is not a name git accepts for a branch, so refs could not synchronise this ref`);let r={...e,[t]:n},i=Sl.safeParse(r);if(!i.success)throw V(T(i.error));return i.data},AO=(e,t)=>t.field===`url`?OO(e,{entry:t.entry,home:t.home,key:t.key,value:t.value}):Promise.resolve(kO(t.entry,t.field,t.value)),jO=async(e,t)=>{let{field:n}=t;if(n===SO)throw B(`use --package <name> <field> <value>`);if(!TO(n))throw B(wO(n));let r=t.entry[n],i=await AO(e,{entry:t.entry,field:n,home:t.home,key:t.key,value:t.value});return{new:i[n],old:r,updated:i}},MO=(e,t)=>{let n=U(e.env),{field:r,opts:i,query:a,value:o}=t;return q(n,`home`,async()=>{let t=await H(n),s=qD(t,a),c=MD(t,s);if(i.packageName!==void 0)return lO({config:t,entry:c,field:r,home:n,key:s,packageName:i.packageName,value:o});let l=await jO(e,{entry:c,field:r,home:n,key:s,value:o});return await Eu(n,{...t,refs:{...t.refs,[s]:l.updated}}),{field:r,key:s,new:YD(l.new),old:YD(l.old)}})},NO=`settings`,PO=[],FO=()=>Object.keys(vl.shape).toSorted().join(`, `),IO=e=>`unknown setting '${e}' — valid settings: ${FO()}`,LO=e=>Object.hasOwn(vl.shape,e),RO=e=>`note: 'settings' addressed the global settings, not ${e} — use the full ref key to edit that ref`,zO=e=>{try{let t=qD(e,NO);return[RO(`ref '${t}'`)]}catch(e){if(e instanceof fu&&e.code===`usage`)return[RO("one of several matching refs — see `refs list`")];if(e instanceof fu&&e.code===`not_found`)return PO;throw e}},BO=e=>({data:{field:e.key,key:NO,new:YD(e.parsed[e.key]),old:YD(e.old)},warnings:zO(e.config)}),VO=(e,t)=>{let n=U(e.env);return q(n,`home`,async()=>{let e=await H(n);if(!LO(t.key))throw B(IO(t.key));let r=e.settings[t.key],i={...e.settings,[t.key]:t.value},a=vl.safeParse(i);if(!a.success)throw V(T(a.error));return await Eu(n,{...e,settings:a.data}),BO({config:e,key:t.key,old:r,parsed:a.data})})},HO=[],UO=e=>{let t={};return e.package!==void 0&&(t.packageName=e.package),t},WO=e=>{if(e.second===void 0||e.value===void 0)throw B(`missing <field> and <value> — see 'refs edit --help'`);return{field:e.second,value:e.value}},GO=(e,t,n)=>{if(t.opts.packageName!==void 0)throw B(`--package is not valid with 'refs edit settings ...' — it only applies to ref/package edits`);return VO(e,n)},KO=async(e,t)=>{if(t.create.description!==void 0||t.create.path!==void 0)throw B(`--path and --description only apply to the package modes — to change one field of a registered package use: refs edit <ref> <field> <value> --package <name>`);let{field:n,value:r}=WO(t);return t.first===`settings`?GO(e,t,{key:n,value:r}):{data:await MO(e,{field:n,opts:t.opts,query:t.first,value:r}),warnings:HO}},qO=async(e,t)=>{let n=bO(t.create);return n===void 0?KO(e,t):{data:await xO(e,n,{create:t.create,first:t.first,packageName:t.opts.packageName,second:t.second,value:t.value}),warnings:HO}},JO=e=>e==null?`(unset)`:String(e),YO=(e,t)=>{let n=t?e.new:e.old,r=t?`declined`:`no longer declining`;return`${e.key}: ${r} '${n.name}' at ${n.path}`},XO=e=>{if(e.created===!0){let t=e.new;return`${e.key}: registered '${t.name}' at ${t.path}`}if(e.removed===!0){let t=e.old;return`${e.key}: unregistered '${t.name}' (was at ${t.path})`}return e.declined===void 0?void 0:YO(e,e.declined)},ZO=e=>{let t=XO(e);return t===void 0?[`${e.key}: ${e.field} '${JO(e.old)}' -> '${JO(e.new)}'`]:[t]},QO=(e,t)=>{e.command(`edit`).description(`Edit one field: 'refs edit settings <key> <value>' for a global setting, or 'refs edit <ref> <field> <value> [--package <name>]' for a ref or package field. With --create, registers a package the config does not have yet; with --remove, unregisters one it has; with --decline, records that a package the checkout declares is deliberately not registered, so drift stops reporting it.`).argument(`<ref-or-settings>`,`a ref key/unique suffix, or the literal 'settings'`).argument(`[field-or-key]`,`field to edit (or, in settings mode, the setting key)`).argument(`[value]`,`the new value`).option(`--package <name>`,`edit this package's field instead of a top-level ref field`).option(`--create`,`register --package as a new package on this ref`).option(`--remove`,`unregister --package from this ref, leaving the checkout alone`).option(`--decline`,`record that --package at --path is deliberately not registered`).option(`--undecline`,`withdraw a decline, so the package is reported again`).option(`--path <path>`,`with --create/--decline/--undecline: the package path, relative to the checkout root`).option(`--description <text>`,`with --create: what the package is`).action((e,n,r,i,a)=>{let o=X(a);return Q(t,o,async()=>{let{data:a,warnings:s}=await qO(t,{create:i,first:e,opts:UO(i),second:n,value:r});Z(t,o,ZO(a),a,s)})()})},$O=`Install the agent skill: npx skills add kaisers-io/refs (from a local clone: npx skills add <path-to-this-repo> --skill refs)`,ek={migrated:`migrated`,noop:`unchanged`,seeded:`seeded`},tk=async e=>{await a(e,{mode:448,recursive:!0}),(await i(e)).isSymbolicLink()||await t(e,448)},nk=async e=>{try{await t(e,384)}catch(e){if(!z(e))throw e}},rk=async e=>{for(let t of[e.root,e.sourcesDir,e.locksDir,e.hooksDir])await tk(t);await Promise.all([nk(e.configPath),nk(e.statePath)])},ik=async e=>{let t=U(e.env);return await rk(t),{config:await q(t,`home`,async()=>{let e=await Hu(t,Wx);return await pm(t),e}),home:t.root,skill_hint:$O}},ak=(e,t)=>{e.command(`init`).description(`Seed or migrate the refs home directory, its config, and the git hooks guard.`).action((e,n)=>{let r=X(n);return Q(t,r,async()=>{let e=await ik(t);Z(t,r,[`home: ${e.home}`,`config: ${ek[e.config]}`,``,$O],e)})()})},ok=async e=>{let t=U(e.env),n=await q(t,`home`,()=>Hu(t,Wx));return n===`migrated`?{backup:Au(t),result:n}:{backup:null,result:n}},sk=e=>e.result===`migrated`&&e.backup!==null?`config migrated (backup: ${ie(e.backup)})`:e.result===`seeded`?`config seeded`:`config up to date`,ck=(e,t)=>{e.command(`migrate`).description(`Migrate the refs config to the current schema, seeding it if absent.`).action((e,n)=>{let r=X(n);return Q(t,r,async()=>{let e=await ok(t);Z(t,r,sk(e),e)})()})},lk=async e=>{try{return await i(e),!0}catch(e){if(z(e))return!1;throw e}},uk=async e=>{try{return await c(e)}catch(e){if(z(e))return;throw e}},dk=async e=>{try{return(await i(e)).isDirectory()}catch(e){if(z(e))return;throw e}},fk=/* @__PURE__ */ new Set([`EEXIST`,`ENOTEMPTY`]),pk=async e=>{try{return await f(e),!0}catch(e){if(z(e))return!0;if(fk.has(cu(e)))return!1;throw e}},mk=async e=>{let t=await uk(e);return t===void 0?!0:t.length>0?!1:pk(e)},hk=async e=>{let t=await dk(e);return t===void 0?!0:t?mk(e):!1},gk=async(e,t)=>{t!==e.sourcesDir&&await hk(t)&&await gk(e,_(t))},_k=async(e,t)=>await lk(t)?(Pu(e,t),await d(t,{force:!0,recursive:!0}),await gk(e,_(t)),{removedCheckout:!0}):{removedCheckout:!1,warning:`checkout was already missing`},vk=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),yk=async(e,t)=>{let n=await H(e),r={...n,refs:vk(n.refs,t)};await Eu(e,r);let i=await cb(e),a={...i,refs:vk(i.refs,t)};await lb(e,a)},bk=async(e,t)=>{let n=U(e.env),r=await H(n),i=qD(r,t),a=ku(n,i),{removedCheckout:o,warning:s}=await q(n,WS(i),()=>_k(n,a));return await q(n,`home`,()=>yk(n,i)),{data:{key:i,removed_checkout:o},warnings:mS(s)}},xk=e=>e.removed_checkout?[`removed ${e.key} (checkout deleted)`]:[`removed ${e.key} (checkout was already missing)`],Sk=(e,t)=>{e.command(`remove`).description(`Remove a configured ref: its config/state entry AND its checkout directory.`).argument(`<ref>`,`full ref key or a unique suffix, e.g. zod`).action((e,n,r)=>{let i=X(r);return Q(t,i,async()=>{let{data:n,warnings:r}=await bk(t,e);Z(t,i,xk(n),n,r)})()})},Ck=async e=>{let t=await zy(e.checkoutDir,e.configuredPath,e.packageName);return t.kind===`match`?{path:e.configuredPath,status:`verified`}:t.kind===`unreadable`?{path:e.configuredPath,reason:t.reason,status:`unverifiable`}:wk(e)},wk=async e=>KT(e,await Ax(e.checkoutDir)),Tk=async e=>{try{return await q(e.home,WS(e.key),()=>Ck(e),e.lockTimeoutMs===void 0?void 0:{timeoutMs:e.lockTimeoutMs})}catch(t){if(t instanceof fu&&t.code===`conflict`)return{path:e.configuredPath,reason:`could not acquire the ref lock in time`,status:`unverifiable`};throw t}},Ek=async e=>{if(!K(e.checkoutDir))return{path:e.configuredPath,status:`unmaterialized`};let t=await zy(e.checkoutDir,e.configuredPath,e.packageName);return t.kind===`match`?{path:e.configuredPath,status:`verified`}:t.kind===`unreadable`?{path:e.configuredPath,reason:t.reason,status:`unverifiable`}:(e.onProbed?.(),Tk(e))},Dk=(e,t)=>({local_path:null,name:e,path:null,reason:t,status:`unverifiable`}),Ok=async e=>{if(!e.checkoutManaged)return Dk(e.packageName,e.checkoutReason);let t=await Ek(e),n=(t.status===`verified`||t.status===`relocated`)&&t.path!==null?await $y(v(e.checkoutDir,t.path),e.packageName):void 0;return{...t.candidates===void 0?{}:{candidates:t.candidates},...t.configuredPath===void 0?{}:{configured_path:t.configuredPath},...n===void 0?{}:{entry_points:n},local_path:t.path===null?null:v(e.checkoutDir,t.path),name:e.packageName,path:t.path,...t.reason===void 0?{}:{reason:t.reason},status:t.status}},kk=e=>e.kind===`target`?[{observed:e.observed,target:e.target}]:e.kind===`alternatives`?e.alternatives.flatMap(e=>kk(e)):e.kind===`conditions`?e.branches.flatMap(e=>kk(e.value)):[],Ak=e=>{if(e.length===0)return[];let t=e.filter(e=>e.observed===`not_checked`||e.observed===`unverifiable`).length,n=e.length-t,r=t===0?``:`, ${t} not inspected`;return n===0?[`entry points: none of the ${e.length} declared target(s) was inspected`]:[`entry points: ${n} declared target(s) absent here${r}`]},jk=e=>{if(e.status!==`complete`)return[`entry points: could not be read (${e.reason??`unknown`})`];let t=e.entries.flatMap(e=>kk(e.value)),n=t.filter(e=>e.observed===`file`||e.observed===`directory`);if(n.length===0)return Ak(t);let r=n.slice(0,3).map(e=>e.target),i=n.length-r.length;return[`entry points present: ${r.join(`, `)}${i===0?``:` (+${i} more)`}`]},Mk=e=>[`package: ${e.name}`,`package path: ${e.local_path??`(unknown)`}`,...e.status===`verified`?[]:[`package status: ${e.status}`],...e.configured_path===void 0?[]:[`configured path: ${e.configured_path}`],...e.candidates===void 0?[]:[`candidates: ${e.candidates.join(`, `)}`],...e.reason===void 0?[]:[`reason: ${e.reason}`],...e.entry_points===void 0?[]:jk(e.entry_points)],Nk=`node_modules`,Pk=[`.pnp.cjs`,`.pnp.js`],Fk=e=>!ae(e)&&e.split(`/`).every(e=>il(e)),Ik=function*(e){let t=le(e);for(;;){ie(t)!==Nk&&(yield v(t,Nk));let e=_(t);if(e===t)return;t=e}},Lk=async e=>{if(await Bk(e)!==`absent`)try{let t=JSON.parse(await s(e,`utf8`)),{name:n,version:r}=typeof t==`object`&&t?t:{};return typeof r!=`string`||r===``?{package_json:e,reason:`manifest_has_no_version`,status:`unverifiable`}:{...typeof n==`string`?{name:n}:{},package_json:e,status:`found`,version:r}}catch{return{package_json:e,reason:`manifest_unreadable`,status:`unverifiable`}}},Rk=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),zk=async e=>{try{return(await c(e)).length===0}catch{return!1}},Bk=async e=>{try{return await p(e),`present`}catch(e){let t=typeof e==`object`&&e&&`code`in e&&typeof e.code==`string`?e.code:void 0;return t!==void 0&&Rk.has(t)?`absent`:`unreadable`}},Vk=async e=>{for(let t of Ik(e)){let e=_(t);if((await Promise.all(Pk.map(t=>Bk(v(e,t))))).includes(`present`))return!0}return!1},Hk=async e=>{try{return await p(e)}catch(t){if(z(t))return;throw B(`--project could not be read: ${e} (${cu(t)??`unknown`})`)}},Uk=async e=>{let t=await Hk(e);if(t===void 0)throw B(`--project path does not exist: ${e}`);if(!t.isDirectory())throw B(`--project must be a directory: ${e}`)},Wk=async e=>{let t=await Bk(e);if(t===`unreadable`)return{reason:`slot_unreadable`,status:`unverifiable`};if(t===`absent`)return;let n=await Lk(v(e,`package.json`));return n===void 0?await zk(e)?void 0:{reason:`installed_without_manifest`,status:`unverifiable`}:n},Gk=async(e,t)=>{if(!Fk(t))return{reason:`unsupported_package_name`,status:`unverifiable`};for(let n of Ik(e)){let e=await Wk(v(n,...t.split(`/`)));if(e!==void 0)return e}return await Vk(e)?{reason:`yarn_pnp`,status:`unsupported_layout`}:{status:`not_materialized`}},Kk={'"':`"`,"\\":`\\`,b:`\b`,n:`
471
+ `,t:` `},qk={'"':`"`,"\\":`\\`},Jk=/* @__PURE__ */ new Set([` `,` `]),$=Symbol(`malformed git config`),Yk=e=>e!==void 0&&!e.quoted&&Jk.has(e.char),Xk=e=>{let t=0,n=e.length;for(;t<n&&Yk(e[t]);)t+=1;for(;n>t&&Yk(e[n-1]);)--n;return e.slice(t,n).map(e=>e.char).join(``)},Zk=e=>{let t=[],n=!1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i===`\\`){r+=1;let n=Kk[e[r]??``];if(n===void 0)return $;t.push({char:n,quoted:!0})}else if(i===`"`)n=!n;else if(!n&&(i===`#`||i===`;`))return Xk(t);else t.push({char:i??``,quoted:n})}return n?$:Xk(t)},Qk=e=>{let t=``;for(let n=0;n<e.length;n+=1){let r=e[n];if(r===`\\`){n+=1;let r=qk[e[n]??``];if(r===void 0)return $;t+=r}else t+=r??``}return t},$k=/^[ \t]+|[ \t]+$/gu,eA=e=>e.replaceAll($k,``),tA=/^\[[ \t]*(?<section>[A-Za-z0-9.-]+)[ \t]*(?:"(?<subsection>(?:[^"\\]|\\.)*)")?[ \t]*\]/u,nA=/^(?<name>[A-Za-z][A-Za-z0-9-]*)[ \t]*(?:=[ \t]*(?<value>.*))?$/u,rA=function*(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;i+=1){let a=e[i];if(a===`
470
472
  `)yield t,t=``,n=!1,r=!1;else if(a!==`\r`||e[i+1]!==`
471
473
  `){if(r)t+=a;else if(a===`\\`){let n=e[i+1];n===`
472
474
  `||n===`\r`&&e[i+2]===`
473
- `?i+=n===`\r`?2:1:(t+=a+(n??``),i+=1)}else a===`"`?n=!n:n||a!==`#`&&a!==`;`||(r=!0),t+=a}}t!==``&&(yield t)},Hk=(e,t)=>e.subsection===void 0?`${e.name}.${t.toLowerCase()}`:`${e.name}.${e.subsection}.${t.toLowerCase()}`,Uk=(e,t)=>{let n=e.toLowerCase();if(t===void 0)return{name:n};let r=Ik(t);return r===$?$:{name:n,subsection:r}},Wk=e=>{let t=zk.exec(e),n=t?.groups?.section;if(n===void 0)return;let r=Rk(e.slice(t?.[0].length??0)),i=Uk(n,t?.groups?.subsection);return i===$?$:{rest:r,section:i}},Gk=e=>e===``||e.startsWith(`#`)||e.startsWith(`;`),Kk=e=>{let t=Bk.exec(e),n=t?.groups?.name;if(n===void 0)return $;let r=Fk(t?.groups?.value??``);return r===$?$:{name:n,value:r}},qk=(e,t)=>{let n=Kk(t.line);if(n===$)return`malformed`;let r=Hk(t.section,n.name);return t.wanted.includes(r)&&e.set(r,[...e.get(r)??[],n.value]),`ok`},Jk=(e,t,n)=>t.rest===``||Gk(t.rest)?t.section:qk(e,{line:t.rest,section:t.section,wanted:n})===`malformed`?$:t.section,Yk=(e,t)=>{let n=Wk(t.line);return n===$?$:n===void 0?t.section===Xk||qk(e,t)===`malformed`?$:t.section:Jk(e,n,t.wanted)},Xk={name:``},Zk=(e,t)=>{let n=/* @__PURE__ */ new Map,r=Xk;for(let i of Vk(e)){let e=Rk(i),a=Gk(e)?r:Yk(n,{line:e,section:r,wanted:t});if(a===$)return;r=a}return n},Qk=`core.hookspath`,$k=`remote.origin.url`,eA=[Qk,$k],tA={status:`managed`},nA={status:`missing`},rA=e=>({reason:e,status:`unmanaged`}),iA=e=>({reason:e,status:`unverifiable`}),aA=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),oA=e=>typeof e==`object`&&e&&`code`in e&&typeof e.code==`string`?e.code:void 0,sA=async e=>{try{return await i(e),`present`}catch(e){let t=oA(e);return t!==void 0&&aA.has(t)?`absent`:`unreadable`}},cA=async e=>{try{let t=await i(v(e,`.git`));return t.isSymbolicLink()?rA(`git_is_symlink`):t.isDirectory()?void 0:rA(`git_is_file`)}catch(e){let t=oA(e);return t!==void 0&&aA.has(t)?rA(`no_git`):iA(`git_unreadable`)}},lA=(e,t)=>{let n=e.get(t);if(n===void 0||n.length!==1)return;let[r]=n;return r===void 0||r===``?void 0:r},uA=(e,t,n)=>{try{return yh(e,{allowFileUrls:n}).key===yh(t,{allowFileUrls:n}).key}catch{return!1}},dA=e=>(e.get(Qk)?.length??0)>1||(e.get($k)?.length??0)>1,fA=(e,t)=>{let n=Zk(e,eA);return n===void 0?iA(`config_malformed`):dA(n)?iA(`duplicate_config_values`):pA(n,t)},pA=(e,t)=>{if(lA(e,Qk)!==t.hooksDir)return rA(`no_refs_marker`);let n=lA(e,$k);return n===void 0?rA(`no_origin`):uA(n,t.expectedUrl,t.allowFileUrls)?tA:rA(`origin_mismatch`)},mA={missing:nA,outside:rA(`outside_sources`),unreadable:iA(`path_unreadable`)},hA=async e=>{let t=await W(e.sourcesDir,e.dest);if(t.kind!==`inside`)return t.kind===`unreadable`?await sA(e.sourcesDir)===`absent`?nA:mA.unreadable:mA[t.kind]},gA=async e=>{let t=await hA(e);if(t!==void 0)return t;let n=await cA(e.dest);if(n!==void 0)return n;try{return fA(await s(v(e.dest,`.git`,`config`),`utf8`),e)}catch{return iA(`config_unreadable`)}},_A=function*(e){let t=e.split(`/`);for(let e=t.length-1;e>=1;--e)yield t.slice(0,e).join(`/`)},vA=(e,t)=>{let n=Object.hasOwn(e,t)?e[t]:void 0;if(n!==void 0)return{entry:n,name:t};for(let n of _A(t)){let t=Object.hasOwn(e,n)?e[n]:void 0;if(t!==void 0)return{entry:t,name:n}}},yA=e=>`no registered package or ref matches '${e}' — this does not establish that the repository is untracked; it may be registered under a different identifier. Run: refs list --json`,bA=e=>`ref '${e}' is not in the active refs configuration — to track it: refs add <url>`,xA=e=>`--ref '${e}' matched no configured ref — pass a full ref key or a unique suffix of one. Run: refs list --json`,SA=/^[a-z][a-z0-9+.-]*:\/\//iu,CA=/^git@[^:/\s]+:[^\s]+$/u,wA=e=>SA.test(e)||CA.test(e),TA=(e,t)=>{try{return yh(e,t)}catch{if(wA(e))throw V(`query looks like a git url but is not a supported form — check the url (credentials are never accepted) or run: refs resolve <package|ref-suffix>`);return}},EA=(e,t,n)=>{let r=TA(t,n);if(r!==void 0){if(Object.hasOwn(e.refs,r.key))return{key:r.key};throw z(bA(r.key),`ref_not_registered`)}},DA=(e,t)=>{let n=[];for(let r of Object.keys(e.refs).toSorted()){let i=e.refs[r]?.packages,a=i!==void 0&&Object.hasOwn(i,t)?i[t]:void 0;a!==void 0&&n.push({entry:a,key:sl.parse(r)})}return n},OA=(e,t,n)=>`package '${e}' is registered by more than one ref: ${t.join(`, `)} — pick one with: refs resolve ${aS(e)} --ref ${aS(n)}`,kA=(e,t)=>{let n=DA(e,t),[r]=n;if(r!==void 0){if(n.length>1)throw B(OA(t,n.map(e=>e.key),r.key));return r}},AA=(e,t)=>{for(let n of _A(t)){let t=kA(e,n);if(t!==void 0)return{...t,name:n}}},jA=(e,t,n)=>{try{return jD(e,t)}catch(e){throw e instanceof R&&e.code===`not_found`?z(n,`unmatched_query`):e}},MA=(e,t,n)=>{let r=jA(e,n,xA(n)),i=vA(e.refs[r]?.packages??{},t);if(i===void 0)throw z(wA(t)?`ref '${r}' is tracked but registers no package matching that query — inspect: refs show ${aS(r)} --packages --json`:`ref '${r}' is tracked but registers no package matching '${t}' — inspect: refs show ${aS(r)} --packages --json`,`package_not_registered`);return{key:r,packageMatch:{...i,key:r}}},NA=(e,t,n)=>{let r=EA(e,t,n);if(r!==void 0)return r;let i=kA(e,t);if(i!==void 0)return{key:i.key,packageMatch:{...i,name:t}};let a=AA(e,t);return a===void 0?{key:jA(e,t,yA(t))}:{key:a.key,packageMatch:a}},PA=(e,t,n)=>n.ref===void 0?NA(e,t,n):MA(e,t,n.ref),FA=(e,t)=>{let n={head_sha:t.headSha,last_fetched_at:(/* @__PURE__ */ new Date()).toISOString()},r=t.effectiveCloneMode??e?.effective_clone_mode;return r!==void 0&&(n.effective_clone_mode=r),n},IA=async(e,t,n)=>{let r=await H(e),i=r.refs[t];i!==void 0&&(r.refs[t]={...i,default_branch:n},await Eu(e,r))},LA=(e,t,n)=>q(e,`home`,async()=>{n.branchRenamedTo!==void 0&&await IA(e,t,n.branchRenamedTo);let r=await Ky(e);r.refs[t]=FA(r.refs[t],n),await qy(e,r)}),RA=2e3,zA=e=>{if(e.length<=RA)return e;let t=e.slice(0,1500),n=e.slice(e.length-500),r=e.length-RA;return`${t}\n… ${String(r)} characters omitted …\n${n}`},BA=async(e,t,n)=>{try{await q(e,`home`,async()=>{let r=await Ky(e);r.refs[t]={...r.refs[t],last_error:zA(n)},await qy(e,r)})}catch{}},VA=(e,t,n)=>`sync produced a HEAD sha for '${e}' at ${t} that refs cannot store yet (${n.length} hex chars) — only SHA-1 repositories are supported for now`,HA=(e,t,n)=>{if(!Vy.shape.head_sha.safeParse(n).success)throw V(VA(e,t,n));return n},UA=(e,t,n)=>{let r={effectiveCloneMode:t.effectiveMode,headSha:n.headSha,status:`cloned`};return n.actualBranch!==e.ref.default_branch&&(r.branchRenamedTo=n.actualBranch),t.warning!==void 0&&(r.warning=t.warning),r},WA=async(e,t,n)=>{await a(_(n),{recursive:!0});let r=Uy(`clone_mode`,t.ref,t.settings),i=await hm(e.runner,{cloneUrl:t.ref.url,dest:n,hooksDir:t.home.hooksDir,mode:r}),o=await fm(e.runner,n),s=await iC(e.runner,{allowFileUrls:kS(e.env),dest:n,expectedUrl:t.ref.url,hooksDir:t.home.hooksDir,key:t.key});return UA(t,i,{actualBranch:o,headSha:s})},GA=async(e,t,n)=>{await $S(e.runner,{dest:n,hooksDir:t.home.hooksDir}),await ZS(e.runner,{allowFileUrls:kS(e.env),dest:n,expectedUrl:t.ref.url});let r=await xm(e.runner,{defaultBranch:t.ref.default_branch,dir:n,hooksDir:t.home.hooksDir}),i={headSha:HA(t.key,n,r.newSha),previousSha:r.oldSha,status:r.status};return r.branchRenamedTo!==void 0&&(i.branchRenamedTo=r.branchRenamedTo),r.warning!==void 0&&(i.warning=r.warning),i},KA=(e,t,n)=>(Pu(t.home,n),K(n)?GA(e,t,n):WA(e,t,n)),qA={changedDirs:[],kind:`arrivals`,namesBefore:[]},JA=async(e,t,n)=>{if(n.previousSha===void 0)return qA;let r=await Op(e.runner,{dir:t,from:n.previousSha,to:n.headSha});return r===void 0?qA:{...r,kind:`arrivals`}},YA=(e,t)=>q(t.home,OS(t.key),async()=>{let n=ku(t.home,t.key),r=await KA(e,t,n),i=await JA(e,n,r);return{...r,structure:await LT(n,t.ref,i)}}),XA=(e,t)=>`Syncing refs: ${e}/${t} done`,ZA=(e,t)=>{let n=0;return{finished:()=>{n+=1,e.update(XA(n,t))},started:()=>{e.update(XA(n,t))}}},QA=e=>{let t=[];e.branchRenamedTo!==void 0&&t.push(`default branch renamed to ${e.branchRenamedTo}`),e.warning!==void 0&&t.push(e.warning);let[n]=t;if(n!==void 0)return t.join(` | `)},$A=(e,t)=>{let n={key:e,status:t.status},r=QA(t);return r!==void 0&&(n.warning=r),t.structure!==void 0&&(n.structure=t.structure),n},ej=async(e,t)=>{try{let n=await YA(e,t);return await LA(t.home,t.key,n),n}catch(e){throw await BA(t.home,t.key,$x(e)),e}},tj=async(e,t)=>{try{return $A(t.key,await ej(e,t))}catch(e){return{error:$x(e),key:t.key,status:`failed`}}},nj=/^\d+$/u,rj=e=>{let t=e.REFS_SYNC_CONCURRENCY?.trim()??``;return nj.test(t)?Math.min(16,Math.max(1,Number(t))):4},ij=(e,t)=>e.status===`rejected`?{error:$x(e.reason),key:t,status:`failed`}:e.value,aj=async(e,t,n)=>{let r=bw(rj(e.env)),i=n===void 0?void 0:ZA(n,t.length);return(await Promise.allSettled(t.map(t=>xw(r,async()=>{i?.started();try{return await tj(e,t)}finally{i?.finished()}})))).map((e,n)=>{let r=t[n];
475
+ `?i+=n===`\r`?2:1:(t+=a+(n??``),i+=1)}else a===`"`?n=!n:n||a!==`#`&&a!==`;`||(r=!0),t+=a}}t!==``&&(yield t)},iA=(e,t)=>e.subsection===void 0?`${e.name}.${t.toLowerCase()}`:`${e.name}.${e.subsection}.${t.toLowerCase()}`,aA=(e,t)=>{let n=e.toLowerCase();if(t===void 0)return{name:n};let r=Qk(t);return r===$?$:{name:n,subsection:r}},oA=e=>{let t=tA.exec(e),n=t?.groups?.section;if(n===void 0)return;let r=eA(e.slice(t?.[0].length??0)),i=aA(n,t?.groups?.subsection);return i===$?$:{rest:r,section:i}},sA=e=>e===``||e.startsWith(`#`)||e.startsWith(`;`),cA=e=>{let t=nA.exec(e),n=t?.groups?.name;if(n===void 0)return $;let r=Zk(t?.groups?.value??``);return r===$?$:{name:n,value:r}},lA=(e,t)=>{let n=cA(t.line);if(n===$)return`malformed`;let r=iA(t.section,n.name);return t.wanted.includes(r)&&e.set(r,[...e.get(r)??[],n.value]),`ok`},uA=(e,t,n)=>t.rest===``||sA(t.rest)?t.section:lA(e,{line:t.rest,section:t.section,wanted:n})===`malformed`?$:t.section,dA=(e,t)=>{let n=oA(t.line);return n===$?$:n===void 0?t.section===fA||lA(e,t)===`malformed`?$:t.section:uA(e,n,t.wanted)},fA={name:``},pA=(e,t)=>{let n=/* @__PURE__ */ new Map,r=fA;for(let i of rA(e)){let e=eA(i),a=sA(e)?r:dA(n,{line:e,section:r,wanted:t});if(a===$)return;r=a}return n},mA=`core.hookspath`,hA=`remote.origin.url`,gA=[mA,hA],_A={status:`managed`},vA={status:`missing`},yA=e=>({reason:e,status:`unmanaged`}),bA=e=>({reason:e,status:`unverifiable`}),xA=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),SA=e=>typeof e==`object`&&e&&`code`in e&&typeof e.code==`string`?e.code:void 0,CA=async e=>{try{return await i(e),`present`}catch(e){let t=SA(e);return t!==void 0&&xA.has(t)?`absent`:`unreadable`}},wA=async e=>{try{let t=await i(v(e,`.git`));return t.isSymbolicLink()?yA(`git_is_symlink`):t.isDirectory()?void 0:yA(`git_is_file`)}catch(e){let t=SA(e);return t!==void 0&&xA.has(t)?yA(`no_git`):bA(`git_unreadable`)}},TA=(e,t)=>{let n=e.get(t);if(n===void 0||n.length!==1)return;let[r]=n;return r===void 0||r===``?void 0:r},EA=(e,t,n)=>{try{return yh(e,{allowFileUrls:n}).key===yh(t,{allowFileUrls:n}).key}catch{return!1}},DA=e=>(e.get(mA)?.length??0)>1||(e.get(hA)?.length??0)>1,OA=(e,t)=>{let n=pA(e,gA);return n===void 0?bA(`config_malformed`):DA(n)?bA(`duplicate_config_values`):kA(n,t)},kA=(e,t)=>{if(TA(e,mA)!==t.hooksDir)return yA(`no_refs_marker`);let n=TA(e,hA);return n===void 0?yA(`no_origin`):EA(n,t.expectedUrl,t.allowFileUrls)?_A:yA(`origin_mismatch`)},AA={missing:vA,outside:yA(`outside_sources`),unreadable:bA(`path_unreadable`)},jA=async e=>{let t=await W(e.sourcesDir,e.dest);if(t.kind!==`inside`)return t.kind===`unreadable`?await CA(e.sourcesDir)===`absent`?vA:AA.unreadable:AA[t.kind]},MA=async e=>{let t=await jA(e);if(t!==void 0)return t;let n=await wA(e.dest);if(n!==void 0)return n;try{return OA(await s(v(e.dest,`.git`,`config`),`utf8`),e)}catch{return bA(`config_unreadable`)}},NA=function*(e){let t=e.split(`/`);for(let e=t.length-1;e>=1;--e)yield t.slice(0,e).join(`/`)},PA=(e,t)=>{let n=Object.hasOwn(e,t)?e[t]:void 0;if(n!==void 0)return{entry:n,name:t};for(let n of NA(t)){let t=Object.hasOwn(e,n)?e[n]:void 0;if(t!==void 0)return{entry:t,name:n}}},FA=e=>`no registered package or ref matches '${e}' — this does not establish that the repository is untracked; it may be registered under a different identifier. Run: refs list --json`,IA=e=>`ref '${e}' is not in the active refs configuration — to track it: refs add <url>`,LA=e=>`--ref '${e}' matched no configured ref — pass a full ref key or a unique suffix of one. Run: refs list --json`,RA=/^[a-z][a-z0-9+.-]*:\/\//iu,zA=/^git@[^:/\s]+:[^\s]+$/u,BA=e=>RA.test(e)||zA.test(e),VA=(e,t)=>{try{return yh(e,t)}catch{if(BA(e))throw V(`query looks like a git url but is not a supported form — check the url (credentials are never accepted) or run: refs resolve <package|ref-suffix>`);return}},HA=(e,t,n)=>{let r=VA(t,n);if(r!==void 0){if(Object.hasOwn(e.refs,r.key))return{key:r.key};throw mu(IA(r.key),`ref_not_registered`)}},UA=(e,t)=>{let n=[];for(let r of Object.keys(e.refs).toSorted()){let i=e.refs[r]?.packages,a=i!==void 0&&Object.hasOwn(i,t)?i[t]:void 0;a!==void 0&&n.push({entry:a,key:al.parse(r)})}return n},WA=(e,t,n)=>`package '${e}' is registered by more than one ref: ${t.join(`, `)} — pick one with: refs resolve ${xS(e)} --ref ${xS(n)}`,GA=(e,t)=>{let n=UA(e,t),[r]=n;if(r!==void 0){if(n.length>1)throw B(WA(t,n.map(e=>e.key),r.key));return r}},KA=(e,t)=>{for(let n of NA(t)){let t=GA(e,n);if(t!==void 0)return{...t,name:n}}},qA=(e,t,n)=>{try{return qD(e,t)}catch(e){throw e instanceof fu&&e.code===`not_found`?mu(n,`unmatched_query`):e}},JA=(e,t,n)=>{let r=qA(e,n,LA(n)),i=PA(e.refs[r]?.packages??{},t);if(i===void 0)throw mu(BA(t)?`ref '${r}' is tracked but registers no package matching that query — inspect: refs show ${xS(r)} --packages --json`:`ref '${r}' is tracked but registers no package matching '${t}' — inspect: refs show ${xS(r)} --packages --json`,`package_not_registered`);return{key:r,packageMatch:{...i,key:r}}},YA=(e,t,n)=>{let r=HA(e,t,n);if(r!==void 0)return r;let i=GA(e,t);if(i!==void 0)return{key:i.key,packageMatch:{...i,name:t}};let a=KA(e,t);return a===void 0?{key:qA(e,t,FA(t))}:{key:a.key,packageMatch:a}},XA=(e,t,n)=>n.ref===void 0?YA(e,t,n):JA(e,t,n.ref),ZA=(e,t)=>{let n={head_sha:t.headSha,last_fetched_at:(/* @__PURE__ */ new Date()).toISOString()},r=t.effectiveCloneMode??e?.effective_clone_mode;return r!==void 0&&(n.effective_clone_mode=r),n},QA=async(e,t,n)=>{let r=await H(e),i=r.refs[t];i!==void 0&&(r.refs[t]={...i,default_branch:n},await Eu(e,r))},$A=(e,t,n)=>q(e,`home`,async()=>{n.branchRenamedTo!==void 0&&await QA(e,t,n.branchRenamedTo);let r=await cb(e);r.refs[t]=ZA(r.refs[t],n),await lb(e,r)}),ej=2e3,tj=e=>{if(e.length<=ej)return e;let t=e.slice(0,1500),n=e.slice(e.length-500),r=e.length-ej;return`${t}\n… ${String(r)} characters omitted …\n${n}`},nj=async(e,t,n)=>{try{await q(e,`home`,async()=>{let r=await cb(e);r.refs[t]={...r.refs[t],last_error:tj(n)},await lb(e,r)})}catch{}},rj=(e,t,n)=>`sync produced a HEAD sha for '${e}' at ${t} that refs cannot store yet (${n.length} hex chars) — only SHA-1 repositories are supported for now`,ij=(e,t,n)=>{if(!rb.shape.head_sha.safeParse(n).success)throw V(rj(e,t,n));return n},aj=(e,t,n)=>{let r={effectiveCloneMode:t.effectiveMode,headSha:n.headSha,status:`cloned`};return n.actualBranch!==e.ref.default_branch&&(r.branchRenamedTo=n.actualBranch),t.warning!==void 0&&(r.warning=t.warning),r},oj=async(e,t,n)=>{await a(_(n),{recursive:!0});let r=ab(`clone_mode`,t.ref,t.settings),i=await hm(e.runner,{cloneUrl:t.ref.url,dest:n,hooksDir:t.home.hooksDir,mode:r}),o=await fm(e.runner,n),s=await bC(e.runner,{allowFileUrls:GS(e.env),dest:n,expectedUrl:t.ref.url,hooksDir:t.home.hooksDir,key:t.key});return aj(t,i,{actualBranch:o,headSha:s})},sj=async(e,t,n)=>{await hC(e.runner,{dest:n,hooksDir:t.home.hooksDir}),await pC(e.runner,{allowFileUrls:GS(e.env),dest:n,expectedUrl:t.ref.url});let r=await xm(e.runner,{defaultBranch:t.ref.default_branch,dir:n,hooksDir:t.home.hooksDir}),i={headSha:ij(t.key,n,r.newSha),previousSha:r.oldSha,status:r.status};return r.branchRenamedTo!==void 0&&(i.branchRenamedTo=r.branchRenamedTo),r.warning!==void 0&&(i.warning=r.warning),i},cj=(e,t,n)=>(Pu(t.home,n),K(n)?sj(e,t,n):oj(e,t,n)),lj={changedDirs:[],kind:`arrivals`,namesBefore:[]},uj=async(e,t,n)=>{if(n.previousSha===void 0)return lj;let r=await Op(e.runner,{dir:t,from:n.previousSha,to:n.headSha});return r===void 0?lj:{...r,kind:`arrivals`}},dj=(e,t)=>q(t.home,WS(t.key),async()=>{let n=ku(t.home,t.key),r=await cj(e,t,n),i=await uj(e,n,r);return{...r,structure:await $T(n,t.ref,i)}}),fj=(e,t)=>`Syncing refs: ${e}/${t} done`,pj=(e,t)=>{let n=0;return{finished:()=>{n+=1,e.update(fj(n,t))},started:()=>{e.update(fj(n,t))}}},mj=e=>{let t=[];e.branchRenamedTo!==void 0&&t.push(`default branch renamed to ${e.branchRenamedTo}`),e.warning!==void 0&&t.push(e.warning);let[n]=t;if(n!==void 0)return t.join(` | `)},hj=(e,t)=>{let n={key:e,status:t.status},r=mj(t);return r!==void 0&&(n.warning=r),t.structure!==void 0&&(n.structure=t.structure),n},gj=async(e,t)=>{try{let n=await dj(e,t);return await $A(t.home,t.key,n),n}catch(e){throw await nj(t.home,t.key,hS(e)),e}},_j=async(e,t)=>{try{return hj(t.key,await gj(e,t))}catch(e){return{error:hS(e),key:t.key,status:`failed`}}},vj=/^\d+$/u,yj=e=>{let t=e.REFS_SYNC_CONCURRENCY?.trim()??``;return vj.test(t)?Math.min(16,Math.max(1,Number(t))):4},bj=(e,t)=>e.status===`rejected`?{error:hS(e.reason),key:t,status:`failed`}:e.value,xj=async(e,t,n)=>{let r=Iw(yj(e.env)),i=n===void 0?void 0:pj(n,t.length);return(await Promise.allSettled(t.map(t=>Lw(r,async()=>{i?.started();try{return await _j(e,t)}finally{i?.finished()}})))).map((e,n)=>{let r=t[n];
474
476
  /* v8 ignore next 5 -- `settled` is produced by mapping over `targets`, so it is always the
475
477
  same length; this only satisfies `noUncheckedIndexedAccess` and can never actually
476
478
  trigger. */
477
- if(r===void 0)throw Error(`internal: sync target at index ${n} is missing`);return ij(e,r.key)})},oj=async e=>{let{packageMatch:t}=e.match;return t===void 0?null:await fk({checkoutDir:e.dest,checkoutManaged:e.checkout.status===`managed`||e.checkout.status===`missing`,checkoutReason:`checkout is ${e.checkout.status}`,configuredPath:t.entry.path,home:e.home,key:e.match.key,packageName:t.name})},sj=(e,t,n)=>PA(t,n.query,{allowFileUrls:kS(e.env),...n.ref===void 0?{}:{ref:n.ref}}),cj=async(e,t)=>{let n=U(e.env),r=await H(n);return{config:r,home:n,match:sj(e,r,t),state:await Ky(n)}},lj=async(e,t)=>{if(t===void 0)return;let{packageMatch:n}=e;if(n===void 0)throw B(`--project needs a query that names a package; '${e.key}' resolves to the ref itself`);return await kk(t,n.name)},uj=(e,t)=>{if(e.status!==`managed`&&e.status!==`missing`)throw V(`refusing to sync ${t}: its checkout is ${e.status}${e.reason===void 0?``:` (${e.reason})`} — run: refs doctor`)},dj=async(e,t)=>(await ej(e,{home:t.home,key:t.match.key,ref:gD(t.config,t.match.key),settings:t.config.settings})).status,fj=async(e,t)=>{t.project!==void 0&&await Dk(t.project);let n=await cj(e,t),r=await mj(e,n,t);return t.syncIfStale!==!0||!(r.stale||r.missing)?r:(uj(r.checkout,r.key),await pj(e,{key:r.key,opts:t,target:n}))},pj=async(e,t)=>{let{key:n,opts:r}=t,i=await dj(e,t.target),a=await cj(e,r);
479
+ if(r===void 0)throw Error(`internal: sync target at index ${n} is missing`);return bj(e,r.key)})},Sj=async e=>{let{packageMatch:t}=e.match;return t===void 0?null:await Ok({checkoutDir:e.dest,checkoutManaged:e.checkout.status===`managed`||e.checkout.status===`missing`,checkoutReason:`checkout is ${e.checkout.status}`,configuredPath:t.entry.path,home:e.home,key:e.match.key,packageName:t.name})},Cj=(e,t,n)=>XA(t,n.query,{allowFileUrls:GS(e.env),...n.ref===void 0?{}:{ref:n.ref}}),wj=async(e,t)=>{let n=U(e.env),r=await H(n);return{config:r,home:n,match:Cj(e,r,t),state:await cb(n)}},Tj=async(e,t)=>{if(t===void 0)return;let{packageMatch:n}=e;if(n===void 0)throw B(`--project needs a query that names a package; '${e.key}' resolves to the ref itself`);return await Gk(t,n.name)},Ej=(e,t)=>{if(e.status!==`managed`&&e.status!==`missing`)throw V(`refusing to sync ${t}: its checkout is ${e.status}${e.reason===void 0?``:` (${e.reason})`} — run: refs doctor`)},Dj=async(e,t)=>(await gj(e,{home:t.home,key:t.match.key,ref:MD(t.config,t.match.key),settings:t.config.settings})).status,Oj=async(e,t)=>{t.project!==void 0&&await Uk(t.project);let n=await wj(e,t),r=await Aj(e,n,t);return t.syncIfStale!==!0||!(r.stale||r.missing)?r:(Ej(r.checkout,r.key),await kj(e,{key:r.key,opts:t,target:n}))},kj=async(e,t)=>{let{key:n,opts:r}=t,i=await Dj(e,t.target),a=await wj(e,r);
478
480
  /* v8 ignore next 6 -- reachable only under real concurrency: a `refs edit` landing inside the
479
481
  sync window, between the two config reads. Provoking it deterministically would mean injecting
480
482
  a config rewrite into the middle of a real git operation, which is more machinery than the arm
481
483
  is worth; the guard exists so the outcome is a clear conflict rather than a reply describing
482
484
  one ref while carrying another's sync status. */
483
- if(a.match.key!==n)throw mu(`configuration changed while resolving '${r.query}' — retry`);return{...await mj(e,a,r),sync:{status:i}}},mj=async(e,t,n)=>{let{config:r,home:i,match:a,state:o}=t,{now:s}=n,c=gD(r,a.key),l=ku(i,a.key),u=ll(Uy(`sync_ttl`,c,r.settings)),d=o.refs[a.key]?.last_fetched_at,f=await gA({allowFileUrls:kS(e.env),dest:l,expectedUrl:c.url,hooksDir:i.hooksDir,sourcesDir:i.sourcesDir}),p=await lj(a,n.project);return{checkout:f,key:a.key,...d===void 0?{}:{last_fetched_at:d},...p===void 0?{}:{installed:p},local_path:l,missing:f.status===`missing`,package:await oj({checkout:f,dest:l,home:i,match:a}),stale:bD(d,u,s)}},hj=(e,t)=>{let n=[`ref: ${e.key}`,`path: ${e.local_path}`,...CD({lastFetchedAt:e.last_fetched_at,missing:e.missing,now:t,stale:e.stale}),...e.checkout.status===`managed`||e.checkout.status===`missing`?[]:[`checkout: ${e.checkout.status}${e.checkout.reason===void 0?``:` (${e.checkout.reason})`}`]];return e.package!==null&&n.push(...gk(e.package)),e.sync!==void 0&&n.push(`sync: ${e.sync.status}`),e.installed!==void 0&&n.push(`installed: ${e.installed.version??`(${e.installed.status})`}`,...e.installed.name===void 0?[]:[`installed name: ${e.installed.name}`],...e.installed.reason===void 0?[]:[`installed reason: ${e.installed.reason}`]),n},gj=(e,t,n)=>({now:t,...n.project===void 0?{}:{project:n.project},query:e,...n.ref===void 0?{}:{ref:n.ref},...n.syncIfStale===!0?{syncIfStale:!0}:{}}),_j=(e,t)=>{e.command(`resolve`).description(`Resolve a git url, npm package name, import path, or ref-key suffix to its ref/package.`).argument(`<query>`,`git url, npm package name, import path, or unique ref-key suffix`).option(`--ref <ref>`,`resolve the query as a package within this ref (full key or unique suffix)`).option(`--project <dir>`,`report the version this project has installed of the query's package`).option(`--sync-if-stale`,`fetch or clone first when the ref is stale or its checkout is absent`).action((e,n,r)=>{let i=X(r);return Q(t,i,async()=>{let r=Date.now(),a=await fj(t,gj(e,r,n));Z(t,i,hj(a,r),a)})()})},vj={},yj=async(e,t)=>{if(!K(t))return{tags:[]};try{let{tags:n}=await Cm(e.runner,t,5);return{tags:n}}catch(e){return{tags:[],warning:`could not list tags: ${$x(e)}`}}},bj=async(e,t,n,r)=>{let i=U(e.env),a=await H(i),o=jD(a,t),s=gD(a,o),c=await Ky(i),l=ku(i,o),{packages:u,...d}=s,f=n.tags?await yj(e,l):void 0,p=c.refs[o]??vj;return{data:{...d,key:o,local_path:l,missing:!K(l),...n.packages?{packages:u??{}}:{},packages_count:Object.keys(u??{}).length,url:Wp(s.url),...f===void 0?{}:{sample_tags:f.tags},stale:bD(p.last_fetched_at,ll(Uy(`sync_ttl`,s,a.settings)),r),state:p},warnings:Qx(f?.warning)}},xj=(e,t)=>{let n=[`ref: ${e.key}`,`description: ${e.description}`,`url: ${e.url}`,`path: ${e.local_path}`,...CD({lastFetchedAt:e.state.last_fetched_at,missing:e.missing,now:t,stale:e.stale})];return e.sample_tags!==void 0&&e.sample_tags.length>0&&n.push(`tags: ${e.sample_tags.join(`, `)}`),n},Sj=(e,t)=>{e.command(`show`).description(`Show a configured ref: entry, state, local path, package count; --packages/--tags add the package map and sample tags to --json.`).argument(`<ref>`,`full ref key or a unique suffix, e.g. zod`).option(`--packages`,`include the ref's full package map in --json output (off by default)`).option(`--tags`,`include sample tags in --json output (human output always probes for them)`).action((e,n,r)=>{let i=X(r);return Q(t,i,async()=>{let r={packages:n.packages===!0,tags:!i.json||n.tags===!0},a=Date.now(),{data:o,warnings:s}=await bj(t,e,r,a);Z(t,i,xj(o,a),o,s)})()})},Cj=(e,t,n)=>({home:e,key:n,ref:gD(t,n),settings:t.settings}),wj=(e,t,n)=>n.length===0?Object.keys(t.refs).toSorted().map(n=>Cj(e,t,sl.parse(n))):n.map(n=>Cj(e,t,jD(t,n))),Tj=(e,t,n)=>{let r=Date.now();return t.filter(t=>{let i=ll(Uy(`sync_ttl`,t.ref,t.settings)),a=bD(n.refs[t.key]?.last_fetched_at,i,r),o=!K(ku(e,t.key));return a||o})},Ej=async(e,t,n)=>{if(!fb({env:e.env,updates:n.updates}))return[];let{latest:r,refreshed:i}=await ib({fetch:e.fetcher,home:t,nowMs:Date.now()});return!i||r===void 0||!ab(e.cliVersion,r)?[]:[ob(e.cliVersion,r)]},Dj=async(e,t,n)=>{if(!n)return t;let r=await Ky(e);return Tj(e,t,r)},Oj=e=>{let{config:t,ctx:n,home:r,scoped:i,spinner:a}=e;if(i.length===0)return Promise.resolve([[],[]]);let o={pending:!0};return Promise.all([(async()=>{let e=await aj(n,i,a);return o.pending&&a.update(`Checking for a newer refs release`),e})(),(async()=>{try{return await Ej(n,r,t)}finally{o.pending=!1}})()])},kj=async(e,t,n)=>{n.update(`Reading the config`);let r=U(e.env),i=await H(r),a=wj(r,i,t.refs),o=await Dj(r,a,t.staleOnly),[s,c]=await Oj({config:i,ctx:e,home:r,scoped:o,spinner:n});return{failedCount:s.filter(e=>e.status===`failed`).length,results:s,warnings:c}},Aj=[`updated`,`fresh`,`cloned`,`restored`,`failed`],jj={cloned:`Cloned`,failed:`Failed`,fresh:`Fresh`,restored:`Restored`,updated:`Updated`},Mj=e=>{let t={cloned:[],failed:[],fresh:[],restored:[],updated:[]};for(let n of e)t[n.status].push(n);return t},Nj=e=>{if(e.status===`failed`)return[` ${e.key}: ${e.error??`unknown error`}`];let t=e.warning===void 0?` ${e.key}`:` ${e.key} (${e.warning})`;return e.structure===void 0?[t]:[t,...mT(e.structure,e.key).map(e=>` ${e}`)]},Pj=e=>{let t=Mj(e),n=[Aj.map(e=>`${jj[e]} (${t[e].length})`).join(` / `)];for(let e of Aj)for(let r of t[e])n.push(...Nj(r));return n},Fj=(e,t)=>({refs:e,staleOnly:t.staleOnly===!0}),Ij=(e,t)=>{e.command(`sync`).description(`Fetch (or re-clone, if the checkout is missing) configured refs — all by default.`).argument(`[refs...]`,`ref keys or unique suffixes to sync (default: every configured ref)`).option(`--stale-only`,`skip refs whose last sync is still within their ref's sync_ttl`).action((e,n,r)=>{let i=X(r);return Q(t,i,async()=>{let r=await nS(t,i,r=>kj(t,Fj(e,n),r));Z(t,i,Pj(r.results),{results:r.results},r.warnings),r.failedCount>0&&(process.exitCode=pu.UNEXPECTED)})()})},Lj=(e,t,n)=>n===void 0?e.tag_format:vD(e,t,n).tag_format??e.tag_format,Rj=(e,t,n)=>{if(e!==void 0)return e;let r=n===void 0?`ref '${t}'`:`package '${n}'`,i=cS(n===void 0?[]:[[`--package`,n]],[t,`tag_format`,`<format>`]),a=i===void 0?`set one on this entry — no single-line command can carry these values, so none is offered`:`set one with: ${i}`;throw V(`${r} has no tag_format configured — inspect the repository's real tags and ${a}`)},zj=async(e,t)=>{let n=U(e.env),r=await H(n),i=jD(r,t.query),a=gD(r,i),o=Rj(Lj(a,i,t.opts.packageName),i,t.opts.packageName),s=ku(n,i);_D(s,i);let c=await Fm(e.runner,s,o,t.version);return{key:i,ref_path:`refs/tags/${c}`,tag:c,version:t.version}},Bj=e=>[`${e.key}@${e.version} -> ${e.tag}`],Vj=e=>{let t={};return e.package!==void 0&&(t.packageName=e.package),t},Hj=[UO,cw,IO,MD,hD,KO,ok,_j,Sj,Ij,(e,t)=>{e.command(`tag`).description(`Resolve a version to its git tag, via the ref's (or a package's) tag_format.`).argument(`<ref>`,`full ref key or a unique suffix, e.g. zod`).argument(`<version>`,`version to resolve, e.g. 4.1.0`).option(`--package <name>`,`resolve against this package's tag_format instead of the ref's`).action((e,n,r,i)=>{let a=X(i);return Q(t,a,async()=>{let i=await zj(t,{opts:Vj(r),query:e,version:n});Z(t,a,Bj(i),i)})()})}],Uj=(e,t)=>{for(let n of Hj)n(e,t)},Wj=e=>{let t={},n={run:(n,r,i)=>(t.pinned??=kp({run:(...t)=>e.runner.run(...t)},U(e.env).hooksDir),t.pinned.run(n,r,i))};return{...e,runner:n}},Gj=/* @__PURE__ */ new Set([`commander.help`,`commander.helpDisplayed`,`commander.version`]),Kj=`--json`,qj=`--verbose`,Jj=/\n$/u,Yj=/^error: /u,Xj=e=>e.replace(Yj,``),Zj=(e,t)=>{for(let n of e){if(n===`--`)return!1;if(n===t)return!0}return!1},Qj=e=>Zj(e,Kj),$j=e=>Zj(e,qj),eM=(e,t,n)=>n&&t!==void 0?`${e}\n${t}`:e,tM=e=>{let t=new Ux().name(`refs`).description(`Manage git-based reference checkouts shared across a workspace.`).version(Ox).option(Kj,`emit machine-readable JSON on stdout instead of human-readable text`).option(qj,`include stack traces in error output`).allowExcessArguments(!1).exitOverride().configureOutput({outputError:()=>{},writeErr:t=>{e.errLine(t.replace(Jj,``))},writeOut:t=>{e.out(t.replace(Jj,``))}});return t.addHelpText(`after`,`
485
+ if(a.match.key!==n)throw pu(`configuration changed while resolving '${r.query}' — retry`);return{...await Aj(e,a,r),sync:{status:i}}},Aj=async(e,t,n)=>{let{config:r,home:i,match:a,state:o}=t,{now:s}=n,c=MD(r,a.key),l=ku(i,a.key),u=sl(ab(`sync_ttl`,c,r.settings)),d=o.refs[a.key]?.last_fetched_at,f=await MA({allowFileUrls:GS(e.env),dest:l,expectedUrl:c.url,hooksDir:i.hooksDir,sourcesDir:i.sourcesDir}),p=await Tj(a,n.project);return{checkout:f,key:a.key,...d===void 0?{}:{last_fetched_at:d},...p===void 0?{}:{installed:p},local_path:l,missing:f.status===`missing`,package:await Sj({checkout:f,dest:l,home:i,match:a}),stale:ID(d,u,s)}},jj=(e,t)=>{let n=[`ref: ${e.key}`,`path: ${e.local_path}`,...zD({lastFetchedAt:e.last_fetched_at,missing:e.missing,now:t,stale:e.stale}),...e.checkout.status===`managed`||e.checkout.status===`missing`?[]:[`checkout: ${e.checkout.status}${e.checkout.reason===void 0?``:` (${e.checkout.reason})`}`]];return e.package!==null&&n.push(...Mk(e.package)),e.sync!==void 0&&n.push(`sync: ${e.sync.status}`),e.installed!==void 0&&n.push(`installed: ${e.installed.version??`(${e.installed.status})`}`,...e.installed.name===void 0?[]:[`installed name: ${e.installed.name}`],...e.installed.reason===void 0?[]:[`installed reason: ${e.installed.reason}`]),n},Mj=(e,t,n)=>({now:t,...n.project===void 0?{}:{project:n.project},query:e,...n.ref===void 0?{}:{ref:n.ref},...n.syncIfStale===!0?{syncIfStale:!0}:{}}),Nj=(e,t)=>{e.command(`resolve`).description(`Resolve a git url, npm package name, import path, or ref-key suffix to its ref/package.`).argument(`<query>`,`git url, npm package name, import path, or unique ref-key suffix`).option(`--ref <ref>`,`resolve the query as a package within this ref (full key or unique suffix)`).option(`--project <dir>`,`report the version this project has installed of the query's package`).option(`--sync-if-stale`,`fetch or clone first when the ref is stale or its checkout is absent`).action((e,n,r)=>{let i=X(r);return Q(t,i,async()=>{let r=Date.now(),a=await Oj(t,Mj(e,r,n));Z(t,i,jj(a,r),a)})()})},Pj={},Fj=async(e,t)=>{if(!K(t))return{tags:[]};try{let{tags:n}=await Cm(e.runner,t,5);return{tags:n}}catch(e){return{tags:[],warning:`could not list tags: ${hS(e)}`}}},Ij=async(e,t,n,r)=>{let i=U(e.env),a=await H(i),o=qD(a,t),s=MD(a,o),c=await cb(i),l=ku(i,o),{packages:u,...d}=s,f=n.tags?await Fj(e,l):void 0,p=c.refs[o]??Pj;return{data:{...d,key:o,local_path:l,missing:!K(l),...n.packages?{packages:u??{}}:{},packages_count:Object.keys(u??{}).length,url:Wp(s.url),...f===void 0?{}:{sample_tags:f.tags},stale:ID(p.last_fetched_at,sl(ab(`sync_ttl`,s,a.settings)),r),state:p},warnings:mS(f?.warning)}},Lj=(e,t)=>{let n=[`ref: ${e.key}`,`description: ${e.description}`,`url: ${e.url}`,`path: ${e.local_path}`,...zD({lastFetchedAt:e.state.last_fetched_at,missing:e.missing,now:t,stale:e.stale})];return e.sample_tags!==void 0&&e.sample_tags.length>0&&n.push(`tags: ${e.sample_tags.join(`, `)}`),n},Rj=(e,t)=>{e.command(`show`).description(`Show a configured ref: entry, state, local path, package count; --packages/--tags add the package map and sample tags to --json.`).argument(`<ref>`,`full ref key or a unique suffix, e.g. zod`).option(`--packages`,`include the ref's full package map in --json output (off by default)`).option(`--tags`,`include sample tags in --json output (human output always probes for them)`).action((e,n,r)=>{let i=X(r);return Q(t,i,async()=>{let r={packages:n.packages===!0,tags:!i.json||n.tags===!0},a=Date.now(),{data:o,warnings:s}=await Ij(t,e,r,a);Z(t,i,Lj(o,a),o,s)})()})},zj=(e,t,n)=>({home:e,key:n,ref:MD(t,n),settings:t.settings}),Bj=(e,t,n)=>n.length===0?Object.keys(t.refs).toSorted().map(n=>zj(e,t,al.parse(n))):n.map(n=>zj(e,t,qD(t,n))),Vj=(e,t,n)=>{let r=Date.now();return t.filter(t=>{let i=sl(ab(`sync_ttl`,t.ref,t.settings)),a=ID(n.refs[t.key]?.last_fetched_at,i,r),o=!K(ku(e,t.key));return a||o})},Hj=async(e,t,n)=>{if(!Ob({env:e.env,updates:n.updates}))return[];let{latest:r,refreshed:i}=await bb({fetch:e.fetcher,home:t,nowMs:Date.now()});return!i||r===void 0||!xb(e.cliVersion,r)?[]:[Sb(e.cliVersion,r)]},Uj=async(e,t,n)=>{if(!n)return t;let r=await cb(e);return Vj(e,t,r)},Wj=e=>{let{config:t,ctx:n,home:r,scoped:i,spinner:a}=e;if(i.length===0)return Promise.resolve([[],[]]);let o={pending:!0};return Promise.all([(async()=>{let e=await xj(n,i,a);return o.pending&&a.update(`Checking for a newer refs release`),e})(),(async()=>{try{return await Hj(n,r,t)}finally{o.pending=!1}})()])},Gj=async(e,t,n)=>{n.update(`Reading the config`);let r=U(e.env),i=await H(r),a=Bj(r,i,t.refs),o=await Uj(r,a,t.staleOnly),[s,c]=await Wj({config:i,ctx:e,home:r,scoped:o,spinner:n});return{failedCount:s.filter(e=>e.status===`failed`).length,results:s,warnings:c}},Kj=[`updated`,`fresh`,`cloned`,`restored`,`failed`],qj={cloned:`Cloned`,failed:`Failed`,fresh:`Fresh`,restored:`Restored`,updated:`Updated`},Jj=e=>{let t={cloned:[],failed:[],fresh:[],restored:[],updated:[]};for(let n of e)t[n.status].push(n);return t},Yj=e=>{if(e.status===`failed`)return[` ${e.key}: ${e.error??`unknown error`}`];let t=e.warning===void 0?` ${e.key}`:` ${e.key} (${e.warning})`;return e.structure===void 0?[t]:[t,...AT(e.structure,e.key).map(e=>` ${e}`)]},Xj=e=>{let t=Jj(e),n=[Kj.map(e=>`${qj[e]} (${t[e].length})`).join(` / `)];for(let e of Kj)for(let r of t[e])n.push(...Yj(r));return n},Zj=(e,t)=>({refs:e,staleOnly:t.staleOnly===!0}),Qj=(e,t)=>{e.command(`sync`).description(`Fetch (or re-clone, if the checkout is missing) configured refs — all by default.`).argument(`[refs...]`,`ref keys or unique suffixes to sync (default: every configured ref)`).option(`--stale-only`,`skip refs whose last sync is still within their ref's sync_ttl`).action((e,n,r)=>{let i=X(r);return Q(t,i,async()=>{let r=await vS(t,i,r=>Gj(t,Zj(e,n),r));Z(t,i,Xj(r.results),{results:r.results},r.warnings),r.failedCount>0&&(process.exitCode=du.UNEXPECTED)})()})},$j=(e,t,n)=>n===void 0?e.tag_format:PD(e,t,n).tag_format??e.tag_format,eM=(e,t,n)=>{if(e!==void 0)return e;let r=n===void 0?`ref '${t}'`:`package '${n}'`,i=wS(n===void 0?[]:[[`--package`,n]],[t,`tag_format`,`<format>`]),a=i===void 0?`set one on this entry — no single-line command can carry these values, so none is offered`:`set one with: ${i}`;throw V(`${r} has no tag_format configured — inspect the repository's real tags and ${a}`)},tM=async(e,t)=>{let n=U(e.env),r=await H(n),i=qD(r,t.query),a=MD(r,i),o=eM($j(a,i,t.opts.packageName),i,t.opts.packageName),s=ku(n,i);ND(s,i);let c=await Fm(e.runner,s,o,t.version);return{key:i,ref_path:`refs/tags/${c}`,tag:c,version:t.version}},nM=e=>[`${e.key}@${e.version} -> ${e.tag}`],rM=e=>{let t={};return e.package!==void 0&&(t.packageName=e.package),t},iM=[ak,ww,QO,JD,jD,ck,Sk,Nj,Rj,Qj,(e,t)=>{e.command(`tag`).description(`Resolve a version to its git tag, via the ref's (or a package's) tag_format.`).argument(`<ref>`,`full ref key or a unique suffix, e.g. zod`).argument(`<version>`,`version to resolve, e.g. 4.1.0`).option(`--package <name>`,`resolve against this package's tag_format instead of the ref's`).action((e,n,r,i)=>{let a=X(i);return Q(t,a,async()=>{let i=await tM(t,{opts:rM(r),query:e,version:n});Z(t,a,nM(i),i)})()})}],aM=(e,t)=>{for(let n of iM)n(e,t)},oM=e=>{let t={},n={run:(n,r,i)=>(t.pinned??=kp({run:(...t)=>e.runner.run(...t)},U(e.env).hooksDir),t.pinned.run(n,r,i))};return{...e,runner:n}},sM=/* @__PURE__ */ new Set([`commander.help`,`commander.helpDisplayed`,`commander.version`]),cM=`--json`,lM=`--verbose`,uM=/\n$/u,dM=/^error: /u,fM=e=>e.replace(dM,``),pM=(e,t)=>{for(let n of e){if(n===`--`)return!1;if(n===t)return!0}return!1},mM=e=>pM(e,cM),hM=e=>pM(e,lM),gM=(e,t,n)=>n&&t!==void 0?`${e}\n${t}`:e,_M=e=>{let t=new aS().name(`refs`).description(`Manage git-based reference checkouts shared across a workspace.`).version(Wx).option(cM,`emit machine-readable JSON on stdout instead of human-readable text`).option(lM,`include stack traces in error output`).allowExcessArguments(!1).exitOverride().configureOutput({outputError:()=>{},writeErr:t=>{e.errLine(t.replace(uM,``))},writeOut:t=>{e.out(t.replace(uM,``))}});return t.addHelpText(`after`,`
484
486
  Examples:
485
487
  $ refs list --json
486
488
  $ refs sync --stale-only --json
487
489
  $ refs resolve zod/mini --json
488
490
 
489
- Every command accepts --json for structured output and --verbose for stack traces on error.`),Uj(t,Wj(e)),t},nM=()=>{process.exitCode=pu.OK},rM=(e,t,n)=>{let r={code:`usage`,message:eM(Xj(n.message),n.stack,t.verbose)};eS(e,t,r),process.exitCode=pu.USAGE},iM=(e,t,n)=>{Gj.has(n.code)?nM():rM(e,t,n)},aM=(e,t,n)=>{let r=gu(n,{verbose:t.verbose});eS(e,t,r),process.exitCode=r.exitCode},oM=async(e,t,n)=>{let r={json:Qj(n),verbose:$j(n)};try{await t.parseAsync(n)}catch(t){if(t instanceof Mx){iM(e,r,t);return}aM(e,r,t)}},sM=(e,t)=>oM(e,tM(e),t);
491
+ Every command accepts --json for structured output and --verbose for stack traces on error.`),aM(t,oM(e)),t},vM=()=>{process.exitCode=du.OK},yM=(e,t,n)=>{let r={code:`usage`,message:gM(fM(n.message),n.stack,t.verbose)};gS(e,t,r),process.exitCode=du.USAGE},bM=(e,t,n)=>{sM.has(n.code)?vM():yM(e,t,n)},xM=(e,t,n)=>{let r=gu(n,{verbose:t.verbose});gS(e,t,r),process.exitCode=r.exitCode},SM=async(e,t,n)=>{let r={json:mM(n),verbose:hM(n)};try{await t.parseAsync(n)}catch(t){if(t instanceof Jx){bM(e,r,t);return}xM(e,r,t)}},CM=(e,t)=>SM(e,_M(e),t);
490
492
  /* v8 ignore start -- `import.meta.main` is only true when this file IS the process entrypoint;
491
493
  the in-process test runner always imports it as a module, so this branch is exercised solely by
492
494
  the spawned-CLI bin-stub tests, whose subprocess execution v8 coverage cannot observe. */
493
- import.meta.main&&await sM(jx(),process.argv);export{tM as buildProgram,X as cliOptsOf,Yx as displaySafe,Z as emit,eS as emitError,$x as errorMessageOf,tS as progress,jx as realContext,Uj as registerCommands,sM as run,oM as runProgram,Qx as warningsFor,nS as withSpinner,Q as wrapAction};
495
+ import.meta.main&&await CM(qx(),process.argv);export{_M as buildProgram,X as cliOptsOf,dS as displaySafe,Z as emit,gS as emitError,hS as errorMessageOf,_S as progress,qx as realContext,aM as registerCommands,CM as run,SM as runProgram,mS as warningsFor,vS as withSpinner,Q as wrapAction};