@dmgnr/kuber 2.5.2 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/dist/index.js +85 -84
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
`)}function
|
|
5
|
-
`)}catch(r){console.error(r)}}async function
|
|
6
|
-
`)}function
|
|
7
|
-
`);process.exit(1)}}function vc(e){return(t={})=>Eb(e,t)}async function Sb(e){let t=await G(e.args||{}),r=new Set,o=new Set;for(let[n,i]of Object.entries(t)){r.add(n);for(let s of Rt(i.alias))o.add(s)}return{help:bc("help","h",r,o),version:bc("version","v",r,o)}}function bc(e,t,r,o){if(r.has(e)||o.has(e))return[];if(r.has(t)||o.has(t))return[`--${e}`];return[`--${e}`,`-${t}`]}var Ce,gb,Ar=(e,t=39)=>(r)=>gb?r:`\x1B[${e}m${r}\x1B[${t}m`,Er,fe,$r,Sr,vb;var M=_(()=>{gc();Ce=class extends Error{code;constructor(e,t){super(e);this.name="CLIError",this.code=t}};gb=(()=>{let e=globalThis.process?.env??{};return e.NO_COLOR==="1"||e.TERM==="dumb"||e.TEST||e.CI})(),Er=Ar(1,22),fe=Ar(36),$r=Ar(90),Sr=Ar(4,24);vb=/^no[-A-Z]/});function g(e,t,r){function o(a,c){if(!a._zod)Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1});if(a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let u=s.prototype,l=Object.keys(u);for(let f=0;f<l.length;f++){let p=l[f];if(!(p in a))a[p]=u[p].bind(a)}}let n=r?.Parent??Object;class i extends n{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let u=r?.Parent?new i:this;o(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(s,"init",{value:o}),Object.defineProperty(s,Symbol.hasInstance,{value:(a)=>{if(r?.Parent&&a instanceof r.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}function W(e){if(e)Object.assign(at,e);return at}var xc,$b,Re,ct,at;var Qe=_(()=>{$b=Symbol("zod_brand");Re=class Re extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};ct=class ct extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}};(xc=globalThis).__zod_globalConfig??(xc.__zod_globalConfig={});at=globalThis.__zod_globalConfig});function Pr(e){let t=Object.values(e).filter((o)=>typeof o==="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function In(e,t="|"){return e.map((r)=>Nn(r)).join(t)}function Tt(e,t){if(typeof t==="bigint")return t.toString();return t}function Ot(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw Error("cached value already set")}}}function We(e){return e===null||e===void 0}function Cr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Sc(e,t){let r=e/t,o=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-o)<n)return 0;return r-o}function T(e,t,r){let o=void 0;Object.defineProperty(e,t,{get(){if(o===Ec)return;if(o===void 0)o=Ec,o=r();return o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ge(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ze(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function Bn(e){return JSON.stringify(e)}function $c(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function ut(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Ke(e){if(ut(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(ut(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function Dn(e){if(Ke(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}function me(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(e,t,r){let o=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)o._zod.parent=e;return o}function w(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}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Nn(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Pc(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function Ab(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i=ze(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in r.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;s[a]=r.shape[a]}return Ge(this,"shape",s),s},checks:[]});return ce(e,i)}function kb(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=ze(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in r.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;delete s[a]}return Ge(this,"shape",s),s},checks:[]});return ce(e,i)}function Pb(e,t){if(!Ke(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=ze(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Ge(this,"shape",i),i}});return ce(e,n)}function Cb(e,t){if(!Ke(t))throw Error("Invalid input to safeExtend: expected a plain object");let r=ze(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Ge(this,"shape",o),o}});return ce(e,r)}function Rb(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=ze(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t._zod.def.shape};return Ge(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ce(e,r)}function Tb(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let s=ze(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(r)for(let u in r){if(!(u in a))throw Error(`Unrecognized key: "${u}"`);if(!r[u])continue;c[u]=e?new e({type:"optional",innerType:a[u]}):a[u]}else for(let u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return Ge(this,"shape",c),c},checks:[]});return ce(t,s)}function Ob(e,t,r){let o=ze(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(r)for(let s in r){if(!(s in i))throw Error(`Unrecognized key: "${s}"`);if(!r[s])continue;i[s]=new e({type:"nonoptional",innerType:n[s]})}else for(let s in n)i[s]=new e({type:"nonoptional",innerType:n[s]});return Ge(this,"shape",i),i}});return ce(t,o)}function He(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Tc(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function ne(e,t){return t.map((r)=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function kr(e){return typeof e==="string"?e:e?.message}function te(e,t,r){let o=e.message?e.message:kr(e.inst?._zod.def?.error?.(e))??kr(t?.error?.(e))??kr(r.customError?.(e))??kr(r.localeError?.(e))??"Invalid input",{inst:n,continue:i,input:s,...a}=e;if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=s;return a}function Tr(e){if(e instanceof Set)return"set";if(e instanceof Map)return"map";if(e instanceof File)return"file";return"unknown"}function Or(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Oc(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 r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Je(...e){let[t,r,o]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:o};return{...t}}var Ec,zn,Ac,Rr,kc,Cc,Rc;var ue=_(()=>{Qe();Ec=Symbol("evaluating");zn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};Ac=Ot(()=>{if(at.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});Rr=new Set(["string","number","symbol"]),kc=new Set(["string","number","bigint","boolean","symbol","undefined"]);Cc={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Rc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]}});function Ln(e,t=(r)=>r.message){let r={},o=[];for(let n of e.issues)if(n.path.length>0)r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n));else o.push(t(n));return{formErrors:o,fieldErrors:r}}function Vn(e,t=(r)=>r.message){let r={_errors:[]},o=(n,i=[])=>{for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>o({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")o({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")o({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,u=0;while(u<a.length){let l=a[u];if(u!==a.length-1)c[l]=c[l]||{_errors:[]};else c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(s));c=c[l],u++}}}};return o(e),r}function Ib(e){let t=[],r=e.map((o)=>typeof o==="object"?o.key:o);for(let o of r)if(typeof o==="number")t.push(`[${o}]`);else if(typeof o==="symbol")t.push(`[${JSON.stringify(String(o))}]`);else if(/[^\w$]/.test(o))t.push(`[${JSON.stringify(o)}]`);else{if(t.length)t.push(".");t.push(o)}return t.join("")}function Bc(e){let t=[],r=[...e.issues].sort((o,n)=>(o.path??[]).length-(n.path??[]).length);for(let o of r)if(t.push(`\u2716 ${o.message}`),o.path?.length)t.push(` \u2192 at ${Ib(o.path)}`);return t.join(`
|
|
8
|
-
`)}var Ic=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Tt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ir,It;var Un=_(()=>{Qe();ue();Ir=g("$ZodError",Ic),It=g("$ZodError",Ic,{Parent:Error})});var Bt=(e)=>(t,r,o,n)=>{let i=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new Re;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((c)=>te(c,i,W())));throw zn(a,n?.callee),a}return s.value},Fn,zt=(e)=>async(t,r,o,n)=>{let i=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)s=await s;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((c)=>te(c,i,W())));throw zn(a,n?.callee),a}return s.value},Mn,Dt=(e)=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)throw new Re;return i.issues.length?{success:!1,error:new(e??Ir)(i.issues.map((s)=>te(s,n,W())))}:{success:!0,data:i.value}},zc,Nt=(e)=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)i=await i;return i.issues.length?{success:!1,error:new e(i.issues.map((s)=>te(s,n,W())))}:{success:!0,data:i.value}},Dc,Nc=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Bt(e)(t,r,n)},Lc=(e)=>(t,r,o)=>Bt(e)(t,r,o),Vc=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return zt(e)(t,r,n)},Uc=(e)=>async(t,r,o)=>zt(e)(t,r,o),Fc=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Dt(e)(t,r,n)},Mc=(e)=>(t,r,o)=>Dt(e)(t,r,o),jc=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Nt(e)(t,r,n)},Zc=(e)=>async(t,r,o)=>Nt(e)(t,r,o);var jn=_(()=>{Qe();Un();ue();Fn=Bt(It),Mn=zt(It),zc=Dt(It),Dc=Nt(It)});var Xe={};vr(Xe,{base64:()=>ii,base64url:()=>Br,bigint:()=>pi,boolean:()=>fi,browserEmail:()=>Mb,cidrv4:()=>oi,cidrv6:()=>ni,cuid:()=>Zn,cuid2:()=>qn,date:()=>ai,datetime:()=>ui,domain:()=>Wc,duration:()=>Hn,e164:()=>si,email:()=>Yn,emoji:()=>Xn,extendedDuration:()=>zb,guid:()=>Jn,hex:()=>Hc,hostname:()=>Qc,html5Email:()=>Vb,httpProtocol:()=>zr,idnEmail:()=>Fb,integer:()=>di,ipv4:()=>ei,ipv6:()=>ti,ksuid:()=>Gn,lowercase:()=>gi,mac:()=>ri,md5_base64:()=>qb,md5_base64url:()=>Qb,md5_hex:()=>Zb,nanoid:()=>Kn,null:()=>mi,number:()=>Dr,rfc5322Email:()=>Ub,sha1_base64:()=>Gb,sha1_base64url:()=>Kb,sha1_hex:()=>Wb,sha256_base64:()=>Jb,sha256_base64url:()=>Yb,sha256_hex:()=>Hb,sha384_base64:()=>e_,sha384_base64url:()=>t_,sha384_hex:()=>Xb,sha512_base64:()=>o_,sha512_base64url:()=>n_,sha512_hex:()=>r_,string:()=>li,time:()=>ci,ulid:()=>Qn,undefined:()=>hi,unicodeEmail:()=>qc,uppercase:()=>yi,uuid:()=>Ye,uuid4:()=>Db,uuid6:()=>Nb,uuid7:()=>Lb,xid:()=>Wn});function Xn(){return new RegExp(jb,"u")}function Kc(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function ci(e){return new RegExp(`^${Kc(e)}$`)}function ui(e){let t=Kc({precision:e.precision}),r=["Z"];if(e.local)r.push("");if(e.offset)r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let o=`${t}(?:${r.join("|")})`;return new RegExp(`^${Gc}T(?:${o})$`)}function Lt(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Vt(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var Zn,qn,Qn,Wn,Gn,Kn,Hn,zb,Jn,Ye=(e)=>{if(!e)return/^([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)$/;return new 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})$`)},Db,Nb,Lb,Yn,Vb,Ub,qc,Fb,Mb,jb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ei,ti,ri=(e)=>{let t=me(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},oi,ni,ii,Br,Qc,Wc,zr,si,Gc="(?:(?:\\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])))",ai,li=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},pi,di,Dr,fi,mi,hi,gi,yi,Hc,Zb,qb,Qb,Wb,Gb,Kb,Hb,Jb,Yb,Xb,e_,t_,r_,o_,n_;var Nr=_(()=>{ue();Zn=/^[cC][0-9a-z]{6,}$/,qn=/^[0-9a-z]+$/,Qn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Wn=/^[0-9a-vA-V]{20}$/,Gn=/^[A-Za-z0-9]{27}$/,Kn=/^[a-zA-Z0-9_-]{21}$/,Hn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,zb=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Jn=/^([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})$/,Db=Ye(4),Nb=Ye(6),Lb=Ye(7),Yn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Vb=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Ub=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,qc=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Fb=qc,Mb=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;ei=/^(?:(?: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])$/,ti=/^(([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}|:))$/,oi=/^((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])$/,ni=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ii=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Br=/^[A-Za-z0-9_-]*$/,Qc=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Wc=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,zr=/^https?$/,si=/^\+[1-9]\d{6,14}$/,ai=new RegExp(`^${Gc}$`);pi=/^-?\d+n?$/,di=/^-?\d+$/,Dr=/^-?\d+(?:\.\d+)?$/,fi=/^(?:true|false)$/i,mi=/^null$/i,hi=/^undefined$/i,gi=/^[^A-Z]*$/,yi=/^[^a-z]*$/,Hc=/^[0-9a-fA-F]*$/;Zb=/^[0-9a-fA-F]{32}$/,qb=Lt(22,"=="),Qb=Vt(22),Wb=/^[0-9a-fA-F]{40}$/,Gb=Lt(27,"="),Kb=Vt(27),Hb=/^[0-9a-fA-F]{64}$/,Jb=Lt(43,"="),Yb=Vt(43),Xb=/^[0-9a-fA-F]{96}$/,e_=Lt(64,""),t_=Vt(64),r_=/^[0-9a-fA-F]{128}$/,o_=Lt(86,"=="),n_=Vt(86)});function Jc(e,t,r){if(e.issues.length)t.issues.push(...ne(r,e.issues))}var N,Yc,bi,_i,Xc,eu,tu,ru,ou,nu,iu,su,au,Ut,cu,uu,lu,pu,du,fu,mu,hu,gu;var Lr=_(()=>{Qe();Nr();ue();N=g("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Yc={number:"number",bigint:"bigint",object:"date"},bi=g("$ZodCheckLessThan",(e,t)=>{N.init(e,t);let r=Yc[typeof t.value];e._zod.onattach.push((o)=>{let n=o._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<i)if(t.inclusive)n.maximum=t.value;else n.exclusiveMaximum=t.value}),e._zod.check=(o)=>{if(t.inclusive?o.value<=t.value:o.value<t.value)return;o.issues.push({origin:r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_i=g("$ZodCheckGreaterThan",(e,t)=>{N.init(e,t);let r=Yc[typeof t.value];e._zod.onattach.push((o)=>{let n=o._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>i)if(t.inclusive)n.minimum=t.value;else n.exclusiveMinimum=t.value}),e._zod.check=(o)=>{if(t.inclusive?o.value>=t.value:o.value>t.value)return;o.issues.push({origin:r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Xc=g("$ZodCheckMultipleOf",(e,t)=>{N.init(e,t),e._zod.onattach.push((r)=>{var o;(o=r._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?r.value%t.value===BigInt(0):Sc(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),eu=g("$ZodCheckNumberFormat",(e,t)=>{N.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,i]=Cc[t.format];e._zod.onattach.push((s)=>{let a=s._zod.bag;if(a.format=t.format,a.minimum=n,a.maximum=i,r)a.pattern=di}),e._zod.check=(s)=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});else s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}if(a<n)s.issues.push({origin:"number",input:a,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(a>i)s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),tu=g("$ZodCheckBigIntFormat",(e,t)=>{N.init(e,t);let[r,o]=Rc[t.format];e._zod.onattach.push((n)=>{let i=n._zod.bag;i.format=t.format,i.minimum=r,i.maximum=o}),e._zod.check=(n)=>{let i=n.value;if(i<r)n.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(i>o)n.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),ru=g("$ZodCheckMaxSize",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!We(n)&&n.size!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)o._zod.bag.maximum=t.maximum}),e._zod.check=(o)=>{let n=o.value;if(n.size<=t.maximum)return;o.issues.push({origin:Tr(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ou=g("$ZodCheckMinSize",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!We(n)&&n.size!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)o._zod.bag.minimum=t.minimum}),e._zod.check=(o)=>{let n=o.value;if(n.size>=t.minimum)return;o.issues.push({origin:Tr(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),nu=g("$ZodCheckSizeEquals",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!We(n)&&n.size!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=(o)=>{let n=o.value,i=n.size;if(i===t.size)return;let s=i>t.size;o.issues.push({origin:Tr(n),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),iu=g("$ZodCheckMaxLength",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!We(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)o._zod.bag.maximum=t.maximum}),e._zod.check=(o)=>{let n=o.value;if(n.length<=t.maximum)return;let s=Or(n);o.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),su=g("$ZodCheckMinLength",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!We(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)o._zod.bag.minimum=t.minimum}),e._zod.check=(o)=>{let n=o.value;if(n.length>=t.minimum)return;let s=Or(n);o.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),au=g("$ZodCheckLengthEquals",(e,t)=>{var r;N.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!We(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=(o)=>{let n=o.value,i=n.length;if(i===t.length)return;let s=Or(n),a=i>t.length;o.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Ut=g("$ZodCheckStringFormat",(e,t)=>{var r,o;if(N.init(e,t),e._zod.onattach.push((n)=>{let i=n._zod.bag;if(i.format=t.format,t.pattern)i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern)}),t.pattern)(r=e._zod).check??(r.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;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})});else(o=e._zod).check??(o.check=()=>{})}),cu=g("$ZodCheckRegex",(e,t)=>{Ut.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),uu=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=gi),Ut.init(e,t)}),lu=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=yi),Ut.init(e,t)}),pu=g("$ZodCheckIncludes",(e,t)=>{N.init(e,t);let r=me(t.includes),o=new RegExp(typeof t.position==="number"?`^.{${t.position}}${r}`:r);t.pattern=o,e._zod.onattach.push((n)=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(o)}),e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),du=g("$ZodCheckStartsWith",(e,t)=>{N.init(e,t);let r=new RegExp(`^${me(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=(o)=>{if(o.value.startsWith(t.prefix))return;o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),fu=g("$ZodCheckEndsWith",(e,t)=>{N.init(e,t);let r=new RegExp(`.*${me(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=(o)=>{if(o.value.endsWith(t.suffix))return;o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});mu=g("$ZodCheckProperty",(e,t)=>{N.init(e,t),e._zod.check=(r)=>{let o=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(o instanceof Promise)return o.then((n)=>Jc(n,r,t.property));Jc(o,r,t.property);return}}),hu=g("$ZodCheckMimeType",(e,t)=>{N.init(e,t);let r=new Set(t.mime);e._zod.onattach.push((o)=>{o._zod.bag.mime=t.mime}),e._zod.check=(o)=>{if(r.has(o.value.type))return;o.issues.push({code:"invalid_value",values:t.mime,input:o.value.type,inst:e,continue:!t.abort})}}),gu=g("$ZodCheckOverwrite",(e,t)=>{N.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}})});class wi{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
|
|
3
|
+
var ab=Object.defineProperty;var cb=(e)=>e;function ub(e,t){this[e]=cb.bind(null,t)}var Er=(e,t)=>{for(var r in t)ab(e,r,{get:t[r],enumerable:!0,configurable:!0,set:ub.bind(t,r)})};var _=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(o){r=[o]}if(r)throw r[0];return t};function db(e=""){if(lb.test(e))return;return e!==e.toLowerCase()}function hc(e,t){let r=t??pb,o=[];if(!e||typeof e!=="string")return o;let n="",i,s;for(let a of e){let c=r.includes(a);if(c===!0){o.push(n),n="",i=void 0;continue}let u=db(a);if(s===!1){if(i===!1&&u===!0){o.push(n),n=a,i=u;continue}if(i===!0&&u===!1&&n.length>1){let l=n.at(-1);o.push(n.slice(0,Math.max(0,n.length-1))),n=l+a,i=u;continue}}n+=a,i=u,s=c}return o.push(n),o}function fb(e){return e?e[0].toUpperCase()+e.slice(1):""}function mb(e){return e?e[0].toLowerCase()+e.slice(1):""}function hb(e,t){return e?(Array.isArray(e)?e:hc(e)).map((r)=>fb(t?.normalize?r.toLowerCase():r)).join(""):""}function Tt(e,t){return mb(hb(e||"",t))}function Sr(e,t){return e?(Array.isArray(e)?e:hc(e)).map((r)=>r.toLowerCase()).join(t??"-"):""}function gc(e){return Sr(e||"","_")}var lb,pb;var yc=_(()=>{lb=/\d/,pb=["-","_","/","."]});import{parseArgs as gb}from"util";function Ot(e){if(Array.isArray(e))return e;return e===void 0?[]:[e]}function Pn(e,t=""){let r=[];for(let o of e)for(let[n,i]of o.entries())r[n]=Math.max(r[n]||0,i.length);return e.map((o)=>o.map((n,i)=>t+n[i===0?"padStart":"padEnd"](r[i])).join(" ")).join(`
|
|
4
|
+
`)}function J(e){return typeof e==="function"?e():e}function yb(e=[],t={}){let r=new Set(t.boolean||[]),o=new Set(t.string||[]),n=t.alias||{},i=t.default||{},s=new Map,a=new Map;for(let[y,b]of Object.entries(n)){let P=b;for(let E of P){if(s.set(y,E),!a.has(E))a.set(E,[]);if(a.get(E).push(y),s.set(E,y),!a.has(y))a.set(y,[]);a.get(y).push(E)}}let c={};function u(y){if(r.has(y))return"boolean";let b=a.get(y)||[];for(let P of b)if(r.has(P))return"boolean";return"string"}function l(y){if(o.has(y))return!0;let b=a.get(y)||[];for(let P of b)if(o.has(P))return!0;return!1}let f=new Set([...r,...o,...Object.keys(n),...Object.values(n).flat(),...Object.keys(i)]);for(let y of f)if(!c[y])c[y]={type:u(y),default:i[y]};for(let[y,b]of s.entries())if(y.length===1&&c[b]&&!c[b].short)c[b].short=y;let d=[],p={};for(let y=0;y<e.length;y++){let b=e[y];if(b==="--"){d.push(...e.slice(y));break}if(b.startsWith("--no-")){let P=b.slice(5);p[P]=!0;continue}d.push(b)}let m;try{m=gb({args:d,options:Object.keys(c).length>0?c:void 0,allowPositionals:!0,strict:!1})}catch{m={values:{},positionals:d}}let h={_:[]};h._=m.positionals;for(let[y,b]of Object.entries(m.values)){let P=b;if(u(y)==="boolean"&&typeof b==="string")P=b!=="false";else if(l(y)&&typeof b==="boolean")P="";h[y]=P}for(let[y]of Object.entries(p)){h[y]=!1;let b=s.get(y);if(b)h[b]=!1;let P=a.get(y);if(P)for(let E of P)h[E]=!1}for(let[y,b]of s.entries()){if(h[y]!==void 0&&h[b]===void 0)h[b]=h[y];if(h[b]!==void 0&&h[y]===void 0)h[y]=h[b];if(h[y]!==h[b]&&i[b]===h[b])h[b]=h[y]}return h}function _b(e,t){let r={boolean:[],string:[],alias:{},default:{}},o=wc(t);for(let a of o){if(a.type==="positional")continue;if(a.type==="string"||a.type==="enum")r.string.push(a.name);else if(a.type==="boolean")r.boolean.push(a.name);if(a.default!==void 0)r.default[a.name]=a.default;if(a.alias)r.alias[a.name]=a.alias;let c=Tt(a.name),u=Sr(a.name);if(c!==a.name||u!==a.name){let l=Ot(r.alias[a.name]||[]);if(c!==a.name&&!l.includes(c))l.push(c);if(u!==a.name&&!l.includes(u))l.push(u);if(l.length>0)r.alias[a.name]=l}}let n=yb(e,r),[...i]=n._,s=new Proxy(n,{get(a,c){return a[c]??a[Tt(c)]??a[Sr(c)]}});for(let[,a]of o.entries())if(a.type==="positional"){let c=i.shift();if(c!==void 0)s[a.name]=c;else if(a.default===void 0&&a.required!==!1)throw new Oe(`Missing required positional argument: ${a.name.toUpperCase()}`,"EARG");else s[a.name]=a.default}else if(a.type==="enum"){let c=s[a.name],u=a.options||[];if(c!==void 0&&u.length>0&&!u.includes(c))throw new Oe(`Invalid value for argument: ${ge(`--${a.name}`)} (${ge(c)}). Expected one of: ${u.map((l)=>ge(l)).join(", ")}.`,"EARG")}else if(a.required&&s[a.name]===void 0)throw new Oe(`Missing required argument: --${a.name}`,"EARG");return s}function wc(e){let t=[];for(let[r,o]of Object.entries(e||{}))t.push({...o,name:r,alias:Ot(o.alias)});return t}async function wb(e){return Promise.all(e.map((t)=>J(t)))}function S(e){return e}async function Rn(e,t){let r=await J(e.args||{}),o=_b(t.rawArgs,r),n={rawArgs:t.rawArgs,args:o,data:t.data,cmd:e},i=await wb(e.plugins??[]),s,a;try{for(let l of i)await l.setup?.(n);if(typeof e.setup==="function")await e.setup(n);let u=await J(e.subCommands);if(u&&Object.keys(u).length>0){let l=vc(t.rawArgs,r),f=t.rawArgs[l];if(f){let d=await On(u,f);if(!d)throw new Oe(`Unknown command ${ge(f)}`,"E_UNKNOWN_COMMAND");await Rn(d,{rawArgs:t.rawArgs.slice(l+1)})}else{let d=await J(e.default);if(d){if(e.run)throw new Oe("Cannot specify both 'run' and 'default' on the same command.","E_DEFAULT_CONFLICT");let p=await On(u,d);if(!p)throw new Oe(`Default sub command ${ge(d)} not found in subCommands.`,"E_UNKNOWN_COMMAND");await Rn(p,{rawArgs:t.rawArgs})}else if(!e.run)throw new Oe("No command specified.","E_NO_COMMAND")}}if(typeof e.run==="function")s=await e.run(n)}catch(u){a=u}let c=[];if(typeof e.cleanup==="function")try{await e.cleanup(n)}catch(u){c.push(u)}for(let u of[...i].reverse())try{await u.cleanup?.(n)}catch(l){c.push(l)}if(a)throw a;if(c.length===1)throw c[0];if(c.length>1)throw Error("Multiple cleanup errors",{cause:c});return{result:s}}async function Tn(e,t,r){let o=await J(e.subCommands);if(o&&Object.keys(o).length>0){let n=vc(t,await J(e.args||{})),i=t[n],s=await On(o,i);if(s)return Tn(s,t.slice(n+1),e)}return[e,r]}async function On(e,t){if(t in e)return J(e[t]);for(let r of Object.values(e)){let o=await J(r),n=await J(o?.meta);if(n?.alias){if(Ot(n.alias).includes(t))return o}}}function vc(e,t){for(let r=0;r<e.length;r++){let o=e[r];if(o==="--")return-1;if(o.startsWith("-")){if(!o.includes("=")&&vb(o,t))r++;continue}return r}return-1}function vb(e,t){let r=e.replace(/^-{1,2}/,""),o=Tt(r);for(let[n,i]of Object.entries(t)){if(i.type!=="string"&&i.type!=="enum")continue;if(o===Tt(n))return!0;if((Array.isArray(i.alias)?i.alias:i.alias?[i.alias]:[]).includes(r))return!0}return!1}async function xb(e,t){try{console.log(await Sb(e,t)+`
|
|
5
|
+
`)}catch(r){console.error(r)}}async function Sb(e,t){let r=await J(e.meta||{}),o=wc(await J(e.args||{})),n=await J(t?.meta||{}),i=`${n.name?`${n.name} `:""}`+(r.name||process.argv[1]),s=[],a=[],c=[],u=[];for(let p of o)if(p.type==="positional"){let m=p.name.toUpperCase(),h=p.required!==!1&&p.default===void 0;a.push([ge(m+Cn(p)),bc(p,h)]),u.push(h?`<${m}>`:`[${m}]`)}else{let m=p.required===!0&&p.default===void 0,h=[...(p.alias||[]).map((y)=>`-${y}`),`--${p.name}`].join(", ")+Cn(p);if(s.push([ge(h),bc(p,m)]),p.type==="boolean"&&(p.default===!0||p.negativeDescription)&&!Eb.test(p.name)){let y=[...(p.alias||[]).map((b)=>`--no-${b}`),`--no-${p.name}`].join(", ");s.push([ge(y),[p.negativeDescription,m?kr("(Required)"):""].filter(Boolean).join(" ")])}if(m)u.push(`--${p.name}`+Cn(p))}if(e.subCommands){let p=[],m=await J(e.subCommands);for(let[h,y]of Object.entries(m)){let b=await J((await J(y))?.meta);if(b?.hidden)continue;let P=Ot(b?.alias),E=[h,...P].join(", ");c.push([ge(E),b?.description||""]),p.push(h,...P)}u.push(p.join("|"))}let l=[],f=r.version||n.version;l.push(kr(`${r.description} (${i+(f?` v${f}`:"")})`),"");let d=s.length>0||a.length>0;if(l.push(`${Ar($r("USAGE"))} ${ge(`${i}${d?" [OPTIONS]":""} ${u.join(" ")}`)}`,""),a.length>0)l.push(Ar($r("ARGUMENTS")),""),l.push(Pn(a," ")),l.push("");if(s.length>0)l.push(Ar($r("OPTIONS")),""),l.push(Pn(s," ")),l.push("");if(c.length>0)l.push(Ar($r("COMMANDS")),""),l.push(Pn(c," ")),l.push("",`Use ${ge(`${i} <command> --help`)} for more information about a command.`);return l.filter((p)=>typeof p==="string").join(`
|
|
6
|
+
`)}function Cn(e){let t=e.valueHint?`=<${e.valueHint}>`:"",r=t||`=<${gc(e.name)}>`;if(!e.type||e.type==="positional"||e.type==="boolean")return t;if(e.type==="enum"&&e.options?.length)return`=<${e.options.join("|")}>`;return r}function bc(e,t){let r=t?kr("(Required)"):"",o=e.default===void 0?"":kr(`(Default: ${e.default})`);return[e.description,r,o].filter(Boolean).join(" ")}async function $b(e,t={}){let r=t.rawArgs||process.argv.slice(2),o=t.showUsage||xb;try{let n=await Ab(e);if(n.help.length>0&&r.some((i)=>n.help.includes(i)))await o(...await Tn(e,r)),process.exit(0);else if(r.length===1&&n.version.includes(r[0])){let i=typeof e.meta==="function"?await e.meta():await e.meta;if(!i?.version)throw new Oe("No version specified","E_NO_VERSION");console.log(i.version)}else await Rn(e,{rawArgs:r})}catch(n){if(n instanceof Oe)await o(...await Tn(e,r)),console.error(n.message);else console.error(n,`
|
|
7
|
+
`);process.exit(1)}}function xc(e){return(t={})=>$b(e,t)}async function Ab(e){let t=await J(e.args||{}),r=new Set,o=new Set;for(let[n,i]of Object.entries(t)){r.add(n);for(let s of Ot(i.alias))o.add(s)}return{help:_c("help","h",r,o),version:_c("version","v",r,o)}}function _c(e,t,r,o){if(r.has(e)||o.has(e))return[];if(r.has(t)||o.has(t))return[`--${e}`];return[`--${e}`,`-${t}`]}var Oe,bb,Pr=(e,t=39)=>(r)=>bb?r:`\x1B[${e}m${r}\x1B[${t}m`,$r,ge,kr,Ar,Eb;var q=_(()=>{yc();Oe=class extends Error{code;constructor(e,t){super(e);this.name="CLIError",this.code=t}};bb=(()=>{let e=globalThis.process?.env??{};return e.NO_COLOR==="1"||e.TERM==="dumb"||e.TEST||e.CI})(),$r=Pr(1,22),ge=Pr(36),kr=Pr(90),Ar=Pr(4,24);Eb=/^no[-A-Z]/});function g(e,t,r){function o(a,c){if(!a._zod)Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1});if(a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let u=s.prototype,l=Object.keys(u);for(let f=0;f<l.length;f++){let d=l[f];if(!(d in a))a[d]=u[d].bind(a)}}let n=r?.Parent??Object;class i extends n{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let u=r?.Parent?new i:this;o(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(s,"init",{value:o}),Object.defineProperty(s,Symbol.hasInstance,{value:(a)=>{if(r?.Parent&&a instanceof r.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}function H(e){if(e)Object.assign(ut,e);return ut}var Ec,kb,Ie,lt,ut;var Ge=_(()=>{kb=Symbol("zod_brand");Ie=class Ie extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};lt=class lt extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}};(Ec=globalThis).__zod_globalConfig??(Ec.__zod_globalConfig={});ut=globalThis.__zod_globalConfig});function Rr(e){let t=Object.values(e).filter((o)=>typeof o==="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function Bn(e,t="|"){return e.map((r)=>Ln(r)).join(t)}function It(e,t){if(typeof t==="bigint")return t.toString();return t}function Bt(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw Error("cached value already set")}}}function Ke(e){return e===null||e===void 0}function Tr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function $c(e,t){let r=e/t,o=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-o)<n)return 0;return r-o}function I(e,t,r){let o=void 0;Object.defineProperty(e,t,{get(){if(o===Sc)return;if(o===void 0)o=Sc,o=r();return o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function He(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Le(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function zn(e){return JSON.stringify(e)}function Ac(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function pt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Je(e){if(pt(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(pt(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function Nn(e){if(Je(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}function ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pe(e,t,r){let o=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)o._zod.parent=e;return o}function w(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}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Ln(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Cc(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function Pb(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i=Le(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in r.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;s[a]=r.shape[a]}return He(this,"shape",s),s},checks:[]});return pe(e,i)}function Cb(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=Le(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in r.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;delete s[a]}return He(this,"shape",s),s},checks:[]});return pe(e,i)}function Rb(e,t){if(!Je(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=Le(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return He(this,"shape",i),i}});return pe(e,n)}function Tb(e,t){if(!Je(t))throw Error("Invalid input to safeExtend: expected a plain object");let r=Le(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return He(this,"shape",o),o}});return pe(e,r)}function Ob(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=Le(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t._zod.def.shape};return He(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return pe(e,r)}function Ib(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let s=Le(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(r)for(let u in r){if(!(u in a))throw Error(`Unrecognized key: "${u}"`);if(!r[u])continue;c[u]=e?new e({type:"optional",innerType:a[u]}):a[u]}else for(let u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return He(this,"shape",c),c},checks:[]});return pe(t,s)}function Bb(e,t,r){let o=Le(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(r)for(let s in r){if(!(s in i))throw Error(`Unrecognized key: "${s}"`);if(!r[s])continue;i[s]=new e({type:"nonoptional",innerType:n[s]})}else for(let s in n)i[s]=new e({type:"nonoptional",innerType:n[s]});return He(this,"shape",i),i}});return pe(t,o)}function Ye(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Oc(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function ae(e,t){return t.map((r)=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function Cr(e){return typeof e==="string"?e:e?.message}function ne(e,t,r){let o=e.message?e.message:Cr(e.inst?._zod.def?.error?.(e))??Cr(t?.error?.(e))??Cr(r.customError?.(e))??Cr(r.localeError?.(e))??"Invalid input",{inst:n,continue:i,input:s,...a}=e;if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=s;return a}function Ir(e){if(e instanceof Set)return"set";if(e instanceof Map)return"map";if(e instanceof File)return"file";return"unknown"}function Br(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Ic(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 r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Xe(...e){let[t,r,o]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:o};return{...t}}var Sc,Dn,kc,Or,Pc,Rc,Tc;var de=_(()=>{Ge();Sc=Symbol("evaluating");Dn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};kc=Bt(()=>{if(ut.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});Or=new Set(["string","number","symbol"]),Pc=new Set(["string","number","bigint","boolean","symbol","undefined"]);Rc={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Tc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]}});function Vn(e,t=(r)=>r.message){let r={},o=[];for(let n of e.issues)if(n.path.length>0)r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n));else o.push(t(n));return{formErrors:o,fieldErrors:r}}function Un(e,t=(r)=>r.message){let r={_errors:[]},o=(n,i=[])=>{for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>o({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")o({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")o({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,u=0;while(u<a.length){let l=a[u];if(u!==a.length-1)c[l]=c[l]||{_errors:[]};else c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(s));c=c[l],u++}}}};return o(e),r}function zb(e){let t=[],r=e.map((o)=>typeof o==="object"?o.key:o);for(let o of r)if(typeof o==="number")t.push(`[${o}]`);else if(typeof o==="symbol")t.push(`[${JSON.stringify(String(o))}]`);else if(/[^\w$]/.test(o))t.push(`[${JSON.stringify(o)}]`);else{if(t.length)t.push(".");t.push(o)}return t.join("")}function zc(e){let t=[],r=[...e.issues].sort((o,n)=>(o.path??[]).length-(n.path??[]).length);for(let o of r)if(t.push(`\u2716 ${o.message}`),o.path?.length)t.push(` \u2192 at ${zb(o.path)}`);return t.join(`
|
|
8
|
+
`)}var Bc=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,It,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},zr,zt;var Mn=_(()=>{Ge();de();zr=g("$ZodError",Bc),zt=g("$ZodError",Bc,{Parent:Error})});var Dt=(e)=>(t,r,o,n)=>{let i=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new Ie;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((c)=>ne(c,i,H())));throw Dn(a,n?.callee),a}return s.value},Fn,Nt=(e)=>async(t,r,o,n)=>{let i=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)s=await s;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((c)=>ne(c,i,H())));throw Dn(a,n?.callee),a}return s.value},jn,Lt=(e)=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)throw new Ie;return i.issues.length?{success:!1,error:new(e??zr)(i.issues.map((s)=>ne(s,n,H())))}:{success:!0,data:i.value}},Dc,Vt=(e)=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)i=await i;return i.issues.length?{success:!1,error:new e(i.issues.map((s)=>ne(s,n,H())))}:{success:!0,data:i.value}},Nc,Lc=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Dt(e)(t,r,n)},Vc=(e)=>(t,r,o)=>Dt(e)(t,r,o),Uc=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Nt(e)(t,r,n)},Mc=(e)=>async(t,r,o)=>Nt(e)(t,r,o),Fc=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Lt(e)(t,r,n)},jc=(e)=>(t,r,o)=>Lt(e)(t,r,o),Zc=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Vt(e)(t,r,n)},qc=(e)=>async(t,r,o)=>Vt(e)(t,r,o);var Zn=_(()=>{Ge();Mn();de();Fn=Dt(zt),jn=Nt(zt),Dc=Lt(zt),Nc=Vt(zt)});var tt={};Er(tt,{base64:()=>si,base64url:()=>Dr,bigint:()=>di,boolean:()=>mi,browserEmail:()=>Zb,cidrv4:()=>ni,cidrv6:()=>ii,cuid:()=>qn,cuid2:()=>Qn,date:()=>ci,datetime:()=>li,domain:()=>Gc,duration:()=>Jn,e164:()=>ai,email:()=>Xn,emoji:()=>ei,extendedDuration:()=>Nb,guid:()=>Yn,hex:()=>Jc,hostname:()=>Wc,html5Email:()=>Mb,httpProtocol:()=>Nr,idnEmail:()=>jb,integer:()=>fi,ipv4:()=>ti,ipv6:()=>ri,ksuid:()=>Kn,lowercase:()=>yi,mac:()=>oi,md5_base64:()=>Wb,md5_base64url:()=>Gb,md5_hex:()=>Qb,nanoid:()=>Hn,null:()=>hi,number:()=>Lr,rfc5322Email:()=>Fb,sha1_base64:()=>Hb,sha1_base64url:()=>Jb,sha1_hex:()=>Kb,sha256_base64:()=>Xb,sha256_base64url:()=>e_,sha256_hex:()=>Yb,sha384_base64:()=>r_,sha384_base64url:()=>o_,sha384_hex:()=>t_,sha512_base64:()=>i_,sha512_base64url:()=>s_,sha512_hex:()=>n_,string:()=>pi,time:()=>ui,ulid:()=>Wn,undefined:()=>gi,unicodeEmail:()=>Qc,uppercase:()=>bi,uuid:()=>et,uuid4:()=>Lb,uuid6:()=>Vb,uuid7:()=>Ub,xid:()=>Gn});function ei(){return new RegExp(qb,"u")}function Hc(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function ui(e){return new RegExp(`^${Hc(e)}$`)}function li(e){let t=Hc({precision:e.precision}),r=["Z"];if(e.local)r.push("");if(e.offset)r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let o=`${t}(?:${r.join("|")})`;return new RegExp(`^${Kc}T(?:${o})$`)}function Ut(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Mt(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var qn,Qn,Wn,Gn,Kn,Hn,Jn,Nb,Yn,et=(e)=>{if(!e)return/^([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)$/;return new 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})$`)},Lb,Vb,Ub,Xn,Mb,Fb,Qc,jb,Zb,qb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ti,ri,oi=(e)=>{let t=ye(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},ni,ii,si,Dr,Wc,Gc,Nr,ai,Kc="(?:(?:\\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])))",ci,pi=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},di,fi,Lr,mi,hi,gi,yi,bi,Jc,Qb,Wb,Gb,Kb,Hb,Jb,Yb,Xb,e_,t_,r_,o_,n_,i_,s_;var Vr=_(()=>{de();qn=/^[cC][0-9a-z]{6,}$/,Qn=/^[0-9a-z]+$/,Wn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Gn=/^[0-9a-vA-V]{20}$/,Kn=/^[A-Za-z0-9]{27}$/,Hn=/^[a-zA-Z0-9_-]{21}$/,Jn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Nb=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Yn=/^([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})$/,Lb=et(4),Vb=et(6),Ub=et(7),Xn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Mb=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Fb=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,Qc=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,jb=Qc,Zb=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;ti=/^(?:(?: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])$/,ri=/^(([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}|:))$/,ni=/^((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])$/,ii=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,si=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Dr=/^[A-Za-z0-9_-]*$/,Wc=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Gc=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Nr=/^https?$/,ai=/^\+[1-9]\d{6,14}$/,ci=new RegExp(`^${Kc}$`);di=/^-?\d+n?$/,fi=/^-?\d+$/,Lr=/^-?\d+(?:\.\d+)?$/,mi=/^(?:true|false)$/i,hi=/^null$/i,gi=/^undefined$/i,yi=/^[^A-Z]*$/,bi=/^[^a-z]*$/,Jc=/^[0-9a-fA-F]*$/;Qb=/^[0-9a-fA-F]{32}$/,Wb=Ut(22,"=="),Gb=Mt(22),Kb=/^[0-9a-fA-F]{40}$/,Hb=Ut(27,"="),Jb=Mt(27),Yb=/^[0-9a-fA-F]{64}$/,Xb=Ut(43,"="),e_=Mt(43),t_=/^[0-9a-fA-F]{96}$/,r_=Ut(64,""),o_=Mt(64),n_=/^[0-9a-fA-F]{128}$/,i_=Ut(86,"=="),s_=Mt(86)});function Yc(e,t,r){if(e.issues.length)t.issues.push(...ae(r,e.issues))}var U,Xc,_i,wi,eu,tu,ru,ou,nu,iu,su,au,cu,Ft,uu,lu,pu,du,fu,mu,hu,gu,yu;var Ur=_(()=>{Ge();Vr();de();U=g("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Xc={number:"number",bigint:"bigint",object:"date"},_i=g("$ZodCheckLessThan",(e,t)=>{U.init(e,t);let r=Xc[typeof t.value];e._zod.onattach.push((o)=>{let n=o._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<i)if(t.inclusive)n.maximum=t.value;else n.exclusiveMaximum=t.value}),e._zod.check=(o)=>{if(t.inclusive?o.value<=t.value:o.value<t.value)return;o.issues.push({origin:r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wi=g("$ZodCheckGreaterThan",(e,t)=>{U.init(e,t);let r=Xc[typeof t.value];e._zod.onattach.push((o)=>{let n=o._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>i)if(t.inclusive)n.minimum=t.value;else n.exclusiveMinimum=t.value}),e._zod.check=(o)=>{if(t.inclusive?o.value>=t.value:o.value>t.value)return;o.issues.push({origin:r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),eu=g("$ZodCheckMultipleOf",(e,t)=>{U.init(e,t),e._zod.onattach.push((r)=>{var o;(o=r._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?r.value%t.value===BigInt(0):$c(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),tu=g("$ZodCheckNumberFormat",(e,t)=>{U.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,i]=Rc[t.format];e._zod.onattach.push((s)=>{let a=s._zod.bag;if(a.format=t.format,a.minimum=n,a.maximum=i,r)a.pattern=fi}),e._zod.check=(s)=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});else s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}if(a<n)s.issues.push({origin:"number",input:a,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(a>i)s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),ru=g("$ZodCheckBigIntFormat",(e,t)=>{U.init(e,t);let[r,o]=Tc[t.format];e._zod.onattach.push((n)=>{let i=n._zod.bag;i.format=t.format,i.minimum=r,i.maximum=o}),e._zod.check=(n)=>{let i=n.value;if(i<r)n.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(i>o)n.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),ou=g("$ZodCheckMaxSize",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!Ke(n)&&n.size!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)o._zod.bag.maximum=t.maximum}),e._zod.check=(o)=>{let n=o.value;if(n.size<=t.maximum)return;o.issues.push({origin:Ir(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),nu=g("$ZodCheckMinSize",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!Ke(n)&&n.size!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)o._zod.bag.minimum=t.minimum}),e._zod.check=(o)=>{let n=o.value;if(n.size>=t.minimum)return;o.issues.push({origin:Ir(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),iu=g("$ZodCheckSizeEquals",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!Ke(n)&&n.size!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=(o)=>{let n=o.value,i=n.size;if(i===t.size)return;let s=i>t.size;o.issues.push({origin:Ir(n),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),su=g("$ZodCheckMaxLength",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!Ke(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)o._zod.bag.maximum=t.maximum}),e._zod.check=(o)=>{let n=o.value;if(n.length<=t.maximum)return;let s=Br(n);o.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),au=g("$ZodCheckMinLength",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!Ke(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)o._zod.bag.minimum=t.minimum}),e._zod.check=(o)=>{let n=o.value;if(n.length>=t.minimum)return;let s=Br(n);o.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),cu=g("$ZodCheckLengthEquals",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!Ke(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=(o)=>{let n=o.value,i=n.length;if(i===t.length)return;let s=Br(n),a=i>t.length;o.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Ft=g("$ZodCheckStringFormat",(e,t)=>{var r,o;if(U.init(e,t),e._zod.onattach.push((n)=>{let i=n._zod.bag;if(i.format=t.format,t.pattern)i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern)}),t.pattern)(r=e._zod).check??(r.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;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})});else(o=e._zod).check??(o.check=()=>{})}),uu=g("$ZodCheckRegex",(e,t)=>{Ft.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),lu=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=yi),Ft.init(e,t)}),pu=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=bi),Ft.init(e,t)}),du=g("$ZodCheckIncludes",(e,t)=>{U.init(e,t);let r=ye(t.includes),o=new RegExp(typeof t.position==="number"?`^.{${t.position}}${r}`:r);t.pattern=o,e._zod.onattach.push((n)=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(o)}),e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),fu=g("$ZodCheckStartsWith",(e,t)=>{U.init(e,t);let r=new RegExp(`^${ye(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=(o)=>{if(o.value.startsWith(t.prefix))return;o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),mu=g("$ZodCheckEndsWith",(e,t)=>{U.init(e,t);let r=new RegExp(`.*${ye(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=(o)=>{if(o.value.endsWith(t.suffix))return;o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});hu=g("$ZodCheckProperty",(e,t)=>{U.init(e,t),e._zod.check=(r)=>{let o=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(o instanceof Promise)return o.then((n)=>Yc(n,r,t.property));Yc(o,r,t.property);return}}),gu=g("$ZodCheckMimeType",(e,t)=>{U.init(e,t);let r=new Set(t.mime);e._zod.onattach.push((o)=>{o._zod.bag.mime=t.mime}),e._zod.check=(o)=>{if(r.has(o.value.type))return;o.issues.push({code:"invalid_value",values:t.mime,input:o.value.type,inst:e,continue:!t.abort})}}),yu=g("$ZodCheckOverwrite",(e,t)=>{U.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}})});class vi{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
|
|
9
9
|
`).filter((i)=>i),o=Math.min(...r.map((i)=>i.length-i.trimStart().length)),n=r.map((i)=>i.slice(o)).map((i)=>" ".repeat(this.indent*2)+i);for(let i of n)this.content.push(i)}compile(){let e=Function,t=this?.args,o=[...(this?.content??[""]).map((n)=>` ${n}`)];return new e(...t,o.join(`
|
|
10
|
-
`))}}var bu;var vi=_(()=>{bu={major:4,minor:4,patch:3}});function Xu(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}function i_(e){if(!Br.test(e))return!1;let t=e.replace(/[-_]/g,(o)=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Xu(r)}function s_(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[o]=r;if(!o)return!1;let n=JSON.parse(atob(o));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}function _u(e,t,r){if(e.issues.length)t.issues.push(...ne(r,e.issues));t.value[r]=e.value}function Mr(e,t,r,o,n,i){let s=r in o;if(e.issues.length){if(n&&i&&!s)return;t.issues.push(...ne(r,e.issues))}if(!s&&!n){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(s)t.value[r]=void 0}else t.value[r]=e.value}function gl(e){let t=Object.keys(e.shape);for(let o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${o}": expected a Zod schema`);let r=Pc(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function yl(e,t,r,o,n,i){let s=[],a=n.keySet,c=n.catchall._zod,u=c.def.type,l=c.optin==="optional",f=c.optout==="optional";for(let p in t){if(p==="__proto__")continue;if(a.has(p))continue;if(u==="never"){s.push(p);continue}let d=c.run({value:t[p],issues:[]},o);if(d instanceof Promise)e.push(d.then((m)=>Mr(m,r,p,t,l,f)));else Mr(d,r,p,t,l,f)}if(s.length)r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i});if(!e.length)return r;return Promise.all(e).then(()=>r)}function wu(e,t,r,o){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let n=e.filter((i)=>!He(i));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>te(s,o,W())))}),t}function vu(e,t,r,o){let n=e.filter((i)=>i.issues.length===0);if(n.length===1)return t.value=n[0].value,t;if(n.length===0)t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>te(s,o,W())))});else t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1});return t}function xi(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Ke(e)&&Ke(t)){let r=Object.keys(t),o=Object.keys(e).filter((i)=>r.indexOf(i)!==-1),n={...e,...t};for(let i of o){let s=xi(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n[i]=s.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let o=0;o<e.length;o++){let n=e[o],i=t[o],s=xi(n,i);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function xu(e,t,r){let o=new Map,n;for(let a of t.issues)if(a.code==="unrecognized_keys"){n??(n=a);for(let c of a.keys){if(!o.has(c))o.set(c,{});o.get(c).l=!0}}else e.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys){if(!o.has(c))o.set(c,{});o.get(c).r=!0}else e.issues.push(a);let i=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&n)e.issues.push({...n,keys:i});if(He(e))return e;let s=xi(t.value,r.value);if(!s.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}function Eu(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function Su(e,t,r){if(e.issues.length)t.issues.push(...ne(r,e.issues));t.value[r]=e.value}function $u(e,t,r,o,n){for(let i=0;i<r.length;i++){let s=e[i],a=i<o.length;if(s.issues.length){if(!a&&i>=n){t.value.length=i;break}t.issues.push(...ne(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=o.length;i--)if(r[i]._zod.optout==="optional"&&t.value[i]===void 0)t.value.length=i;else break;return t}function Au(e,t,r,o,n,i,s){if(e.issues.length)if(Rr.has(typeof o))r.issues.push(...ne(o,e.issues));else r.issues.push({code:"invalid_key",origin:"map",input:n,inst:i,issues:e.issues.map((a)=>te(a,s,W()))});if(t.issues.length)if(Rr.has(typeof o))r.issues.push(...ne(o,t.issues));else r.issues.push({origin:"map",code:"invalid_element",input:n,inst:i,key:o,issues:t.issues.map((a)=>te(a,s,W()))});r.value.set(e.value,t.value)}function ku(e,t){if(e.issues.length)t.issues.push(...e.issues);t.value.add(e.value)}function Pu(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}function Cu(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}function Ru(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function Vr(e,t,r){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}function Ur(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let n=t.transform(e.value,e);if(n instanceof Promise)return n.then((i)=>Fr(e,i,t.out,r));return Fr(e,n,t.out,r)}else{let n=t.reverseTransform(e.value,e);if(n instanceof Promise)return n.then((i)=>Fr(e,i,t.in,r));return Fr(e,n,t.in,r)}}function Fr(e,t,r,o){if(e.issues.length)return e.aborted=!0,e;return r._zod.run({value:t,issues:e.issues},o)}function Tu(e){return e.value=Object.freeze(e.value),e}function Ou(e,t,r,o){if(!e){let n={code:"custom",input:r,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};if(o._zod.def.params)n.params=o._zod.def.params;t.issues.push(Je(n))}}var P,lt,B,Iu,Bu,zu,Du,Nu,Lu,Vu,Uu,Fu,Mu,ju,Zu,qu,Qu,Wu,Gu,Ku,Hu,Ju,Yu,el,tl,rl,ol,nl,Ei,il,jr,Si,sl,al,cl,ul,ll,pl,dl,fl,ml,hl,a_,bl,Zr,_l,wl,vl,$i,xl,El,Sl,$l,Al,kl,Pl,Ai,Cl,Rl,Tl,Ol,Il,Bl,zl,Dl,ki,qr,Nl,Ll,Vl,Ul,Fl,Ml,jl;var Pi=_(()=>{Lr();Qe();jn();Nr();ue();vi();ue();P=g("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=bu;let o=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))o.unshift(e);for(let n of o)for(let i of n._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(s,a,c)=>{let u=He(s),l;for(let f of a){if(f._zod.def.when){if(Tc(s))continue;if(!f._zod.def.when(s))continue}else if(u)continue;let p=s.issues.length,d=f._zod.check(s);if(d instanceof Promise&&c?.async===!1)throw new Re;if(l||d instanceof Promise)l=(l??Promise.resolve()).then(async()=>{if(await d,s.issues.length===p)return;if(!u)u=He(s,p)});else{if(s.issues.length===p)continue;if(!u)u=He(s,p)}}if(l)return l.then(()=>s);return s},i=(s,a,c)=>{if(He(s))return s.aborted=!0,s;let u=n(a,o,c);if(u instanceof Promise){if(c.async===!1)throw new Re;return u.then((l)=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});if(u instanceof Promise)return u.then((l)=>i(l,s,a));return i(u,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new Re;return c.then((u)=>n(u,o,a))}return n(c,o,a)}}T(e,"~standard",()=>({validate:(n)=>{try{let i=zc(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch(i){return Dc(e,n).then((s)=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),lt=g("$ZodString",(e,t)=>{P.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??li(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),B=g("$ZodStringFormat",(e,t)=>{Ut.init(e,t),lt.init(e,t)}),Iu=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Jn),B.init(e,t)}),Bu=g("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ye(o))}else t.pattern??(t.pattern=Ye());B.init(e,t)}),zu=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Yn),B.init(e,t)}),Du=g("$ZodURL",(e,t)=>{B.init(e,t),e._zod.check=(r)=>{try{let o=r.value.trim();if(!t.normalize&&t.protocol?.source===zr.source){if(!/^https?:\/\//i.test(o)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}}let n=new URL(o);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(n.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})}if(t.normalize)r.value=n.href;else r.value=o;return}catch(o){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Nu=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Xn()),B.init(e,t)}),Lu=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Kn),B.init(e,t)}),Vu=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Zn),B.init(e,t)}),Uu=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=qn),B.init(e,t)}),Fu=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Qn),B.init(e,t)}),Mu=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Wn),B.init(e,t)}),ju=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Gn),B.init(e,t)}),Zu=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ui(t)),B.init(e,t)}),qu=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ai),B.init(e,t)}),Qu=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ci(t)),B.init(e,t)}),Wu=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Hn),B.init(e,t)}),Gu=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ei),B.init(e,t),e._zod.bag.format="ipv4"}),Ku=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ti),B.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(r)=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Hu=g("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=ri(t.delimiter)),B.init(e,t),e._zod.bag.format="mac"}),Ju=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=oi),B.init(e,t)}),Yu=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ni),B.init(e,t),e._zod.check=(r)=>{let o=r.value.split("/");try{if(o.length!==2)throw Error();let[n,i]=o;if(!i)throw Error();let s=Number(i);if(`${s}`!==i)throw Error();if(s<0||s>128)throw Error();new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});el=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ii),B.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(r)=>{if(Xu(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});tl=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Br),B.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(r)=>{if(i_(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),rl=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=si),B.init(e,t)});ol=g("$ZodJWT",(e,t)=>{B.init(e,t),e._zod.check=(r)=>{if(s_(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),nl=g("$ZodCustomStringFormat",(e,t)=>{B.init(e,t),e._zod.check=(r)=>{if(t.fn(r.value))return;r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),Ei=g("$ZodNumber",(e,t)=>{P.init(e,t),e._zod.pattern=e._zod.bag.pattern??Dr,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch(s){}let n=r.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let i=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?"Infinity":void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),r}}),il=g("$ZodNumberFormat",(e,t)=>{eu.init(e,t),Ei.init(e,t)}),jr=g("$ZodBoolean",(e,t)=>{P.init(e,t),e._zod.pattern=fi,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(i){}let n=r.value;if(typeof n==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),Si=g("$ZodBigInt",(e,t)=>{P.init(e,t),e._zod.pattern=pi,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch(n){}if(typeof r.value==="bigint")return r;return r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),sl=g("$ZodBigIntFormat",(e,t)=>{tu.init(e,t),Si.init(e,t)}),al=g("$ZodSymbol",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(typeof n==="symbol")return r;return r.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),r}}),cl=g("$ZodUndefined",(e,t)=>{P.init(e,t),e._zod.pattern=hi,e._zod.values=new Set([void 0]),e._zod.parse=(r,o)=>{let n=r.value;if(typeof n>"u")return r;return r.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),r}}),ul=g("$ZodNull",(e,t)=>{P.init(e,t),e._zod.pattern=mi,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{let n=r.value;if(n===null)return r;return r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),ll=g("$ZodAny",(e,t)=>{P.init(e,t),e._zod.parse=(r)=>r}),pl=g("$ZodUnknown",(e,t)=>{P.init(e,t),e._zod.parse=(r)=>r}),dl=g("$ZodNever",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),fl=g("$ZodVoid",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(typeof n>"u")return r;return r.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),r}}),ml=g("$ZodDate",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(a){}let n=r.value,i=n instanceof Date;if(i&&!Number.isNaN(n.getTime()))return r;return r.issues.push({expected:"date",code:"invalid_type",input:n,...i?{received:"Invalid Date"}:{},inst:e}),r}});hl=g("$ZodArray",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let i=[];for(let s=0;s<n.length;s++){let a=n[s],c=t.element._zod.run({value:a,issues:[]},o);if(c instanceof Promise)i.push(c.then((u)=>_u(u,r,s)));else _u(c,r,s)}if(i.length)return Promise.all(i).then(()=>r);return r}});a_=g("$ZodObject",(e,t)=>{if(P.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let o=Ot(()=>gl(t));T(e._zod,"propValues",()=>{let a=t.shape,c={};for(let u in a){let l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let f of l.values)c[u].add(f)}}return c});let n=ut,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=o.value);let u=a.value;if(!n(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};let l=[],f=s.shape;for(let p of s.keys){let d=f[p],m=d._zod.optin==="optional",h=d._zod.optout==="optional",y=d._zod.run({value:u[p],issues:[]},c);if(y instanceof Promise)l.push(y.then((b)=>Mr(b,a,p,u,m,h)));else Mr(y,a,p,u,m,h)}if(!i)return l.length?Promise.all(l).then(()=>a):a;return yl(l,u,a,c,o.value,e)}}),bl=g("$ZodObjectJIT",(e,t)=>{a_.init(e,t);let r=e._zod.parse,o=Ot(()=>gl(t)),n=(p)=>{let d=new wi(["shape","payload","ctx"]),m=o.value,h=(x)=>{let A=Bn(x);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};d.write("const input = payload.value;");let y=Object.create(null),b=0;for(let x of m.keys)y[x]=`key_${b++}`;d.write("const newResult = {};");for(let x of m.keys){let A=y[x],R=Bn(x),Z=p[x],_e=Z?._zod?.optin==="optional",Ze=Z?._zod?.optout==="optional";if(d.write(`const ${A} = ${h(x)};`),_e&&Ze)d.write(`
|
|
10
|
+
`))}}var _u;var xi=_(()=>{_u={major:4,minor:4,patch:3}});function el(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}function a_(e){if(!Dr.test(e))return!1;let t=e.replace(/[-_]/g,(o)=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return el(r)}function c_(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[o]=r;if(!o)return!1;let n=JSON.parse(atob(o));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}function wu(e,t,r){if(e.issues.length)t.issues.push(...ae(r,e.issues));t.value[r]=e.value}function Zr(e,t,r,o,n,i){let s=r in o;if(e.issues.length){if(n&&i&&!s)return;t.issues.push(...ae(r,e.issues))}if(!s&&!n){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(s)t.value[r]=void 0}else t.value[r]=e.value}function yl(e){let t=Object.keys(e.shape);for(let o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${o}": expected a Zod schema`);let r=Cc(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function bl(e,t,r,o,n,i){let s=[],a=n.keySet,c=n.catchall._zod,u=c.def.type,l=c.optin==="optional",f=c.optout==="optional";for(let d in t){if(d==="__proto__")continue;if(a.has(d))continue;if(u==="never"){s.push(d);continue}let p=c.run({value:t[d],issues:[]},o);if(p instanceof Promise)e.push(p.then((m)=>Zr(m,r,d,t,l,f)));else Zr(p,r,d,t,l,f)}if(s.length)r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i});if(!e.length)return r;return Promise.all(e).then(()=>r)}function vu(e,t,r,o){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let n=e.filter((i)=>!Ye(i));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>ne(s,o,H())))}),t}function xu(e,t,r,o){let n=e.filter((i)=>i.issues.length===0);if(n.length===1)return t.value=n[0].value,t;if(n.length===0)t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>ne(s,o,H())))});else t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1});return t}function Ei(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Je(e)&&Je(t)){let r=Object.keys(t),o=Object.keys(e).filter((i)=>r.indexOf(i)!==-1),n={...e,...t};for(let i of o){let s=Ei(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n[i]=s.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let o=0;o<e.length;o++){let n=e[o],i=t[o],s=Ei(n,i);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Eu(e,t,r){let o=new Map,n;for(let a of t.issues)if(a.code==="unrecognized_keys"){n??(n=a);for(let c of a.keys){if(!o.has(c))o.set(c,{});o.get(c).l=!0}}else e.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys){if(!o.has(c))o.set(c,{});o.get(c).r=!0}else e.issues.push(a);let i=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&n)e.issues.push({...n,keys:i});if(Ye(e))return e;let s=Ei(t.value,r.value);if(!s.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}function Su(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function $u(e,t,r){if(e.issues.length)t.issues.push(...ae(r,e.issues));t.value[r]=e.value}function Au(e,t,r,o,n){for(let i=0;i<r.length;i++){let s=e[i],a=i<o.length;if(s.issues.length){if(!a&&i>=n){t.value.length=i;break}t.issues.push(...ae(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=o.length;i--)if(r[i]._zod.optout==="optional"&&t.value[i]===void 0)t.value.length=i;else break;return t}function ku(e,t,r,o,n,i,s){if(e.issues.length)if(Or.has(typeof o))r.issues.push(...ae(o,e.issues));else r.issues.push({code:"invalid_key",origin:"map",input:n,inst:i,issues:e.issues.map((a)=>ne(a,s,H()))});if(t.issues.length)if(Or.has(typeof o))r.issues.push(...ae(o,t.issues));else r.issues.push({origin:"map",code:"invalid_element",input:n,inst:i,key:o,issues:t.issues.map((a)=>ne(a,s,H()))});r.value.set(e.value,t.value)}function Pu(e,t){if(e.issues.length)t.issues.push(...e.issues);t.value.add(e.value)}function Cu(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}function Ru(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}function Tu(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function Mr(e,t,r){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}function Fr(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let n=t.transform(e.value,e);if(n instanceof Promise)return n.then((i)=>jr(e,i,t.out,r));return jr(e,n,t.out,r)}else{let n=t.reverseTransform(e.value,e);if(n instanceof Promise)return n.then((i)=>jr(e,i,t.in,r));return jr(e,n,t.in,r)}}function jr(e,t,r,o){if(e.issues.length)return e.aborted=!0,e;return r._zod.run({value:t,issues:e.issues},o)}function Ou(e){return e.value=Object.freeze(e.value),e}function Iu(e,t,r,o){if(!e){let n={code:"custom",input:r,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};if(o._zod.def.params)n.params=o._zod.def.params;t.issues.push(Xe(n))}}var R,dt,N,Bu,zu,Du,Nu,Lu,Vu,Uu,Mu,Fu,ju,Zu,qu,Qu,Wu,Gu,Ku,Hu,Ju,Yu,Xu,tl,rl,ol,nl,il,Si,sl,qr,$i,al,cl,ul,ll,pl,dl,fl,ml,hl,gl,u_,_l,Qr,wl,vl,xl,Ai,El,Sl,$l,Al,kl,Pl,Cl,ki,Rl,Tl,Ol,Il,Bl,zl,Dl,Nl,Pi,Wr,Ll,Vl,Ul,Ml,Fl,jl,Zl;var Ci=_(()=>{Ur();Ge();Zn();Vr();de();xi();de();R=g("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_u;let o=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))o.unshift(e);for(let n of o)for(let i of n._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(s,a,c)=>{let u=Ye(s),l;for(let f of a){if(f._zod.def.when){if(Oc(s))continue;if(!f._zod.def.when(s))continue}else if(u)continue;let d=s.issues.length,p=f._zod.check(s);if(p instanceof Promise&&c?.async===!1)throw new Ie;if(l||p instanceof Promise)l=(l??Promise.resolve()).then(async()=>{if(await p,s.issues.length===d)return;if(!u)u=Ye(s,d)});else{if(s.issues.length===d)continue;if(!u)u=Ye(s,d)}}if(l)return l.then(()=>s);return s},i=(s,a,c)=>{if(Ye(s))return s.aborted=!0,s;let u=n(a,o,c);if(u instanceof Promise){if(c.async===!1)throw new Ie;return u.then((l)=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});if(u instanceof Promise)return u.then((l)=>i(l,s,a));return i(u,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new Ie;return c.then((u)=>n(u,o,a))}return n(c,o,a)}}I(e,"~standard",()=>({validate:(n)=>{try{let i=Dc(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch(i){return Nc(e,n).then((s)=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),dt=g("$ZodString",(e,t)=>{R.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??pi(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),N=g("$ZodStringFormat",(e,t)=>{Ft.init(e,t),dt.init(e,t)}),Bu=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Yn),N.init(e,t)}),zu=g("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=et(o))}else t.pattern??(t.pattern=et());N.init(e,t)}),Du=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Xn),N.init(e,t)}),Nu=g("$ZodURL",(e,t)=>{N.init(e,t),e._zod.check=(r)=>{try{let o=r.value.trim();if(!t.normalize&&t.protocol?.source===Nr.source){if(!/^https?:\/\//i.test(o)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}}let n=new URL(o);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(n.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})}if(t.normalize)r.value=n.href;else r.value=o;return}catch(o){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Lu=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ei()),N.init(e,t)}),Vu=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Hn),N.init(e,t)}),Uu=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=qn),N.init(e,t)}),Mu=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Qn),N.init(e,t)}),Fu=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Wn),N.init(e,t)}),ju=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Gn),N.init(e,t)}),Zu=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Kn),N.init(e,t)}),qu=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=li(t)),N.init(e,t)}),Qu=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ci),N.init(e,t)}),Wu=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ui(t)),N.init(e,t)}),Gu=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Jn),N.init(e,t)}),Ku=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ti),N.init(e,t),e._zod.bag.format="ipv4"}),Hu=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ri),N.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(r)=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Ju=g("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=oi(t.delimiter)),N.init(e,t),e._zod.bag.format="mac"}),Yu=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ni),N.init(e,t)}),Xu=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ii),N.init(e,t),e._zod.check=(r)=>{let o=r.value.split("/");try{if(o.length!==2)throw Error();let[n,i]=o;if(!i)throw Error();let s=Number(i);if(`${s}`!==i)throw Error();if(s<0||s>128)throw Error();new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});tl=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=si),N.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(r)=>{if(el(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});rl=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Dr),N.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(r)=>{if(a_(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ol=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ai),N.init(e,t)});nl=g("$ZodJWT",(e,t)=>{N.init(e,t),e._zod.check=(r)=>{if(c_(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),il=g("$ZodCustomStringFormat",(e,t)=>{N.init(e,t),e._zod.check=(r)=>{if(t.fn(r.value))return;r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),Si=g("$ZodNumber",(e,t)=>{R.init(e,t),e._zod.pattern=e._zod.bag.pattern??Lr,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch(s){}let n=r.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let i=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?"Infinity":void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),r}}),sl=g("$ZodNumberFormat",(e,t)=>{tu.init(e,t),Si.init(e,t)}),qr=g("$ZodBoolean",(e,t)=>{R.init(e,t),e._zod.pattern=mi,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(i){}let n=r.value;if(typeof n==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),$i=g("$ZodBigInt",(e,t)=>{R.init(e,t),e._zod.pattern=di,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch(n){}if(typeof r.value==="bigint")return r;return r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),al=g("$ZodBigIntFormat",(e,t)=>{ru.init(e,t),$i.init(e,t)}),cl=g("$ZodSymbol",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(typeof n==="symbol")return r;return r.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),r}}),ul=g("$ZodUndefined",(e,t)=>{R.init(e,t),e._zod.pattern=gi,e._zod.values=new Set([void 0]),e._zod.parse=(r,o)=>{let n=r.value;if(typeof n>"u")return r;return r.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),r}}),ll=g("$ZodNull",(e,t)=>{R.init(e,t),e._zod.pattern=hi,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{let n=r.value;if(n===null)return r;return r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),pl=g("$ZodAny",(e,t)=>{R.init(e,t),e._zod.parse=(r)=>r}),dl=g("$ZodUnknown",(e,t)=>{R.init(e,t),e._zod.parse=(r)=>r}),fl=g("$ZodNever",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),ml=g("$ZodVoid",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(typeof n>"u")return r;return r.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),r}}),hl=g("$ZodDate",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(a){}let n=r.value,i=n instanceof Date;if(i&&!Number.isNaN(n.getTime()))return r;return r.issues.push({expected:"date",code:"invalid_type",input:n,...i?{received:"Invalid Date"}:{},inst:e}),r}});gl=g("$ZodArray",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let i=[];for(let s=0;s<n.length;s++){let a=n[s],c=t.element._zod.run({value:a,issues:[]},o);if(c instanceof Promise)i.push(c.then((u)=>wu(u,r,s)));else wu(c,r,s)}if(i.length)return Promise.all(i).then(()=>r);return r}});u_=g("$ZodObject",(e,t)=>{if(R.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let o=Bt(()=>yl(t));I(e._zod,"propValues",()=>{let a=t.shape,c={};for(let u in a){let l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let f of l.values)c[u].add(f)}}return c});let n=pt,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=o.value);let u=a.value;if(!n(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};let l=[],f=s.shape;for(let d of s.keys){let p=f[d],m=p._zod.optin==="optional",h=p._zod.optout==="optional",y=p._zod.run({value:u[d],issues:[]},c);if(y instanceof Promise)l.push(y.then((b)=>Zr(b,a,d,u,m,h)));else Zr(y,a,d,u,m,h)}if(!i)return l.length?Promise.all(l).then(()=>a):a;return bl(l,u,a,c,o.value,e)}}),_l=g("$ZodObjectJIT",(e,t)=>{u_.init(e,t);let r=e._zod.parse,o=Bt(()=>yl(t)),n=(d)=>{let p=new vi(["shape","payload","ctx"]),m=o.value,h=(E)=>{let A=zn(E);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};p.write("const input = payload.value;");let y=Object.create(null),b=0;for(let E of m.keys)y[E]=`key_${b++}`;p.write("const newResult = {};");for(let E of m.keys){let A=y[E],x=zn(E),k=d[E],T=k?._zod?.optin==="optional",B=k?._zod?.optout==="optional";if(p.write(`const ${A} = ${h(E)};`),T&&B)p.write(`
|
|
11
11
|
if (${A}.issues.length) {
|
|
12
|
-
if (${
|
|
12
|
+
if (${x} in input) {
|
|
13
13
|
payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
|
|
14
14
|
...iss,
|
|
15
|
-
path: iss.path ? [${
|
|
15
|
+
path: iss.path ? [${x}, ...iss.path] : [${x}]
|
|
16
16
|
})));
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
if (${A}.value === undefined) {
|
|
21
|
-
if (${
|
|
22
|
-
newResult[${
|
|
21
|
+
if (${x} in input) {
|
|
22
|
+
newResult[${x}] = undefined;
|
|
23
23
|
}
|
|
24
24
|
} else {
|
|
25
|
-
newResult[${
|
|
25
|
+
newResult[${x}] = ${A}.value;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
`);else if(!
|
|
29
|
-
const ${A}_present = ${
|
|
28
|
+
`);else if(!T)p.write(`
|
|
29
|
+
const ${A}_present = ${x} in input;
|
|
30
30
|
if (${A}.issues.length) {
|
|
31
31
|
payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
|
|
32
32
|
...iss,
|
|
33
|
-
path: iss.path ? [${
|
|
33
|
+
path: iss.path ? [${x}, ...iss.path] : [${x}]
|
|
34
34
|
})));
|
|
35
35
|
}
|
|
36
36
|
if (!${A}_present && !${A}.issues.length) {
|
|
@@ -38,80 +38,81 @@ var ib=Object.defineProperty;var sb=(e)=>e;function ab(e,t){this[e]=sb.bind(null
|
|
|
38
38
|
code: "invalid_type",
|
|
39
39
|
expected: "nonoptional",
|
|
40
40
|
input: undefined,
|
|
41
|
-
path: [${
|
|
41
|
+
path: [${x}]
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
if (${A}_present) {
|
|
46
46
|
if (${A}.value === undefined) {
|
|
47
|
-
newResult[${
|
|
47
|
+
newResult[${x}] = undefined;
|
|
48
48
|
} else {
|
|
49
|
-
newResult[${
|
|
49
|
+
newResult[${x}] = ${A}.value;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
`);else
|
|
53
|
+
`);else p.write(`
|
|
54
54
|
if (${A}.issues.length) {
|
|
55
55
|
payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
|
|
56
56
|
...iss,
|
|
57
|
-
path: iss.path ? [${
|
|
57
|
+
path: iss.path ? [${x}, ...iss.path] : [${x}]
|
|
58
58
|
})));
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
if (${A}.value === undefined) {
|
|
62
|
-
if (${
|
|
63
|
-
newResult[${
|
|
62
|
+
if (${x} in input) {
|
|
63
|
+
newResult[${x}] = undefined;
|
|
64
64
|
}
|
|
65
65
|
} else {
|
|
66
|
-
newResult[${
|
|
66
|
+
newResult[${x}] = ${A}.value;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
`)}d.write("payload.value = newResult;"),d.write("return payload;");let S=d.compile();return(x,A)=>S(p,x,A)},i,s=ut,a=!at.jitless,u=a&&Ac.value,l=t.catchall,f;e._zod.parse=(p,d)=>{f??(f=o.value);let m=p.value;if(!s(m))return p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p;if(a&&u&&d?.async===!1&&d.jitless!==!0){if(!i)i=n(t.shape);if(p=i(p,d),!l)return p;return yl([],m,p,d,f,e)}return r(p,d)}});Zr=g("$ZodUnion",(e,t)=>{P.init(e,t),T(e._zod,"optin",()=>t.options.some((o)=>o._zod.optin==="optional")?"optional":void 0),T(e._zod,"optout",()=>t.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),T(e._zod,"values",()=>{if(t.options.every((o)=>o._zod.values))return new Set(t.options.flatMap((o)=>Array.from(o._zod.values)));return}),T(e._zod,"pattern",()=>{if(t.options.every((o)=>o._zod.pattern)){let o=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${o.map((n)=>Cr(n.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return wu(s,o,e,n);return Promise.all(s).then((a)=>wu(a,o,e,n))}});_l=g("$ZodXor",(e,t)=>{Zr.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else s.push(c)}if(!i)return vu(s,o,e,n);return Promise.all(s).then((a)=>vu(a,o,e,n))}}),wl=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Zr.init(e,t);let r=e._zod.parse;T(e._zod,"propValues",()=>{let n={};for(let i of t.options){let s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[a,c]of Object.entries(s)){if(!n[a])n[a]=new Set;for(let u of c)n[a].add(u)}}return n});let o=Ot(()=>{let n=t.options,i=new Map;for(let s of n){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let c of a){if(i.has(c))throw Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,s)}}return i});e._zod.parse=(n,i)=>{let s=n.value;if(!ut(s))return n.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),n;let a=o.value.get(s?.[t.discriminator]);if(a)return a._zod.run(n,i);if(t.unionFallback||i.direction==="backward")return r(n,i);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()),input:s,path:[t.discriminator],inst:e}),n}}),vl=g("$ZodIntersection",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,i=t.left._zod.run({value:n,issues:[]},o),s=t.right._zod.run({value:n,issues:[]},o);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>xu(r,c,u));return xu(r,i,s)}});$i=g("$ZodTuple",(e,t)=>{P.init(e,t);let r=t.items;e._zod.parse=(o,n)=>{let i=o.value;if(!Array.isArray(i))return o.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=[];let s=[],a=Eu(r,"optin"),c=Eu(r,"optout");if(!t.rest){if(i.length<a)return o.issues.push({code:"too_small",minimum:a,inclusive:!0,input:i,inst:e,origin:"array"}),o;if(i.length>r.length)o.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:i,inst:e,origin:"array"})}let u=Array(r.length);for(let l=0;l<r.length;l++){let f=r[l]._zod.run({value:i[l],issues:[]},n);if(f instanceof Promise)s.push(f.then((p)=>{u[l]=p}));else u[l]=f}if(t.rest){let l=r.length-1,f=i.slice(r.length);for(let p of f){l++;let d=t.rest._zod.run({value:p,issues:[]},n);if(d instanceof Promise)s.push(d.then((m)=>Su(m,o,l)));else Su(d,o,l)}}if(s.length)return Promise.all(s).then(()=>$u(u,o,r,i,c));return $u(u,o,r,i,c)}});xl=g("$ZodRecord",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Ke(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let i=[],s=t.keyType._zod.values;if(s){r.value={};let a=new Set;for(let u of s)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){a.add(typeof u==="number"?u.toString():u);let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((d)=>te(d,o,W())),input:u,path:[u],inst:e});continue}let f=l.value,p=t.valueType._zod.run({value:n[u],issues:[]},o);if(p instanceof Promise)i.push(p.then((d)=>{if(d.issues.length)r.issues.push(...ne(u,d.issues));r.value[f]=d.value}));else{if(p.issues.length)r.issues.push(...ne(u,p.issues));r.value[f]=p.value}}let c;for(let u in n)if(!a.has(u))c=c??[],c.push(u);if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(n)){if(a==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(n,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof a==="string"&&Dr.test(a)&&c.issues.length){let f=t.keyType._zod.run({value:Number(a),issues:[]},o);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length===0)c=f}if(c.issues.length){if(t.mode==="loose")r.value[a]=n[a];else r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map((f)=>te(f,o,W())),input:a,path:[a],inst:e});continue}let l=t.valueType._zod.run({value:n[a],issues:[]},o);if(l instanceof Promise)i.push(l.then((f)=>{if(f.issues.length)r.issues.push(...ne(a,f.issues));r.value[c.value]=f.value}));else{if(l.issues.length)r.issues.push(...ne(a,l.issues));r.value[c.value]=l.value}}}if(i.length)return Promise.all(i).then(()=>r);return r}}),El=g("$ZodMap",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!(n instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),r;let i=[];r.value=new Map;for(let[s,a]of n){let c=t.keyType._zod.run({value:s,issues:[]},o),u=t.valueType._zod.run({value:a,issues:[]},o);if(c instanceof Promise||u instanceof Promise)i.push(Promise.all([c,u]).then(([l,f])=>{Au(l,f,r,s,n,e,o)}));else Au(c,u,r,s,n,e,o)}if(i.length)return Promise.all(i).then(()=>r);return r}});Sl=g("$ZodSet",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!(n instanceof Set))return r.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),r;let i=[];r.value=new Set;for(let s of n){let a=t.valueType._zod.run({value:s,issues:[]},o);if(a instanceof Promise)i.push(a.then((c)=>ku(c,r)));else ku(a,r)}if(i.length)return Promise.all(i).then(()=>r);return r}});$l=g("$ZodEnum",(e,t)=>{P.init(e,t);let r=Pr(t.entries),o=new Set(r);e._zod.values=o,e._zod.pattern=new RegExp(`^(${r.filter((n)=>Rr.has(typeof n)).map((n)=>typeof n==="string"?me(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let s=n.value;if(o.has(s))return n;return n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),Al=g("$ZodLiteral",(e,t)=>{if(P.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map((o)=>typeof o==="string"?me(o):o?me(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,n)=>{let i=o.value;if(r.has(i))return o;return o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),kl=g("$ZodFile",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(n instanceof File)return r;return r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),Pl=g("$ZodTransform",(e,t)=>{P.init(e,t),e._zod.optin="optional",e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new ct(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then((s)=>(r.value=s,r.fallback=!0,r));if(n instanceof Promise)throw new Re;return r.value=n,r.fallback=!0,r}});Ai=g("$ZodOptional",(e,t)=>{P.init(e,t),e._zod.optin="optional",e._zod.optout="optional",T(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),T(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Cr(r.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(t.innerType._zod.optin==="optional"){let n=r.value,i=t.innerType._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Pu(s,n));return Pu(i,n)}if(r.value===void 0)return r;return t.innerType._zod.run(r,o)}}),Cl=g("$ZodExactOptional",(e,t)=>{Ai.init(e,t),T(e._zod,"values",()=>t.innerType._zod.values),T(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),Rl=g("$ZodNullable",(e,t)=>{P.init(e,t),T(e._zod,"optin",()=>t.innerType._zod.optin),T(e._zod,"optout",()=>t.innerType._zod.optout),T(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Cr(r.source)}|null)$`):void 0}),T(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>{if(r.value===null)return r;return t.innerType._zod.run(r,o)}}),Tl=g("$ZodDefault",(e,t)=>{P.init(e,t),e._zod.optin="optional",T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Cu(i,t));return Cu(n,t)}});Ol=g("$ZodPrefault",(e,t)=>{P.init(e,t),e._zod.optin="optional",T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,o)}}),Il=g("$ZodNonOptional",(e,t)=>{P.init(e,t),T(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Ru(i,e));return Ru(n,e)}});Bl=g("$ZodSuccess",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new ct("ZodSuccess");let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>(r.value=i.issues.length===0,r));return r.value=n.issues.length===0,r}}),zl=g("$ZodCatch",(e,t)=>{P.init(e,t),e._zod.optin="optional",T(e._zod,"optout",()=>t.innerType._zod.optout),T(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>{if(r.value=i.value,i.issues.length)r.value=t.catchValue({...r,error:{issues:i.issues.map((s)=>te(s,o,W()))},input:r.value}),r.issues=[],r.fallback=!0;return r});if(r.value=n.value,n.issues.length)r.value=t.catchValue({...r,error:{issues:n.issues.map((i)=>te(i,o,W()))},input:r.value}),r.issues=[],r.fallback=!0;return r}}),Dl=g("$ZodNaN",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{if(typeof r.value!=="number"||!Number.isNaN(r.value))return r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r;return r}}),ki=g("$ZodPipe",(e,t)=>{P.init(e,t),T(e._zod,"values",()=>t.in._zod.values),T(e._zod,"optin",()=>t.in._zod.optin),T(e._zod,"optout",()=>t.out._zod.optout),T(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let i=t.out._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Vr(s,t.in,o));return Vr(i,t.in,o)}let n=t.in._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Vr(i,t.out,o));return Vr(n,t.out,o)}});qr=g("$ZodCodec",(e,t)=>{P.init(e,t),T(e._zod,"values",()=>t.in._zod.values),T(e._zod,"optin",()=>t.in._zod.optin),T(e._zod,"optout",()=>t.out._zod.optout),T(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if((o.direction||"forward")==="forward"){let i=t.in._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Ur(s,t,o));return Ur(i,t,o)}else{let i=t.out._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Ur(s,t,o));return Ur(i,t,o)}}});Nl=g("$ZodPreprocess",(e,t)=>{ki.init(e,t)}),Ll=g("$ZodReadonly",(e,t)=>{P.init(e,t),T(e._zod,"propValues",()=>t.innerType._zod.propValues),T(e._zod,"values",()=>t.innerType._zod.values),T(e._zod,"optin",()=>t.innerType?._zod?.optin),T(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then(Tu);return Tu(n)}});Vl=g("$ZodTemplateLiteral",(e,t)=>{P.init(e,t);let r=[];for(let o of t.parts)if(typeof o==="object"&&o!==null){if(!o._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...o._zod.traits].shift()}`);let n=o._zod.pattern instanceof RegExp?o._zod.pattern.source:o._zod.pattern;if(!n)throw Error(`Invalid template literal part: ${o._zod.traits}`);let i=n.startsWith("^")?1:0,s=n.endsWith("$")?n.length-1:n.length;r.push(n.slice(i,s))}else if(o===null||kc.has(typeof o))r.push(me(`${o}`));else throw Error(`Invalid template literal part: ${o}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(o,n)=>{if(typeof o.value!=="string")return o.issues.push({input:o.value,inst:e,expected:"string",code:"invalid_type"}),o;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(o.value))return o.issues.push({input:o.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),o;return o}}),Ul=g("$ZodFunction",(e,t)=>(P.init(e,t),e._def=t,e._zod.def=t,e.implement=(r)=>{if(typeof r!=="function")throw Error("implement() must be called with a function");return function(...o){let n=e._def.input?Fn(e._def.input,o):o,i=Reflect.apply(r,this,n);if(e._def.output)return Fn(e._def.output,i);return i}},e.implementAsync=(r)=>{if(typeof r!=="function")throw Error("implementAsync() must be called with a function");return async function(...o){let n=e._def.input?await Mn(e._def.input,o):o,i=await Reflect.apply(r,this,n);if(e._def.output)return await Mn(e._def.output,i);return i}},e._zod.parse=(r,o)=>{if(typeof r.value!=="function")return r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r;if(e._def.output&&e._def.output._zod.def.type==="promise")r.value=e.implementAsync(r.value);else r.value=e.implement(r.value);return r},e.input=(...r)=>{let o=e.constructor;if(Array.isArray(r[0]))return new o({type:"function",input:new $i({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output});return new o({type:"function",input:r[0],output:e._def.output})},e.output=(r)=>new e.constructor({type:"function",input:e._def.input,output:r}),e)),Fl=g("$ZodPromise",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>Promise.resolve(r.value).then((n)=>t.innerType._zod.run({value:n,issues:[]},o))}),Ml=g("$ZodLazy",(e,t)=>{P.init(e,t),T(e._zod,"innerType",()=>{let r=t;if(!r._cachedInner)r._cachedInner=t.getter();return r._cachedInner}),T(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),T(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),T(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),T(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,o)=>e._zod.innerType._zod.run(r,o)}),jl=g("$ZodCustom",(e,t)=>{N.init(e,t),P.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=(r)=>{let o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then((i)=>Ou(i,r,o,e));Ou(n,r,o,e);return}})});function Ci(){return{localeError:u_()}}var u_=()=>{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(n){return e[n]??null}let r={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",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=Oc(n.input),a=o[s]??s;return`Invalid input: expected ${i}, received ${a}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${Nn(n.values[0])}`;return`Invalid option: expected one of ${In(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${s.unit??"elements"}`;return`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${s.unit}`;return`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Invalid string: must start with "${i.prefix}"`;if(i.format==="ends_with")return`Invalid string: must end with "${i.suffix}"`;if(i.format==="includes")return`Invalid string: must include "${i.includes}"`;if(i.format==="regex")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${r[i.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${In(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":if(n.options&&Array.isArray(n.options)&&n.options.length>0)return`Invalid discriminator value. Expected ${n.options.map((s)=>`'${s}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};var Zl=_(()=>{ue()});var Ri=()=>{};class Wl{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let o={...r,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Gl(){return new Wl}var Ql,l_,p_,Y;var Ft=_(()=>{l_=Symbol("ZodOutput"),p_=Symbol("ZodInput");(Ql=globalThis).__zod_globalRegistry??(Ql.__zod_globalRegistry=Gl());Y=globalThis.__zod_globalRegistry});function Kl(e,t){return new e({type:"string",...w(t)})}function Ti(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...w(t)})}function Qr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...w(t)})}function Oi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...w(t)})}function Ii(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...w(t)})}function Bi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...w(t)})}function zi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...w(t)})}function Wr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...w(t)})}function Di(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...w(t)})}function Ni(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...w(t)})}function Li(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...w(t)})}function Vi(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...w(t)})}function Ui(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...w(t)})}function Fi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...w(t)})}function Mi(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...w(t)})}function ji(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...w(t)})}function Zi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...w(t)})}function Hl(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...w(t)})}function qi(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...w(t)})}function Qi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...w(t)})}function Wi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...w(t)})}function Gi(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...w(t)})}function Ki(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...w(t)})}function Hi(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...w(t)})}function Jl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...w(t)})}function Yl(e,t){return new e({type:"string",format:"date",check:"string_format",...w(t)})}function Xl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...w(t)})}function ep(e,t){return new e({type:"string",format:"duration",check:"string_format",...w(t)})}function tp(e,t){return new e({type:"number",checks:[],...w(t)})}function rp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...w(t)})}function op(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...w(t)})}function np(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...w(t)})}function ip(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...w(t)})}function sp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...w(t)})}function ap(e,t){return new e({type:"boolean",...w(t)})}function cp(e,t){return new e({type:"bigint",...w(t)})}function up(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...w(t)})}function lp(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...w(t)})}function pp(e,t){return new e({type:"symbol",...w(t)})}function dp(e,t){return new e({type:"undefined",...w(t)})}function fp(e,t){return new e({type:"null",...w(t)})}function mp(e){return new e({type:"any"})}function hp(e){return new e({type:"unknown"})}function gp(e,t){return new e({type:"never",...w(t)})}function yp(e,t){return new e({type:"void",...w(t)})}function bp(e,t){return new e({type:"date",...w(t)})}function _p(e,t){return new e({type:"nan",...w(t)})}function De(e,t){return new bi({check:"less_than",...w(t),value:e,inclusive:!1})}function ge(e,t){return new bi({check:"less_than",...w(t),value:e,inclusive:!0})}function Ne(e,t){return new _i({check:"greater_than",...w(t),value:e,inclusive:!1})}function ie(e,t){return new _i({check:"greater_than",...w(t),value:e,inclusive:!0})}function wp(e){return Ne(0,e)}function vp(e){return De(0,e)}function xp(e){return ge(0,e)}function Ep(e){return ie(0,e)}function pt(e,t){return new Xc({check:"multiple_of",...w(t),value:e})}function dt(e,t){return new ru({check:"max_size",...w(t),maximum:e})}function Le(e,t){return new ou({check:"min_size",...w(t),minimum:e})}function Mt(e,t){return new nu({check:"size_equals",...w(t),size:e})}function jt(e,t){return new iu({check:"max_length",...w(t),maximum:e})}function et(e,t){return new su({check:"min_length",...w(t),minimum:e})}function Zt(e,t){return new au({check:"length_equals",...w(t),length:e})}function Gr(e,t){return new cu({check:"string_format",format:"regex",...w(t),pattern:e})}function Kr(e){return new uu({check:"string_format",format:"lowercase",...w(e)})}function Hr(e){return new lu({check:"string_format",format:"uppercase",...w(e)})}function Jr(e,t){return new pu({check:"string_format",format:"includes",...w(t),includes:e})}function Yr(e,t){return new du({check:"string_format",format:"starts_with",...w(t),prefix:e})}function Xr(e,t){return new fu({check:"string_format",format:"ends_with",...w(t),suffix:e})}function Sp(e,t,r){return new mu({check:"property",property:e,schema:t,...w(r)})}function eo(e,t){return new hu({check:"mime_type",mime:e,...w(t)})}function Te(e){return new gu({check:"overwrite",tx:e})}function to(e){return Te((t)=>t.normalize(e))}function ro(){return Te((e)=>e.trim())}function oo(){return Te((e)=>e.toLowerCase())}function no(){return Te((e)=>e.toUpperCase())}function io(){return Te((e)=>$c(e))}function $p(e,t,r){return new e({type:"array",element:t,...w(r)})}function Ap(e,t){return new e({type:"file",...w(t)})}function kp(e,t,r){let o=w(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Pp(e,t,r){return new e({type:"custom",check:"custom",fn:t,...w(r)})}function Cp(e,t){let r=f_((o)=>(o.addIssue=(n)=>{if(typeof n==="string")o.issues.push(Je(n,o.value,r._zod.def));else{let i=n;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=o.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),o.issues.push(Je(i))}},e(o.value,o)),t);return r}function f_(e,t){let r=new N({check:"custom",...w(t)});return r._zod.check=e,r}function Rp(e){let t=new N({check:"describe"});return t._zod.onattach=[(r)=>{let o=Y.get(r)??{};Y.add(r,{...o,description:e})}],t._zod.check=()=>{},t}function Tp(e){let t=new N({check:"meta"});return t._zod.onattach=[(r)=>{let o=Y.get(r)??{};Y.add(r,{...o,...e})}],t._zod.check=()=>{},t}function Op(e,t){let r=w(t),o=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];if(r.case!=="sensitive")o=o.map((d)=>typeof d==="string"?d.toLowerCase():d),n=n.map((d)=>typeof d==="string"?d.toLowerCase():d);let i=new Set(o),s=new Set(n),a=e.Codec??qr,c=e.Boolean??jr,l=new(e.String??lt)({type:"string",error:r.error}),f=new c({type:"boolean",error:r.error}),p=new a({type:"pipe",in:l,out:f,transform:(d,m)=>{let h=d;if(r.case!=="sensitive")h=h.toLowerCase();if(i.has(h))return!0;else if(s.has(h))return!1;else return m.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...s],input:m.value,inst:p,continue:!1}),{}},reverseTransform:(d,m)=>{if(d===!0)return o[0]||"true";else return n[0]||"false"},error:r.error});return p}function qt(e,t,r,o={}){let n=w(o),i={...w(o),check:"string_format",type:"string",format:t,fn:typeof r==="function"?r:(a)=>r.test(a),...n};if(r instanceof RegExp)i.pattern=r;return new e(i)}var Ip=_(()=>{Lr();Ft();Pi();ue()});function Ji(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Y,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function U(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,r.schemaPath.includes(e))i.cycle=r.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{let p=s.schema,d=t.processors[n.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);d(e,t,p,l)}let f=e._zod.parent;if(f){if(!s.ref)s.ref=f;U(f,t,l),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Object.assign(s.schema,c);if(t.io==="input"&&X(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(o=s.schema).default??(o.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function Yi(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=o.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,s[0])}}let n=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(s[0])?.id,p=e.external.uri??((m)=>m);if(f)return{ref:p(f)};let d=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=d,{defId:d,ref:`${p("__shared")}#/${a}/${d}`}}if(s[1]===r)return{ref:"#"};let u=`${"#"}/${a}/`,l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=n(s);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let f in l)delete l[f];l.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
70
|
-
|
|
71
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref"){i(s);continue}}}}function Xi(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},f=c.ref;if(c.ref=null,f){o(f);let d=e.seen.get(f),m=d.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(m);else Object.assign(u,m);if(Object.assign(u,l),a._zod.parent===f)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(!(y in l))delete u[y]}if(m.$ref&&d.def)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(y in d.def&&JSON.stringify(u[y])===JSON.stringify(d.def[y]))delete u[y]}}let p=a._zod.parent;if(p&&p!==f){o(p);let d=e.seen.get(p);if(d?.schema.$ref){if(u.$ref=d.schema.$ref,d.def)for(let m in u){if(m==="$ref"||m==="allOf")continue;if(m in d.def&&JSON.stringify(u[m])===JSON.stringify(d.def[m]))delete u[m]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())o(a[0]);let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}Object.assign(n,r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&n.id===i)delete n.id;let s=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;s[c.defId]=c.def}}if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")n.$defs=s;else n.definitions=s;try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Qt(t,"input",e.processors),output:Qt(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function X(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return X(o.element,r);if(o.type==="set")return X(o.valueType,r);if(o.type==="lazy")return X(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return X(o.innerType,r);if(o.type==="intersection")return X(o.left,r)||X(o.right,r);if(o.type==="record"||o.type==="map")return X(o.keyType,r)||X(o.valueType,r);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return X(o.in,r)||X(o.out,r)}if(o.type==="object"){for(let n in o.shape)if(X(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(X(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(X(n,r))return!0;if(o.rest&&X(o.rest,r))return!0;return!1}return!1}var Bp=(e,t={})=>(r)=>{let o=Ji({...r,processors:t});return U(e,o),Yi(o,e),Xi(o,e)},Qt=(e,t,r={})=>(o)=>{let{libraryOptions:n,target:i}=o??{},s=Ji({...n??{},target:i,io:t,processors:r});return U(e,s),Yi(s,e),Xi(s,e)};var so=_(()=>{Ft()});var m_,zp=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i==="number")n.minLength=i;if(typeof s==="number")n.maxLength=s;if(a){if(n.format=m_[a]??a,n.format==="")delete n.format;if(a==="time")delete n.format}if(u)n.contentEncoding=u;if(c&&c.size>0){let l=[...c];if(l.length===1)n.pattern=l[0].source;else if(l.length>1)n.allOf=[...l.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},Dp=(e,t,r,o)=>{let n=r,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;if(typeof a==="string"&&a.includes("int"))n.type="integer";else n.type="number";let f=typeof l==="number"&&l>=(i??Number.NEGATIVE_INFINITY),p=typeof u==="number"&&u<=(s??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(d)n.minimum=l,n.exclusiveMinimum=!0;else n.exclusiveMinimum=l;else if(typeof i==="number")n.minimum=i;if(p)if(d)n.maximum=u,n.exclusiveMaximum=!0;else n.exclusiveMaximum=u;else if(typeof s==="number")n.maximum=s;if(typeof c==="number")n.multipleOf=c},Np=(e,t,r,o)=>{r.type="boolean"},Lp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},Vp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},Up=(e,t,r,o)=>{if(t.target==="openapi-3.0")r.type="string",r.nullable=!0,r.enum=[null];else r.type="null"},Fp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},Mp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},jp=(e,t,r,o)=>{r.not={}},Zp=(e,t,r,o)=>{},qp=(e,t,r,o)=>{},Qp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},Wp=(e,t,r,o)=>{let n=e._zod.def,i=Pr(n.entries);if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";r.enum=i},Gp=(e,t,r,o)=>{let n=e._zod.def,i=[];for(let s of n.values)if(s===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else i.push(Number(s));else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[s];else r.const=s}else{if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";if(i.every((s)=>typeof s==="boolean"))r.type="boolean";if(i.every((s)=>s===null))r.type="null";r.enum=i}},Kp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},Hp=(e,t,r,o)=>{let n=r,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},Jp=(e,t,r,o)=>{let n=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=e._zod.bag;if(s!==void 0)i.minLength=s;if(a!==void 0)i.maxLength=a;if(c)if(c.length===1)i.contentMediaType=c[0],Object.assign(n,i);else Object.assign(n,i),n.anyOf=c.map((u)=>({contentMediaType:u}));else Object.assign(n,i)},Yp=(e,t,r,o)=>{r.type="boolean"},Xp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},ed=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},td=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},rd=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},od=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},nd=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;if(typeof s==="number")n.minItems=s;if(typeof a==="number")n.maxItems=a;n.type="array",n.items=U(i.element,t,{...o,path:[...o.path,"items"]})},id=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object",n.properties={};let s=i.shape;for(let u in s)n.properties[u]=U(s[u],t,{...o,path:[...o.path,"properties",u]});let a=new Set(Object.keys(s)),c=new Set([...a].filter((u)=>{let l=i.shape[u]._zod;if(t.io==="input")return l.optin===void 0;else return l.optout===void 0}));if(c.size>0)n.required=Array.from(c);if(i.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")n.additionalProperties=!1}else if(i.catchall)n.additionalProperties=U(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},es=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((a,c)=>U(a,t,{...o,path:[...o.path,i?"oneOf":"anyOf",c]}));if(i)r.oneOf=s;else r.anyOf=s},sd=(e,t,r,o)=>{let n=e._zod.def,i=U(n.left,t,{...o,path:[...o.path,"allOf",0]}),s=U(n.right,t,{...o,path:[...o.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=c},ad=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((p,d)=>U(p,t,{...o,path:[...o.path,s,d]})),u=i.rest?U(i.rest,t,{...o,path:[...o.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(n.prefixItems=c,u)n.items=u}else if(t.target==="openapi-3.0"){if(n.items={anyOf:c},u)n.items.anyOf.push(u);if(n.minItems=c.length,!u)n.maxItems=c.length}else if(n.items=c,u)n.additionalItems=u;let{minimum:l,maximum:f}=e._zod.bag;if(typeof l==="number")n.minItems=l;if(typeof f==="number")n.maxItems=f},cd=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let s=i.keyType,c=s._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){let l=U(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let f of c)n.patternProperties[f.source]=l}else{if(t.target==="draft-07"||t.target==="draft-2020-12")n.propertyNames=U(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});n.additionalProperties=U(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let u=s._zod.values;if(u){let l=[...u].filter((f)=>typeof f==="string"||typeof f==="number");if(l.length>0)n.required=l}},ud=(e,t,r,o)=>{let n=e._zod.def,i=U(n.innerType,t,o),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=n.innerType,r.nullable=!0;else r.anyOf=[i,{type:"null"}]},ld=(e,t,r,o)=>{let n=e._zod.def;U(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},pd=(e,t,r,o)=>{let n=e._zod.def;U(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},dd=(e,t,r,o)=>{let n=e._zod.def;U(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io==="input")r._prefault=JSON.parse(JSON.stringify(n.defaultValue))},fd=(e,t,r,o)=>{let n=e._zod.def;U(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let s;try{s=n.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},md=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?n.out:n.in:n.out;U(s,t,o);let a=t.seen.get(e);a.ref=s},hd=(e,t,r,o)=>{let n=e._zod.def;U(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},gd=(e,t,r,o)=>{let n=e._zod.def;U(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},ts=(e,t,r,o)=>{let n=e._zod.def;U(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},yd=(e,t,r,o)=>{let n=e._zod.innerType;U(n,t,o);let i=t.seen.get(e);i.ref=n};var bd=_(()=>{so();ue();m_={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""}});var _d=()=>{};var ye=_(()=>{ue();Nr();Ri();_d();Qe();jn();Un();Pi();Lr();vi();Ft();Ip();so()});var ao={};vr(ao,{endsWith:()=>Xr,gt:()=>Ne,gte:()=>ie,includes:()=>Jr,length:()=>Zt,lowercase:()=>Kr,lt:()=>De,lte:()=>ge,maxLength:()=>jt,maxSize:()=>dt,mime:()=>eo,minLength:()=>et,minSize:()=>Le,multipleOf:()=>pt,negative:()=>vp,nonnegative:()=>Ep,nonpositive:()=>xp,normalize:()=>to,overwrite:()=>Te,positive:()=>wp,property:()=>Sp,regex:()=>Gr,size:()=>Mt,slugify:()=>io,startsWith:()=>Yr,toLowerCase:()=>oo,toUpperCase:()=>no,trim:()=>ro,uppercase:()=>Hr});var co=_(()=>{ye()});var Gt={};vr(Gt,{ZodISODate:()=>vd,ZodISODateTime:()=>wd,ZodISODuration:()=>Ed,ZodISOTime:()=>xd,date:()=>os,datetime:()=>rs,duration:()=>is,time:()=>ns});function rs(e){return Jl(wd,e)}function os(e){return Yl(vd,e)}function ns(e){return Xl(xd,e)}function is(e){return ep(Ed,e)}var wd,vd,xd,Ed;var uo=_(()=>{ye();po();wd=g("ZodISODateTime",(e,t)=>{Zu.init(e,t),z.init(e,t)});vd=g("ZodISODate",(e,t)=>{qu.init(e,t),z.init(e,t)});xd=g("ZodISOTime",(e,t)=>{Qu.init(e,t),z.init(e,t)});Ed=g("ZodISODuration",(e,t)=>{Wu.init(e,t),z.init(e,t)})});var Sd=(e,t)=>{Ir.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(r)=>Vn(e,r)},flatten:{value:(r)=>Ln(e,r)},addIssue:{value:(r)=>{e.issues.push(r),e.message=JSON.stringify(e.issues,Tt,2)}},addIssues:{value:(r)=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,Tt,2)}},isEmpty:{get(){return e.issues.length===0}}})},$d,se;var ss=_(()=>{ye();ye();ue();$d=g("ZodError",Sd),se=g("ZodError",Sd,{Parent:Error})});var Ad,kd,Pd,Cd,Rd,Td,Od,Id,Bd,zd,Dd,Nd;var as=_(()=>{ye();ss();Ad=Bt(se),kd=zt(se),Pd=Dt(se),Cd=Nt(se),Rd=Nc(se),Td=Lc(se),Od=Vc(se),Id=Uc(se),Bd=Fc(se),zd=Mc(se),Dd=jc(se),Nd=Zc(se)});var lo={};vr(lo,{ZodAny:()=>Qd,ZodArray:()=>Jd,ZodBase64:()=>Ss,ZodBase64URL:()=>$s,ZodBigInt:()=>Rs,ZodBigIntFormat:()=>Ts,ZodBoolean:()=>Cs,ZodCIDRv4:()=>xs,ZodCIDRv6:()=>Es,ZodCUID:()=>hs,ZodCUID2:()=>gs,ZodCatch:()=>wf,ZodCodec:()=>xo,ZodCustom:()=>Eo,ZodCustomStringFormat:()=>Yt,ZodDate:()=>Hd,ZodDefault:()=>mf,ZodDiscriminatedUnion:()=>Xd,ZodE164:()=>As,ZodEmail:()=>ds,ZodEmoji:()=>fs,ZodEnum:()=>Ht,ZodExactOptional:()=>pf,ZodFile:()=>uf,ZodFunction:()=>Rf,ZodGUID:()=>mo,ZodIPv4:()=>ws,ZodIPv6:()=>vs,ZodIntersection:()=>ef,ZodJWT:()=>ks,ZodKSUID:()=>_s,ZodLazy:()=>kf,ZodLiteral:()=>cf,ZodMAC:()=>Vd,ZodMap:()=>sf,ZodNaN:()=>xf,ZodNanoID:()=>ms,ZodNever:()=>Gd,ZodNonOptional:()=>Ns,ZodNull:()=>Zd,ZodNullable:()=>ff,ZodNumber:()=>Ps,ZodNumberFormat:()=>mt,ZodObject:()=>_o,ZodOptional:()=>Ds,ZodPipe:()=>vo,ZodPrefault:()=>gf,ZodPreprocess:()=>Ef,ZodPromise:()=>Cf,ZodReadonly:()=>Sf,ZodRecord:()=>Kt,ZodSet:()=>af,ZodString:()=>ps,ZodStringFormat:()=>z,ZodSuccess:()=>_f,ZodSymbol:()=>Md,ZodTemplateLiteral:()=>Af,ZodTransform:()=>lf,ZodTuple:()=>rf,ZodType:()=>C,ZodULID:()=>ys,ZodURL:()=>yo,ZodUUID:()=>Oe,ZodUndefined:()=>jd,ZodUnion:()=>wo,ZodUnknown:()=>Wd,ZodVoid:()=>Kd,ZodXID:()=>bs,ZodXor:()=>Yd,_ZodString:()=>ls,_default:()=>hf,_function:()=>Ew,any:()=>ew,array:()=>bo,base64:()=>N_,base64url:()=>L_,bigint:()=>K_,boolean:()=>Fd,catch:()=>vf,check:()=>Sw,cidrv4:()=>z_,cidrv6:()=>D_,codec:()=>_w,cuid:()=>k_,cuid2:()=>P_,custom:()=>$w,date:()=>rw,describe:()=>Aw,discriminatedUnion:()=>cw,e164:()=>V_,email:()=>y_,emoji:()=>$_,enum:()=>Bs,exactOptional:()=>df,file:()=>hw,float32:()=>q_,float64:()=>Q_,function:()=>Ew,guid:()=>b_,hash:()=>Z_,hex:()=>j_,hostname:()=>M_,httpUrl:()=>S_,instanceof:()=>Pw,int:()=>cs,int32:()=>W_,int64:()=>H_,intersection:()=>tf,invertCodec:()=>ww,ipv4:()=>O_,ipv6:()=>B_,json:()=>Rw,jwt:()=>U_,keyof:()=>ow,ksuid:()=>T_,lazy:()=>Pf,literal:()=>mw,looseObject:()=>sw,looseRecord:()=>lw,mac:()=>I_,map:()=>pw,meta:()=>kw,nan:()=>bw,nanoid:()=>A_,nativeEnum:()=>fw,never:()=>Os,nonoptional:()=>bf,null:()=>qd,nullable:()=>go,nullish:()=>gw,number:()=>Ud,object:()=>nw,optional:()=>ho,partialRecord:()=>uw,pipe:()=>us,prefault:()=>yf,preprocess:()=>Tw,promise:()=>xw,readonly:()=>$f,record:()=>nf,refine:()=>Tf,set:()=>dw,strictObject:()=>iw,string:()=>fo,stringFormat:()=>F_,stringbool:()=>Cw,success:()=>yw,superRefine:()=>Of,symbol:()=>Y_,templateLiteral:()=>vw,transform:()=>zs,tuple:()=>of,uint32:()=>G_,uint64:()=>J_,ulid:()=>C_,undefined:()=>X_,union:()=>Is,unknown:()=>ft,url:()=>E_,uuid:()=>__,uuidv4:()=>w_,uuidv6:()=>v_,uuidv7:()=>x_,void:()=>tw,xid:()=>R_,xor:()=>aw});function Jt(e,t,r){let o=Object.getPrototypeOf(e),n=Ld.get(o);if(!n)n=new Set,Ld.set(o,n);if(n.has(t))return;n.add(t);for(let i in r){let s=r[i];Object.defineProperty(o,i,{configurable:!0,enumerable:!1,get(){let a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}function fo(e){return Kl(ps,e)}function y_(e){return Ti(ds,e)}function b_(e){return Qr(mo,e)}function __(e){return Oi(Oe,e)}function w_(e){return Ii(Oe,e)}function v_(e){return Bi(Oe,e)}function x_(e){return zi(Oe,e)}function E_(e){return Wr(yo,e)}function S_(e){return Wr(yo,{protocol:zr,hostname:Wc,...w(e)})}function $_(e){return Di(fs,e)}function A_(e){return Ni(ms,e)}function k_(e){return Li(hs,e)}function P_(e){return Vi(gs,e)}function C_(e){return Ui(ys,e)}function R_(e){return Fi(bs,e)}function T_(e){return Mi(_s,e)}function O_(e){return ji(ws,e)}function I_(e){return Hl(Vd,e)}function B_(e){return Zi(vs,e)}function z_(e){return qi(xs,e)}function D_(e){return Qi(Es,e)}function N_(e){return Wi(Ss,e)}function L_(e){return Gi($s,e)}function V_(e){return Ki(As,e)}function U_(e){return Hi(ks,e)}function F_(e,t,r={}){return qt(Yt,e,t,r)}function M_(e){return qt(Yt,"hostname",Qc,e)}function j_(e){return qt(Yt,"hex",Hc,e)}function Z_(e,t){let r=t?.enc??"hex",o=`${e}_${r}`,n=Xe[o];if(!n)throw Error(`Unrecognized hash format: ${o}`);return qt(Yt,o,n,t)}function Ud(e){return tp(Ps,e)}function cs(e){return rp(mt,e)}function q_(e){return op(mt,e)}function Q_(e){return np(mt,e)}function W_(e){return ip(mt,e)}function G_(e){return sp(mt,e)}function Fd(e){return ap(Cs,e)}function K_(e){return cp(Rs,e)}function H_(e){return up(Ts,e)}function J_(e){return lp(Ts,e)}function Y_(e){return pp(Md,e)}function X_(e){return dp(jd,e)}function qd(e){return fp(Zd,e)}function ew(){return mp(Qd)}function ft(){return hp(Wd)}function Os(e){return gp(Gd,e)}function tw(e){return yp(Kd,e)}function rw(e){return bp(Hd,e)}function bo(e,t){return $p(Jd,e,t)}function ow(e){let t=e._zod.def.shape;return Bs(Object.keys(t))}function nw(e,t){let r={type:"object",shape:e??{},...w(t)};return new _o(r)}function iw(e,t){return new _o({type:"object",shape:e,catchall:Os(),...w(t)})}function sw(e,t){return new _o({type:"object",shape:e,catchall:ft(),...w(t)})}function Is(e,t){return new wo({type:"union",options:e,...w(t)})}function aw(e,t){return new Yd({type:"union",options:e,inclusive:!1,...w(t)})}function cw(e,t,r){return new Xd({type:"union",options:t,discriminator:e,...w(r)})}function tf(e,t){return new ef({type:"intersection",left:e,right:t})}function of(e,t,r){let o=t instanceof P,n=o?r:t;return new rf({type:"tuple",items:e,rest:o?t:null,...w(n)})}function nf(e,t,r){if(!t||!t._zod)return new Kt({type:"record",keyType:fo(),valueType:e,...w(t)});return new Kt({type:"record",keyType:e,valueType:t,...w(r)})}function uw(e,t,r){let o=ce(e);return o._zod.values=void 0,new Kt({type:"record",keyType:o,valueType:t,...w(r)})}function lw(e,t,r){return new Kt({type:"record",keyType:e,valueType:t,mode:"loose",...w(r)})}function pw(e,t,r){return new sf({type:"map",keyType:e,valueType:t,...w(r)})}function dw(e,t){return new af({type:"set",valueType:e,...w(t)})}function Bs(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new Ht({type:"enum",entries:r,...w(t)})}function fw(e,t){return new Ht({type:"enum",entries:e,...w(t)})}function mw(e,t){return new cf({type:"literal",values:Array.isArray(e)?e:[e],...w(t)})}function hw(e){return Ap(uf,e)}function zs(e){return new lf({type:"transform",transform:e})}function ho(e){return new Ds({type:"optional",innerType:e})}function df(e){return new pf({type:"optional",innerType:e})}function go(e){return new ff({type:"nullable",innerType:e})}function gw(e){return ho(go(e))}function hf(e,t){return new mf({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Dn(t)}})}function yf(e,t){return new gf({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Dn(t)}})}function bf(e,t){return new Ns({type:"nonoptional",innerType:e,...w(t)})}function yw(e){return new _f({type:"success",innerType:e})}function vf(e,t){return new wf({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}function bw(e){return _p(xf,e)}function us(e,t){return new vo({type:"pipe",in:e,out:t})}function _w(e,t,r){return new xo({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function ww(e){let t=e._zod.def;return new xo({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}function $f(e){return new Sf({type:"readonly",innerType:e})}function vw(e,t){return new Af({type:"template_literal",parts:e,...w(t)})}function Pf(e){return new kf({type:"lazy",getter:e})}function xw(e){return new Cf({type:"promise",innerType:e})}function Ew(e){return new Rf({type:"function",input:Array.isArray(e?.input)?of(e?.input):e?.input??bo(ft()),output:e?.output??ft()})}function Sw(e){let t=new N({check:"custom"});return t._zod.check=e,t}function $w(e,t){return kp(Eo,e??(()=>!0),t)}function Tf(e,t={}){return Pp(Eo,e,t)}function Of(e,t){return Cp(e,t)}function Pw(e,t={}){let r=new Eo({type:"custom",check:"custom",fn:(o)=>o instanceof e,abort:!0,...w(t)});return r._zod.bag.Class=e,r._zod.check=(o)=>{if(!(o.value instanceof e))o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:r,path:[...r._zod.def.path??[]]})},r}function Rw(e){let t=Pf(()=>Is([fo(e),Ud(),Fd(),qd(),bo(t),nf(fo(),t)]));return t}function Tw(e,t){return new Ef({type:"pipe",in:zs(e),out:t})}var Ld,C,ls,ps,z,ds,mo,Oe,yo,fs,ms,hs,gs,ys,bs,_s,ws,Vd,vs,xs,Es,Ss,$s,As,ks,Yt,Ps,mt,Cs,Rs,Ts,Md,jd,Zd,Qd,Wd,Gd,Kd,Hd,Jd,_o,wo,Yd,Xd,ef,rf,Kt,sf,af,Ht,cf,uf,lf,Ds,pf,ff,mf,gf,Ns,_f,wf,xf,vo,xo,Ef,Sf,Af,kf,Cf,Rf,Eo,Aw,kw,Cw=(...e)=>Op({Codec:xo,Boolean:Cs,String:ps},...e);var po=_(()=>{ye();ye();bd();so();co();uo();as();Ld=new WeakMap;C=g("ZodType",(e,t)=>(P.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Qt(e,"input"),output:Qt(e,"output")}}),e.toJSONSchema=Bp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,o)=>Ad(e,r,o,{callee:e.parse}),e.safeParse=(r,o)=>Pd(e,r,o),e.parseAsync=async(r,o)=>kd(e,r,o,{callee:e.parseAsync}),e.safeParseAsync=async(r,o)=>Cd(e,r,o),e.spa=e.safeParseAsync,e.encode=(r,o)=>Rd(e,r,o),e.decode=(r,o)=>Td(e,r,o),e.encodeAsync=async(r,o)=>Od(e,r,o),e.decodeAsync=async(r,o)=>Id(e,r,o),e.safeEncode=(r,o)=>Bd(e,r,o),e.safeDecode=(r,o)=>zd(e,r,o),e.safeEncodeAsync=async(r,o)=>Dd(e,r,o),e.safeDecodeAsync=async(r,o)=>Nd(e,r,o),Jt(e,"ZodType",{check(...r){let o=this.def;return this.clone(ze(o,{checks:[...o.checks??[],...r.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,o){return ce(this,r,o)},brand(){return this},register(r,o){return r.add(this,o),this},refine(r,o){return this.check(Tf(r,o))},superRefine(r,o){return this.check(Of(r,o))},overwrite(r){return this.check(Te(r))},optional(){return ho(this)},exactOptional(){return df(this)},nullable(){return go(this)},nullish(){return ho(go(this))},nonoptional(r){return bf(this,r)},array(){return bo(this)},or(r){return Is([this,r])},and(r){return tf(this,r)},transform(r){return us(this,zs(r))},default(r){return hf(this,r)},prefault(r){return yf(this,r)},catch(r){return vf(this,r)},pipe(r){return us(this,r)},readonly(){return $f(this)},describe(r){let o=this.clone();return Y.add(o,{description:r}),o},meta(...r){if(r.length===0)return Y.get(this);let o=this.clone();return Y.add(o,r[0]),o},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return Y.get(e)?.description},configurable:!0}),e)),ls=g("_ZodString",(e,t)=>{lt.init(e,t),C.init(e,t),e._zod.processJSONSchema=(o,n,i)=>zp(e,o,n,i);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,Jt(e,"_ZodString",{regex(...o){return this.check(Gr(...o))},includes(...o){return this.check(Jr(...o))},startsWith(...o){return this.check(Yr(...o))},endsWith(...o){return this.check(Xr(...o))},min(...o){return this.check(et(...o))},max(...o){return this.check(jt(...o))},length(...o){return this.check(Zt(...o))},nonempty(...o){return this.check(et(1,...o))},lowercase(o){return this.check(Kr(o))},uppercase(o){return this.check(Hr(o))},trim(){return this.check(ro())},normalize(...o){return this.check(to(...o))},toLowerCase(){return this.check(oo())},toUpperCase(){return this.check(no())},slugify(){return this.check(io())}})}),ps=g("ZodString",(e,t)=>{lt.init(e,t),ls.init(e,t),e.email=(r)=>e.check(Ti(ds,r)),e.url=(r)=>e.check(Wr(yo,r)),e.jwt=(r)=>e.check(Hi(ks,r)),e.emoji=(r)=>e.check(Di(fs,r)),e.guid=(r)=>e.check(Qr(mo,r)),e.uuid=(r)=>e.check(Oi(Oe,r)),e.uuidv4=(r)=>e.check(Ii(Oe,r)),e.uuidv6=(r)=>e.check(Bi(Oe,r)),e.uuidv7=(r)=>e.check(zi(Oe,r)),e.nanoid=(r)=>e.check(Ni(ms,r)),e.guid=(r)=>e.check(Qr(mo,r)),e.cuid=(r)=>e.check(Li(hs,r)),e.cuid2=(r)=>e.check(Vi(gs,r)),e.ulid=(r)=>e.check(Ui(ys,r)),e.base64=(r)=>e.check(Wi(Ss,r)),e.base64url=(r)=>e.check(Gi($s,r)),e.xid=(r)=>e.check(Fi(bs,r)),e.ksuid=(r)=>e.check(Mi(_s,r)),e.ipv4=(r)=>e.check(ji(ws,r)),e.ipv6=(r)=>e.check(Zi(vs,r)),e.cidrv4=(r)=>e.check(qi(xs,r)),e.cidrv6=(r)=>e.check(Qi(Es,r)),e.e164=(r)=>e.check(Ki(As,r)),e.datetime=(r)=>e.check(rs(r)),e.date=(r)=>e.check(os(r)),e.time=(r)=>e.check(ns(r)),e.duration=(r)=>e.check(is(r))});z=g("ZodStringFormat",(e,t)=>{B.init(e,t),ls.init(e,t)}),ds=g("ZodEmail",(e,t)=>{zu.init(e,t),z.init(e,t)});mo=g("ZodGUID",(e,t)=>{Iu.init(e,t),z.init(e,t)});Oe=g("ZodUUID",(e,t)=>{Bu.init(e,t),z.init(e,t)});yo=g("ZodURL",(e,t)=>{Du.init(e,t),z.init(e,t)});fs=g("ZodEmoji",(e,t)=>{Nu.init(e,t),z.init(e,t)});ms=g("ZodNanoID",(e,t)=>{Lu.init(e,t),z.init(e,t)});hs=g("ZodCUID",(e,t)=>{Vu.init(e,t),z.init(e,t)});gs=g("ZodCUID2",(e,t)=>{Uu.init(e,t),z.init(e,t)});ys=g("ZodULID",(e,t)=>{Fu.init(e,t),z.init(e,t)});bs=g("ZodXID",(e,t)=>{Mu.init(e,t),z.init(e,t)});_s=g("ZodKSUID",(e,t)=>{ju.init(e,t),z.init(e,t)});ws=g("ZodIPv4",(e,t)=>{Gu.init(e,t),z.init(e,t)});Vd=g("ZodMAC",(e,t)=>{Hu.init(e,t),z.init(e,t)});vs=g("ZodIPv6",(e,t)=>{Ku.init(e,t),z.init(e,t)});xs=g("ZodCIDRv4",(e,t)=>{Ju.init(e,t),z.init(e,t)});Es=g("ZodCIDRv6",(e,t)=>{Yu.init(e,t),z.init(e,t)});Ss=g("ZodBase64",(e,t)=>{el.init(e,t),z.init(e,t)});$s=g("ZodBase64URL",(e,t)=>{tl.init(e,t),z.init(e,t)});As=g("ZodE164",(e,t)=>{rl.init(e,t),z.init(e,t)});ks=g("ZodJWT",(e,t)=>{ol.init(e,t),z.init(e,t)});Yt=g("ZodCustomStringFormat",(e,t)=>{nl.init(e,t),z.init(e,t)});Ps=g("ZodNumber",(e,t)=>{Ei.init(e,t),C.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Dp(e,o,n,i),Jt(e,"ZodNumber",{gt(o,n){return this.check(Ne(o,n))},gte(o,n){return this.check(ie(o,n))},min(o,n){return this.check(ie(o,n))},lt(o,n){return this.check(De(o,n))},lte(o,n){return this.check(ge(o,n))},max(o,n){return this.check(ge(o,n))},int(o){return this.check(cs(o))},safe(o){return this.check(cs(o))},positive(o){return this.check(Ne(0,o))},nonnegative(o){return this.check(ie(0,o))},negative(o){return this.check(De(0,o))},nonpositive(o){return this.check(ge(0,o))},multipleOf(o,n){return this.check(pt(o,n))},step(o,n){return this.check(pt(o,n))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??0.5),e.isFinite=!0,e.format=r.format??null});mt=g("ZodNumberFormat",(e,t)=>{il.init(e,t),Ps.init(e,t)});Cs=g("ZodBoolean",(e,t)=>{jr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Np(e,r,o,n)});Rs=g("ZodBigInt",(e,t)=>{Si.init(e,t),C.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Lp(e,o,n,i),e.gte=(o,n)=>e.check(ie(o,n)),e.min=(o,n)=>e.check(ie(o,n)),e.gt=(o,n)=>e.check(Ne(o,n)),e.gte=(o,n)=>e.check(ie(o,n)),e.min=(o,n)=>e.check(ie(o,n)),e.lt=(o,n)=>e.check(De(o,n)),e.lte=(o,n)=>e.check(ge(o,n)),e.max=(o,n)=>e.check(ge(o,n)),e.positive=(o)=>e.check(Ne(BigInt(0),o)),e.negative=(o)=>e.check(De(BigInt(0),o)),e.nonpositive=(o)=>e.check(ge(BigInt(0),o)),e.nonnegative=(o)=>e.check(ie(BigInt(0),o)),e.multipleOf=(o,n)=>e.check(pt(o,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});Ts=g("ZodBigIntFormat",(e,t)=>{sl.init(e,t),Rs.init(e,t)});Md=g("ZodSymbol",(e,t)=>{al.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Vp(e,r,o,n)});jd=g("ZodUndefined",(e,t)=>{cl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Fp(e,r,o,n)});Zd=g("ZodNull",(e,t)=>{ul.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Up(e,r,o,n)});Qd=g("ZodAny",(e,t)=>{ll.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Zp(e,r,o,n)});Wd=g("ZodUnknown",(e,t)=>{pl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qp(e,r,o,n)});Gd=g("ZodNever",(e,t)=>{dl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>jp(e,r,o,n)});Kd=g("ZodVoid",(e,t)=>{fl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Mp(e,r,o,n)});Hd=g("ZodDate",(e,t)=>{ml.init(e,t),C.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Qp(e,o,n,i),e.min=(o,n)=>e.check(ie(o,n)),e.max=(o,n)=>e.check(ge(o,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});Jd=g("ZodArray",(e,t)=>{hl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>nd(e,r,o,n),e.element=t.element,Jt(e,"ZodArray",{min(r,o){return this.check(et(r,o))},nonempty(r){return this.check(et(1,r))},max(r,o){return this.check(jt(r,o))},length(r,o){return this.check(Zt(r,o))},unwrap(){return this.element}})});_o=g("ZodObject",(e,t)=>{bl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>id(e,r,o,n),T(e,"shape",()=>t.shape),Jt(e,"ZodObject",{keyof(){return Bs(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:ft()})},loose(){return this.clone({...this._zod.def,catchall:ft()})},strict(){return this.clone({...this._zod.def,catchall:Os()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return Pb(this,r)},safeExtend(r){return Cb(this,r)},merge(r){return Rb(this,r)},pick(r){return Ab(this,r)},omit(r){return kb(this,r)},partial(...r){return Tb(Ds,this,r[0])},required(...r){return Ob(Ns,this,r[0])}})});wo=g("ZodUnion",(e,t)=>{Zr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>es(e,r,o,n),e.options=t.options});Yd=g("ZodXor",(e,t)=>{wo.init(e,t),_l.init(e,t),e._zod.processJSONSchema=(r,o,n)=>es(e,r,o,n),e.options=t.options});Xd=g("ZodDiscriminatedUnion",(e,t)=>{wo.init(e,t),wl.init(e,t)});ef=g("ZodIntersection",(e,t)=>{vl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>sd(e,r,o,n)});rf=g("ZodTuple",(e,t)=>{$i.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ad(e,r,o,n),e.rest=(r)=>e.clone({...e._zod.def,rest:r})});Kt=g("ZodRecord",(e,t)=>{xl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>cd(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});sf=g("ZodMap",(e,t)=>{El.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>rd(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Le(...r)),e.nonempty=(r)=>e.check(Le(1,r)),e.max=(...r)=>e.check(dt(...r)),e.size=(...r)=>e.check(Mt(...r))});af=g("ZodSet",(e,t)=>{Sl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>od(e,r,o,n),e.min=(...r)=>e.check(Le(...r)),e.nonempty=(r)=>e.check(Le(1,r)),e.max=(...r)=>e.check(dt(...r)),e.size=(...r)=>e.check(Mt(...r))});Ht=g("ZodEnum",(e,t)=>{$l.init(e,t),C.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Wp(e,o,n,i),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let s of o)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Ht({...t,checks:[],...w(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let s of o)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Ht({...t,checks:[],...w(n),entries:i})}});cf=g("ZodLiteral",(e,t)=>{Al.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gp(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});uf=g("ZodFile",(e,t)=>{kl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jp(e,r,o,n),e.min=(r,o)=>e.check(Le(r,o)),e.max=(r,o)=>e.check(dt(r,o)),e.mime=(r,o)=>e.check(eo(Array.isArray(r)?r:[r],o))});lf=g("ZodTransform",(e,t)=>{Pl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>td(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new ct(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(Je(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(Je(s))}};let n=t.transform(r.value,r);if(n instanceof Promise)return n.then((i)=>(r.value=i,r.fallback=!0,r));return r.value=n,r.fallback=!0,r}});Ds=g("ZodOptional",(e,t)=>{Ai.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ts(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});pf=g("ZodExactOptional",(e,t)=>{Cl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ts(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});ff=g("ZodNullable",(e,t)=>{Rl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ud(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});mf=g("ZodDefault",(e,t)=>{Tl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>pd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});gf=g("ZodPrefault",(e,t)=>{Ol.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>dd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});Ns=g("ZodNonOptional",(e,t)=>{Il.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ld(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});_f=g("ZodSuccess",(e,t)=>{Bl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});wf=g("ZodCatch",(e,t)=>{zl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>fd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});xf=g("ZodNaN",(e,t)=>{Dl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kp(e,r,o,n)});vo=g("ZodPipe",(e,t)=>{ki.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>md(e,r,o,n),e.in=t.in,e.out=t.out});xo=g("ZodCodec",(e,t)=>{vo.init(e,t),qr.init(e,t)});Ef=g("ZodPreprocess",(e,t)=>{vo.init(e,t),Nl.init(e,t)}),Sf=g("ZodReadonly",(e,t)=>{Ll.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>hd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});Af=g("ZodTemplateLiteral",(e,t)=>{Vl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Hp(e,r,o,n)});kf=g("ZodLazy",(e,t)=>{Ml.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>yd(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});Cf=g("ZodPromise",(e,t)=>{Fl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>gd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});Rf=g("ZodFunction",(e,t)=>{Ul.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ed(e,r,o,n)});Eo=g("ZodCustom",(e,t)=>{jl.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xp(e,r,o,n)});Aw=Rp,kw=Tp});var If;var Bf=_(()=>{(function(e){})(If||(If={}))});function Iw(e,t){let r=e.$schema;if(r==="https://json-schema.org/draft/2020-12/schema")return"draft-2020-12";if(r==="http://json-schema.org/draft-07/schema#")return"draft-7";if(r==="http://json-schema.org/draft-04/schema#")return"draft-4";return t??"draft-2020-12"}function Bw(e,t){if(!e.startsWith("#"))throw Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){let n=r[1];if(!n||!t.defs[n])throw Error(`Reference not found: ${e}`);return t.defs[n]}throw Error(`Reference not found: ${e}`)}function zf(e,t){if(e.not!==void 0){if(typeof e.not==="object"&&Object.keys(e.not).length===0)return v.never();throw Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return v.lazy(()=>{if(!t.refs.has(n))throw Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=Bw(n,t),s=K(i,t);return t.refs.set(n,s),t.processing.delete(n),s}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return v.null();if(n.length===0)return v.never();if(n.length===1)return v.literal(n[0]);if(n.every((s)=>typeof s==="string"))return v.enum(n);let i=n.map((s)=>v.literal(s));if(i.length<2)return i[0];return v.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return v.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map((i)=>{let s={...e,type:i};return zf(s,t)});if(n.length===0)return v.never();if(n.length===1)return n[0];return v.union(n)}if(!r)return v.any();let o;switch(r){case"string":{let n=v.string();if(e.format){let i=e.format;if(i==="email")n=n.check(v.email());else if(i==="uri"||i==="uri-reference")n=n.check(v.url());else if(i==="uuid"||i==="guid")n=n.check(v.uuid());else if(i==="date-time")n=n.check(v.iso.datetime());else if(i==="date")n=n.check(v.iso.date());else if(i==="time")n=n.check(v.iso.time());else if(i==="duration")n=n.check(v.iso.duration());else if(i==="ipv4")n=n.check(v.ipv4());else if(i==="ipv6")n=n.check(v.ipv6());else if(i==="mac")n=n.check(v.mac());else if(i==="cidr")n=n.check(v.cidrv4());else if(i==="cidr-v6")n=n.check(v.cidrv6());else if(i==="base64")n=n.check(v.base64());else if(i==="base64url")n=n.check(v.base64url());else if(i==="e164")n=n.check(v.e164());else if(i==="jwt")n=n.check(v.jwt());else if(i==="emoji")n=n.check(v.emoji());else if(i==="nanoid")n=n.check(v.nanoid());else if(i==="cuid")n=n.check(v.cuid());else if(i==="cuid2")n=n.check(v.cuid2());else if(i==="ulid")n=n.check(v.ulid());else if(i==="xid")n=n.check(v.xid());else if(i==="ksuid")n=n.check(v.ksuid())}if(typeof e.minLength==="number")n=n.min(e.minLength);if(typeof e.maxLength==="number")n=n.max(e.maxLength);if(e.pattern)n=n.regex(new RegExp(e.pattern));o=n;break}case"number":case"integer":{let n=r==="integer"?v.number().int():v.number();if(typeof e.minimum==="number")n=n.min(e.minimum);if(typeof e.maximum==="number")n=n.max(e.maximum);if(typeof e.exclusiveMinimum==="number")n=n.gt(e.exclusiveMinimum);else if(e.exclusiveMinimum===!0&&typeof e.minimum==="number")n=n.gt(e.minimum);if(typeof e.exclusiveMaximum==="number")n=n.lt(e.exclusiveMaximum);else if(e.exclusiveMaximum===!0&&typeof e.maximum==="number")n=n.lt(e.maximum);if(typeof e.multipleOf==="number")n=n.multipleOf(e.multipleOf);o=n;break}case"boolean":{o=v.boolean();break}case"null":{o=v.null();break}case"object":{let n={},i=e.properties||{},s=new Set(e.required||[]);for(let[c,u]of Object.entries(i)){let l=K(u,t);n[c]=s.has(c)?l:l.optional()}if(e.propertyNames){let c=K(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties==="object"?K(e.additionalProperties,t):v.any();if(Object.keys(n).length===0){o=v.record(c,u);break}let l=v.object(n).passthrough(),f=v.looseRecord(c,u);o=v.intersection(l,f);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let p of u){let d=K(c[p],t),m=v.string().regex(new RegExp(p));l.push(v.looseRecord(m,d))}let f=[];if(Object.keys(n).length>0)f.push(v.object(n).passthrough());if(f.push(...l),f.length===0)o=v.object({}).passthrough();else if(f.length===1)o=f[0];else{let p=v.intersection(f[0],f[1]);for(let d=2;d<f.length;d++)p=v.intersection(p,f[d]);o=p}break}let a=v.object(n);if(e.additionalProperties===!1)o=a.strict();else if(typeof e.additionalProperties==="object")o=a.catchall(K(e.additionalProperties,t));else o=a.passthrough();break}case"array":{let{prefixItems:n,items:i}=e;if(n&&Array.isArray(n)){let s=n.map((c)=>K(c,t)),a=i&&typeof i==="object"&&!Array.isArray(i)?K(i,t):void 0;if(a)o=v.tuple(s).rest(a);else o=v.tuple(s);if(typeof e.minItems==="number")o=o.check(v.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(v.maxLength(e.maxItems))}else if(Array.isArray(i)){let s=i.map((c)=>K(c,t)),a=e.additionalItems&&typeof e.additionalItems==="object"?K(e.additionalItems,t):void 0;if(a)o=v.tuple(s).rest(a);else o=v.tuple(s);if(typeof e.minItems==="number")o=o.check(v.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(v.maxLength(e.maxItems))}else if(i!==void 0){let s=K(i,t),a=v.array(s);if(typeof e.minItems==="number")a=a.min(e.minItems);if(typeof e.maxItems==="number")a=a.max(e.maxItems);o=a}else o=v.array(v.any());break}default:throw Error(`Unsupported type: ${r}`)}return o}function K(e,t){if(typeof e==="boolean")return e?v.any():v.never();let r=zf(e,t),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map((u)=>K(u,t)),c=v.union(a);r=o?v.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map((u)=>K(u,t)),c=v.xor(a);r=o?v.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:v.any();else{let a=o?r:K(e.allOf[0],t),c=o?0:1;for(let u=c;u<e.allOf.length;u++)a=v.intersection(a,K(e.allOf[u],t));r=a}if(e.nullable===!0&&t.version==="openapi-3.0")r=v.nullable(r);if(e.readOnly===!0)r=v.readonly(r);if(e.default!==void 0)r=r.default(e.default);let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of i)if(a in e)n[a]=e[a];let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)if(a in e)n[a]=e[a];for(let a of Object.keys(e))if(!Ow.has(a))n[a]=e[a];if(Object.keys(n).length>0)t.registry.add(r,n);if(e.description)r=r.describe(e.description);return r}function Df(e,t){if(typeof e==="boolean")return e?v.any():v.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=Iw(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:o,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??Y};return K(r,i)}var v,Ow;var Nf=_(()=>{Ft();co();uo();po();v={...lo,...ao,iso:Gt},Ow=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"])});var Lf=()=>{};var Vs=_(()=>{ye();ye();Zl();ye();Nf();Ri();uo();Lf();po();co();ss();as();Bf();W(Ci())});var Us=_(()=>{Vs();Vs()});var Uf="registry.neko-piranha.ts.net",So="https://kuber.astrxl.dev/api/v2",H;var Ve=_(()=>{H={"app.kubernetes.io/managed-by":"kuber"}});import{chmod as Ff,mkdir as Nw,readFile as Lw,rename as Vw,rm as Ms,writeFile as Uw}from"fs/promises";import{randomUUID as Fw}from"crypto";import{tmpdir as qf}from"os";import{dirname as Mf,join as $o}from"path";function js(){let e=process.env.XDG_RUNTIME_DIR??$o(qf(),`kuber-${process.getuid?.()??"user"}`);return $o(e,"kuber","session.json")}function Zs(){let e=process.env.XDG_CONFIG_HOME??$o(process.env.HOME??qf(),".config");return $o(e,"kuber","session.json")}function jf(e){return e?Zs():js()}function Mw(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.token==="string"&&typeof t.expiresAt==="string"&&Boolean(t.user)&&typeof t.user?.username==="string"&&Array.isArray(t.user.roles)&&t.user.roles.every((r)=>typeof r==="string")}async function Zf(e){try{let t=JSON.parse(await Lw(e,"utf8"));if(!Mw(t))return;if(Date.parse(t.expiresAt)<=Date.now()){await Ms(e,{force:!0});return}return t}catch(t){if(t&&typeof t==="object"&&"code"in t&&t.code==="ENOENT")return;if(t instanceof SyntaxError)return;throw t}}async function ht(){let e=js(),t=Zs();if(Ue?.runtimePath===e&&Ue.persistentPath===t&&(Ue.expiresAt===0||Ue.expiresAt>Date.now()))return Ue.value;let r=await Zf(e)??await Zf(t);return Ue={runtimePath:e,persistentPath:t,value:r,expiresAt:r?Date.parse(r.expiresAt):0},r}async function Qf(e,t){let r=jf(t);await Nw(Mf(r),{recursive:!0,mode:448}),await Ff(Mf(r),448);let o=`${r}.${Fw()}.tmp`;return await Uw(o,`${JSON.stringify(e,null,2)}
|
|
72
|
-
`,{flag:"wx",mode:384}),await
|
|
73
|
-
`,
|
|
74
|
-
`,
|
|
75
|
-
`).map((a)=>{let c=typeof r>"u"?a:
|
|
76
|
-
`)[0]?.split(/ /g);for(let n=0;n<o.length;n++){let i=o[n];if(r){let s=
|
|
77
|
-
`)[0].matchAll(new RegExp(`(?:${
|
|
78
|
-
`,u)return a+this.renderRow(e,t,r,u);if(r.rows.length>1&&(t===0&&r.hasHeaderBorder||t<r.rows.length-1&&r.hasBodyBorder))a+=this.renderBorderRow(n,s,e,r);if(t===r.rows.length-1&&n.hasBorder())a+=this.renderBorderRow(n,void 0,e,r);return a}renderCell(e,t,r,o){let n="",i=t[e-1],s=t[e];if(!o){if(e===0){if(s.getBorder())n+=this.options.chars.left;else if(r.hasBorder)n+=" "}else if(s.getBorder()||i?.getBorder())n+=this.options.chars.middle;else if(r.hasBorder)n+=" "}let a=r.width[e],c=s.getColSpan();if(c>1){for(let f=1;f<c;f++)if(a+=r.width[e+f]+r.padding[e+f],r.hasBorder)a+=r.padding[e+f]+1}let{current:u,next:l}=this.renderCellValue(s,a);if(t[e].setValue(l),r.hasBorder)n+=" ".repeat(r.padding[e]);if(n+=u,r.hasBorder||e<r.columns-1)n+=" ".repeat(r.padding[e]);return n}renderCellValue(e,t){if(t<=0)return{current:"",next:""};let r=Math.min(t,
|
|
79
|
-
`:""}renderBorderCell(e,t,r,o,n){let i=t?.[e-1],s=r?.[e-1],a=t?.[e],c=r?.[e],u=!!i?.getBorder(),l=!!s?.getBorder(),f=!!a?.getBorder(),p=!!c?.getBorder(),d=(b)=>(b?.getColSpan()??1)>1,m=(b)=>(b?.getRowSpan()??1)>1,h="";if(e===0)if(o[e]>1)if(f)h+=this.options.chars.left;else h+=" ";else if(f&&p)h+=this.options.chars.leftMid;else if(f)h+=this.options.chars.bottomLeft;else if(p)h+=this.options.chars.topLeft;else h+=" ";else if(e<n.columns)if(u&&p||f&&l){let b=d(i),S=d(s),x=d(a),A=d(c),R=m(i),Z=m(s),_e=m(a),Ze=m(c),qe=u&&p&&f&&l,An=R&&_e&&Z&&Ze,nb=b&&x&&S&&A;if(An&&qe)h+=this.options.chars.middle;else if(nb&&qe&&i===a&&s===c)h+=this.options.chars.mid;else if(b&&x&&i===a)h+=this.options.chars.topMid;else if(S&&A&&s===c)h+=this.options.chars.bottomMid;else if(R&&Z&&i===s)h+=this.options.chars.leftMid;else if(_e&&Ze&&a===c)h+=this.options.chars.rightMid;else h+=this.options.chars.midMid}else if(u&&f)if(d(i)&&d(a)&&i===a)h+=this.options.chars.bottom;else h+=this.options.chars.bottomMid;else if(f&&p)if(o[e]>1)h+=this.options.chars.left;else h+=this.options.chars.leftMid;else if(p&&l)if(d(s)&&d(c)&&s===c)h+=this.options.chars.top;else h+=this.options.chars.topMid;else if(u&&l)if(m(i)&&i===s)h+=this.options.chars.right;else h+=this.options.chars.rightMid;else if(u)h+=this.options.chars.bottomRight;else if(f)h+=this.options.chars.bottomLeft;else if(l)h+=this.options.chars.topRight;else if(p)h+=this.options.chars.topLeft;else h+=" ";let y=n.padding[e]+n.width[e]+n.padding[e];if(o[e]>1&&r){if(h+=this.renderCell(e,r,n,!0),r[e]===r[r.length-1]){if(f)h+=this.options.chars.right;else h+=" ";return h}}else if(f&&p)h+=this.options.chars.mid.repeat(y);else if(f)h+=this.options.chars.bottom.repeat(y);else if(p)h+=this.options.chars.top.repeat(y);else h+=" ".repeat(y);if(e===n.columns-1)if(f&&p)h+=this.options.chars.rightMid;else if(f)h+=this.options.chars.bottomRight;else if(p)h+=this.options.chars.topRight;else h+=" ";return h}}var Ee=(e)=>e.reduce((t,r)=>t+r,0);var im=_(()=>{ko();Po();Hs()});var Fe;var sm=_(()=>{Gs();im();Po();Fe=class Fe extends Array{static _chars={...Ws};options={indent:0,border:!1,maxColWidth:1/0,minColWidth:0,padding:1,maxWidth:1/0,flexShrink:0,flexGrow:0,chars:{...Fe._chars},columns:[]};headerRow;static from(e){let t=new this(...e);if(e instanceof Fe)t.options={...e.options},t.headerRow=e.headerRow?ae.from(e.headerRow):void 0;return t}static fromJson(e){return new this().fromJson(e)}static chars(e){return Object.assign(this._chars,e),this}static render(e){Fe.from(e).render()}fromJson(e){return this.header(Object.keys(e[0])),this.body(e.map((t)=>Object.values(t))),this}columns(e){return this.options.columns=e.map((t)=>t instanceof ve?t:ve.from(t)),this}column(e,t){if(t instanceof ve)this.options.columns[e]=t;else if(this.options.columns[e])this.options.columns[e].options(t);else this.options.columns[e]=ve.from(t);return this}header(e){return this.headerRow=e instanceof ae?e:ae.from(e),this}body(e){return this.length=0,this.push(...e),this}clone(){let e=new Fe(...this.map((t)=>t instanceof ae?t.clone():ae.from(t).clone()));return e.options={...this.options},e.headerRow=this.headerRow?.clone(),e}toString(){return new Js(this,this.options).toString()}render(){return console.log(this.toString()),this}maxColWidth(e,t=!0){if(t||typeof this.options.maxColWidth>"u")this.options.maxColWidth=e;return this}minColWidth(e,t=!0){if(t||typeof this.options.minColWidth>"u")this.options.minColWidth=e;return this}maxWidth(e,t=!0){if(t||typeof this.options.maxWidth>"u")this.options.maxWidth=e;return this}flexShrink(e=1,t=!0){if(t||typeof this.options.flexShrink>"u")this.options.flexShrink=e;return this}flexGrow(e=1,t=!0){if(t||typeof this.options.flexGrow>"u")this.options.flexGrow=e;return this}flex(e=1,t=!0){return this.flexGrow(e,t).flexShrink(e,t)}indent(e,t=!0){if(t||typeof this.options.indent>"u")this.options.indent=e;return this}padding(e,t=!0){if(t||typeof this.options.padding>"u")this.options.padding=e;return this}border(e=!0,t=!0){if(t||typeof this.options.border>"u")this.options.border=e;return this}align(e,t=!0){if(t||typeof this.options.align>"u")this.options.align=e;return this}chars(e){return Object.assign(this.options.chars,e),this}getHeader(){return this.headerRow}getBody(){return[...this]}getMaxColWidth(){return this.options.maxColWidth}getMinColWidth(){return this.options.minColWidth}getIndent(){return this.options.indent}getPadding(){return this.options.padding}getBorder(){return this.options.border===!0}hasHeaderBorder(){let e=this.headerRow?.hasBorder();return e===!0||this.getBorder()&&e!==!1}hasBodyBorder(){return this.getBorder()||this.options.columns.some((e)=>e.getBorder())||this.some((e)=>e instanceof ae?e.hasBorder():e.some((t)=>t instanceof re?t.getBorder():!1))}hasBorder(){return this.hasHeaderBorder()||this.hasBodyBorder()}getAlign(){return this.options.align??"left"}getColumns(){return this.options.columns}getColumn(e){return this.options.columns[e]??=new ve}}});var am=_(()=>{Gs();ko();Po();sm()});function le(e){return new Fe(Object.keys(e[0]??{}).map((t)=>t.toUpperCase()),...e.map((t)=>Object.values(t))).toString()}function cm(e){if(!e)return;if(Array.isArray(e))return e.map((t)=>{let r=t.indexOf("=");return{name:r===-1?t:t.slice(0,r),value:r===-1?void 0:t.slice(r+1)}});return Object.entries(e).map(([t,r])=>({name:t,value:r===null?void 0:String(r)}))}var tt=_(()=>{am()});async function Yw(e,t=k){let r=e?`/audit?${new URLSearchParams({workspaceId:e})}`:"/audit",o=await t(r);if(o.items.length===0)return"No audit events";return le(o.items.map((n)=>({timestamp:n.metadata.creationTimestamp,actor:n.spec.actor.username,action:n.spec.action,workspace:n.spec.workspaceId,outcome:n.spec.outcome,operation:n.spec.operationId})))}var Xw,ev;var um=_(()=>{M();q();tt();Xw=E({meta:{name:"ls",description:"List audit events"},args:{workspace:{type:"string",alias:"w",description:"Filter by workspace"}},async run({args:e}){console.log(await Yw(e.workspace??e._[0]))}}),ev=E({meta:{name:"audit",description:"Inspect the audit log"},subCommands:{ls:Xw}})});import{basename as tv,isAbsolute as rv,resolve as lm}from"path";import{pathToFileURL as ov}from"url";function Ys(e,t){if(typeof e!=="string"||e.trim().length===0)throw Error(`${t} must be a non-empty string`);return e.trim()}function sv(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw Error(`${t} must default export a configuration object`);let r=e;for(let o of["compose","preBuild","postBuild","postRender","postApply"])if(r[o]!==void 0&&typeof r[o]!=="function")throw Error(`${o} in ${t} must be a function`);if(r.project!==void 0)Ys(r.project,"project");if(r.composeFile!==void 0)Ys(r.composeFile,"composeFile");if(r.registry!==void 0)Ys(r.registry,"registry");if(r.rolloutTimeoutMs!==void 0&&(typeof r.rolloutTimeoutMs!=="number"||!Number.isFinite(r.rolloutTimeoutMs)||r.rolloutTimeoutMs<=0))throw Error(`rolloutTimeoutMs in ${t} must be a positive number`);return e}function pm(e){let t,r=[];for(let o=0;o<e.length;o+=1){let n=e[o];if(n==="--"){r.push(...e.slice(o));break}if(n.startsWith("--config=")){let i=n.slice(9);if(!i)throw Error("--config requires a path");if(t)throw Error("--config may only be specified once");t=i;continue}if(n==="--config"){let i=e[o+1];if(!i||i.startsWith("-"))throw Error(`${n} requires a path`);if(t)throw Error("--config may only be specified once");t=i,o+=1;continue}r.push(n)}return{configPath:t,rawArgs:r}}async function dm(e,t){let r=lm(e,t??nv),o=await Bun.file(r).exists();if(!o&&t)throw Error(`Config file cannot be found: ${r}`);let n=o?sv((await import(ov(r).href)).default,r):{},i=n.composeFile?.trim(),s=(n.registry?.trim()??Co).replace(/\/+$/,"");if(!s)throw Error(`registry in ${r} cannot be empty`);return{project:n.project?.trim()??tv(e),projectConfigured:n.project!==void 0,composeFile:i?rv(i)?i:lm(e,i):void 0,registry:s,rolloutTimeoutMs:n.rolloutTimeoutMs??iv,configFile:o?r:void 0,compose:n.compose,preBuild:n.preBuild,postBuild:n.postBuild,postRender:n.postRender,postApply:n.postApply}}function fm(e,t,r){return{cwd:t,project:e.project,composeFile:r,configFile:e.configFile}}var nv=".kuberrc.ts",Co,iv=300000;var Ro=_(()=>{Ve();Co=Uf});var mm;var hm=_(()=>{mm={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"compose_spec.json",type:"object",title:"Compose Specification",description:"The Compose file is a YAML file defining a multi-containers based application.",properties:{version:{type:"string",deprecated:!0,description:"declared for backward compatibility, ignored. Please remove it."},name:{type:"string",description:"define the Compose project name, until user defines one explicitly."},include:{type:"array",items:{$ref:"#/$defs/include"},description:"compose sub-projects to be included."},services:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/service"}},additionalProperties:!1,description:"The services that will be used by your application."},models:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/model"}},description:"Language models that will be used by your application."},networks:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/network"}},description:"Networks that are shared among multiple services."},volumes:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/volume"}},additionalProperties:!1,description:"Named volumes that are shared among multiple services."},secrets:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/secret"}},additionalProperties:!1,description:"Secrets that are shared among multiple services."},configs:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/config"}},additionalProperties:!1,description:"Configurations that are shared among multiple services."}},patternProperties:{"^x-":{}},additionalProperties:!1,$defs:{service:{type:"object",description:"Configuration for a service.",properties:{develop:{$ref:"#/$defs/development"},deploy:{$ref:"#/$defs/deployment"},annotations:{$ref:"#/$defs/list_or_dict"},attach:{type:["boolean","string"]},build:{description:"Configuration options for building the service's image.",oneOf:[{type:"string",description:"Path to the build context. Can be a relative path or a URL."},{type:"object",properties:{context:{type:"string",description:"Path to the build context. Can be a relative path or a URL."},dockerfile:{type:"string",description:"Name of the Dockerfile to use for building the image."},dockerfile_inline:{type:"string",description:"Inline Dockerfile content to use instead of a Dockerfile from the build context."},entitlements:{type:"array",items:{type:"string"},description:"List of extra privileged entitlements to grant to the build process."},args:{$ref:"#/$defs/list_or_dict",description:"Build-time variables, specified as a map or a list of KEY=VAL pairs."},ssh:{$ref:"#/$defs/list_or_dict",description:"SSH agent socket or keys to expose to the build. Format is either a string or a list of 'default|<id>[=<socket>|<key>[,<key>]]'."},labels:{$ref:"#/$defs/list_or_dict",description:"Labels to apply to the built image."},cache_from:{type:"array",items:{type:"string"},description:"List of sources the image builder should use for cache resolution"},cache_to:{type:"array",items:{type:"string"},description:"Cache destinations for the build cache."},no_cache:{type:["boolean","string"],description:"Do not use cache when building the image."},no_cache_filter:{$ref:"#/$defs/string_or_list",description:"Do not use build cache for the specified stages."},additional_contexts:{$ref:"#/$defs/list_or_dict",description:"Additional build contexts to use, specified as a map of name to context path or URL."},network:{type:"string",description:"Network mode to use for the build. Options include 'default', 'none', 'host', or a network name."},provenance:{type:["string","boolean"],description:"Add a provenance attestation"},sbom:{type:["string","boolean"],description:"Add a SBOM attestation"},pull:{type:["boolean","string"],description:"Always attempt to pull a newer version of the image."},target:{type:"string",description:"Build stage to target in a multi-stage Dockerfile."},shm_size:{type:["integer","string"],description:"Size of /dev/shm for the build container. A string value can use suffix like '2g' for 2 gigabytes."},extra_hosts:{$ref:"#/$defs/extra_hosts",description:"Add hostname mappings for the build container."},isolation:{type:"string",description:"Container isolation technology to use for the build process."},privileged:{type:["boolean","string"],description:"Give extended privileges to the build container."},secrets:{$ref:"#/$defs/service_config_or_secret",description:"Secrets to expose to the build. These are accessible at build-time."},tags:{type:"array",items:{type:"string"},description:"Additional tags to apply to the built image."},ulimits:{$ref:"#/$defs/ulimits",description:"Override the default ulimits for the build container."},platforms:{type:"array",items:{type:"string"},description:"Platforms to build for, e.g., 'linux/amd64', 'linux/arm64', or 'windows/amd64'."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},blkio_config:{type:"object",description:"Block IO configuration for the service.",properties:{device_read_bps:{type:"array",description:"Limit read rate (bytes per second) from a device.",items:{$ref:"#/$defs/blkio_limit"}},device_read_iops:{type:"array",description:"Limit read rate (IO per second) from a device.",items:{$ref:"#/$defs/blkio_limit"}},device_write_bps:{type:"array",description:"Limit write rate (bytes per second) to a device.",items:{$ref:"#/$defs/blkio_limit"}},device_write_iops:{type:"array",description:"Limit write rate (IO per second) to a device.",items:{$ref:"#/$defs/blkio_limit"}},weight:{type:["integer","string"],description:"Block IO weight (relative weight) for the service, between 10 and 1000."},weight_device:{type:"array",description:"Block IO weight (relative weight) for specific devices.",items:{$ref:"#/$defs/blkio_weight"}}},additionalProperties:!1},cap_add:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Add Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'."},cap_drop:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Drop Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'."},cgroup:{type:"string",enum:["host","private"],description:"Specify the cgroup namespace to join. Use 'host' to use the host's cgroup namespace, or 'private' to use a private cgroup namespace."},cgroup_parent:{type:"string",description:"Specify an optional parent cgroup for the container."},command:{$ref:"#/$defs/command",description:"Override the default command declared by the container image, for example 'CMD' in Dockerfile."},configs:{$ref:"#/$defs/service_config_or_secret",description:"Grant access to Configs on a per-service basis."},container_name:{type:"string",description:"Specify a custom container name, rather than a generated default name.",pattern:"[a-zA-Z0-9][a-zA-Z0-9_.-]+"},cpu_count:{oneOf:[{type:"string"},{type:"integer",minimum:0}],description:"Number of usable CPUs."},cpu_percent:{oneOf:[{type:"string"},{type:"integer",minimum:0,maximum:100}],description:"Percentage of CPU resources to use."},cpu_shares:{type:["number","string"],description:"CPU shares (relative weight) for the container."},cpu_quota:{type:["number","string"],description:"Limit the CPU CFS (Completely Fair Scheduler) quota."},cpu_period:{type:["number","string"],description:"Limit the CPU CFS (Completely Fair Scheduler) period."},cpu_rt_period:{type:["number","string"],description:"Limit the CPU real-time period in microseconds or a duration."},cpu_rt_runtime:{type:["number","string"],description:"Limit the CPU real-time runtime in microseconds or a duration."},cpus:{type:["number","string"],description:"Number of CPUs to use. A floating-point value is supported to request partial CPUs."},cpuset:{type:"string",description:"CPUs in which to allow execution (0-3, 0,1)."},credential_spec:{type:"object",description:"Configure the credential spec for managed service account.",properties:{config:{type:"string",description:"The name of the credential spec Config to use."},file:{type:"string",description:"Path to a credential spec file."},registry:{type:"string",description:"Path to a credential spec in the Windows registry."}},additionalProperties:!1,patternProperties:{"^x-":{}}},depends_on:{oneOf:[{$ref:"#/$defs/list_of_strings"},{type:"object",additionalProperties:!1,patternProperties:{"^[a-zA-Z0-9._-]+$":{type:"object",additionalProperties:!1,patternProperties:{"^x-":{}},properties:{restart:{type:["boolean","string"],description:"Whether to restart dependent services when this service is restarted."},required:{type:"boolean",default:!0,description:"Whether the dependency is required for the dependent service to start."},condition:{type:"string",enum:["service_started","service_healthy","service_completed_successfully"],description:"Condition to wait for. 'service_started' waits until the service has started, 'service_healthy' waits until the service is healthy (as defined by its healthcheck), 'service_completed_successfully' waits until the service has completed successfully."}},required:["condition"]}}}],description:"Express dependency between services. Service dependencies cause services to be started in dependency order. The dependent service will wait for the dependency to be ready before starting."},device_cgroup_rules:{$ref:"#/$defs/list_of_strings",description:"Add rules to the cgroup allowed devices list."},devices:{type:"array",description:"List of device mappings for the container.",items:{oneOf:[{type:"string"},{type:"object",required:["source"],properties:{source:{type:"string",description:"Path on the host to the device."},target:{type:"string",description:"Path in the container where the device will be mapped."},permissions:{type:"string",description:"Cgroup permissions for the device (rwm)."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]}},dns:{$ref:"#/$defs/string_or_list",description:"Custom DNS servers to set for the service container."},dns_opt:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Custom DNS options to be passed to the container's DNS resolver."},dns_search:{$ref:"#/$defs/string_or_list",description:"Custom DNS search domains to set on the service container."},domainname:{type:"string",description:"Custom domain name to use for the service container."},entrypoint:{$ref:"#/$defs/command",description:"Override the default entrypoint declared by the container image, for example 'ENTRYPOINT' in Dockerfile."},env_file:{$ref:"#/$defs/env_file",description:"Add environment variables from a file or multiple files. Can be a single file path or a list of file paths."},label_file:{$ref:"#/$defs/label_file",description:"Add metadata to containers using files containing Docker labels."},environment:{$ref:"#/$defs/list_or_dict",description:"Add environment variables. You can use either an array or a list of KEY=VAL pairs."},expose:{type:"array",items:{type:["string","number"]},uniqueItems:!0,description:"Expose ports without publishing them to the host machine - they'll only be accessible to linked services."},extends:{oneOf:[{type:"string"},{type:"object",properties:{service:{type:"string",description:"The name of the service to extend."},file:{type:"string",description:"The file path where the service to extend is defined."}},required:["service"],additionalProperties:!1}],description:"Extend another service, in the current file or another file."},provider:{type:"object",description:"Specify a service which will not be manage by Compose directly, and delegate its management to an external provider.",required:["type"],properties:{type:{type:"string",description:"External component used by Compose to manage setup and teardown lifecycle of the service."},options:{type:"object",description:"Provider-specific options.",patternProperties:{"^.+$":{oneOf:[{type:["string","number","boolean"]},{type:"array",items:{type:["string","number","boolean"]}}]}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},external_links:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Link to services started outside this Compose application. Specify services as <service_name>:<alias>."},extra_hosts:{$ref:"#/$defs/extra_hosts",description:"Add hostname mappings to the container network interface configuration."},gpus:{$ref:"#/$defs/gpus",description:"Define GPU devices to use. Can be set to 'all' to use all GPUs, or a list of specific GPU devices."},group_add:{type:"array",items:{type:["string","number"]},uniqueItems:!0,description:"Add additional groups which user inside the container should be member of."},healthcheck:{$ref:"#/$defs/healthcheck",description:"Configure a health check for the container to monitor its health status."},hostname:{type:"string",description:"Define a custom hostname for the service container."},image:{type:"string",description:"Specify the image to start the container from. Can be a repository/tag, a digest, or a local image ID."},init:{type:["boolean","string"],description:"Run as an init process inside the container that forwards signals and reaps processes."},ipc:{type:"string",description:"IPC sharing mode for the service container. Use 'host' to share the host's IPC namespace, 'service:[service_name]' to share with another service, or 'shareable' to allow other services to share this service's IPC namespace."},isolation:{type:"string",description:"Container isolation technology to use. Supported values are platform-specific."},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to containers using Docker labels. You can use either an array or a list."},links:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Link to containers in another service. Either specify both the service name and a link alias (SERVICE:ALIAS), or just the service name."},logging:{type:"object",description:"Logging configuration for the service.",properties:{driver:{type:"string",description:"Logging driver to use, such as 'json-file', 'syslog', 'journald', etc."},options:{type:"object",description:"Options for the logging driver.",patternProperties:{"^.+$":{type:["string","number","null"]}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},mac_address:{type:"string",description:"Container MAC address to set."},mem_limit:{type:["number","string"],description:"Memory limit for the container. A string value can use suffix like '2g' for 2 gigabytes."},mem_reservation:{type:["string","integer"],description:"Memory reservation for the container."},mem_swappiness:{type:["integer","string"],description:"Container memory swappiness as percentage (0 to 100)."},memswap_limit:{type:["number","string"],description:"Amount of memory the container is allowed to swap to disk. Set to -1 to enable unlimited swap."},network_mode:{type:"string",description:"Network mode. Values can be 'bridge', 'host', 'none', 'service:[service name]', or 'container:[container name]'."},models:{oneOf:[{$ref:"#/$defs/list_of_strings"},{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{oneOf:[{type:"object",properties:{endpoint_var:{type:"string",description:"Environment variable set to AI model endpoint."},model_var:{type:"string",description:"Environment variable set to AI model name."}},additionalProperties:!1,patternProperties:{"^x-":{}}},{type:"null"}]}}}],description:"AI Models to use, referencing entries under the top-level models key."},networks:{oneOf:[{$ref:"#/$defs/list_of_strings"},{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{oneOf:[{type:"object",properties:{aliases:{$ref:"#/$defs/list_of_strings",description:"Alternative hostnames for this service on the network."},interface_name:{type:"string",description:"Interface network name used to connect to network"},ipv4_address:{type:"string",description:"Specify a static IPv4 address for this service on this network."},ipv6_address:{type:"string",description:"Specify a static IPv6 address for this service on this network."},link_local_ips:{$ref:"#/$defs/list_of_strings",description:"List of link-local IPs."},mac_address:{type:"string",description:"Specify a MAC address for this service on this network."},driver_opts:{type:"object",description:"Driver options for this network.",patternProperties:{"^.+$":{type:["string","number"]}}},priority:{type:"number",description:"Specify the priority for the network connection."},gw_priority:{type:"number",description:"Specify the gateway priority for the network connection."}},additionalProperties:!1,patternProperties:{"^x-":{}}},{type:"null"}]}},additionalProperties:!1}],description:"Networks to join, referencing entries under the top-level networks key. Can be a list of network names or a mapping of network name to network configuration."},oom_kill_disable:{type:["boolean","string"],description:"Disable OOM Killer for the container."},oom_score_adj:{oneOf:[{type:"string"},{type:"integer",minimum:-1000,maximum:1000}],description:"Tune host's OOM preferences for the container (accepts -1000 to 1000)."},pid:{type:["string","null"],description:"PID mode for container."},pids_limit:{type:["number","string"],description:"Tune a container's PIDs limit. Set to -1 for unlimited PIDs."},platform:{type:"string",description:"Target platform to run on, e.g., 'linux/amd64', 'linux/arm64', or 'windows/amd64'."},ports:{type:"array",description:"Expose container ports. Short format ([HOST:]CONTAINER[/PROTOCOL]).",items:{oneOf:[{type:"number"},{type:"string"},{type:"object",properties:{name:{type:"string",description:"A human-readable name for this port mapping."},mode:{type:"string",description:"The port binding mode, either 'host' for publishing a host port or 'ingress' for load balancing."},host_ip:{type:"string",description:"The host IP to bind to."},target:{type:["integer","string"],description:"The port inside the container."},published:{type:["string","integer"],description:"The publicly exposed port."},protocol:{type:"string",description:"The port protocol (tcp or udp)."},app_protocol:{type:"string",description:"Application protocol to use with the port (e.g., http, https, mysql)."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},uniqueItems:!0},pre_start:{type:"array",items:{$ref:"#/$defs/pre_start_hook"},description:"Init containers to run to completion before the service container is started. Each step runs in its own ephemeral container, in declared order; a non-zero exit fails the bring-up of the service and its dependents."},post_start:{type:"array",items:{$ref:"#/$defs/service_hook"},description:"Commands to run after the container starts. If any command fails, the container stops."},pre_stop:{type:"array",items:{$ref:"#/$defs/service_hook"},description:"Commands to run before the container stops. If any command fails, the container stop is aborted."},privileged:{type:["boolean","string"],description:"Give extended privileges to the service container."},profiles:{$ref:"#/$defs/list_of_strings",description:"List of profiles for this service. When profiles are specified, services are only started when the profile is activated."},pull_policy:{type:"string",pattern:"always|never|build|if_not_present|missing|refresh|daily|weekly|every_([0-9]+[wdhms])+",description:"Policy for pulling images. Options include: 'always', 'never', 'if_not_present', 'missing', 'build', or time-based refresh policies."},pull_refresh_after:{type:"string",description:"Time after which to refresh the image. Used with pull_policy=refresh."},read_only:{type:["boolean","string"],description:"Mount the container's filesystem as read only."},restart:{type:"string",description:"Restart policy for the service container. Options include: 'no', 'always', 'on-failure', and 'unless-stopped'."},runtime:{type:"string",description:"Runtime to use for this container, e.g., 'runc'."},scale:{type:["integer","string"],description:"Number of containers to deploy for this service."},security_opt:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Override the default labeling scheme for each container."},shm_size:{type:["number","string"],description:"Size of /dev/shm. A string value can use suffix like '2g' for 2 gigabytes."},secrets:{$ref:"#/$defs/service_config_or_secret",description:"Grant access to Secrets on a per-service basis."},sysctls:{$ref:"#/$defs/list_or_dict",description:"Kernel parameters to set in the container. You can use either an array or a list."},stdin_open:{type:["boolean","string"],description:"Keep STDIN open even if not attached."},stop_grace_period:{type:"string",description:"Time to wait for the container to stop gracefully before sending SIGKILL (e.g., '1s', '1m30s')."},stop_signal:{type:"string",description:"Signal to stop the container (e.g., 'SIGTERM', 'SIGINT')."},storage_opt:{type:"object",description:"Storage driver options for the container."},tmpfs:{$ref:"#/$defs/string_or_list",description:"Mount a temporary filesystem (tmpfs) into the container. Can be a single value or a list."},tty:{type:["boolean","string"],description:"Allocate a pseudo-TTY to service container."},ulimits:{$ref:"#/$defs/ulimits",description:"Override the default ulimits for a container."},use_api_socket:{type:"boolean",description:"Bind mount Docker API socket and required auth."},user:{type:"string",description:"Username or UID to run the container process as."},uts:{type:"string",description:"UTS namespace to use. 'host' shares the host's UTS namespace."},userns_mode:{type:"string",description:"User namespace to use. 'host' shares the host's user namespace."},volumes:{type:"array",description:"Mount host paths or named volumes accessible to the container. Short syntax (VOLUME:CONTAINER_PATH[:MODE])",items:{oneOf:[{type:"string"},{type:"object",required:["type"],properties:{type:{type:"string",enum:["bind","volume","tmpfs","cluster","npipe","image"],description:"The mount type: bind for mounting host directories, volume for named volumes, tmpfs for temporary filesystems, cluster for cluster volumes, npipe for named pipes, or image for mounting from an image."},source:{type:"string",description:"The source of the mount, a path on the host for a bind mount, a docker image reference for an image mount, or the name of a volume defined in the top-level volumes key. Not applicable for a tmpfs mount."},target:{type:"string",description:"The path in the container where the volume is mounted."},read_only:{type:["boolean","string"],description:"Flag to set the volume as read-only."},consistency:{type:"string",description:"The consistency requirements for the mount. Available values are platform specific."},bind:{type:"object",description:"Configuration specific to bind mounts.",properties:{propagation:{type:"string",description:"The propagation mode for the bind mount: 'shared', 'slave', 'private', 'rshared', 'rslave', or 'rprivate'."},create_host_path:{type:["boolean","string"],description:"Create the host path if it doesn't exist."},recursive:{type:"string",enum:["enabled","disabled","writable","readonly"],description:"Recursively mount the source directory."},selinux:{type:"string",enum:["z","Z"],description:"SELinux relabeling options: 'z' for shared content, 'Z' for private unshared content."}},additionalProperties:!1,patternProperties:{"^x-":{}}},volume:{type:"object",description:"Configuration specific to volume mounts.",properties:{labels:{$ref:"#/$defs/list_or_dict",description:"Labels to apply to the volume."},nocopy:{type:["boolean","string"],description:"Flag to disable copying of data from a container when a volume is created."},subpath:{type:"string",description:"Path within the volume to mount instead of the volume root."}},additionalProperties:!1,patternProperties:{"^x-":{}}},tmpfs:{type:"object",description:"Configuration specific to tmpfs mounts.",properties:{size:{oneOf:[{type:"integer",minimum:0},{type:"string"}],description:"Size of the tmpfs mount in bytes."},mode:{type:["number","string"],description:"File mode of the tmpfs in octal."}},additionalProperties:!1,patternProperties:{"^x-":{}}},image:{type:"object",description:"Configuration specific to image mounts.",properties:{subpath:{type:"string",description:"Path within the image to mount instead of the image root."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},uniqueItems:!0},volumes_from:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Mount volumes from another service or container. Optionally specify read-only access (ro) or read-write (rw)."},working_dir:{type:"string",description:"The working directory in which the entrypoint or command will be run"}},patternProperties:{"^x-":{}},additionalProperties:!1},healthcheck:{type:"object",description:"Configuration options to determine whether the container is healthy.",properties:{disable:{type:["boolean","string"],description:"Disable any container-specified healthcheck. Set to true to disable."},interval:{type:"string",description:"Time between running the check (e.g., '1s', '1m30s'). Default: 30s."},retries:{type:["number","string"],description:"Number of consecutive failures needed to consider the container as unhealthy. Default: 3."},test:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}],description:"The test to perform to check container health. Can be a string or a list. The first item is either NONE, CMD, or CMD-SHELL. If it's CMD, the rest of the command is exec'd. If it's CMD-SHELL, the rest is run in the shell."},timeout:{type:"string",description:"Maximum time to allow one check to run (e.g., '1s', '1m30s'). Default: 30s."},start_period:{type:"string",description:"Start period for the container to initialize before starting health-retries countdown (e.g., '1s', '1m30s'). Default: 0s."},start_interval:{type:"string",description:"Time between running the check during the start period (e.g., '1s', '1m30s'). Default: interval value."}},additionalProperties:!1,patternProperties:{"^x-":{}}},development:{type:["object","null"],description:"Development configuration for the service, used for development workflows.",properties:{watch:{type:"array",description:"Configure watch mode for the service, which monitors file changes and performs actions in response.",items:{type:"object",required:["path","action"],properties:{ignore:{$ref:"#/$defs/string_or_list",description:"Patterns to exclude from watching."},include:{$ref:"#/$defs/string_or_list",description:"Patterns to include in watching."},path:{type:"string",description:"Path to watch for changes."},action:{type:"string",enum:["rebuild","sync","restart","sync+restart","sync+exec"],description:"Action to take when a change is detected: rebuild the container, sync files, restart the container, sync and restart, or sync and execute a command."},target:{type:"string",description:"Target path in the container for sync operations."},exec:{$ref:"#/$defs/service_hook",description:"Command to execute when a change is detected and action is sync+exec."},initial_sync:{type:"boolean",description:"Ensure that an initial synchronization is done before starting watch mode for sync+x triggers"}},additionalProperties:!1,patternProperties:{"^x-":{}}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},deployment:{type:["object","null"],description:"Deployment configuration for the service.",properties:{mode:{type:"string",description:"Deployment mode for the service: 'replicated' (default) or 'global'."},endpoint_mode:{type:"string",description:"Endpoint mode for the service: 'vip' (default) or 'dnsrr'."},replicas:{type:["integer","string"],description:"Number of replicas of the service container to run."},labels:{$ref:"#/$defs/list_or_dict",description:"Labels to apply to the service."},rollback_config:{type:"object",description:"Configuration for rolling back a service update.",properties:{parallelism:{type:["integer","string"],description:"The number of containers to rollback at a time. If set to 0, all containers rollback simultaneously."},delay:{type:"string",description:"The time to wait between each container group's rollback (e.g., '1s', '1m30s')."},failure_action:{type:"string",description:"Action to take if a rollback fails: 'continue', 'pause'."},monitor:{type:"string",description:"Duration to monitor each task for failures after it is created (e.g., '1s', '1m30s')."},max_failure_ratio:{type:["number","string"],description:"Failure rate to tolerate during a rollback."},order:{type:"string",enum:["start-first","stop-first"],description:"Order of operations during rollbacks: 'stop-first' (default) or 'start-first'."}},additionalProperties:!1,patternProperties:{"^x-":{}}},update_config:{type:"object",description:"Configuration for updating a service.",properties:{parallelism:{type:["integer","string"],description:"The number of containers to update at a time."},delay:{type:"string",description:"The time to wait between updating a group of containers (e.g., '1s', '1m30s')."},failure_action:{type:"string",description:"Action to take if an update fails: 'continue', 'pause', 'rollback'."},monitor:{type:"string",description:"Duration to monitor each updated task for failures after it is created (e.g., '1s', '1m30s')."},max_failure_ratio:{type:["number","string"],description:"Failure rate to tolerate during an update (0 to 1)."},order:{type:"string",enum:["start-first","stop-first"],description:"Order of operations during updates: 'stop-first' (default) or 'start-first'."}},additionalProperties:!1,patternProperties:{"^x-":{}}},resources:{type:"object",description:"Resource constraints and reservations for the service.",properties:{limits:{type:"object",description:"Resource limits for the service containers.",properties:{cpus:{type:["number","string"],description:"Limit for how much of the available CPU resources, as number of cores, a container can use."},memory:{type:"string",description:"Limit on the amount of memory a container can allocate (e.g., '1g', '1024m')."},pids:{type:["integer","string"],description:"Maximum number of PIDs available to the container."}},additionalProperties:!1,patternProperties:{"^x-":{}}},reservations:{type:"object",description:"Resource reservations for the service containers.",properties:{cpus:{type:["number","string"],description:"Reservation for how much of the available CPU resources, as number of cores, a container can use."},memory:{type:"string",description:"Reservation on the amount of memory a container can allocate (e.g., '1g', '1024m')."},generic_resources:{$ref:"#/$defs/generic_resources",description:"User-defined resources to reserve."},devices:{$ref:"#/$defs/devices",description:"Device reservations for the container."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},restart_policy:{type:"object",description:"Restart policy for the service containers.",properties:{condition:{type:"string",description:"Condition for restarting the container: 'none', 'on-failure', 'any'."},delay:{type:"string",description:"Delay between restart attempts (e.g., '1s', '1m30s')."},max_attempts:{type:["integer","string"],description:"Maximum number of restart attempts before giving up."},window:{type:"string",description:"Time window used to evaluate the restart policy (e.g., '1s', '1m30s')."}},additionalProperties:!1,patternProperties:{"^x-":{}}},placement:{type:"object",description:"Constraints and preferences for the platform to select a physical node to run service containers",properties:{constraints:{type:"array",items:{type:"string"},description:"Placement constraints for the service (e.g., 'node.role==manager')."},preferences:{type:"array",description:"Placement preferences for the service.",items:{type:"object",properties:{spread:{type:"string",description:"Spread tasks evenly across values of the specified node label."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},max_replicas_per_node:{type:["integer","string"],description:"Maximum number of replicas of the service."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},generic_resources:{type:"array",description:"User-defined resources for services, allowing services to reserve specialized hardware resources.",items:{type:"object",properties:{discrete_resource_spec:{type:"object",description:"Specification for discrete (countable) resources.",properties:{kind:{type:"string",description:"Type of resource (e.g., 'GPU', 'FPGA', 'SSD')."},value:{type:["number","string"],description:"Number of resources of this kind to reserve."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}}},devices:{type:"array",description:"Device reservations for containers, allowing services to access specific hardware devices.",items:{type:"object",properties:{capabilities:{$ref:"#/$defs/list_of_strings",description:"List of capabilities the device needs to have (e.g., 'gpu', 'compute', 'utility')."},count:{type:["string","integer"],description:"Number of devices of this type to reserve."},device_ids:{$ref:"#/$defs/list_of_strings",description:"List of specific device IDs to reserve."},driver:{type:"string",description:"Device driver to use (e.g., 'nvidia')."},options:{$ref:"#/$defs/list_or_dict",description:"Driver-specific options for the device."}},additionalProperties:!1,patternProperties:{"^x-":{}},required:["capabilities"]}},gpus:{oneOf:[{type:"string",enum:["all"],description:"Use all available GPUs."},{type:"array",description:"List of specific GPU devices to use.",items:{type:"object",properties:{capabilities:{$ref:"#/$defs/list_of_strings",description:"List of capabilities the GPU needs to have (e.g., 'compute', 'utility')."},count:{type:["string","integer"],description:"Number of GPUs to use."},device_ids:{$ref:"#/$defs/list_of_strings",description:"List of specific GPU device IDs to use."},driver:{type:"string",description:"GPU driver to use (e.g., 'nvidia')."},options:{$ref:"#/$defs/list_or_dict",description:"Driver-specific options for the GPU."}}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},include:{description:"Compose application or sub-projects to be included.",oneOf:[{type:"string"},{type:"object",properties:{path:{$ref:"#/$defs/string_or_list",description:"Path to the Compose application or sub-project files to include."},env_file:{$ref:"#/$defs/string_or_list",description:"Path to the environment files to use to define default values when interpolating variables in the Compose files being parsed."},project_directory:{type:"string",description:"Path to resolve relative paths set in the Compose file"}},additionalProperties:!1}]},network:{type:["object","null"],description:"Network configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this network."},driver:{type:"string",description:"Specify which driver should be used for this network. Default is 'bridge'."},driver_opts:{type:"object",description:"Specify driver-specific options defined as key/value pairs.",patternProperties:{"^.+$":{type:["string","number"]}}},ipam:{type:"object",description:"Custom IP Address Management configuration for this network.",properties:{driver:{type:"string",description:"Custom IPAM driver, instead of the default."},config:{type:"array",description:"List of IPAM configuration blocks.",items:{type:"object",properties:{subnet:{type:"string",description:"Subnet in CIDR format that represents a network segment."},ip_range:{type:"string",description:"Range of IPs from which to allocate container IPs."},gateway:{type:"string",description:"IPv4 or IPv6 gateway for the subnet."},aux_addresses:{type:"object",description:"Auxiliary IPv4 or IPv6 addresses used by Network driver.",additionalProperties:!1,patternProperties:{"^.+$":{type:"string"}}}},additionalProperties:!1,patternProperties:{"^x-":{}}}},options:{type:"object",description:"Driver-specific options for the IPAM driver.",additionalProperties:!1,patternProperties:{"^.+$":{type:"string"}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},external:{type:["boolean","string","object"],description:"Specifies that this network already exists and was created outside of Compose.",properties:{name:{deprecated:!0,type:"string",description:"Specifies the name of the external network. Deprecated: use the 'name' property instead."}},additionalProperties:!1,patternProperties:{"^x-":{}}},internal:{type:["boolean","string"],description:"Create an externally isolated network."},enable_ipv4:{type:["boolean","string"],description:"Enable IPv4 networking."},enable_ipv6:{type:["boolean","string"],description:"Enable IPv6 networking."},attachable:{type:["boolean","string"],description:"If true, standalone containers can attach to this network."},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the network using labels."}},additionalProperties:!1,patternProperties:{"^x-":{}}},volume:{type:["object","null"],description:"Volume configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this volume."},driver:{type:"string",description:"Specify which volume driver should be used for this volume."},driver_opts:{type:"object",description:"Specify driver-specific options.",patternProperties:{"^.+$":{type:["string","number"]}}},external:{type:["boolean","string","object"],description:"Specifies that this volume already exists and was created outside of Compose.",properties:{name:{deprecated:!0,type:"string",description:"Specifies the name of the external volume. Deprecated: use the 'name' property instead."}},additionalProperties:!1,patternProperties:{"^x-":{}}},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the volume using labels."}},additionalProperties:!1,patternProperties:{"^x-":{}}},secret:{type:"object",description:"Secret configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this secret."},environment:{type:"string",description:"Name of an environment variable from which to get the secret value."},file:{type:"string",description:"Path to a file containing the secret value."},external:{type:["boolean","string","object"],description:"Specifies that this secret already exists and was created outside of Compose.",properties:{name:{type:"string",description:"Specifies the name of the external secret."}}},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the secret using labels."},driver:{type:"string",description:"Specify which secret driver should be used for this secret."},driver_opts:{type:"object",description:"Specify driver-specific options.",patternProperties:{"^.+$":{type:["string","number"]}}},template_driver:{type:"string",description:"Driver to use for templating the secret's value."}},additionalProperties:!1,patternProperties:{"^x-":{}}},config:{type:"object",description:"Config configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this config."},content:{type:"string",description:"Inline content of the config."},environment:{type:"string",description:"Name of an environment variable from which to get the config value."},file:{type:"string",description:"Path to a file containing the config value."},external:{type:["boolean","string","object"],description:"Specifies that this config already exists and was created outside of Compose.",properties:{name:{deprecated:!0,type:"string",description:"Specifies the name of the external config. Deprecated: use the 'name' property instead."}}},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the config using labels."},template_driver:{type:"string",description:"Driver to use for templating the config's value."}},additionalProperties:!1,patternProperties:{"^x-":{}}},model:{type:"object",description:"Language Model for the Compose application.",properties:{name:{type:"string",description:"Custom name for this model."},model:{type:"string",description:"Language Model to run."},context_size:{type:"integer"},runtime_flags:{type:"array",items:{type:"string"},description:"Raw runtime flags to pass to the inference engine."}},required:["model"],additionalProperties:!1,patternProperties:{"^x-":{}}},command:{oneOf:[{type:"null",description:"No command specified, use the container's default command."},{type:"string",description:"Command as a string, which will be executed in a shell (e.g., '/bin/sh -c')."},{type:"array",description:"Command as an array of strings, which will be executed directly without a shell.",items:{type:"string",description:"Part of the command (executable or argument)."}}],description:"Command to run in the container, which can be specified as a string (shell form) or array (exec form)."},service_hook:{type:"object",description:"Configuration for service lifecycle hooks, which are commands executed at specific points in a container's lifecycle.",properties:{command:{$ref:"#/$defs/command",description:"Command to execute as part of the hook."},user:{type:"string",description:"User to run the command as."},privileged:{type:["boolean","string"],description:"Whether to run the command with extended privileges."},working_dir:{type:"string",description:"Working directory for the command."},environment:{$ref:"#/$defs/list_or_dict",description:"Environment variables for the command."}},additionalProperties:!1,patternProperties:{"^x-":{}},required:["command"]},pre_start_hook:{type:"object",description:"Configuration for a pre_start init container, run to completion before the service container starts.",properties:{command:{$ref:"#/$defs/command",description:"Command to execute. Optional when the chosen image's entrypoint already runs the intended command."},image:{type:"string",description:"Image used for the ephemeral container. If omitted, the parent service's image is used."},user:{type:"string",description:"User to run the command as. Defaults to the user declared in image (or to the service's user when image is omitted)."},privileged:{type:["boolean","string"],description:"Whether to run the command with extended privileges."},working_dir:{type:"string",description:"Working directory for the command. Defaults to the service's working directory."},environment:{$ref:"#/$defs/list_or_dict",description:"Environment variables for the command. Appended to or overriding the service environment."},per_replica:{type:["boolean","string"],description:"Whether the hook runs once per service replica (true), or once for the service as a whole before any replica starts (false, the default)."}},additionalProperties:!1,patternProperties:{"^x-":{}}},env_file:{oneOf:[{type:"string",description:"Path to a file containing environment variables."},{type:"array",description:"List of paths to files containing environment variables.",items:{oneOf:[{type:"string",description:"Path to a file containing environment variables."},{type:"object",description:"Detailed configuration for an environment file.",additionalProperties:!1,properties:{path:{type:"string",description:"Path to the environment file."},format:{type:"string",description:"Format attribute lets you to use an alternative file formats for env_file. When not set, env_file is parsed according to Compose rules."},required:{type:["boolean","string"],default:!0,description:"Whether the file is required. If true and the file doesn't exist, an error will be raised."}},required:["path"]}]}}]},label_file:{oneOf:[{type:"string",description:"Path to a file containing Docker labels."},{type:"array",description:"List of paths to files containing Docker labels.",items:{type:"string",description:"Path to a file containing Docker labels."}}]},string_or_list:{oneOf:[{type:"string",description:"A single string value."},{$ref:"#/$defs/list_of_strings",description:"A list of string values."}],description:"Either a single string or a list of strings."},list_of_strings:{type:"array",description:"A list of unique string values.",items:{type:"string",description:"A string value in the list."},uniqueItems:!0},list_or_dict:{oneOf:[{type:"object",description:"A dictionary mapping keys to values.",patternProperties:{".+":{type:["string","number","boolean","null"],description:"Value for the key, which can be a string, number, boolean, or null."}},additionalProperties:!1},{type:"array",description:"A list of unique string values.",items:{type:"string",description:"A string value in the list."},uniqueItems:!0}],description:"Either a dictionary mapping keys to values, or a list of strings."},extra_hosts:{oneOf:[{type:"object",description:"list mapping hostnames to IP addresses.",patternProperties:{".+":{oneOf:[{type:"string",description:"IP address for the hostname."},{type:"array",description:"List of IP addresses for the hostname.",items:{type:"string",description:"IP address for the hostname."},uniqueItems:!1}]}},additionalProperties:!1},{type:"array",description:"List of host:IP mappings in the format 'hostname:IP'.",items:{type:"string",description:"Host:IP mapping in the format 'hostname:IP'."},uniqueItems:!0}],description:"Additional hostnames to be defined in the container's /etc/hosts file."},blkio_limit:{type:"object",description:"Block IO limit for a specific device.",properties:{path:{type:"string",description:"Path to the device (e.g., '/dev/sda')."},rate:{type:["integer","string"],description:"Rate limit in bytes per second or IO operations per second."}},additionalProperties:!1},blkio_weight:{type:"object",description:"Block IO weight for a specific device.",properties:{path:{type:"string",description:"Path to the device (e.g., '/dev/sda')."},weight:{type:["integer","string"],description:"Relative weight for the device, between 10 and 1000."}},additionalProperties:!1},service_config_or_secret:{type:"array",description:"Configuration for service configs or secrets, defining how they are mounted in the container.",items:{oneOf:[{type:"string",description:"Name of the config or secret to grant access to."},{type:"object",description:"Detailed configuration for a config or secret.",properties:{source:{type:"string",description:"Name of the config or secret as defined in the top-level configs or secrets section."},target:{type:"string",description:"Path in the container where the config or secret will be mounted. Defaults to /<source> for configs and /run/secrets/<source> for secrets."},uid:{type:"string",description:"UID of the file in the container. Default is 0 (root)."},gid:{type:"string",description:"GID of the file in the container. Default is 0 (root)."},mode:{type:["number","string"],description:"File permission mode inside the container, in octal. Default is 0444 for configs and 0400 for secrets."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]}},ulimits:{type:"object",description:"Container ulimit options, controlling resource limits for processes inside the container.",patternProperties:{"^[a-z]+$":{oneOf:[{type:["integer","string"],description:"Single value for both soft and hard limits."},{type:"object",description:"Separate soft and hard limits.",properties:{hard:{type:["integer","string"],description:"Hard limit for the ulimit type. This is the maximum allowed value."},soft:{type:["integer","string"],description:"Soft limit for the ulimit type. This is the value that's actually enforced."}},required:["soft","hard"],additionalProperties:!1,patternProperties:{"^x-":{}}}]}}}}}});import{readdir as av}from"fs/promises";import{join as cv}from"path";var{file:uv,YAML:lv}=globalThis.Bun;function dv(){if(!To)To=Promise.resolve().then(() => (hm(),{})).then(({})=>Df(mm)).catch((e)=>{throw To=void 0,e});return To}function gm(e){return uv(e).text().then(lv.parse).then(async(t)=>(await dv()).parse(t))}async function ym(e){return(await av(e,{withFileTypes:!0})).filter((r)=>r.isFile()&&pv.has(r.name)).map((r)=>cv(e,r.name)).sort()[0]}var pv,To;var bm=_(()=>{Us();pv=new Set(["compose.yml","compose.yaml","docker-compose.yml","docker-compose.yaml"])});import{AsyncLocalStorage as fv}from"async_hooks";function mv(e,t){if(e.projectConfigured)return e.project;return t.name?.trim()||e.project}async function wm(e,t){let r=process.cwd(),o=await dm(r,t),n=Oo("composeFile",()=>o.composeFile?Promise.resolve(o.composeFile):ym(r)),i=Oo("parsedCompose",async()=>{let c=await n();if(!c)throw Error("Compose file cannot be found");return gm(c)});if(!o.projectConfigured){if(await n())o.project=mv(o,await i())}let s=Oo("hookContext",async()=>{let c=await n();if(!c)throw Error("Compose file cannot be found");return fm(o,r,c)}),a=Oo("compose",async()=>{let c=await s(),u=await i();return await o.compose?.(u,c),u});return await _m.run({project:o.project,cwd:r,config:o,path:n,hookContext:s,compose:a},e)}function I(){let e=_m.getStore();if(!e)throw Error("Not in context!");return e}function Oo(e,t){let r;return()=>(r??=t().catch((o)=>{throw r=void 0,o}),r)}var _m;var ee=_(()=>{Ro();bm();_m=new fv});import{createHash as hv,randomUUID as gv}from"crypto";import{chmod as vm,mkdir as yv,readFile as bv,realpath as _v,rename as wv,writeFile as vv}from"fs/promises";import{join as xm}from"path";function Sm(){return xm(process.env.XDG_CONFIG_HOME??xm(process.env.HOME??"/tmp",".config"),"kuber","trust.json")}async function gt(e,t=process.cwd()){let r=await _v(t);return{project:e,fingerprint:hv("sha256").update(r).digest("hex")}}function xv(e){return!!e&&typeof e==="object"&&typeof e.project==="string"&&typeof e.fingerprint==="string"&&/^[a-f0-9]{64}$/.test(e.fingerprint)}async function Io(){try{let e=JSON.parse(await bv(Sm(),"utf8"));if(!e||typeof e!=="object"||e.version!==Em||!Array.isArray(e.records))return[];return e.records.filter(xv)}catch{return[]}}async function Ev(e){let t=Sm(),r=t.slice(0,t.lastIndexOf("/"));await yv(r,{recursive:!0,mode:448}),await vm(r,448);let o=`${t}.${gv()}.tmp`;await vv(o,JSON.stringify({version:Em,records:e},null,2)+`
|
|
80
|
-
`,{flag:"wx",mode:384}),await
|
|
81
|
-
${t}`,Ov,Iv,Bv=(e,t,r)=>{let o=r===""?"":`with ${r.trim()}() `,n=Tv.bind(null,o,t.toString());Object.defineProperty(n,"name",Iv);let{writable:i,enumerable:s,configurable:a}=Ov;Object.defineProperty(e,"toString",{value:n,writable:i,enumerable:s,configurable:a})};var Om=_(()=>{Ov=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Iv=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name")});var Do,Im=(e,t={})=>{if(typeof e!=="function")throw TypeError("Expected a function");let r,o=0,n=e.displayName||e.name||"<anonymous>",i=function(...s){if(Do.set(i,++o),o===1)r=e.apply(this,s),e=void 0;else if(t.throw===!0)throw Error(`Function \`${n}\` can only be called once`);return r};return na(i,e),Do.set(i,o),i},Bm;var zm=_(()=>{Om();Do=new WeakMap;Im.callCount=(e)=>{if(!Do.has(e))throw Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Do.get(e)};Bm=Im});var rt;var Dm=_(()=>{rt=[];rt.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")rt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")rt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class Nm{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(sa[ia])return sa[ia];zv(sa,ia,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let r=this.listeners[e],o=r.indexOf(t);if(o===-1)return;if(o===0&&r.length===1)r.length=0;else r.splice(o,1)}emit(e,t,r){if(this.emitted[e])return!1;this.emitted[e]=!0;let o=!1;for(let n of this.listeners[e])o=n(t,r)===!0||o;if(e==="exit")o=this.emit("afterExit",t,r)||o;return o}}class ca{}var No=(e)=>!!e&&typeof e==="object"&&typeof e.removeListener==="function"&&typeof e.emit==="function"&&typeof e.reallyExit==="function"&&typeof e.listeners==="function"&&typeof e.kill==="function"&&typeof e.pid==="number"&&typeof e.on==="function",ia,sa,zv,Dv=(e)=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),Lm,Vm,aa,Um,H0,J0;var Fm=_(()=>{Dm();ia=Symbol.for("signal-exit emitter"),sa=globalThis,zv=Object.defineProperty.bind(Object);Lm=class Lm extends ca{onExit(){return()=>{}}load(){}unload(){}};Vm=class Vm extends ca{#t=aa.platform==="win32"?"SIGINT":"SIGHUP";#r=new Nm;#e;#o;#s;#i={};#n=!1;constructor(e){super();this.#e=e,this.#i={};for(let t of rt)this.#i[t]=()=>{let r=this.#e.listeners(t),{count:o}=this.#r,n=e;if(typeof n.__signal_exit_emitter__==="object"&&typeof n.__signal_exit_emitter__.count==="number")o+=n.__signal_exit_emitter__.count;if(r.length===o){this.unload();let i=this.#r.emit("exit",null,t),s=t==="SIGHUP"?this.#t:t;if(!i)e.kill(e.pid,s)}};this.#s=e.reallyExit,this.#o=e.emit}onExit(e,t){if(!No(this.#e))return()=>{};if(this.#n===!1)this.load();let r=t?.alwaysLast?"afterExit":"exit";return this.#r.on(r,e),()=>{if(this.#r.removeListener(r,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0)this.unload()}}load(){if(this.#n)return;this.#n=!0,this.#r.count+=1;for(let e of rt)try{let t=this.#i[e];if(t)this.#e.on(e,t)}catch(t){}this.#e.emit=(e,...t)=>this.#c(e,...t),this.#e.reallyExit=(e)=>this.#a(e)}unload(){if(!this.#n)return;this.#n=!1,rt.forEach((e)=>{let t=this.#i[e];if(!t)throw Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,t)}catch(r){}}),this.#e.emit=this.#o,this.#e.reallyExit=this.#s,this.#r.count-=1}#a(e){if(!No(this.#e))return 0;return this.#e.exitCode=e||0,this.#r.emit("exit",this.#e.exitCode,null),this.#s.call(this.#e,this.#e.exitCode)}#c(e,...t){let r=this.#o;if(e==="exit"&&No(this.#e)){if(typeof t[0]==="number")this.#e.exitCode=t[0];let o=r.call(this.#e,e,...t);return this.#r.emit("exit",this.#e.exitCode,null),o}else return r.call(this.#e,e,...t)}};aa=globalThis.process,{onExit:Um,load:H0,unload:J0}=Dv(No(aa)?new Vm(aa):new Lm)});import Lo from"process";var Mm,Nv,jm;var Zm=_(()=>{zm();Fm();Mm=Lo.stderr.isTTY?Lo.stderr:Lo.stdout.isTTY?Lo.stdout:void 0,Nv=Mm?Bm(()=>{Um(()=>{Mm.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},jm=Nv});import qm from"process";var Vo=!1,_t,ua;var Qm=_(()=>{Zm();_t={};_t.show=(e=qm.stderr)=>{if(!e.isTTY)return;Vo=!1,e.write("\x1B[?25h")};_t.hide=(e=qm.stderr)=>{if(!e.isTTY)return;jm(),Vo=!0,e.write("\x1B[?25l")};_t.toggle=(e,t)=>{if(e!==void 0)Vo=e;if(Vo)_t.show(t);else _t.hide(t)};ua=_t});function la({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}function Me(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes("\x9B"))return e;return e.replace(Lv,"")}var Lv;var Uo=_(()=>{Lv=la()});var Wm=161,Gm=1114109,Km,Hm=12288,Jm=65510,Ym,Xm=4352,eh=262141,pa;var th=_(()=>{Km=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Ym=[12288,12288,65281,65376,65504,65510],pa=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141]});var Fo=(e,t)=>{let r=0,o=Math.floor(e.length/2)-1;while(r<=o){let n=Math.floor((r+o)/2),i=n*2;if(t<e[i])o=n-1;else if(t>e[i+1])r=n+1;else return!0}return!1};function Fv(e){let t=e[0],r=e[1];for(let o=0;o<e.length;o+=2){let n=e[o],i=e[o+1];if(rh>=n&&rh<=i)return[n,i];if(i-n>r-t)t=n,r=i}return[t,r]}var rh=19968,Vv,Uv,oh=(e)=>{if(e<Wm||e>Gm)return!1;return Fo(Km,e)},nr=(e)=>{if(e<Hm||e>Jm)return!1;return Fo(Ym,e)},ir=(e)=>{if(e>=Vv&&e<=Uv)return!0;if(e<Xm||e>eh)return!1;return Fo(pa,e)};var da=_(()=>{th();[Vv,Uv]=Fv(pa)});function Mv(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function sr(e,{ambiguousAsWide:t=!1}={}){if(Mv(e),nr(e)||ir(e)||t&&oh(e))return 2;return 1}var fa=_(()=>{da();da()});function Kv(e){if(e.length>50)return!1;if(Wv.test(e))return!0;if(e.includes("\u200D")){let t=e.match(Gv);return t!==null&&t.length>=2}return!1}function Hv(e){return e.replace(Zv,"")}function Jv(e){return nh.test(e)}function ih(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function sh(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function ah(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function Yv(e){return ih(e)||sh(e)||ah(e)}function Xv(e,t){let r=[];for(let n of e){if(nh.test(n))continue;r.push(n.codePointAt(0))}if(r.length===0)return;let o=0;for(let n=0;n<r.length;n++){let i=r[n];if(!Yv(i)){if(o===0)return;for(let s=n;s<r.length;s++)o+=sr(r[s],t);return o}if(ih(i)&&sh(r[n+1])){o+=2,n+=ah(r[n+2])?2:1;continue}o+=sr(i,t)}return o}function ex(e,t){let r=0,o=!0;for(let n of e){if(o){o=!1;continue}if(qv.test(n)||n>="\uFF00"&&n<="\uFFEF")r+=sr(n.codePointAt(0),t)}return r}function Q(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:r=!0,countAnsiEscapeCodes:o=!1}=t,n=e;if(!o&&(n.includes("\x1B")||n.includes("\x9B")))n=Me(n);if(n.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(n))return n.length;let i=0,s={ambiguousAsWide:!r};for(let{segment:a}of jv.segment(n)){if(Jv(a))continue;if(Qv.test(a)||Kv(a)){i+=2;continue}let c=Hv(a),u=Xv(c,s);if(u!==void 0){i+=u;continue}let l=c.codePointAt(0);i+=sr(l,s),i+=ex(c,s)}return i}var jv,nh,Zv,qv,Qv,Wv,Gv;var Mo=_(()=>{Uo();fa();jv=new Intl.Segmenter,nh=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,Zv=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,qv=/\p{Spacing_Mark}/v,Qv=/^\p{RGI_Emoji}$/v,Wv=/^[\d#*]\u20E3$/,Gv=/\p{Extended_Pictographic}/gu});function ox(){let e=new Map;for(let[t,r]of Object.entries(F)){for(let[o,n]of Object.entries(r))F[o]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},r[o]=F[o],e.set(n[0],n[1]);Object.defineProperty(F,t,{value:r,enumerable:!1})}return Object.defineProperty(F,"codes",{value:e,enumerable:!1}),F.color.close="\x1B[39m",F.bgColor.close="\x1B[49m",F.color.ansi=ch(),F.color.ansi256=uh(),F.color.ansi16m=lh(),F.bgColor.ansi=ch(10),F.bgColor.ansi256=uh(10),F.bgColor.ansi16m=lh(10),Object.defineProperties(F,{rgbToAnsi256:{value(t,r,o){if(t===r&&r===o){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[o]=r;if(o.length===3)o=[...o].map((i)=>i+i).join("");let n=Number.parseInt(o,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:(t)=>F.rgbToAnsi256(...F.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,o,n;if(t>=232)r=((t-232)*10+8)/255,o=r,n=r;else{t-=16;let a=t%36;r=Math.floor(t/36)/5,o=Math.floor(a/6)/5,n=a%6/5}let i=Math.max(r,o,n)*2;if(i===0)return 30;let s=30+(Math.round(n)<<2|Math.round(o)<<1|Math.round(r));if(i===2)s+=60;return s},enumerable:!1},rgbToAnsi:{value:(t,r,o)=>F.ansi256ToAnsi(F.rgbToAnsi256(t,r,o)),enumerable:!1},hexToAnsi:{value:(t)=>F.ansi256ToAnsi(F.hexToAnsi256(t)),enumerable:!1}}),F}var ch=(e=0)=>(t)=>`\x1B[${t+e}m`,uh=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,lh=(e=0)=>(t,r,o)=>`\x1B[${38+e};2;${t};${r};${o}m`,F,kR,tx,rx,PR,nx,pe;var ma=_(()=>{F={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},kR=Object.keys(F.modifier),tx=Object.keys(F.color),rx=Object.keys(F.bgColor),PR=[...tx,...rx];nx=ox(),pe=nx});function ar(e,t,r){return String(e).normalize().replaceAll(`\r
|
|
69
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");let P=p.compile();return(E,A)=>P(d,E,A)},i,s=pt,a=!ut.jitless,u=a&&kc.value,l=t.catchall,f;e._zod.parse=(d,p)=>{f??(f=o.value);let m=d.value;if(!s(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),d;if(a&&u&&p?.async===!1&&p.jitless!==!0){if(!i)i=n(t.shape);if(d=i(d,p),!l)return d;return bl([],m,d,p,f,e)}return r(d,p)}});Qr=g("$ZodUnion",(e,t)=>{R.init(e,t),I(e._zod,"optin",()=>t.options.some((o)=>o._zod.optin==="optional")?"optional":void 0),I(e._zod,"optout",()=>t.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),I(e._zod,"values",()=>{if(t.options.every((o)=>o._zod.values))return new Set(t.options.flatMap((o)=>Array.from(o._zod.values)));return}),I(e._zod,"pattern",()=>{if(t.options.every((o)=>o._zod.pattern)){let o=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${o.map((n)=>Tr(n.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return vu(s,o,e,n);return Promise.all(s).then((a)=>vu(a,o,e,n))}});wl=g("$ZodXor",(e,t)=>{Qr.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else s.push(c)}if(!i)return xu(s,o,e,n);return Promise.all(s).then((a)=>xu(a,o,e,n))}}),vl=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Qr.init(e,t);let r=e._zod.parse;I(e._zod,"propValues",()=>{let n={};for(let i of t.options){let s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[a,c]of Object.entries(s)){if(!n[a])n[a]=new Set;for(let u of c)n[a].add(u)}}return n});let o=Bt(()=>{let n=t.options,i=new Map;for(let s of n){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let c of a){if(i.has(c))throw Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,s)}}return i});e._zod.parse=(n,i)=>{let s=n.value;if(!pt(s))return n.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),n;let a=o.value.get(s?.[t.discriminator]);if(a)return a._zod.run(n,i);if(t.unionFallback||i.direction==="backward")return r(n,i);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()),input:s,path:[t.discriminator],inst:e}),n}}),xl=g("$ZodIntersection",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,i=t.left._zod.run({value:n,issues:[]},o),s=t.right._zod.run({value:n,issues:[]},o);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>Eu(r,c,u));return Eu(r,i,s)}});Ai=g("$ZodTuple",(e,t)=>{R.init(e,t);let r=t.items;e._zod.parse=(o,n)=>{let i=o.value;if(!Array.isArray(i))return o.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=[];let s=[],a=Su(r,"optin"),c=Su(r,"optout");if(!t.rest){if(i.length<a)return o.issues.push({code:"too_small",minimum:a,inclusive:!0,input:i,inst:e,origin:"array"}),o;if(i.length>r.length)o.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:i,inst:e,origin:"array"})}let u=Array(r.length);for(let l=0;l<r.length;l++){let f=r[l]._zod.run({value:i[l],issues:[]},n);if(f instanceof Promise)s.push(f.then((d)=>{u[l]=d}));else u[l]=f}if(t.rest){let l=r.length-1,f=i.slice(r.length);for(let d of f){l++;let p=t.rest._zod.run({value:d,issues:[]},n);if(p instanceof Promise)s.push(p.then((m)=>$u(m,o,l)));else $u(p,o,l)}}if(s.length)return Promise.all(s).then(()=>Au(u,o,r,i,c));return Au(u,o,r,i,c)}});El=g("$ZodRecord",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Je(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let i=[],s=t.keyType._zod.values;if(s){r.value={};let a=new Set;for(let u of s)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){a.add(typeof u==="number"?u.toString():u);let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((p)=>ne(p,o,H())),input:u,path:[u],inst:e});continue}let f=l.value,d=t.valueType._zod.run({value:n[u],issues:[]},o);if(d instanceof Promise)i.push(d.then((p)=>{if(p.issues.length)r.issues.push(...ae(u,p.issues));r.value[f]=p.value}));else{if(d.issues.length)r.issues.push(...ae(u,d.issues));r.value[f]=d.value}}let c;for(let u in n)if(!a.has(u))c=c??[],c.push(u);if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(n)){if(a==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(n,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof a==="string"&&Lr.test(a)&&c.issues.length){let f=t.keyType._zod.run({value:Number(a),issues:[]},o);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length===0)c=f}if(c.issues.length){if(t.mode==="loose")r.value[a]=n[a];else r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map((f)=>ne(f,o,H())),input:a,path:[a],inst:e});continue}let l=t.valueType._zod.run({value:n[a],issues:[]},o);if(l instanceof Promise)i.push(l.then((f)=>{if(f.issues.length)r.issues.push(...ae(a,f.issues));r.value[c.value]=f.value}));else{if(l.issues.length)r.issues.push(...ae(a,l.issues));r.value[c.value]=l.value}}}if(i.length)return Promise.all(i).then(()=>r);return r}}),Sl=g("$ZodMap",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!(n instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),r;let i=[];r.value=new Map;for(let[s,a]of n){let c=t.keyType._zod.run({value:s,issues:[]},o),u=t.valueType._zod.run({value:a,issues:[]},o);if(c instanceof Promise||u instanceof Promise)i.push(Promise.all([c,u]).then(([l,f])=>{ku(l,f,r,s,n,e,o)}));else ku(c,u,r,s,n,e,o)}if(i.length)return Promise.all(i).then(()=>r);return r}});$l=g("$ZodSet",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!(n instanceof Set))return r.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),r;let i=[];r.value=new Set;for(let s of n){let a=t.valueType._zod.run({value:s,issues:[]},o);if(a instanceof Promise)i.push(a.then((c)=>Pu(c,r)));else Pu(a,r)}if(i.length)return Promise.all(i).then(()=>r);return r}});Al=g("$ZodEnum",(e,t)=>{R.init(e,t);let r=Rr(t.entries),o=new Set(r);e._zod.values=o,e._zod.pattern=new RegExp(`^(${r.filter((n)=>Or.has(typeof n)).map((n)=>typeof n==="string"?ye(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let s=n.value;if(o.has(s))return n;return n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),kl=g("$ZodLiteral",(e,t)=>{if(R.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map((o)=>typeof o==="string"?ye(o):o?ye(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,n)=>{let i=o.value;if(r.has(i))return o;return o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),Pl=g("$ZodFile",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(n instanceof File)return r;return r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),Cl=g("$ZodTransform",(e,t)=>{R.init(e,t),e._zod.optin="optional",e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new lt(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then((s)=>(r.value=s,r.fallback=!0,r));if(n instanceof Promise)throw new Ie;return r.value=n,r.fallback=!0,r}});ki=g("$ZodOptional",(e,t)=>{R.init(e,t),e._zod.optin="optional",e._zod.optout="optional",I(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),I(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Tr(r.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(t.innerType._zod.optin==="optional"){let n=r.value,i=t.innerType._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Cu(s,n));return Cu(i,n)}if(r.value===void 0)return r;return t.innerType._zod.run(r,o)}}),Rl=g("$ZodExactOptional",(e,t)=>{ki.init(e,t),I(e._zod,"values",()=>t.innerType._zod.values),I(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),Tl=g("$ZodNullable",(e,t)=>{R.init(e,t),I(e._zod,"optin",()=>t.innerType._zod.optin),I(e._zod,"optout",()=>t.innerType._zod.optout),I(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Tr(r.source)}|null)$`):void 0}),I(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>{if(r.value===null)return r;return t.innerType._zod.run(r,o)}}),Ol=g("$ZodDefault",(e,t)=>{R.init(e,t),e._zod.optin="optional",I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Ru(i,t));return Ru(n,t)}});Il=g("$ZodPrefault",(e,t)=>{R.init(e,t),e._zod.optin="optional",I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,o)}}),Bl=g("$ZodNonOptional",(e,t)=>{R.init(e,t),I(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Tu(i,e));return Tu(n,e)}});zl=g("$ZodSuccess",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new lt("ZodSuccess");let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>(r.value=i.issues.length===0,r));return r.value=n.issues.length===0,r}}),Dl=g("$ZodCatch",(e,t)=>{R.init(e,t),e._zod.optin="optional",I(e._zod,"optout",()=>t.innerType._zod.optout),I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>{if(r.value=i.value,i.issues.length)r.value=t.catchValue({...r,error:{issues:i.issues.map((s)=>ne(s,o,H()))},input:r.value}),r.issues=[],r.fallback=!0;return r});if(r.value=n.value,n.issues.length)r.value=t.catchValue({...r,error:{issues:n.issues.map((i)=>ne(i,o,H()))},input:r.value}),r.issues=[],r.fallback=!0;return r}}),Nl=g("$ZodNaN",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{if(typeof r.value!=="number"||!Number.isNaN(r.value))return r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r;return r}}),Pi=g("$ZodPipe",(e,t)=>{R.init(e,t),I(e._zod,"values",()=>t.in._zod.values),I(e._zod,"optin",()=>t.in._zod.optin),I(e._zod,"optout",()=>t.out._zod.optout),I(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let i=t.out._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Mr(s,t.in,o));return Mr(i,t.in,o)}let n=t.in._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Mr(i,t.out,o));return Mr(n,t.out,o)}});Wr=g("$ZodCodec",(e,t)=>{R.init(e,t),I(e._zod,"values",()=>t.in._zod.values),I(e._zod,"optin",()=>t.in._zod.optin),I(e._zod,"optout",()=>t.out._zod.optout),I(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if((o.direction||"forward")==="forward"){let i=t.in._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Fr(s,t,o));return Fr(i,t,o)}else{let i=t.out._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Fr(s,t,o));return Fr(i,t,o)}}});Ll=g("$ZodPreprocess",(e,t)=>{Pi.init(e,t)}),Vl=g("$ZodReadonly",(e,t)=>{R.init(e,t),I(e._zod,"propValues",()=>t.innerType._zod.propValues),I(e._zod,"values",()=>t.innerType._zod.values),I(e._zod,"optin",()=>t.innerType?._zod?.optin),I(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then(Ou);return Ou(n)}});Ul=g("$ZodTemplateLiteral",(e,t)=>{R.init(e,t);let r=[];for(let o of t.parts)if(typeof o==="object"&&o!==null){if(!o._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...o._zod.traits].shift()}`);let n=o._zod.pattern instanceof RegExp?o._zod.pattern.source:o._zod.pattern;if(!n)throw Error(`Invalid template literal part: ${o._zod.traits}`);let i=n.startsWith("^")?1:0,s=n.endsWith("$")?n.length-1:n.length;r.push(n.slice(i,s))}else if(o===null||Pc.has(typeof o))r.push(ye(`${o}`));else throw Error(`Invalid template literal part: ${o}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(o,n)=>{if(typeof o.value!=="string")return o.issues.push({input:o.value,inst:e,expected:"string",code:"invalid_type"}),o;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(o.value))return o.issues.push({input:o.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),o;return o}}),Ml=g("$ZodFunction",(e,t)=>(R.init(e,t),e._def=t,e._zod.def=t,e.implement=(r)=>{if(typeof r!=="function")throw Error("implement() must be called with a function");return function(...o){let n=e._def.input?Fn(e._def.input,o):o,i=Reflect.apply(r,this,n);if(e._def.output)return Fn(e._def.output,i);return i}},e.implementAsync=(r)=>{if(typeof r!=="function")throw Error("implementAsync() must be called with a function");return async function(...o){let n=e._def.input?await jn(e._def.input,o):o,i=await Reflect.apply(r,this,n);if(e._def.output)return await jn(e._def.output,i);return i}},e._zod.parse=(r,o)=>{if(typeof r.value!=="function")return r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r;if(e._def.output&&e._def.output._zod.def.type==="promise")r.value=e.implementAsync(r.value);else r.value=e.implement(r.value);return r},e.input=(...r)=>{let o=e.constructor;if(Array.isArray(r[0]))return new o({type:"function",input:new Ai({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output});return new o({type:"function",input:r[0],output:e._def.output})},e.output=(r)=>new e.constructor({type:"function",input:e._def.input,output:r}),e)),Fl=g("$ZodPromise",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>Promise.resolve(r.value).then((n)=>t.innerType._zod.run({value:n,issues:[]},o))}),jl=g("$ZodLazy",(e,t)=>{R.init(e,t),I(e._zod,"innerType",()=>{let r=t;if(!r._cachedInner)r._cachedInner=t.getter();return r._cachedInner}),I(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),I(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),I(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),I(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,o)=>e._zod.innerType._zod.run(r,o)}),Zl=g("$ZodCustom",(e,t)=>{U.init(e,t),R.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=(r)=>{let o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then((i)=>Iu(i,r,o,e));Iu(n,r,o,e);return}})});function Ri(){return{localeError:p_()}}var p_=()=>{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(n){return e[n]??null}let r={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",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=Ic(n.input),a=o[s]??s;return`Invalid input: expected ${i}, received ${a}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${Ln(n.values[0])}`;return`Invalid option: expected one of ${Bn(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${s.unit??"elements"}`;return`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${s.unit}`;return`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Invalid string: must start with "${i.prefix}"`;if(i.format==="ends_with")return`Invalid string: must end with "${i.suffix}"`;if(i.format==="includes")return`Invalid string: must include "${i.includes}"`;if(i.format==="regex")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${r[i.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Bn(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":if(n.options&&Array.isArray(n.options)&&n.options.length>0)return`Invalid discriminator value. Expected ${n.options.map((s)=>`'${s}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};var ql=_(()=>{de()});var Ti=()=>{};class Gl{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let o={...r,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Kl(){return new Gl}var Wl,d_,f_,te;var jt=_(()=>{d_=Symbol("ZodOutput"),f_=Symbol("ZodInput");(Wl=globalThis).__zod_globalRegistry??(Wl.__zod_globalRegistry=Kl());te=globalThis.__zod_globalRegistry});function Hl(e,t){return new e({type:"string",...w(t)})}function Oi(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...w(t)})}function Gr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...w(t)})}function Ii(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...w(t)})}function Bi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...w(t)})}function zi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...w(t)})}function Di(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...w(t)})}function Kr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...w(t)})}function Ni(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...w(t)})}function Li(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...w(t)})}function Vi(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...w(t)})}function Ui(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...w(t)})}function Mi(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...w(t)})}function Fi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...w(t)})}function ji(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...w(t)})}function Zi(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...w(t)})}function qi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...w(t)})}function Jl(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...w(t)})}function Qi(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...w(t)})}function Wi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...w(t)})}function Gi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...w(t)})}function Ki(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...w(t)})}function Hi(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...w(t)})}function Ji(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...w(t)})}function Yl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...w(t)})}function Xl(e,t){return new e({type:"string",format:"date",check:"string_format",...w(t)})}function ep(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...w(t)})}function tp(e,t){return new e({type:"string",format:"duration",check:"string_format",...w(t)})}function rp(e,t){return new e({type:"number",checks:[],...w(t)})}function op(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...w(t)})}function np(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...w(t)})}function ip(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...w(t)})}function sp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...w(t)})}function ap(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...w(t)})}function cp(e,t){return new e({type:"boolean",...w(t)})}function up(e,t){return new e({type:"bigint",...w(t)})}function lp(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...w(t)})}function pp(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...w(t)})}function dp(e,t){return new e({type:"symbol",...w(t)})}function fp(e,t){return new e({type:"undefined",...w(t)})}function mp(e,t){return new e({type:"null",...w(t)})}function hp(e){return new e({type:"any"})}function gp(e){return new e({type:"unknown"})}function yp(e,t){return new e({type:"never",...w(t)})}function bp(e,t){return new e({type:"void",...w(t)})}function _p(e,t){return new e({type:"date",...w(t)})}function wp(e,t){return new e({type:"nan",...w(t)})}function Ve(e,t){return new _i({check:"less_than",...w(t),value:e,inclusive:!1})}function _e(e,t){return new _i({check:"less_than",...w(t),value:e,inclusive:!0})}function Ue(e,t){return new wi({check:"greater_than",...w(t),value:e,inclusive:!1})}function ce(e,t){return new wi({check:"greater_than",...w(t),value:e,inclusive:!0})}function vp(e){return Ue(0,e)}function xp(e){return Ve(0,e)}function Ep(e){return _e(0,e)}function Sp(e){return ce(0,e)}function ft(e,t){return new eu({check:"multiple_of",...w(t),value:e})}function mt(e,t){return new ou({check:"max_size",...w(t),maximum:e})}function Me(e,t){return new nu({check:"min_size",...w(t),minimum:e})}function Zt(e,t){return new iu({check:"size_equals",...w(t),size:e})}function qt(e,t){return new su({check:"max_length",...w(t),maximum:e})}function rt(e,t){return new au({check:"min_length",...w(t),minimum:e})}function Qt(e,t){return new cu({check:"length_equals",...w(t),length:e})}function Hr(e,t){return new uu({check:"string_format",format:"regex",...w(t),pattern:e})}function Jr(e){return new lu({check:"string_format",format:"lowercase",...w(e)})}function Yr(e){return new pu({check:"string_format",format:"uppercase",...w(e)})}function Xr(e,t){return new du({check:"string_format",format:"includes",...w(t),includes:e})}function eo(e,t){return new fu({check:"string_format",format:"starts_with",...w(t),prefix:e})}function to(e,t){return new mu({check:"string_format",format:"ends_with",...w(t),suffix:e})}function $p(e,t,r){return new hu({check:"property",property:e,schema:t,...w(r)})}function ro(e,t){return new gu({check:"mime_type",mime:e,...w(t)})}function Be(e){return new yu({check:"overwrite",tx:e})}function oo(e){return Be((t)=>t.normalize(e))}function no(){return Be((e)=>e.trim())}function io(){return Be((e)=>e.toLowerCase())}function so(){return Be((e)=>e.toUpperCase())}function ao(){return Be((e)=>Ac(e))}function Ap(e,t,r){return new e({type:"array",element:t,...w(r)})}function kp(e,t){return new e({type:"file",...w(t)})}function Pp(e,t,r){let o=w(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Cp(e,t,r){return new e({type:"custom",check:"custom",fn:t,...w(r)})}function Rp(e,t){let r=h_((o)=>(o.addIssue=(n)=>{if(typeof n==="string")o.issues.push(Xe(n,o.value,r._zod.def));else{let i=n;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=o.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),o.issues.push(Xe(i))}},e(o.value,o)),t);return r}function h_(e,t){let r=new U({check:"custom",...w(t)});return r._zod.check=e,r}function Tp(e){let t=new U({check:"describe"});return t._zod.onattach=[(r)=>{let o=te.get(r)??{};te.add(r,{...o,description:e})}],t._zod.check=()=>{},t}function Op(e){let t=new U({check:"meta"});return t._zod.onattach=[(r)=>{let o=te.get(r)??{};te.add(r,{...o,...e})}],t._zod.check=()=>{},t}function Ip(e,t){let r=w(t),o=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];if(r.case!=="sensitive")o=o.map((p)=>typeof p==="string"?p.toLowerCase():p),n=n.map((p)=>typeof p==="string"?p.toLowerCase():p);let i=new Set(o),s=new Set(n),a=e.Codec??Wr,c=e.Boolean??qr,l=new(e.String??dt)({type:"string",error:r.error}),f=new c({type:"boolean",error:r.error}),d=new a({type:"pipe",in:l,out:f,transform:(p,m)=>{let h=p;if(r.case!=="sensitive")h=h.toLowerCase();if(i.has(h))return!0;else if(s.has(h))return!1;else return m.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...s],input:m.value,inst:d,continue:!1}),{}},reverseTransform:(p,m)=>{if(p===!0)return o[0]||"true";else return n[0]||"false"},error:r.error});return d}function Wt(e,t,r,o={}){let n=w(o),i={...w(o),check:"string_format",type:"string",format:t,fn:typeof r==="function"?r:(a)=>r.test(a),...n};if(r instanceof RegExp)i.pattern=r;return new e(i)}var Bp=_(()=>{Ur();jt();Ci();de()});function Yi(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??te,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function j(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,r.schemaPath.includes(e))i.cycle=r.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{let d=s.schema,p=t.processors[n.type];if(!p)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);p(e,t,d,l)}let f=e._zod.parent;if(f){if(!s.ref)s.ref=f;j(f,t,l),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Object.assign(s.schema,c);if(t.io==="input"&&re(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(o=s.schema).default??(o.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function Xi(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=o.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,s[0])}}let n=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(s[0])?.id,d=e.external.uri??((m)=>m);if(f)return{ref:d(f)};let p=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=p,{defId:p,ref:`${d("__shared")}#/${a}/${p}`}}if(s[1]===r)return{ref:"#"};let u=`${"#"}/${a}/`,l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=n(s);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let f in l)delete l[f];l.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
70
|
+
|
|
71
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref"){i(s);continue}}}}function es(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},f=c.ref;if(c.ref=null,f){o(f);let p=e.seen.get(f),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(m);else Object.assign(u,m);if(Object.assign(u,l),a._zod.parent===f)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(!(y in l))delete u[y]}if(m.$ref&&p.def)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(y in p.def&&JSON.stringify(u[y])===JSON.stringify(p.def[y]))delete u[y]}}let d=a._zod.parent;if(d&&d!==f){o(d);let p=e.seen.get(d);if(p?.schema.$ref){if(u.$ref=p.schema.$ref,p.def)for(let m in u){if(m==="$ref"||m==="allOf")continue;if(m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m]))delete u[m]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())o(a[0]);let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}Object.assign(n,r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&n.id===i)delete n.id;let s=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;s[c.defId]=c.def}}if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")n.$defs=s;else n.definitions=s;try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Gt(t,"input",e.processors),output:Gt(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function re(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return re(o.element,r);if(o.type==="set")return re(o.valueType,r);if(o.type==="lazy")return re(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return re(o.innerType,r);if(o.type==="intersection")return re(o.left,r)||re(o.right,r);if(o.type==="record"||o.type==="map")return re(o.keyType,r)||re(o.valueType,r);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return re(o.in,r)||re(o.out,r)}if(o.type==="object"){for(let n in o.shape)if(re(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(re(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(re(n,r))return!0;if(o.rest&&re(o.rest,r))return!0;return!1}return!1}var zp=(e,t={})=>(r)=>{let o=Yi({...r,processors:t});return j(e,o),Xi(o,e),es(o,e)},Gt=(e,t,r={})=>(o)=>{let{libraryOptions:n,target:i}=o??{},s=Yi({...n??{},target:i,io:t,processors:r});return j(e,s),Xi(s,e),es(s,e)};var co=_(()=>{jt()});var g_,Dp=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i==="number")n.minLength=i;if(typeof s==="number")n.maxLength=s;if(a){if(n.format=g_[a]??a,n.format==="")delete n.format;if(a==="time")delete n.format}if(u)n.contentEncoding=u;if(c&&c.size>0){let l=[...c];if(l.length===1)n.pattern=l[0].source;else if(l.length>1)n.allOf=[...l.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},Np=(e,t,r,o)=>{let n=r,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;if(typeof a==="string"&&a.includes("int"))n.type="integer";else n.type="number";let f=typeof l==="number"&&l>=(i??Number.NEGATIVE_INFINITY),d=typeof u==="number"&&u<=(s??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(p)n.minimum=l,n.exclusiveMinimum=!0;else n.exclusiveMinimum=l;else if(typeof i==="number")n.minimum=i;if(d)if(p)n.maximum=u,n.exclusiveMaximum=!0;else n.exclusiveMaximum=u;else if(typeof s==="number")n.maximum=s;if(typeof c==="number")n.multipleOf=c},Lp=(e,t,r,o)=>{r.type="boolean"},Vp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},Up=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},Mp=(e,t,r,o)=>{if(t.target==="openapi-3.0")r.type="string",r.nullable=!0,r.enum=[null];else r.type="null"},Fp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},jp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},Zp=(e,t,r,o)=>{r.not={}},qp=(e,t,r,o)=>{},Qp=(e,t,r,o)=>{},Wp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},Gp=(e,t,r,o)=>{let n=e._zod.def,i=Rr(n.entries);if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";r.enum=i},Kp=(e,t,r,o)=>{let n=e._zod.def,i=[];for(let s of n.values)if(s===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else i.push(Number(s));else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[s];else r.const=s}else{if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";if(i.every((s)=>typeof s==="boolean"))r.type="boolean";if(i.every((s)=>s===null))r.type="null";r.enum=i}},Hp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},Jp=(e,t,r,o)=>{let n=r,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},Yp=(e,t,r,o)=>{let n=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=e._zod.bag;if(s!==void 0)i.minLength=s;if(a!==void 0)i.maxLength=a;if(c)if(c.length===1)i.contentMediaType=c[0],Object.assign(n,i);else Object.assign(n,i),n.anyOf=c.map((u)=>({contentMediaType:u}));else Object.assign(n,i)},Xp=(e,t,r,o)=>{r.type="boolean"},ed=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},td=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},rd=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},od=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},nd=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},id=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;if(typeof s==="number")n.minItems=s;if(typeof a==="number")n.maxItems=a;n.type="array",n.items=j(i.element,t,{...o,path:[...o.path,"items"]})},sd=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object",n.properties={};let s=i.shape;for(let u in s)n.properties[u]=j(s[u],t,{...o,path:[...o.path,"properties",u]});let a=new Set(Object.keys(s)),c=new Set([...a].filter((u)=>{let l=i.shape[u]._zod;if(t.io==="input")return l.optin===void 0;else return l.optout===void 0}));if(c.size>0)n.required=Array.from(c);if(i.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")n.additionalProperties=!1}else if(i.catchall)n.additionalProperties=j(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},ts=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((a,c)=>j(a,t,{...o,path:[...o.path,i?"oneOf":"anyOf",c]}));if(i)r.oneOf=s;else r.anyOf=s},ad=(e,t,r,o)=>{let n=e._zod.def,i=j(n.left,t,{...o,path:[...o.path,"allOf",0]}),s=j(n.right,t,{...o,path:[...o.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=c},cd=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((d,p)=>j(d,t,{...o,path:[...o.path,s,p]})),u=i.rest?j(i.rest,t,{...o,path:[...o.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(n.prefixItems=c,u)n.items=u}else if(t.target==="openapi-3.0"){if(n.items={anyOf:c},u)n.items.anyOf.push(u);if(n.minItems=c.length,!u)n.maxItems=c.length}else if(n.items=c,u)n.additionalItems=u;let{minimum:l,maximum:f}=e._zod.bag;if(typeof l==="number")n.minItems=l;if(typeof f==="number")n.maxItems=f},ud=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let s=i.keyType,c=s._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){let l=j(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let f of c)n.patternProperties[f.source]=l}else{if(t.target==="draft-07"||t.target==="draft-2020-12")n.propertyNames=j(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});n.additionalProperties=j(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let u=s._zod.values;if(u){let l=[...u].filter((f)=>typeof f==="string"||typeof f==="number");if(l.length>0)n.required=l}},ld=(e,t,r,o)=>{let n=e._zod.def,i=j(n.innerType,t,o),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=n.innerType,r.nullable=!0;else r.anyOf=[i,{type:"null"}]},pd=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},dd=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},fd=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io==="input")r._prefault=JSON.parse(JSON.stringify(n.defaultValue))},md=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let s;try{s=n.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},hd=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?n.out:n.in:n.out;j(s,t,o);let a=t.seen.get(e);a.ref=s},gd=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},yd=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},rs=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},bd=(e,t,r,o)=>{let n=e._zod.innerType;j(n,t,o);let i=t.seen.get(e);i.ref=n};var _d=_(()=>{co();de();g_={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""}});var wd=()=>{};var we=_(()=>{de();Vr();Ti();wd();Ge();Zn();Mn();Ci();Ur();xi();jt();Bp();co()});var uo={};Er(uo,{endsWith:()=>to,gt:()=>Ue,gte:()=>ce,includes:()=>Xr,length:()=>Qt,lowercase:()=>Jr,lt:()=>Ve,lte:()=>_e,maxLength:()=>qt,maxSize:()=>mt,mime:()=>ro,minLength:()=>rt,minSize:()=>Me,multipleOf:()=>ft,negative:()=>xp,nonnegative:()=>Sp,nonpositive:()=>Ep,normalize:()=>oo,overwrite:()=>Be,positive:()=>vp,property:()=>$p,regex:()=>Hr,size:()=>Zt,slugify:()=>ao,startsWith:()=>eo,toLowerCase:()=>io,toUpperCase:()=>so,trim:()=>no,uppercase:()=>Yr});var lo=_(()=>{we()});var Ht={};Er(Ht,{ZodISODate:()=>xd,ZodISODateTime:()=>vd,ZodISODuration:()=>Sd,ZodISOTime:()=>Ed,date:()=>ns,datetime:()=>os,duration:()=>ss,time:()=>is});function os(e){return Yl(vd,e)}function ns(e){return Xl(xd,e)}function is(e){return ep(Ed,e)}function ss(e){return tp(Sd,e)}var vd,xd,Ed,Sd;var po=_(()=>{we();mo();vd=g("ZodISODateTime",(e,t)=>{qu.init(e,t),L.init(e,t)});xd=g("ZodISODate",(e,t)=>{Qu.init(e,t),L.init(e,t)});Ed=g("ZodISOTime",(e,t)=>{Wu.init(e,t),L.init(e,t)});Sd=g("ZodISODuration",(e,t)=>{Gu.init(e,t),L.init(e,t)})});var $d=(e,t)=>{zr.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(r)=>Un(e,r)},flatten:{value:(r)=>Vn(e,r)},addIssue:{value:(r)=>{e.issues.push(r),e.message=JSON.stringify(e.issues,It,2)}},addIssues:{value:(r)=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,It,2)}},isEmpty:{get(){return e.issues.length===0}}})},Ad,ue;var as=_(()=>{we();we();de();Ad=g("ZodError",$d),ue=g("ZodError",$d,{Parent:Error})});var kd,Pd,Cd,Rd,Td,Od,Id,Bd,zd,Dd,Nd,Ld;var cs=_(()=>{we();as();kd=Dt(ue),Pd=Nt(ue),Cd=Lt(ue),Rd=Vt(ue),Td=Lc(ue),Od=Vc(ue),Id=Uc(ue),Bd=Mc(ue),zd=Fc(ue),Dd=jc(ue),Nd=Zc(ue),Ld=qc(ue)});var fo={};Er(fo,{ZodAny:()=>Wd,ZodArray:()=>Yd,ZodBase64:()=>$s,ZodBase64URL:()=>As,ZodBigInt:()=>Ts,ZodBigIntFormat:()=>Os,ZodBoolean:()=>Rs,ZodCIDRv4:()=>Es,ZodCIDRv6:()=>Ss,ZodCUID:()=>gs,ZodCUID2:()=>ys,ZodCatch:()=>vf,ZodCodec:()=>So,ZodCustom:()=>$o,ZodCustomStringFormat:()=>er,ZodDate:()=>Jd,ZodDefault:()=>hf,ZodDiscriminatedUnion:()=>ef,ZodE164:()=>ks,ZodEmail:()=>fs,ZodEmoji:()=>ms,ZodEnum:()=>Yt,ZodExactOptional:()=>df,ZodFile:()=>lf,ZodFunction:()=>Tf,ZodGUID:()=>go,ZodIPv4:()=>vs,ZodIPv6:()=>xs,ZodIntersection:()=>tf,ZodJWT:()=>Ps,ZodKSUID:()=>ws,ZodLazy:()=>Pf,ZodLiteral:()=>uf,ZodMAC:()=>Ud,ZodMap:()=>af,ZodNaN:()=>Ef,ZodNanoID:()=>hs,ZodNever:()=>Kd,ZodNonOptional:()=>Ls,ZodNull:()=>qd,ZodNullable:()=>mf,ZodNumber:()=>Cs,ZodNumberFormat:()=>gt,ZodObject:()=>vo,ZodOptional:()=>Ns,ZodPipe:()=>Eo,ZodPrefault:()=>yf,ZodPreprocess:()=>Sf,ZodPromise:()=>Rf,ZodReadonly:()=>$f,ZodRecord:()=>Jt,ZodSet:()=>cf,ZodString:()=>ds,ZodStringFormat:()=>L,ZodSuccess:()=>wf,ZodSymbol:()=>jd,ZodTemplateLiteral:()=>kf,ZodTransform:()=>pf,ZodTuple:()=>of,ZodType:()=>O,ZodULID:()=>bs,ZodURL:()=>_o,ZodUUID:()=>ze,ZodUndefined:()=>Zd,ZodUnion:()=>xo,ZodUnknown:()=>Gd,ZodVoid:()=>Hd,ZodXID:()=>_s,ZodXor:()=>Xd,_ZodString:()=>ps,_default:()=>gf,_function:()=>$w,any:()=>rw,array:()=>wo,base64:()=>V_,base64url:()=>U_,bigint:()=>J_,boolean:()=>Fd,catch:()=>xf,check:()=>Aw,cidrv4:()=>N_,cidrv6:()=>L_,codec:()=>vw,cuid:()=>C_,cuid2:()=>R_,custom:()=>kw,date:()=>nw,describe:()=>Pw,discriminatedUnion:()=>lw,e164:()=>M_,email:()=>__,emoji:()=>k_,enum:()=>zs,exactOptional:()=>ff,file:()=>yw,float32:()=>W_,float64:()=>G_,function:()=>$w,guid:()=>w_,hash:()=>Q_,hex:()=>q_,hostname:()=>Z_,httpUrl:()=>A_,instanceof:()=>Rw,int:()=>us,int32:()=>K_,int64:()=>Y_,intersection:()=>rf,invertCodec:()=>xw,ipv4:()=>B_,ipv6:()=>D_,json:()=>Ow,jwt:()=>F_,keyof:()=>iw,ksuid:()=>I_,lazy:()=>Cf,literal:()=>gw,looseObject:()=>cw,looseRecord:()=>dw,mac:()=>z_,map:()=>fw,meta:()=>Cw,nan:()=>ww,nanoid:()=>P_,nativeEnum:()=>hw,never:()=>Is,nonoptional:()=>_f,null:()=>Qd,nullable:()=>bo,nullish:()=>bw,number:()=>Md,object:()=>sw,optional:()=>yo,partialRecord:()=>pw,pipe:()=>ls,prefault:()=>bf,preprocess:()=>Iw,promise:()=>Sw,readonly:()=>Af,record:()=>sf,refine:()=>Of,set:()=>mw,strictObject:()=>aw,string:()=>ho,stringFormat:()=>j_,stringbool:()=>Tw,success:()=>_w,superRefine:()=>If,symbol:()=>ew,templateLiteral:()=>Ew,transform:()=>Ds,tuple:()=>nf,uint32:()=>H_,uint64:()=>X_,ulid:()=>T_,undefined:()=>tw,union:()=>Bs,unknown:()=>ht,url:()=>$_,uuid:()=>v_,uuidv4:()=>x_,uuidv6:()=>E_,uuidv7:()=>S_,void:()=>ow,xid:()=>O_,xor:()=>uw});function Xt(e,t,r){let o=Object.getPrototypeOf(e),n=Vd.get(o);if(!n)n=new Set,Vd.set(o,n);if(n.has(t))return;n.add(t);for(let i in r){let s=r[i];Object.defineProperty(o,i,{configurable:!0,enumerable:!1,get(){let a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}function ho(e){return Hl(ds,e)}function __(e){return Oi(fs,e)}function w_(e){return Gr(go,e)}function v_(e){return Ii(ze,e)}function x_(e){return Bi(ze,e)}function E_(e){return zi(ze,e)}function S_(e){return Di(ze,e)}function $_(e){return Kr(_o,e)}function A_(e){return Kr(_o,{protocol:Nr,hostname:Gc,...w(e)})}function k_(e){return Ni(ms,e)}function P_(e){return Li(hs,e)}function C_(e){return Vi(gs,e)}function R_(e){return Ui(ys,e)}function T_(e){return Mi(bs,e)}function O_(e){return Fi(_s,e)}function I_(e){return ji(ws,e)}function B_(e){return Zi(vs,e)}function z_(e){return Jl(Ud,e)}function D_(e){return qi(xs,e)}function N_(e){return Qi(Es,e)}function L_(e){return Wi(Ss,e)}function V_(e){return Gi($s,e)}function U_(e){return Ki(As,e)}function M_(e){return Hi(ks,e)}function F_(e){return Ji(Ps,e)}function j_(e,t,r={}){return Wt(er,e,t,r)}function Z_(e){return Wt(er,"hostname",Wc,e)}function q_(e){return Wt(er,"hex",Jc,e)}function Q_(e,t){let r=t?.enc??"hex",o=`${e}_${r}`,n=tt[o];if(!n)throw Error(`Unrecognized hash format: ${o}`);return Wt(er,o,n,t)}function Md(e){return rp(Cs,e)}function us(e){return op(gt,e)}function W_(e){return np(gt,e)}function G_(e){return ip(gt,e)}function K_(e){return sp(gt,e)}function H_(e){return ap(gt,e)}function Fd(e){return cp(Rs,e)}function J_(e){return up(Ts,e)}function Y_(e){return lp(Os,e)}function X_(e){return pp(Os,e)}function ew(e){return dp(jd,e)}function tw(e){return fp(Zd,e)}function Qd(e){return mp(qd,e)}function rw(){return hp(Wd)}function ht(){return gp(Gd)}function Is(e){return yp(Kd,e)}function ow(e){return bp(Hd,e)}function nw(e){return _p(Jd,e)}function wo(e,t){return Ap(Yd,e,t)}function iw(e){let t=e._zod.def.shape;return zs(Object.keys(t))}function sw(e,t){let r={type:"object",shape:e??{},...w(t)};return new vo(r)}function aw(e,t){return new vo({type:"object",shape:e,catchall:Is(),...w(t)})}function cw(e,t){return new vo({type:"object",shape:e,catchall:ht(),...w(t)})}function Bs(e,t){return new xo({type:"union",options:e,...w(t)})}function uw(e,t){return new Xd({type:"union",options:e,inclusive:!1,...w(t)})}function lw(e,t,r){return new ef({type:"union",options:t,discriminator:e,...w(r)})}function rf(e,t){return new tf({type:"intersection",left:e,right:t})}function nf(e,t,r){let o=t instanceof R,n=o?r:t;return new of({type:"tuple",items:e,rest:o?t:null,...w(n)})}function sf(e,t,r){if(!t||!t._zod)return new Jt({type:"record",keyType:ho(),valueType:e,...w(t)});return new Jt({type:"record",keyType:e,valueType:t,...w(r)})}function pw(e,t,r){let o=pe(e);return o._zod.values=void 0,new Jt({type:"record",keyType:o,valueType:t,...w(r)})}function dw(e,t,r){return new Jt({type:"record",keyType:e,valueType:t,mode:"loose",...w(r)})}function fw(e,t,r){return new af({type:"map",keyType:e,valueType:t,...w(r)})}function mw(e,t){return new cf({type:"set",valueType:e,...w(t)})}function zs(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new Yt({type:"enum",entries:r,...w(t)})}function hw(e,t){return new Yt({type:"enum",entries:e,...w(t)})}function gw(e,t){return new uf({type:"literal",values:Array.isArray(e)?e:[e],...w(t)})}function yw(e){return kp(lf,e)}function Ds(e){return new pf({type:"transform",transform:e})}function yo(e){return new Ns({type:"optional",innerType:e})}function ff(e){return new df({type:"optional",innerType:e})}function bo(e){return new mf({type:"nullable",innerType:e})}function bw(e){return yo(bo(e))}function gf(e,t){return new hf({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Nn(t)}})}function bf(e,t){return new yf({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Nn(t)}})}function _f(e,t){return new Ls({type:"nonoptional",innerType:e,...w(t)})}function _w(e){return new wf({type:"success",innerType:e})}function xf(e,t){return new vf({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}function ww(e){return wp(Ef,e)}function ls(e,t){return new Eo({type:"pipe",in:e,out:t})}function vw(e,t,r){return new So({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function xw(e){let t=e._zod.def;return new So({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}function Af(e){return new $f({type:"readonly",innerType:e})}function Ew(e,t){return new kf({type:"template_literal",parts:e,...w(t)})}function Cf(e){return new Pf({type:"lazy",getter:e})}function Sw(e){return new Rf({type:"promise",innerType:e})}function $w(e){return new Tf({type:"function",input:Array.isArray(e?.input)?nf(e?.input):e?.input??wo(ht()),output:e?.output??ht()})}function Aw(e){let t=new U({check:"custom"});return t._zod.check=e,t}function kw(e,t){return Pp($o,e??(()=>!0),t)}function Of(e,t={}){return Cp($o,e,t)}function If(e,t){return Rp(e,t)}function Rw(e,t={}){let r=new $o({type:"custom",check:"custom",fn:(o)=>o instanceof e,abort:!0,...w(t)});return r._zod.bag.Class=e,r._zod.check=(o)=>{if(!(o.value instanceof e))o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:r,path:[...r._zod.def.path??[]]})},r}function Ow(e){let t=Cf(()=>Bs([ho(e),Md(),Fd(),Qd(),wo(t),sf(ho(),t)]));return t}function Iw(e,t){return new Sf({type:"pipe",in:Ds(e),out:t})}var Vd,O,ps,ds,L,fs,go,ze,_o,ms,hs,gs,ys,bs,_s,ws,vs,Ud,xs,Es,Ss,$s,As,ks,Ps,er,Cs,gt,Rs,Ts,Os,jd,Zd,qd,Wd,Gd,Kd,Hd,Jd,Yd,vo,xo,Xd,ef,tf,of,Jt,af,cf,Yt,uf,lf,pf,Ns,df,mf,hf,yf,Ls,wf,vf,Ef,Eo,So,Sf,$f,kf,Pf,Rf,Tf,$o,Pw,Cw,Tw=(...e)=>Ip({Codec:So,Boolean:Rs,String:ds},...e);var mo=_(()=>{we();we();_d();co();lo();po();cs();Vd=new WeakMap;O=g("ZodType",(e,t)=>(R.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Gt(e,"input"),output:Gt(e,"output")}}),e.toJSONSchema=zp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,o)=>kd(e,r,o,{callee:e.parse}),e.safeParse=(r,o)=>Cd(e,r,o),e.parseAsync=async(r,o)=>Pd(e,r,o,{callee:e.parseAsync}),e.safeParseAsync=async(r,o)=>Rd(e,r,o),e.spa=e.safeParseAsync,e.encode=(r,o)=>Td(e,r,o),e.decode=(r,o)=>Od(e,r,o),e.encodeAsync=async(r,o)=>Id(e,r,o),e.decodeAsync=async(r,o)=>Bd(e,r,o),e.safeEncode=(r,o)=>zd(e,r,o),e.safeDecode=(r,o)=>Dd(e,r,o),e.safeEncodeAsync=async(r,o)=>Nd(e,r,o),e.safeDecodeAsync=async(r,o)=>Ld(e,r,o),Xt(e,"ZodType",{check(...r){let o=this.def;return this.clone(Le(o,{checks:[...o.checks??[],...r.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,o){return pe(this,r,o)},brand(){return this},register(r,o){return r.add(this,o),this},refine(r,o){return this.check(Of(r,o))},superRefine(r,o){return this.check(If(r,o))},overwrite(r){return this.check(Be(r))},optional(){return yo(this)},exactOptional(){return ff(this)},nullable(){return bo(this)},nullish(){return yo(bo(this))},nonoptional(r){return _f(this,r)},array(){return wo(this)},or(r){return Bs([this,r])},and(r){return rf(this,r)},transform(r){return ls(this,Ds(r))},default(r){return gf(this,r)},prefault(r){return bf(this,r)},catch(r){return xf(this,r)},pipe(r){return ls(this,r)},readonly(){return Af(this)},describe(r){let o=this.clone();return te.add(o,{description:r}),o},meta(...r){if(r.length===0)return te.get(this);let o=this.clone();return te.add(o,r[0]),o},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return te.get(e)?.description},configurable:!0}),e)),ps=g("_ZodString",(e,t)=>{dt.init(e,t),O.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Dp(e,o,n,i);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,Xt(e,"_ZodString",{regex(...o){return this.check(Hr(...o))},includes(...o){return this.check(Xr(...o))},startsWith(...o){return this.check(eo(...o))},endsWith(...o){return this.check(to(...o))},min(...o){return this.check(rt(...o))},max(...o){return this.check(qt(...o))},length(...o){return this.check(Qt(...o))},nonempty(...o){return this.check(rt(1,...o))},lowercase(o){return this.check(Jr(o))},uppercase(o){return this.check(Yr(o))},trim(){return this.check(no())},normalize(...o){return this.check(oo(...o))},toLowerCase(){return this.check(io())},toUpperCase(){return this.check(so())},slugify(){return this.check(ao())}})}),ds=g("ZodString",(e,t)=>{dt.init(e,t),ps.init(e,t),e.email=(r)=>e.check(Oi(fs,r)),e.url=(r)=>e.check(Kr(_o,r)),e.jwt=(r)=>e.check(Ji(Ps,r)),e.emoji=(r)=>e.check(Ni(ms,r)),e.guid=(r)=>e.check(Gr(go,r)),e.uuid=(r)=>e.check(Ii(ze,r)),e.uuidv4=(r)=>e.check(Bi(ze,r)),e.uuidv6=(r)=>e.check(zi(ze,r)),e.uuidv7=(r)=>e.check(Di(ze,r)),e.nanoid=(r)=>e.check(Li(hs,r)),e.guid=(r)=>e.check(Gr(go,r)),e.cuid=(r)=>e.check(Vi(gs,r)),e.cuid2=(r)=>e.check(Ui(ys,r)),e.ulid=(r)=>e.check(Mi(bs,r)),e.base64=(r)=>e.check(Gi($s,r)),e.base64url=(r)=>e.check(Ki(As,r)),e.xid=(r)=>e.check(Fi(_s,r)),e.ksuid=(r)=>e.check(ji(ws,r)),e.ipv4=(r)=>e.check(Zi(vs,r)),e.ipv6=(r)=>e.check(qi(xs,r)),e.cidrv4=(r)=>e.check(Qi(Es,r)),e.cidrv6=(r)=>e.check(Wi(Ss,r)),e.e164=(r)=>e.check(Hi(ks,r)),e.datetime=(r)=>e.check(os(r)),e.date=(r)=>e.check(ns(r)),e.time=(r)=>e.check(is(r)),e.duration=(r)=>e.check(ss(r))});L=g("ZodStringFormat",(e,t)=>{N.init(e,t),ps.init(e,t)}),fs=g("ZodEmail",(e,t)=>{Du.init(e,t),L.init(e,t)});go=g("ZodGUID",(e,t)=>{Bu.init(e,t),L.init(e,t)});ze=g("ZodUUID",(e,t)=>{zu.init(e,t),L.init(e,t)});_o=g("ZodURL",(e,t)=>{Nu.init(e,t),L.init(e,t)});ms=g("ZodEmoji",(e,t)=>{Lu.init(e,t),L.init(e,t)});hs=g("ZodNanoID",(e,t)=>{Vu.init(e,t),L.init(e,t)});gs=g("ZodCUID",(e,t)=>{Uu.init(e,t),L.init(e,t)});ys=g("ZodCUID2",(e,t)=>{Mu.init(e,t),L.init(e,t)});bs=g("ZodULID",(e,t)=>{Fu.init(e,t),L.init(e,t)});_s=g("ZodXID",(e,t)=>{ju.init(e,t),L.init(e,t)});ws=g("ZodKSUID",(e,t)=>{Zu.init(e,t),L.init(e,t)});vs=g("ZodIPv4",(e,t)=>{Ku.init(e,t),L.init(e,t)});Ud=g("ZodMAC",(e,t)=>{Ju.init(e,t),L.init(e,t)});xs=g("ZodIPv6",(e,t)=>{Hu.init(e,t),L.init(e,t)});Es=g("ZodCIDRv4",(e,t)=>{Yu.init(e,t),L.init(e,t)});Ss=g("ZodCIDRv6",(e,t)=>{Xu.init(e,t),L.init(e,t)});$s=g("ZodBase64",(e,t)=>{tl.init(e,t),L.init(e,t)});As=g("ZodBase64URL",(e,t)=>{rl.init(e,t),L.init(e,t)});ks=g("ZodE164",(e,t)=>{ol.init(e,t),L.init(e,t)});Ps=g("ZodJWT",(e,t)=>{nl.init(e,t),L.init(e,t)});er=g("ZodCustomStringFormat",(e,t)=>{il.init(e,t),L.init(e,t)});Cs=g("ZodNumber",(e,t)=>{Si.init(e,t),O.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Np(e,o,n,i),Xt(e,"ZodNumber",{gt(o,n){return this.check(Ue(o,n))},gte(o,n){return this.check(ce(o,n))},min(o,n){return this.check(ce(o,n))},lt(o,n){return this.check(Ve(o,n))},lte(o,n){return this.check(_e(o,n))},max(o,n){return this.check(_e(o,n))},int(o){return this.check(us(o))},safe(o){return this.check(us(o))},positive(o){return this.check(Ue(0,o))},nonnegative(o){return this.check(ce(0,o))},negative(o){return this.check(Ve(0,o))},nonpositive(o){return this.check(_e(0,o))},multipleOf(o,n){return this.check(ft(o,n))},step(o,n){return this.check(ft(o,n))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??0.5),e.isFinite=!0,e.format=r.format??null});gt=g("ZodNumberFormat",(e,t)=>{sl.init(e,t),Cs.init(e,t)});Rs=g("ZodBoolean",(e,t)=>{qr.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Lp(e,r,o,n)});Ts=g("ZodBigInt",(e,t)=>{$i.init(e,t),O.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Vp(e,o,n,i),e.gte=(o,n)=>e.check(ce(o,n)),e.min=(o,n)=>e.check(ce(o,n)),e.gt=(o,n)=>e.check(Ue(o,n)),e.gte=(o,n)=>e.check(ce(o,n)),e.min=(o,n)=>e.check(ce(o,n)),e.lt=(o,n)=>e.check(Ve(o,n)),e.lte=(o,n)=>e.check(_e(o,n)),e.max=(o,n)=>e.check(_e(o,n)),e.positive=(o)=>e.check(Ue(BigInt(0),o)),e.negative=(o)=>e.check(Ve(BigInt(0),o)),e.nonpositive=(o)=>e.check(_e(BigInt(0),o)),e.nonnegative=(o)=>e.check(ce(BigInt(0),o)),e.multipleOf=(o,n)=>e.check(ft(o,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});Os=g("ZodBigIntFormat",(e,t)=>{al.init(e,t),Ts.init(e,t)});jd=g("ZodSymbol",(e,t)=>{cl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Up(e,r,o,n)});Zd=g("ZodUndefined",(e,t)=>{ul.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Fp(e,r,o,n)});qd=g("ZodNull",(e,t)=>{ll.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Mp(e,r,o,n)});Wd=g("ZodAny",(e,t)=>{pl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qp(e,r,o,n)});Gd=g("ZodUnknown",(e,t)=>{dl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Qp(e,r,o,n)});Kd=g("ZodNever",(e,t)=>{fl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Zp(e,r,o,n)});Hd=g("ZodVoid",(e,t)=>{ml.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>jp(e,r,o,n)});Jd=g("ZodDate",(e,t)=>{hl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Wp(e,o,n,i),e.min=(o,n)=>e.check(ce(o,n)),e.max=(o,n)=>e.check(_e(o,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});Yd=g("ZodArray",(e,t)=>{gl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>id(e,r,o,n),e.element=t.element,Xt(e,"ZodArray",{min(r,o){return this.check(rt(r,o))},nonempty(r){return this.check(rt(1,r))},max(r,o){return this.check(qt(r,o))},length(r,o){return this.check(Qt(r,o))},unwrap(){return this.element}})});vo=g("ZodObject",(e,t)=>{_l.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>sd(e,r,o,n),I(e,"shape",()=>t.shape),Xt(e,"ZodObject",{keyof(){return zs(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:ht()})},loose(){return this.clone({...this._zod.def,catchall:ht()})},strict(){return this.clone({...this._zod.def,catchall:Is()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return Rb(this,r)},safeExtend(r){return Tb(this,r)},merge(r){return Ob(this,r)},pick(r){return Pb(this,r)},omit(r){return Cb(this,r)},partial(...r){return Ib(Ns,this,r[0])},required(...r){return Bb(Ls,this,r[0])}})});xo=g("ZodUnion",(e,t)=>{Qr.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ts(e,r,o,n),e.options=t.options});Xd=g("ZodXor",(e,t)=>{xo.init(e,t),wl.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ts(e,r,o,n),e.options=t.options});ef=g("ZodDiscriminatedUnion",(e,t)=>{xo.init(e,t),vl.init(e,t)});tf=g("ZodIntersection",(e,t)=>{xl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ad(e,r,o,n)});of=g("ZodTuple",(e,t)=>{Ai.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>cd(e,r,o,n),e.rest=(r)=>e.clone({...e._zod.def,rest:r})});Jt=g("ZodRecord",(e,t)=>{El.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ud(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});af=g("ZodMap",(e,t)=>{Sl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>od(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Me(...r)),e.nonempty=(r)=>e.check(Me(1,r)),e.max=(...r)=>e.check(mt(...r)),e.size=(...r)=>e.check(Zt(...r))});cf=g("ZodSet",(e,t)=>{$l.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>nd(e,r,o,n),e.min=(...r)=>e.check(Me(...r)),e.nonempty=(r)=>e.check(Me(1,r)),e.max=(...r)=>e.check(mt(...r)),e.size=(...r)=>e.check(Zt(...r))});Yt=g("ZodEnum",(e,t)=>{Al.init(e,t),O.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Gp(e,o,n,i),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let s of o)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Yt({...t,checks:[],...w(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let s of o)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Yt({...t,checks:[],...w(n),entries:i})}});uf=g("ZodLiteral",(e,t)=>{kl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kp(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});lf=g("ZodFile",(e,t)=>{Pl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yp(e,r,o,n),e.min=(r,o)=>e.check(Me(r,o)),e.max=(r,o)=>e.check(mt(r,o)),e.mime=(r,o)=>e.check(ro(Array.isArray(r)?r:[r],o))});pf=g("ZodTransform",(e,t)=>{Cl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>rd(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new lt(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(Xe(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(Xe(s))}};let n=t.transform(r.value,r);if(n instanceof Promise)return n.then((i)=>(r.value=i,r.fallback=!0,r));return r.value=n,r.fallback=!0,r}});Ns=g("ZodOptional",(e,t)=>{ki.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>rs(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});df=g("ZodExactOptional",(e,t)=>{Rl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>rs(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});mf=g("ZodNullable",(e,t)=>{Tl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ld(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});hf=g("ZodDefault",(e,t)=>{Ol.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>dd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});yf=g("ZodPrefault",(e,t)=>{Il.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>fd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});Ls=g("ZodNonOptional",(e,t)=>{Bl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>pd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});wf=g("ZodSuccess",(e,t)=>{zl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});vf=g("ZodCatch",(e,t)=>{Dl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>md(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});Ef=g("ZodNaN",(e,t)=>{Nl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Hp(e,r,o,n)});Eo=g("ZodPipe",(e,t)=>{Pi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>hd(e,r,o,n),e.in=t.in,e.out=t.out});So=g("ZodCodec",(e,t)=>{Eo.init(e,t),Wr.init(e,t)});Sf=g("ZodPreprocess",(e,t)=>{Eo.init(e,t),Ll.init(e,t)}),$f=g("ZodReadonly",(e,t)=>{Vl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>gd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});kf=g("ZodTemplateLiteral",(e,t)=>{Ul.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jp(e,r,o,n)});Pf=g("ZodLazy",(e,t)=>{jl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>bd(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});Rf=g("ZodPromise",(e,t)=>{Fl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>yd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});Tf=g("ZodFunction",(e,t)=>{Ml.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>td(e,r,o,n)});$o=g("ZodCustom",(e,t)=>{Zl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ed(e,r,o,n)});Pw=Tp,Cw=Op});var Bf;var zf=_(()=>{(function(e){})(Bf||(Bf={}))});function zw(e,t){let r=e.$schema;if(r==="https://json-schema.org/draft/2020-12/schema")return"draft-2020-12";if(r==="http://json-schema.org/draft-07/schema#")return"draft-7";if(r==="http://json-schema.org/draft-04/schema#")return"draft-4";return t??"draft-2020-12"}function Dw(e,t){if(!e.startsWith("#"))throw Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){let n=r[1];if(!n||!t.defs[n])throw Error(`Reference not found: ${e}`);return t.defs[n]}throw Error(`Reference not found: ${e}`)}function Df(e,t){if(e.not!==void 0){if(typeof e.not==="object"&&Object.keys(e.not).length===0)return v.never();throw Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return v.lazy(()=>{if(!t.refs.has(n))throw Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=Dw(n,t),s=Y(i,t);return t.refs.set(n,s),t.processing.delete(n),s}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return v.null();if(n.length===0)return v.never();if(n.length===1)return v.literal(n[0]);if(n.every((s)=>typeof s==="string"))return v.enum(n);let i=n.map((s)=>v.literal(s));if(i.length<2)return i[0];return v.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return v.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map((i)=>{let s={...e,type:i};return Df(s,t)});if(n.length===0)return v.never();if(n.length===1)return n[0];return v.union(n)}if(!r)return v.any();let o;switch(r){case"string":{let n=v.string();if(e.format){let i=e.format;if(i==="email")n=n.check(v.email());else if(i==="uri"||i==="uri-reference")n=n.check(v.url());else if(i==="uuid"||i==="guid")n=n.check(v.uuid());else if(i==="date-time")n=n.check(v.iso.datetime());else if(i==="date")n=n.check(v.iso.date());else if(i==="time")n=n.check(v.iso.time());else if(i==="duration")n=n.check(v.iso.duration());else if(i==="ipv4")n=n.check(v.ipv4());else if(i==="ipv6")n=n.check(v.ipv6());else if(i==="mac")n=n.check(v.mac());else if(i==="cidr")n=n.check(v.cidrv4());else if(i==="cidr-v6")n=n.check(v.cidrv6());else if(i==="base64")n=n.check(v.base64());else if(i==="base64url")n=n.check(v.base64url());else if(i==="e164")n=n.check(v.e164());else if(i==="jwt")n=n.check(v.jwt());else if(i==="emoji")n=n.check(v.emoji());else if(i==="nanoid")n=n.check(v.nanoid());else if(i==="cuid")n=n.check(v.cuid());else if(i==="cuid2")n=n.check(v.cuid2());else if(i==="ulid")n=n.check(v.ulid());else if(i==="xid")n=n.check(v.xid());else if(i==="ksuid")n=n.check(v.ksuid())}if(typeof e.minLength==="number")n=n.min(e.minLength);if(typeof e.maxLength==="number")n=n.max(e.maxLength);if(e.pattern)n=n.regex(new RegExp(e.pattern));o=n;break}case"number":case"integer":{let n=r==="integer"?v.number().int():v.number();if(typeof e.minimum==="number")n=n.min(e.minimum);if(typeof e.maximum==="number")n=n.max(e.maximum);if(typeof e.exclusiveMinimum==="number")n=n.gt(e.exclusiveMinimum);else if(e.exclusiveMinimum===!0&&typeof e.minimum==="number")n=n.gt(e.minimum);if(typeof e.exclusiveMaximum==="number")n=n.lt(e.exclusiveMaximum);else if(e.exclusiveMaximum===!0&&typeof e.maximum==="number")n=n.lt(e.maximum);if(typeof e.multipleOf==="number")n=n.multipleOf(e.multipleOf);o=n;break}case"boolean":{o=v.boolean();break}case"null":{o=v.null();break}case"object":{let n={},i=e.properties||{},s=new Set(e.required||[]);for(let[c,u]of Object.entries(i)){let l=Y(u,t);n[c]=s.has(c)?l:l.optional()}if(e.propertyNames){let c=Y(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties==="object"?Y(e.additionalProperties,t):v.any();if(Object.keys(n).length===0){o=v.record(c,u);break}let l=v.object(n).passthrough(),f=v.looseRecord(c,u);o=v.intersection(l,f);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let d of u){let p=Y(c[d],t),m=v.string().regex(new RegExp(d));l.push(v.looseRecord(m,p))}let f=[];if(Object.keys(n).length>0)f.push(v.object(n).passthrough());if(f.push(...l),f.length===0)o=v.object({}).passthrough();else if(f.length===1)o=f[0];else{let d=v.intersection(f[0],f[1]);for(let p=2;p<f.length;p++)d=v.intersection(d,f[p]);o=d}break}let a=v.object(n);if(e.additionalProperties===!1)o=a.strict();else if(typeof e.additionalProperties==="object")o=a.catchall(Y(e.additionalProperties,t));else o=a.passthrough();break}case"array":{let{prefixItems:n,items:i}=e;if(n&&Array.isArray(n)){let s=n.map((c)=>Y(c,t)),a=i&&typeof i==="object"&&!Array.isArray(i)?Y(i,t):void 0;if(a)o=v.tuple(s).rest(a);else o=v.tuple(s);if(typeof e.minItems==="number")o=o.check(v.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(v.maxLength(e.maxItems))}else if(Array.isArray(i)){let s=i.map((c)=>Y(c,t)),a=e.additionalItems&&typeof e.additionalItems==="object"?Y(e.additionalItems,t):void 0;if(a)o=v.tuple(s).rest(a);else o=v.tuple(s);if(typeof e.minItems==="number")o=o.check(v.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(v.maxLength(e.maxItems))}else if(i!==void 0){let s=Y(i,t),a=v.array(s);if(typeof e.minItems==="number")a=a.min(e.minItems);if(typeof e.maxItems==="number")a=a.max(e.maxItems);o=a}else o=v.array(v.any());break}default:throw Error(`Unsupported type: ${r}`)}return o}function Y(e,t){if(typeof e==="boolean")return e?v.any():v.never();let r=Df(e,t),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map((u)=>Y(u,t)),c=v.union(a);r=o?v.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map((u)=>Y(u,t)),c=v.xor(a);r=o?v.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:v.any();else{let a=o?r:Y(e.allOf[0],t),c=o?0:1;for(let u=c;u<e.allOf.length;u++)a=v.intersection(a,Y(e.allOf[u],t));r=a}if(e.nullable===!0&&t.version==="openapi-3.0")r=v.nullable(r);if(e.readOnly===!0)r=v.readonly(r);if(e.default!==void 0)r=r.default(e.default);let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of i)if(a in e)n[a]=e[a];let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)if(a in e)n[a]=e[a];for(let a of Object.keys(e))if(!Bw.has(a))n[a]=e[a];if(Object.keys(n).length>0)t.registry.add(r,n);if(e.description)r=r.describe(e.description);return r}function Nf(e,t){if(typeof e==="boolean")return e?v.any():v.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=zw(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:o,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??te};return Y(r,i)}var v,Bw;var Lf=_(()=>{jt();lo();po();mo();v={...fo,...uo,iso:Ht},Bw=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"])});var Vf=()=>{};var Us=_(()=>{we();we();ql();we();Lf();Ti();po();Vf();mo();lo();as();cs();zf();H(Ri())});var Ms=_(()=>{Us();Us()});var Mf="registry.neko-piranha.ts.net",Ao="https://kuber.astrxl.dev/api/v2",X;var Fe=_(()=>{X={"app.kubernetes.io/managed-by":"kuber"}});import{chmod as Ff,mkdir as Vw,readFile as Uw,rename as Mw,rm as js,writeFile as Fw}from"fs/promises";import{randomUUID as jw}from"crypto";import{tmpdir as Qf}from"os";import{dirname as jf,join as ko}from"path";function Zs(){let e=process.env.XDG_RUNTIME_DIR??ko(Qf(),`kuber-${process.getuid?.()??"user"}`);return ko(e,"kuber","session.json")}function qs(){let e=process.env.XDG_CONFIG_HOME??ko(process.env.HOME??Qf(),".config");return ko(e,"kuber","session.json")}function Zf(e){return e?qs():Zs()}function Zw(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.token==="string"&&typeof t.expiresAt==="string"&&Boolean(t.user)&&typeof t.user?.username==="string"&&Array.isArray(t.user.roles)&&t.user.roles.every((r)=>typeof r==="string")}async function qf(e){try{let t=JSON.parse(await Uw(e,"utf8"));if(!Zw(t))return;if(Date.parse(t.expiresAt)<=Date.now()){await js(e,{force:!0});return}return t}catch(t){if(t&&typeof t==="object"&&"code"in t&&t.code==="ENOENT")return;if(t instanceof SyntaxError)return;throw t}}async function yt(){let e=Zs(),t=qs();if(je?.runtimePath===e&&je.persistentPath===t&&(je.expiresAt===0||je.expiresAt>Date.now()))return je.value;let r=await qf(e)??await qf(t);return je={runtimePath:e,persistentPath:t,value:r,expiresAt:r?Date.parse(r.expiresAt):0},r}async function Wf(e,t){let r=Zf(t);await Vw(jf(r),{recursive:!0,mode:448}),await Ff(jf(r),448);let o=`${r}.${jw()}.tmp`;return await Fw(o,`${JSON.stringify(e,null,2)}
|
|
72
|
+
`,{flag:"wx",mode:384}),await Mw(o,r),await Ff(r,384),await js(Zf(!t),{force:!0}),je=void 0,r}async function Qs(){await Promise.all([Zs(),qs()].map((e)=>js(e,{force:!0}))),je=void 0}var je;var Po=()=>{};function Gf(e,t=qw){if(!Number.isFinite(t)||t<0)throw RangeError("timeoutMs must be a finite non-negative number");let r=new AbortController,o=()=>r.abort(e?.reason);if(e?.aborted)o();else e?.addEventListener("abort",o,{once:!0});let n=t===0?void 0:setTimeout(()=>{r.abort(new DOMException(`API request timed out after ${t}ms`,"TimeoutError"))},t);return{signal:r.signal,clear:()=>{if(n!==void 0)clearTimeout(n);e?.removeEventListener("abort",o)}}}function Qw(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof Blob<"u"&&e instanceof Blob||typeof ReadableStream<"u"&&e instanceof ReadableStream}async function Ww(e,t){let r=new Headers(e.headers);if(!r.has("accept"))r.set("accept","application/json");if(Object.hasOwn(e,"json"))r.set("content-type","application/json");else if(e.body!==void 0&&e.body!==null&&!r.has("content-type")&&!Qw(e.body))r.set("content-type","application/json");if(t.uploadOffset!==void 0){if(!Number.isSafeInteger(t.uploadOffset)||t.uploadOffset<0)throw RangeError("uploadOffset must be a non-negative safe integer");r.set("upload-offset",String(t.uploadOffset))}if(t.authenticated!==!1){let o=t.session??await yt();if(!o)throw Error("Not logged in. Run kuber login first.");r.set("authorization",`Bearer ${o.token}`)}return r}async function Gw(e){let t;try{let r=JSON.parse(await e.text());if(r&&typeof r==="object")t=r}catch{}return{...t,status:e.status,title:t?.title||e.statusText||`HTTP ${e.status}`,code:t?.code||`HTTP_${e.status}`,requestId:t?.requestId??e.headers.get("x-request-id")??void 0,operationId:t?.operationId??e.headers.get("x-operation-id")??void 0}}async function Kf(e){if(e.ok)return;let t=await Gw(e);throw new xe(t.detail||t.message||t.title,e.status,t)}async function Hf(e,t,r,o){let n=await Ww(t,r),{json:i,...s}=t,a=Object.hasOwn(t,"json")?JSON.stringify(i):t.body;return fetch(`${r.baseUrl??Ao}${e}`,{...s,body:a,headers:n,signal:o})}async function C(e,t={},r={}){let o=Gf(t.signal,r.timeoutMs);try{let n=await Hf(e,t,r,o.signal);if(await Kf(n),t.method?.toUpperCase()==="HEAD"||n.status===204||n.status===205||n.body===null)return;let i=await n.text();if(!i.trim())return;return JSON.parse(i)}finally{o.clear()}}async function*Ws(e,t={},r={}){let o=Gf(t.signal,r.timeoutMs);try{let n=new Headers(t.headers);n.set("accept","application/x-ndjson");let i=await Hf(e,{...t,headers:n},r,o.signal);if(await Kf(i),!i.body)return;let s=i.body.getReader();try{let a=new TextDecoder,c="";for(;;){let{done:l,value:f}=await s.read();c+=a.decode(f,{stream:!l});let d=0,p=c.indexOf(`
|
|
73
|
+
`,d);while(p!==-1){let m=c.slice(d,p).replace(/\r$/,"").trim();if(m)yield JSON.parse(m);d=p+1,p=c.indexOf(`
|
|
74
|
+
`,d)}if(c=c.slice(d),l)break}let u=c.replace(/\r$/,"").trim();if(u)yield JSON.parse(u)}finally{try{await s.cancel()}catch{}s.releaseLock()}}finally{o.clear()}}var qw=30000,xe;var G=_(()=>{Fe();Po();xe=class xe extends Error{code;requestId;operationId;problem;constructor(e,t,r){super(e);this.name="KuberApiError",this.status=t,this.code=r?.code??`HTTP_${t}`,this.requestId=r?.requestId,this.operationId=r?.operationId,this.problem={...r,status:t,title:r?.title??e,code:this.code}}status}});var Gs;var Ks=_(()=>{Gs={top:"\u2500",topMid:"\u252C",topLeft:"\u250C",topRight:"\u2510",bottom:"\u2500",bottomMid:"\u2534",bottomLeft:"\u2514",bottomRight:"\u2518",left:"\u2502",leftMid:"\u251C",mid:"\u2500",midMid:"\u253C",right:"\u2502",rightMid:"\u2524",middle:"\u2502"}});class ie{value;options;get length(){return this.toString().length}get unclosedAnsiRuns(){return this.options.unclosedAnsiRuns??""}set unclosedAnsiRuns(e){this.options.unclosedAnsiRuns=e}static from(e){let t;if(e instanceof ie)t=new this(e.getValue()),t.options={...e.options};else t=new this(e);return t}constructor(e){this.value=e,this.options={}}toString(){return this.value.toString()}getValue(){return this.value}setValue(e){return this.value=e,this}clone(e){return ie.from(e??this)}border(e=!0,t=!0){if(t||typeof this.options.border>"u")this.options.border=e;return this}colSpan(e,t=!0){if(t||typeof this.options.colSpan>"u")this.options.colSpan=e;return this}rowSpan(e,t=!0){if(t||typeof this.options.rowSpan>"u")this.options.rowSpan=e;return this}align(e,t=!0){if(t||typeof this.options.align>"u")this.options.align=e;return this}getBorder(){return this.options.border===!0}getColSpan(){return typeof this.options.colSpan==="number"&&this.options.colSpan>0?this.options.colSpan:1}getRowSpan(){return typeof this.options.rowSpan==="number"&&this.options.rowSpan>0?this.options.rowSpan:1}getAlign(){return this.options.align??"left"}}class Ee{static from(e){let t=e instanceof Ee?e.opts:e;return new Ee().options(t)}opts={};options(e){return Object.assign(this.opts,e),this}minWidth(e){return this.opts.minWidth=e,this}maxWidth(e){return this.opts.maxWidth=e,this}border(e=!0){return this.opts.border=e,this}padding(e){return this.opts.padding=e,this}align(e){return this.opts.align=e,this}flexShrink(e=1){return this.opts.flexShrink=e,this}flexGrow(e=1){return this.opts.flexGrow=e,this}flex(e=1){return this.opts.flexGrow=e,this.opts.flexShrink=e,this}getMinWidth(){return this.opts.minWidth}getMaxWidth(){return this.opts.maxWidth}getBorder(){return this.opts.border}getPadding(){return this.opts.padding}getAlign(){return this.opts.align}getFlexShrink(){return this.opts.flexShrink}getFlexGrow(){return this.opts.flexGrow}}function Yf(e){return e.replace(Kw,"")}var Jf,aC,Kw;var Xf=_(()=>{({Deno:Jf}=globalThis),aC=typeof Jf?.noColor==="boolean"?Jf.noColor:!1,Kw=new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g")});function Jw(e){if(!rr)rr=Hw.tables.map(Xw);let t=rr.at(0)?.[e>>13&255]??0,r=rr.at(1)?.[128*t+(e>>6&127)]??0,n=(rr.at(2)?.[16*r+(e>>2&15)]??0)>>2*(e&3)&3;return n===3?1:n}function Yw(e){let t=em.get(e);if(t!==void 0)return t;let r=e.codePointAt(0);if(r===void 0)return null;let o;if(r<127)o=r>=32?1:r===0?0:null;else if(r>=160)o=Jw(r);else o=null;return em.set(e,o),o}function tm(e){return[...e].map((t)=>Yw(t)??0).reduce((t,r)=>t+r,0)}function Xw({d:e,r:t}){let r=atob(e),o=atob(t),n="";for(let[i,s]of[...o].entries())n+=r.charAt(i).repeat(s.codePointAt(0)??0);return Uint8Array.from([...n].map((i)=>i.codePointAt(0)??0))}var rr=null,Hw,em;var rm=_(()=>{Hw={UNICODE_VERSION:"15.0.0",tables:[{d:"AAECAwQFBgcICQoLDA0OAw8DDwkQCRESERIA",r:"AQEBAgEBAQEBAQEBAQEBBwEHAVABBwcBBwF4"},{d:"AAECAwQFBgcGCAYJCgsMDQ4PEAYREhMUBhUWFxgZGhscHR4fICEiIyIkJSYnKCkqJSssLS4vMDEyMzQ1Njc4OToGOzwKBj0GPj9AQUIGQwZEBkVGR0hJSktMTQZOBgoGT1BRUlNUVVZXWFkGWgZbBlxdXl1fYGFiY2RlZmdoBmlqBmsGAQZsBm1uO29wcXI7czt0dXZ3OwY7eHkGent8Bn0Gfn+AgYKDhIWGBoc7iAZdO4kGiosGAXGMBo0GjgaPBpAGkQaSBpMGlJUGlpcGmJmam5ydnp+gLgahLKIGo6SlpganqKmqqwasBq0Grq8GsLGyswa0BrUGtre4Brm6uwZHvAa9vga/wME7wjvDxAbFO8bHO8gGyQbKywbMzQbOBs/Q0QbSBr8GvgbT1AbUBtUG1gbXBtjZ2tsG3N0G3t/g4eLjO+Tl5ufoO+k76gbrBuztOwbu7/AGO+XxCgYKCwZd8g==",r:"AQEBAQEBAQEBAQEBAQEBAQEBAQMBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQECBQEOAQEBAQEBAQEBAwEBAQEBAQEBAQIBAwEIAQEBAQEBAQEBAQEBAQIBAQEBAQEBAQEBAQEBAQEBDQEBBQEBAQEBAgEBAwEBAQEBAQEBAQEBbQHaAQEFAQEBBAECAQEBAQEBAQEBAwGuASFkCAELAQEBAQEBAQEHAQMBAQEaAQIBCAEFAQEBAQEBAQEBAQEBAQEBAQEBAQECAQEBAQIBAQEBAQEBAwEDAQEBAQEBAQUBAQEBAQEBBAEBAVIBAdkBARABAQFfARMBAYoBBAEBBQEmAUkBAQcBAQIBHgEBARUBAQEBAQUBAQcBDwEBARoBAgEBAQEBAQECAQEBAQEBAQEBAQEBAQEBAQMBBAEBAgEBAQEUfwEBAQIDAXj/AQ=="},{d:"AFUVAF3Xd3X/93//VXVVV9VX9V91f1/31X93XVXdVdVV9dVV/VVX1X9X/131VfXVVXV3V1VdVV1V1/1dV1X/3VUAVf3/3/9fVf3/3/9fVV1V/11VFQBQVQEAEEEQVQBQVQBAVFUVAFVUVQUAEAAUBFBVFVFVAEBVBQBUVRUAVVFVBRAAAVBVAVVQVQBVBQBAVUVUAQBUUQEAVQVVUVVUAVRVUVUFVUVBVVRBFRRQUVVQUVUBEFRRVQVVBQBRVRQBVFVRVUFVBVVFVVRVUVVUVQRUBQRQVUFVBVVFVVBVBVVQVRVUAVRVUVUFVVFVRVUFRFVRAEBVFQBAVVEAVFUAQFVQVRFRVQEAQAAEVQEAAQBUVUVVAQQAQVVQBVRVAVRVRUFVUVVRVaoAVQFVBVRVBVUFVQVVEABQVUUBAFVRVRUAVUFVUVVAFVRVRVUBVRUUVUUAQEQBAFQVABRVAEBVAFUEQFRFVRUAVVBVBVAQUFVFUBFQVQAFVUAABABUUVVUUFUVANd/X3//BUD3XdV1VQAEAFVXVdX9V1VXVQBUVdVdVdV1VX111VXVV9V//1X/X1VdVf9fVV9VdVdV1VX31dfVXXX9193/d1X/VV9VV3VVX//1VfVVXVVdVdVVdVWlVWlVqVaWVf/f/1X/Vf/1X1Xf/19V9VVf9df1X1X1X1XVVWlVfV31VVpVd1V3VapV33/fVZVVlVX1WVWlVelV+v/v//7/31Xv/6/77/tVWaVVVlVdVWaVmlX1/1WpVVZVlVWVVlVW+V9VFVBVAKqaqlWqWlWqVaoKoKpqqapqgapVqaqpqmqqVapqqv+qVqpqVRVAAFBVBVVQVUUVVUFVVFVQVQBQVRVVBQBQVRUAUFWqVkBVFQVQVVFVAUBBVRVVVFVUVQQUVAVRVVBVRVVRVFFVqlVFVQCqWlUAqmqqaqpVqlZVqmpVAV1VUVVUVQVAVQFBVQBVQBVVQVUAVRVUVQFVBQBUVQVQVVFVAEBVFFRVFVBVFUBBUUVVUVVAVRUAAQBUVRVVUFUFAEBVARRVFVAEVUVVFQBAVVRVBQBUAFRVAAVEVUVVFQBEFQRVBVBVEFRVUFUVAEARVFUVUQAQVQEFEABVFQBBVRVEFVUABVVUVQEAQFUVABRAVRVVAUABVQUAQFBVAEAAEFUFAAUABEFVAUBFEAAQVVARVRVUVVBVBUBVRFVUFQBQVQBUVQBAVRVVFUBVqlRVWlWqVapaVapWVaqpqmmqalVlVWpZVapVqlVBAFUAUABAVRVQVRUAQAEAVQVQVQVUVQBAFQBUVVFVVFUVAAEAVQBAABQAEARAVUVVAFUAQFUAQFVWVZVV/39V/1//X1X/76uq6v9XVWpVqlWqVlVaVapaVapWVamqmqqmqlWqapWqVapWqmqmqpaqWlWVaqpVZVVpVVZVlapVqlpVVmqpVapVlVZVqlZVqlVWVapqqpqqVapWqlZVqpqqWlWlqlWqVlWqVlVRVQD/Xw==",r:"CBcBCAEBAQEBAQEBAQECAQEBAQEBAQEBAQEBAQMBAQECAQEBAQEBAQEBAQEBBAEBGAEDAQwBAwEIAQEBAQEBAQgcCAEDAQEBAQEDAQEBDQEDEAELAQEBEQEKAQEBDgEBAgIBAQoBBQQBCAEBAQEBAQEHAQEHBgEWAQIBDQECAgEFAQECAgEKAQ0BAQIKAQ0BDQEBAQEBAQEBAgEHAQ4BAQEBAQQBBgEBDgEBAQEBAQcBAQIBAQEBBAEFAQEBDgEBAQEBAQECAQcBDwECAQwCDQEBAQEBAQECAQgBAQEEAQcBDQEBAQEBAQQBBwERAQEBARYBAQECAQEBGAECAQIBARIBBgEBDQECAQEBAQECAQgBAQEZAQEBAgYBAQEDAQECAQEBAQMBCBgIBwEMAQEGAQcBBwEQAQEBAQEBAgIBCgEBDQEIAQ0BAQEBAQEBBgEBDgEBAQEBAQEBAgEMBwEMAQwBAQEBCQECAwEHAQEBAQ0BAQEBDgIBBgEDAQEBAQEBAQMBAQEBAgEBAQEBAQEBCAEBAgEBAQEBAQkBCAgBAwECAQEBAgEBAQkBAQEBAwECAQMBAQIBBwEFAQEDAQYBAQEBAgEBAQEBAQEBAQECAgEDAQECBAIDAgIBBQEEAQEBAwEPAQEBCyIBCAEJAwQBAQIBAQEBAgECAQEBAQMBAQEBAwEBAQEBAQEBAQgBAQMDAgEBAwEEAQIBAQEBBAEBAQEBAQECAQEBAQEBAQEBAQEHAQQBAwEBAQcBAgUBBgECAQYBAQwBAQEUAQELCAYBFgMFAQYDAQoBAQMBARQBAQkBAQoBBgEVAwsBCgIPAQ0BGQEBAgEHARQBAwIBBgEBAQUBBgQBAgEJAQEBBQECAQMHAQELAQECCQEQAQECAgECAQsBDAEBAQEBCgEBAQsBAQEECQ4BCAQCAQEECAEEAQEFCAEPAQEEAQEPAQgBFAEBAQEBAQEKAQEJAQ8BEAEBEwEBAQIBCwEBDgENAwEKAQEBAQELAQEBAQECAQwBCAEBAQEBDgEDAQwBAQECAQEXAQEBAQEHAgEBBQEIAQEBAQEQAgEBBQEUAQEBAQEbAQEBAQEGARQBAQEBARkBAQEBCQEBAQEQAQIBDwEBARQBAQEBBwEBAQkBAQEBAQECAQEBCwECAQEVAQEBAQQBBQEBAQEOAQEBAQEBEgEBFgEBAgEMAQEBAQ8BAQMBFgEBDgEBBQEPAQETAQECAQMOAgUBCgIBGQEBAQEIAQMBBwEBAwECEwgBAQcLAQUBFwEBAQEDAQEBBwEBBAEBDg0BAQwBAQEDAQQBAQEDBAEBBAEBAQEBEAEPAQgBAQsBAQ4BEQEMAgEBBwEOAQEHAQEBAQQBBAEDCwECAQEBAwEBBggBAgEBAREBBQMKAQEBAwQCEQEBHgEPAQIBAQYEAQYBAwEUAQUMAQEBAQEBAQECAQEBAgEIAwEBBgsBAgEODAMBAgEBCwEBAQEBAwECAQECAQEBBwgPAQ=="}]};em=new Map});function om(e,t,r){let o=t.map((n)=>{let i=n[e];return(i instanceof ie&&i.getColSpan()>1?"":i?.toString()||"").split(`
|
|
75
|
+
`).map((a)=>{let c=typeof r>"u"?a:or(r,a);return Se(c)||0})}).flat();return Math.max(...o)}function nm(e){let t=[];for(let{groups:i}of e.matchAll(new RegExp(Hs,"g"))){if(!i)continue;let s=Object.entries(i).find(([u,l])=>l);if(!s)continue;let[a,c]=s;t.push({kind:a.slice(1),content:c})}let r=[];for(let i of t)r=[...r.filter((s)=>s.kind!==i.kind),i];r=r.filter(({content:i,kind:s})=>i!==s);let o=r.map(({kind:i})=>`\x1B[${i}m`).reverse().join(""),n=r.map(({content:i})=>`\x1B[${i}m`).join("");return{currentSuffix:o,nextPrefix:n}}var Se=(e)=>tm(Yf(e)),Hs;var Js=_(()=>{Co();Xf();rm();Hs=/\x1b\[(?:(?<_0>0)|(?<_22>1|2|22)|(?<_23>3|23)|(?<_24>4|24)|(?<_27>7|27)|(?<_28>8|28)|(?<_29>9|29)|(?<_39>30|31|32|33|34|35|36|37|38;2;\d+;\d+;\d+|38;5;\d+|39|90|91|92|93|94|95|96|97)|(?<_49>40|41|42|43|44|45|46|47|48;2;\d+;\d+;\d+|48;5;\d+|49|100|101|102|103|104|105|106|107))m/.source});function or(e,t){let r="",o=t.split(`
|
|
76
|
+
`)[0]?.split(/ /g);for(let n=0;n<o.length;n++){let i=o[n];if(r){let s=Se(i);if(Se(r)+s>=e)break}r+=(n>0?" ":"")+i}return r}function im(e,t){let r="",o=[...t.split(`
|
|
77
|
+
`)[0].matchAll(new RegExp(`(?:${Hs})+|.`,"gu"))].map(([n])=>n);for(let n of o){if(r){let i=Se(n);if(Se(r)+i>e)break}r+=n}return r}var Co=_(()=>{Js()});var le;var Ro=_(()=>{le=class le extends Array{options={};static from(e){let t=new this(...e);if(e instanceof le)t.options={...e.options};return t}clone(){let e=new le(...this.map((t)=>t instanceof ie?t.clone():t));return e.options={...this.options},e}border(e=!0,t=!0){if(t||typeof this.options.border>"u")this.options.border=e;return this}align(e,t=!0){if(t||typeof this.options.align>"u")this.options.align=e;return this}getBorder(){return this.options.border===!0}hasBorder(){return this.getBorder()||this.some((e)=>e instanceof ie&&e.getBorder())}getAlign(){return this.options.align??"left"}}});class Ys{table;options;constructor(e,t){this.table=e,this.options=t}toString(){let e=this.createLayout();return e.rows.length?this.renderRows(e):""}createLayout(){Object.keys(this.options.chars).forEach((u)=>{if(typeof this.options.chars[u]!=="string")this.options.chars[u]=""});let e=this.table.getBorder()||this.table.hasBodyBorder(),t=this.table.hasHeaderBorder(),r=t||e,o=this.#t(),n=Math.max(...o.map((u)=>u.length));for(let u=0;u<o.length;u++){let l=o[u],f=l.length;if(f<n){let d=n-f;for(let p=0;p<d;p++)l.push(this.createCell(null,l,u,f+p))}}let{padding:i,width:s,minColWidth:a,maxColWidth:c}=this.computeColumnDimensions(n,o);if(isFinite(this.options.maxWidth)){let u=r?$e(i)*2+(n+1):$e(i.slice(0,-1)),l=this.options.maxWidth-u;if($e(s)>l)this.applyFlexShrink(s,a,l);if($e(s)<l)this.applyFlexGrow(s,c,l)}return{padding:i,width:s,rows:o,columns:n,hasBorder:r,hasBodyBorder:e,hasHeaderBorder:t}}computeColumnDimensions(e,t){let r=[],o=[],n=[],i=[];for(let s=0;s<e;s++){let a=this.options.columns.at(s);n[s]=a?.getMinWidth()??(Array.isArray(this.options.minColWidth)?this.options.minColWidth[s]:this.options.minColWidth)??0,i[s]=a?.getMaxWidth()??(Array.isArray(this.options.maxColWidth)?this.options.maxColWidth[s]:this.options.maxColWidth)??1/0;let c=om(s,t,i[s]);o[s]=Math.min(i[s],Math.max(n[s],c)),r[s]=a?.getPadding()??(Array.isArray(this.options.padding)?this.options.padding[s]:this.options.padding)??0}return{padding:r,width:o,minColWidth:n,maxColWidth:i}}applyFlexShrink(e,t,r){let o=e.map((i,s)=>this.resolveColumnWeight("flexShrink",s)),n=!0;while(n){if(n=!1,$e(e)<=r)break;let i=$e(e)-r,s=$e(e.map((a,c)=>o[c]>0&&a>t[c]?o[c]*a:0));if(s===0)break;for(let a=0;a<e.length;a++)if(o[a]>0&&e[a]>t[a]){let c=Math.max(Math.max(1,t[a]),Math.floor(e[a]*(1-i*o[a]/s)));if(c!==e[a])e[a]=c,n=!0}}}applyFlexGrow(e,t,r){let o=e.map((i,s)=>this.resolveColumnWeight("flexGrow",s)),n=!0;while(n){if(n=!1,$e(e)>=r)break;let i=r-$e(e),s=$e(o.map((a,c)=>e[c]<t[c]?a:0));if(s===0)break;for(let a=0;a<e.length;a++)if(o[a]>0&&e[a]<t[a]){let c=Math.floor(i*o[a]/s),u=Math.min(t[a],e[a]+c);if(u!==e[a])e[a]=u,n=!0}}}resolveColumnWeight(e,t){let r=e==="flexShrink"?"getFlexShrink":"getFlexGrow",o=this.options.columns.at(t)?.[r]()??(Array.isArray(this.options[e])?this.options[e][t]:this.options[e]);return Number.isFinite(o)&&o>0?o:0}#t(){let e=this.table.getHeader(),t=e?[e,...this.table]:this.table.slice();if(t.some((o)=>o.some((n)=>n instanceof ie&&(n.getColSpan()>1||n.getRowSpan()>1))))return this.spanRows(t);return t.map((o,n)=>{let i=this.createRow(o);for(let s=0;s<o.length;s++)i[s]=this.createCell(o[s],i,n,s);return i})}spanRows(e){let t=[],r=1,o=-1;while(!0){if(o++,o===e.length&&t.every((s)=>s===1))break;let n=e[o]=this.createRow(e[o]||[]),i=-1;while(!0){if(i++,i===n.length&&i===t.length&&r===1)break;if(r>1){r--,t[i]=t[i-1],n.splice(i,this.getDeleteCount(e,o,i),n[i-1]);continue}if(t[i]>1){t[i]--,e[o].splice(i,this.getDeleteCount(e,o,i),e[o-1][i]);continue}let s=n[i]=this.createCell(n[i]||null,n,o,i);r=s.getColSpan(),t[i]=s.getRowSpan()}}return e}getDeleteCount(e,t,r){return r<=e[t].length-1&&typeof e[t][r]>"u"?1:0}createRow(e){return le.from(e).border(this.table.getBorder(),!1).align(this.table.getAlign(),!1)}createCell(e,t,r,o){let n=this.options.columns.at(o),i=this.isHeaderRow(r);return ie.from(e??"").border((i?null:n?.getBorder())??t.getBorder(),!1).align((i?null:n?.getAlign())??t.getAlign(),!1)}isHeaderRow(e){return e===0&&this.table.getHeader()!==void 0}renderRows(e){let t="",r=Array(e.columns).fill(1);for(let o=0;o<e.rows.length;o++)t+=this.renderRow(r,o,e);return t.slice(0,-1)}renderRow(e,t,r,o){let n=r.rows[t],i=r.rows[t-1],s=r.rows[t+1],a="",c=1;if(!o&&t===0&&n.hasBorder())a+=this.renderBorderRow(void 0,n,e,r);let u=!1;a+=" ".repeat(this.options.indent||0);for(let l=0;l<r.columns;l++){if(c>1){c--,e[l]=e[l-1];continue}if(a+=this.renderCell(l,n,r),e[l]>1){if(!o)e[l]--}else if(!i||i[l]!==n[l])e[l]=n[l].getRowSpan();if(c=n[l].getColSpan(),e[l]===1&&n[l].length)u=!0}if(r.columns>0){if(n[r.columns-1].getBorder())a+=this.options.chars.right;else if(r.hasBorder)a+=" "}if(a+=`
|
|
78
|
+
`,u)return a+this.renderRow(e,t,r,u);if(r.rows.length>1&&(t===0&&r.hasHeaderBorder||t<r.rows.length-1&&r.hasBodyBorder))a+=this.renderBorderRow(n,s,e,r);if(t===r.rows.length-1&&n.hasBorder())a+=this.renderBorderRow(n,void 0,e,r);return a}renderCell(e,t,r,o){let n="",i=t[e-1],s=t[e];if(!o){if(e===0){if(s.getBorder())n+=this.options.chars.left;else if(r.hasBorder)n+=" "}else if(s.getBorder()||i?.getBorder())n+=this.options.chars.middle;else if(r.hasBorder)n+=" "}let a=r.width[e],c=s.getColSpan();if(c>1){for(let f=1;f<c;f++)if(a+=r.width[e+f]+r.padding[e+f],r.hasBorder)a+=r.padding[e+f]+1}let{current:u,next:l}=this.renderCellValue(s,a);if(t[e].setValue(l),r.hasBorder)n+=" ".repeat(r.padding[e]);if(n+=u,r.hasBorder||e<r.columns-1)n+=" ".repeat(r.padding[e]);return n}renderCellValue(e,t){if(t<=0)return{current:"",next:""};let r=Math.min(t,Se(e.toString())),o=or(r,e.toString()),n=Se(o)>r;if(n)o=im(r,o);let i=e.toString().slice(o.length+(n?0:1));o=e.unclosedAnsiRuns+o;let{currentSuffix:s,nextPrefix:a}=nm(o);o+=s,e.unclosedAnsiRuns=a;let c=t-Se(o),u=e.getAlign(),l;if(c===0)l=o;else if(u==="left")l=o+" ".repeat(c);else if(u==="center")l=" ".repeat(Math.floor(c/2))+o+" ".repeat(Math.ceil(c/2));else if(u==="right")l=" ".repeat(c)+o;else throw Error("Unknown direction: "+u);return{current:l,next:i}}renderBorderRow(e,t,r,o){let n="",i=1;for(let s=0;s<o.columns;s++){if(r[s]>1){if(!t)throw Error("invalid layout");if(i>1){i--;continue}}n+=this.renderBorderCell(s,e,t,r,o),i=t?.[s].getColSpan()??1}return n.length?" ".repeat(this.options.indent)+n+`
|
|
79
|
+
`:""}renderBorderCell(e,t,r,o,n){let i=t?.[e-1],s=r?.[e-1],a=t?.[e],c=r?.[e],u=!!i?.getBorder(),l=!!s?.getBorder(),f=!!a?.getBorder(),d=!!c?.getBorder(),p=(b)=>(b?.getColSpan()??1)>1,m=(b)=>(b?.getRowSpan()??1)>1,h="";if(e===0)if(o[e]>1)if(f)h+=this.options.chars.left;else h+=" ";else if(f&&d)h+=this.options.chars.leftMid;else if(f)h+=this.options.chars.bottomLeft;else if(d)h+=this.options.chars.topLeft;else h+=" ";else if(e<n.columns)if(u&&d||f&&l){let b=p(i),P=p(s),E=p(a),A=p(c),x=m(i),k=m(s),T=m(a),B=m(c),W=u&&d&&f&&l,Te=x&&T&&k&&B,Ne=b&&E&&P&&A;if(Te&&W)h+=this.options.chars.middle;else if(Ne&&W&&i===a&&s===c)h+=this.options.chars.mid;else if(b&&E&&i===a)h+=this.options.chars.topMid;else if(P&&A&&s===c)h+=this.options.chars.bottomMid;else if(x&&k&&i===s)h+=this.options.chars.leftMid;else if(T&&B&&a===c)h+=this.options.chars.rightMid;else h+=this.options.chars.midMid}else if(u&&f)if(p(i)&&p(a)&&i===a)h+=this.options.chars.bottom;else h+=this.options.chars.bottomMid;else if(f&&d)if(o[e]>1)h+=this.options.chars.left;else h+=this.options.chars.leftMid;else if(d&&l)if(p(s)&&p(c)&&s===c)h+=this.options.chars.top;else h+=this.options.chars.topMid;else if(u&&l)if(m(i)&&i===s)h+=this.options.chars.right;else h+=this.options.chars.rightMid;else if(u)h+=this.options.chars.bottomRight;else if(f)h+=this.options.chars.bottomLeft;else if(l)h+=this.options.chars.topRight;else if(d)h+=this.options.chars.topLeft;else h+=" ";let y=n.padding[e]+n.width[e]+n.padding[e];if(o[e]>1&&r){if(h+=this.renderCell(e,r,n,!0),r[e]===r[r.length-1]){if(f)h+=this.options.chars.right;else h+=" ";return h}}else if(f&&d)h+=this.options.chars.mid.repeat(y);else if(f)h+=this.options.chars.bottom.repeat(y);else if(d)h+=this.options.chars.top.repeat(y);else h+=" ".repeat(y);if(e===n.columns-1)if(f&&d)h+=this.options.chars.rightMid;else if(f)h+=this.options.chars.bottomRight;else if(d)h+=this.options.chars.topRight;else h+=" ";return h}}var $e=(e)=>e.reduce((t,r)=>t+r,0);var sm=_(()=>{Co();Ro();Js()});var Ze;var am=_(()=>{Ks();sm();Ro();Ze=class Ze extends Array{static _chars={...Gs};options={indent:0,border:!1,maxColWidth:1/0,minColWidth:0,padding:1,maxWidth:1/0,flexShrink:0,flexGrow:0,chars:{...Ze._chars},columns:[]};headerRow;static from(e){let t=new this(...e);if(e instanceof Ze)t.options={...e.options},t.headerRow=e.headerRow?le.from(e.headerRow):void 0;return t}static fromJson(e){return new this().fromJson(e)}static chars(e){return Object.assign(this._chars,e),this}static render(e){Ze.from(e).render()}fromJson(e){return this.header(Object.keys(e[0])),this.body(e.map((t)=>Object.values(t))),this}columns(e){return this.options.columns=e.map((t)=>t instanceof Ee?t:Ee.from(t)),this}column(e,t){if(t instanceof Ee)this.options.columns[e]=t;else if(this.options.columns[e])this.options.columns[e].options(t);else this.options.columns[e]=Ee.from(t);return this}header(e){return this.headerRow=e instanceof le?e:le.from(e),this}body(e){return this.length=0,this.push(...e),this}clone(){let e=new Ze(...this.map((t)=>t instanceof le?t.clone():le.from(t).clone()));return e.options={...this.options},e.headerRow=this.headerRow?.clone(),e}toString(){return new Ys(this,this.options).toString()}render(){return console.log(this.toString()),this}maxColWidth(e,t=!0){if(t||typeof this.options.maxColWidth>"u")this.options.maxColWidth=e;return this}minColWidth(e,t=!0){if(t||typeof this.options.minColWidth>"u")this.options.minColWidth=e;return this}maxWidth(e,t=!0){if(t||typeof this.options.maxWidth>"u")this.options.maxWidth=e;return this}flexShrink(e=1,t=!0){if(t||typeof this.options.flexShrink>"u")this.options.flexShrink=e;return this}flexGrow(e=1,t=!0){if(t||typeof this.options.flexGrow>"u")this.options.flexGrow=e;return this}flex(e=1,t=!0){return this.flexGrow(e,t).flexShrink(e,t)}indent(e,t=!0){if(t||typeof this.options.indent>"u")this.options.indent=e;return this}padding(e,t=!0){if(t||typeof this.options.padding>"u")this.options.padding=e;return this}border(e=!0,t=!0){if(t||typeof this.options.border>"u")this.options.border=e;return this}align(e,t=!0){if(t||typeof this.options.align>"u")this.options.align=e;return this}chars(e){return Object.assign(this.options.chars,e),this}getHeader(){return this.headerRow}getBody(){return[...this]}getMaxColWidth(){return this.options.maxColWidth}getMinColWidth(){return this.options.minColWidth}getIndent(){return this.options.indent}getPadding(){return this.options.padding}getBorder(){return this.options.border===!0}hasHeaderBorder(){let e=this.headerRow?.hasBorder();return e===!0||this.getBorder()&&e!==!1}hasBodyBorder(){return this.getBorder()||this.options.columns.some((e)=>e.getBorder())||this.some((e)=>e instanceof le?e.hasBorder():e.some((t)=>t instanceof ie?t.getBorder():!1))}hasBorder(){return this.hasHeaderBorder()||this.hasBodyBorder()}getAlign(){return this.options.align??"left"}getColumns(){return this.options.columns}getColumn(e){return this.options.columns[e]??=new Ee}}});var cm=_(()=>{Ks();Co();Ro();am()});function fe(e){return new Ze(Object.keys(e[0]??{}).map((t)=>t.toUpperCase()),...e.map((t)=>Object.values(t))).toString()}function um(e){if(!e)return;if(Array.isArray(e))return e.map((t)=>{let r=t.indexOf("=");return{name:r===-1?t:t.slice(0,r),value:r===-1?void 0:t.slice(r+1)}});return Object.entries(e).map(([t,r])=>({name:t,value:r===null?void 0:String(r)}))}var ot=_(()=>{cm()});async function ev(e,t=C){let r=e?`/audit?${new URLSearchParams({workspaceId:e})}`:"/audit",o=await t(r);if(o.items.length===0)return"No audit events";return fe(o.items.map((n)=>({timestamp:n.metadata.creationTimestamp,actor:n.spec.actor.username,action:n.spec.action,workspace:n.spec.workspaceId,outcome:n.spec.outcome,operation:n.spec.operationId})))}var tv,rv;var lm=_(()=>{q();G();ot();tv=S({meta:{name:"ls",description:"List audit events"},args:{workspace:{type:"string",alias:"w",description:"Filter by workspace"}},async run({args:e}){console.log(await ev(e.workspace??e._[0]))}}),rv=S({meta:{name:"audit",description:"Inspect the audit log"},subCommands:{ls:tv}})});import{basename as ov,isAbsolute as nv,resolve as pm}from"path";import{pathToFileURL as iv}from"url";function Xs(e,t){if(typeof e!=="string"||e.trim().length===0)throw Error(`${t} must be a non-empty string`);return e.trim()}function cv(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw Error(`${t} must default export a configuration object`);let r=e;for(let o of["compose","preBuild","postBuild","postRender","postApply"])if(r[o]!==void 0&&typeof r[o]!=="function")throw Error(`${o} in ${t} must be a function`);if(r.project!==void 0)Xs(r.project,"project");if(r.composeFile!==void 0)Xs(r.composeFile,"composeFile");if(r.registry!==void 0)Xs(r.registry,"registry");if(r.rolloutTimeoutMs!==void 0&&(typeof r.rolloutTimeoutMs!=="number"||!Number.isFinite(r.rolloutTimeoutMs)||r.rolloutTimeoutMs<=0))throw Error(`rolloutTimeoutMs in ${t} must be a positive number`);return e}function dm(e){let t,r=[];for(let o=0;o<e.length;o+=1){let n=e[o];if(n==="--"){r.push(...e.slice(o));break}if(n.startsWith("--config=")){let i=n.slice(9);if(!i)throw Error("--config requires a path");if(t)throw Error("--config may only be specified once");t=i;continue}if(n==="--config"){let i=e[o+1];if(!i||i.startsWith("-"))throw Error(`${n} requires a path`);if(t)throw Error("--config may only be specified once");t=i,o+=1;continue}r.push(n)}return{configPath:t,rawArgs:r}}async function fm(e,t){let r=pm(e,t??sv),o=await Bun.file(r).exists();if(!o&&t)throw Error(`Config file cannot be found: ${r}`);let n=o?cv((await import(iv(r).href)).default,r):{},i=n.composeFile?.trim(),s=(n.registry?.trim()??To).replace(/\/+$/,"");if(!s)throw Error(`registry in ${r} cannot be empty`);return{project:n.project?.trim()??ov(e),projectConfigured:n.project!==void 0,composeFile:i?nv(i)?i:pm(e,i):void 0,registry:s,rolloutTimeoutMs:n.rolloutTimeoutMs??av,configFile:o?r:void 0,compose:n.compose,preBuild:n.preBuild,postBuild:n.postBuild,postRender:n.postRender,postApply:n.postApply}}function mm(e,t,r){return{cwd:t,project:e.project,composeFile:r,configFile:e.configFile}}var sv=".kuberrc.ts",To,av=300000;var Oo=_(()=>{Fe();To=Mf});var hm;var gm=_(()=>{hm={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"compose_spec.json",type:"object",title:"Compose Specification",description:"The Compose file is a YAML file defining a multi-containers based application.",properties:{version:{type:"string",deprecated:!0,description:"declared for backward compatibility, ignored. Please remove it."},name:{type:"string",description:"define the Compose project name, until user defines one explicitly."},include:{type:"array",items:{$ref:"#/$defs/include"},description:"compose sub-projects to be included."},services:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/service"}},additionalProperties:!1,description:"The services that will be used by your application."},models:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/model"}},description:"Language models that will be used by your application."},networks:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/network"}},description:"Networks that are shared among multiple services."},volumes:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/volume"}},additionalProperties:!1,description:"Named volumes that are shared among multiple services."},secrets:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/secret"}},additionalProperties:!1,description:"Secrets that are shared among multiple services."},configs:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/config"}},additionalProperties:!1,description:"Configurations that are shared among multiple services."}},patternProperties:{"^x-":{}},additionalProperties:!1,$defs:{service:{type:"object",description:"Configuration for a service.",properties:{develop:{$ref:"#/$defs/development"},deploy:{$ref:"#/$defs/deployment"},annotations:{$ref:"#/$defs/list_or_dict"},attach:{type:["boolean","string"]},build:{description:"Configuration options for building the service's image.",oneOf:[{type:"string",description:"Path to the build context. Can be a relative path or a URL."},{type:"object",properties:{context:{type:"string",description:"Path to the build context. Can be a relative path or a URL."},dockerfile:{type:"string",description:"Name of the Dockerfile to use for building the image."},dockerfile_inline:{type:"string",description:"Inline Dockerfile content to use instead of a Dockerfile from the build context."},entitlements:{type:"array",items:{type:"string"},description:"List of extra privileged entitlements to grant to the build process."},args:{$ref:"#/$defs/list_or_dict",description:"Build-time variables, specified as a map or a list of KEY=VAL pairs."},ssh:{$ref:"#/$defs/list_or_dict",description:"SSH agent socket or keys to expose to the build. Format is either a string or a list of 'default|<id>[=<socket>|<key>[,<key>]]'."},labels:{$ref:"#/$defs/list_or_dict",description:"Labels to apply to the built image."},cache_from:{type:"array",items:{type:"string"},description:"List of sources the image builder should use for cache resolution"},cache_to:{type:"array",items:{type:"string"},description:"Cache destinations for the build cache."},no_cache:{type:["boolean","string"],description:"Do not use cache when building the image."},no_cache_filter:{$ref:"#/$defs/string_or_list",description:"Do not use build cache for the specified stages."},additional_contexts:{$ref:"#/$defs/list_or_dict",description:"Additional build contexts to use, specified as a map of name to context path or URL."},network:{type:"string",description:"Network mode to use for the build. Options include 'default', 'none', 'host', or a network name."},provenance:{type:["string","boolean"],description:"Add a provenance attestation"},sbom:{type:["string","boolean"],description:"Add a SBOM attestation"},pull:{type:["boolean","string"],description:"Always attempt to pull a newer version of the image."},target:{type:"string",description:"Build stage to target in a multi-stage Dockerfile."},shm_size:{type:["integer","string"],description:"Size of /dev/shm for the build container. A string value can use suffix like '2g' for 2 gigabytes."},extra_hosts:{$ref:"#/$defs/extra_hosts",description:"Add hostname mappings for the build container."},isolation:{type:"string",description:"Container isolation technology to use for the build process."},privileged:{type:["boolean","string"],description:"Give extended privileges to the build container."},secrets:{$ref:"#/$defs/service_config_or_secret",description:"Secrets to expose to the build. These are accessible at build-time."},tags:{type:"array",items:{type:"string"},description:"Additional tags to apply to the built image."},ulimits:{$ref:"#/$defs/ulimits",description:"Override the default ulimits for the build container."},platforms:{type:"array",items:{type:"string"},description:"Platforms to build for, e.g., 'linux/amd64', 'linux/arm64', or 'windows/amd64'."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},blkio_config:{type:"object",description:"Block IO configuration for the service.",properties:{device_read_bps:{type:"array",description:"Limit read rate (bytes per second) from a device.",items:{$ref:"#/$defs/blkio_limit"}},device_read_iops:{type:"array",description:"Limit read rate (IO per second) from a device.",items:{$ref:"#/$defs/blkio_limit"}},device_write_bps:{type:"array",description:"Limit write rate (bytes per second) to a device.",items:{$ref:"#/$defs/blkio_limit"}},device_write_iops:{type:"array",description:"Limit write rate (IO per second) to a device.",items:{$ref:"#/$defs/blkio_limit"}},weight:{type:["integer","string"],description:"Block IO weight (relative weight) for the service, between 10 and 1000."},weight_device:{type:"array",description:"Block IO weight (relative weight) for specific devices.",items:{$ref:"#/$defs/blkio_weight"}}},additionalProperties:!1},cap_add:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Add Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'."},cap_drop:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Drop Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'."},cgroup:{type:"string",enum:["host","private"],description:"Specify the cgroup namespace to join. Use 'host' to use the host's cgroup namespace, or 'private' to use a private cgroup namespace."},cgroup_parent:{type:"string",description:"Specify an optional parent cgroup for the container."},command:{$ref:"#/$defs/command",description:"Override the default command declared by the container image, for example 'CMD' in Dockerfile."},configs:{$ref:"#/$defs/service_config_or_secret",description:"Grant access to Configs on a per-service basis."},container_name:{type:"string",description:"Specify a custom container name, rather than a generated default name.",pattern:"[a-zA-Z0-9][a-zA-Z0-9_.-]+"},cpu_count:{oneOf:[{type:"string"},{type:"integer",minimum:0}],description:"Number of usable CPUs."},cpu_percent:{oneOf:[{type:"string"},{type:"integer",minimum:0,maximum:100}],description:"Percentage of CPU resources to use."},cpu_shares:{type:["number","string"],description:"CPU shares (relative weight) for the container."},cpu_quota:{type:["number","string"],description:"Limit the CPU CFS (Completely Fair Scheduler) quota."},cpu_period:{type:["number","string"],description:"Limit the CPU CFS (Completely Fair Scheduler) period."},cpu_rt_period:{type:["number","string"],description:"Limit the CPU real-time period in microseconds or a duration."},cpu_rt_runtime:{type:["number","string"],description:"Limit the CPU real-time runtime in microseconds or a duration."},cpus:{type:["number","string"],description:"Number of CPUs to use. A floating-point value is supported to request partial CPUs."},cpuset:{type:"string",description:"CPUs in which to allow execution (0-3, 0,1)."},credential_spec:{type:"object",description:"Configure the credential spec for managed service account.",properties:{config:{type:"string",description:"The name of the credential spec Config to use."},file:{type:"string",description:"Path to a credential spec file."},registry:{type:"string",description:"Path to a credential spec in the Windows registry."}},additionalProperties:!1,patternProperties:{"^x-":{}}},depends_on:{oneOf:[{$ref:"#/$defs/list_of_strings"},{type:"object",additionalProperties:!1,patternProperties:{"^[a-zA-Z0-9._-]+$":{type:"object",additionalProperties:!1,patternProperties:{"^x-":{}},properties:{restart:{type:["boolean","string"],description:"Whether to restart dependent services when this service is restarted."},required:{type:"boolean",default:!0,description:"Whether the dependency is required for the dependent service to start."},condition:{type:"string",enum:["service_started","service_healthy","service_completed_successfully"],description:"Condition to wait for. 'service_started' waits until the service has started, 'service_healthy' waits until the service is healthy (as defined by its healthcheck), 'service_completed_successfully' waits until the service has completed successfully."}},required:["condition"]}}}],description:"Express dependency between services. Service dependencies cause services to be started in dependency order. The dependent service will wait for the dependency to be ready before starting."},device_cgroup_rules:{$ref:"#/$defs/list_of_strings",description:"Add rules to the cgroup allowed devices list."},devices:{type:"array",description:"List of device mappings for the container.",items:{oneOf:[{type:"string"},{type:"object",required:["source"],properties:{source:{type:"string",description:"Path on the host to the device."},target:{type:"string",description:"Path in the container where the device will be mapped."},permissions:{type:"string",description:"Cgroup permissions for the device (rwm)."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]}},dns:{$ref:"#/$defs/string_or_list",description:"Custom DNS servers to set for the service container."},dns_opt:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Custom DNS options to be passed to the container's DNS resolver."},dns_search:{$ref:"#/$defs/string_or_list",description:"Custom DNS search domains to set on the service container."},domainname:{type:"string",description:"Custom domain name to use for the service container."},entrypoint:{$ref:"#/$defs/command",description:"Override the default entrypoint declared by the container image, for example 'ENTRYPOINT' in Dockerfile."},env_file:{$ref:"#/$defs/env_file",description:"Add environment variables from a file or multiple files. Can be a single file path or a list of file paths."},label_file:{$ref:"#/$defs/label_file",description:"Add metadata to containers using files containing Docker labels."},environment:{$ref:"#/$defs/list_or_dict",description:"Add environment variables. You can use either an array or a list of KEY=VAL pairs."},expose:{type:"array",items:{type:["string","number"]},uniqueItems:!0,description:"Expose ports without publishing them to the host machine - they'll only be accessible to linked services."},extends:{oneOf:[{type:"string"},{type:"object",properties:{service:{type:"string",description:"The name of the service to extend."},file:{type:"string",description:"The file path where the service to extend is defined."}},required:["service"],additionalProperties:!1}],description:"Extend another service, in the current file or another file."},provider:{type:"object",description:"Specify a service which will not be manage by Compose directly, and delegate its management to an external provider.",required:["type"],properties:{type:{type:"string",description:"External component used by Compose to manage setup and teardown lifecycle of the service."},options:{type:"object",description:"Provider-specific options.",patternProperties:{"^.+$":{oneOf:[{type:["string","number","boolean"]},{type:"array",items:{type:["string","number","boolean"]}}]}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},external_links:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Link to services started outside this Compose application. Specify services as <service_name>:<alias>."},extra_hosts:{$ref:"#/$defs/extra_hosts",description:"Add hostname mappings to the container network interface configuration."},gpus:{$ref:"#/$defs/gpus",description:"Define GPU devices to use. Can be set to 'all' to use all GPUs, or a list of specific GPU devices."},group_add:{type:"array",items:{type:["string","number"]},uniqueItems:!0,description:"Add additional groups which user inside the container should be member of."},healthcheck:{$ref:"#/$defs/healthcheck",description:"Configure a health check for the container to monitor its health status."},hostname:{type:"string",description:"Define a custom hostname for the service container."},image:{type:"string",description:"Specify the image to start the container from. Can be a repository/tag, a digest, or a local image ID."},init:{type:["boolean","string"],description:"Run as an init process inside the container that forwards signals and reaps processes."},ipc:{type:"string",description:"IPC sharing mode for the service container. Use 'host' to share the host's IPC namespace, 'service:[service_name]' to share with another service, or 'shareable' to allow other services to share this service's IPC namespace."},isolation:{type:"string",description:"Container isolation technology to use. Supported values are platform-specific."},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to containers using Docker labels. You can use either an array or a list."},links:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Link to containers in another service. Either specify both the service name and a link alias (SERVICE:ALIAS), or just the service name."},logging:{type:"object",description:"Logging configuration for the service.",properties:{driver:{type:"string",description:"Logging driver to use, such as 'json-file', 'syslog', 'journald', etc."},options:{type:"object",description:"Options for the logging driver.",patternProperties:{"^.+$":{type:["string","number","null"]}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},mac_address:{type:"string",description:"Container MAC address to set."},mem_limit:{type:["number","string"],description:"Memory limit for the container. A string value can use suffix like '2g' for 2 gigabytes."},mem_reservation:{type:["string","integer"],description:"Memory reservation for the container."},mem_swappiness:{type:["integer","string"],description:"Container memory swappiness as percentage (0 to 100)."},memswap_limit:{type:["number","string"],description:"Amount of memory the container is allowed to swap to disk. Set to -1 to enable unlimited swap."},network_mode:{type:"string",description:"Network mode. Values can be 'bridge', 'host', 'none', 'service:[service name]', or 'container:[container name]'."},models:{oneOf:[{$ref:"#/$defs/list_of_strings"},{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{oneOf:[{type:"object",properties:{endpoint_var:{type:"string",description:"Environment variable set to AI model endpoint."},model_var:{type:"string",description:"Environment variable set to AI model name."}},additionalProperties:!1,patternProperties:{"^x-":{}}},{type:"null"}]}}}],description:"AI Models to use, referencing entries under the top-level models key."},networks:{oneOf:[{$ref:"#/$defs/list_of_strings"},{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{oneOf:[{type:"object",properties:{aliases:{$ref:"#/$defs/list_of_strings",description:"Alternative hostnames for this service on the network."},interface_name:{type:"string",description:"Interface network name used to connect to network"},ipv4_address:{type:"string",description:"Specify a static IPv4 address for this service on this network."},ipv6_address:{type:"string",description:"Specify a static IPv6 address for this service on this network."},link_local_ips:{$ref:"#/$defs/list_of_strings",description:"List of link-local IPs."},mac_address:{type:"string",description:"Specify a MAC address for this service on this network."},driver_opts:{type:"object",description:"Driver options for this network.",patternProperties:{"^.+$":{type:["string","number"]}}},priority:{type:"number",description:"Specify the priority for the network connection."},gw_priority:{type:"number",description:"Specify the gateway priority for the network connection."}},additionalProperties:!1,patternProperties:{"^x-":{}}},{type:"null"}]}},additionalProperties:!1}],description:"Networks to join, referencing entries under the top-level networks key. Can be a list of network names or a mapping of network name to network configuration."},oom_kill_disable:{type:["boolean","string"],description:"Disable OOM Killer for the container."},oom_score_adj:{oneOf:[{type:"string"},{type:"integer",minimum:-1000,maximum:1000}],description:"Tune host's OOM preferences for the container (accepts -1000 to 1000)."},pid:{type:["string","null"],description:"PID mode for container."},pids_limit:{type:["number","string"],description:"Tune a container's PIDs limit. Set to -1 for unlimited PIDs."},platform:{type:"string",description:"Target platform to run on, e.g., 'linux/amd64', 'linux/arm64', or 'windows/amd64'."},ports:{type:"array",description:"Expose container ports. Short format ([HOST:]CONTAINER[/PROTOCOL]).",items:{oneOf:[{type:"number"},{type:"string"},{type:"object",properties:{name:{type:"string",description:"A human-readable name for this port mapping."},mode:{type:"string",description:"The port binding mode, either 'host' for publishing a host port or 'ingress' for load balancing."},host_ip:{type:"string",description:"The host IP to bind to."},target:{type:["integer","string"],description:"The port inside the container."},published:{type:["string","integer"],description:"The publicly exposed port."},protocol:{type:"string",description:"The port protocol (tcp or udp)."},app_protocol:{type:"string",description:"Application protocol to use with the port (e.g., http, https, mysql)."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},uniqueItems:!0},pre_start:{type:"array",items:{$ref:"#/$defs/pre_start_hook"},description:"Init containers to run to completion before the service container is started. Each step runs in its own ephemeral container, in declared order; a non-zero exit fails the bring-up of the service and its dependents."},post_start:{type:"array",items:{$ref:"#/$defs/service_hook"},description:"Commands to run after the container starts. If any command fails, the container stops."},pre_stop:{type:"array",items:{$ref:"#/$defs/service_hook"},description:"Commands to run before the container stops. If any command fails, the container stop is aborted."},privileged:{type:["boolean","string"],description:"Give extended privileges to the service container."},profiles:{$ref:"#/$defs/list_of_strings",description:"List of profiles for this service. When profiles are specified, services are only started when the profile is activated."},pull_policy:{type:"string",pattern:"always|never|build|if_not_present|missing|refresh|daily|weekly|every_([0-9]+[wdhms])+",description:"Policy for pulling images. Options include: 'always', 'never', 'if_not_present', 'missing', 'build', or time-based refresh policies."},pull_refresh_after:{type:"string",description:"Time after which to refresh the image. Used with pull_policy=refresh."},read_only:{type:["boolean","string"],description:"Mount the container's filesystem as read only."},restart:{type:"string",description:"Restart policy for the service container. Options include: 'no', 'always', 'on-failure', and 'unless-stopped'."},runtime:{type:"string",description:"Runtime to use for this container, e.g., 'runc'."},scale:{type:["integer","string"],description:"Number of containers to deploy for this service."},security_opt:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Override the default labeling scheme for each container."},shm_size:{type:["number","string"],description:"Size of /dev/shm. A string value can use suffix like '2g' for 2 gigabytes."},secrets:{$ref:"#/$defs/service_config_or_secret",description:"Grant access to Secrets on a per-service basis."},sysctls:{$ref:"#/$defs/list_or_dict",description:"Kernel parameters to set in the container. You can use either an array or a list."},stdin_open:{type:["boolean","string"],description:"Keep STDIN open even if not attached."},stop_grace_period:{type:"string",description:"Time to wait for the container to stop gracefully before sending SIGKILL (e.g., '1s', '1m30s')."},stop_signal:{type:"string",description:"Signal to stop the container (e.g., 'SIGTERM', 'SIGINT')."},storage_opt:{type:"object",description:"Storage driver options for the container."},tmpfs:{$ref:"#/$defs/string_or_list",description:"Mount a temporary filesystem (tmpfs) into the container. Can be a single value or a list."},tty:{type:["boolean","string"],description:"Allocate a pseudo-TTY to service container."},ulimits:{$ref:"#/$defs/ulimits",description:"Override the default ulimits for a container."},use_api_socket:{type:"boolean",description:"Bind mount Docker API socket and required auth."},user:{type:"string",description:"Username or UID to run the container process as."},uts:{type:"string",description:"UTS namespace to use. 'host' shares the host's UTS namespace."},userns_mode:{type:"string",description:"User namespace to use. 'host' shares the host's user namespace."},volumes:{type:"array",description:"Mount host paths or named volumes accessible to the container. Short syntax (VOLUME:CONTAINER_PATH[:MODE])",items:{oneOf:[{type:"string"},{type:"object",required:["type"],properties:{type:{type:"string",enum:["bind","volume","tmpfs","cluster","npipe","image"],description:"The mount type: bind for mounting host directories, volume for named volumes, tmpfs for temporary filesystems, cluster for cluster volumes, npipe for named pipes, or image for mounting from an image."},source:{type:"string",description:"The source of the mount, a path on the host for a bind mount, a docker image reference for an image mount, or the name of a volume defined in the top-level volumes key. Not applicable for a tmpfs mount."},target:{type:"string",description:"The path in the container where the volume is mounted."},read_only:{type:["boolean","string"],description:"Flag to set the volume as read-only."},consistency:{type:"string",description:"The consistency requirements for the mount. Available values are platform specific."},bind:{type:"object",description:"Configuration specific to bind mounts.",properties:{propagation:{type:"string",description:"The propagation mode for the bind mount: 'shared', 'slave', 'private', 'rshared', 'rslave', or 'rprivate'."},create_host_path:{type:["boolean","string"],description:"Create the host path if it doesn't exist."},recursive:{type:"string",enum:["enabled","disabled","writable","readonly"],description:"Recursively mount the source directory."},selinux:{type:"string",enum:["z","Z"],description:"SELinux relabeling options: 'z' for shared content, 'Z' for private unshared content."}},additionalProperties:!1,patternProperties:{"^x-":{}}},volume:{type:"object",description:"Configuration specific to volume mounts.",properties:{labels:{$ref:"#/$defs/list_or_dict",description:"Labels to apply to the volume."},nocopy:{type:["boolean","string"],description:"Flag to disable copying of data from a container when a volume is created."},subpath:{type:"string",description:"Path within the volume to mount instead of the volume root."}},additionalProperties:!1,patternProperties:{"^x-":{}}},tmpfs:{type:"object",description:"Configuration specific to tmpfs mounts.",properties:{size:{oneOf:[{type:"integer",minimum:0},{type:"string"}],description:"Size of the tmpfs mount in bytes."},mode:{type:["number","string"],description:"File mode of the tmpfs in octal."}},additionalProperties:!1,patternProperties:{"^x-":{}}},image:{type:"object",description:"Configuration specific to image mounts.",properties:{subpath:{type:"string",description:"Path within the image to mount instead of the image root."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},uniqueItems:!0},volumes_from:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Mount volumes from another service or container. Optionally specify read-only access (ro) or read-write (rw)."},working_dir:{type:"string",description:"The working directory in which the entrypoint or command will be run"}},patternProperties:{"^x-":{}},additionalProperties:!1},healthcheck:{type:"object",description:"Configuration options to determine whether the container is healthy.",properties:{disable:{type:["boolean","string"],description:"Disable any container-specified healthcheck. Set to true to disable."},interval:{type:"string",description:"Time between running the check (e.g., '1s', '1m30s'). Default: 30s."},retries:{type:["number","string"],description:"Number of consecutive failures needed to consider the container as unhealthy. Default: 3."},test:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}],description:"The test to perform to check container health. Can be a string or a list. The first item is either NONE, CMD, or CMD-SHELL. If it's CMD, the rest of the command is exec'd. If it's CMD-SHELL, the rest is run in the shell."},timeout:{type:"string",description:"Maximum time to allow one check to run (e.g., '1s', '1m30s'). Default: 30s."},start_period:{type:"string",description:"Start period for the container to initialize before starting health-retries countdown (e.g., '1s', '1m30s'). Default: 0s."},start_interval:{type:"string",description:"Time between running the check during the start period (e.g., '1s', '1m30s'). Default: interval value."}},additionalProperties:!1,patternProperties:{"^x-":{}}},development:{type:["object","null"],description:"Development configuration for the service, used for development workflows.",properties:{watch:{type:"array",description:"Configure watch mode for the service, which monitors file changes and performs actions in response.",items:{type:"object",required:["path","action"],properties:{ignore:{$ref:"#/$defs/string_or_list",description:"Patterns to exclude from watching."},include:{$ref:"#/$defs/string_or_list",description:"Patterns to include in watching."},path:{type:"string",description:"Path to watch for changes."},action:{type:"string",enum:["rebuild","sync","restart","sync+restart","sync+exec"],description:"Action to take when a change is detected: rebuild the container, sync files, restart the container, sync and restart, or sync and execute a command."},target:{type:"string",description:"Target path in the container for sync operations."},exec:{$ref:"#/$defs/service_hook",description:"Command to execute when a change is detected and action is sync+exec."},initial_sync:{type:"boolean",description:"Ensure that an initial synchronization is done before starting watch mode for sync+x triggers"}},additionalProperties:!1,patternProperties:{"^x-":{}}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},deployment:{type:["object","null"],description:"Deployment configuration for the service.",properties:{mode:{type:"string",description:"Deployment mode for the service: 'replicated' (default) or 'global'."},endpoint_mode:{type:"string",description:"Endpoint mode for the service: 'vip' (default) or 'dnsrr'."},replicas:{type:["integer","string"],description:"Number of replicas of the service container to run."},labels:{$ref:"#/$defs/list_or_dict",description:"Labels to apply to the service."},rollback_config:{type:"object",description:"Configuration for rolling back a service update.",properties:{parallelism:{type:["integer","string"],description:"The number of containers to rollback at a time. If set to 0, all containers rollback simultaneously."},delay:{type:"string",description:"The time to wait between each container group's rollback (e.g., '1s', '1m30s')."},failure_action:{type:"string",description:"Action to take if a rollback fails: 'continue', 'pause'."},monitor:{type:"string",description:"Duration to monitor each task for failures after it is created (e.g., '1s', '1m30s')."},max_failure_ratio:{type:["number","string"],description:"Failure rate to tolerate during a rollback."},order:{type:"string",enum:["start-first","stop-first"],description:"Order of operations during rollbacks: 'stop-first' (default) or 'start-first'."}},additionalProperties:!1,patternProperties:{"^x-":{}}},update_config:{type:"object",description:"Configuration for updating a service.",properties:{parallelism:{type:["integer","string"],description:"The number of containers to update at a time."},delay:{type:"string",description:"The time to wait between updating a group of containers (e.g., '1s', '1m30s')."},failure_action:{type:"string",description:"Action to take if an update fails: 'continue', 'pause', 'rollback'."},monitor:{type:"string",description:"Duration to monitor each updated task for failures after it is created (e.g., '1s', '1m30s')."},max_failure_ratio:{type:["number","string"],description:"Failure rate to tolerate during an update (0 to 1)."},order:{type:"string",enum:["start-first","stop-first"],description:"Order of operations during updates: 'stop-first' (default) or 'start-first'."}},additionalProperties:!1,patternProperties:{"^x-":{}}},resources:{type:"object",description:"Resource constraints and reservations for the service.",properties:{limits:{type:"object",description:"Resource limits for the service containers.",properties:{cpus:{type:["number","string"],description:"Limit for how much of the available CPU resources, as number of cores, a container can use."},memory:{type:"string",description:"Limit on the amount of memory a container can allocate (e.g., '1g', '1024m')."},pids:{type:["integer","string"],description:"Maximum number of PIDs available to the container."}},additionalProperties:!1,patternProperties:{"^x-":{}}},reservations:{type:"object",description:"Resource reservations for the service containers.",properties:{cpus:{type:["number","string"],description:"Reservation for how much of the available CPU resources, as number of cores, a container can use."},memory:{type:"string",description:"Reservation on the amount of memory a container can allocate (e.g., '1g', '1024m')."},generic_resources:{$ref:"#/$defs/generic_resources",description:"User-defined resources to reserve."},devices:{$ref:"#/$defs/devices",description:"Device reservations for the container."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},restart_policy:{type:"object",description:"Restart policy for the service containers.",properties:{condition:{type:"string",description:"Condition for restarting the container: 'none', 'on-failure', 'any'."},delay:{type:"string",description:"Delay between restart attempts (e.g., '1s', '1m30s')."},max_attempts:{type:["integer","string"],description:"Maximum number of restart attempts before giving up."},window:{type:"string",description:"Time window used to evaluate the restart policy (e.g., '1s', '1m30s')."}},additionalProperties:!1,patternProperties:{"^x-":{}}},placement:{type:"object",description:"Constraints and preferences for the platform to select a physical node to run service containers",properties:{constraints:{type:"array",items:{type:"string"},description:"Placement constraints for the service (e.g., 'node.role==manager')."},preferences:{type:"array",description:"Placement preferences for the service.",items:{type:"object",properties:{spread:{type:"string",description:"Spread tasks evenly across values of the specified node label."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},max_replicas_per_node:{type:["integer","string"],description:"Maximum number of replicas of the service."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},generic_resources:{type:"array",description:"User-defined resources for services, allowing services to reserve specialized hardware resources.",items:{type:"object",properties:{discrete_resource_spec:{type:"object",description:"Specification for discrete (countable) resources.",properties:{kind:{type:"string",description:"Type of resource (e.g., 'GPU', 'FPGA', 'SSD')."},value:{type:["number","string"],description:"Number of resources of this kind to reserve."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}}},devices:{type:"array",description:"Device reservations for containers, allowing services to access specific hardware devices.",items:{type:"object",properties:{capabilities:{$ref:"#/$defs/list_of_strings",description:"List of capabilities the device needs to have (e.g., 'gpu', 'compute', 'utility')."},count:{type:["string","integer"],description:"Number of devices of this type to reserve."},device_ids:{$ref:"#/$defs/list_of_strings",description:"List of specific device IDs to reserve."},driver:{type:"string",description:"Device driver to use (e.g., 'nvidia')."},options:{$ref:"#/$defs/list_or_dict",description:"Driver-specific options for the device."}},additionalProperties:!1,patternProperties:{"^x-":{}},required:["capabilities"]}},gpus:{oneOf:[{type:"string",enum:["all"],description:"Use all available GPUs."},{type:"array",description:"List of specific GPU devices to use.",items:{type:"object",properties:{capabilities:{$ref:"#/$defs/list_of_strings",description:"List of capabilities the GPU needs to have (e.g., 'compute', 'utility')."},count:{type:["string","integer"],description:"Number of GPUs to use."},device_ids:{$ref:"#/$defs/list_of_strings",description:"List of specific GPU device IDs to use."},driver:{type:"string",description:"GPU driver to use (e.g., 'nvidia')."},options:{$ref:"#/$defs/list_or_dict",description:"Driver-specific options for the GPU."}}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},include:{description:"Compose application or sub-projects to be included.",oneOf:[{type:"string"},{type:"object",properties:{path:{$ref:"#/$defs/string_or_list",description:"Path to the Compose application or sub-project files to include."},env_file:{$ref:"#/$defs/string_or_list",description:"Path to the environment files to use to define default values when interpolating variables in the Compose files being parsed."},project_directory:{type:"string",description:"Path to resolve relative paths set in the Compose file"}},additionalProperties:!1}]},network:{type:["object","null"],description:"Network configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this network."},driver:{type:"string",description:"Specify which driver should be used for this network. Default is 'bridge'."},driver_opts:{type:"object",description:"Specify driver-specific options defined as key/value pairs.",patternProperties:{"^.+$":{type:["string","number"]}}},ipam:{type:"object",description:"Custom IP Address Management configuration for this network.",properties:{driver:{type:"string",description:"Custom IPAM driver, instead of the default."},config:{type:"array",description:"List of IPAM configuration blocks.",items:{type:"object",properties:{subnet:{type:"string",description:"Subnet in CIDR format that represents a network segment."},ip_range:{type:"string",description:"Range of IPs from which to allocate container IPs."},gateway:{type:"string",description:"IPv4 or IPv6 gateway for the subnet."},aux_addresses:{type:"object",description:"Auxiliary IPv4 or IPv6 addresses used by Network driver.",additionalProperties:!1,patternProperties:{"^.+$":{type:"string"}}}},additionalProperties:!1,patternProperties:{"^x-":{}}}},options:{type:"object",description:"Driver-specific options for the IPAM driver.",additionalProperties:!1,patternProperties:{"^.+$":{type:"string"}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},external:{type:["boolean","string","object"],description:"Specifies that this network already exists and was created outside of Compose.",properties:{name:{deprecated:!0,type:"string",description:"Specifies the name of the external network. Deprecated: use the 'name' property instead."}},additionalProperties:!1,patternProperties:{"^x-":{}}},internal:{type:["boolean","string"],description:"Create an externally isolated network."},enable_ipv4:{type:["boolean","string"],description:"Enable IPv4 networking."},enable_ipv6:{type:["boolean","string"],description:"Enable IPv6 networking."},attachable:{type:["boolean","string"],description:"If true, standalone containers can attach to this network."},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the network using labels."}},additionalProperties:!1,patternProperties:{"^x-":{}}},volume:{type:["object","null"],description:"Volume configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this volume."},driver:{type:"string",description:"Specify which volume driver should be used for this volume."},driver_opts:{type:"object",description:"Specify driver-specific options.",patternProperties:{"^.+$":{type:["string","number"]}}},external:{type:["boolean","string","object"],description:"Specifies that this volume already exists and was created outside of Compose.",properties:{name:{deprecated:!0,type:"string",description:"Specifies the name of the external volume. Deprecated: use the 'name' property instead."}},additionalProperties:!1,patternProperties:{"^x-":{}}},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the volume using labels."}},additionalProperties:!1,patternProperties:{"^x-":{}}},secret:{type:"object",description:"Secret configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this secret."},environment:{type:"string",description:"Name of an environment variable from which to get the secret value."},file:{type:"string",description:"Path to a file containing the secret value."},external:{type:["boolean","string","object"],description:"Specifies that this secret already exists and was created outside of Compose.",properties:{name:{type:"string",description:"Specifies the name of the external secret."}}},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the secret using labels."},driver:{type:"string",description:"Specify which secret driver should be used for this secret."},driver_opts:{type:"object",description:"Specify driver-specific options.",patternProperties:{"^.+$":{type:["string","number"]}}},template_driver:{type:"string",description:"Driver to use for templating the secret's value."}},additionalProperties:!1,patternProperties:{"^x-":{}}},config:{type:"object",description:"Config configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this config."},content:{type:"string",description:"Inline content of the config."},environment:{type:"string",description:"Name of an environment variable from which to get the config value."},file:{type:"string",description:"Path to a file containing the config value."},external:{type:["boolean","string","object"],description:"Specifies that this config already exists and was created outside of Compose.",properties:{name:{deprecated:!0,type:"string",description:"Specifies the name of the external config. Deprecated: use the 'name' property instead."}}},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the config using labels."},template_driver:{type:"string",description:"Driver to use for templating the config's value."}},additionalProperties:!1,patternProperties:{"^x-":{}}},model:{type:"object",description:"Language Model for the Compose application.",properties:{name:{type:"string",description:"Custom name for this model."},model:{type:"string",description:"Language Model to run."},context_size:{type:"integer"},runtime_flags:{type:"array",items:{type:"string"},description:"Raw runtime flags to pass to the inference engine."}},required:["model"],additionalProperties:!1,patternProperties:{"^x-":{}}},command:{oneOf:[{type:"null",description:"No command specified, use the container's default command."},{type:"string",description:"Command as a string, which will be executed in a shell (e.g., '/bin/sh -c')."},{type:"array",description:"Command as an array of strings, which will be executed directly without a shell.",items:{type:"string",description:"Part of the command (executable or argument)."}}],description:"Command to run in the container, which can be specified as a string (shell form) or array (exec form)."},service_hook:{type:"object",description:"Configuration for service lifecycle hooks, which are commands executed at specific points in a container's lifecycle.",properties:{command:{$ref:"#/$defs/command",description:"Command to execute as part of the hook."},user:{type:"string",description:"User to run the command as."},privileged:{type:["boolean","string"],description:"Whether to run the command with extended privileges."},working_dir:{type:"string",description:"Working directory for the command."},environment:{$ref:"#/$defs/list_or_dict",description:"Environment variables for the command."}},additionalProperties:!1,patternProperties:{"^x-":{}},required:["command"]},pre_start_hook:{type:"object",description:"Configuration for a pre_start init container, run to completion before the service container starts.",properties:{command:{$ref:"#/$defs/command",description:"Command to execute. Optional when the chosen image's entrypoint already runs the intended command."},image:{type:"string",description:"Image used for the ephemeral container. If omitted, the parent service's image is used."},user:{type:"string",description:"User to run the command as. Defaults to the user declared in image (or to the service's user when image is omitted)."},privileged:{type:["boolean","string"],description:"Whether to run the command with extended privileges."},working_dir:{type:"string",description:"Working directory for the command. Defaults to the service's working directory."},environment:{$ref:"#/$defs/list_or_dict",description:"Environment variables for the command. Appended to or overriding the service environment."},per_replica:{type:["boolean","string"],description:"Whether the hook runs once per service replica (true), or once for the service as a whole before any replica starts (false, the default)."}},additionalProperties:!1,patternProperties:{"^x-":{}}},env_file:{oneOf:[{type:"string",description:"Path to a file containing environment variables."},{type:"array",description:"List of paths to files containing environment variables.",items:{oneOf:[{type:"string",description:"Path to a file containing environment variables."},{type:"object",description:"Detailed configuration for an environment file.",additionalProperties:!1,properties:{path:{type:"string",description:"Path to the environment file."},format:{type:"string",description:"Format attribute lets you to use an alternative file formats for env_file. When not set, env_file is parsed according to Compose rules."},required:{type:["boolean","string"],default:!0,description:"Whether the file is required. If true and the file doesn't exist, an error will be raised."}},required:["path"]}]}}]},label_file:{oneOf:[{type:"string",description:"Path to a file containing Docker labels."},{type:"array",description:"List of paths to files containing Docker labels.",items:{type:"string",description:"Path to a file containing Docker labels."}}]},string_or_list:{oneOf:[{type:"string",description:"A single string value."},{$ref:"#/$defs/list_of_strings",description:"A list of string values."}],description:"Either a single string or a list of strings."},list_of_strings:{type:"array",description:"A list of unique string values.",items:{type:"string",description:"A string value in the list."},uniqueItems:!0},list_or_dict:{oneOf:[{type:"object",description:"A dictionary mapping keys to values.",patternProperties:{".+":{type:["string","number","boolean","null"],description:"Value for the key, which can be a string, number, boolean, or null."}},additionalProperties:!1},{type:"array",description:"A list of unique string values.",items:{type:"string",description:"A string value in the list."},uniqueItems:!0}],description:"Either a dictionary mapping keys to values, or a list of strings."},extra_hosts:{oneOf:[{type:"object",description:"list mapping hostnames to IP addresses.",patternProperties:{".+":{oneOf:[{type:"string",description:"IP address for the hostname."},{type:"array",description:"List of IP addresses for the hostname.",items:{type:"string",description:"IP address for the hostname."},uniqueItems:!1}]}},additionalProperties:!1},{type:"array",description:"List of host:IP mappings in the format 'hostname:IP'.",items:{type:"string",description:"Host:IP mapping in the format 'hostname:IP'."},uniqueItems:!0}],description:"Additional hostnames to be defined in the container's /etc/hosts file."},blkio_limit:{type:"object",description:"Block IO limit for a specific device.",properties:{path:{type:"string",description:"Path to the device (e.g., '/dev/sda')."},rate:{type:["integer","string"],description:"Rate limit in bytes per second or IO operations per second."}},additionalProperties:!1},blkio_weight:{type:"object",description:"Block IO weight for a specific device.",properties:{path:{type:"string",description:"Path to the device (e.g., '/dev/sda')."},weight:{type:["integer","string"],description:"Relative weight for the device, between 10 and 1000."}},additionalProperties:!1},service_config_or_secret:{type:"array",description:"Configuration for service configs or secrets, defining how they are mounted in the container.",items:{oneOf:[{type:"string",description:"Name of the config or secret to grant access to."},{type:"object",description:"Detailed configuration for a config or secret.",properties:{source:{type:"string",description:"Name of the config or secret as defined in the top-level configs or secrets section."},target:{type:"string",description:"Path in the container where the config or secret will be mounted. Defaults to /<source> for configs and /run/secrets/<source> for secrets."},uid:{type:"string",description:"UID of the file in the container. Default is 0 (root)."},gid:{type:"string",description:"GID of the file in the container. Default is 0 (root)."},mode:{type:["number","string"],description:"File permission mode inside the container, in octal. Default is 0444 for configs and 0400 for secrets."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]}},ulimits:{type:"object",description:"Container ulimit options, controlling resource limits for processes inside the container.",patternProperties:{"^[a-z]+$":{oneOf:[{type:["integer","string"],description:"Single value for both soft and hard limits."},{type:"object",description:"Separate soft and hard limits.",properties:{hard:{type:["integer","string"],description:"Hard limit for the ulimit type. This is the maximum allowed value."},soft:{type:["integer","string"],description:"Soft limit for the ulimit type. This is the value that's actually enforced."}},required:["soft","hard"],additionalProperties:!1,patternProperties:{"^x-":{}}}]}}}}}});import{readdir as uv}from"fs/promises";import{join as lv}from"path";var{file:pv,YAML:dv}=globalThis.Bun;function mv(){if(!Io)Io=Promise.resolve().then(() => (gm(),{})).then(({})=>Nf(hm)).catch((e)=>{throw Io=void 0,e});return Io}function ym(e){return pv(e).text().then(dv.parse).then(async(t)=>(await mv()).parse(t))}async function bm(e){return(await uv(e,{withFileTypes:!0})).filter((r)=>r.isFile()&&fv.has(r.name)).map((r)=>lv(e,r.name)).sort()[0]}var fv,Io;var _m=_(()=>{Ms();fv=new Set(["compose.yml","compose.yaml","docker-compose.yml","docker-compose.yaml"])});import{AsyncLocalStorage as hv}from"async_hooks";function gv(e,t){if(e.projectConfigured)return e.project;return t.name?.trim()||e.project}async function vm(e,t){let r=process.cwd(),o=await fm(r,t),n=Bo("composeFile",()=>o.composeFile?Promise.resolve(o.composeFile):bm(r)),i=Bo("parsedCompose",async()=>{let c=await n();if(!c)throw Error("Compose file cannot be found");return ym(c)});if(!o.projectConfigured){if(await n())o.project=gv(o,await i())}let s=Bo("hookContext",async()=>{let c=await n();if(!c)throw Error("Compose file cannot be found");return mm(o,r,c)}),a=Bo("compose",async()=>{let c=await s(),u=await i();return await o.compose?.(u,c),u});return await wm.run({project:o.project,cwd:r,config:o,path:n,hookContext:s,compose:a},e)}function D(){let e=wm.getStore();if(!e)throw Error("Not in context!");return e}function Bo(e,t){let r;return()=>(r??=t().catch((o)=>{throw r=void 0,o}),r)}var wm;var oe=_(()=>{Oo();_m();wm=new hv});import{createHash as yv,randomUUID as bv}from"crypto";import{chmod as xm,mkdir as _v,readFile as wv,realpath as vv,rename as xv,writeFile as Ev}from"fs/promises";import{join as Em}from"path";function $m(){return Em(process.env.XDG_CONFIG_HOME??Em(process.env.HOME??"/tmp",".config"),"kuber","trust.json")}async function bt(e,t=process.cwd()){let r=await vv(t);return{project:e,fingerprint:yv("sha256").update(r).digest("hex")}}function Sv(e){return!!e&&typeof e==="object"&&typeof e.project==="string"&&typeof e.fingerprint==="string"&&/^[a-f0-9]{64}$/.test(e.fingerprint)}async function zo(){try{let e=JSON.parse(await wv($m(),"utf8"));if(!e||typeof e!=="object"||e.version!==Sm||!Array.isArray(e.records))return[];return e.records.filter(Sv)}catch{return[]}}async function $v(e){let t=$m(),r=t.slice(0,t.lastIndexOf("/"));await _v(r,{recursive:!0,mode:448}),await xm(r,448);let o=`${t}.${bv()}.tmp`;await Ev(o,JSON.stringify({version:Sm,records:e},null,2)+`
|
|
80
|
+
`,{flag:"wx",mode:384}),await xv(o,t),await xm(t,384)}async function ea(e){await $v(e(await zo()))}function Am(e){return{"x-kuber-trust-project":e.project,"x-kuber-trust-fingerprint":e.fingerprint}}async function km(e){let t=(await zo()).find((r)=>r.project===e.project&&r.fingerprint===e.fingerprint);if(t)return t;throw Error("TRUST_REQUIRED: this directory is not trusted for this namespace. Run kuber trust before kuber up.")}var Sm=1;var Do=()=>{};var _t,a0,c0,u0,l0,p0,d0,f0,m0,h0,nr,g0,y0,b0,_0,w0;var Pm=_(()=>{_t=globalThis.window?.document!==void 0,a0=globalThis.process?.versions?.node!==void 0,c0=globalThis.process?.versions?.bun!==void 0,u0=globalThis.Deno?.version?.deno!==void 0,l0=globalThis.process?.versions?.electron!==void 0,p0=globalThis.navigator?.userAgent?.includes("jsdom")===!0,d0=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,f0=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,m0=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,h0=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,nr=globalThis.navigator?.userAgentData?.platform,g0=nr==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",y0=nr==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",b0=nr==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",_0=nr==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),w0=nr==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android"});import wt from"process";import Av from"os";var M="\x1B[",Cm,kv,$0,A0,No=(e=1)=>M+e+"A",ra=(e=1)=>M+e+"B",oa,k0,P0,C0,R0,T0,O0,I0,ir=(e)=>{let t="";for(let r=0;r<e;r++)t+=Rm+(r<e-1?No():"");if(e)t+=oa;return t},Pv,B0,Rm,z0,D0,ta,N0,L0,V0,Cv=()=>{if(_t||!kv)return!1;let e=Av.release().split("."),t=Number(e[0]),r=Number(e[2]??0);if(t<10)return!0;if(t===10&&r<10586)return!0;return!1},U0,M0,F0,j0,Z0;var na=_(()=>{Pm();Cm=!_t&&wt.env.TERM_PROGRAM==="Apple_Terminal",kv=!_t&&wt.platform==="win32",$0=!_t&&(wt.env.TERM?.startsWith("screen")||wt.env.TERM?.startsWith("tmux")||wt.env.TMUX!==void 0),A0=_t?()=>{throw Error("`process.cwd()` only works in Node.js, not the browser.")}:wt.cwd,oa=M+"G",k0=Cm?"\x1B7":M+"s",P0=Cm?"\x1B8":M+"u",C0=M+"6n",R0=M+"E",T0=M+"F",O0=M+"?25l",I0=M+"?25h",Pv=M+"K",B0=M+"1K",Rm=M+"2K",z0=M+"J",D0=M+"1J",ta=M+"2J",N0=M+"S",L0=M+"T",V0=`${ta}${M}H`,U0=Cv()?`${ta}${M}0f`:`${ta}${M}3J${M}H`,M0=M+"?1049h",F0=M+"?1049l",j0=M+"?2026h",Z0=M+"?2026l"});var Om=_(()=>{na();na()});function ia(e,t,{ignoreNonConfigurable:r=!1}={}){let{name:o}=e;for(let n of Reflect.ownKeys(t))Rv(e,t,n,r);return Ov(e,t),Dv(e,t,o),e}var Rv=(e,t,r,o)=>{if(r==="length"||r==="prototype")return;if(r==="arguments"||r==="caller")return;let n=Object.getOwnPropertyDescriptor(e,r),i=Object.getOwnPropertyDescriptor(t,r);if(!Tv(n,i)&&o)return;Object.defineProperty(e,r,i)},Tv=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},Ov=(e,t)=>{let r=Object.getPrototypeOf(t);if(r===Object.getPrototypeOf(e))return;Object.setPrototypeOf(e,r)},Iv=(e,t)=>`/* Wrapped ${e}*/
|
|
81
|
+
${t}`,Bv,zv,Dv=(e,t,r)=>{let o=r===""?"":`with ${r.trim()}() `,n=Iv.bind(null,o,t.toString());Object.defineProperty(n,"name",zv);let{writable:i,enumerable:s,configurable:a}=Bv;Object.defineProperty(e,"toString",{value:n,writable:i,enumerable:s,configurable:a})};var Im=_(()=>{Bv=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),zv=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name")});var Lo,Bm=(e,t={})=>{if(typeof e!=="function")throw TypeError("Expected a function");let r,o=0,n=e.displayName||e.name||"<anonymous>",i=function(...s){if(Lo.set(i,++o),o===1)r=e.apply(this,s),e=void 0;else if(t.throw===!0)throw Error(`Function \`${n}\` can only be called once`);return r};return ia(i,e),Lo.set(i,o),i},zm;var Dm=_(()=>{Im();Lo=new WeakMap;Bm.callCount=(e)=>{if(!Lo.has(e))throw Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Lo.get(e)};zm=Bm});var nt;var Nm=_(()=>{nt=[];nt.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")nt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")nt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class Lm{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(aa[sa])return aa[sa];Nv(aa,sa,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let r=this.listeners[e],o=r.indexOf(t);if(o===-1)return;if(o===0&&r.length===1)r.length=0;else r.splice(o,1)}emit(e,t,r){if(this.emitted[e])return!1;this.emitted[e]=!0;let o=!1;for(let n of this.listeners[e])o=n(t,r)===!0||o;if(e==="exit")o=this.emit("afterExit",t,r)||o;return o}}class ua{}var Vo=(e)=>!!e&&typeof e==="object"&&typeof e.removeListener==="function"&&typeof e.emit==="function"&&typeof e.reallyExit==="function"&&typeof e.listeners==="function"&&typeof e.kill==="function"&&typeof e.pid==="number"&&typeof e.on==="function",sa,aa,Nv,Lv=(e)=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),Vm,Um,ca,Mm,Y0,X0;var Fm=_(()=>{Nm();sa=Symbol.for("signal-exit emitter"),aa=globalThis,Nv=Object.defineProperty.bind(Object);Vm=class Vm extends ua{onExit(){return()=>{}}load(){}unload(){}};Um=class Um extends ua{#t=ca.platform==="win32"?"SIGINT":"SIGHUP";#r=new Lm;#e;#o;#s;#i={};#n=!1;constructor(e){super();this.#e=e,this.#i={};for(let t of nt)this.#i[t]=()=>{let r=this.#e.listeners(t),{count:o}=this.#r,n=e;if(typeof n.__signal_exit_emitter__==="object"&&typeof n.__signal_exit_emitter__.count==="number")o+=n.__signal_exit_emitter__.count;if(r.length===o){this.unload();let i=this.#r.emit("exit",null,t),s=t==="SIGHUP"?this.#t:t;if(!i)e.kill(e.pid,s)}};this.#s=e.reallyExit,this.#o=e.emit}onExit(e,t){if(!Vo(this.#e))return()=>{};if(this.#n===!1)this.load();let r=t?.alwaysLast?"afterExit":"exit";return this.#r.on(r,e),()=>{if(this.#r.removeListener(r,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0)this.unload()}}load(){if(this.#n)return;this.#n=!0,this.#r.count+=1;for(let e of nt)try{let t=this.#i[e];if(t)this.#e.on(e,t)}catch(t){}this.#e.emit=(e,...t)=>this.#c(e,...t),this.#e.reallyExit=(e)=>this.#a(e)}unload(){if(!this.#n)return;this.#n=!1,nt.forEach((e)=>{let t=this.#i[e];if(!t)throw Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,t)}catch(r){}}),this.#e.emit=this.#o,this.#e.reallyExit=this.#s,this.#r.count-=1}#a(e){if(!Vo(this.#e))return 0;return this.#e.exitCode=e||0,this.#r.emit("exit",this.#e.exitCode,null),this.#s.call(this.#e,this.#e.exitCode)}#c(e,...t){let r=this.#o;if(e==="exit"&&Vo(this.#e)){if(typeof t[0]==="number")this.#e.exitCode=t[0];let o=r.call(this.#e,e,...t);return this.#r.emit("exit",this.#e.exitCode,null),o}else return r.call(this.#e,e,...t)}};ca=globalThis.process,{onExit:Mm,load:Y0,unload:X0}=Lv(Vo(ca)?new Um(ca):new Vm)});import Uo from"process";var jm,Vv,Zm;var qm=_(()=>{Dm();Fm();jm=Uo.stderr.isTTY?Uo.stderr:Uo.stdout.isTTY?Uo.stdout:void 0,Vv=jm?zm(()=>{Mm(()=>{jm.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},Zm=Vv});import Qm from"process";var Mo=!1,vt,la;var Wm=_(()=>{qm();vt={};vt.show=(e=Qm.stderr)=>{if(!e.isTTY)return;Mo=!1,e.write("\x1B[?25h")};vt.hide=(e=Qm.stderr)=>{if(!e.isTTY)return;Zm(),Mo=!0,e.write("\x1B[?25l")};vt.toggle=(e,t)=>{if(e!==void 0)Mo=e;if(Mo)vt.show(t);else vt.hide(t)};la=vt});function pa({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}function qe(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes("\x9B"))return e;return e.replace(Uv,"")}var Uv;var Fo=_(()=>{Uv=pa()});var Gm=161,Km=1114109,Hm,Jm=12288,Ym=65510,Xm,eh=4352,th=262141,da;var rh=_(()=>{Hm=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Xm=[12288,12288,65281,65376,65504,65510],da=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141]});var jo=(e,t)=>{let r=0,o=Math.floor(e.length/2)-1;while(r<=o){let n=Math.floor((r+o)/2),i=n*2;if(t<e[i])o=n-1;else if(t>e[i+1])r=n+1;else return!0}return!1};function jv(e){let t=e[0],r=e[1];for(let o=0;o<e.length;o+=2){let n=e[o],i=e[o+1];if(oh>=n&&oh<=i)return[n,i];if(i-n>r-t)t=n,r=i}return[t,r]}var oh=19968,Mv,Fv,nh=(e)=>{if(e<Gm||e>Km)return!1;return jo(Hm,e)},sr=(e)=>{if(e<Jm||e>Ym)return!1;return jo(Xm,e)},ar=(e)=>{if(e>=Mv&&e<=Fv)return!0;if(e<eh||e>th)return!1;return jo(da,e)};var fa=_(()=>{rh();[Mv,Fv]=jv(da)});function Zv(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function cr(e,{ambiguousAsWide:t=!1}={}){if(Zv(e),sr(e)||ar(e)||t&&nh(e))return 2;return 1}var ma=_(()=>{fa();fa()});function Jv(e){if(e.length>50)return!1;if(Kv.test(e))return!0;if(e.includes("\u200D")){let t=e.match(Hv);return t!==null&&t.length>=2}return!1}function Yv(e){return e.replace(Qv,"")}function Xv(e){return ih.test(e)}function sh(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function ah(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function ch(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function ex(e){return sh(e)||ah(e)||ch(e)}function tx(e,t){let r=[];for(let n of e){if(ih.test(n))continue;r.push(n.codePointAt(0))}if(r.length===0)return;let o=0;for(let n=0;n<r.length;n++){let i=r[n];if(!ex(i)){if(o===0)return;for(let s=n;s<r.length;s++)o+=cr(r[s],t);return o}if(sh(i)&&ah(r[n+1])){o+=2,n+=ch(r[n+2])?2:1;continue}o+=cr(i,t)}return o}function rx(e,t){let r=0,o=!0;for(let n of e){if(o){o=!1;continue}if(Wv.test(n)||n>="\uFF00"&&n<="\uFFEF")r+=cr(n.codePointAt(0),t)}return r}function K(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:r=!0,countAnsiEscapeCodes:o=!1}=t,n=e;if(!o&&(n.includes("\x1B")||n.includes("\x9B")))n=qe(n);if(n.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(n))return n.length;let i=0,s={ambiguousAsWide:!r};for(let{segment:a}of qv.segment(n)){if(Xv(a))continue;if(Gv.test(a)||Jv(a)){i+=2;continue}let c=Yv(a),u=tx(c,s);if(u!==void 0){i+=u;continue}let l=c.codePointAt(0);i+=cr(l,s),i+=rx(c,s)}return i}var qv,ih,Qv,Wv,Gv,Kv,Hv;var Zo=_(()=>{Fo();ma();qv=new Intl.Segmenter,ih=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,Qv=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,Wv=/\p{Spacing_Mark}/v,Gv=/^\p{RGI_Emoji}$/v,Kv=/^[\d#*]\u20E3$/,Hv=/\p{Extended_Pictographic}/gu});function ix(){let e=new Map;for(let[t,r]of Object.entries(Z)){for(let[o,n]of Object.entries(r))Z[o]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},r[o]=Z[o],e.set(n[0],n[1]);Object.defineProperty(Z,t,{value:r,enumerable:!1})}return Object.defineProperty(Z,"codes",{value:e,enumerable:!1}),Z.color.close="\x1B[39m",Z.bgColor.close="\x1B[49m",Z.color.ansi=uh(),Z.color.ansi256=lh(),Z.color.ansi16m=ph(),Z.bgColor.ansi=uh(10),Z.bgColor.ansi256=lh(10),Z.bgColor.ansi16m=ph(10),Object.defineProperties(Z,{rgbToAnsi256:{value(t,r,o){if(t===r&&r===o){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[o]=r;if(o.length===3)o=[...o].map((i)=>i+i).join("");let n=Number.parseInt(o,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:(t)=>Z.rgbToAnsi256(...Z.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,o,n;if(t>=232)r=((t-232)*10+8)/255,o=r,n=r;else{t-=16;let a=t%36;r=Math.floor(t/36)/5,o=Math.floor(a/6)/5,n=a%6/5}let i=Math.max(r,o,n)*2;if(i===0)return 30;let s=30+(Math.round(n)<<2|Math.round(o)<<1|Math.round(r));if(i===2)s+=60;return s},enumerable:!1},rgbToAnsi:{value:(t,r,o)=>Z.ansi256ToAnsi(Z.rgbToAnsi256(t,r,o)),enumerable:!1},hexToAnsi:{value:(t)=>Z.ansi256ToAnsi(Z.hexToAnsi256(t)),enumerable:!1}}),Z}var uh=(e=0)=>(t)=>`\x1B[${t+e}m`,lh=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,ph=(e=0)=>(t,r,o)=>`\x1B[${38+e};2;${t};${r};${o}m`,Z,CR,ox,nx,RR,sx,me;var ha=_(()=>{Z={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},CR=Object.keys(Z.modifier),ox=Object.keys(Z.color),nx=Object.keys(Z.bgColor),RR=[...ox,...nx];sx=ix(),me=sx});function ur(e,t,r){return String(e).normalize().replaceAll(`\r
|
|
82
82
|
`,`
|
|
83
83
|
`).split(`
|
|
84
|
-
`).map((o)=>
|
|
85
|
-
`)}var
|
|
86
|
-
`),u=
|
|
87
|
-
`){if(n)o+=
|
|
88
|
-
`){let d=[...i];if(fx(c.slice(l+1),d),o+=hx(d),n)o+=dh(n)}l+=p.length}return o};var ya=_(()=>{Mo();Uo();ma();ix=new Set([ot,ga]),Zo=`${sx}8;;`,Sh=new RegExp(`^\\u001B(?:\\${yh}(?<sgr>[0-9;]*)${qo}|${Zo}(?<uri>[^\\u0007\\u001B]*)(?:\\u0007|\\u001B\\\\))`),$h=new RegExp(`^\\u009B(?<sgr>[0-9;]*)${qo}`),Ah=new Set(pe.codes.values());Ah.delete(Qo);ux=new Intl.Segmenter});function Wo(e){if(!Number.isInteger(e))return!1;return nr(e)||ir(e)}var Th=_(()=>{fa()});function Wx(e){return e>=kx&&e<=Px||e===Cx||e===Rx}function Gx(e){return e>=Tx&&e<=Ox}function Kx(e){return e>=Ix&&e<=Bx}function Hx(e){return e>=zx&&e<=Dx}function Jx(e){return e>=Nx&&e<=Lx}function be(e,t){return{token:{type:"control",code:e},endIndex:t}}function Yx(e){if(Qx.test(e))return!0;for(let t of e){let r=t.codePointAt(0);if(r===Zx||r===qx)return!0}return!1}function qh(e){let t=0;for(let r of e){let o=r.codePointAt(0);if(Wo(o))return 2;if(Jx(o))t++}if(t>=1)return 2;if(Yx(e))return 2;return 1}function Xx(e){if(e.startsWith("\x9B"))return"\x9B";return`${wt}${Sa}`}function cr(e,t){return`${e}${t.join(";")}${Mh}`}function eE(e){let t=[],r=Xx(e),o;if(e.startsWith(`${wt}${Sa}`))o=e.slice(2,-1);else if(e.startsWith("\x9B"))o=e.slice(1,-1);else return t;let n=o.length===0?[String(Oh)]:o.split(";"),i=0;while(i<n.length){let s=Number.parseInt(n[i],10);if(Number.isNaN(s)){i++;continue}if(s===Oh){t.push({type:"reset"}),i++;continue}if(s===Go||s===Vx){let u=Number.parseInt(n[i+1],10);if(u===Ux&&i+Mx<n.length){let f=cr(r,n.slice(i,i+Ih));t.push({type:"start",code:f,endCode:pe.color.ansi(s===Go?ba:_a)}),i+=Ih;continue}if(u===Fx&&i+jx<n.length){let f=cr(r,n.slice(i,i+Bh));t.push({type:"start",code:f,endCode:pe.color.ansi(s===Go?ba:_a)}),i+=Bh;continue}let l=cr(r,[n[i]]);t.push({type:"start",code:l,endCode:pe.color.ansi(s===Go?ba:_a)}),i++;continue}if(Zh.has(s)){t.push({type:"end",endCode:pe.color.ansi(s)}),i++;continue}let a=pe.codes.get(s);if(a!==void 0){let u=cr(r,[n[i]]);t.push({type:"start",code:u,endCode:pe.color.ansi(a)}),i++;continue}let c=cr(r,[n[i]]);t.push({type:"start",code:c,endCode:pe.reset.open}),i++}if(t.length===0)t.push({type:"reset"});return t}function tE(e,t){let r=e.codePointAt(t),o;if(r===ur){if(e[t+1]!==Sa)return;o=t+2}else if(r===Nh)o=t+1;else return;let n=!0;for(let i=o;i<e.length;i++){let s=e.codePointAt(i);if(Hx(s)){let c=e.slice(t,i+1);if(e[i]!==Mh||!n)return be(c,i+1);return{token:{type:"sgr",code:c,fragments:eE(c)},endIndex:i+1}}if(Gx(s)){if(!Wx(s))n=!1;continue}if(Kx(s)){n=!1;continue}let a=i;return be(e.slice(t,a),a)}return be(e.slice(t),e.length)}function rE(e,t){let r,o,n=e.codePointAt(t);if(n===ur&&e.startsWith(xa,t))r=xa,o=$x;else if(n===Jo&&e.startsWith(Ea,t))r=Ea,o=Ax;else return;let i=e.indexOf(";",t+r.length);if(i===-1)return be(e.slice(t),e.length);for(let s=i+1;s<e.length;s++){let a=e[s];if(a===va){let c=e.slice(t,s+1),u=s===i+1?"close":"open";return{token:{type:"hyperlink",code:c,action:u,closePrefix:o,terminator:va},endIndex:s+1}}if(a===wt&&e[s+1]===Ko){let c=e.slice(t,s+2),u=s===i+1?"close":"open";return{token:{type:"hyperlink",code:c,action:u,closePrefix:o,terminator:jh},endIndex:s+2}}if(a===Ho){let c=e.slice(t,s+1),u=s===i+1?"close":"open";return{token:{type:"hyperlink",code:c,action:u,closePrefix:o,terminator:Ho},endIndex:s+1}}}return be(e.slice(t),e.length)}function oE(e,t){let r=e.codePointAt(t),o,n=!1;switch(r){case ur:{switch(e[t+1]){case Fh:{o=t+2,n=!0;break}case wx:case vx:case xx:case Ex:{o=t+2;break}case Ko:return be(jh,t+2);default:return}break}case Jo:{o=t+1,n=!0;break}case zh:case Dh:case Vh:case Uh:{o=t+1;break}case Lh:return be(Ho,t+1);default:return}for(let i=o;i<e.length;i++){if(n&&e[i]===va)return be(e.slice(t,i+1),i+1);if(e[i]===wt&&e[i+1]===Ko)return be(e.slice(t,i+2),i+2);if(e[i]===Ho)return be(e.slice(t,i+1),i+1)}return be(e.slice(t),e.length)}function pr(e,t){let r=e.codePointAt(t);if(r===ur||r===Jo){let n=rE(e,t);if(n)return n}let o=oE(e,t);if(o)return o;return tE(e,t)}function Qh(e,t,r){while(t<e.length){let o=e.codePointAt(t);if(!lr.has(o))break;let n=pr(e,t);if(!n)break;r.push(n.token),t=n.endIndex}return t}function Wh(e,t,r){let o=r.containing(t);if(!o||o.index!==t)return;return{token:{type:"character",value:o.segment,visibleWidth:qh(o.segment),isGraphemeContinuation:!1},endIndex:t+o.segment.length}}function nE(e){let t=[],r=0;while(r<e.length){let o=e.codePointAt(r);if(lr.has(o)){let i=pr(e,r);if(i){r=i.endIndex;continue}}let n=String.fromCodePoint(o);t.push({value:n,visibleWidth:1,isGraphemeContinuation:!1}),r+=n.length}return t}function iE(e){if(e.length===0)return;let t=e.map(({value:i})=>i).join(""),r=[],o=0;for(let i of e)r.push(o),o+=i.value.length;let n=0;for(let i of $a.segment(t)){while(n<e.length&&r[n]<i.index)n++;let s=n,a=!0;while(s<e.length&&r[s]<i.index+i.segment.length)e[s].visibleWidth=a?qh(i.segment):0,e[s].isGraphemeContinuation=!a,a=!1,s++;n=s}}function wa(e,{endCharacter:t=Number.POSITIVE_INFINITY}={}){let r=[],o=nE(e);iE(o);let n=0,i=0,s=0;while(n<e.length){let a=e.codePointAt(n);if(lr.has(a)){let p=pr(e,n);if(p){r.push(p.token),n=p.endIndex;continue}}let c=String.fromCodePoint(a),u=o[i],l=Wo(a)?2:c.length;if(u)l=u.visibleWidth;let f={type:"character",value:c,visibleWidth:l,isGraphemeContinuation:u?u.isGraphemeContinuation:!1};if(r.push(f),n+=c.length,i++,s+=f.visibleWidth,s>=t){let p=o[i];if(!p||!p.isGraphemeContinuation){n=Qh(e,n,r);break}}}return r}function Gh(e,t){let r=`${e}${t}`,o=e.length;for(let n of $a.segment(r)){if(n.index===o)return!1;if(n.index>o)return!0}return!0}function sE(e,t,r,o){if(!r)return!1;let n=t,i=!1;while(n<e.length){let s=e.codePointAt(n);if(lr.has(s)){let c=pr(e,n);if(c){i=!0,n=c.endIndex;continue}}if(!i)return!1;let a=Wh(e,n,o);if(!a)return!0;return Gh(r,a.token.value)}return!1}function Aa(e,{endCharacter:t=Number.POSITIVE_INFINITY}={}){let r=[],o=$a.segment(e),n=0,i=0,s,a=!1;while(n<e.length){let c=e.codePointAt(n);if(lr.has(c)){let l=pr(e,n);if(l){r.push(l.token),n=l.endIndex,a=!0;continue}}let u=Wh(e,n,o);if(!u)return wa(e,{endCharacter:t});if(a&&s&&Gh(s,u.token.value))return wa(e,{endCharacter:t});if(r.push(u.token),n=u.endIndex,i+=u.token.visibleWidth,a=!1,s=u.token.value,i>=t){if(sE(e,n,s,o))return wa(e,{endCharacter:t});n=Qh(e,n,r);break}}return r}var ur=27,zh=144,Dh=152,Nh=155,Lh=156,Jo=157,Vh=158,Uh=159,lr,wt="\x1B",va="\x07",Sa="[",Fh="]",wx="P",vx="X",xx="^",Ex="_",Mh="m",Ko="\\",jh,Sx="\x9D",Ho="\x9C",xa,Ea,$x,Ax,kx,Px,Cx,Rx,Tx,Ox,Ix,Bx,zx,Dx,Nx=127462,Lx=127487,Oh=0,Go=38,ba=39,Vx=48,_a=49,Ux=5,Fx=2,Ih=3,Bh=5,Mx=2,jx=4,Zx=65039,qx=8419,Qx,$a,Zh;var Kh=_(()=>{ma();Th();lr=new Set([ur,zh,Dh,Nh,Lh,Jo,Vh,Uh]),jh=`${wt}${Ko}`,xa=`${wt}${Fh}8;`,Ea=`${Sx}8;`,$x=`${xa};`,Ax=`${Ea};`,kx="0".codePointAt(0),Px="9".codePointAt(0),Cx=";".codePointAt(0),Rx=":".codePointAt(0),Tx="0".codePointAt(0),Ox="?".codePointAt(0),Ix=" ".codePointAt(0),Bx="/".codePointAt(0),zx="@".codePointAt(0),Dx="~".codePointAt(0),Qx=/\p{Emoji_Presentation}/v,$a=new Intl.Segmenter(void 0,{granularity:"grapheme"}),Zh=new Set;for(let[,e]of pe.codes)Zh.add(e)});function aE(e,t){for(let r of t)switch(r.type){case"reset":{e.clear();break}case"end":{e.delete(r.endCode);break}case"start":{e.delete(r.endCode),e.set(r.endCode,r.code);break}default:break}return e}function cE(e){return[...e.keys()].toReversed().join("")}function uE(e){return`${e.closePrefix}${e.terminator}`}function lE(e,t){let r=!1,o=!1;for(let n of e.fragments){if(n.type==="start"){r=!0;continue}if(n.type==="reset"&&t.size>0){o=!0;continue}if(n.type==="end"&&t.has(n.endCode))o=!0}return o&&!r}function pE(e){return e.fragments.some((t)=>t.type==="start")}function Hh(e){if(e.activeHyperlink&&!e.activeHyperlinkHasVisibleText&&e.activeHyperlinkOutputIndex!==void 0){let t=e.activeHyperlink.code.length;if(e.returnValue=e.returnValue.slice(0,e.activeHyperlinkOutputIndex)+e.returnValue.slice(e.activeHyperlinkOutputIndex+t),e.pendingSgrOutputIndex!==void 0&&e.pendingSgrOutputIndex>e.activeHyperlinkOutputIndex)e.pendingSgrOutputIndex-=t}e.activeHyperlink=void 0,e.activeHyperlinkHasVisibleText=!1,e.activeHyperlinkOutputIndex=void 0}function dE(e){if(e.isPastEnd&&!lE(e.token,e.activeStyles))return e;if(e.include&&pE(e.token)&&e.pendingSgrOutputIndex===void 0)e.pendingSgrOutputIndex=e.returnValue.length,e.pendingSgrActiveStyles=new Map(e.activeStyles);if(e.activeStyles=aE(e.activeStyles,e.token.fragments),e.include)e.returnValue+=e.token.code;return e}function fE(e){if(e.isPastEnd&&(e.token.action!=="close"||!e.activeHyperlink))return e;if(e.token.action==="open"){if(e.activeHyperlink=e.token,e.activeHyperlinkHasVisibleText=!1,e.activeHyperlinkOutputIndex=void 0,e.include)e.activeHyperlinkOutputIndex=e.returnValue.length}else if(e.token.action==="close"){if(e.include&&e.activeHyperlink&&!e.activeHyperlinkHasVisibleText)return Hh(e),e;e.activeHyperlink=void 0,e.activeHyperlinkHasVisibleText=!1,e.activeHyperlinkOutputIndex=void 0}if(e.include)e.returnValue+=e.token.code;return e}function mE(e){if(!e.isPastEnd&&e.include)e.returnValue+=e.token.code;return e}function hE(e){if(!e.include&&e.position>=e.start&&!e.token.isGraphemeContinuation){if(e.include=!0,e.returnValue=[...e.activeStyles.values()].join(""),e.activeHyperlink)e.activeHyperlinkOutputIndex=e.returnValue.length,e.returnValue+=e.activeHyperlink.code}if(e.include){if(e.returnValue+=e.token.value,e.pendingSgrOutputIndex=void 0,e.pendingSgrActiveStyles=void 0,e.activeHyperlink)e.activeHyperlinkHasVisibleText=!0}return e.position+=e.token.visibleWidth,e}function yE(e){let t=gE[e.token.type];if(!t)return e;return t(e)}function bE(e){let t=Array.from({length:e.length},()=>!1),r=!1;for(let o=e.length-1;o>=0;o--){let n=e[o];if(t[o]=r,n.type==="character")r=Boolean(n.isGraphemeContinuation)}return t}function _E(e,t,r){if(r===void 0)return!1;if(t>=r)return!0;return e.type==="character"&&!e.isGraphemeContinuation&&t+e.visibleWidth>r}function oe(e,t,r){let o=Aa(e,{endCharacter:r}),n=bE(o),i=new Map,s,a=!1,c,u,l,f=0,p="",d=!1;for(let[m,h]of o.entries()){let y=_E(h,f,r);if(y&&h.type!=="character"&&n[m])y=!1;if(y&&h.type==="character"&&!h.isGraphemeContinuation){if(s&&!a){let b={activeHyperlink:s,activeHyperlinkHasVisibleText:a,activeHyperlinkOutputIndex:c,pendingSgrOutputIndex:u,returnValue:p};Hh(b),{activeHyperlink:s,activeHyperlinkHasVisibleText:a,activeHyperlinkOutputIndex:c,pendingSgrOutputIndex:u,returnValue:p}=b}if(u!==void 0)p=p.slice(0,u),i=l,u=void 0,l=void 0;break}({activeStyles:i,activeHyperlink:s,activeHyperlinkHasVisibleText:a,activeHyperlinkOutputIndex:c,pendingSgrOutputIndex:u,pendingSgrActiveStyles:l,position:f,returnValue:p,include:d}=yE({token:h,isPastEnd:y,start:t,activeStyles:i,activeHyperlink:s,activeHyperlinkHasVisibleText:a,activeHyperlinkOutputIndex:c,pendingSgrOutputIndex:u,pendingSgrActiveStyles:l,position:f,returnValue:p,include:d}))}if(!d)return"";if(s)p+=uE(s);return p+=cE(i),p}var gE;var ka=_(()=>{Kh();gE={sgr:dE,hyperlink:fE,control:mE,character:hE}});import Jh from"process";function Xo(e,{showCursor:t=!1,defaultWidth:r,defaultHeight:o}={}){let n=0,i=Yo(e,r),s="",a=e.isTTY===!0,c=(p)=>{if(p==="")return;if(a){e.write(wE+p+vE);return}e.write(p)},u=(p,d,m=!0)=>{let h=String(p),y=h.endsWith(`
|
|
84
|
+
`).map((o)=>vx(wx(o),t,r)).join(`
|
|
85
|
+
`)}var it="\x1B",ya="\x9B",ax,yh="\x07",bh="[",cx="]",Wo="m",Go=0,_h=39,wh=49,vh=59,xh=38,Eh=48,Sh=58,ux=5,lx=2,Qo,$h,Ah,kh,px,Ph=(e)=>Array.from(px.segment(e),({segment:t})=>t),dh=8,Ch=(e)=>`${it}${bh}${e}${Wo}`,fh=(e)=>`${it}${Qo}${e}${yh}`,Rh=(e)=>{let t=e.split(";").map((o)=>o===""?Go:Number.parseInt(o,10)),r=[];for(let o=0;o<t.length;o++){let n=t[o];if(!Number.isFinite(n))continue;if(n===xh||n===Eh||n===Sh){if(o+1>=t.length)break;let i=t[o+1];if(i===ux&&Number.isFinite(t[o+2])){r.push([n,i,t[o+2]]),o+=2;continue}let s=t[o+2],a=t[o+3],c=t[o+4];if(i===lx&&Number.isFinite(s)&&Number.isFinite(a)&&Number.isFinite(c)){r.push([n,i,s,a,c]),o+=4;continue}break}r.push([n])}return r},qo=(e,t)=>{let r=e.findIndex((o)=>o.family===t);if(r!==-1)e.splice(r,1)},mh=(e,t)=>{qo(e,t.family),e.push(t)},dx=(e,t)=>{for(let r=e.length-1;r>=0;r--){let o=e[r];if(o.family.startsWith("modifier-")&&o.close===t)e.splice(r,1)}},fx=(e,t)=>{if(e>=30&&e<=37||e>=90&&e<=97||e===xh&&t.length>1)return{family:"foreground",open:t.join(";"),close:_h};if(e>=40&&e<=47||e>=100&&e<=107||e===Eh&&t.length>1)return{family:"background",open:t.join(";"),close:wh};if(e===Sh&&t.length>1)return{family:"underlineColor",open:t.join(";"),close:vh}},Th=(e,t)=>{if(e===Go)return t.length=0,!0;if(e===_h)return qo(t,"foreground"),!0;if(e===wh)return qo(t,"background"),!0;if(e===vh)return qo(t,"underlineColor"),!0;if(kh.has(e))return dx(t,e),!0;return!1},mx=(e,t)=>{let[r]=e;if(Th(r,t))return;let o=fx(r,e);if(o){mh(t,o);return}let n=me.codes.get(r);if(n!==void 0&&n!==Go)mh(t,{family:`modifier-${r}`,open:e.join(";"),close:n})},hh=(e,t)=>{for(let r of Rh(e))mx(r,t)},gh=(e,t)=>{for(let r of Rh(e)){let[o]=r;Th(o,t)}},hx=(e,t)=>{let r=e;while(r.length>0){if(r.startsWith(it)&&r[1]!=="\\"){let o=$h.exec(r);if(!o)break;if(o.groups.sgr!==void 0)gh(o.groups.sgr,t);r=r.slice(o[0].length);continue}if(r.startsWith(ya)){let o=Ah.exec(r);if(!o||o.groups.sgr===void 0)break;gh(o.groups.sgr,t),r=r.slice(o[0].length);continue}break}},gx=(e)=>[...e].reverse().map((t)=>Ch(t.close)).join(""),yx=(e)=>e.map((t)=>Ch(t.open)).join(""),bx=(e)=>e.split(" ").map((t)=>K(t)),ga=(e,t,r)=>{let o=Ph(t),n=!1,i=!1,s=K(qe(e.at(-1)));for(let[a,c]of o.entries()){let u=K(c);if(s+u<=r)e[e.length-1]+=c;else e.push(c),s=0;if(ax.has(c)&&!(i&&c===it&&o[a+1]==="\\"))n=!0,i=o.slice(a+1,a+1+Qo.length).join("")===Qo;if(n){if(i){if(c===yh||c==="\\"&&a>0&&o[a-1]===it)n=!1,i=!1}else if(c===Wo)n=!1;continue}if(s+=u,s===r&&a<o.length-1)e.push(""),s=0}if(!s&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},_x=(e)=>{let t=e.split(" "),r=t.length;while(r>0){if(K(t[r-1])>0)break;r--}if(r===t.length)return e;return t.slice(0,r).join(" ")+t.slice(r).join("")},wx=(e)=>{if(!e.includes("\t"))return e;let t=e.split("\t"),r=0,o="";for(let[n,i]of t.entries())if(o+=i,r+=K(i),n<t.length-1){let s=dh-r%dh;o+=" ".repeat(s),r+=s}return o},vx=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let o="",n,i=[],s=bx(e),a=[""];for(let[f,d]of e.split(" ").entries()){if(r.trim!==!1)a[a.length-1]=a.at(-1).trimStart();let p=K(a.at(-1));if(f!==0){if(p>=t&&(r.wordWrap===!1||r.trim===!1))a.push(""),p=0;if(p>0||r.trim===!1)a[a.length-1]+=" ",p++}if(r.hard&&r.wordWrap!==!1&&s[f]>t){let m=t-p,h=1+Math.floor((s[f]-m-1)/t);if(Math.floor((s[f]-1)/t)<h)a.push("");ga(a,d,t);continue}if(p+s[f]>t&&p>0&&s[f]>0){if(r.wordWrap===!1&&p<t){ga(a,d,t);continue}a.push("")}if(p+s[f]>t&&r.wordWrap===!1){ga(a,d,t);continue}a[a.length-1]+=d}if(r.trim!==!1)a=a.map((f)=>_x(f));let c=a.join(`
|
|
86
|
+
`),u=Ph(c),l=0;for(let[f,d]of u.entries()){if(o+=d,d===it&&u[f+1]!=="\\"){let{groups:p}=$h.exec(c.slice(l))||{groups:{}};if(p.sgr!==void 0)hh(p.sgr,i);else if(p.uri!==void 0)n=p.uri.length===0?void 0:p.uri}else if(d===ya){let{groups:p}=Ah.exec(c.slice(l))||{groups:{}};if(p.sgr!==void 0)hh(p.sgr,i)}if(u[f+1]===`
|
|
87
|
+
`){if(n)o+=fh("");o+=gx(i)}else if(d===`
|
|
88
|
+
`){let p=[...i];if(hx(c.slice(l+1),p),o+=yx(p),n)o+=fh(n)}l+=d.length}return o};var ba=_(()=>{Zo();Fo();ha();ax=new Set([it,ya]),Qo=`${cx}8;;`,$h=new RegExp(`^\\u001B(?:\\${bh}(?<sgr>[0-9;]*)${Wo}|${Qo}(?<uri>[^\\u0007\\u001B]*)(?:\\u0007|\\u001B\\\\))`),Ah=new RegExp(`^\\u009B(?<sgr>[0-9;]*)${Wo}`),kh=new Set(me.codes.values());kh.delete(Go);px=new Intl.Segmenter});function Ko(e){if(!Number.isInteger(e))return!1;return sr(e)||ar(e)}var Oh=_(()=>{ma()});function Kx(e){return e>=Cx&&e<=Rx||e===Tx||e===Ox}function Hx(e){return e>=Ix&&e<=Bx}function Jx(e){return e>=zx&&e<=Dx}function Yx(e){return e>=Nx&&e<=Lx}function Xx(e){return e>=Vx&&e<=Ux}function ve(e,t){return{token:{type:"control",code:e},endIndex:t}}function eE(e){if(Gx.test(e))return!0;for(let t of e){let r=t.codePointAt(0);if(r===Qx||r===Wx)return!0}return!1}function Qh(e){let t=0;for(let r of e){let o=r.codePointAt(0);if(Ko(o))return 2;if(Xx(o))t++}if(t>=1)return 2;if(eE(e))return 2;return 1}function tE(e){if(e.startsWith("\x9B"))return"\x9B";return`${xt}${$a}`}function lr(e,t){return`${e}${t.join(";")}${jh}`}function rE(e){let t=[],r=tE(e),o;if(e.startsWith(`${xt}${$a}`))o=e.slice(2,-1);else if(e.startsWith("\x9B"))o=e.slice(1,-1);else return t;let n=o.length===0?[String(Ih)]:o.split(";"),i=0;while(i<n.length){let s=Number.parseInt(n[i],10);if(Number.isNaN(s)){i++;continue}if(s===Ih){t.push({type:"reset"}),i++;continue}if(s===Ho||s===Mx){let u=Number.parseInt(n[i+1],10);if(u===Fx&&i+Zx<n.length){let f=lr(r,n.slice(i,i+Bh));t.push({type:"start",code:f,endCode:me.color.ansi(s===Ho?_a:wa)}),i+=Bh;continue}if(u===jx&&i+qx<n.length){let f=lr(r,n.slice(i,i+zh));t.push({type:"start",code:f,endCode:me.color.ansi(s===Ho?_a:wa)}),i+=zh;continue}let l=lr(r,[n[i]]);t.push({type:"start",code:l,endCode:me.color.ansi(s===Ho?_a:wa)}),i++;continue}if(qh.has(s)){t.push({type:"end",endCode:me.color.ansi(s)}),i++;continue}let a=me.codes.get(s);if(a!==void 0){let u=lr(r,[n[i]]);t.push({type:"start",code:u,endCode:me.color.ansi(a)}),i++;continue}let c=lr(r,[n[i]]);t.push({type:"start",code:c,endCode:me.reset.open}),i++}if(t.length===0)t.push({type:"reset"});return t}function oE(e,t){let r=e.codePointAt(t),o;if(r===pr){if(e[t+1]!==$a)return;o=t+2}else if(r===Lh)o=t+1;else return;let n=!0;for(let i=o;i<e.length;i++){let s=e.codePointAt(i);if(Yx(s)){let c=e.slice(t,i+1);if(e[i]!==jh||!n)return ve(c,i+1);return{token:{type:"sgr",code:c,fragments:rE(c)},endIndex:i+1}}if(Hx(s)){if(!Kx(s))n=!1;continue}if(Jx(s)){n=!1;continue}let a=i;return ve(e.slice(t,a),a)}return ve(e.slice(t),e.length)}function nE(e,t){let r,o,n=e.codePointAt(t);if(n===pr&&e.startsWith(Ea,t))r=Ea,o=kx;else if(n===Xo&&e.startsWith(Sa,t))r=Sa,o=Px;else return;let i=e.indexOf(";",t+r.length);if(i===-1)return ve(e.slice(t),e.length);for(let s=i+1;s<e.length;s++){let a=e[s];if(a===xa){let c=e.slice(t,s+1),u=s===i+1?"close":"open";return{token:{type:"hyperlink",code:c,action:u,closePrefix:o,terminator:xa},endIndex:s+1}}if(a===xt&&e[s+1]===Jo){let c=e.slice(t,s+2),u=s===i+1?"close":"open";return{token:{type:"hyperlink",code:c,action:u,closePrefix:o,terminator:Zh},endIndex:s+2}}if(a===Yo){let c=e.slice(t,s+1),u=s===i+1?"close":"open";return{token:{type:"hyperlink",code:c,action:u,closePrefix:o,terminator:Yo},endIndex:s+1}}}return ve(e.slice(t),e.length)}function iE(e,t){let r=e.codePointAt(t),o,n=!1;switch(r){case pr:{switch(e[t+1]){case Fh:{o=t+2,n=!0;break}case xx:case Ex:case Sx:case $x:{o=t+2;break}case Jo:return ve(Zh,t+2);default:return}break}case Xo:{o=t+1,n=!0;break}case Dh:case Nh:case Uh:case Mh:{o=t+1;break}case Vh:return ve(Yo,t+1);default:return}for(let i=o;i<e.length;i++){if(n&&e[i]===xa)return ve(e.slice(t,i+1),i+1);if(e[i]===xt&&e[i+1]===Jo)return ve(e.slice(t,i+2),i+2);if(e[i]===Yo)return ve(e.slice(t,i+1),i+1)}return ve(e.slice(t),e.length)}function fr(e,t){let r=e.codePointAt(t);if(r===pr||r===Xo){let n=nE(e,t);if(n)return n}let o=iE(e,t);if(o)return o;return oE(e,t)}function Wh(e,t,r){while(t<e.length){let o=e.codePointAt(t);if(!dr.has(o))break;let n=fr(e,t);if(!n)break;r.push(n.token),t=n.endIndex}return t}function Gh(e,t,r){let o=r.containing(t);if(!o||o.index!==t)return;return{token:{type:"character",value:o.segment,visibleWidth:Qh(o.segment),isGraphemeContinuation:!1},endIndex:t+o.segment.length}}function sE(e){let t=[],r=0;while(r<e.length){let o=e.codePointAt(r);if(dr.has(o)){let i=fr(e,r);if(i){r=i.endIndex;continue}}let n=String.fromCodePoint(o);t.push({value:n,visibleWidth:1,isGraphemeContinuation:!1}),r+=n.length}return t}function aE(e){if(e.length===0)return;let t=e.map(({value:i})=>i).join(""),r=[],o=0;for(let i of e)r.push(o),o+=i.value.length;let n=0;for(let i of Aa.segment(t)){while(n<e.length&&r[n]<i.index)n++;let s=n,a=!0;while(s<e.length&&r[s]<i.index+i.segment.length)e[s].visibleWidth=a?Qh(i.segment):0,e[s].isGraphemeContinuation=!a,a=!1,s++;n=s}}function va(e,{endCharacter:t=Number.POSITIVE_INFINITY}={}){let r=[],o=sE(e);aE(o);let n=0,i=0,s=0;while(n<e.length){let a=e.codePointAt(n);if(dr.has(a)){let d=fr(e,n);if(d){r.push(d.token),n=d.endIndex;continue}}let c=String.fromCodePoint(a),u=o[i],l=Ko(a)?2:c.length;if(u)l=u.visibleWidth;let f={type:"character",value:c,visibleWidth:l,isGraphemeContinuation:u?u.isGraphemeContinuation:!1};if(r.push(f),n+=c.length,i++,s+=f.visibleWidth,s>=t){let d=o[i];if(!d||!d.isGraphemeContinuation){n=Wh(e,n,r);break}}}return r}function Kh(e,t){let r=`${e}${t}`,o=e.length;for(let n of Aa.segment(r)){if(n.index===o)return!1;if(n.index>o)return!0}return!0}function cE(e,t,r,o){if(!r)return!1;let n=t,i=!1;while(n<e.length){let s=e.codePointAt(n);if(dr.has(s)){let c=fr(e,n);if(c){i=!0,n=c.endIndex;continue}}if(!i)return!1;let a=Gh(e,n,o);if(!a)return!0;return Kh(r,a.token.value)}return!1}function ka(e,{endCharacter:t=Number.POSITIVE_INFINITY}={}){let r=[],o=Aa.segment(e),n=0,i=0,s,a=!1;while(n<e.length){let c=e.codePointAt(n);if(dr.has(c)){let l=fr(e,n);if(l){r.push(l.token),n=l.endIndex,a=!0;continue}}let u=Gh(e,n,o);if(!u)return va(e,{endCharacter:t});if(a&&s&&Kh(s,u.token.value))return va(e,{endCharacter:t});if(r.push(u.token),n=u.endIndex,i+=u.token.visibleWidth,a=!1,s=u.token.value,i>=t){if(cE(e,n,s,o))return va(e,{endCharacter:t});n=Wh(e,n,r);break}}return r}var pr=27,Dh=144,Nh=152,Lh=155,Vh=156,Xo=157,Uh=158,Mh=159,dr,xt="\x1B",xa="\x07",$a="[",Fh="]",xx="P",Ex="X",Sx="^",$x="_",jh="m",Jo="\\",Zh,Ax="\x9D",Yo="\x9C",Ea,Sa,kx,Px,Cx,Rx,Tx,Ox,Ix,Bx,zx,Dx,Nx,Lx,Vx=127462,Ux=127487,Ih=0,Ho=38,_a=39,Mx=48,wa=49,Fx=5,jx=2,Bh=3,zh=5,Zx=2,qx=4,Qx=65039,Wx=8419,Gx,Aa,qh;var Hh=_(()=>{ha();Oh();dr=new Set([pr,Dh,Nh,Lh,Vh,Xo,Uh,Mh]),Zh=`${xt}${Jo}`,Ea=`${xt}${Fh}8;`,Sa=`${Ax}8;`,kx=`${Ea};`,Px=`${Sa};`,Cx="0".codePointAt(0),Rx="9".codePointAt(0),Tx=";".codePointAt(0),Ox=":".codePointAt(0),Ix="0".codePointAt(0),Bx="?".codePointAt(0),zx=" ".codePointAt(0),Dx="/".codePointAt(0),Nx="@".codePointAt(0),Lx="~".codePointAt(0),Gx=/\p{Emoji_Presentation}/v,Aa=new Intl.Segmenter(void 0,{granularity:"grapheme"}),qh=new Set;for(let[,e]of me.codes)qh.add(e)});function uE(e,t){for(let r of t)switch(r.type){case"reset":{e.clear();break}case"end":{e.delete(r.endCode);break}case"start":{e.delete(r.endCode),e.set(r.endCode,r.code);break}default:break}return e}function lE(e){return[...e.keys()].toReversed().join("")}function pE(e){return`${e.closePrefix}${e.terminator}`}function dE(e,t){let r=!1,o=!1;for(let n of e.fragments){if(n.type==="start"){r=!0;continue}if(n.type==="reset"&&t.size>0){o=!0;continue}if(n.type==="end"&&t.has(n.endCode))o=!0}return o&&!r}function fE(e){return e.fragments.some((t)=>t.type==="start")}function Jh(e){if(e.activeHyperlink&&!e.activeHyperlinkHasVisibleText&&e.activeHyperlinkOutputIndex!==void 0){let t=e.activeHyperlink.code.length;if(e.returnValue=e.returnValue.slice(0,e.activeHyperlinkOutputIndex)+e.returnValue.slice(e.activeHyperlinkOutputIndex+t),e.pendingSgrOutputIndex!==void 0&&e.pendingSgrOutputIndex>e.activeHyperlinkOutputIndex)e.pendingSgrOutputIndex-=t}e.activeHyperlink=void 0,e.activeHyperlinkHasVisibleText=!1,e.activeHyperlinkOutputIndex=void 0}function mE(e){if(e.isPastEnd&&!dE(e.token,e.activeStyles))return e;if(e.include&&fE(e.token)&&e.pendingSgrOutputIndex===void 0)e.pendingSgrOutputIndex=e.returnValue.length,e.pendingSgrActiveStyles=new Map(e.activeStyles);if(e.activeStyles=uE(e.activeStyles,e.token.fragments),e.include)e.returnValue+=e.token.code;return e}function hE(e){if(e.isPastEnd&&(e.token.action!=="close"||!e.activeHyperlink))return e;if(e.token.action==="open"){if(e.activeHyperlink=e.token,e.activeHyperlinkHasVisibleText=!1,e.activeHyperlinkOutputIndex=void 0,e.include)e.activeHyperlinkOutputIndex=e.returnValue.length}else if(e.token.action==="close"){if(e.include&&e.activeHyperlink&&!e.activeHyperlinkHasVisibleText)return Jh(e),e;e.activeHyperlink=void 0,e.activeHyperlinkHasVisibleText=!1,e.activeHyperlinkOutputIndex=void 0}if(e.include)e.returnValue+=e.token.code;return e}function gE(e){if(!e.isPastEnd&&e.include)e.returnValue+=e.token.code;return e}function yE(e){if(!e.include&&e.position>=e.start&&!e.token.isGraphemeContinuation){if(e.include=!0,e.returnValue=[...e.activeStyles.values()].join(""),e.activeHyperlink)e.activeHyperlinkOutputIndex=e.returnValue.length,e.returnValue+=e.activeHyperlink.code}if(e.include){if(e.returnValue+=e.token.value,e.pendingSgrOutputIndex=void 0,e.pendingSgrActiveStyles=void 0,e.activeHyperlink)e.activeHyperlinkHasVisibleText=!0}return e.position+=e.token.visibleWidth,e}function _E(e){let t=bE[e.token.type];if(!t)return e;return t(e)}function wE(e){let t=Array.from({length:e.length},()=>!1),r=!1;for(let o=e.length-1;o>=0;o--){let n=e[o];if(t[o]=r,n.type==="character")r=Boolean(n.isGraphemeContinuation)}return t}function vE(e,t,r){if(r===void 0)return!1;if(t>=r)return!0;return e.type==="character"&&!e.isGraphemeContinuation&&t+e.visibleWidth>r}function se(e,t,r){let o=ka(e,{endCharacter:r}),n=wE(o),i=new Map,s,a=!1,c,u,l,f=0,d="",p=!1;for(let[m,h]of o.entries()){let y=vE(h,f,r);if(y&&h.type!=="character"&&n[m])y=!1;if(y&&h.type==="character"&&!h.isGraphemeContinuation){if(s&&!a){let b={activeHyperlink:s,activeHyperlinkHasVisibleText:a,activeHyperlinkOutputIndex:c,pendingSgrOutputIndex:u,returnValue:d};Jh(b),{activeHyperlink:s,activeHyperlinkHasVisibleText:a,activeHyperlinkOutputIndex:c,pendingSgrOutputIndex:u,returnValue:d}=b}if(u!==void 0)d=d.slice(0,u),i=l,u=void 0,l=void 0;break}({activeStyles:i,activeHyperlink:s,activeHyperlinkHasVisibleText:a,activeHyperlinkOutputIndex:c,pendingSgrOutputIndex:u,pendingSgrActiveStyles:l,position:f,returnValue:d,include:p}=_E({token:h,isPastEnd:y,start:t,activeStyles:i,activeHyperlink:s,activeHyperlinkHasVisibleText:a,activeHyperlinkOutputIndex:c,pendingSgrOutputIndex:u,pendingSgrActiveStyles:l,position:f,returnValue:d,include:p}))}if(!p)return"";if(s)d+=pE(s);return d+=lE(i),d}var bE;var Pa=_(()=>{Hh();bE={sgr:mE,hyperlink:hE,control:gE,character:yE}});import Yh from"process";function tn(e,{showCursor:t=!1,defaultWidth:r,defaultHeight:o}={}){let n=0,i=en(e,r),s="",a=e.isTTY===!0,c=(d)=>{if(d==="")return;if(a){e.write(xE+d+EE);return}e.write(d)},u=(d,p,m=!0)=>{let h=String(d),y=h.endsWith(`
|
|
89
89
|
`)?h:`${h}
|
|
90
|
-
`,b=
|
|
91
|
-
`);return{wrapped:
|
|
92
|
-
`),{start:
|
|
93
|
-
`)});c(
|
|
94
|
-
`).length,
|
|
95
|
-
`).length}
|
|
96
|
-
`),s=Math.max(0,i.length-o);if(s===0)return{text:t,wasClipped:!1};let a=0;for(let l=0;l<s;l++)a+=
|
|
90
|
+
`,b=ur(y,p,{trim:!1,hard:!0,wordWrap:!1}),{text:P,wasClipped:E}=m?$E(e,b,o):{text:b,wasClipped:!1},A=P===""?[]:P.split(`
|
|
91
|
+
`);return{wrapped:P,lines:A,wasClipped:E}},l=()=>{s="",i=en(e,r),n=0},f=(...d)=>{if(!t)la.hide();let p=en(e,r),{wrapped:m,lines:h,wasClipped:y}=u(d.join(" "),p);if(h.length===0){if(n>0)c(ir(n));s=m,i=p,n=0;return}if(m===s&&i===p)return;if(n===0){c(m),s=m,i=p,n=h.length;return}if(i!==p||y){c(ir(n)+m),s=m,i=p,n=h.length;return}let b=s===""?[]:s.split(`
|
|
92
|
+
`),{start:P,endPrevious:E,endNext:A}=AE(b,h);if(b.length!==h.length)E=b.length-1,A=h.length-1;if(P===h.length&&n===h.length)return;if(P===0){c(ir(n)+m),s=m,i=p,n=h.length;return}let x=kE({prevCount:n,start:P,endPrevious:E,endNext:A,nextLines:h,nextWrappedEndsWithNewline:m.endsWith(`
|
|
93
|
+
`)});c(x),s=m,i=p,n=h.length};return f.clear=()=>{c(ir(n)),l()},f.done=()=>{if(l(),!t)la.show()},f.persist=(...d)=>{let p=n>0?ir(n):"",m=en(e,r),{wrapped:h}=u(d.join(" "),m,!1);c(p+h),l()},f}var en=(e,t)=>e.columns??t??80,xE="\x1B[?2026h",EE="\x1B[?2026l",SE=(e)=>e.split(`
|
|
94
|
+
`).length,Ca=(e)=>{let t=qe(e);return t===""?0:t.split(`
|
|
95
|
+
`).length},$E=(e,t,r)=>{let o=e.rows??r??24;if(o===0)return{text:"",wasClipped:t!==""};let i=qe(t).split(`
|
|
96
|
+
`),s=Math.max(0,i.length-o);if(s===0)return{text:t,wasClipped:!1};let a=0;for(let l=0;l<s;l++)a+=K(i[l])+1;let c=se(t,a),u=Ca(c);while(u>o)a++,c=se(t,a),u=Ca(c);while(a>0){let l=se(t,a-1);if(Ca(l)>o)break;a--,c=l}return{text:c,wasClipped:a>0}},AE=(e,t)=>{let r=0;for(;r<e.length&&r<t.length;r++)if(e[r]!==t[r])break;let o=e.length-1,n=t.length-1;while(o>=r&&n>=r&&e[o]===t[n])o--,n--;return{start:r,endPrevious:o,endNext:n}},kE=({prevCount:e,start:t,endPrevious:r,endNext:o,nextLines:n,nextWrappedEndsWithNewline:i})=>{let s="",a=e-1,c=t-a;if(c>0)s+=ra(c);if(c<0)s+=No(-c);s+=oa;let u=Math.max(0,r-t+1);for(let h=0;h<u;h++)if(s+=Rm,h<u-1)s+=ra();if(u>1)s+=No(u-1);s+=oa;let l=n.slice(t,o+1),f=0;if(l.length>0){let h=l.join(`
|
|
97
97
|
`),y=i&&o<n.length-1&&!h.endsWith(`
|
|
98
|
-
`);if(s+=h,f=
|
|
99
|
-
`,f++}let p=t+f,m=n.length-1-p;if(m>0)s+=ta(m);if(m<0)s+=zo(-m);return s},GR,KR;var Yh=_(()=>{Tm();Qm();ya();ka();Uo();Mo();GR=Xo(Jh.stdout),KR=Xo(Jh.stderr)});function en(e,t,r){if(e.charAt(t)===" ")return t;let o=r?1:-1;for(let n=0;n<=3;n++){let i=t+n*o;if(e.charAt(i)===" ")return i}return t}function kE(e,t,r,o){if(typeof e!=="string")throw TypeError(`Expected \`input\` to be a string, got ${typeof e}`);if(typeof t!=="number")throw TypeError(`Expected \`columns\` to be a number, got ${typeof t}`);if(!Number.isFinite(t))throw TypeError(`Expected \`columns\` to be a finite number, got ${t}`);if(!AE.has(r))throw TypeError(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${r}`);if(typeof o!=="string")throw TypeError(`Expected \`options.truncationCharacter\` to be a string, got ${typeof o}`)}function Ca(e,t,r={}){let{position:o="end",space:n=!1,preferTruncationOnSpace:i=!1}=r,{truncationCharacter:s="\u2026"}=r;if(kE(e,t,o,s),t<1)return"";let a=Q(e);if(a<=t)return e;if(t===1)return s;let c={ESC:27,LEFT_BRACKET:91,LETTER_M:109},u=(m)=>m>=48&&m<=57||m===59;function l(m){let h=0;while(h+2<m.length&&m.codePointAt(h)===c.ESC&&m.codePointAt(h+1)===c.LEFT_BRACKET){let y=h+2;while(y<m.length&&u(m.codePointAt(y)))y++;if(y<m.length&&m.codePointAt(y)===c.LETTER_M){h=y+1;continue}break}return h}function f(m){let h=m.length;while(h>1&&m.codePointAt(h-1)===c.LETTER_M){let y=h-2;while(y>=0&&u(m.codePointAt(y)))y--;if(y>=1&&m.codePointAt(y-1)===c.ESC&&m.codePointAt(y)===c.LEFT_BRACKET){h=y-1;continue}break}return h}function p(m,h){let y=f(m);if(y===m.length)return m+h;return m.slice(0,y)+h+m.slice(y)}function d(m,h){let y=l(h);if(y===0)return m+h;return h.slice(0,y)+m+h.slice(y)}if(o==="start"){if(i){let h=en(e,a-t+Q(s),!0),y=oe(e,h,a).trim();return d(s,y)}if(n)s+=" ";let m=oe(e,a-t+Q(s),a);return d(s,m)}if(o==="middle"){if(n){if(s=` ${s} `,Q(s)>=t)s=s.trim()}let m=Q(s),h=Math.min(Math.floor(t/2),Math.max(0,t-m));if(i){let y=en(e,h),b=en(e,a-(t-h)+m,!0);return oe(e,0,y)+s+oe(e,b,a).trim()}return oe(e,0,h)+s+oe(e,a-(t-h)+m,a)}if(o==="end"){if(i){let h=en(e,t-Q(s)),y=oe(e,0,h);return p(y,s)}if(n)s=` ${s}`;let m=oe(e,0,t-Q(s));return p(m,s)}}var AE;var Xh=_(()=>{ka();Mo();AE=new Set(["start","middle","end"])});import PE,{setMaxListeners as CE}from"events";import{inspect as RE,styleText as TE}from"util";import{format as OE}from"util";import{EOL as Se}from"os";import{StringDecoder as IE}from"string_decoder";import{Writable as BE}from"stream";import{randomUUID as zE}from"crypto";function VE(e){return!!e&&typeof e==="object"&&typeof e.subscribe==="function"}function UE(e){return!!e&&typeof e==="object"&&e.readable===!0&&typeof e.read==="function"&&typeof e.on==="function"}function ag(){return!!process.env.LISTR_FORCE_UNICODE||process.platform!=="win32"||!!process.env.CI||!!process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM==="xterm-256color"||process.env.TERM==="alacritty"}function fr(e){return String(e).replace(new RegExp(FE,"gmi"),"").trim()}function rg(e,t){return e.replace(/^(?!\s*$)/gm," ".repeat(t))}function dr(e,...t){return OE(String(e),...t)}function ZE(e){let t=new BE;return t.rows=1/0,t.columns=1/0,t.write=(r)=>(e(r.toString()),!0),t}function QE(e){let t=Math.floor(e/1000),r=Math.floor(t/60),o;if(t===0&&r===0)o=`0.${Math.floor(e/100)}s`;if(t>0)o=`${t%60}s`;if(r>0)o=`${r}m${o}`;return o}function XE(e){return process.stdout.isTTY===!0||e.nonTTY===!0}function tn(e){if(typeof e==="string")return Ra[e]??Ra.default;return typeof e==="function"?e:Ra.default}function eS(e){if(vt(e?.silentRendererCondition))return{renderer:tn("silent"),selection:"SILENT"};let t={renderer:tn(e.renderer),options:e.rendererOptions,selection:"PRIMARY"};if(!XE(t.renderer)||vt(e?.fallbackRendererCondition))return{renderer:tn(e.fallbackRenderer),options:e.fallbackRendererOptions,selection:"SECONDARY"};return t}function vt(e,...t){if(typeof e==="function")return e(...t);else return e}function rS(e){return new Promise((t)=>{setTimeout(t,e)})}var eg,DE,sg=class{emitter=new PE;constructor(){this.emitter.setMaxListeners(0)}emit(e,t){this.emitter.emit(e,t)}on(e,t){if(!t)return;this.emitter.addListener(e,t)}once(e,t){if(!t)return;this.emitter.once(e,t)}off(e,t){if(t)this.emitter.off(e,t);else this.emitter.removeAllListeners(e)}complete(){this.emitter.removeAllListeners()}},NE,tg,LE,FE="(?:\\u001b|\\u009b)\\[[\\=><~/#&.:=?%@~_-]*[0-9]*[\\a-ln-tqyz=><~/#&.:=?%@~_-]+",O,cg,ME,V,rn,ug,on=class{options;process;constructor(e){this.options=e,this.options={useIcons:!0,toStderr:[],...e??{}},this.options.fields??={},this.options.fields.prefix??=[],this.options.fields.suffix??=[],this.process=this.options.processOutput??new jE}log(e,t,r){let o=this.format(e,t,r);if(this.options.toStderr.includes(e)){this.process.toStderr(o);return}this.process.toStdout(o)}toStdout(e,t,r=!0){this.process.toStdout(this.format(null,e,t),r)}toStderr(e,t,r=!0){this.process.toStderr(this.format(null,e,t),r)}wrap(e,t){if(!e)return e;return this.applyFormat(`[${e}]`,t)}splat(...e){let t=e.shift()??"";return e.length===0?t:dr(t,e)}suffix(e,...t){return t.filter(Boolean).forEach((r)=>{if(e+=this.spacing(e),typeof r==="string")e+=this.wrap(r);else if(typeof r==="object"){if(r.args??=[],typeof r.condition==="function"?!r.condition(...r.args):!(r.condition??!0))return e;e+=this.wrap(typeof r.field==="function"?r.field(...r.args):r.field,{format:r?.format(...r.args)})}}),e}prefix(e,...t){return t.filter(Boolean).forEach((r)=>{if(e=this.spacing(e)+e,typeof r==="string")e=this.wrap(r)+e;else if(typeof r==="object"){if(r.args??=[],typeof r.condition==="function"?!r.condition(...r.args):!(r.condition??!0))return e;e=this.wrap(typeof r.field==="function"?r.field(...r.args):r.field,{format:r?.format()})+e}}),e}fields(e,t){if(this.options?.fields?.prefix)e=this.prefix(e,...this.options.fields.prefix);if(t?.prefix)e=this.prefix(e,...t.prefix);if(t?.suffix)e=this.suffix(e,...t.suffix);if(this.options?.fields?.suffix)e=this.suffix(e,...this.options.fields.suffix);return e}icon(e,t){if(!e)return null;if(!t){let o=this.options.icon?.[e];t=typeof o==="function"?o():o}let r=this.options.color?.[e];if(t&&r)t=r(t);return t}format(e,t,r){if(!Array.isArray(t))t=[t];return t=this.splat(t.shift(),...t).toString().split(Se).filter((o)=>!o||o.trim()!=="").map((o)=>this.style(e,this.fields(o,{prefix:Array.isArray(r?.prefix)?r.prefix:[r?.prefix],suffix:Array.isArray(r?.suffix)?r.suffix:[r?.suffix]}))).join(Se),t}style(e,t){if(!e||!t)return t;let r=this.icon(e,!this.options.useIcons&&this.wrap(e));if(r)t=r+" "+t;return t}applyFormat(e,t){if(t?.format)return t.format(e);return e}spacing(e){return typeof e>"u"||e.trim()===""?"":" "}},Ta=class{options;buffer=[];decoder=new IE;constructor(e){this.options=e}get all(){return this.buffer}get last(){return this.buffer.at(-1)}get length(){return this.buffer.length}write(e,...t){let r=t[t.length-1];if(this.buffer.push({time:Date.now(),stream:this.options?.stream,entry:this.decoder.write(typeof e==="string"?Buffer.from(e,typeof t[0]==="string"?t[0]:void 0):Buffer.from(e))}),this.options?.limit)this.buffer=this.buffer.slice(-this.options.limit);if(typeof r==="function")r();return!0}reset(){this.buffer=[]}},og=class{stream;method;buffer;constructor(e){this.stream=e,this.method=e.write,this.buffer=new Ta({stream:e})}get out(){let e=this;return new Proxy(this.stream,{get(t,r,o){if(r==="write")return e.write.bind(e);return Reflect.get(t,r,o)}})}hijack(){this.stream.write=this.buffer.write.bind(this.buffer)}release(){this.stream.write=this.method;let e=[...this.buffer.all];return this.buffer.reset(),e}write(...e){return this.method.apply(this.stream,e)}},jE=class{options;stream;active;constructor(e,t,r){this.options=r,this.stream={stdout:new og(e??process.stdout),stderr:new og(t??process.stderr)},this.options={dump:["stdout","stderr"],leaveEmptyLine:!0,...r}}get stdout(){return this.stream.stdout.out}get stderr(){return this.stream.stderr.out}hijack(){if(this.active)throw Error("ProcessOutput has been already hijacked!");this.stream.stdout.write(eg.CURSOR_HIDE),Object.values(this.stream).forEach((e)=>e.hijack()),this.active=!0}release(){let e=Object.entries(this.stream).map(([t,r])=>({name:t,buffer:r.release()})).filter((t)=>this.options.dump.includes(t.name)).flatMap((t)=>t.buffer).sort((t,r)=>t.time-r.time).map((t)=>({...t,entry:fr(t.entry)})).filter((t)=>t.entry);if(e.length>0){if(this.options.leaveEmptyLine)this.stdout.write(Se);e.forEach((t)=>{(t.stream??this.stdout).write(t.entry+Se)})}this.stream.stdout.write(eg.CURSOR_SHOW),this.active=!1}toStdout(e,t=!0){if(t)e=e+Se;return this.stream.stdout.write(e)}toStderr(e,t=!0){if(t)e=e+Se;return this.stream.stderr.write(e)}},qE=class{spinner=!ag()?["-","\\","|","/"]:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];id;spinnerPosition=0;spin(){this.spinnerPosition=++this.spinnerPosition%this.spinner.length}fetch(){return this.spinner[this.spinnerPosition]}isRunning(){return!!this.id}start(e,t=100){this.id=setInterval(()=>{if(this.spin(),e)e()},t)}stop(){clearInterval(this.id),this.id=void 0}},ng,Oa,WE,GE=class{tasks;options;static nonTTY=!0;static rendererOptions;static rendererTaskOptions;constructor(e,t){this.tasks=e,this.options=t}render(){}end(){}},KE,HE=class{options;constructor(e){this.options=e}serialize(e,t,r){return JSON.stringify(this.generate(e,t,r))}generate(e,t,r){let o={event:e,data:t};if(typeof this.options?.task!=="boolean"){let n=Object.fromEntries(this.options.task.map((i)=>{let s=r[i];if(typeof s==="function")return[i,s.call(r)];return[i,s]}));if(Object.keys(r).length>0)o.task=n}return o}},JE,YE,Ra,tS=class{concurrency;count;queue;constructor(e){this.concurrency=e.concurrency,this.count=0,this.queue=new Set}add(e){if(this.count<this.concurrency)return this.run(e);return new Promise((t)=>{let r=()=>t(this.run(e));this.queue.add(r)})}flush(){for(let e of this.queue){if(this.count>=this.concurrency)break;this.queue.delete(e),e()}}run(e){this.count++;let t=e(),r=()=>{this.count--,this.flush()};return t.then(r,()=>{this.queue.clear()}),t}},oS=class{task;constructor(e){this.task=e}get title(){return this.task.title}set title(e){e=Array.isArray(e)?e:[e],this.task.title$=dr(e.shift(),...e)}get output(){return this.task.output}set output(e){if(e===null){this.task.outputReset$=null;return}e=Array.isArray(e)?e:[e],this.task.output$=dr(e.shift(),...e)}set promptOutput(e){this.task.promptOutput$=e}get signal(){return this.task.listr.signal}cancel(){this.task.listr.cancel()}newListr(e,t){let r;if(typeof e==="function")r=e(this);else r=e;return new de(r,t,this.task)}report(e,t){if(this.task.options.collectErrors)this.task.listr.errors?.push(new NE(e,t,this.task));this.task.message$={error:e.message??this.task?.title}}skip(e,...t){if(this.task.state$="SKIPPED",e)this.task.message$={skip:e?dr(e,...t):this.task?.title}}isRetrying(){return this.task.isRetrying()?this.task.retry:{count:0}}prompt(e){if(this.task.prompt)return this.task.prompt;return new e(this.task,this)}stdout(e){return ZE((t)=>{switch(e){case"PROMPT":this.promptOutput=t;break;default:this.output=t}})}run(e){return this.task.run(e,this)}},nS,iS,ig,de=class{task;options;parentTask;tasks=[];errors;ctx;events;path=[];rendererClass;rendererClassOptions;rendererSelection;boundSignalHandler;signal;concurrency;renderer;abortController;startedTasks=[];constructor(e,t,r){if(this.task=e,this.options=t,this.parentTask=r,this.options={concurrent:!1,renderer:"default",fallbackRenderer:"simple",exitOnError:!0,exitAfterRollback:!0,collectErrors:!1,registerSignalListeners:!0,...this.parentTask?.options??{},...t},this.options.concurrent===!0)this.options.concurrent=1/0;else if(typeof this.options.concurrent!=="number")this.options.concurrent=1;if(this.concurrency=new tS({concurrency:this.options.concurrent}),r)this.path=[...r.listr.path,r.title],this.errors=r.listr.errors;else this.errors=this.options.collectErrors?[]:null;if(this.parentTask?.listr.events instanceof ig)this.events=this.parentTask.listr.events;else this.events=new ig;if(this.parentTask?.listr.abortController instanceof AbortController)this.abortController=this.parentTask.listr.abortController;else this.abortController=new AbortController,CE(0,this.abortController.signal);if(this.signal=this.abortController.signal,this.options?.forceTTY||process.env.LISTR_FORCE_TTY)process.stdout.isTTY=!0,process.stderr.isTTY=!0;if(this.options?.forceUnicode)process.env.LISTR_FORCE_UNICODE="1";let o=eS({renderer:this.options.renderer,rendererOptions:this.options.rendererOptions,fallbackRenderer:this.options.fallbackRenderer,fallbackRendererOptions:this.options.fallbackRendererOptions,fallbackRendererCondition:this.options?.fallbackRendererCondition,silentRendererCondition:this.options?.silentRendererCondition});if(this.rendererClass=o.renderer,this.rendererClassOptions=o.options,this.rendererSelection=o.selection,this.add(e??[]),this.options.registerSignalListeners&&this.isRoot())this.boundSignalHandler=this.signalHandler.bind(this),process.on("SIGINT",this.boundSignalHandler).setMaxListeners(0)}isRoot(){return!this.parentTask}isSubtask(){return!!this.parentTask}add(e){this.tasks.push(...this.generate(e))}async run(e){if(!this.renderer)this.renderer=new this.rendererClass(this.tasks,this.rendererClassOptions,this.events);await this.renderer.render(),this.ctx=this.options?.ctx??e??{};let t,r=!1;try{await Promise.all(this.tasks.map((o)=>o.check(this.ctx))),await Promise.all(this.tasks.map((o)=>this.concurrency.add(()=>this.runTask(o))))}catch(o){r=!0,t=o}if(this.signal.aborted){if(await Promise.allSettled(this.startedTasks),this.isRoot())return this.cancelUnfinishedTasks(),this.renderer.end(),this.removeSignalHandler(),process.exit(127),this.ctx;throw t??Error("Interrupted.")}if(r&&this.options.exitOnError!==!1)throw this.renderer.end(t),this.removeSignalHandler(),t;if(!r)this.renderer.end(),this.removeSignalHandler();return this.ctx}cancel(){this.abortController.abort()}generate(e){return e=Array.isArray(e)?e:[e],e.map((t)=>{let r;if(this.rendererSelection==="PRIMARY")r=t.rendererOptions;else if(this.rendererSelection==="SECONDARY")r=t.fallbackRendererOptions;return new iS(this,t,this.options,this.rendererClassOptions,r)})}async runTask(e){if(!await e.check(this.ctx))return;let t=new oS(e).run(this.ctx);return this.startedTasks.push(t),t}signalHandler(){this.abortController.abort()}removeSignalHandler(){if(this.boundSignalHandler)process.removeListener("SIGINT",this.boundSignalHandler)}cancelUnfinishedTasks(e=this.tasks){for(let t of e){if(t.hasSubtasks())this.cancelUnfinishedTasks(t.subtasks);if(t.isEnabled()!==!1&&!t.hasFinalized())t.state$="CANCELLED"}}};var xt=_(()=>{eg={CURSOR_HIDE:"\x1B[?25l",CURSOR_SHOW:"\x1B[?25h"},DE=function(e){return e.WAITING="WAITING",e.STARTED="STARTED",e.COMPLETED="COMPLETED",e.FAILED="FAILED",e.SKIPPED="SKIPPED",e.ROLLING_BACK="ROLLING_BACK",e.ROLLED_BACK="ROLLED_BACK",e.RETRY="RETRY",e.PAUSED="PAUSED",e.PROMPT="PROMPT",e.PROMPT_COMPLETED="PROMPT_COMPLETED",e.PROMPT_FAILED="PROMPT_FAILED",e.CANCELLED="CANCELLED",e}({}),NE=class extends Error{error;type;task;path;constructor(e,t,r){super(e.message);this.error=e,this.type=t,this.task=r,this.name="ListrError",this.path=r.path,this.stack=e?.stack}},tg=class extends Error{},LE=class extends Error{};O=Object.fromEntries(Object.keys(RE.colors).map((e)=>[e,(t)=>TE(e,String(t))]));cg={warning:"\u26A0",cross:"\u2716",arrowDown:"\u2193",tick:"\u2714",arrowRight:"\u2192",pointer:"\u276F",checkboxOn:"\u2612",arrowLeft:"\u2190",squareSmallFilled:"\u25FC",pointerSmall:"\u203A",circleSlash:"\u2298"},ME={...cg,warning:"\u203C",cross:"\xD7",tick:"\u221A",pointer:">",checkboxOn:"[\xD7]",squareSmallFilled:"\u25A0",circleSlash:"\xF8"},V=ag()?cg:ME;rn={icon:{["STARTED"]:V.pointer,["FAILED"]:V.cross,["SKIPPED"]:V.arrowDown,["COMPLETED"]:V.tick,["OUTPUT"]:V.pointerSmall,["TITLE"]:V.arrowRight,["RETRY"]:V.warning,["ROLLBACK"]:V.arrowLeft,["PAUSED"]:V.squareSmallFilled,["CANCELLED"]:V.circleSlash},color:{["STARTED"]:O.yellow,["FAILED"]:O.red,["SKIPPED"]:O.yellow,["COMPLETED"]:O.green,["RETRY"]:O.yellowBright,["ROLLBACK"]:O.redBright,["PAUSED"]:O.yellowBright,["CANCELLED"]:O.red}},ug=["RETRY","ROLLBACK","FAILED"];ng={icon:{["SKIPPED_WITH_COLLAPSE"]:V.arrowDown,["SKIPPED_WITHOUT_COLLAPSE"]:V.warning,["OUTPUT"]:V.pointerSmall,["OUTPUT_WITH_BOTTOMBAR"]:V.pointerSmall,["PENDING"]:V.pointer,["COMPLETED"]:V.tick,["COMPLETED_WITH_FAILED_SUBTASKS"]:V.warning,["COMPLETED_WITH_SISTER_TASKS_FAILED"]:V.squareSmallFilled,["RETRY"]:V.warning,["ROLLING_BACK"]:V.warning,["ROLLED_BACK"]:V.arrowLeft,["FAILED"]:V.cross,["FAILED_WITH_SUBTASKS"]:V.pointer,["WAITING"]:V.squareSmallFilled,["PAUSED"]:V.squareSmallFilled,["CANCELLED"]:V.circleSlash},color:{["SKIPPED_WITH_COLLAPSE"]:O.yellow,["SKIPPED_WITHOUT_COLLAPSE"]:O.yellow,["PENDING"]:O.yellow,["COMPLETED"]:O.green,["COMPLETED_WITH_FAILED_SUBTASKS"]:O.yellow,["COMPLETED_WITH_SISTER_TASKS_FAILED"]:O.red,["RETRY"]:O.yellowBright,["ROLLING_BACK"]:O.redBright,["ROLLED_BACK"]:O.redBright,["FAILED"]:O.red,["FAILED_WITH_SUBTASKS"]:O.red,["WAITING"]:O.dim,["PAUSED"]:O.yellowBright,["CANCELLED"]:O.red}};Oa={condition:!0,field:QE,format:()=>O.dim},WE=class e{tasks;options;events;static nonTTY=!1;static rendererOptions={indentation:2,clearOutput:!1,showSubtasks:!0,collapseSubtasks:!0,collapseSkips:!0,showSkipMessage:!0,suffixSkips:!1,collapseErrors:!0,showErrorMessage:!0,suffixRetries:!0,lazy:!1,removeEmptyLines:!0,formatOutput:"wrap",pausedTimer:{...Oa,format:()=>O.yellowBright}};static rendererTaskOptions={outputBar:!0};prompt;activePrompt;spinner;logger;updater;truncate;wrap;buffer={output:new Map,bottom:new Map};cache={render:new Map,rendererOptions:new Map,rendererTaskOptions:new Map};constructor(t,r,o){this.tasks=t,this.options=r,this.events=o,this.options={...e.rendererOptions,...this.options,icon:{...ng.icon,...r?.icon??{}},color:{...ng.color,...r?.color??{}}},this.spinner=this.options.spinner??new qE,this.logger=this.options.logger??new on({useIcons:!0,toStderr:[]}),this.logger.options.icon=this.options.icon,this.logger.options.color=this.options.color}async render(){await Promise.resolve().then(() => Yh());await Promise.resolve().then(() => Xh());await Promise.resolve().then(() => ya());if(this.updater=Xo(this.logger.process.stdout),this.truncate=Ca,this.wrap=ar,this.logger.process.hijack(),!this.options?.lazy)this.spinner.start(()=>{this.update()});this.events.on("SHOUD_REFRESH_RENDER",this.refresh)}update(){this.updater(this.create())}end(){if(this.spinner.stop(),this.events.off("SHOUD_REFRESH_RENDER",this.refresh),this.updater.clear(),this.updater.done(),!this.options.clearOutput)this.logger.process.toStdout(this.create({prompt:!1}));this.logger.process.release()}create(t){t={tasks:!0,bottomBar:!0,prompt:!0,...t};let r=[],o=this.renderer(this.tasks),n=this.renderBottomBar(),i=this.renderPrompt();if(t.tasks&&o.length>0)r.push(...o);if(t.bottomBar&&n.length>0){if(r.length>0)r.push("");r.push(...n)}if(t.prompt&&i.length>0){if(r.length>0)r.push("");r.push(...i)}return r.join(Se)}style(t,r=!1){let o=this.cache.rendererOptions.get(t.id);if(t.isSkipped()){if(r||o.collapseSkips)return this.logger.icon("SKIPPED_WITH_COLLAPSE");else if(o.collapseSkips===!1)return this.logger.icon("SKIPPED_WITHOUT_COLLAPSE")}if(r){if(this.shouldOutputToBottomBar(t))return this.logger.icon("OUTPUT_WITH_BOTTOMBAR");return this.logger.icon("OUTPUT")}if(t.hasSubtasks()){if(t.isStarted()||t.isPrompt()&&o.showSubtasks!==!1&&!t.subtasks.every((n)=>!n.hasTitle()))return this.logger.icon("PENDING");else if(t.isCompleted()&&t.subtasks.some((n)=>n.hasFailed()))return this.logger.icon("COMPLETED_WITH_FAILED_SUBTASKS");else if(t.hasFailed())return this.logger.icon("FAILED_WITH_SUBTASKS")}if(t.isStarted()||t.isPrompt())return this.logger.icon("PENDING",!this.options?.lazy&&this.spinner.fetch());else if(t.isCompleted())return this.logger.icon("COMPLETED");else if(t.isRetrying())return this.logger.icon("RETRY",!this.options?.lazy&&this.spinner.fetch());else if(t.isRollingBack())return this.logger.icon("ROLLING_BACK",!this.options?.lazy&&this.spinner.fetch());else if(t.hasRolledBack())return this.logger.icon("ROLLED_BACK");else if(t.hasFailed())return this.logger.icon("FAILED");else if(t.isCancelled())return this.logger.icon("CANCELLED");else if(t.isPaused())return this.logger.icon("PAUSED");return this.logger.icon("WAITING")}format(t,r,o){if(t.trim()==="")return[];if(r)t=r+" "+t;let n,i=(this.logger.process.stdout.columns??80)-o*this.options.indentation-2;switch(this.options.formatOutput){case"truncate":n=t.split(Se).map((s,a)=>this.truncate(this.indent(s,a),i));break;case"wrap":n=this.wrap(t,i,{hard:!0,trim:!1}).split(Se).map((s,a)=>this.indent(s,a));break;default:throw new tg("Format option for the renderer is wrong.")}if(this.options.removeEmptyLines)n=n.filter(Boolean);return n.map((s)=>rg(s,o*this.options.indentation))}shouldOutputToOutputBar(t){let r=this.cache.rendererTaskOptions.get(t.id).outputBar;return typeof r==="number"&&r!==0||typeof r==="boolean"&&r!==!1}shouldOutputToBottomBar(t){let r=this.cache.rendererTaskOptions.get(t.id).bottomBar;return typeof r==="number"&&r!==0||typeof r==="boolean"&&r!==!1||!t.hasTitle()}refresh=()=>{this.update()};renderer(t,r=0){return t.flatMap((o)=>{if(!o.isEnabled())return[];if(this.cache.render.has(o.id))return this.cache.render.get(o.id);this.calculate(o),this.setupBuffer(o);let n=this.cache.rendererOptions.get(o.id),i=this.cache.rendererTaskOptions.get(o.id),s=[];if(o.isPrompt()){if(this.activePrompt&&this.activePrompt!==o.id)throw new tg("Only one prompt can be active at the given time, please re-evaluate your task design.");else if(!this.activePrompt)o.on("PROMPT",(a)=>{let c=fr(a);if(c)this.prompt=c}),o.on("STATE",(a)=>{if(a==="PROMPT_COMPLETED"||o.hasFinalized()||o.hasReset())this.prompt=null,this.activePrompt=null,o.off("PROMPT")}),this.activePrompt=o.id}if(o.hasTitle())if(!(t.some((a)=>a.hasFailed())&&!o.hasFailed()&&o.options.exitOnError!==!1&&!(o.isCompleted()||o.isSkipped()||o.isCancelled())))if(o.hasFailed()&&n.collapseErrors)s.push(...this.format(!o.hasSubtasks()&&o.message.error&&n.showErrorMessage?o.message.error:o.title,this.style(o),r));else if(o.isSkipped()&&n.collapseSkips)s.push(...this.format(this.logger.suffix(o.message.skip&&n.showSkipMessage?o.message.skip:o.title,{field:"SKIPPED",condition:n.suffixSkips,format:()=>O.dim}),this.style(o),r));else if(o.isRetrying())s.push(...this.format(this.logger.suffix(o.title,{field:`RETRY:${o.message.retry.count}`,format:()=>O.yellow,condition:n.suffixRetries}),this.style(o),r));else if(o.isCompleted()&&o.hasTitle()&&vt(i.timer?.condition,o.message.duration))s.push(...this.format(this.logger.suffix(o?.title,{...i.timer,args:[o.message.duration]}),this.style(o),r));else if(o.isPaused())s.push(...this.format(this.logger.suffix(o.title,{...n.pausedTimer,args:[o.message.paused-Date.now()]}),this.style(o),r));else s.push(...this.format(o.title,this.style(o),r));else s.push(...this.format(o.title,this.logger.icon("COMPLETED_WITH_SISTER_TASKS_FAILED"),r));if(!o.hasSubtasks()||!n.showSubtasks){if(o.hasFailed()&&n.collapseErrors===!1&&(n.showErrorMessage||!n.showSubtasks))s.push(...this.dump(o,r,"FAILED"));else if(o.isSkipped()&&n.collapseSkips===!1&&(n.showSkipMessage||!n.showSubtasks))s.push(...this.dump(o,r,"SKIPPED"))}if(o.isPending()||i.persistentOutput)s.push(...this.renderOutputBar(o,r));if(n.showSubtasks!==!1&&o.hasSubtasks()&&(o.isPending()||o.hasFinalized()&&!o.hasTitle()||o.isCompleted()&&n.collapseSubtasks===!1&&!o.subtasks.some((a)=>this.cache.rendererOptions.get(a.id)?.collapseSubtasks===!0)||o.subtasks.some((a)=>this.cache.rendererOptions.get(a.id)?.collapseSubtasks===!1)||o.subtasks.some((a)=>a.hasFailed())||o.subtasks.some((a)=>a.hasRolledBack())||o.subtasks.some((a)=>a.isCancelled()))){let a=!o.hasTitle()?r:r+1,c=this.renderer(o.subtasks,a);s.push(...c)}if(o.hasFinalized()){if(!i.persistentOutput)this.buffer.bottom.delete(o.id),this.buffer.output.delete(o.id)}if(o.isClosed())this.cache.render.set(o.id,s),this.reset(o);return s})}renderOutputBar(t,r){let o=this.buffer.output.get(t.id);if(!o)return[];return o.all.flatMap((n)=>this.dump(t,r,"OUTPUT",n.entry))}renderBottomBar(){if(this.buffer.bottom.size===0)return[];return Array.from(this.buffer.bottom.values()).flatMap((t)=>t.all).sort((t,r)=>t.time-r.time).map((t)=>t.entry)}renderPrompt(){if(!this.prompt)return[];return[this.prompt]}calculate(t){if(this.cache.rendererOptions.has(t.id)&&this.cache.rendererTaskOptions.has(t.id))return;let r={...this.options,...t.rendererOptions};this.cache.rendererOptions.set(t.id,r),this.cache.rendererTaskOptions.set(t.id,{...e.rendererTaskOptions,timer:r.timer,...t.rendererTaskOptions})}setupBuffer(t){if(this.buffer.bottom.has(t.id)||this.buffer.output.has(t.id))return;if(t.hasFinalized())return;let r=this.cache.rendererTaskOptions.get(t.id);if(this.shouldOutputToBottomBar(t)&&!this.buffer.bottom.has(t.id))this.buffer.bottom.set(t.id,new Ta({limit:typeof r.bottomBar==="number"?r.bottomBar:1})),t.on("OUTPUT",(o)=>{let n=this.dump(t,-1,"OUTPUT",o);this.buffer.bottom.get(t.id).write(n.join(Se))}),t.on("OUTPUT_RESET",()=>{this.buffer.bottom.get(t.id)?.reset()}),t.on("STATE",(o)=>{if(o==="RETRY"||o==="ROLLING_BACK")this.buffer.bottom.delete(t.id)});else if(this.shouldOutputToOutputBar(t)&&!this.buffer.output.has(t.id))this.buffer.output.set(t.id,new Ta({limit:typeof r.outputBar==="number"?r.outputBar:1})),t.on("OUTPUT",(o)=>{this.buffer.output.get(t.id).write(o)}),t.on("OUTPUT_RESET",()=>{this.buffer.output.get(t.id)?.reset()}),t.on("STATE",(o)=>{if(o==="RETRY"||o==="ROLLING_BACK")this.buffer.output.delete(t.id)})}reset(t){this.cache.rendererOptions.delete(t.id),this.cache.rendererTaskOptions.delete(t.id),this.buffer.output.delete(t.id)}dump(t,r,o="OUTPUT",n){if(!n)switch(o){case"OUTPUT":n=t.output;break;case"SKIPPED":n=t.message.skip;break;case"FAILED":n=t.message.error;break}if(t.hasTitle()&&o==="FAILED"&&n===t.title||typeof n!=="string")return[];if(o==="OUTPUT")n=fr(n);return this.format(n,this.style(t,!0),r+1)}indent(t,r){return r>0?rg(t.trimEnd(),this.options.indentation):t.trimEnd()}},KE=class e{tasks;options;static nonTTY=!0;static rendererOptions={pausedTimer:{...Oa,field:(t)=>`PAUSED:${t}`,format:()=>O.yellowBright}};static rendererTaskOptions={};logger;cache={rendererOptions:new Map,rendererTaskOptions:new Map};constructor(t,r){if(this.tasks=t,this.options=r,this.options={...e.rendererOptions,...r,icon:{...rn.icon,...r?.icon??{}},color:{...rn.color,...r?.color??{}}},this.logger=this.options.logger??new on({useIcons:!0,toStderr:ug}),this.logger.options.icon=this.options.icon,this.logger.options.color=this.options.color,this.options.timestamp)this.logger.options.fields.prefix.unshift(this.options.timestamp)}end(){}render(){this.renderer(this.tasks)}renderer(t){t.forEach((r)=>{this.calculate(r),r.once("CLOSED",()=>{this.reset(r)});let o=this.cache.rendererOptions.get(r.id),n=this.cache.rendererTaskOptions.get(r.id);r.on("SUBTASK",(i)=>{this.renderer(i)}),r.on("STATE",(i)=>{if(!r.hasTitle())return;if(i==="STARTED")this.logger.log("STARTED",r.title);else if(i==="COMPLETED"){let s=n?.timer;this.logger.log("COMPLETED",r.title,s&&{suffix:{...s,condition:!!r.message?.duration&&s.condition,args:[r.message.duration]}})}else if(i==="PROMPT")this.logger.process.hijack(),r.on("PROMPT",(s)=>{this.logger.process.toStderr(s,!1)});else if(i==="PROMPT_COMPLETED")r.off("PROMPT"),this.logger.process.release();else if(i==="CANCELLED")this.logger.log("CANCELLED",r.title)}),r.on("OUTPUT",(i)=>{this.logger.log("OUTPUT",i)}),r.on("MESSAGE",(i)=>{if(i.error)this.logger.log("FAILED",r.title,{suffix:{field:`FAILED: ${i.error}`,format:()=>O.red}});else if(i.skip)this.logger.log("SKIPPED",r.title,{suffix:{field:`SKIPPED: ${i.skip}`,format:()=>O.yellow}});else if(i.rollback)this.logger.log("ROLLBACK",r.title,{suffix:{field:`ROLLBACK: ${i.rollback}`,format:()=>O.red}});else if(i.retry)this.logger.log("RETRY",r.title,{suffix:{field:`RETRY:${i.retry.count}`,format:()=>O.red}});else if(i.paused){let s=o?.pausedTimer;this.logger.log("PAUSED",r.title,s&&{suffix:{...s,condition:!!i?.paused&&s.condition,args:[i.paused-Date.now()]}})}})})}calculate(t){if(this.cache.rendererOptions.has(t.id)&&this.cache.rendererTaskOptions.has(t.id))return;let r={...this.options,...t.rendererOptions};this.cache.rendererOptions.set(t.id,r),this.cache.rendererTaskOptions.set(t.id,{...e.rendererTaskOptions,timer:r.timer,...t.rendererTaskOptions})}reset(t){this.cache.rendererOptions.delete(t.id),this.cache.rendererTaskOptions.delete(t.id)}},JE=class e{tasks;options;static nonTTY=!0;static rendererOptions={subtasks:!0,state:Object.values(DE),output:!0,prompt:!0,title:!0,messages:["skip","error","retry","rollback","paused"],messagesToStderr:["error","rollback","retry"],task:["hasRolledBack","isRollingBack","isCompleted","isSkipped","hasFinalized","hasSubtasks","title","hasReset","hasTitle","isPrompt","isPaused","isPending","isCancelled","isStarted","hasFailed","isEnabled","isRetrying","path"]};static rendererTaskOptions;logger;serializer;constructor(t,r){this.tasks=t,this.options=r,this.options={...e.rendererOptions,...this.options},this.logger=this.options.logger??new on({useIcons:!1}),this.serializer=new HE(this.options)}render(){this.renderer(this.tasks)}end(){}renderer(t){t.forEach((r)=>{if(this.options.subtasks)r.on("SUBTASK",(o)=>{this.renderer(o)});if(this.options.state)r.on("STATE",(o)=>{this.logger.toStdout(this.serializer.serialize("STATE",o,r))});if(this.options.output)r.on("OUTPUT",(o)=>{this.logger.toStdout(this.serializer.serialize("OUTPUT",o,r))});if(this.options.prompt)r.on("PROMPT",(o)=>{this.logger.toStdout(this.serializer.serialize("PROMPT",o,r))});if(this.options.title)r.on("TITLE",(o)=>{this.logger.toStdout(this.serializer.serialize("TITLE",o,r))});r.on("MESSAGE",(o)=>{let n=Object.fromEntries(Object.entries(o).map(([i,s])=>{if(this.options.messages.includes(i))return[i,s]}).filter(Boolean));if(Object.keys(n).length>0){let i=this.serializer.serialize("MESSAGE",n,r);if(this.options.messagesToStderr.some((s)=>Object.keys(n).includes(s)))this.logger.toStderr(i);else this.logger.toStdout(i)}})})}},YE=class e{tasks;options;static nonTTY=!0;static rendererOptions={logTitleChange:!1,pausedTimer:{...Oa,format:()=>O.yellowBright}};static rendererTaskOptions;logger;cache={rendererOptions:new Map,rendererTaskOptions:new Map};constructor(t,r){if(this.tasks=t,this.options=r,this.options={...e.rendererOptions,...this.options,icon:{...rn.icon,...r?.icon??{}},color:{...rn.color,...r?.color??{}}},this.logger=this.options.logger??new on({useIcons:!1,toStderr:ug}),this.logger.options.icon=this.options.icon,this.logger.options.color=this.options.color,this.options.timestamp)this.logger.options.fields.prefix.unshift(this.options.timestamp)}render(){this.renderer(this.tasks)}end(){}renderer(t){t.forEach((r)=>{this.calculate(r),r.once("CLOSED",()=>{this.reset(r)});let o=this.cache.rendererOptions.get(r.id),n=this.cache.rendererTaskOptions.get(r.id);if(r.on("SUBTASK",(i)=>{this.renderer(i)}),r.on("STATE",(i)=>{if(!r.hasTitle())return;if(i==="STARTED")this.logger.log("STARTED",r.title);else if(i==="COMPLETED"){let s=n.timer;this.logger.log("COMPLETED",r.title,s&&{suffix:{...s,condition:!!r.message?.duration&&s.condition,args:[r.message.duration]}})}else if(i==="CANCELLED")this.logger.log("CANCELLED",r.title)}),r.on("OUTPUT",(i)=>{this.logger.log("OUTPUT",i)}),r.on("PROMPT",(i)=>{let s=fr(i);if(s)this.logger.log("PROMPT",s)}),this.options?.logTitleChange!==!1)r.on("TITLE",(i)=>{this.logger.log("TITLE",i)});r.on("MESSAGE",(i)=>{if(i?.error)this.logger.log("FAILED",i.error);else if(i?.skip)this.logger.log("SKIPPED",i.skip);else if(i?.rollback)this.logger.log("ROLLBACK",i.rollback);else if(i?.retry)this.logger.log("RETRY",r.title,{suffix:i.retry.count.toString()});else if(i?.paused){let s=o?.pausedTimer;this.logger.log("PAUSED",r.title,s&&{suffix:{...s,condition:!!i?.paused&&s.condition,args:[i.paused-Date.now()]}})}})})}calculate(t){if(this.cache.rendererOptions.has(t.id)&&this.cache.rendererTaskOptions.has(t.id))return;let r={...this.options,...t.rendererOptions};this.cache.rendererOptions.set(t.id,r),this.cache.rendererTaskOptions.set(t.id,{...e.rendererTaskOptions,timer:r.timer,...t.rendererTaskOptions})}reset(t){this.cache.rendererOptions.delete(t.id),this.cache.rendererTaskOptions.delete(t.id)}},Ra={default:WE,simple:KE,verbose:YE,test:JE,silent:GE};nS=class extends sg{},iS=class extends nS{listr;task;options;rendererOptions;rendererTaskOptions;id=zE();state="WAITING";subtasks;title;initialTitle;output;retry;message={};prompt;parent;enabled;taskFn;closed;constructor(e,t,r,o,n){super();if(this.listr=e,this.task=t,this.options=r,this.rendererOptions=o,this.rendererTaskOptions=n,t.title){let i=Array.isArray(t?.title)?t.title:[t.title];this.title=dr(i.shift(),...i),this.initialTitle=this.title}this.taskFn=t.task,this.parent=e.parentTask}set state$(e){if(this.state=e,this.emit("STATE",e),this.hasSubtasks()&&this.hasFailed()){for(let t of this.subtasks)if(t.state==="STARTED")t.state$="FAILED"}this.listr.events.emit("SHOUD_REFRESH_RENDER")}set output$(e){this.output=e,this.emit("OUTPUT",e),this.listr.events.emit("SHOUD_REFRESH_RENDER")}set outputReset$(e){this.output=e,this.emit("OUTPUT_RESET"),this.listr.events.emit("SHOUD_REFRESH_RENDER")}set promptOutput$(e){if(this.emit("PROMPT",e),fr(e))this.listr.events.emit("SHOUD_REFRESH_RENDER")}set message$(e){this.message={...this.message,...e},this.emit("MESSAGE",e),this.listr.events.emit("SHOUD_REFRESH_RENDER")}set title$(e){this.title=e,this.emit("TITLE",e),this.listr.events.emit("SHOUD_REFRESH_RENDER")}get path(){return[...this.listr.path,this.initialTitle]}async check(e){if(this.state==="WAITING")this.enabled=await vt(this.task?.enabled??!0,e),this.emit("ENABLED",this.enabled),this.listr.events.emit("SHOUD_REFRESH_RENDER");return this.enabled}hasSubtasks(){return this.subtasks?.length>0}hasFinalized(){return this.isCompleted()||this.hasFailed()||this.isSkipped()||this.hasRolledBack()||this.isCancelled()}isPending(){return this.isStarted()||this.isPrompt()||this.hasReset()}isStarted(){return this.state==="STARTED"}isSkipped(){return this.state==="SKIPPED"}isCompleted(){return this.state==="COMPLETED"}hasFailed(){return this.state==="FAILED"}isCancelled(){return this.state==="CANCELLED"}isRollingBack(){return this.state==="ROLLING_BACK"}hasRolledBack(){return this.state==="ROLLED_BACK"}isRetrying(){return this.state==="RETRY"}hasReset(){return this.state==="RETRY"||this.state==="ROLLING_BACK"}isEnabled(){return this.enabled}hasTitle(){return typeof this?.title==="string"}isPrompt(){return this.state==="PROMPT"}isPaused(){return this.state==="PAUSED"}isClosed(){return this.closed}async pause(e){let t=this.state;this.state$="PAUSED",this.message$={paused:Date.now()+e},await rS(e),this.state$=t,this.message$={paused:null}}async run(e,t){let r=(i)=>{if(i instanceof de)i.options={...this.options,...i.options},i.rendererClass=tn("silent"),this.subtasks=i.tasks,i.errors=this.listr.errors,this.emit("SUBTASK",this.subtasks),i=i.run(e);else if(i instanceof Promise)i=i.then(r);else if(UE(i))i=new Promise((s,a)=>{i.on("data",(c)=>{this.output$=c.toString()}),i.on("error",(c)=>a(c)),i.on("end",()=>s(null))});else if(VE(i))i=new Promise((s,a)=>{i.subscribe({next:(c)=>{this.output$=c},error:a,complete:s})});return i},o=Date.now();this.state$="STARTED";let n=await vt(this.task?.skip??!1,e);if(n){if(typeof n==="string")this.message$={skip:n};else if(this.hasTitle())this.message$={skip:this.title};else this.message$={skip:"Skipped task without a title."};this.state$="SKIPPED";return}try{let i=typeof this.task?.retry==="number"&&this.task.retry>0?this.task.retry+1:typeof this.task?.retry==="object"&&this.task.retry.tries>0?this.task.retry.tries+1:1,s=typeof this.task.retry==="object"&&this.task.retry.delay;for(let a=1;a<=i;a++)try{await Promise.race([r(this.taskFn(e,t)),this.whenInterrupted()]);break}catch(c){if(this.listr.signal.aborted)throw c;if(a!==i){if(this.retry={count:a,error:c},this.message$={retry:this.retry},this.title$=this.initialTitle,this.output=void 0,t.report(c,"WILL_RETRY"),this.state$="RETRY",s)await this.pause(s)}else throw c}if(this.isStarted()||this.isRetrying())this.message$={duration:Date.now()-o},this.state$="COMPLETED"}catch(i){if(this.prompt instanceof LE)i=this.prompt;if(this.task?.rollback){t.report(i,"WILL_ROLLBACK");try{this.state$="ROLLING_BACK",await this.task.rollback(e,t),this.message$={rollback:this.title},this.state$="ROLLED_BACK"}catch(s){throw this.state$="FAILED",t.report(s,"HAS_FAILED_TO_ROLLBACK"),this.close(),s}if(this.listr.options?.exitAfterRollback!==!1)throw this.close(),i}else{if(this.listr.signal.aborted)throw this.state$="CANCELLED",i;if(this.state$="FAILED",this.listr.options.exitOnError!==!1&&await vt(this.task?.exitOnError,e)!==!1)throw t.report(i,"HAS_FAILED"),this.close(),i;else if(!this.hasSubtasks())t.report(i,"HAS_FAILED_WITHOUT_ERROR")}}finally{this.close()}}close(){this.emit("CLOSED"),this.listr.events.emit("SHOUD_REFRESH_RENDER"),this.complete()}whenInterrupted(){return new Promise((e,t)=>{let r=()=>{if(!this.hasSubtasks())t(Error("Interrupted."))};if(this.listr.signal.aborted){r();return}this.listr.signal.addEventListener("abort",r,{once:!0})})}},ig=class extends sg{}});function sS(e){return typeof e==="string"&&/^sha256:[a-f0-9]{64}$/.test(e)}function lg(e){if(!sS(e))throw Error(`Invalid SHA-256 digest: ${e}`)}var mr=1;import{AsyncLocalStorage as aS}from"async_hooks";function Ia(e){return e["x-arch"]==="amd64"?"amd64":"arm64"}function pg(e){if(Ia(e)!=="amd64")return{};return{nodeSelector:{"kubernetes.io/arch":"amd64"},tolerations:[{key:"arch",operator:"Equal",value:"amd64",effect:"NoExecute"}]}}var kT;var Ba=_(()=>{kT=new aS});import{execFile as cS,spawn as uS}from"child_process";import{createHash as lS}from"crypto";import{constants as za}from"fs";import{access as pS}from"fs/promises";import{chmod as BT,lstat as dS,mkdir as zT,open as fS,readdir as mg,readlink as mS,realpath as hS,symlink as DT,readFile as gS}from"fs/promises";import{delimiter as yS,dirname as bS,isAbsolute as Na,relative as hr,resolve as Et,sep as gr}from"path";import{promisify as _S}from"util";async function Va(){for(let e of(process.env.PATH??"").split(yS)){if(!e)continue;try{return await pS(Et(e,process.platform==="win32"?"git.exe":"git"),za.X_OK),!0}catch{}}return!1}function Da(e){return`sha256:${lS("sha256").update(e).digest("hex")}`}function hg(e){if(!e||e.includes("\x00")||e.includes("\\")||Na(e)||e.split("/").some((t)=>!t||t==="."||t===".."))throw Error(`Unsafe workspace path: ${JSON.stringify(e)}`)}function dg(e,t){let r=hr(e,t);return r===""||!r.startsWith(`..${gr}`)&&r!==".."&&!Na(r)}async function fg(e,t){let{stdout:r}=await La("git",["-C",e,"ls-files","-z",...t],{encoding:"buffer",maxBuffer:67108864}),o=new TextDecoder("utf-8",{fatal:!0}),n=[],i=0;for(let s=r.indexOf(0);s!==-1;s=r.indexOf(0,i)){if(s>i)n.push(o.decode(r.subarray(i,s)));i=s+1}return n}async function wS(e){let[t,r]=await Promise.all([fg(e,["--cached","--others","--exclude-standard"]),fg(e,["--others","--ignored","--exclude-standard","--",".env*","**/.env*"])]);return[...new Set([...t,...r])].sort((o,n)=>Buffer.from(o).compare(Buffer.from(n)))}async function vS(e){let t=[],r=new Set([".git",".hg",".svn","node_modules","vendor","bower_components",".venv","venv","__pycache__",".tox",".mypy_cache",".pytest_cache",".next",".nuxt",".svelte-kit",".cache",".turbo","dist","build","coverage","target","out","tmp","temp"]),o=/(?:^|[-_.])(?:secrets?|credentials?|configs?)(?:$|[-_.])/i,n=[],i=async(c)=>{try{let u=await gS(Et(c,".gitignore"),"utf8");for(let l of u.split(/\r?\n/)){let f=l.trim();if(!f||f.startsWith("#"))continue;if(f.startsWith("!"))continue;let p=f.replace(/^\//,"");if(p)n.push({base:hr(e,c).split(gr).join("/"),pattern:p.replace(/\/$/,""),directory:f.endsWith("/")})}}catch(u){if(u.code!=="ENOENT")throw u}},s=(c,u)=>{let l=!1;for(let f of n){let p=f.base?`${f.base}/`:"";if(f.base&&c!==f.base&&!c.startsWith(p))continue;let d=f.base&&c.startsWith(p)?c.slice(p.length):c,m=f.pattern.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"__DOUBLESTAR__").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]").replace(/__DOUBLESTAR__/g,".*"),h=new RegExp(`^(?:${m})(?:/.*)?$`),y=new RegExp(`^(?:${m})$`);if((h.test(d)||d.split("/").some((b)=>y.test(b)))&&(!f.directory||u||d.includes("/")))l=!0}return l},a=async(c)=>{await i(c);for(let u of await mg(c,{withFileTypes:!0})){let l=Et(c,u.name),f=hr(e,l).split(gr).join("/");if(u.isDirectory()){if(r.has(u.name)||o.test(u.name)||s(f,!0))continue;await a(l)}else if(u.isFile()||u.isSymbolicLink()){if(s(f,!1))continue;if(/^\.env/i.test(u.name)||/(?:secret|credential|password|token|private[-_.]?key)/i.test(u.name)||/^(?:id_rsa|id_ed25519|known_hosts|config\.json|\.npmrc|\.pypirc|\.netrc)$/i.test(u.name))continue;t.push(f)}else throw Error(`Special files are not allowed in workspaces: ${hr(e,l).split(gr).join("/")}`)}};return await a(e),t.sort((c,u)=>Buffer.from(c).compare(Buffer.from(u)))}async function xS(e){if(!await Va())return!1;try{return await La("git",["-C",e,"rev-parse","--show-toplevel"]),!0}catch(t){let{code:r,exitCode:o}=t,n=t instanceof Error?t.message:String(t);if(r==="ENOENT")return!1;if(o===128||r===128||/not a git repository/i.test(n))return!1;throw t}}async function ES(e){let t=await La("git",["-C",e,"ls-files","--others","--ignored","--exclude-standard","--directory","-z"],{encoding:"buffer",maxBuffer:67108864}),r=new TextDecoder("utf-8",{fatal:!0}),o=new Set,n=0;for(let m=t.stdout.indexOf(0);m!==-1;m=t.stdout.indexOf(0,n)){if(m>n){let h=r.decode(t.stdout.subarray(n,m));if(h.endsWith("/"))o.add(h.slice(0,-1))}n=m+1}let i=[],s=async(m)=>{for(let h of await mg(m,{withFileTypes:!0})){if(m===e&&h.name===".git")continue;let y=Et(m,h.name),b=hr(e,y).split(gr).join("/");if(h.isDirectory()){if(!o.has(b))await s(y)}else if(!h.isFile()&&!h.isSymbolicLink())i.push(b)}};if(await s(e),i.length===0)return;let a=Buffer.from(`${i.join("\x00")}\x00`),c=uS("git",["-C",e,"check-ignore","--stdin","-z"]),u=[],l=[];c.stdout.on("data",(m)=>u.push(m)),c.stderr.on("data",(m)=>l.push(m));let f=new Promise((m,h)=>{c.once("error",h),c.once("close",(y)=>{if(y===0||y===1)m();else h(Error(Buffer.concat(l).toString("utf8")||`git check-ignore exited with ${y}`))})});c.stdin.end(a),await f;let p=Buffer.concat(u),d=new Set;n=0;for(let m=p.indexOf(0);m!==-1;m=p.indexOf(0,n)){if(m>n)d.add(r.decode(p.subarray(n,m)));n=m+1}for(let m of i){let h=m.slice(m.lastIndexOf("/")+1);if(!d.has(m)||h.startsWith(".env"))throw Error(`Special files are not allowed in workspaces: ${m}`)}}function SS(e){return JSON.stringify({version:e.version,files:e.files.map((t)=>({path:t.path,type:t.type,digest:t.digest,size:t.size,mode:t.mode}))})}function Ua(e){return AS(e),Buffer.from(SS(e))}function $S(e){return Da(Ua(e))}function AS(e){if(e.version!==mr||!Array.isArray(e.files))throw Error("Unsupported workspace manifest");let t="",r=new Set;for(let o of e.files){if(hg(o.path),lg(o.digest),!Number.isSafeInteger(o.size)||o.size<0)throw Error(`Invalid size for ${o.path}`);if(o.type==="file"&&o.mode!==420&&o.mode!==493||o.type==="symlink"&&o.mode!==511)throw Error(`Invalid mode for ${o.path}`);if(o.type!=="file"&&o.type!=="symlink")throw Error(`Invalid entry type for ${o.path}`);if(r.has(o.path))throw Error(`Duplicate workspace path: ${o.path}`);for(let n of o.path.split("/").slice(0,-1).map((i,s,a)=>a.slice(0,s+1).join("/")))if(r.has(n))throw Error(`Workspace entry is used as a directory: ${n}`);if(t&&Buffer.from(t).compare(Buffer.from(o.path))>=0)throw Error("Workspace files must be bytewise sorted");r.add(o.path),t=o.path}}async function nn(e){let t=await hS(e),o=await xS(t)?await(async()=>(await ES(t),wS(t)))():await vS(t),n=[],i=new Map;for(let a of o){hg(a);let c=Et(t,a);if(!dg(t,c))throw Error(`Workspace path escapes root: ${a}`);let u;try{u=await dS(c)}catch(p){if(p.code==="ENOENT")continue;throw p}let l,f;if(u.isSymbolicLink()){let p=await mS(c);if(Na(p)||!dg(t,Et(bS(c),p)))throw Error(`Symlink escapes workspace: ${a} -> ${p}`);l=Buffer.from(p),f={path:a,type:"symlink",digest:Da(l),size:l.byteLength,mode:511}}else if(u.isFile()){let p,d=await fS(c,za.O_RDONLY|za.O_NOFOLLOW);try{let m=await d.stat();if(!m.isFile())throw Error(`Not a regular file: ${a}`);p=m.mode&73?493:420,l=await d.readFile()}finally{await d.close()}f={path:a,type:"file",digest:Da(l),size:l.byteLength,mode:p}}else throw Error(`Special files are not allowed in workspaces: ${a}`);n.push(f),i.set(f.digest,l)}let s={version:mr,files:n};return{manifest:s,digest:$S(s),blobs:[...i].map(([a,c])=>({digest:a,data:c}))}}var La;var Fa=_(()=>{La=_S(cS)});import{randomUUID as kS}from"crypto";import{execFile as PS}from"child_process";import{isAbsolute as CS,relative as wg,resolve as gg,sep as vg}from"path";import{promisify as RS}from"util";class Eg{inflight=0;maxInflight;maxPerSecond;requestStarts=[];waiting=[];rateGate=Promise.resolve();clock;sleep;constructor(e){if(this.maxInflight=e?.maxInflight??zS,this.maxPerSecond=e?.maxPerSecond??DS,!Number.isSafeInteger(this.maxInflight)||this.maxInflight<1)throw RangeError("maxInflight must be a positive integer");if(!Number.isSafeInteger(this.maxPerSecond)||this.maxPerSecond<1)throw RangeError("maxPerSecond must be a positive integer");this.clock=e?.clock??{now:()=>Date.now()},this.sleep=e?.sleep??((t)=>Bun.sleep(t))}get currentInflight(){return this.inflight}get maxConcurrent(){return this.maxInflight}get currentRequestStarts(){return this.pruneOldStarts(),this.requestStarts.length}pruneOldStarts(){let e=this.clock.now()-1000;while(this.requestStarts.length>0&&this.requestStarts[0]<=e)this.requestStarts.shift()}async acquire(){if(this.inflight<this.maxInflight){this.inflight++;return}await new Promise((e)=>{this.waiting.push(e)})}release(){if(this.waiting.length>0)this.waiting.shift()();else this.inflight--}waitForRateLimit(){let e=this.rateGate.then(async()=>{for(;;){if(this.pruneOldStarts(),this.requestStarts.length<this.maxPerSecond){this.requestStarts.push(this.clock.now());return}let t=this.requestStarts[0];await this.sleep(Math.max(1,t+1000-this.clock.now()))}});return this.rateGate=e.catch(()=>{}),e}async run(e){await this.acquire();try{return await this.waitForRateLimit(),await e()}finally{this.release()}}}async function NS(e,t,r){let o=0,n=async()=>{for(;;){let i=o++;if(i>=e.length)return;await r(e[i])}};await Promise.all(Array.from({length:Math.min(t,e.length)},n))}function LS(e,t){return wg(e,t).split(vg).join("/")||"."}function bg(e,t,r,o){let n=wg(e,t);if(n.startsWith(`..${vg}`)||n===".."||CS(n))throw Error(`${r} must stay inside the git repo for service ${o}`);return LS(e,t)}function VS(e){if(!e.build||typeof e.build==="string"||!e.build.args)return[];if(Array.isArray(e.build.args))return[...e.build.args];return Object.entries(e.build.args).filter(([,t])=>t!==null).map(([t,r])=>`${t}=${String(r)}`)}function US(e,t,r,o,n,i){if(!r.build)return;let s=r.build,a=typeof s==="string"?s:s.context??".";if(a.includes("://"))throw Error(`Remote build context is not supported for service ${t}`);if(typeof s!=="string"&&s.dockerfile_inline)throw Error(`dockerfile_inline is not supported for service ${t}`);let c=gg(o,a),u=bg(n,c,"Build context",t),l=typeof s==="string"||!s.dockerfile?void 0:gg(c,s.dockerfile);return{name:t,image:FS(e,t,i),context:u,dockerfile:l?bg(n,l,"Dockerfile",t):void 0,target:typeof s==="string"?void 0:s.target,buildArgs:VS(r)}}function FS(e,t,r=Co){return`${r.replace(/\/+$/,"")}/kuber/${e}-${t}:latest`}async function Ma(e){if(!await Va())return e;try{let{stdout:t}=await TS("git",["-C",e,"rev-parse","--show-toplevel"]);return t.trim()}catch(t){if(t.code==="ENOENT")return e;throw t}}async function MS(e,t,r,o,n){let i=`/blobs/${encodeURIComponent(e)}/uploads`,s=n?`?project=${encodeURIComponent(n)}`:"",a=`${i}${s}`,c=await o.run(()=>r(a,{method:"POST",json:{size:t.byteLength}})),u=c.offset;while(!c.complete&&u<t.byteLength){let l=t.subarray(u,u+OS),f=await o.run(()=>r(a,{method:"PATCH",headers:{"content-type":"application/octet-stream","upload-offset":String(u)},body:l}));if(f.offset<=u)throw Error(`Blob upload for ${e} made no progress`);u=f.offset}if(!c.complete)await o.run(()=>r(`${i}/complete${s}`,{method:"POST",json:{}}))}async function jS(e,t=k,r,o,n){let i=new Map(e.blobs.map((a)=>[a.digest,a.data]));i.set(e.digest,Ua(e.manifest));let s=o??new Eg;for(;;){let a=await s.run(()=>t("/snapshots/negotiate",{method:"POST",json:{workspace:e.digest,...n&&{project:n}}}));if(a.ready)return;if(a.missing.length===0)throw Error("Snapshot negotiation is incomplete but reported no missing blobs");await NS(a.missing,s.maxConcurrent,async(c)=>{let u=i.get(c);if(!u)throw Error(`Server requested unknown workspace blob ${c}`);await r?.progress?.(`Uploading ${c}`),await MS(c,u,t,s,n)})}}async function ZS(e,t,r,o){if(e.type==="status"){if(!r?.has(e.status.state))r?.add(e.status.state),await t?.progress?.(`${o?`${o}: `:""}Build ${e.status.state}`);return 0}if(t?.stream)t.stream.write(o?`[${o}] ${e.message}`:e.message);else await t?.progress?.(`${o?`${o}: `:""}${e.message.trimEnd()}`);return e.sequence}function qS(e){if(!(e instanceof Error)||e.name==="AbortError")return!1;if(e.name==="TimeoutError"||e instanceof TypeError)return!0;let t="code"in e&&typeof e.code==="string"?e.code:e.cause&&typeof e.cause==="object"&&("code"in e.cause)&&typeof e.cause.code==="string"?e.cause.code:void 0;return t==="ECONNABORTED"||t==="ECONNRESET"||t==="ECONNREFUSED"||t==="EAI_AGAIN"||t==="ETIMEDOUT"}async function _g(e,t,r,o,n,i){for(let s=1;s<=yg;s++)try{return i?.throwIfAborted(),await e(t,{...r,signal:i},{timeoutMs:BS})}catch(a){if(!qS(a)||s===yg)throw a;i?.throwIfAborted(),await n(o)}throw Error("Build poll retries exhausted")}async function QS(e,t,r,o,n,i,s,a){let c=i,u=0,l=new Set;for(;;){let f=await _g(t,`/builds/${encodeURIComponent(e)}/events?after=${u}`,void 0,o,n,s);for(let p of f)u=Math.max(u,await ZS(p,r,l,a));if(c.state==="succeeded"||c.state==="failed")return c;if(c=await _g(t,`/builds/${encodeURIComponent(e)}/reconcile`,{method:"POST",json:{}},o,n,s),c.state!=="succeeded"&&c.state!=="failed")s?.throwIfAborted(),await n(o)}}async function sn(e,t,r={}){let o=r.request??k,n=Object.entries(t.services??{}).filter(([,a])=>a.build).map(([a])=>a),i=Array(n.length),s=0;return await Promise.all(Array.from({length:Math.min(xg,n.length)},async()=>{for(;;){let a=s++;if(a>=n.length)return;let c=n[a];r.signal?.throwIfAborted();try{i[a]=(await o("/images/resolve",{method:"POST",json:{project:e,service:c},signal:r.signal})).reference}catch(u){throw Error(`Cannot resolve a published image for service ${c}. Run kuber up to build it.`,{cause:u})}}})),Object.fromEntries(n.map((a,c)=>[a,i[c]]))}async function Sg(e,t,r=process.cwd(),o,n={}){if(!Object.values(t.services??{}).some((b)=>b.build))return{built:[],changed:[],images:{}};let i=n.buildConcurrency??xg;if(!Number.isSafeInteger(i)||i<1)throw RangeError("buildConcurrency must be a positive integer");let s=n.request??k,a=n.workspaceRoot;if(!a&&!n.snapshot)try{a=await Ma(r)}catch(b){a=r}a??=r;let c=n.snapshot??await nn(a),u=Object.entries(t.services??{}).flatMap(([b,S])=>{let x=US(e,b,S,r,a,n.registry??Co);return x?[x]:[]});await jS(c,s,o,n.scheduler,e);let l=Array(u.length),f=0,p,d=!1,m=async()=>{while(!d&&f<u.length){let b=f++,S=u[b];try{n.signal?.throwIfAborted(),await o?.progress?.(`Building ${S.name}`),l[b]=await h(S)}catch(x){if(!d)p=x;d=!0}}},h=async(b)=>{let S=kS(),x={version:mr,id:S,project:e,service:b.name,spec:{architecture:Ia(t),image:b.image,context:b.context,dockerfile:b.dockerfile,target:b.target,buildArgs:b.buildArgs,workspace:c.digest}},A=await s("/builds",{method:"POST",json:x,signal:n.signal},{timeoutMs:300000}),R=await QS(S,s,o,n.pollIntervalMs??IS,n.sleep??((Z)=>Bun.sleep(Z)),A,n.signal,b.name);if(R.state!=="succeeded")throw Error(`Build failed for service ${b.name}: ${R.error??"unknown error"}`);return(await s(`/builds/${encodeURIComponent(S)}/result`,{signal:n.signal})).reference};if(await Promise.all(Array.from({length:Math.min(i,u.length)},m)),d)throw p;let y=Object.fromEntries(u.map((b,S)=>[b.name,l[S]]));return{built:u.map((b)=>b.name),changed:u.map((b)=>b.name),images:y}}var TS,OS=8388608,IS=1000,BS=300000,yg=3,xg=3,zS=20,DS=40;var ja=_(()=>{Ba();q();Ro();Fa();TS=RS(PS)});function $g(e){return WS[e.kind]??999}function Ag(e){return[...e].sort((t,r)=>$g(t)-$g(r))}var WS,tO,rO;var an=_(()=>{Ve();WS={Namespace:0,GarageBucket:1,GarageKey:2,ServiceAccount:3,ClusterRole:4,Role:5,ClusterRoleBinding:6,RoleBinding:7,StorageClass:8,PersistentVolumeClaim:9,Secret:10,ConfigMap:11,Service:12,Deployment:13,HorizontalPodAutoscaler:14,Ingress:15,IngressRoute:16},tO=`app.kubernetes.io/managed-by=${H["app.kubernetes.io/managed-by"]}`,rO=H["app.kubernetes.io/managed-by"]});function JS(e){return`${HS}-${e}`}function Za(e){return encodeURIComponent(e)}function kg(e,t){return`postgresql://${Za(t.username)}:${Za(t.password)}@${qa}:${Qa}/${Za(e.database)}`}function Pg(e){if(!e.startsWith("postgresql:"))return;let t=e.split(":");if(t.length!==2)throw Error(`Invalid postgres volume ${e}. Use postgresql:<name> or postgresql:<user>/<database>.`);let r=t[1]?.trim();if(!r)throw Error(`Invalid postgres volume ${e}. Use postgresql:<name> or postgresql:<user>/<database>.`);let o=r.split("/");if(o.length>2||o.some((s)=>s.trim()===""))throw Error(`Invalid postgres volume ${e}. Use postgresql:<name> or postgresql:<user>/<database>.`);let n=o[0],i=o[1]??n;return{username:n,database:i}}function Cg(e){return typeof e==="string"&&Pg(e)!==void 0}function YS(e,t){let r=t.volumes?.flatMap((o)=>{if(typeof o!=="string")return[];let n=Pg(o);return n?[{...n,service:e,secretName:JS(n.username)}]:[]})??[];if(r.length>1)throw Error(`Service ${e} declares multiple postgres volumes. Only zero or one postgresql:<...> entry is allowed per service.`);return r[0]}function nt(e){let t=Object.entries(e.services??{}).flatMap(([o,n])=>{let i=YS(o,n);return i?[i]:[]}),r=new Map;for(let o of t){let n=r.get(o.database);if(n&&n!==o.username)throw Error(`Database ${o.database} is claimed by both ${n} and ${o.username}. A database can only have one owner.`);r.set(o.database,o.username)}return t}var KS="database",HS="postgres",qa,Qa=5432;var yr=_(()=>{Ve();an();qa=`c.${KS}.svc.cluster.local`});function cn(e,t){if(typeof e!=="object"||e===null||typeof t!=="object"||t===null)return t;let r=Array.isArray(e)?[...e]:{...e};for(let o of Object.keys(t)){let n=r[o],i=t[o];if(Array.isArray(n)&&Array.isArray(i))r[o]=[...n,...i];else if(n&&typeof n==="object"&&i&&typeof i==="object")r[o]=cn(n,i);else r[o]=i}return r}function Rg(e){if(!e.startsWith("s3:"))return;let t=e.split(":");if(t.length!==2)throw Error(`Invalid S3 volume ${e}. Use s3:<name> or s3:<key>/<bucket>.`);let r=t[1]?.trim();if(!r)throw Error(`Invalid S3 volume ${e}. Use s3:<name> or s3:<key>/<bucket>.`);let o=r.split("/");if(o.length>2||o.some((s)=>s.trim()===""))throw Error(`Invalid S3 volume ${e}. Use s3:<name> or s3:<key>/<bucket>.`);let n=o[0],i=o[1]??n;return{key:n,bucket:i}}function Tg(e){return typeof e==="string"&&Rg(e)!==void 0}function XS(e,t){let r=t.volumes?.flatMap((o)=>{if(typeof o!=="string")return[];let n=Rg(o);return n?[{...n,service:e}]:[]})??[];if(r.length>1)throw Error(`Service ${e} declares multiple S3 volumes. Only zero or one s3:<...> entry is allowed per service.`);return r[0]}function it(e){let t=Object.entries(e.services??{}).flatMap(([o,n])=>{let i=XS(o,n);return i?[i]:[]}),r=new Map;for(let o of t){let n=r.get(o.key);if(n&&n!==o.bucket)throw Error(`S3 key ${o.key} is claimed for both ${n} and ${o.bucket}. A managed key can only target one bucket.`);r.set(o.key,o.bucket)}return t}var br=_(()=>{Ve();an()});import{existsSync as Og,readFileSync as e$,realpathSync as Ga,statSync as t$}from"fs";import{dirname as r$,isAbsolute as Ig,normalize as o$,relative as n$,resolve as un,sep as Bg}from"path";function St(e,t){return Object.assign(Error(e),t?{code:t}:{})}function i$(e){if(!e||e.includes("\x00")||e.includes("\\")||e.startsWith("~")||Ig(e))throw St(`Artifact path must be workspace-relative: ${e}`);let t=o$(e);if(t===".."||t.startsWith(`..${Bg}`))throw St(`Artifact path escapes the workspace: ${e}`);return t.replace(/^\.\//,"")}function Ka(e,t){let r=n$(e,t);if(r===".."||r.startsWith(`..${Bg}`)||Ig(r))throw St(`Artifact path escapes the workspace: ${t}`)}function s$(e,t){let r=t;while(!Og(r)){let o=r$(r);if(o===r)break;r=o}Ka(e,Ga(r))}function Wa(e,t){if(t!==void 0&&(!Number.isSafeInteger(t)||t<0))throw Error(`${e} must be a non-negative safe integer`)}class zg{#t;#r=0;#e=0;constructor(e){Wa("maxArtifactCount",e.maxArtifactCount),Wa("maxArtifactBytes",e.maxArtifactBytes),Wa("maxTotalBytes",e.maxTotalBytes),this.#t=e}add(e,t){let r=Buffer.byteLength(t);if(this.#t.maxArtifactBytes!==void 0&&r>this.#t.maxArtifactBytes)throw St(`Artifact ${e} exceeds the ${this.#t.maxArtifactBytes} byte limit`);if(this.#t.maxArtifactCount!==void 0&&this.#r+1>this.#t.maxArtifactCount)throw St(`Artifact count exceeds the ${this.#t.maxArtifactCount} limit`);if(this.#t.maxTotalBytes!==void 0&&this.#e+r>this.#t.maxTotalBytes)throw St(`Artifact bytes exceed the ${this.#t.maxTotalBytes} byte limit`);this.#r+=1,this.#e+=r}}class je{#t;#r;#e;constructor(e){this.#t=e.strict?Ga(e.workspace):un(e.workspace),this.#r=e.strict??!1,this.#e=new zg(e)}#o(e,t){if(!this.#r)return t.expandHome&&e.startsWith("~")?un(process.env.HOME??"",e.slice(1)):un(this.#t,e);let r=un(this.#t,i$(e));return Ka(this.#t,r),s$(this.#t,r),r}isFile(e,t={}){let r=this.#o(e,t);return Og(r)&&t$(r).isFile()}readText(e,t={}){let r=this.#o(e,t);if(this.#r)Ka(this.#t,Ga(r));let o=e$(r,"utf8");return this.#e.add(e,o),o}}var Dg=()=>{};import{createHash as Mg}from"crypto";import{basename as jg}from"path";function Zg(e){if(!e.diskTag&&e.replicaCount===void 0&&!e.dataLocality)return;return{diskTag:e.diskTag?[...e.diskTag].sort():void 0,replicaCount:e.replicaCount,dataLocality:e.dataLocality}}function qg(e){return`kuber-longhorn-${Mg("sha256").update(JSON.stringify(e)).digest("hex").slice(0,12)}`}function st(e){if(typeof e==="number")return e;if(!e||e.includes("-"))return;let t=Number(e);return Number.isInteger(t)?t:void 0}function Ng(e){if(typeof e!=="string"&&typeof e!=="number")return;let t=String(e).trim(),r=a$.exec(t);if(!r)return;let o=Number(r[1]),n=Number(r[2]);if(!Number.isInteger(o)||!Number.isInteger(n))return;if(o<1||n<1)throw Error(`Invalid replica range ${t}. Range bounds must be positive integers.`);if(o>n)throw Error(`Invalid replica range ${t}. Minimum (${o}) cannot exceed maximum (${n}).`);return{kind:"range",min:o,max:n}}function pn(e,t){if(t===void 0||t.trim()==="")return;let r=Number(t);if(!Number.isInteger(r)||r<0)throw Error(`Invalid ${e} value ${JSON.stringify(t)}. Expected a non-negative integer (zero allowed for a fixed replica count), a numeric string, or a "min-max" range.`)}function Lg(e){if(e.scale!==void 0){let t=st(e.scale);if(t!==void 0)return pn("scale",String(e.scale)),t;pn("scale",String(e.scale))}if(e.deploy?.replicas!==void 0){let t=st(e.deploy.replicas);if(t!==void 0)return pn("deploy.replicas",String(e.deploy.replicas)),t;pn("deploy.replicas",String(e.deploy.replicas))}return 1}function Qg(e){let t=Ng(e.scale);if(t)return Vg(t);if(e.scale!==void 0)return{kind:"fixed",value:Lg(e)};let r=Ng(e.deploy?.replicas);if(r)return Vg(r);return{kind:"fixed",value:Lg(e)}}function Vg(e){if(e.min===e.max)return{kind:"fixed",value:e.min};return e}function c$(e){if(e.kind==="range")return e.max>1;return e.value>1}function u$(e,t,r){if(t.build){let o=r[e];if(!o)throw Error(`Missing resolved build image for service ${e}`);return o}return t.image}function Ha(e){return e?.toUpperCase()==="UDP"?"UDP":"TCP"}function dn(e){if(!e)return;return/[a-z]/i.test(e)?e:void 0}function fn(e){return typeof e==="string"?JSON.stringify(e):String(e)}function Ug(e,t){let r=String(e).trim(),o=l$.exec(r);if(!o)throw Error(`Invalid ${t} value ${fn(e)}. Expected a non-negative finite decimal number of CPU cores.`);let n=BigInt(o[1]??"0"),i=o[2]??"",s=n*1000n+(i?BigInt(i.padEnd(3,"0").slice(0,3)):0n);if(i.slice(3).replaceAll("0","")!=="")throw Error(`Invalid ${t} value ${fn(e)}. CPU cores must be representable in whole millicores.`);return s%1000n===0n?String(s/1000n):`${s}m`}function Fg(e,t){let r=e.trim(),o=p$.exec(r);if(!o)throw Error(`Invalid ${t} value ${fn(e)}. Expected a non-negative memory quantity.`);let n=o[1]??"",i=(()=>{switch(n.toLowerCase()){case"b":return"";case"k":case"kb":return"k";case"m":case"mb":return"M";case"g":case"gb":return"G";case"t":case"tb":return"T";case"p":case"pb":return"P";case"e":case"eb":return"E";default:return n}})();if(!["","n","u","m","k","M","G","T","P","E","Ki","Mi","Gi","Ti","Pi","Ei"].includes(i))throw Error(`Invalid ${t} value ${fn(e)}. Expected a valid Kubernetes or Compose memory quantity.`);return`${r.slice(0,r.length-n.length)}${i}`}function d$(e){let t=e.deploy?.resources;if(!t)return;let r={...t.limits?.cpus!==void 0?{cpu:Ug(t.limits.cpus,"deploy.resources.limits.cpus")}:{},...t.limits?.memory!==void 0?{memory:Fg(t.limits.memory,"deploy.resources.limits.memory")}:{}},o={...t.reservations?.cpus!==void 0?{cpu:Ug(t.reservations.cpus,"deploy.resources.reservations.cpus")}:{},...t.reservations?.memory!==void 0?{memory:Fg(t.reservations.memory,"deploy.resources.reservations.memory")}:{}};if(Object.keys(r).length===0&&Object.keys(o).length===0)return;return{...Object.keys(r).length>0?{limits:r}:{},...Object.keys(o).length>0?{requests:o}:{}}}function f$(e){if(typeof e==="boolean")return e;if(!e)return;switch(e.toLowerCase()){case"1":case"true":case"yes":case"on":case"ro":return!0;case"0":case"false":case"no":case"off":case"rw":return!1}}function mn(e){return e.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,63)}function Ja(e){if(e===void 0||e===null)return;let t=String(e).trim();if(!t)return;return t}function Wg(e){if(e===void 0||e===null)return;let t=(Array.isArray(e)?e:[e]).flatMap((r)=>String(r).split(",")).map((r)=>r.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}function Gg(e){if(e===void 0||e===null||e==="")return;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=20?t:void 0}function m$(e){let[t,r]=e.split(/\s+on\s+/i,2).map((n)=>n?.trim());if(!r)return{requestedStorage:Ja(t)};let o=/^(?:(?<replicas>\d+)\s+)?(?<tags>.+)$/.exec(r);return{requestedStorage:Ja(t),diskTag:Wg(o?.groups?.tags),replicaCount:Gg(o?.groups?.replicas),dataLocality:"none"}}function h$(e){let t=/^(?<name>[^()]+)\((?<size>[^()]+)\)$/.exec(e.trim());if(!t?.groups)return;let r=t.groups.name?.trim(),{requestedStorage:o,diskTag:n,replicaCount:i,dataLocality:s}=m$(t.groups.size??"");if(!r)return;return{source:r,requestedStorage:o,diskTag:n,replicaCount:i,dataLocality:s}}function Kg(e){if(!e||Ya(e))return{source:e};let t=h$(e);if(!t)return{source:e};if(!t.source)throw Error(`Invalid volume source ${e}. Expected name(size).`);return t}function Hg(e){return Ja(e?.["x-size"])}function Jg(e){return Wg(e?.["x-diskTag"])}function Yg(e){return Gg(e?.["x-replicaCount"])}function Xg(e){return e?.["x-dataLocality"]==="none"?"none":void 0}function ey(e){return mn(`bind-${Bun.hash(e).toString(36)}`)}function Ya(e){return e.startsWith(".")||e.startsWith("/")||e.startsWith("~")||e.includes("/")}function ty(e,t){return t.isFile(e,{expandHome:!0})}function g$(e,t,r){if(Cg(e)||Tg(e))return;let o=e.split(":");if(o.length===1)return{name:`volume-${t}`,kind:"volume",target:e};let n=o.at(-1),i=n==="ro"||n==="rw",s=o.at(i?-2:-1),a=o.slice(0,i?-2:-1).join(":");if(!s)return;let{source:c,requestedStorage:u,diskTag:l,replicaCount:f,dataLocality:p}=Kg(a||void 0);return{name:c&&Ya(c)?ey(c):`volume-${t}`,kind:c&&Ya(c)?ty(c,r)?"config-file":"bind":"volume",source:c||void 0,target:s,configKey:c?jg(c):void 0,readOnly:i?n==="ro":void 0,requestedStorage:u,diskTag:l,replicaCount:f,dataLocality:p}}function y$(e,t,r){if(typeof e==="string")return g$(e,t,r);if(!e.target)return;if(e.type!=="bind"&&e.type!=="volume"&&e.type!=="tmpfs")return;let{source:o,requestedStorage:n,diskTag:i,replicaCount:s,dataLocality:a}=Kg(e.source);return{name:o?e.type==="bind"?ey(o):`${e.type}-${mn(o)||t}`:`${e.type}-${t}`,kind:e.type==="bind"&&o&&ty(o,r)?"config-file":e.type,source:o,target:e.target,readOnly:f$(e.read_only),configKey:o?jg(o):void 0,subPath:e.volume?.subpath,sizeLimit:e.type==="tmpfs"&&e.tmpfs?.size!==void 0?String(e.tmpfs.size):void 0,requestedStorage:n??Hg(e.volume),diskTag:i??Jg(e.volume),replicaCount:s??Yg(e.volume),dataLocality:a??Xg(e.volume)}}function b$(e,t){if(!t||!e)return;let r=e[t];return Hg(r)}function _$(e,t){if(!t||!e)return;let r=e[t];return Jg(r)}function w$(e,t){if(!t||!e)return;let r=e[t];return Yg(r)}function v$(e,t){if(!t||!e)return;let r=e[t];return Xg(r)}function hn(e,t,r={}){let o=e.volumes?.flatMap((i,s)=>{let a=y$(i,s,t);if(!a)return[];return[{...a,requestedStorage:a.requestedStorage??b$(r,a.source)??(a.kind==="volume"&&a.source?ln.requestedStorage:void 0),diskTag:a.diskTag??_$(r,a.source)??(a.kind==="volume"&&a.source?ln.diskTag:void 0),replicaCount:a.replicaCount??w$(r,a.source)??(a.kind==="volume"&&a.source?ln.replicaCount:void 0),dataLocality:a.dataLocality??v$(r,a.source)??(a.kind==="volume"&&a.source?ln.dataLocality:void 0)}]})??[],n=(Array.isArray(e.tmpfs)?e.tmpfs:[e.tmpfs]).filter((i)=>Boolean(i)).map((i,s)=>({name:`tmpfs-${o.length+s}`,kind:"tmpfs",target:i}));return[...o,...n]}function x$(e){if(e.length===0)return;return e.map((t)=>({name:t.name,mountPath:t.target,readOnly:t.readOnly,subPath:t.kind==="config-file"?t.configKey:t.subPath}))}function E$(e,t){if(t.length===0)return;return t.map((r)=>{if(r.kind==="config-file")return{name:r.name,configMap:{name:r.name}};if(r.kind==="bind"){if(!r.source)return{name:r.name,emptyDir:{}};return{name:r.name,persistentVolumeClaim:{claimName:r.name}}}if(r.kind==="tmpfs")return{name:r.name,emptyDir:{medium:"Memory",sizeLimit:r.sizeLimit}};if(!r.source)return{name:r.name,emptyDir:{}};return{name:r.name,persistentVolumeClaim:{claimName:mn(`${e}-${r.source}`)}}})}function S$(e){return[...new Set(e.split(",").map((t)=>t.trim()).filter(Boolean).map((t)=>t.startsWith("/")?t:`/${t}`))]}function $$(e){let t=/^(?<portSpec>.+):protected(?:\((?<paths>[^)]*)\))?$/.exec(e);if(!t?.groups)return{portSpec:e};let r=t.groups.portSpec?.trim();if(!r)throw Error(`Invalid protected port syntax ${e}.`);let o=t.groups.paths?.trim();if(o===void 0)return{portSpec:r,routingKind:"ingressroute"};let n=S$(o);if(n.length===0)throw Error(`Invalid protected port syntax ${e}. Expected one or more paths.`);return{portSpec:r,routingKind:"ingressroute",paths:n}}function gn(e){let t=e.ports?.flatMap((o,n)=>{if(typeof o==="number")return[{name:`port-${n}`,containerPort:o,servicePort:o,protocol:"TCP"}];if(typeof o==="string"){let a=/\/(tcp|udp)$/i.exec(o),c=a?o.slice(0,-a[0].length):o,u=a?.[1];if(!c)return[];let{portSpec:l,routingKind:f,paths:p}=$$(c),d=l.split(":"),m=st(d.at(-1));if(!m)return[];let h=st(d.at(-2)),y=h!==void 0?dn(d.at(-3)):dn(d.at(-2));return[{name:`port-${n}`,containerPort:m,servicePort:h??m,hostPort:h,host:y,protocol:Ha(u),routingKind:y?f??"ingress":void 0,paths:p}]}let i=st(o.target);if(!i)return[];let s=st(o.published);return[{name:o.name??`port-${n}`,containerPort:i,servicePort:s??i,hostPort:s,host:dn(o.host_ip),protocol:Ha(o.protocol),routingKind:dn(o.host_ip)?"ingress":void 0}]})??[],r=e.expose?.flatMap((o,n)=>{let[i,s]=String(o).split("/"),a=st(i);if(!a)return[];return[{name:`expose-${n}`,containerPort:a,servicePort:a,protocol:Ha(s)}]})??[];return[...t,...r]}function A$(e){if(e.length===0)return;let t=new Map;for(let r of e)t.set(`${r.containerPort}:${r.protocol}`,{name:r.name,containerPort:r.containerPort,hostPort:r.hostPort,protocol:r.protocol});return[...t.values()]}function k$(e){if(e.length===0)return;let t=new Map;for(let r of e)t.set(`${r.servicePort}:${r.protocol}`,{name:r.name,port:r.servicePort,targetPort:r.containerPort,protocol:r.protocol});return[...t.values()]}function P$(e,t){let r=new Set;return t.flatMap((o)=>{if(!o.host||o.routingKind==="ingressroute"||r.has(o.host))return[];return r.add(o.host),[{host:o.host,http:{paths:[{path:"/",pathType:"Prefix",backend:{service:{name:e,port:{number:o.servicePort}}}}]}}]})}function C$(e,t,r){let o=r.flatMap((n)=>{if(!n.host||n.routingKind!=="ingressroute")return[];return(n.paths&&n.paths.length>0?n.paths.map((s)=>`Host(\`${n.host}\`) && PathPrefix(\`${s}\`)`):[`Host(\`${n.host}\`)`]).map((s)=>({kind:"Rule",match:s,middlewares:[{name:"cf-auth",namespace:"routing"}],services:[{name:t,port:n.servicePort}]}))});if(o.length===0)return;return{apiVersion:"traefik.io/v1alpha1",kind:"IngressRoute",metadata:{name:t,namespace:e,labels:H},spec:{routes:o}}}function R$(e){if(!e)return[];return(Array.isArray(e)?e:[e]).map((r)=>typeof r==="string"?{path:r,required:!0}:{path:r.path,required:r.required!==!1&&r.required!=="false"})}function T$(e){let t={};for(let r of e.split(/\r?\n/)){let o=r.trim();if(!o||o.startsWith("#"))continue;let n=o.indexOf("=");if(n===-1)continue;let i=o.slice(0,n).trim(),s=o.slice(n+1);if(!i)continue;t[i]=s}return t}async function O$(e,t){let r={};for(let o of R$(e))try{let n=t.readText(o.path);Object.assign(r,T$(n))}catch(n){if(!o.required&&n&&typeof n==="object"&&"code"in n&&n.code==="ENOENT")continue;throw n}return r}function I$(e,t,r,o,n=process.cwd(),i={},s={},a={},c=new je({workspace:n}),u={}){let l=hn(o,c,s),f=gn(o),p=Boolean(o.env_file)||Object.keys(i).length>0,d=u.replicaSpec??Qg(o),m=d.kind==="range"?d.min:d.value,h=[cn({name:t,imagePullPolicy:"Always",env:cm(o.environment),image:u$(t,o,a),command:o.command instanceof Array?o.command:o.command?o.command.split(" "):void 0,envFrom:p?[{secretRef:{name:`${t}-env`}}]:void 0,ports:A$(f),resources:d$(o),volumeMounts:x$(l)},o["x-container"]??{})],y={restartPolicy:"Always",...pg(r),volumes:E$(e,l),containers:h};if(c$(d))y.topologySpreadConstraints=[{maxSkew:1,topologyKey:"kubernetes.io/hostname",whenUnsatisfiable:"ScheduleAnyway",labelSelector:{matchLabels:{app:t}}}];return cn({apiVersion:"apps/v1",kind:"Deployment",metadata:{name:t,namespace:e,labels:H},spec:{replicas:m,strategy:{rollingUpdate:{maxSurge:"25%",maxUnavailable:"25%"}},selector:{matchLabels:{app:t}},template:{metadata:{labels:{app:t}},spec:y}}},o["x-deployment"]??{})}function B$(e,t,r){let o=k$(gn(r));if(!o)return;return{apiVersion:"v1",kind:"Service",metadata:{name:t,namespace:e,labels:H},spec:{type:"ClusterIP",selector:{app:t},ports:o}}}function z$(e,t,r){let o=P$(t,gn(r));if(o.length===0)return;return{apiVersion:"networking.k8s.io/v1",kind:"Ingress",metadata:{name:t,namespace:e,labels:H},spec:{rules:o}}}function D$(e,t,r=process.cwd(),o={},n=new je({workspace:r})){let i=new Map;for(let s of hn(t,n,o)){let a=s.kind==="bind"?s.source?s.name:void 0:s.kind==="volume"&&s.source?mn(`${e}-${s.source}`):void 0;if(!a||i.has(a))continue;let c=Zg(s);i.set(a,{apiVersion:"v1",kind:"PersistentVolumeClaim",metadata:{name:a,namespace:e,labels:H},spec:{accessModes:[c?.replicaCount===1?"ReadWriteOnce":"ReadWriteMany"],storageClassName:c?qg(c):void 0,resources:{requests:{storage:s.requestedStorage??"1Gi"}}}})}return[...i.values()]}function N$(e,t=process.cwd(),r={},o=new je({workspace:t})){let n=new Map;for(let i of hn(e,o,r)){let s=Zg(i);if(!s)continue;let a=qg(s);n.set(a,{apiVersion:"storage.k8s.io/v1",kind:"StorageClass",metadata:{name:a,labels:H},provisioner:"driver.longhorn.io",allowVolumeExpansion:!0,reclaimPolicy:"Delete",volumeBindingMode:"Immediate",parameters:{...s.diskTag?{diskSelector:s.diskTag.join(",")}:{},...s.replicaCount!==void 0?{numberOfReplicas:String(s.replicaCount)}:{},...s.dataLocality?{dataLocality:"disabled"}:{}}})}return[...n.values()]}function L$(e,t,r=process.cwd(),o={},n=new je({workspace:r})){let i=new Map;for(let s of hn(t,n,o)){if(s.kind!=="config-file"||!s.source||!s.configKey)continue;i.set(s.name,{apiVersion:"v1",kind:"ConfigMap",metadata:{name:s.name,namespace:e,labels:H},data:{[s.configKey]:n.readText(s.source,{expandHome:!0})}})}return[...i.values()]}async function V$(e,t,r,o=process.cwd(),n={},i=new je({workspace:o})){let s={...await O$(r.env_file,i),...n};if(Object.keys(s).length===0)return[];return[{apiVersion:"v1",kind:"Secret",metadata:{name:`${t}-env`,namespace:e,labels:H},type:"Opaque",stringData:s}]}function U$(e){let t=Object.entries(e.stringData??{}).sort(([r],[o])=>r.localeCompare(o));return Mg("sha256").update(JSON.stringify(t)).digest("hex")}function F$(e){return{apiVersion:"v1",kind:"Namespace",metadata:{name:e,labels:H}}}function M$(e,t){let r=e.spec?.template.spec?.containers[0];if(!r)return;if(t["x-container"]?.resources?.requests?.cpu!==void 0)return;if(r.resources??={},r.resources.requests??={},r.resources.requests.cpu===void 0)r.resources.requests.cpu="100m"}function j$(e,t,r){return{apiVersion:"autoscaling/v2",kind:"HorizontalPodAutoscaler",metadata:{name:t,namespace:e,labels:H},spec:{scaleTargetRef:{apiVersion:"apps/v1",kind:"Deployment",name:t},minReplicas:r.min,maxReplicas:r.max,metrics:[{type:"Resource",resource:{name:"cpu",target:{type:"Utilization",averageUtilization:80}}}]}}}function $e(e){return`${e.kind}:${e.metadata?.namespace??""}:${e.metadata?.name??""}`}async function yn(e,t,r=process.cwd(),o={},n={},i=new je({workspace:r})){let s=new Map,a=F$(e);s.set($e(a),a);for(let[c,u]of Object.entries(t.services??{})){for(let b of N$(u,r,t.volumes,i))s.set($e(b),b);for(let b of D$(e,u,r,t.volumes,i))s.set($e(b),b);for(let b of L$(e,u,r,t.volumes,i))s.set($e(b),b);let l=await V$(e,c,u,r,o[c]??{},i);for(let b of l)s.set($e(b),b);let f=B$(e,c,u);if(f)s.set($e(f),f);let p=Qg(u),d=I$(e,c,t,u,r,o[c]??{},t.volumes,n,i,{replicaSpec:p}),m=l[0];if(m)d.spec.template.metadata.annotations={...d.spec?.template.metadata?.annotations,"kuber.astrxl.dev/env-checksum":U$(m)};if(s.set($e(d),d),p.kind==="range"){M$(d,u);let b=j$(e,c,p);s.set($e(b),b)}let h=z$(e,c,u);if(h)s.set($e(h),h);let y=C$(e,c,gn(u));if(y)s.set($e(y),y)}return[...s.values()]}var ln,a$,l$,p$;var Xa=_(()=>{Ve();Ba();yr();tt();br();Dg();ln={requestedStorage:"1Gi",diskTag:["fast"],replicaCount:2,dataLocality:"none"};a$=/^\s*(\d+)\s*-\s*(\d+)\s*$/;l$=/^(\d+)(?:\.(\d+))?$/,p$=/^(?:\d+(?:\.\d+)?|\.\d+)([a-zA-Z]*)$/});import{randomUUID as ec}from"crypto";import{isDeepStrictEqual as ry}from"util";function uy(e){return`/workspaces/${encodeURIComponent(e)}/adopt`}function oy(e,t){let r={...e};for(let[o,n]of Object.entries(t))r[o]={...r[o],...n};return r}function G$(e){let{resource:t,phase:r,state:o}=e.data;return`${r==="apply"?"Applied":r==="wait"?"Waited for":"Deleted"} ${t.kind}/${t.name}: ${o}`}function K$(e){if(!e||typeof e!=="object")return!1;let{sequence:t,data:r}=e;if(!Number.isSafeInteger(t)||!r||typeof r!=="object")return!1;let{resource:o,phase:n,state:i}=r;if(!o||typeof o!=="object")return!1;let s=o;return typeof s.apiVersion==="string"&&typeof s.kind==="string"&&typeof s.name==="string"&&(s.namespace===void 0||typeof s.namespace==="string")&&(n==="apply"||n==="wait"||n==="delete")&&(i==="started"||i==="succeeded"||i==="failed"||i==="aborted")}function H$(e,t){return{source:{uri:`cas://${t.digest}`,digest:t.digest},config:{compose:e}}}function J$(e,t){return ry(e.spec?.source,t.source)&&ry(e.spec?.config,t.config)}function ny(e){if(e instanceof we)return e.status===409;if(e instanceof DOMException&&e.name==="AbortError")return!1;if(e instanceof Error&&e.name==="AbortError")return!1;return e instanceof TypeError||e instanceof Error&&e.name==="TimeoutError"}async function Y$(e,t,r,o=k){let n=`/workspaces/${encodeURIComponent(e)}`,i=H$(t,r),s=(u)=>o(n,{method:"PUT",headers:{"if-match":`"${u.metadata.resourceVersion}"`},json:i}),a=async(u)=>{try{let l=await o(n);if(J$(l,i))return l;return await s(l)}catch{throw u}},c;try{c=await o(n)}catch(u){if(!(u instanceof we)||u.status!==404)throw u;try{return await o("/workspaces",{method:"POST",json:{id:e,...i}})}catch(l){if(!ny(l))throw l;return a(l)}}try{return await s(c)}catch(u){if(!ny(u))throw u;return a(u)}}function iy(e){return Object.fromEntries(Object.entries(e).filter(([t,r])=>t!=="operation"&&t!=="operationId"&&r!==null&&typeof r==="object"&&!Array.isArray(r)))}function bn(e,t){let r=t instanceof Error?t.message:String(t);if(!/namespace .* (?:external|different-workspace)/i.test(r))return t instanceof Error?t:Error(r);return Error(`${r}. Safe adoption requires ${cy} ${uy(e)} with namespace UID and ownership preconditions.`,{cause:t})}async function At(e,t,r,o){try{return await t(r,o)}catch(n){throw bn(e,n)}}function X$(e){if(!e||typeof e!=="object")return;let t=e.operationId;return typeof t==="string"&&t?t:void 0}function eA(e){if(!e||typeof e!=="object")return;let t=e.operation?.status;return t&&typeof t==="object"?t:void 0}function sy(e,t){let r=t.error,o=t.state==="cancelled",n=typeof r?.message==="string"?r.message:o?"The operation was cancelled":"The operation failed",i=typeof r?.code==="string"?r.code:o?"OPERATION_CANCELLED":"OPERATION_FAILED";return new we(n,o?409:500,{title:o?"Operation cancelled":"Operation failed",status:o?409:500,code:i,operationId:e})}function tA(e){if(e instanceof we)return W$.has(e.code);if(e instanceof DOMException&&e.name==="AbortError")return!1;if(e instanceof Error&&e.name==="AbortError")return!1;return e instanceof TypeError||e instanceof Error&&e.name==="TimeoutError"}function rA(e){return e.state==="failed"&&e.error?.code==="OPERATION_INTERRUPTED"}function oA(e,t){return e.cursorGap===!0||Number.isSafeInteger(e.retainedFirstSequence)&&e.retainedFirstSequence>t+1}function nA(e,t){return t+Math.max(e,0)+Q$}function ly(e){return e.reason??new DOMException("The operation was aborted","AbortError")}function $t(e){if(e?.aborted)throw ly(e)}function iA(e,t){return $t(t),new Promise((r,o)=>{let n,i=()=>{if(n!==void 0)clearTimeout(n);t?.removeEventListener("abort",a)},s=()=>{i(),r()},a=()=>{i(),o(ly(t))};if(n=setTimeout(s,e),t?.addEventListener("abort",a,{once:!0}),t?.aborted)a()})}async function tc(e,t,r,o,n,i){let s=i.now??Date.now,a=nA(n,s()),c=new Headers(o.headers);c.set("idempotency-key",ec()),c.set("prefer","respond-async");let u={...o,headers:c,signal:i.signal??o.signal},l,f=Z$,p=!1,d=0;for(;;){if($t(i.signal),p&&s()>=a)throw Error("Timed out while reconnecting to resume the operation");try{let y;if(l)y=(await At(e,t,`/operations/${encodeURIComponent(l)}`,{signal:i.signal})).status;else{p=!1;let b=await At(e,t,r,u);l=X$(b),y=eA(b)}if(l)try{let b=await At(e,t,`/operations/${encodeURIComponent(l)}/events?after=${d}`,{signal:i.signal});if(oA(b,d))throw new nc;for(let S of b.items??[]){if(!Number.isSafeInteger(S.sequence)||S.sequence<=d)continue;if(d=S.sequence,!K$(S))continue;i.onEvent?.(S)}}catch(b){if(b instanceof nc)throw b;$t(i.signal)}if(!l||!y||y.state==="succeeded")return;if(rA(y)){if(s()>=a)throw sy(l,y);l=void 0,d=0,p=!0,c.set("idempotency-key",ec()),u={...o,headers:c,signal:i.signal??o.signal}}else if(y.state==="failed"||y.state==="cancelled")throw sy(l,y)}catch(y){if($t(i.signal),y instanceof we&&y.code==="OPERATION_INTERRUPTED"){if(s()>=a)throw bn(e,y);l=void 0,d=0,p=!0,c.set("idempotency-key",ec()),u={...o,headers:c,signal:i.signal??o.signal}}else{if(!tA(y))throw bn(e,y);if(s()>=a)throw bn(e,y)}}let m=a-s();if(m<=0)throw Error("Timed out while reconnecting to resume the operation");let h=Math.min(f,m);if(i.sleep)$t(i.signal),await i.sleep(h),$t(i.signal);else await iA(h,i.signal);f=Math.min(f*2,q$)}}async function sA(e,t,r=k){let o=`/workspaces/${encodeURIComponent(e)}`;return At(e,r,`${o}/resources/plan`,{method:"POST",json:{resources:t}})}function rc(e){let t=e.name??e.metadata?.name;if(!e.apiVersion||!e.kind||!t)return;return{apiVersion:e.apiVersion,kind:e.kind,name:t,namespace:e.namespace??e.metadata?.namespace}}function ay(e){return`${e.apiVersion}\x00${e.kind}\x00${e.namespace??""}\x00${e.name}`}function aA(e,t){return`${e==="apply"?"Apply":e==="wait"?"Wait for":"Delete"} ${t.kind}/${t.name}`}function oc(e,t,r,o,n={}){if(r.length===0)return o(()=>{},e.signal);let i=new Map,s=new Set,a=0;return e.newListr(r.map((c)=>({title:aA(t,c),task:async(u,l)=>{if(i.set(ay(c),l),n.onTaskStarted?.(c,l),a+=1,a!==r.length)return new Promise((f)=>{let p=()=>{e.signal.removeEventListener("abort",p),s.delete(p),f()};if(s.add(p),e.signal.aborted)p();else e.signal.addEventListener("abort",p,{once:!0})});try{await o((f)=>{let p=f.data.resource,d=i.get(ay(p));if(!d)return;d.output=f.data.state,e.output=G$(f)},e.signal)}finally{for(let f of[...s])f()}}})),{concurrent:!0})}async function _r(e,t=k,r={}){let{project:o,compose:n,cwd:i,config:s,hookContext:a}=I(),c=r.trust??await Am(await gt(o,i)),u=t;t=async(p,d={},m)=>{let h=new Headers(d.headers);for(let[y,b]of Object.entries($m(c)))h.set(y,b);return u(p,{...d,headers:h},m)};let l=`/workspaces/${encodeURIComponent(o)}`;return await new de([{title:"Read compose",task:async(p,d)=>{if(p.compose=await n(),e)await s.preBuild?.(p.compose,await a());d.output=`${Object.keys(p.compose.services??{}).length} services`}},{title:"Snapshot workspace",task:async(p,d)=>{let m;try{m=await Ma(i)}catch(h){m=i}p.workspaceRoot=m,p.snapshot=await nn(m),d.output=`${p.snapshot.manifest.files.length} files`}},{title:"Build images",rendererOptions:{outputBar:10,persistentOutput:!0},enabled:async()=>e&&Object.values((await n()).services??{}).some((p)=>p.build),task:async(p,d)=>{let m=await Sg(o,p.compose,i,{progress:(h)=>{d.output=h},stream:d.stdout()},{...s,request:t,snapshot:p.snapshot,workspaceRoot:p.workspaceRoot,signal:d.signal});p.buildImages=m.images,await s.postBuild?.(m,await a()),d.output=`Built ${m.built.length} image${m.built.length===1?"":"s"}`}},{title:"Resolve images",enabled:async()=>!e&&Object.values((await n()).services??{}).some((p)=>p.build),task:async(p,d)=>{p.buildImages=await sn(o,p.compose,{...s,request:t}),d.output=`${Object.keys(p.buildImages).length} images`}},{title:"Update workspace",task:async(p,d)=>{let m=await Y$(o,p.compose,p.snapshot,t),h=await t(uy(o),{method:cy,json:{workspaceUid:m.metadata.uid}});d.output=h.resourcesAdopted?`Adopted ${h.resourcesAdopted} existing resources`:"Workspace ready"}},{title:"Reconcile backing services",task:async(p,d)=>{let m={},h={};await d.newListr([{title:"Reconcile databases",enabled:()=>nt(p.compose).length>0,task:async(y,b)=>{let S=await At(o,t,`${l}/databases`,{method:"POST",json:{compose:p.compose}});m=iy(S),b.output=`${Object.keys(m).length} services`}},{title:"Reconcile S3 storage",enabled:()=>it(p.compose).length>0,task:async(y,b)=>{let S=await At(o,t,`${l}/storage`,{method:"POST",json:{compose:p.compose}});h=iy(S),b.output=`${Object.keys(h).length} services`}}],{concurrent:!0}).run(),p.serviceEnv=oy(oy(p.serviceEnv,m),h)}},{title:"Render manifests",task:async(p,d)=>{p.resources=await yn(o,p.compose,i,p.serviceEnv,p.buildImages),await s.postRender?.(p.resources,await a()),d.output=`${p.resources.length} resources`}},{title:"Reconcile resources",task:async(p,d)=>{p.plan=await sA(o,p.resources,t);let m=p.plan,h=m.desired.map(rc).filter((x)=>Boolean(x)),y=m.desired.filter((x)=>x.kind==="Deployment").map(rc).filter((x)=>Boolean(x)),b=m.stale.map(rc).filter((x)=>Boolean(x)),S=`${l}/resources`;return d.newListr([{title:"Apply resources",task:async(x,A)=>oc(A,"apply",h,(R,Z)=>tc(o,t,`${S}/apply`,{method:"POST",json:{resources:m.desired}},s.rolloutTimeoutMs,{onEvent:R,signal:Z}))},{title:"Run post-apply hook",skip:!s.postApply,task:async()=>s.postApply?.(m.desired,await a())},{title:"Wait for deployments",skip:y.length===0,task:async(x,A)=>oc(A,"wait",y,(R,Z)=>tc(o,t,`${S}/wait`,{method:"POST",json:{deployments:y.map((_e)=>_e.name),timeoutMs:s.rolloutTimeoutMs}},s.rolloutTimeoutMs,{onEvent:R,signal:Z}))},{title:"Delete stale resources",skip:b.length===0,task:async(x,A)=>oc(A,"delete",b,(R,Z)=>tc(o,t,`${S}/delete`,{method:"POST",json:{resources:m.stale}},s.rolloutTimeoutMs,{onEvent:R,signal:Z}))}])}}],{rendererOptions:{collapseErrors:!1}}).run()}var cy="POST",Z$=250,q$=5000,Q$=60000,W$,nc,cA;var _n=_(()=>{M();xt();q();ja();Xa();ee();yr();br();Fa();Bo();W$=new Set(["HTTP_502","HTTP_503","HTTP_504"]);nc=class nc extends Error{constructor(){super("Operation progress history was truncated; refusing to report an incomplete resource stream")}};cA=E({meta:{name:"up",description:"Create and start deployments"},args:{build:{type:"boolean",default:!0,alias:"b",description:"Build images before starting deployments",negativeDescription:"Don't build an image, even if it's policy"}},async run({args:e}){await _r(e.build)}})});function uA(e){let t=e?.trim();if(!t)throw Error("KUBER_API_KEY or --api-key is required for kuber ci");return t}function lA(e){return(t,r={},o={})=>{let n=new Headers(r.headers);return n.set("authorization",`Bearer ${e}`),k(t,{...r,headers:n},{...o,authenticated:!1})}}async function pA(e,t,r,o=lA(r)){let{project:n,cwd:i}=I(),s=await gt(n,i);if(t)await o(`/workspaces/${encodeURIComponent(n)}/trust`,{method:"POST",json:{fingerprint:s.fingerprint}});await _r(e,o,{trust:t?s:void 0})}var dA;var py=_(()=>{M();q();ee();Bo();_n();dA=E({meta:{name:"ci",description:"Deploy using an API key without a session"},args:{apiKey:{type:"string",description:"API key (defaults to KUBER_API_KEY)"},trust:{type:"boolean",description:"Grant current directory trust before deploying"},build:{type:"boolean",default:!0,negativeDescription:"Resolve existing images without building"}},async run({args:e}){await pA(e.build,Boolean(e.trust),uA(e.apiKey??process.env.KUBER_API_KEY))}})});function fA(e,t,r=k){return r(`/workspaces/${encodeURIComponent(e)}/databases/credentials`,{method:"POST",json:{claim:t}})}var mA,hA,gA;var dy=_(()=>{M();q();ee();yr();tt();mA=E({meta:{name:"ls",description:"List managed postgres claims"},async run(){let e=nt(await I().compose());if(e.length===0){console.log("No managed postgres volumes declared");return}console.log(le(e.map((t)=>({service:t.service,username:t.username,database:t.database,secret:t.secretName}))))}}),hA=E({meta:{name:"creds",description:"Print postgres credentials for a service"},async run({args:e}){let t=e._[0];if(!t)throw Error("Service name is required");let r=I(),o=nt(await r.compose()).find((s)=>s.service===t);if(!o)throw Error(`Service ${t} does not declare a managed postgres volume.`);let n=await fA(r.project,o),i=kg(o,n);console.log(le([{service:o.service,username:n.username,database:o.database,host:qa,port:Qa,secret:o.secretName}])),console.log(`DATABASE_URL=${i}`)}}),gA=E({meta:{name:"db",description:"Inspect managed postgres databases"},subCommands:{creds:hA,ls:mA}})});function yA(e,t=!1,r=k){return r(`/workspaces/${encodeURIComponent(e)}/down`,{method:"POST",json:{full:t}})}var bA;var fy=_(()=>{M();xt();q();ee();bA=E({meta:{name:"down",description:"Delete managed resources except ingress and PVCs"},args:{full:{type:"boolean",alias:"f",description:"Also delete ingress, PVCs, and the namespace"}},async run({args:e}){let{project:t}=I();await new de([{title:"Delete resources",task:async(r,o)=>{let n=await yA(t,e.full);o.output=`${n.delete.length} resources queued`}}]).run()}})});async function my(e,t,r=process.cwd(),o={}){let n=[...nt(t).length?["Postgres"]:[],...it(t).length?["S3"]:[]];if(n.length>0)throw Error(`Cannot export without generated ${n.join(" and ")} credentials. Export is side-effect-free; run kuber up or remove managed provider claims.`);let i=await sn(e,t,o);return yn(e,t,r,{},i)}var hy=_(()=>{Xa();yr();br();ja()});import{resolve as _A}from"path";var{YAML:wA}=globalThis.Bun;function vA(e){return`${Ag(e).map((t)=>wA.stringify(t,null,2).trimEnd()).join(`
|
|
98
|
+
`);if(s+=h,f=SE(h)-1,s+=Pv,y)s+=`
|
|
99
|
+
`,f++}let d=t+f,m=n.length-1-d;if(m>0)s+=ra(m);if(m<0)s+=No(-m);return s},HR,JR;var Xh=_(()=>{Om();Wm();ba();Pa();Fo();Zo();HR=tn(Yh.stdout),JR=tn(Yh.stderr)});function rn(e,t,r){if(e.charAt(t)===" ")return t;let o=r?1:-1;for(let n=0;n<=3;n++){let i=t+n*o;if(e.charAt(i)===" ")return i}return t}function CE(e,t,r,o){if(typeof e!=="string")throw TypeError(`Expected \`input\` to be a string, got ${typeof e}`);if(typeof t!=="number")throw TypeError(`Expected \`columns\` to be a number, got ${typeof t}`);if(!Number.isFinite(t))throw TypeError(`Expected \`columns\` to be a finite number, got ${t}`);if(!PE.has(r))throw TypeError(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${r}`);if(typeof o!=="string")throw TypeError(`Expected \`options.truncationCharacter\` to be a string, got ${typeof o}`)}function Ra(e,t,r={}){let{position:o="end",space:n=!1,preferTruncationOnSpace:i=!1}=r,{truncationCharacter:s="\u2026"}=r;if(CE(e,t,o,s),t<1)return"";let a=K(e);if(a<=t)return e;if(t===1)return s;let c={ESC:27,LEFT_BRACKET:91,LETTER_M:109},u=(m)=>m>=48&&m<=57||m===59;function l(m){let h=0;while(h+2<m.length&&m.codePointAt(h)===c.ESC&&m.codePointAt(h+1)===c.LEFT_BRACKET){let y=h+2;while(y<m.length&&u(m.codePointAt(y)))y++;if(y<m.length&&m.codePointAt(y)===c.LETTER_M){h=y+1;continue}break}return h}function f(m){let h=m.length;while(h>1&&m.codePointAt(h-1)===c.LETTER_M){let y=h-2;while(y>=0&&u(m.codePointAt(y)))y--;if(y>=1&&m.codePointAt(y-1)===c.ESC&&m.codePointAt(y)===c.LEFT_BRACKET){h=y-1;continue}break}return h}function d(m,h){let y=f(m);if(y===m.length)return m+h;return m.slice(0,y)+h+m.slice(y)}function p(m,h){let y=l(h);if(y===0)return m+h;return h.slice(0,y)+m+h.slice(y)}if(o==="start"){if(i){let h=rn(e,a-t+K(s),!0),y=se(e,h,a).trim();return p(s,y)}if(n)s+=" ";let m=se(e,a-t+K(s),a);return p(s,m)}if(o==="middle"){if(n){if(s=` ${s} `,K(s)>=t)s=s.trim()}let m=K(s),h=Math.min(Math.floor(t/2),Math.max(0,t-m));if(i){let y=rn(e,h),b=rn(e,a-(t-h)+m,!0);return se(e,0,y)+s+se(e,b,a).trim()}return se(e,0,h)+s+se(e,a-(t-h)+m,a)}if(o==="end"){if(i){let h=rn(e,t-K(s)),y=se(e,0,h);return d(y,s)}if(n)s=` ${s}`;let m=se(e,0,t-K(s));return d(m,s)}}var PE;var eg=_(()=>{Pa();Zo();PE=new Set(["start","middle","end"])});import RE,{setMaxListeners as TE}from"events";import{inspect as OE,styleText as IE}from"util";import{format as BE}from"util";import{EOL as Ae}from"os";import{StringDecoder as zE}from"string_decoder";import{Writable as DE}from"stream";import{randomUUID as NE}from"crypto";function ME(e){return!!e&&typeof e==="object"&&typeof e.subscribe==="function"}function FE(e){return!!e&&typeof e==="object"&&e.readable===!0&&typeof e.read==="function"&&typeof e.on==="function"}function ug(){return!!process.env.LISTR_FORCE_UNICODE||process.platform!=="win32"||!!process.env.CI||!!process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM==="xterm-256color"||process.env.TERM==="alacritty"}function hr(e){return String(e).replace(new RegExp(jE,"gmi"),"").trim()}function og(e,t){return e.replace(/^(?!\s*$)/gm," ".repeat(t))}function mr(e,...t){return BE(String(e),...t)}function QE(e){let t=new DE;return t.rows=1/0,t.columns=1/0,t.write=(r)=>(e(r.toString()),!0),t}function GE(e){let t=Math.floor(e/1000),r=Math.floor(t/60),o;if(t===0&&r===0)o=`0.${Math.floor(e/100)}s`;if(t>0)o=`${t%60}s`;if(r>0)o=`${r}m${o}`;return o}function tS(e){return process.stdout.isTTY===!0||e.nonTTY===!0}function on(e){if(typeof e==="string")return Ta[e]??Ta.default;return typeof e==="function"?e:Ta.default}function rS(e){if(Et(e?.silentRendererCondition))return{renderer:on("silent"),selection:"SILENT"};let t={renderer:on(e.renderer),options:e.rendererOptions,selection:"PRIMARY"};if(!tS(t.renderer)||Et(e?.fallbackRendererCondition))return{renderer:on(e.fallbackRenderer),options:e.fallbackRendererOptions,selection:"SECONDARY"};return t}function Et(e,...t){if(typeof e==="function")return e(...t);else return e}function nS(e){return new Promise((t)=>{setTimeout(t,e)})}var tg,ag,LE,cg=class{emitter=new RE;constructor(){this.emitter.setMaxListeners(0)}emit(e,t){this.emitter.emit(e,t)}on(e,t){if(!t)return;this.emitter.addListener(e,t)}once(e,t){if(!t)return;this.emitter.once(e,t)}off(e,t){if(t)this.emitter.off(e,t);else this.emitter.removeAllListeners(e)}complete(){this.emitter.removeAllListeners()}},VE,rg,UE,jE="(?:\\u001b|\\u009b)\\[[\\=><~/#&.:=?%@~_-]*[0-9]*[\\a-ln-tqyz=><~/#&.:=?%@~_-]+",z,lg,ZE,F,nn,pg,sn=class{options;process;constructor(e){this.options=e,this.options={useIcons:!0,toStderr:[],...e??{}},this.options.fields??={},this.options.fields.prefix??=[],this.options.fields.suffix??=[],this.process=this.options.processOutput??new qE}log(e,t,r){let o=this.format(e,t,r);if(this.options.toStderr.includes(e)){this.process.toStderr(o);return}this.process.toStdout(o)}toStdout(e,t,r=!0){this.process.toStdout(this.format(null,e,t),r)}toStderr(e,t,r=!0){this.process.toStderr(this.format(null,e,t),r)}wrap(e,t){if(!e)return e;return this.applyFormat(`[${e}]`,t)}splat(...e){let t=e.shift()??"";return e.length===0?t:mr(t,e)}suffix(e,...t){return t.filter(Boolean).forEach((r)=>{if(e+=this.spacing(e),typeof r==="string")e+=this.wrap(r);else if(typeof r==="object"){if(r.args??=[],typeof r.condition==="function"?!r.condition(...r.args):!(r.condition??!0))return e;e+=this.wrap(typeof r.field==="function"?r.field(...r.args):r.field,{format:r?.format(...r.args)})}}),e}prefix(e,...t){return t.filter(Boolean).forEach((r)=>{if(e=this.spacing(e)+e,typeof r==="string")e=this.wrap(r)+e;else if(typeof r==="object"){if(r.args??=[],typeof r.condition==="function"?!r.condition(...r.args):!(r.condition??!0))return e;e=this.wrap(typeof r.field==="function"?r.field(...r.args):r.field,{format:r?.format()})+e}}),e}fields(e,t){if(this.options?.fields?.prefix)e=this.prefix(e,...this.options.fields.prefix);if(t?.prefix)e=this.prefix(e,...t.prefix);if(t?.suffix)e=this.suffix(e,...t.suffix);if(this.options?.fields?.suffix)e=this.suffix(e,...this.options.fields.suffix);return e}icon(e,t){if(!e)return null;if(!t){let o=this.options.icon?.[e];t=typeof o==="function"?o():o}let r=this.options.color?.[e];if(t&&r)t=r(t);return t}format(e,t,r){if(!Array.isArray(t))t=[t];return t=this.splat(t.shift(),...t).toString().split(Ae).filter((o)=>!o||o.trim()!=="").map((o)=>this.style(e,this.fields(o,{prefix:Array.isArray(r?.prefix)?r.prefix:[r?.prefix],suffix:Array.isArray(r?.suffix)?r.suffix:[r?.suffix]}))).join(Ae),t}style(e,t){if(!e||!t)return t;let r=this.icon(e,!this.options.useIcons&&this.wrap(e));if(r)t=r+" "+t;return t}applyFormat(e,t){if(t?.format)return t.format(e);return e}spacing(e){return typeof e>"u"||e.trim()===""?"":" "}},Oa=class{options;buffer=[];decoder=new zE;constructor(e){this.options=e}get all(){return this.buffer}get last(){return this.buffer.at(-1)}get length(){return this.buffer.length}write(e,...t){let r=t[t.length-1];if(this.buffer.push({time:Date.now(),stream:this.options?.stream,entry:this.decoder.write(typeof e==="string"?Buffer.from(e,typeof t[0]==="string"?t[0]:void 0):Buffer.from(e))}),this.options?.limit)this.buffer=this.buffer.slice(-this.options.limit);if(typeof r==="function")r();return!0}reset(){this.buffer=[]}},ng=class{stream;method;buffer;constructor(e){this.stream=e,this.method=e.write,this.buffer=new Oa({stream:e})}get out(){let e=this;return new Proxy(this.stream,{get(t,r,o){if(r==="write")return e.write.bind(e);return Reflect.get(t,r,o)}})}hijack(){this.stream.write=this.buffer.write.bind(this.buffer)}release(){this.stream.write=this.method;let e=[...this.buffer.all];return this.buffer.reset(),e}write(...e){return this.method.apply(this.stream,e)}},qE=class{options;stream;active;constructor(e,t,r){this.options=r,this.stream={stdout:new ng(e??process.stdout),stderr:new ng(t??process.stderr)},this.options={dump:["stdout","stderr"],leaveEmptyLine:!0,...r}}get stdout(){return this.stream.stdout.out}get stderr(){return this.stream.stderr.out}hijack(){if(this.active)throw Error("ProcessOutput has been already hijacked!");this.stream.stdout.write(tg.CURSOR_HIDE),Object.values(this.stream).forEach((e)=>e.hijack()),this.active=!0}release(){let e=Object.entries(this.stream).map(([t,r])=>({name:t,buffer:r.release()})).filter((t)=>this.options.dump.includes(t.name)).flatMap((t)=>t.buffer).sort((t,r)=>t.time-r.time).map((t)=>({...t,entry:hr(t.entry)})).filter((t)=>t.entry);if(e.length>0){if(this.options.leaveEmptyLine)this.stdout.write(Ae);e.forEach((t)=>{(t.stream??this.stdout).write(t.entry+Ae)})}this.stream.stdout.write(tg.CURSOR_SHOW),this.active=!1}toStdout(e,t=!0){if(t)e=e+Ae;return this.stream.stdout.write(e)}toStderr(e,t=!0){if(t)e=e+Ae;return this.stream.stderr.write(e)}},WE=class{spinner=!ug()?["-","\\","|","/"]:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];id;spinnerPosition=0;spin(){this.spinnerPosition=++this.spinnerPosition%this.spinner.length}fetch(){return this.spinner[this.spinnerPosition]}isRunning(){return!!this.id}start(e,t=100){this.id=setInterval(()=>{if(this.spin(),e)e()},t)}stop(){clearInterval(this.id),this.id=void 0}},ig,Ia,KE,HE=class{tasks;options;static nonTTY=!0;static rendererOptions;static rendererTaskOptions;constructor(e,t){this.tasks=e,this.options=t}render(){}end(){}},JE,YE=class{options;constructor(e){this.options=e}serialize(e,t,r){return JSON.stringify(this.generate(e,t,r))}generate(e,t,r){let o={event:e,data:t};if(typeof this.options?.task!=="boolean"){let n=Object.fromEntries(this.options.task.map((i)=>{let s=r[i];if(typeof s==="function")return[i,s.call(r)];return[i,s]}));if(Object.keys(r).length>0)o.task=n}return o}},XE,eS,Ta,oS=class{concurrency;count;queue;constructor(e){this.concurrency=e.concurrency,this.count=0,this.queue=new Set}add(e){if(this.count<this.concurrency)return this.run(e);return new Promise((t)=>{let r=()=>t(this.run(e));this.queue.add(r)})}flush(){for(let e of this.queue){if(this.count>=this.concurrency)break;this.queue.delete(e),e()}}run(e){this.count++;let t=e(),r=()=>{this.count--,this.flush()};return t.then(r,()=>{this.queue.clear()}),t}},iS=class{task;constructor(e){this.task=e}get title(){return this.task.title}set title(e){e=Array.isArray(e)?e:[e],this.task.title$=mr(e.shift(),...e)}get output(){return this.task.output}set output(e){if(e===null){this.task.outputReset$=null;return}e=Array.isArray(e)?e:[e],this.task.output$=mr(e.shift(),...e)}set promptOutput(e){this.task.promptOutput$=e}get signal(){return this.task.listr.signal}cancel(){this.task.listr.cancel()}newListr(e,t){let r;if(typeof e==="function")r=e(this);else r=e;return new he(r,t,this.task)}report(e,t){if(this.task.options.collectErrors)this.task.listr.errors?.push(new VE(e,t,this.task));this.task.message$={error:e.message??this.task?.title}}skip(e,...t){if(this.task.state$="SKIPPED",e)this.task.message$={skip:e?mr(e,...t):this.task?.title}}isRetrying(){return this.task.isRetrying()?this.task.retry:{count:0}}prompt(e){if(this.task.prompt)return this.task.prompt;return new e(this.task,this)}stdout(e){return QE((t)=>{switch(e){case"PROMPT":this.promptOutput=t;break;default:this.output=t}})}run(e){return this.task.run(e,this)}},sS,aS,sg,he=class{task;options;parentTask;tasks=[];errors;ctx;events;path=[];rendererClass;rendererClassOptions;rendererSelection;boundSignalHandler;signal;concurrency;renderer;abortController;startedTasks=[];constructor(e,t,r){if(this.task=e,this.options=t,this.parentTask=r,this.options={concurrent:!1,renderer:"default",fallbackRenderer:"simple",exitOnError:!0,exitAfterRollback:!0,collectErrors:!1,registerSignalListeners:!0,...this.parentTask?.options??{},...t},this.options.concurrent===!0)this.options.concurrent=1/0;else if(typeof this.options.concurrent!=="number")this.options.concurrent=1;if(this.concurrency=new oS({concurrency:this.options.concurrent}),r)this.path=[...r.listr.path,r.title],this.errors=r.listr.errors;else this.errors=this.options.collectErrors?[]:null;if(this.parentTask?.listr.events instanceof sg)this.events=this.parentTask.listr.events;else this.events=new sg;if(this.parentTask?.listr.abortController instanceof AbortController)this.abortController=this.parentTask.listr.abortController;else this.abortController=new AbortController,TE(0,this.abortController.signal);if(this.signal=this.abortController.signal,this.options?.forceTTY||process.env.LISTR_FORCE_TTY)process.stdout.isTTY=!0,process.stderr.isTTY=!0;if(this.options?.forceUnicode)process.env.LISTR_FORCE_UNICODE="1";let o=rS({renderer:this.options.renderer,rendererOptions:this.options.rendererOptions,fallbackRenderer:this.options.fallbackRenderer,fallbackRendererOptions:this.options.fallbackRendererOptions,fallbackRendererCondition:this.options?.fallbackRendererCondition,silentRendererCondition:this.options?.silentRendererCondition});if(this.rendererClass=o.renderer,this.rendererClassOptions=o.options,this.rendererSelection=o.selection,this.add(e??[]),this.options.registerSignalListeners&&this.isRoot())this.boundSignalHandler=this.signalHandler.bind(this),process.on("SIGINT",this.boundSignalHandler).setMaxListeners(0)}isRoot(){return!this.parentTask}isSubtask(){return!!this.parentTask}add(e){this.tasks.push(...this.generate(e))}async run(e){if(!this.renderer)this.renderer=new this.rendererClass(this.tasks,this.rendererClassOptions,this.events);await this.renderer.render(),this.ctx=this.options?.ctx??e??{};let t,r=!1;try{await Promise.all(this.tasks.map((o)=>o.check(this.ctx))),await Promise.all(this.tasks.map((o)=>this.concurrency.add(()=>this.runTask(o))))}catch(o){r=!0,t=o}if(this.signal.aborted){if(await Promise.allSettled(this.startedTasks),this.isRoot())return this.cancelUnfinishedTasks(),this.renderer.end(),this.removeSignalHandler(),process.exit(127),this.ctx;throw t??Error("Interrupted.")}if(r&&this.options.exitOnError!==!1)throw this.renderer.end(t),this.removeSignalHandler(),t;if(!r)this.renderer.end(),this.removeSignalHandler();return this.ctx}cancel(){this.abortController.abort()}generate(e){return e=Array.isArray(e)?e:[e],e.map((t)=>{let r;if(this.rendererSelection==="PRIMARY")r=t.rendererOptions;else if(this.rendererSelection==="SECONDARY")r=t.fallbackRendererOptions;return new aS(this,t,this.options,this.rendererClassOptions,r)})}async runTask(e){if(!await e.check(this.ctx))return;let t=new iS(e).run(this.ctx);return this.startedTasks.push(t),t}signalHandler(){this.abortController.abort()}removeSignalHandler(){if(this.boundSignalHandler)process.removeListener("SIGINT",this.boundSignalHandler)}cancelUnfinishedTasks(e=this.tasks){for(let t of e){if(t.hasSubtasks())this.cancelUnfinishedTasks(t.subtasks);if(t.isEnabled()!==!1&&!t.hasFinalized())t.state$="CANCELLED"}}};var St=_(()=>{tg={CURSOR_HIDE:"\x1B[?25l",CURSOR_SHOW:"\x1B[?25h"},ag=function(e){return e.WILL_RETRY="WILL_RETRY",e.WILL_ROLLBACK="WILL_ROLLBACK",e.HAS_FAILED_TO_ROLLBACK="HAS_FAILED_TO_ROLLBACK",e.HAS_FAILED="HAS_FAILED",e.HAS_FAILED_WITHOUT_ERROR="HAS_FAILED_WITHOUT_ERROR",e}({}),LE=function(e){return e.WAITING="WAITING",e.STARTED="STARTED",e.COMPLETED="COMPLETED",e.FAILED="FAILED",e.SKIPPED="SKIPPED",e.ROLLING_BACK="ROLLING_BACK",e.ROLLED_BACK="ROLLED_BACK",e.RETRY="RETRY",e.PAUSED="PAUSED",e.PROMPT="PROMPT",e.PROMPT_COMPLETED="PROMPT_COMPLETED",e.PROMPT_FAILED="PROMPT_FAILED",e.CANCELLED="CANCELLED",e}({}),VE=class extends Error{error;type;task;path;constructor(e,t,r){super(e.message);this.error=e,this.type=t,this.task=r,this.name="ListrError",this.path=r.path,this.stack=e?.stack}},rg=class extends Error{},UE=class extends Error{};z=Object.fromEntries(Object.keys(OE.colors).map((e)=>[e,(t)=>IE(e,String(t))]));lg={warning:"\u26A0",cross:"\u2716",arrowDown:"\u2193",tick:"\u2714",arrowRight:"\u2192",pointer:"\u276F",checkboxOn:"\u2612",arrowLeft:"\u2190",squareSmallFilled:"\u25FC",pointerSmall:"\u203A",circleSlash:"\u2298"},ZE={...lg,warning:"\u203C",cross:"\xD7",tick:"\u221A",pointer:">",checkboxOn:"[\xD7]",squareSmallFilled:"\u25A0",circleSlash:"\xF8"},F=ug()?lg:ZE;nn={icon:{["STARTED"]:F.pointer,["FAILED"]:F.cross,["SKIPPED"]:F.arrowDown,["COMPLETED"]:F.tick,["OUTPUT"]:F.pointerSmall,["TITLE"]:F.arrowRight,["RETRY"]:F.warning,["ROLLBACK"]:F.arrowLeft,["PAUSED"]:F.squareSmallFilled,["CANCELLED"]:F.circleSlash},color:{["STARTED"]:z.yellow,["FAILED"]:z.red,["SKIPPED"]:z.yellow,["COMPLETED"]:z.green,["RETRY"]:z.yellowBright,["ROLLBACK"]:z.redBright,["PAUSED"]:z.yellowBright,["CANCELLED"]:z.red}},pg=["RETRY","ROLLBACK","FAILED"];ig={icon:{["SKIPPED_WITH_COLLAPSE"]:F.arrowDown,["SKIPPED_WITHOUT_COLLAPSE"]:F.warning,["OUTPUT"]:F.pointerSmall,["OUTPUT_WITH_BOTTOMBAR"]:F.pointerSmall,["PENDING"]:F.pointer,["COMPLETED"]:F.tick,["COMPLETED_WITH_FAILED_SUBTASKS"]:F.warning,["COMPLETED_WITH_SISTER_TASKS_FAILED"]:F.squareSmallFilled,["RETRY"]:F.warning,["ROLLING_BACK"]:F.warning,["ROLLED_BACK"]:F.arrowLeft,["FAILED"]:F.cross,["FAILED_WITH_SUBTASKS"]:F.pointer,["WAITING"]:F.squareSmallFilled,["PAUSED"]:F.squareSmallFilled,["CANCELLED"]:F.circleSlash},color:{["SKIPPED_WITH_COLLAPSE"]:z.yellow,["SKIPPED_WITHOUT_COLLAPSE"]:z.yellow,["PENDING"]:z.yellow,["COMPLETED"]:z.green,["COMPLETED_WITH_FAILED_SUBTASKS"]:z.yellow,["COMPLETED_WITH_SISTER_TASKS_FAILED"]:z.red,["RETRY"]:z.yellowBright,["ROLLING_BACK"]:z.redBright,["ROLLED_BACK"]:z.redBright,["FAILED"]:z.red,["FAILED_WITH_SUBTASKS"]:z.red,["WAITING"]:z.dim,["PAUSED"]:z.yellowBright,["CANCELLED"]:z.red}};Ia={condition:!0,field:GE,format:()=>z.dim},KE=class e{tasks;options;events;static nonTTY=!1;static rendererOptions={indentation:2,clearOutput:!1,showSubtasks:!0,collapseSubtasks:!0,collapseSkips:!0,showSkipMessage:!0,suffixSkips:!1,collapseErrors:!0,showErrorMessage:!0,suffixRetries:!0,lazy:!1,removeEmptyLines:!0,formatOutput:"wrap",pausedTimer:{...Ia,format:()=>z.yellowBright}};static rendererTaskOptions={outputBar:!0};prompt;activePrompt;spinner;logger;updater;truncate;wrap;buffer={output:new Map,bottom:new Map};cache={render:new Map,rendererOptions:new Map,rendererTaskOptions:new Map};constructor(t,r,o){this.tasks=t,this.options=r,this.events=o,this.options={...e.rendererOptions,...this.options,icon:{...ig.icon,...r?.icon??{}},color:{...ig.color,...r?.color??{}}},this.spinner=this.options.spinner??new WE,this.logger=this.options.logger??new sn({useIcons:!0,toStderr:[]}),this.logger.options.icon=this.options.icon,this.logger.options.color=this.options.color}async render(){await Promise.resolve().then(() => Xh());await Promise.resolve().then(() => eg());await Promise.resolve().then(() => ba());if(this.updater=tn(this.logger.process.stdout),this.truncate=Ra,this.wrap=ur,this.logger.process.hijack(),!this.options?.lazy)this.spinner.start(()=>{this.update()});this.events.on("SHOUD_REFRESH_RENDER",this.refresh)}update(){this.updater(this.create())}end(){if(this.spinner.stop(),this.events.off("SHOUD_REFRESH_RENDER",this.refresh),this.updater.clear(),this.updater.done(),!this.options.clearOutput)this.logger.process.toStdout(this.create({prompt:!1}));this.logger.process.release()}create(t){t={tasks:!0,bottomBar:!0,prompt:!0,...t};let r=[],o=this.renderer(this.tasks),n=this.renderBottomBar(),i=this.renderPrompt();if(t.tasks&&o.length>0)r.push(...o);if(t.bottomBar&&n.length>0){if(r.length>0)r.push("");r.push(...n)}if(t.prompt&&i.length>0){if(r.length>0)r.push("");r.push(...i)}return r.join(Ae)}style(t,r=!1){let o=this.cache.rendererOptions.get(t.id);if(t.isSkipped()){if(r||o.collapseSkips)return this.logger.icon("SKIPPED_WITH_COLLAPSE");else if(o.collapseSkips===!1)return this.logger.icon("SKIPPED_WITHOUT_COLLAPSE")}if(r){if(this.shouldOutputToBottomBar(t))return this.logger.icon("OUTPUT_WITH_BOTTOMBAR");return this.logger.icon("OUTPUT")}if(t.hasSubtasks()){if(t.isStarted()||t.isPrompt()&&o.showSubtasks!==!1&&!t.subtasks.every((n)=>!n.hasTitle()))return this.logger.icon("PENDING");else if(t.isCompleted()&&t.subtasks.some((n)=>n.hasFailed()))return this.logger.icon("COMPLETED_WITH_FAILED_SUBTASKS");else if(t.hasFailed())return this.logger.icon("FAILED_WITH_SUBTASKS")}if(t.isStarted()||t.isPrompt())return this.logger.icon("PENDING",!this.options?.lazy&&this.spinner.fetch());else if(t.isCompleted())return this.logger.icon("COMPLETED");else if(t.isRetrying())return this.logger.icon("RETRY",!this.options?.lazy&&this.spinner.fetch());else if(t.isRollingBack())return this.logger.icon("ROLLING_BACK",!this.options?.lazy&&this.spinner.fetch());else if(t.hasRolledBack())return this.logger.icon("ROLLED_BACK");else if(t.hasFailed())return this.logger.icon("FAILED");else if(t.isCancelled())return this.logger.icon("CANCELLED");else if(t.isPaused())return this.logger.icon("PAUSED");return this.logger.icon("WAITING")}format(t,r,o){if(t.trim()==="")return[];if(r)t=r+" "+t;let n,i=(this.logger.process.stdout.columns??80)-o*this.options.indentation-2;switch(this.options.formatOutput){case"truncate":n=t.split(Ae).map((s,a)=>this.truncate(this.indent(s,a),i));break;case"wrap":n=this.wrap(t,i,{hard:!0,trim:!1}).split(Ae).map((s,a)=>this.indent(s,a));break;default:throw new rg("Format option for the renderer is wrong.")}if(this.options.removeEmptyLines)n=n.filter(Boolean);return n.map((s)=>og(s,o*this.options.indentation))}shouldOutputToOutputBar(t){let r=this.cache.rendererTaskOptions.get(t.id).outputBar;return typeof r==="number"&&r!==0||typeof r==="boolean"&&r!==!1}shouldOutputToBottomBar(t){let r=this.cache.rendererTaskOptions.get(t.id).bottomBar;return typeof r==="number"&&r!==0||typeof r==="boolean"&&r!==!1||!t.hasTitle()}refresh=()=>{this.update()};renderer(t,r=0){return t.flatMap((o)=>{if(!o.isEnabled())return[];if(this.cache.render.has(o.id))return this.cache.render.get(o.id);this.calculate(o),this.setupBuffer(o);let n=this.cache.rendererOptions.get(o.id),i=this.cache.rendererTaskOptions.get(o.id),s=[];if(o.isPrompt()){if(this.activePrompt&&this.activePrompt!==o.id)throw new rg("Only one prompt can be active at the given time, please re-evaluate your task design.");else if(!this.activePrompt)o.on("PROMPT",(a)=>{let c=hr(a);if(c)this.prompt=c}),o.on("STATE",(a)=>{if(a==="PROMPT_COMPLETED"||o.hasFinalized()||o.hasReset())this.prompt=null,this.activePrompt=null,o.off("PROMPT")}),this.activePrompt=o.id}if(o.hasTitle())if(!(t.some((a)=>a.hasFailed())&&!o.hasFailed()&&o.options.exitOnError!==!1&&!(o.isCompleted()||o.isSkipped()||o.isCancelled())))if(o.hasFailed()&&n.collapseErrors)s.push(...this.format(!o.hasSubtasks()&&o.message.error&&n.showErrorMessage?o.message.error:o.title,this.style(o),r));else if(o.isSkipped()&&n.collapseSkips)s.push(...this.format(this.logger.suffix(o.message.skip&&n.showSkipMessage?o.message.skip:o.title,{field:"SKIPPED",condition:n.suffixSkips,format:()=>z.dim}),this.style(o),r));else if(o.isRetrying())s.push(...this.format(this.logger.suffix(o.title,{field:`RETRY:${o.message.retry.count}`,format:()=>z.yellow,condition:n.suffixRetries}),this.style(o),r));else if(o.isCompleted()&&o.hasTitle()&&Et(i.timer?.condition,o.message.duration))s.push(...this.format(this.logger.suffix(o?.title,{...i.timer,args:[o.message.duration]}),this.style(o),r));else if(o.isPaused())s.push(...this.format(this.logger.suffix(o.title,{...n.pausedTimer,args:[o.message.paused-Date.now()]}),this.style(o),r));else s.push(...this.format(o.title,this.style(o),r));else s.push(...this.format(o.title,this.logger.icon("COMPLETED_WITH_SISTER_TASKS_FAILED"),r));if(!o.hasSubtasks()||!n.showSubtasks){if(o.hasFailed()&&n.collapseErrors===!1&&(n.showErrorMessage||!n.showSubtasks))s.push(...this.dump(o,r,"FAILED"));else if(o.isSkipped()&&n.collapseSkips===!1&&(n.showSkipMessage||!n.showSubtasks))s.push(...this.dump(o,r,"SKIPPED"))}if(o.isPending()||i.persistentOutput)s.push(...this.renderOutputBar(o,r));if(n.showSubtasks!==!1&&o.hasSubtasks()&&(o.isPending()||o.hasFinalized()&&!o.hasTitle()||o.isCompleted()&&n.collapseSubtasks===!1&&!o.subtasks.some((a)=>this.cache.rendererOptions.get(a.id)?.collapseSubtasks===!0)||o.subtasks.some((a)=>this.cache.rendererOptions.get(a.id)?.collapseSubtasks===!1)||o.subtasks.some((a)=>a.hasFailed())||o.subtasks.some((a)=>a.hasRolledBack())||o.subtasks.some((a)=>a.isCancelled()))){let a=!o.hasTitle()?r:r+1,c=this.renderer(o.subtasks,a);s.push(...c)}if(o.hasFinalized()){if(!i.persistentOutput)this.buffer.bottom.delete(o.id),this.buffer.output.delete(o.id)}if(o.isClosed())this.cache.render.set(o.id,s),this.reset(o);return s})}renderOutputBar(t,r){let o=this.buffer.output.get(t.id);if(!o)return[];return o.all.flatMap((n)=>this.dump(t,r,"OUTPUT",n.entry))}renderBottomBar(){if(this.buffer.bottom.size===0)return[];return Array.from(this.buffer.bottom.values()).flatMap((t)=>t.all).sort((t,r)=>t.time-r.time).map((t)=>t.entry)}renderPrompt(){if(!this.prompt)return[];return[this.prompt]}calculate(t){if(this.cache.rendererOptions.has(t.id)&&this.cache.rendererTaskOptions.has(t.id))return;let r={...this.options,...t.rendererOptions};this.cache.rendererOptions.set(t.id,r),this.cache.rendererTaskOptions.set(t.id,{...e.rendererTaskOptions,timer:r.timer,...t.rendererTaskOptions})}setupBuffer(t){if(this.buffer.bottom.has(t.id)||this.buffer.output.has(t.id))return;if(t.hasFinalized())return;let r=this.cache.rendererTaskOptions.get(t.id);if(this.shouldOutputToBottomBar(t)&&!this.buffer.bottom.has(t.id))this.buffer.bottom.set(t.id,new Oa({limit:typeof r.bottomBar==="number"?r.bottomBar:1})),t.on("OUTPUT",(o)=>{let n=this.dump(t,-1,"OUTPUT",o);this.buffer.bottom.get(t.id).write(n.join(Ae))}),t.on("OUTPUT_RESET",()=>{this.buffer.bottom.get(t.id)?.reset()}),t.on("STATE",(o)=>{if(o==="RETRY"||o==="ROLLING_BACK")this.buffer.bottom.delete(t.id)});else if(this.shouldOutputToOutputBar(t)&&!this.buffer.output.has(t.id))this.buffer.output.set(t.id,new Oa({limit:typeof r.outputBar==="number"?r.outputBar:1})),t.on("OUTPUT",(o)=>{this.buffer.output.get(t.id).write(o)}),t.on("OUTPUT_RESET",()=>{this.buffer.output.get(t.id)?.reset()}),t.on("STATE",(o)=>{if(o==="RETRY"||o==="ROLLING_BACK")this.buffer.output.delete(t.id)})}reset(t){this.cache.rendererOptions.delete(t.id),this.cache.rendererTaskOptions.delete(t.id),this.buffer.output.delete(t.id)}dump(t,r,o="OUTPUT",n){if(!n)switch(o){case"OUTPUT":n=t.output;break;case"SKIPPED":n=t.message.skip;break;case"FAILED":n=t.message.error;break}if(t.hasTitle()&&o==="FAILED"&&n===t.title||typeof n!=="string")return[];if(o==="OUTPUT")n=hr(n);return this.format(n,this.style(t,!0),r+1)}indent(t,r){return r>0?og(t.trimEnd(),this.options.indentation):t.trimEnd()}},JE=class e{tasks;options;static nonTTY=!0;static rendererOptions={pausedTimer:{...Ia,field:(t)=>`PAUSED:${t}`,format:()=>z.yellowBright}};static rendererTaskOptions={};logger;cache={rendererOptions:new Map,rendererTaskOptions:new Map};constructor(t,r){if(this.tasks=t,this.options=r,this.options={...e.rendererOptions,...r,icon:{...nn.icon,...r?.icon??{}},color:{...nn.color,...r?.color??{}}},this.logger=this.options.logger??new sn({useIcons:!0,toStderr:pg}),this.logger.options.icon=this.options.icon,this.logger.options.color=this.options.color,this.options.timestamp)this.logger.options.fields.prefix.unshift(this.options.timestamp)}end(){}render(){this.renderer(this.tasks)}renderer(t){t.forEach((r)=>{this.calculate(r),r.once("CLOSED",()=>{this.reset(r)});let o=this.cache.rendererOptions.get(r.id),n=this.cache.rendererTaskOptions.get(r.id);r.on("SUBTASK",(i)=>{this.renderer(i)}),r.on("STATE",(i)=>{if(!r.hasTitle())return;if(i==="STARTED")this.logger.log("STARTED",r.title);else if(i==="COMPLETED"){let s=n?.timer;this.logger.log("COMPLETED",r.title,s&&{suffix:{...s,condition:!!r.message?.duration&&s.condition,args:[r.message.duration]}})}else if(i==="PROMPT")this.logger.process.hijack(),r.on("PROMPT",(s)=>{this.logger.process.toStderr(s,!1)});else if(i==="PROMPT_COMPLETED")r.off("PROMPT"),this.logger.process.release();else if(i==="CANCELLED")this.logger.log("CANCELLED",r.title)}),r.on("OUTPUT",(i)=>{this.logger.log("OUTPUT",i)}),r.on("MESSAGE",(i)=>{if(i.error)this.logger.log("FAILED",r.title,{suffix:{field:`FAILED: ${i.error}`,format:()=>z.red}});else if(i.skip)this.logger.log("SKIPPED",r.title,{suffix:{field:`SKIPPED: ${i.skip}`,format:()=>z.yellow}});else if(i.rollback)this.logger.log("ROLLBACK",r.title,{suffix:{field:`ROLLBACK: ${i.rollback}`,format:()=>z.red}});else if(i.retry)this.logger.log("RETRY",r.title,{suffix:{field:`RETRY:${i.retry.count}`,format:()=>z.red}});else if(i.paused){let s=o?.pausedTimer;this.logger.log("PAUSED",r.title,s&&{suffix:{...s,condition:!!i?.paused&&s.condition,args:[i.paused-Date.now()]}})}})})}calculate(t){if(this.cache.rendererOptions.has(t.id)&&this.cache.rendererTaskOptions.has(t.id))return;let r={...this.options,...t.rendererOptions};this.cache.rendererOptions.set(t.id,r),this.cache.rendererTaskOptions.set(t.id,{...e.rendererTaskOptions,timer:r.timer,...t.rendererTaskOptions})}reset(t){this.cache.rendererOptions.delete(t.id),this.cache.rendererTaskOptions.delete(t.id)}},XE=class e{tasks;options;static nonTTY=!0;static rendererOptions={subtasks:!0,state:Object.values(LE),output:!0,prompt:!0,title:!0,messages:["skip","error","retry","rollback","paused"],messagesToStderr:["error","rollback","retry"],task:["hasRolledBack","isRollingBack","isCompleted","isSkipped","hasFinalized","hasSubtasks","title","hasReset","hasTitle","isPrompt","isPaused","isPending","isCancelled","isStarted","hasFailed","isEnabled","isRetrying","path"]};static rendererTaskOptions;logger;serializer;constructor(t,r){this.tasks=t,this.options=r,this.options={...e.rendererOptions,...this.options},this.logger=this.options.logger??new sn({useIcons:!1}),this.serializer=new YE(this.options)}render(){this.renderer(this.tasks)}end(){}renderer(t){t.forEach((r)=>{if(this.options.subtasks)r.on("SUBTASK",(o)=>{this.renderer(o)});if(this.options.state)r.on("STATE",(o)=>{this.logger.toStdout(this.serializer.serialize("STATE",o,r))});if(this.options.output)r.on("OUTPUT",(o)=>{this.logger.toStdout(this.serializer.serialize("OUTPUT",o,r))});if(this.options.prompt)r.on("PROMPT",(o)=>{this.logger.toStdout(this.serializer.serialize("PROMPT",o,r))});if(this.options.title)r.on("TITLE",(o)=>{this.logger.toStdout(this.serializer.serialize("TITLE",o,r))});r.on("MESSAGE",(o)=>{let n=Object.fromEntries(Object.entries(o).map(([i,s])=>{if(this.options.messages.includes(i))return[i,s]}).filter(Boolean));if(Object.keys(n).length>0){let i=this.serializer.serialize("MESSAGE",n,r);if(this.options.messagesToStderr.some((s)=>Object.keys(n).includes(s)))this.logger.toStderr(i);else this.logger.toStdout(i)}})})}},eS=class e{tasks;options;static nonTTY=!0;static rendererOptions={logTitleChange:!1,pausedTimer:{...Ia,format:()=>z.yellowBright}};static rendererTaskOptions;logger;cache={rendererOptions:new Map,rendererTaskOptions:new Map};constructor(t,r){if(this.tasks=t,this.options=r,this.options={...e.rendererOptions,...this.options,icon:{...nn.icon,...r?.icon??{}},color:{...nn.color,...r?.color??{}}},this.logger=this.options.logger??new sn({useIcons:!1,toStderr:pg}),this.logger.options.icon=this.options.icon,this.logger.options.color=this.options.color,this.options.timestamp)this.logger.options.fields.prefix.unshift(this.options.timestamp)}render(){this.renderer(this.tasks)}end(){}renderer(t){t.forEach((r)=>{this.calculate(r),r.once("CLOSED",()=>{this.reset(r)});let o=this.cache.rendererOptions.get(r.id),n=this.cache.rendererTaskOptions.get(r.id);if(r.on("SUBTASK",(i)=>{this.renderer(i)}),r.on("STATE",(i)=>{if(!r.hasTitle())return;if(i==="STARTED")this.logger.log("STARTED",r.title);else if(i==="COMPLETED"){let s=n.timer;this.logger.log("COMPLETED",r.title,s&&{suffix:{...s,condition:!!r.message?.duration&&s.condition,args:[r.message.duration]}})}else if(i==="CANCELLED")this.logger.log("CANCELLED",r.title)}),r.on("OUTPUT",(i)=>{this.logger.log("OUTPUT",i)}),r.on("PROMPT",(i)=>{let s=hr(i);if(s)this.logger.log("PROMPT",s)}),this.options?.logTitleChange!==!1)r.on("TITLE",(i)=>{this.logger.log("TITLE",i)});r.on("MESSAGE",(i)=>{if(i?.error)this.logger.log("FAILED",i.error);else if(i?.skip)this.logger.log("SKIPPED",i.skip);else if(i?.rollback)this.logger.log("ROLLBACK",i.rollback);else if(i?.retry)this.logger.log("RETRY",r.title,{suffix:i.retry.count.toString()});else if(i?.paused){let s=o?.pausedTimer;this.logger.log("PAUSED",r.title,s&&{suffix:{...s,condition:!!i?.paused&&s.condition,args:[i.paused-Date.now()]}})}})})}calculate(t){if(this.cache.rendererOptions.has(t.id)&&this.cache.rendererTaskOptions.has(t.id))return;let r={...this.options,...t.rendererOptions};this.cache.rendererOptions.set(t.id,r),this.cache.rendererTaskOptions.set(t.id,{...e.rendererTaskOptions,timer:r.timer,...t.rendererTaskOptions})}reset(t){this.cache.rendererOptions.delete(t.id),this.cache.rendererTaskOptions.delete(t.id)}},Ta={default:KE,simple:JE,verbose:eS,test:XE,silent:HE};sS=class extends cg{},aS=class extends sS{listr;task;options;rendererOptions;rendererTaskOptions;id=NE();state="WAITING";subtasks;title;initialTitle;output;retry;message={};prompt;parent;enabled;taskFn;closed;constructor(e,t,r,o,n){super();if(this.listr=e,this.task=t,this.options=r,this.rendererOptions=o,this.rendererTaskOptions=n,t.title){let i=Array.isArray(t?.title)?t.title:[t.title];this.title=mr(i.shift(),...i),this.initialTitle=this.title}this.taskFn=t.task,this.parent=e.parentTask}set state$(e){if(this.state=e,this.emit("STATE",e),this.hasSubtasks()&&this.hasFailed()){for(let t of this.subtasks)if(t.state==="STARTED")t.state$="FAILED"}this.listr.events.emit("SHOUD_REFRESH_RENDER")}set output$(e){this.output=e,this.emit("OUTPUT",e),this.listr.events.emit("SHOUD_REFRESH_RENDER")}set outputReset$(e){this.output=e,this.emit("OUTPUT_RESET"),this.listr.events.emit("SHOUD_REFRESH_RENDER")}set promptOutput$(e){if(this.emit("PROMPT",e),hr(e))this.listr.events.emit("SHOUD_REFRESH_RENDER")}set message$(e){this.message={...this.message,...e},this.emit("MESSAGE",e),this.listr.events.emit("SHOUD_REFRESH_RENDER")}set title$(e){this.title=e,this.emit("TITLE",e),this.listr.events.emit("SHOUD_REFRESH_RENDER")}get path(){return[...this.listr.path,this.initialTitle]}async check(e){if(this.state==="WAITING")this.enabled=await Et(this.task?.enabled??!0,e),this.emit("ENABLED",this.enabled),this.listr.events.emit("SHOUD_REFRESH_RENDER");return this.enabled}hasSubtasks(){return this.subtasks?.length>0}hasFinalized(){return this.isCompleted()||this.hasFailed()||this.isSkipped()||this.hasRolledBack()||this.isCancelled()}isPending(){return this.isStarted()||this.isPrompt()||this.hasReset()}isStarted(){return this.state==="STARTED"}isSkipped(){return this.state==="SKIPPED"}isCompleted(){return this.state==="COMPLETED"}hasFailed(){return this.state==="FAILED"}isCancelled(){return this.state==="CANCELLED"}isRollingBack(){return this.state==="ROLLING_BACK"}hasRolledBack(){return this.state==="ROLLED_BACK"}isRetrying(){return this.state==="RETRY"}hasReset(){return this.state==="RETRY"||this.state==="ROLLING_BACK"}isEnabled(){return this.enabled}hasTitle(){return typeof this?.title==="string"}isPrompt(){return this.state==="PROMPT"}isPaused(){return this.state==="PAUSED"}isClosed(){return this.closed}async pause(e){let t=this.state;this.state$="PAUSED",this.message$={paused:Date.now()+e},await nS(e),this.state$=t,this.message$={paused:null}}async run(e,t){let r=(i)=>{if(i instanceof he)i.options={...this.options,...i.options},i.rendererClass=on("silent"),this.subtasks=i.tasks,i.errors=this.listr.errors,this.emit("SUBTASK",this.subtasks),i=i.run(e);else if(i instanceof Promise)i=i.then(r);else if(FE(i))i=new Promise((s,a)=>{i.on("data",(c)=>{this.output$=c.toString()}),i.on("error",(c)=>a(c)),i.on("end",()=>s(null))});else if(ME(i))i=new Promise((s,a)=>{i.subscribe({next:(c)=>{this.output$=c},error:a,complete:s})});return i},o=Date.now();this.state$="STARTED";let n=await Et(this.task?.skip??!1,e);if(n){if(typeof n==="string")this.message$={skip:n};else if(this.hasTitle())this.message$={skip:this.title};else this.message$={skip:"Skipped task without a title."};this.state$="SKIPPED";return}try{let i=typeof this.task?.retry==="number"&&this.task.retry>0?this.task.retry+1:typeof this.task?.retry==="object"&&this.task.retry.tries>0?this.task.retry.tries+1:1,s=typeof this.task.retry==="object"&&this.task.retry.delay;for(let a=1;a<=i;a++)try{await Promise.race([r(this.taskFn(e,t)),this.whenInterrupted()]);break}catch(c){if(this.listr.signal.aborted)throw c;if(a!==i){if(this.retry={count:a,error:c},this.message$={retry:this.retry},this.title$=this.initialTitle,this.output=void 0,t.report(c,"WILL_RETRY"),this.state$="RETRY",s)await this.pause(s)}else throw c}if(this.isStarted()||this.isRetrying())this.message$={duration:Date.now()-o},this.state$="COMPLETED"}catch(i){if(this.prompt instanceof UE)i=this.prompt;if(this.task?.rollback){t.report(i,"WILL_ROLLBACK");try{this.state$="ROLLING_BACK",await this.task.rollback(e,t),this.message$={rollback:this.title},this.state$="ROLLED_BACK"}catch(s){throw this.state$="FAILED",t.report(s,"HAS_FAILED_TO_ROLLBACK"),this.close(),s}if(this.listr.options?.exitAfterRollback!==!1)throw this.close(),i}else{if(this.listr.signal.aborted)throw this.state$="CANCELLED",i;if(this.state$="FAILED",this.listr.options.exitOnError!==!1&&await Et(this.task?.exitOnError,e)!==!1)throw t.report(i,"HAS_FAILED"),this.close(),i;else if(!this.hasSubtasks())t.report(i,"HAS_FAILED_WITHOUT_ERROR")}}finally{this.close()}}close(){this.emit("CLOSED"),this.listr.events.emit("SHOUD_REFRESH_RENDER"),this.complete()}whenInterrupted(){return new Promise((e,t)=>{let r=()=>{if(!this.hasSubtasks())t(Error("Interrupted."))};if(this.listr.signal.aborted){r();return}this.listr.signal.addEventListener("abort",r,{once:!0})})}},sg=class extends cg{}});function cS(e){return typeof e==="string"&&/^sha256:[a-f0-9]{64}$/.test(e)}function dg(e){if(!cS(e))throw Error(`Invalid SHA-256 digest: ${e}`)}var gr=1;import{AsyncLocalStorage as uS}from"async_hooks";function Ba(e){return e["x-arch"]==="amd64"?"amd64":"arm64"}function fg(e){if(Ba(e)!=="amd64")return{};return{nodeSelector:{"kubernetes.io/arch":"amd64"},tolerations:[{key:"arch",operator:"Equal",value:"amd64",effect:"NoExecute"}]}}var CT;var za=_(()=>{CT=new uS});import{execFile as lS,spawn as pS}from"child_process";import{createHash as dS}from"crypto";import{constants as Da}from"fs";import{access as fS}from"fs/promises";import{chmod as DT,lstat as mS,mkdir as NT,open as hS,readdir as gg,readlink as gS,realpath as yS,symlink as LT,readFile as bS}from"fs/promises";import{delimiter as _S,dirname as wS,isAbsolute as La,relative as yr,resolve as $t,sep as br}from"path";import{promisify as vS}from"util";async function Ua(){for(let e of(process.env.PATH??"").split(_S)){if(!e)continue;try{return await fS($t(e,process.platform==="win32"?"git.exe":"git"),Da.X_OK),!0}catch{}}return!1}function Na(e){return`sha256:${dS("sha256").update(e).digest("hex")}`}function yg(e){if(!e||e.includes("\x00")||e.includes("\\")||La(e)||e.split("/").some((t)=>!t||t==="."||t===".."))throw Error(`Unsafe workspace path: ${JSON.stringify(e)}`)}function mg(e,t){let r=yr(e,t);return r===""||!r.startsWith(`..${br}`)&&r!==".."&&!La(r)}async function hg(e,t){let{stdout:r}=await Va("git",["-C",e,"ls-files","-z",...t],{encoding:"buffer",maxBuffer:67108864}),o=new TextDecoder("utf-8",{fatal:!0}),n=[],i=0;for(let s=r.indexOf(0);s!==-1;s=r.indexOf(0,i)){if(s>i)n.push(o.decode(r.subarray(i,s)));i=s+1}return n}async function xS(e){let[t,r]=await Promise.all([hg(e,["--cached","--others","--exclude-standard"]),hg(e,["--others","--ignored","--exclude-standard","--",".env*","**/.env*"])]);return[...new Set([...t,...r])].sort((o,n)=>Buffer.from(o).compare(Buffer.from(n)))}async function ES(e){let t=[],r=new Set([".git",".hg",".svn","node_modules","vendor","bower_components",".venv","venv","__pycache__",".tox",".mypy_cache",".pytest_cache",".next",".nuxt",".svelte-kit",".cache",".turbo","dist","build","coverage","target","out","tmp","temp"]),o=/(?:^|[-_.])(?:secrets?|credentials?|configs?)(?:$|[-_.])/i,n=[],i=async(c)=>{try{let u=await bS($t(c,".gitignore"),"utf8");for(let l of u.split(/\r?\n/)){let f=l.trim();if(!f||f.startsWith("#"))continue;if(f.startsWith("!"))continue;let d=f.replace(/^\//,"");if(d)n.push({base:yr(e,c).split(br).join("/"),pattern:d.replace(/\/$/,""),directory:f.endsWith("/")})}}catch(u){if(u.code!=="ENOENT")throw u}},s=(c,u)=>{let l=!1;for(let f of n){let d=f.base?`${f.base}/`:"";if(f.base&&c!==f.base&&!c.startsWith(d))continue;let p=f.base&&c.startsWith(d)?c.slice(d.length):c,m=f.pattern.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"__DOUBLESTAR__").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]").replace(/__DOUBLESTAR__/g,".*"),h=new RegExp(`^(?:${m})(?:/.*)?$`),y=new RegExp(`^(?:${m})$`);if((h.test(p)||p.split("/").some((b)=>y.test(b)))&&(!f.directory||u||p.includes("/")))l=!0}return l},a=async(c)=>{await i(c);for(let u of await gg(c,{withFileTypes:!0})){let l=$t(c,u.name),f=yr(e,l).split(br).join("/");if(u.isDirectory()){if(r.has(u.name)||o.test(u.name)||s(f,!0))continue;await a(l)}else if(u.isFile()||u.isSymbolicLink()){if(s(f,!1))continue;if(/^\.env/i.test(u.name)||/(?:secret|credential|password|token|private[-_.]?key)/i.test(u.name)||/^(?:id_rsa|id_ed25519|known_hosts|config\.json|\.npmrc|\.pypirc|\.netrc)$/i.test(u.name))continue;t.push(f)}else throw Error(`Special files are not allowed in workspaces: ${yr(e,l).split(br).join("/")}`)}};return await a(e),t.sort((c,u)=>Buffer.from(c).compare(Buffer.from(u)))}async function SS(e){if(!await Ua())return!1;try{return await Va("git",["-C",e,"rev-parse","--show-toplevel"]),!0}catch(t){let{code:r,exitCode:o}=t,n=t instanceof Error?t.message:String(t);if(r==="ENOENT")return!1;if(o===128||r===128||/not a git repository/i.test(n))return!1;throw t}}async function $S(e){let t=await Va("git",["-C",e,"ls-files","--others","--ignored","--exclude-standard","--directory","-z"],{encoding:"buffer",maxBuffer:67108864}),r=new TextDecoder("utf-8",{fatal:!0}),o=new Set,n=0;for(let m=t.stdout.indexOf(0);m!==-1;m=t.stdout.indexOf(0,n)){if(m>n){let h=r.decode(t.stdout.subarray(n,m));if(h.endsWith("/"))o.add(h.slice(0,-1))}n=m+1}let i=[],s=async(m)=>{for(let h of await gg(m,{withFileTypes:!0})){if(m===e&&h.name===".git")continue;let y=$t(m,h.name),b=yr(e,y).split(br).join("/");if(h.isDirectory()){if(!o.has(b))await s(y)}else if(!h.isFile()&&!h.isSymbolicLink())i.push(b)}};if(await s(e),i.length===0)return;let a=Buffer.from(`${i.join("\x00")}\x00`),c=pS("git",["-C",e,"check-ignore","--stdin","-z"]),u=[],l=[];c.stdout.on("data",(m)=>u.push(m)),c.stderr.on("data",(m)=>l.push(m));let f=new Promise((m,h)=>{c.once("error",h),c.once("close",(y)=>{if(y===0||y===1)m();else h(Error(Buffer.concat(l).toString("utf8")||`git check-ignore exited with ${y}`))})});c.stdin.end(a),await f;let d=Buffer.concat(u),p=new Set;n=0;for(let m=d.indexOf(0);m!==-1;m=d.indexOf(0,n)){if(m>n)p.add(r.decode(d.subarray(n,m)));n=m+1}for(let m of i){let h=m.slice(m.lastIndexOf("/")+1);if(!p.has(m)||h.startsWith(".env"))throw Error(`Special files are not allowed in workspaces: ${m}`)}}function AS(e){return JSON.stringify({version:e.version,files:e.files.map((t)=>({path:t.path,type:t.type,digest:t.digest,size:t.size,mode:t.mode}))})}function Ma(e){return PS(e),Buffer.from(AS(e))}function kS(e){return Na(Ma(e))}function PS(e){if(e.version!==gr||!Array.isArray(e.files))throw Error("Unsupported workspace manifest");let t="",r=new Set;for(let o of e.files){if(yg(o.path),dg(o.digest),!Number.isSafeInteger(o.size)||o.size<0)throw Error(`Invalid size for ${o.path}`);if(o.type==="file"&&o.mode!==420&&o.mode!==493||o.type==="symlink"&&o.mode!==511)throw Error(`Invalid mode for ${o.path}`);if(o.type!=="file"&&o.type!=="symlink")throw Error(`Invalid entry type for ${o.path}`);if(r.has(o.path))throw Error(`Duplicate workspace path: ${o.path}`);for(let n of o.path.split("/").slice(0,-1).map((i,s,a)=>a.slice(0,s+1).join("/")))if(r.has(n))throw Error(`Workspace entry is used as a directory: ${n}`);if(t&&Buffer.from(t).compare(Buffer.from(o.path))>=0)throw Error("Workspace files must be bytewise sorted");r.add(o.path),t=o.path}}async function an(e){let t=await yS(e),o=await SS(t)?await(async()=>(await $S(t),xS(t)))():await ES(t),n=[],i=new Map;for(let a of o){yg(a);let c=$t(t,a);if(!mg(t,c))throw Error(`Workspace path escapes root: ${a}`);let u;try{u=await mS(c)}catch(d){if(d.code==="ENOENT")continue;throw d}let l,f;if(u.isSymbolicLink()){let d=await gS(c);if(La(d)||!mg(t,$t(wS(c),d)))throw Error(`Symlink escapes workspace: ${a} -> ${d}`);l=Buffer.from(d),f={path:a,type:"symlink",digest:Na(l),size:l.byteLength,mode:511}}else if(u.isFile()){let d,p=await hS(c,Da.O_RDONLY|Da.O_NOFOLLOW);try{let m=await p.stat();if(!m.isFile())throw Error(`Not a regular file: ${a}`);d=m.mode&73?493:420,l=await p.readFile()}finally{await p.close()}f={path:a,type:"file",digest:Na(l),size:l.byteLength,mode:d}}else throw Error(`Special files are not allowed in workspaces: ${a}`);n.push(f),i.set(f.digest,l)}let s={version:gr,files:n};return{manifest:s,digest:kS(s),blobs:[...i].map(([a,c])=>({digest:a,data:c}))}}var Va;var Fa=_(()=>{Va=vS(lS)});import{randomUUID as CS}from"crypto";import{execFile as RS}from"child_process";import{isAbsolute as TS,relative as xg,resolve as bg,sep as Eg}from"path";import{promisify as OS}from"util";class $g{inflight=0;maxInflight;maxPerSecond;requestStarts=[];waiting=[];rateGate=Promise.resolve();clock;sleep;constructor(e){if(this.maxInflight=e?.maxInflight??NS,this.maxPerSecond=e?.maxPerSecond??LS,!Number.isSafeInteger(this.maxInflight)||this.maxInflight<1)throw RangeError("maxInflight must be a positive integer");if(!Number.isSafeInteger(this.maxPerSecond)||this.maxPerSecond<1)throw RangeError("maxPerSecond must be a positive integer");this.clock=e?.clock??{now:()=>Date.now()},this.sleep=e?.sleep??((t)=>Bun.sleep(t))}get currentInflight(){return this.inflight}get maxConcurrent(){return this.maxInflight}get currentRequestStarts(){return this.pruneOldStarts(),this.requestStarts.length}pruneOldStarts(){let e=this.clock.now()-1000;while(this.requestStarts.length>0&&this.requestStarts[0]<=e)this.requestStarts.shift()}async acquire(){if(this.inflight<this.maxInflight){this.inflight++;return}await new Promise((e)=>{this.waiting.push(e)})}release(){if(this.waiting.length>0)this.waiting.shift()();else this.inflight--}waitForRateLimit(){let e=this.rateGate.then(async()=>{for(;;){if(this.pruneOldStarts(),this.requestStarts.length<this.maxPerSecond){this.requestStarts.push(this.clock.now());return}let t=this.requestStarts[0];await this.sleep(Math.max(1,t+1000-this.clock.now()))}});return this.rateGate=e.catch(()=>{}),e}async run(e){await this.acquire();try{return await this.waitForRateLimit(),await e()}finally{this.release()}}}async function VS(e,t,r){let o=0,n=async()=>{for(;;){let i=o++;if(i>=e.length)return;await r(e[i])}};await Promise.all(Array.from({length:Math.min(t,e.length)},n))}function US(e,t){return xg(e,t).split(Eg).join("/")||"."}function wg(e,t,r,o){let n=xg(e,t);if(n.startsWith(`..${Eg}`)||n===".."||TS(n))throw Error(`${r} must stay inside the git repo for service ${o}`);return US(e,t)}function MS(e){if(!e.build||typeof e.build==="string"||!e.build.args)return[];if(Array.isArray(e.build.args))return[...e.build.args];return Object.entries(e.build.args).filter(([,t])=>t!==null).map(([t,r])=>`${t}=${String(r)}`)}function FS(e,t,r,o,n,i){if(!r.build)return;let s=r.build,a=typeof s==="string"?s:s.context??".";if(a.includes("://"))throw Error(`Remote build context is not supported for service ${t}`);if(typeof s!=="string"&&s.dockerfile_inline)throw Error(`dockerfile_inline is not supported for service ${t}`);let c=bg(o,a),u=wg(n,c,"Build context",t),l=typeof s==="string"||!s.dockerfile?void 0:bg(c,s.dockerfile);return{name:t,image:jS(e,t,i),context:u,dockerfile:l?wg(n,l,"Dockerfile",t):void 0,target:typeof s==="string"?void 0:s.target,buildArgs:MS(r)}}function jS(e,t,r=To){return`${r.replace(/\/+$/,"")}/kuber/${e}-${t}:latest`}async function ja(e){if(!await Ua())return e;try{let{stdout:t}=await IS("git",["-C",e,"rev-parse","--show-toplevel"]);return t.trim()}catch(t){if(t.code==="ENOENT")return e;throw t}}async function ZS(e,t,r,o,n){let i=`/blobs/${encodeURIComponent(e)}/uploads`,s=n?`?project=${encodeURIComponent(n)}`:"",a=`${i}${s}`,c=await o.run(()=>r(a,{method:"POST",json:{size:t.byteLength}})),u=c.offset;while(!c.complete&&u<t.byteLength){let l=t.subarray(u,u+BS),f=await o.run(()=>r(a,{method:"PATCH",headers:{"content-type":"application/octet-stream","upload-offset":String(u)},body:l}));if(f.offset<=u)throw Error(`Blob upload for ${e} made no progress`);u=f.offset}if(!c.complete)await o.run(()=>r(`${i}/complete${s}`,{method:"POST",json:{}}))}async function qS(e,t=C,r,o,n){let i=new Map(e.blobs.map((a)=>[a.digest,a.data]));i.set(e.digest,Ma(e.manifest));let s=o??new $g;for(;;){let a=await s.run(()=>t("/snapshots/negotiate",{method:"POST",json:{workspace:e.digest,...n&&{project:n}}}));if(a.ready)return;if(a.missing.length===0)throw Error("Snapshot negotiation is incomplete but reported no missing blobs");await VS(a.missing,s.maxConcurrent,async(c)=>{let u=i.get(c);if(!u)throw Error(`Server requested unknown workspace blob ${c}`);await r?.progress?.(`Uploading ${c}`),await ZS(c,u,t,s,n)})}}async function QS(e,t,r,o){if(e.type==="status"){let n=e.status.phase??(e.status.state==="succeeded"||e.status.state==="failed"?"done":e.status.state);if(!r?.has(n))r?.add(n),await t?.progress?.(`${o?`${o}: `:""}Build ${n}${e.status.state==="failed"?`: ${e.status.error??"unknown error"}`:""}`);return}if(t?.stream)t.stream.write(o?`[${o}] ${e.message}`:e.message);else await t?.progress?.(`${o?`${o}: `:""}${e.message.trimEnd()}`)}function WS(e){if(!(e instanceof Error)||e.name==="AbortError")return!1;if(e.name==="TimeoutError"||e instanceof TypeError)return!0;let t="code"in e&&typeof e.code==="string"?e.code:e.cause&&typeof e.cause==="object"&&("code"in e.cause)&&typeof e.cause.code==="string"?e.cause.code:void 0;return t==="ECONNABORTED"||t==="ECONNRESET"||t==="ECONNREFUSED"||t==="EAI_AGAIN"||t==="ETIMEDOUT"}async function vg(e,t,r,o,n,i){for(let s=1;s<=_g;s++)try{return i?.throwIfAborted(),await e(t,{...r,signal:i},{timeoutMs:DS})}catch(a){if(!WS(a)||s===_g)throw a;i?.throwIfAborted(),await n(o)}throw Error("Build poll retries exhausted")}async function GS(e,t,r,o,n,i,s,a=!1){let c=i,u=0,l="",f=new Map;for(let{name:d,reporter:p}of r)if(!f.has(p))f.set(p,{name:d,reporter:p,states:new Set});for(;;){let d=await vg(t,`/builds/${encodeURIComponent(e)}/events?after=${u}`,void 0,o,n,s);for(let p of d){if(p.type==="log"&&p.sequence<=u)continue;if(p.type==="log")l=(l+p.message).slice(-8192);for(let{name:m,reporter:h,states:y}of f.values())await QS(p,h,y,a?m:void 0);if(p.type==="log")u=p.sequence}if(c.state==="succeeded"||c.state==="failed"){let p=l.trim();if(c.state==="failed"&&p&&!c.error?.includes(p))return{...c,error:`${c.error??"BuildKit Job failed"}
|
|
100
|
+
${p}`};return c}if(c=await vg(t,`/builds/${encodeURIComponent(e)}/reconcile`,{method:"POST",json:{}},o,n,s),c.state!=="succeeded"&&c.state!=="failed")s?.throwIfAborted(),await n(o)}}async function cn(e,t,r={}){let o=r.request??C,n=Object.entries(t.services??{}).filter(([,a])=>a.build).map(([a])=>a),i=Array(n.length),s=0;return await Promise.all(Array.from({length:Math.min(Sg,n.length)},async()=>{for(;;){let a=s++;if(a>=n.length)return;let c=n[a];r.signal?.throwIfAborted();try{i[a]=(await o("/images/resolve",{method:"POST",json:{project:e,service:c},signal:r.signal})).reference}catch(u){throw Error(`Cannot resolve a published image for service ${c}. Run kuber up to build it.`,{cause:u})}}})),Object.fromEntries(n.map((a,c)=>[a,i[c]]))}async function Ag(e,t,r=process.cwd(),o,n={}){if(!Object.values(t.services??{}).some((x)=>x.build))return{built:[],changed:[],images:{}};let i=n.buildConcurrency??Sg;if(!Number.isSafeInteger(i)||i<1)throw RangeError("buildConcurrency must be a positive integer");let s=n.request??C,a=n.workspaceRoot;if(!a&&!n.snapshot)try{a=await ja(r)}catch(x){a=r}a??=r;let c=n.snapshot??await an(a),u=Object.entries(t.services??{}).flatMap(([x,k])=>{let T=FS(e,x,k,r,a,n.registry??To);return T?[T]:[]});await qS(c,s,o,n.scheduler,e);let l=Array(u.length),f=new Map(u.map((x)=>[x.name,o?.service?.(x.name)??o])),d=Ba(t),p=new Map;u.forEach((x,k)=>{let T=JSON.stringify({workspace:c.digest,architecture:d,context:x.context,dockerfile:x.dockerfile,target:x.target,buildArgs:x.buildArgs}),B=p.get(T)??[];B.push(k),p.set(T,B)});let m=[...p.values()],h=0,y,b=!1,P=async()=>{while(!b&&h<m.length){let x=m[h++],k=x.map((T)=>u[T]);try{n.signal?.throwIfAborted();for(let B of k)await f.get(B.name)?.progress?.(`${o?.service?"":`${B.name}: `}Build queued`);let T=await E(k);x.forEach((B)=>{let W=u[B],Te=B===x[0]?T.reference:T.references?.[W.name];if(!Te)throw Error(`Build result missing image for service ${W.name}`);l[B]=Te});for(let B of k)o?.settled?.(B.name)}catch(T){if(!b)y=T;b=!0;for(let B of k)o?.settled?.(B.name,T)}}},E=async(x)=>{let k=x[0],T=CS(),B={version:gr,id:T,project:e,service:k.name,...x.length>1&&{destinations:x.slice(1).map(({name:Ne,image:sb})=>({service:Ne,image:sb}))},spec:{architecture:d,image:k.image,context:k.context,dockerfile:k.dockerfile,target:k.target,buildArgs:k.buildArgs,workspace:c.digest}},W=await s("/builds",{method:"POST",json:B,signal:n.signal},{timeoutMs:300000}),Te=await GS(T,s,x.map(({name:Ne})=>({name:Ne,reporter:f.get(Ne)})),n.pollIntervalMs??zS,n.sleep??((Ne)=>Bun.sleep(Ne)),W,n.signal,!o?.service);if(Te.state!=="succeeded")throw Error(`Build failed for service ${k.name}: ${Te.error??"unknown error"}`);return await s(`/builds/${encodeURIComponent(T)}/result`,{signal:n.signal})};if(await Promise.all(Array.from({length:Math.min(i,m.length)},P)),b)throw y;let A=Object.fromEntries(u.map((x,k)=>[x.name,l[k]]));return{built:u.map((x)=>x.name),changed:u.map((x)=>x.name),images:A}}var IS,BS=8388608,zS=1000,DS=300000,_g=3,Sg=3,NS=20,LS=40;var Za=_(()=>{za();G();Oo();Fa();IS=OS(RS)});function kg(e){return KS[e.kind]??999}function Pg(e){return[...e].sort((t,r)=>kg(t)-kg(r))}var KS,oO,nO;var un=_(()=>{Fe();KS={Namespace:0,GarageBucket:1,GarageKey:2,ServiceAccount:3,ClusterRole:4,Role:5,ClusterRoleBinding:6,RoleBinding:7,StorageClass:8,PersistentVolumeClaim:9,Secret:10,ConfigMap:11,Service:12,Deployment:13,HorizontalPodAutoscaler:14,Ingress:15,IngressRoute:16},oO=`app.kubernetes.io/managed-by=${X["app.kubernetes.io/managed-by"]}`,nO=X["app.kubernetes.io/managed-by"]});function XS(e){return`${YS}-${e}`}function qa(e){return encodeURIComponent(e)}function Cg(e,t){return`postgresql://${qa(t.username)}:${qa(t.password)}@${Qa}:${Wa}/${qa(e.database)}`}function Rg(e){if(!e.startsWith("postgresql:"))return;let t=e.split(":");if(t.length!==2)throw Error(`Invalid postgres volume ${e}. Use postgresql:<name> or postgresql:<user>/<database>.`);let r=t[1]?.trim();if(!r)throw Error(`Invalid postgres volume ${e}. Use postgresql:<name> or postgresql:<user>/<database>.`);let o=r.split("/");if(o.length>2||o.some((s)=>s.trim()===""))throw Error(`Invalid postgres volume ${e}. Use postgresql:<name> or postgresql:<user>/<database>.`);let n=o[0],i=o[1]??n;return{username:n,database:i}}function Tg(e){return typeof e==="string"&&Rg(e)!==void 0}function e$(e,t){let r=t.volumes?.flatMap((o)=>{if(typeof o!=="string")return[];let n=Rg(o);return n?[{...n,service:e,secretName:XS(n.username)}]:[]})??[];if(r.length>1)throw Error(`Service ${e} declares multiple postgres volumes. Only zero or one postgresql:<...> entry is allowed per service.`);return r[0]}function st(e){let t=Object.entries(e.services??{}).flatMap(([o,n])=>{let i=e$(o,n);return i?[i]:[]}),r=new Map;for(let o of t){let n=r.get(o.database);if(n&&n!==o.username)throw Error(`Database ${o.database} is claimed by both ${n} and ${o.username}. A database can only have one owner.`);r.set(o.database,o.username)}return t}var JS="database",YS="postgres",Qa,Wa=5432;var _r=_(()=>{Fe();un();Qa=`c.${JS}.svc.cluster.local`});function ln(e,t){if(typeof e!=="object"||e===null||typeof t!=="object"||t===null)return t;let r=Array.isArray(e)?[...e]:{...e};for(let o of Object.keys(t)){let n=r[o],i=t[o];if(Array.isArray(n)&&Array.isArray(i))r[o]=[...n,...i];else if(n&&typeof n==="object"&&i&&typeof i==="object")r[o]=ln(n,i);else r[o]=i}return r}function Og(e){if(!e.startsWith("s3:"))return;let t=e.split(":");if(t.length!==2)throw Error(`Invalid S3 volume ${e}. Use s3:<name> or s3:<key>/<bucket>.`);let r=t[1]?.trim();if(!r)throw Error(`Invalid S3 volume ${e}. Use s3:<name> or s3:<key>/<bucket>.`);let o=r.split("/");if(o.length>2||o.some((s)=>s.trim()===""))throw Error(`Invalid S3 volume ${e}. Use s3:<name> or s3:<key>/<bucket>.`);let n=o[0],i=o[1]??n;return{key:n,bucket:i}}function Ig(e){return typeof e==="string"&&Og(e)!==void 0}function t$(e,t){let r=t.volumes?.flatMap((o)=>{if(typeof o!=="string")return[];let n=Og(o);return n?[{...n,service:e}]:[]})??[];if(r.length>1)throw Error(`Service ${e} declares multiple S3 volumes. Only zero or one s3:<...> entry is allowed per service.`);return r[0]}function at(e){let t=Object.entries(e.services??{}).flatMap(([o,n])=>{let i=t$(o,n);return i?[i]:[]}),r=new Map;for(let o of t){let n=r.get(o.key);if(n&&n!==o.bucket)throw Error(`S3 key ${o.key} is claimed for both ${n} and ${o.bucket}. A managed key can only target one bucket.`);r.set(o.key,o.bucket)}return t}var wr=_(()=>{Fe();un()});import{existsSync as Bg,readFileSync as r$,realpathSync as Ka,statSync as o$}from"fs";import{dirname as n$,isAbsolute as zg,normalize as i$,relative as s$,resolve as pn,sep as Dg}from"path";function At(e,t){return Object.assign(Error(e),t?{code:t}:{})}function a$(e){if(!e||e.includes("\x00")||e.includes("\\")||e.startsWith("~")||zg(e))throw At(`Artifact path must be workspace-relative: ${e}`);let t=i$(e);if(t===".."||t.startsWith(`..${Dg}`))throw At(`Artifact path escapes the workspace: ${e}`);return t.replace(/^\.\//,"")}function Ha(e,t){let r=s$(e,t);if(r===".."||r.startsWith(`..${Dg}`)||zg(r))throw At(`Artifact path escapes the workspace: ${t}`)}function c$(e,t){let r=t;while(!Bg(r)){let o=n$(r);if(o===r)break;r=o}Ha(e,Ka(r))}function Ga(e,t){if(t!==void 0&&(!Number.isSafeInteger(t)||t<0))throw Error(`${e} must be a non-negative safe integer`)}class Ng{#t;#r=0;#e=0;constructor(e){Ga("maxArtifactCount",e.maxArtifactCount),Ga("maxArtifactBytes",e.maxArtifactBytes),Ga("maxTotalBytes",e.maxTotalBytes),this.#t=e}add(e,t){let r=Buffer.byteLength(t);if(this.#t.maxArtifactBytes!==void 0&&r>this.#t.maxArtifactBytes)throw At(`Artifact ${e} exceeds the ${this.#t.maxArtifactBytes} byte limit`);if(this.#t.maxArtifactCount!==void 0&&this.#r+1>this.#t.maxArtifactCount)throw At(`Artifact count exceeds the ${this.#t.maxArtifactCount} limit`);if(this.#t.maxTotalBytes!==void 0&&this.#e+r>this.#t.maxTotalBytes)throw At(`Artifact bytes exceed the ${this.#t.maxTotalBytes} byte limit`);this.#r+=1,this.#e+=r}}class Qe{#t;#r;#e;constructor(e){this.#t=e.strict?Ka(e.workspace):pn(e.workspace),this.#r=e.strict??!1,this.#e=new Ng(e)}#o(e,t){if(!this.#r)return t.expandHome&&e.startsWith("~")?pn(process.env.HOME??"",e.slice(1)):pn(this.#t,e);let r=pn(this.#t,a$(e));return Ha(this.#t,r),c$(this.#t,r),r}isFile(e,t={}){let r=this.#o(e,t);return Bg(r)&&o$(r).isFile()}readText(e,t={}){let r=this.#o(e,t);if(this.#r)Ha(this.#t,Ka(r));let o=r$(r,"utf8");return this.#e.add(e,o),o}}var Lg=()=>{};import{createHash as Zg}from"crypto";import{basename as qg}from"path";function Qg(e){if(!e.diskTag&&e.replicaCount===void 0&&!e.dataLocality)return;return{diskTag:e.diskTag?[...e.diskTag].sort():void 0,replicaCount:e.replicaCount,dataLocality:e.dataLocality}}function Wg(e){return`kuber-longhorn-${Zg("sha256").update(JSON.stringify(e)).digest("hex").slice(0,12)}`}function ct(e){if(typeof e==="number")return e;if(!e||e.includes("-"))return;let t=Number(e);return Number.isInteger(t)?t:void 0}function Vg(e){if(typeof e!=="string"&&typeof e!=="number")return;let t=String(e).trim(),r=u$.exec(t);if(!r)return;let o=Number(r[1]),n=Number(r[2]);if(!Number.isInteger(o)||!Number.isInteger(n))return;if(o<1||n<1)throw Error(`Invalid replica range ${t}. Range bounds must be positive integers.`);if(o>n)throw Error(`Invalid replica range ${t}. Minimum (${o}) cannot exceed maximum (${n}).`);return{kind:"range",min:o,max:n}}function fn(e,t){if(t===void 0||t.trim()==="")return;let r=Number(t);if(!Number.isInteger(r)||r<0)throw Error(`Invalid ${e} value ${JSON.stringify(t)}. Expected a non-negative integer (zero allowed for a fixed replica count), a numeric string, or a "min-max" range.`)}function Ug(e){if(e.scale!==void 0){let t=ct(e.scale);if(t!==void 0)return fn("scale",String(e.scale)),t;fn("scale",String(e.scale))}if(e.deploy?.replicas!==void 0){let t=ct(e.deploy.replicas);if(t!==void 0)return fn("deploy.replicas",String(e.deploy.replicas)),t;fn("deploy.replicas",String(e.deploy.replicas))}return 1}function Gg(e){let t=Vg(e.scale);if(t)return Mg(t);if(e.scale!==void 0)return{kind:"fixed",value:Ug(e)};let r=Vg(e.deploy?.replicas);if(r)return Mg(r);return{kind:"fixed",value:Ug(e)}}function Mg(e){if(e.min===e.max)return{kind:"fixed",value:e.min};return e}function l$(e){if(e.kind==="range")return e.max>1;return e.value>1}function p$(e,t,r){if(t.build){let o=r[e];if(!o)throw Error(`Missing resolved build image for service ${e}`);return o}return t.image}function Ja(e){return e?.toUpperCase()==="UDP"?"UDP":"TCP"}function mn(e){if(!e)return;return/[a-z]/i.test(e)?e:void 0}function hn(e){return typeof e==="string"?JSON.stringify(e):String(e)}function Fg(e,t){let r=String(e).trim(),o=d$.exec(r);if(!o)throw Error(`Invalid ${t} value ${hn(e)}. Expected a non-negative finite decimal number of CPU cores.`);let n=BigInt(o[1]??"0"),i=o[2]??"",s=n*1000n+(i?BigInt(i.padEnd(3,"0").slice(0,3)):0n);if(i.slice(3).replaceAll("0","")!=="")throw Error(`Invalid ${t} value ${hn(e)}. CPU cores must be representable in whole millicores.`);return s%1000n===0n?String(s/1000n):`${s}m`}function jg(e,t){let r=e.trim(),o=f$.exec(r);if(!o)throw Error(`Invalid ${t} value ${hn(e)}. Expected a non-negative memory quantity.`);let n=o[1]??"",i=(()=>{switch(n.toLowerCase()){case"b":return"";case"k":case"kb":return"k";case"m":case"mb":return"M";case"g":case"gb":return"G";case"t":case"tb":return"T";case"p":case"pb":return"P";case"e":case"eb":return"E";default:return n}})();if(!["","n","u","m","k","M","G","T","P","E","Ki","Mi","Gi","Ti","Pi","Ei"].includes(i))throw Error(`Invalid ${t} value ${hn(e)}. Expected a valid Kubernetes or Compose memory quantity.`);return`${r.slice(0,r.length-n.length)}${i}`}function m$(e){let t=e.deploy?.resources;if(!t)return;let r={...t.limits?.cpus!==void 0?{cpu:Fg(t.limits.cpus,"deploy.resources.limits.cpus")}:{},...t.limits?.memory!==void 0?{memory:jg(t.limits.memory,"deploy.resources.limits.memory")}:{}},o={...t.reservations?.cpus!==void 0?{cpu:Fg(t.reservations.cpus,"deploy.resources.reservations.cpus")}:{},...t.reservations?.memory!==void 0?{memory:jg(t.reservations.memory,"deploy.resources.reservations.memory")}:{}};if(Object.keys(r).length===0&&Object.keys(o).length===0)return;return{...Object.keys(r).length>0?{limits:r}:{},...Object.keys(o).length>0?{requests:o}:{}}}function h$(e){if(typeof e==="boolean")return e;if(!e)return;switch(e.toLowerCase()){case"1":case"true":case"yes":case"on":case"ro":return!0;case"0":case"false":case"no":case"off":case"rw":return!1}}function gn(e){return e.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,63)}function Ya(e){if(e===void 0||e===null)return;let t=String(e).trim();if(!t)return;return t}function Kg(e){if(e===void 0||e===null)return;let t=(Array.isArray(e)?e:[e]).flatMap((r)=>String(r).split(",")).map((r)=>r.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}function Hg(e){if(e===void 0||e===null||e==="")return;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=20?t:void 0}function g$(e){let[t,r]=e.split(/\s+on\s+/i,2).map((n)=>n?.trim());if(!r)return{requestedStorage:Ya(t)};let o=/^(?:(?<replicas>\d+)\s+)?(?<tags>.+)$/.exec(r);return{requestedStorage:Ya(t),diskTag:Kg(o?.groups?.tags),replicaCount:Hg(o?.groups?.replicas),dataLocality:"none"}}function y$(e){let t=/^(?<name>[^()]+)\((?<size>[^()]+)\)$/.exec(e.trim());if(!t?.groups)return;let r=t.groups.name?.trim(),{requestedStorage:o,diskTag:n,replicaCount:i,dataLocality:s}=g$(t.groups.size??"");if(!r)return;return{source:r,requestedStorage:o,diskTag:n,replicaCount:i,dataLocality:s}}function Jg(e){if(!e||Xa(e))return{source:e};let t=y$(e);if(!t)return{source:e};if(!t.source)throw Error(`Invalid volume source ${e}. Expected name(size).`);return t}function Yg(e){return Ya(e?.["x-size"])}function Xg(e){return Kg(e?.["x-diskTag"])}function ey(e){return Hg(e?.["x-replicaCount"])}function ty(e){return e?.["x-dataLocality"]==="none"?"none":void 0}function ry(e){return gn(`bind-${Bun.hash(e).toString(36)}`)}function Xa(e){return e.startsWith(".")||e.startsWith("/")||e.startsWith("~")||e.includes("/")}function oy(e,t){return t.isFile(e,{expandHome:!0})}function b$(e,t,r){if(Tg(e)||Ig(e))return;let o=e.split(":");if(o.length===1)return{name:`volume-${t}`,kind:"volume",target:e};let n=o.at(-1),i=n==="ro"||n==="rw",s=o.at(i?-2:-1),a=o.slice(0,i?-2:-1).join(":");if(!s)return;let{source:c,requestedStorage:u,diskTag:l,replicaCount:f,dataLocality:d}=Jg(a||void 0);return{name:c&&Xa(c)?ry(c):`volume-${t}`,kind:c&&Xa(c)?oy(c,r)?"config-file":"bind":"volume",source:c||void 0,target:s,configKey:c?qg(c):void 0,readOnly:i?n==="ro":void 0,requestedStorage:u,diskTag:l,replicaCount:f,dataLocality:d}}function _$(e,t,r){if(typeof e==="string")return b$(e,t,r);if(!e.target)return;if(e.type!=="bind"&&e.type!=="volume"&&e.type!=="tmpfs")return;let{source:o,requestedStorage:n,diskTag:i,replicaCount:s,dataLocality:a}=Jg(e.source);return{name:o?e.type==="bind"?ry(o):`${e.type}-${gn(o)||t}`:`${e.type}-${t}`,kind:e.type==="bind"&&o&&oy(o,r)?"config-file":e.type,source:o,target:e.target,readOnly:h$(e.read_only),configKey:o?qg(o):void 0,subPath:e.volume?.subpath,sizeLimit:e.type==="tmpfs"&&e.tmpfs?.size!==void 0?String(e.tmpfs.size):void 0,requestedStorage:n??Yg(e.volume),diskTag:i??Xg(e.volume),replicaCount:s??ey(e.volume),dataLocality:a??ty(e.volume)}}function w$(e,t){if(!t||!e)return;let r=e[t];return Yg(r)}function v$(e,t){if(!t||!e)return;let r=e[t];return Xg(r)}function x$(e,t){if(!t||!e)return;let r=e[t];return ey(r)}function E$(e,t){if(!t||!e)return;let r=e[t];return ty(r)}function yn(e,t,r={}){let o=e.volumes?.flatMap((i,s)=>{let a=_$(i,s,t);if(!a)return[];return[{...a,requestedStorage:a.requestedStorage??w$(r,a.source)??(a.kind==="volume"&&a.source?dn.requestedStorage:void 0),diskTag:a.diskTag??v$(r,a.source)??(a.kind==="volume"&&a.source?dn.diskTag:void 0),replicaCount:a.replicaCount??x$(r,a.source)??(a.kind==="volume"&&a.source?dn.replicaCount:void 0),dataLocality:a.dataLocality??E$(r,a.source)??(a.kind==="volume"&&a.source?dn.dataLocality:void 0)}]})??[],n=(Array.isArray(e.tmpfs)?e.tmpfs:[e.tmpfs]).filter((i)=>Boolean(i)).map((i,s)=>({name:`tmpfs-${o.length+s}`,kind:"tmpfs",target:i}));return[...o,...n]}function S$(e){if(e.length===0)return;return e.map((t)=>({name:t.name,mountPath:t.target,readOnly:t.readOnly,subPath:t.kind==="config-file"?t.configKey:t.subPath}))}function $$(e,t){if(t.length===0)return;return t.map((r)=>{if(r.kind==="config-file")return{name:r.name,configMap:{name:r.name}};if(r.kind==="bind"){if(!r.source)return{name:r.name,emptyDir:{}};return{name:r.name,persistentVolumeClaim:{claimName:r.name}}}if(r.kind==="tmpfs")return{name:r.name,emptyDir:{medium:"Memory",sizeLimit:r.sizeLimit}};if(!r.source)return{name:r.name,emptyDir:{}};return{name:r.name,persistentVolumeClaim:{claimName:gn(`${e}-${r.source}`)}}})}function A$(e){return[...new Set(e.split(",").map((t)=>t.trim()).filter(Boolean).map((t)=>t.startsWith("/")?t:`/${t}`))]}function k$(e){let t=/^(?<portSpec>.+):protected(?:\((?<paths>[^)]*)\))?$/.exec(e);if(!t?.groups)return{portSpec:e};let r=t.groups.portSpec?.trim();if(!r)throw Error(`Invalid protected port syntax ${e}.`);let o=t.groups.paths?.trim();if(o===void 0)return{portSpec:r,routingKind:"ingressroute"};let n=A$(o);if(n.length===0)throw Error(`Invalid protected port syntax ${e}. Expected one or more paths.`);return{portSpec:r,routingKind:"ingressroute",paths:n}}function bn(e){let t=e.ports?.flatMap((o,n)=>{if(typeof o==="number")return[{name:`port-${n}`,containerPort:o,servicePort:o,protocol:"TCP"}];if(typeof o==="string"){let a=/\/(tcp|udp)$/i.exec(o),c=a?o.slice(0,-a[0].length):o,u=a?.[1];if(!c)return[];let{portSpec:l,routingKind:f,paths:d}=k$(c),p=l.split(":"),m=ct(p.at(-1));if(!m)return[];let h=ct(p.at(-2)),y=h!==void 0?mn(p.at(-3)):mn(p.at(-2));return[{name:`port-${n}`,containerPort:m,servicePort:h??m,hostPort:h,host:y,protocol:Ja(u),routingKind:y?f??"ingress":void 0,paths:d}]}let i=ct(o.target);if(!i)return[];let s=ct(o.published);return[{name:o.name??`port-${n}`,containerPort:i,servicePort:s??i,hostPort:s,host:mn(o.host_ip),protocol:Ja(o.protocol),routingKind:mn(o.host_ip)?"ingress":void 0}]})??[],r=e.expose?.flatMap((o,n)=>{let[i,s]=String(o).split("/"),a=ct(i);if(!a)return[];return[{name:`expose-${n}`,containerPort:a,servicePort:a,protocol:Ja(s)}]})??[];return[...t,...r]}function P$(e){if(e.length===0)return;let t=new Map;for(let r of e)t.set(`${r.containerPort}:${r.protocol}`,{name:r.name,containerPort:r.containerPort,hostPort:r.hostPort,protocol:r.protocol});return[...t.values()]}function C$(e){if(e.length===0)return;let t=new Map;for(let r of e)t.set(`${r.servicePort}:${r.protocol}`,{name:r.name,port:r.servicePort,targetPort:r.containerPort,protocol:r.protocol});return[...t.values()]}function R$(e,t){let r=new Set;return t.flatMap((o)=>{if(!o.host||o.routingKind==="ingressroute"||r.has(o.host))return[];return r.add(o.host),[{host:o.host,http:{paths:[{path:"/",pathType:"Prefix",backend:{service:{name:e,port:{number:o.servicePort}}}}]}}]})}function T$(e,t,r){let o=r.flatMap((n)=>{if(!n.host||n.routingKind!=="ingressroute")return[];return(n.paths&&n.paths.length>0?n.paths.map((s)=>`Host(\`${n.host}\`) && PathPrefix(\`${s}\`)`):[`Host(\`${n.host}\`)`]).map((s)=>({kind:"Rule",match:s,middlewares:[{name:"cf-auth",namespace:"routing"}],services:[{name:t,port:n.servicePort}]}))});if(o.length===0)return;return{apiVersion:"traefik.io/v1alpha1",kind:"IngressRoute",metadata:{name:t,namespace:e,labels:X},spec:{routes:o}}}function O$(e){if(!e)return[];return(Array.isArray(e)?e:[e]).map((r)=>typeof r==="string"?{path:r,required:!0}:{path:r.path,required:r.required!==!1&&r.required!=="false"})}function I$(e){let t={};for(let r of e.split(/\r?\n/)){let o=r.trim();if(!o||o.startsWith("#"))continue;let n=o.indexOf("=");if(n===-1)continue;let i=o.slice(0,n).trim(),s=o.slice(n+1);if(!i)continue;t[i]=s}return t}async function B$(e,t){let r={};for(let o of O$(e))try{let n=t.readText(o.path);Object.assign(r,I$(n))}catch(n){if(!o.required&&n&&typeof n==="object"&&"code"in n&&n.code==="ENOENT")continue;throw n}return r}function z$(e,t,r,o,n=process.cwd(),i={},s={},a={},c=new Qe({workspace:n}),u={}){let l=yn(o,c,s),f=bn(o),d=Boolean(o.env_file)||Object.keys(i).length>0,p=u.replicaSpec??Gg(o),m=p.kind==="range"?p.min:p.value,h=[ln({name:t,imagePullPolicy:"Always",env:um(o.environment),image:p$(t,o,a),command:o.command instanceof Array?o.command:o.command?o.command.split(" "):void 0,envFrom:d?[{secretRef:{name:`${t}-env`}}]:void 0,ports:P$(f),resources:m$(o),volumeMounts:S$(l)},o["x-container"]??{})],y={restartPolicy:"Always",...fg(r),volumes:$$(e,l),containers:h};if(l$(p))y.topologySpreadConstraints=[{maxSkew:1,topologyKey:"kubernetes.io/hostname",whenUnsatisfiable:"ScheduleAnyway",labelSelector:{matchLabels:{app:t}}}];return ln({apiVersion:"apps/v1",kind:"Deployment",metadata:{name:t,namespace:e,labels:X},spec:{replicas:m,strategy:{rollingUpdate:{maxSurge:"25%",maxUnavailable:"25%"}},selector:{matchLabels:{app:t}},template:{metadata:{labels:{app:t}},spec:y}}},o["x-deployment"]??{})}function D$(e,t,r){let o=C$(bn(r));if(!o)return;return{apiVersion:"v1",kind:"Service",metadata:{name:t,namespace:e,labels:X},spec:{type:"ClusterIP",selector:{app:t},ports:o}}}function N$(e,t,r){let o=R$(t,bn(r));if(o.length===0)return;return{apiVersion:"networking.k8s.io/v1",kind:"Ingress",metadata:{name:t,namespace:e,labels:X},spec:{rules:o}}}function L$(e,t,r=process.cwd(),o={},n=new Qe({workspace:r})){let i=new Map;for(let s of yn(t,n,o)){let a=s.kind==="bind"?s.source?s.name:void 0:s.kind==="volume"&&s.source?gn(`${e}-${s.source}`):void 0;if(!a||i.has(a))continue;let c=Qg(s);i.set(a,{apiVersion:"v1",kind:"PersistentVolumeClaim",metadata:{name:a,namespace:e,labels:X},spec:{accessModes:[c?.replicaCount===1?"ReadWriteOnce":"ReadWriteMany"],storageClassName:c?Wg(c):void 0,resources:{requests:{storage:s.requestedStorage??"1Gi"}}}})}return[...i.values()]}function V$(e,t=process.cwd(),r={},o=new Qe({workspace:t})){let n=new Map;for(let i of yn(e,o,r)){let s=Qg(i);if(!s)continue;let a=Wg(s);n.set(a,{apiVersion:"storage.k8s.io/v1",kind:"StorageClass",metadata:{name:a,labels:X},provisioner:"driver.longhorn.io",allowVolumeExpansion:!0,reclaimPolicy:"Delete",volumeBindingMode:"Immediate",parameters:{...s.diskTag?{diskSelector:s.diskTag.join(",")}:{},...s.replicaCount!==void 0?{numberOfReplicas:String(s.replicaCount)}:{},...s.dataLocality?{dataLocality:"disabled"}:{}}})}return[...n.values()]}function U$(e,t,r=process.cwd(),o={},n=new Qe({workspace:r})){let i=new Map;for(let s of yn(t,n,o)){if(s.kind!=="config-file"||!s.source||!s.configKey)continue;i.set(s.name,{apiVersion:"v1",kind:"ConfigMap",metadata:{name:s.name,namespace:e,labels:X},data:{[s.configKey]:n.readText(s.source,{expandHome:!0})}})}return[...i.values()]}async function M$(e,t,r,o=process.cwd(),n={},i=new Qe({workspace:o})){let s={...await B$(r.env_file,i),...n};if(Object.keys(s).length===0)return[];return[{apiVersion:"v1",kind:"Secret",metadata:{name:`${t}-env`,namespace:e,labels:X},type:"Opaque",stringData:s}]}function F$(e){let t=Object.entries(e.stringData??{}).sort(([r],[o])=>r.localeCompare(o));return Zg("sha256").update(JSON.stringify(t)).digest("hex")}function j$(e){return{apiVersion:"v1",kind:"Namespace",metadata:{name:e,labels:X}}}function Z$(e,t){let r=e.spec?.template.spec?.containers[0];if(!r)return;if(t["x-container"]?.resources?.requests?.cpu!==void 0)return;if(r.resources??={},r.resources.requests??={},r.resources.requests.cpu===void 0)r.resources.requests.cpu="100m"}function q$(e,t,r){return{apiVersion:"autoscaling/v2",kind:"HorizontalPodAutoscaler",metadata:{name:t,namespace:e,labels:X},spec:{scaleTargetRef:{apiVersion:"apps/v1",kind:"Deployment",name:t},minReplicas:r.min,maxReplicas:r.max,metrics:[{type:"Resource",resource:{name:"cpu",target:{type:"Utilization",averageUtilization:80}}}]}}}function ke(e){return`${e.kind}:${e.metadata?.namespace??""}:${e.metadata?.name??""}`}async function _n(e,t,r=process.cwd(),o={},n={},i=new Qe({workspace:r})){let s=new Map,a=j$(e);s.set(ke(a),a);for(let[c,u]of Object.entries(t.services??{})){for(let b of V$(u,r,t.volumes,i))s.set(ke(b),b);for(let b of L$(e,u,r,t.volumes,i))s.set(ke(b),b);for(let b of U$(e,u,r,t.volumes,i))s.set(ke(b),b);let l=await M$(e,c,u,r,o[c]??{},i);for(let b of l)s.set(ke(b),b);let f=D$(e,c,u);if(f)s.set(ke(f),f);let d=Gg(u),p=z$(e,c,t,u,r,o[c]??{},t.volumes,n,i,{replicaSpec:d}),m=l[0];if(m)p.spec.template.metadata.annotations={...p.spec?.template.metadata?.annotations,"kuber.astrxl.dev/env-checksum":F$(m)};if(s.set(ke(p),p),d.kind==="range"){Z$(p,u);let b=q$(e,c,d);s.set(ke(b),b)}let h=N$(e,c,u);if(h)s.set(ke(h),h);let y=T$(e,c,bn(u));if(y)s.set(ke(y),y)}return[...s.values()]}var dn,u$,d$,f$;var ec=_(()=>{Fe();za();_r();ot();wr();Lg();dn={requestedStorage:"1Gi",diskTag:["fast"],replicaCount:2,dataLocality:"none"};u$=/^\s*(\d+)\s*-\s*(\d+)\s*$/;d$=/^(\d+)(?:\.(\d+))?$/,f$=/^(?:\d+(?:\.\d+)?|\.\d+)([a-zA-Z]*)$/});import{randomUUID as tc}from"crypto";import{isDeepStrictEqual as ny}from"util";function py(e){return`/workspaces/${encodeURIComponent(e)}/adopt`}function iy(e,t){let r={...e};for(let[o,n]of Object.entries(t))r[o]={...r[o],...n};return r}function H$(e){let{resource:t,phase:r,state:o}=e.data;return`${r==="apply"?"Applied":r==="wait"?"Waited for":"Deleted"} ${t.kind}/${t.name}: ${o}`}function J$(e){if(!e||typeof e!=="object")return!1;let{sequence:t,data:r}=e;if(!Number.isSafeInteger(t)||!r||typeof r!=="object")return!1;let{resource:o,phase:n,state:i}=r;if(!o||typeof o!=="object")return!1;let s=o;return typeof s.apiVersion==="string"&&typeof s.kind==="string"&&typeof s.name==="string"&&(s.namespace===void 0||typeof s.namespace==="string")&&(n==="apply"||n==="wait"||n==="delete")&&(i==="started"||i==="succeeded"||i==="failed"||i==="aborted")}function Y$(e,t){return{source:{uri:`cas://${t.digest}`,digest:t.digest},config:{compose:e}}}function X$(e,t){return ny(e.spec?.source,t.source)&&ny(e.spec?.config,t.config)}function sy(e){if(e instanceof xe)return e.status===409;if(e instanceof DOMException&&e.name==="AbortError")return!1;if(e instanceof Error&&e.name==="AbortError")return!1;return e instanceof TypeError||e instanceof Error&&e.name==="TimeoutError"}async function eA(e,t,r,o=C){let n=`/workspaces/${encodeURIComponent(e)}`,i=Y$(t,r),s=(u)=>o(n,{method:"PUT",headers:{"if-match":`"${u.metadata.resourceVersion}"`},json:i}),a=async(u)=>{try{let l=await o(n);if(X$(l,i))return l;return await s(l)}catch{throw u}},c;try{c=await o(n)}catch(u){if(!(u instanceof xe)||u.status!==404)throw u;try{return await o("/workspaces",{method:"POST",json:{id:e,...i}})}catch(l){if(!sy(l))throw l;return a(l)}}try{return await s(c)}catch(u){if(!sy(u))throw u;return a(u)}}function ay(e){return Object.fromEntries(Object.entries(e).filter(([t,r])=>t!=="operation"&&t!=="operationId"&&r!==null&&typeof r==="object"&&!Array.isArray(r)))}function wn(e,t){let r=t instanceof Error?t.message:String(t);if(!/namespace .* (?:external|different-workspace)/i.test(r))return t instanceof Error?t:Error(r);return Error(`${r}. Safe adoption requires ${ly} ${py(e)} with namespace UID and ownership preconditions.`,{cause:t})}async function Pt(e,t,r,o){try{return await t(r,o)}catch(n){throw wn(e,n)}}function tA(e){if(!e||typeof e!=="object")return;let t=e.operationId;return typeof t==="string"&&t?t:void 0}function rA(e){if(!e||typeof e!=="object")return;let t=e.operation?.status;return t&&typeof t==="object"?t:void 0}function cy(e,t){let r=t.error,o=t.state==="cancelled",n=typeof r?.message==="string"?r.message:o?"The operation was cancelled":"The operation failed",i=typeof r?.code==="string"?r.code:o?"OPERATION_CANCELLED":"OPERATION_FAILED";return new xe(n,o?409:500,{title:o?"Operation cancelled":"Operation failed",status:o?409:500,code:i,operationId:e})}function oA(e){if(e instanceof xe)return K$.has(e.code);if(e instanceof DOMException&&e.name==="AbortError")return!1;if(e instanceof Error&&e.name==="AbortError")return!1;return e instanceof TypeError||e instanceof Error&&e.name==="TimeoutError"}function nA(e){return e.state==="failed"&&e.error?.code==="OPERATION_INTERRUPTED"}function iA(e,t){return e.cursorGap===!0||Number.isSafeInteger(e.retainedFirstSequence)&&e.retainedFirstSequence>t+1}function sA(e,t){return t+Math.max(e,0)+G$}function dy(e){return e.reason??new DOMException("The operation was aborted","AbortError")}function kt(e){if(e?.aborted)throw dy(e)}function aA(e,t){return kt(t),new Promise((r,o)=>{let n,i=()=>{if(n!==void 0)clearTimeout(n);t?.removeEventListener("abort",a)},s=()=>{i(),r()},a=()=>{i(),o(dy(t))};if(n=setTimeout(s,e),t?.addEventListener("abort",a,{once:!0}),t?.aborted)a()})}async function rc(e,t,r,o,n,i){let s=i.now??Date.now,a=sA(n,s()),c=new Headers(o.headers);c.set("idempotency-key",tc()),c.set("prefer","respond-async");let u={...o,headers:c,signal:i.signal??o.signal},l,f=Q$,d=!1,p=0;for(;;){if(kt(i.signal),d&&s()>=a)throw Error("Timed out while reconnecting to resume the operation");try{let y;if(l)y=(await Pt(e,t,`/operations/${encodeURIComponent(l)}`,{signal:i.signal})).status;else{d=!1;let b=await Pt(e,t,r,u);l=tA(b),y=rA(b)}if(l)try{let b=await Pt(e,t,`/operations/${encodeURIComponent(l)}/events?after=${p}`,{signal:i.signal});if(iA(b,p))throw new ic;for(let P of b.items??[]){if(!Number.isSafeInteger(P.sequence)||P.sequence<=p)continue;if(p=P.sequence,!J$(P))continue;i.onEvent?.(P)}}catch(b){if(b instanceof ic)throw b;kt(i.signal)}if(!l||!y||y.state==="succeeded")return;if(nA(y)){if(s()>=a)throw cy(l,y);l=void 0,p=0,d=!0,c.set("idempotency-key",tc()),u={...o,headers:c,signal:i.signal??o.signal}}else if(y.state==="failed"||y.state==="cancelled")throw cy(l,y)}catch(y){if(kt(i.signal),y instanceof xe&&y.code==="OPERATION_INTERRUPTED"){if(s()>=a)throw wn(e,y);l=void 0,p=0,d=!0,c.set("idempotency-key",tc()),u={...o,headers:c,signal:i.signal??o.signal}}else{if(!oA(y))throw wn(e,y);if(s()>=a)throw wn(e,y)}}let m=a-s();if(m<=0)throw Error("Timed out while reconnecting to resume the operation");let h=Math.min(f,m);if(i.sleep)kt(i.signal),await i.sleep(h),kt(i.signal);else await aA(h,i.signal);f=Math.min(f*2,W$)}}async function cA(e,t,r=C){let o=`/workspaces/${encodeURIComponent(e)}`;return Pt(e,r,`${o}/resources/plan`,{method:"POST",json:{resources:t}})}function oc(e){let t=e.name??e.metadata?.name;if(!e.apiVersion||!e.kind||!t)return;return{apiVersion:e.apiVersion,kind:e.kind,name:t,namespace:e.namespace??e.metadata?.namespace}}function uy(e){return`${e.apiVersion}\x00${e.kind}\x00${e.namespace??""}\x00${e.name}`}function uA(e,t){return`${e==="apply"?"Apply":e==="wait"?"Wait for":"Delete"} ${t.kind}/${t.name}`}function nc(e,t,r,o,n={}){if(r.length===0)return o(()=>{},e.signal);let i=new Map,s=new Set,a=0;return e.newListr(r.map((c)=>({title:uA(t,c),task:async(u,l)=>{if(i.set(uy(c),l),n.onTaskStarted?.(c,l),a+=1,a!==r.length)return new Promise((f)=>{let d=()=>{e.signal.removeEventListener("abort",d),s.delete(d),f()};if(s.add(d),e.signal.aborted)d();else e.signal.addEventListener("abort",d,{once:!0})});try{await o((f)=>{let d=f.data.resource,p=i.get(uy(d));if(!p)return;p.output=f.data.state,e.output=H$(f)},e.signal)}finally{for(let f of[...s])f()}}})),{concurrent:!0})}async function vr(e,t=C,r={}){let{project:o,compose:n,cwd:i,config:s,hookContext:a}=D(),c=r.trust??await km(await bt(o,i)),u=t;t=async(d,p={},m)=>{let h=new Headers(p.headers);for(let[y,b]of Object.entries(Am(c)))h.set(y,b);return u(d,{...p,headers:h},m)};let l=`/workspaces/${encodeURIComponent(o)}`;return await new he([{title:"Read compose",task:async(d,p)=>{if(d.compose=await n(),e)await s.preBuild?.(d.compose,await a());p.output=`${Object.keys(d.compose.services??{}).length} services`}},{title:"Snapshot workspace",task:async(d,p)=>{let m;try{m=await ja(i)}catch(h){m=i}d.workspaceRoot=m,d.snapshot=await an(m),p.output=`${d.snapshot.manifest.files.length} files`}},{title:"Build images",rendererOptions:{bottomBar:1/0,persistentOutput:!0},enabled:async()=>e&&Object.values((await n()).services??{}).some((d)=>d.build),task:async(d,p)=>{let m=Object.entries(d.compose.services??{}).filter(([,k])=>k.build).map(([k])=>k),h=new Map,y=new Map,b=new Map(m.map((k)=>[k,new Promise((T)=>y.set(k,T))])),P,E,A,x=()=>(A??=Ag(o,d.compose,i,{progress:(k)=>{p.output=k},service:(k)=>{let T;return{progress:(B)=>{let W=h.get(k);if(W&&W.output!==B)W.output=B},get stream(){let B=h.get(k);if(B)T??=B.stdout();return T}}},settled:(k,T)=>{y.get(k)?.(T),y.delete(k)}},{...s,request:t,snapshot:d.snapshot,workspaceRoot:d.workspaceRoot,signal:p.signal}).then((k)=>{P=k},(k)=>{let T=k instanceof Error?k:Error(String(k));E=T,p.output=T.stack??T.message,p.report(T,ag.HAS_FAILED);for(let B of y.values())B(T);y.clear()}),A);if(await p.newListr(m.map((k)=>({title:`Build ${k}`,rendererOptions:{outputBar:10,persistentOutput:!0},task:async(T,B)=>{if(h.set(k,B),B.output="Build queued",h.size===m.length)x();let W=await b.get(k);if(W)throw W;B.output="done"}})),{concurrent:!0,exitOnError:!1}).run(),await A,!P)throw E??Error("Build images failed");d.buildImages=P.images,await s.postBuild?.(P,await a()),p.title=`Built ${P.built.length} image${P.built.length===1?"":"s"}`}},{title:"Resolve images",enabled:async()=>!e&&Object.values((await n()).services??{}).some((d)=>d.build),task:async(d,p)=>{d.buildImages=await cn(o,d.compose,{...s,request:t}),p.output=`${Object.keys(d.buildImages).length} images`}},{title:"Update workspace",task:async(d,p)=>{let m=await eA(o,d.compose,d.snapshot,t),h=await t(py(o),{method:ly,json:{workspaceUid:m.metadata.uid}});p.output=h.resourcesAdopted?`Adopted ${h.resourcesAdopted} existing resources`:"Workspace ready"}},{title:"Reconcile backing services",task:async(d,p)=>{let m={},h={};await p.newListr([{title:"Reconcile databases",enabled:()=>st(d.compose).length>0,task:async(y,b)=>{let P=await Pt(o,t,`${l}/databases`,{method:"POST",json:{compose:d.compose}});m=ay(P),b.output=`${Object.keys(m).length} services`}},{title:"Reconcile S3 storage",enabled:()=>at(d.compose).length>0,task:async(y,b)=>{let P=await Pt(o,t,`${l}/storage`,{method:"POST",json:{compose:d.compose}});h=ay(P),b.output=`${Object.keys(h).length} services`}}],{concurrent:!0}).run(),d.serviceEnv=iy(iy(d.serviceEnv,m),h)}},{title:"Render manifests",task:async(d,p)=>{d.resources=await _n(o,d.compose,i,d.serviceEnv,d.buildImages),await s.postRender?.(d.resources,await a()),p.output=`${d.resources.length} resources`}},{title:"Reconcile resources",task:async(d,p)=>{d.plan=await cA(o,d.resources,t);let m=d.plan,h=m.desired.map(oc).filter((E)=>Boolean(E)),y=m.desired.filter((E)=>E.kind==="Deployment").map(oc).filter((E)=>Boolean(E)),b=m.stale.map(oc).filter((E)=>Boolean(E)),P=`${l}/resources`;return p.newListr([{title:"Apply resources",task:async(E,A)=>nc(A,"apply",h,(x,k)=>rc(o,t,`${P}/apply`,{method:"POST",json:{resources:m.desired}},s.rolloutTimeoutMs,{onEvent:x,signal:k}))},{title:"Run post-apply hook",skip:!s.postApply,task:async()=>s.postApply?.(m.desired,await a())},{title:"Wait for deployments",skip:y.length===0,task:async(E,A)=>nc(A,"wait",y,(x,k)=>rc(o,t,`${P}/wait`,{method:"POST",json:{deployments:y.map((T)=>T.name),timeoutMs:s.rolloutTimeoutMs}},s.rolloutTimeoutMs,{onEvent:x,signal:k}))},{title:"Delete stale resources",skip:b.length===0,task:async(E,A)=>nc(A,"delete",b,(x,k)=>rc(o,t,`${P}/delete`,{method:"POST",json:{resources:m.stale}},s.rolloutTimeoutMs,{onEvent:x,signal:k}))}])}}],{rendererOptions:{collapseErrors:!1}}).run()}var ly="POST",Q$=250,W$=5000,G$=60000,K$,ic,lA;var vn=_(()=>{q();St();G();Za();ec();oe();_r();wr();Fa();Do();K$=new Set(["HTTP_502","HTTP_503","HTTP_504"]);ic=class ic extends Error{constructor(){super("Operation progress history was truncated; refusing to report an incomplete resource stream")}};lA=S({meta:{name:"up",description:"Create and start deployments"},args:{build:{type:"boolean",default:!0,alias:"b",description:"Build images before starting deployments",negativeDescription:"Don't build an image, even if it's policy"}},async run({args:e}){await vr(e.build)}})});function pA(e){let t=e?.trim();if(!t)throw Error("KUBER_API_KEY or --api-key is required for kuber ci");return t}function dA(e){return(t,r={},o={})=>{let n=new Headers(r.headers);return n.set("authorization",`Bearer ${e}`),C(t,{...r,headers:n},{...o,authenticated:!1})}}async function fA(e,t,r,o=dA(r)){let{project:n,cwd:i}=D(),s=await bt(n,i);if(t)await o(`/workspaces/${encodeURIComponent(n)}/trust`,{method:"POST",json:{fingerprint:s.fingerprint}});await vr(e,o,{trust:t?s:void 0})}var mA;var fy=_(()=>{q();G();oe();Do();vn();mA=S({meta:{name:"ci",description:"Deploy using an API key without a session"},args:{apiKey:{type:"string",description:"API key (defaults to KUBER_API_KEY)"},trust:{type:"boolean",description:"Grant current directory trust before deploying"},build:{type:"boolean",default:!0,negativeDescription:"Resolve existing images without building"}},async run({args:e}){await fA(e.build,Boolean(e.trust),pA(e.apiKey??process.env.KUBER_API_KEY))}})});function hA(e,t,r=C){return r(`/workspaces/${encodeURIComponent(e)}/databases/credentials`,{method:"POST",json:{claim:t}})}var gA,yA,bA;var my=_(()=>{q();G();oe();_r();ot();gA=S({meta:{name:"ls",description:"List managed postgres claims"},async run(){let e=st(await D().compose());if(e.length===0){console.log("No managed postgres volumes declared");return}console.log(fe(e.map((t)=>({service:t.service,username:t.username,database:t.database,secret:t.secretName}))))}}),yA=S({meta:{name:"creds",description:"Print postgres credentials for a service"},async run({args:e}){let t=e._[0];if(!t)throw Error("Service name is required");let r=D(),o=st(await r.compose()).find((s)=>s.service===t);if(!o)throw Error(`Service ${t} does not declare a managed postgres volume.`);let n=await hA(r.project,o),i=Cg(o,n);console.log(fe([{service:o.service,username:n.username,database:o.database,host:Qa,port:Wa,secret:o.secretName}])),console.log(`DATABASE_URL=${i}`)}}),bA=S({meta:{name:"db",description:"Inspect managed postgres databases"},subCommands:{creds:yA,ls:gA}})});function _A(e,t=!1,r=C){return r(`/workspaces/${encodeURIComponent(e)}/down`,{method:"POST",json:{full:t}})}var wA;var hy=_(()=>{q();St();G();oe();wA=S({meta:{name:"down",description:"Delete managed resources except ingress and PVCs"},args:{full:{type:"boolean",alias:"f",description:"Also delete ingress, PVCs, and the namespace"}},async run({args:e}){let{project:t}=D();await new he([{title:"Delete resources",task:async(r,o)=>{let n=await _A(t,e.full);o.output=`${n.delete.length} resources queued`}}]).run()}})});async function gy(e,t,r=process.cwd(),o={}){let n=[...st(t).length?["Postgres"]:[],...at(t).length?["S3"]:[]];if(n.length>0)throw Error(`Cannot export without generated ${n.join(" and ")} credentials. Export is side-effect-free; run kuber up or remove managed provider claims.`);let i=await cn(e,t,o);return _n(e,t,r,{},i)}var yy=_(()=>{ec();_r();wr();Za()});import{resolve as vA}from"path";var{YAML:xA}=globalThis.Bun;function EA(e){return`${Pg(e).map((t)=>xA.stringify(t,null,2).trimEnd()).join(`
|
|
100
101
|
---
|
|
101
102
|
`)}
|
|
102
|
-
`}var
|
|
103
|
+
`}var SA;var by=_(()=>{q();un();oe();yy();SA=S({meta:{name:"export",description:"Write rendered manifests to a YAML file"},args:{output:{type:"string",alias:"o",description:"Output YAML file path"}},async run({args:e}){let{project:t,compose:r,cwd:o,config:n,hookContext:i}=D(),s=await gy(t,await r(),o,n);await n.postRender?.(s,await i());let a=vA(o,e.output||`${t}.yaml`);await Bun.write(a,EA(s)),console.log(a)}})});function $A(e,t){let r=new URL(`${e}${t}`);return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.toString()}function kA(e){if(typeof e!=="string")throw Error("Exec frame must be JSON text");let t=JSON.parse(e);if(!t||typeof t!=="object"||!("type"in t))throw Error("Invalid exec frame");let r=t;if(r.type==="stdout"||r.type==="stderr"){if(r.encoding!=="base64"||typeof r.data!=="string")throw Error("Invalid exec output frame");return{type:r.type,data:Uint8Array.from(Buffer.from(r.data,"base64"))}}if(r.type==="exit"&&Number.isSafeInteger(r.exitCode))return r;if(r.type==="error"&&typeof r.message==="string")return r;throw Error("Invalid exec frame")}async function _y(e,t,r,o={}){if(r.aborted)throw r.reason??new DOMException("Aborted","AbortError");let n=o.session??await yt();if(!n)throw Error("Not logged in. Run kuber login first.");let i=`/workspaces/${encodeURIComponent(e)}/exec`,s=(o.socketFactory??AA)($A(o.baseUrl??Ao,i),{authorization:`Bearer ${n.token}`});s.binaryType="arraybuffer",await new Promise((E,A)=>{let x=()=>{W(),s.send(JSON.stringify({type:"start",version:1,...t})),E()},k=(Te)=>{W(),A(Te.error??Error("Exec WebSocket connection failed"))},T=()=>{W(),A(Error("Exec WebSocket closed before opening"))},B=()=>{W(),s.close(1000,"aborted"),A(r.reason??new DOMException("Aborted","AbortError"))},W=()=>{s.removeEventListener("open",x),s.removeEventListener("error",k),s.removeEventListener("close",T),r.removeEventListener("abort",B)};s.addEventListener("open",x),s.addEventListener("error",k),s.addEventListener("close",T),r.addEventListener("abort",B,{once:!0})});let a=[],c=[],u=!1,l,f=!1,d=[],p=(E)=>{if(u)return;u=!0,l=E,s.removeEventListener("message",m),s.removeEventListener("error",h),s.removeEventListener("close",y),r.removeEventListener("abort",b);for(let A of c.splice(0))if(E)A.reject(E);else A.resolve({done:!0,value:void 0})},m=(E)=>{try{if(!f){f=!0;for(let k of d.splice(0))s.send(JSON.stringify(k))}let A=kA(E.data),x=c.shift();if(x)x.resolve({done:!1,value:A});else a.push(A)}catch(A){s.close(1002,"invalid frame"),p(A)}},h=(E)=>p(E.error??Error("Exec WebSocket failed")),y=()=>p(),b=()=>{s.close(1000,"aborted"),p()};s.addEventListener("message",m),s.addEventListener("error",h),s.addEventListener("close",y),r.addEventListener("abort",b,{once:!0});let P=(E)=>{if(u)throw l??Error("Exec session is closed");if(!f){d.push(E);return}s.send(JSON.stringify(E))};return{sendStdin(E,A){P({type:"stdin",data:Buffer.from(E).toString("base64"),encoding:"base64",...A?{eof:!0}:{}})},resize(E,A){P({type:"resize",columns:E,rows:A})},close(){if(!u&&s.readyState===1)P({type:"close"});s.close(1000,"client closed"),p()},[Symbol.asyncIterator](){return{next(){let E=a.shift();if(E)return Promise.resolve({done:!1,value:E});if(l)return Promise.reject(l);if(u)return Promise.resolve({done:!0,value:void 0});return new Promise((A,x)=>c.push({resolve:A,reject:x}))}}}}}var AA=(e,t)=>new WebSocket(e,{headers:t});var wy=_(()=>{Fe();Po()});function vy(){return{columns:process.stdout.columns,rows:process.stdout.rows}}async function PA(e,t,r,o,n=_y,i){if(!t)throw Error("Deployment name is required");if(r.length===0)throw Error("Command is required");let s=Boolean(process.stdin.isTTY&&process.stdout.isTTY&&process.stdin.isRaw),a=await n(e,{deployment:t,command:r,tty:s,...s?vy():{}},o,i),c=(f)=>a.sendStdin(typeof f==="string"?new TextEncoder().encode(f):f),u=()=>a.sendStdin(new Uint8Array,!0),l=()=>{let{columns:f,rows:d}=vy();if(f&&d)a.resize(f,d)};if(process.stdin.on("data",c),process.stdin.once("end",u),s)process.stdout.on("resize",l);try{for await(let f of a)if(f.type==="stdout")process.stdout.write(f.data);else if(f.type==="stderr")process.stderr.write(f.data);else if(f.type==="error")throw Error(f.message);else return f.exitCode;if(o.aborted)return 0;throw Error("Exec connection closed without an exit status")}finally{process.stdin.off("data",c),process.stdin.off("end",u),process.stdout.off("resize",l),a.close()}}var CA;var xy=_(()=>{q();oe();wy();CA=S({meta:{name:"exec",description:"Execute a command inside a deployment pod"},async run({args:e}){let[t,...r]=e._;if(!t)throw Error("Deployment name is required");if(r.length===0)throw Error("Command is required");let o=new AbortController,n=()=>o.abort();process.on("SIGINT",n),process.on("SIGTERM",n);let i=Boolean(process.stdin.isTTY);if(i)process.stdin.setRawMode?.(!0),process.stdin.resume();try{let s=await PA(D().project,t,r,o.signal);if(s!==0)process.exitCode=s}catch(s){if(!o.signal.aborted)throw s}finally{if(process.off("SIGINT",n),process.off("SIGTERM",n),i)process.stdin.setRawMode?.(!1),process.stdin.pause()}}})});import{styleText as Ct}from"util";var{inspect:Ey}=globalThis.Bun;function ac(e){let t=Date.now(),r=Sy[sc];sc=(sc+1)%Sy.length;function o(i,s){return(a,...c)=>{if(!(i===console?process.stdout.isTTY:process.stderr.isTTY)){let f=`${(e??`${Date.now()-t}ms`).padStart(7)} \u258C${s?"\u258C":" "}`,d=a.reduce((p,m,h)=>p+m+(typeof c[h]==="string"?c[h]:typeof c[h]<"u"?Ey(c[h],{colors:!1}):""),"");d=d.split(`
|
|
103
104
|
`).join(`
|
|
104
|
-
${" ".repeat(7)} \u258C${s?"\u258C":" "}`),i.write(`${f}${
|
|
105
|
-
`);return}let l=
|
|
106
|
-
`).map((f,
|
|
105
|
+
${" ".repeat(7)} \u258C${s?"\u258C":" "}`),i.write(`${f}${d}
|
|
106
|
+
`);return}let l=Ct(r,`${(s?Ct:(f,d)=>d)("bold",(e??`${Date.now()-t}ms`).padStart(7))} \u258C${s?Ct(s,"\u258C"):" "}${a.reduce((f,d,p)=>f+Ct(r,d)+(typeof c[p]==="string"?c[p]:typeof c[p]<"u"?Ey(c[p],{colors:!0}):""),"").split(`
|
|
107
|
+
`).map((f,d)=>Ct(r,d?`${" ".repeat(7)} \u258C${s?Ct(s,"\u258C"):" "}${f}`:f)).join(`
|
|
107
108
|
`)}
|
|
108
|
-
`);i.write(l)}}let n=o(console);return n.error=o(process.stderr,"redBright"),n.warn=o(console,"yellow"),n.debug=o(console,"blue"),n}var
|
|
109
|
+
`);i.write(l)}}let n=o(console);return n.error=o(process.stderr,"redBright"),n.warn=o(console,"yellow"),n.debug=o(console,"blue"),n}var Sy,sc=0,$1;var $y=_(()=>{Sy=["red","green","yellow","blue","magenta","cyan","white","redBright","greenBright","yellowBright","blueBright","magentaBright","cyanBright","whiteBright"];$1=ac("APP")});function Ay(){let e=new Map;return(t,r,o)=>{let n=e.get(t);if(!n)n=ac(t),e.set(t,n);if(o)n.warn`${r}`;else n`${r}`}}function RA(e){let t=Number(e);if(!/^\d+$/.test(e)||!Number.isSafeInteger(t))throw Error("-n must be a non-negative integer");return t}async function TA(e,t,r,o,n=Ws,i=Ay(),s){if(s!==void 0&&(!Number.isSafeInteger(s)||s<0))throw Error("-n must be a non-negative integer");let a=new URLSearchParams;if(t)a.set("service",t);if(r)a.set("follow","true");if(s!==void 0)a.set("tailLines",String(s));let c=a.size?`?${a}`:"";for await(let u of n(`/workspaces/${encodeURIComponent(e)}/logs${c}`,{signal:o},{timeoutMs:r?0:void 0})){if(u.type==="heartbeat")continue;if(u.type==="error"){i(t??u.pod??e,u.message,!0);continue}i(u.pod||u.targetName||t||e,u.message,!1)}}var OA;var ky=_(()=>{q();G();oe();$y();OA=S({meta:{name:"logs",description:"Show deployment logs"},args:{follow:{type:"boolean",alias:"f",description:"Follow log output"},tail:{type:"string",alias:"n",description:"Show the last N lines per container"}},async run({args:e}){let t=e._[0],r=new AbortController,o=()=>r.abort();process.on("SIGINT",o),process.on("SIGTERM",o);try{await TA(D().project,t,Boolean(e.follow),r.signal,Ws,Ay(),e.tail===void 0?void 0:RA(e.tail))}catch(n){if(!r.signal.aborted)throw n}finally{process.off("SIGINT",o),process.off("SIGTERM",o)}}})});import{mkdir as IA,readFile as BA,rm as zA,writeFile as DA}from"fs/promises";import{join as Py}from"path";async function LA(e){try{let t=JSON.parse(await BA(xn,"utf8"));if(t.host===e&&typeof t.expiresAt==="number"&&t.expiresAt>Date.now())return await zA(xn,{force:!0}),!0}catch{}return await IA(Py(xn,".."),{recursive:!0,mode:448}),await DA(xn,JSON.stringify({host:e,expiresAt:Date.now()+NA}),{mode:384}),!1}async function VA(e,t=C,r=LA){let o=await t(`/maintenance/${encodeURIComponent(e)}`);if(!await r(o.host))return console.log(`${o.host} maintenance is currently ${o.enabled?"\x1B[31mON\x1B[0m":"\x1B[32mOFF\x1B[0m"}, run this command again to toggle.`),o;let n=await t(`/maintenance/${encodeURIComponent(o.host)}`,{method:"POST",json:{enabled:!o.enabled}});return console.log(`${n.host} maintenance is now ${n.enabled?"\x1B[31mON\x1B[0m":"\x1B[32mOFF\x1B[0m"}`),n}var xn,NA=60000,UA;var Cy=_(()=>{q();G();xn=Py(process.env.XDG_RUNTIME_DIR??"/tmp","kuber","maintenance-confirmation");UA=S({meta:{name:"maintenance",description:"Toggle a global hostname maintenance override"},args:{host:{type:"positional",required:!0,description:"DNS hostname"}},async run({args:e}){await VA(e.host)}})});import{createInterface as MA}from"readline/promises";import{stdin as De,stdout as cc}from"process";async function FA(){let e=MA({input:De,output:cc});try{return(await e.question("Username: ")).trim()}finally{e.close()}}async function jA(){if(!De.isTTY||!De.setRawMode)throw Error("Password input requires an interactive terminal");return cc.write("Password: "),De.setRawMode(!0),De.resume(),new Promise((e,t)=>{let r="",o=()=>{De.off("data",n),De.setRawMode(!1),De.pause(),cc.write(`
|
|
109
110
|
`)},n=(i)=>{let s=i.toString("utf8");if(s==="\x03"){o(),t(Error("Login cancelled"));return}if(s==="\r"||s===`
|
|
110
|
-
`){o(),e(r);return}if(s==="\x7F"||s==="\b"){r=r.slice(0,-1);return}r+=s};
|
|
111
|
-
`)}var
|
|
112
|
-
`)}var
|
|
111
|
+
`){o(),e(r);return}if(s==="\x7F"||s==="\b"){r=r.slice(0,-1);return}r+=s};De.on("data",n)})}async function ZA(e,t,r){let o=await C("/login",{method:"POST",body:JSON.stringify({username:e,password:t,persistent:r})},{authenticated:!1});return await Wf(o,r),o}var qA,QA,WA;var En=_(()=>{q();G();Po();qA=S({meta:{name:"login",description:"Log in to kuber.astrxl.dev"},args:{persist:{type:"boolean",description:"Keep the login across reboots"}},async run({args:e}){let t=String(e._[0]??"").trim()||await FA();if(!t)throw Error("Username is required");let r=await ZA(t,await jA(),Boolean(e.persist));console.log(`Logged in as ${r.user.username}`)}}),QA=S({meta:{name:"logout",description:"Log out of kuber.astrxl.dev"},async run(){let e=await yt();if(e)try{await C("/logout",{method:"POST"},{session:e})}finally{await Qs()}else await Qs();console.log("Logged out")}}),WA=S({meta:{name:"whoami",description:"Show the current kuber user"},async run(){let e=await C("/me");console.log(`${e.username} (${e.roles.join(", ")})`)}})});function GA(e){return e?`/operations?${new URLSearchParams({workspaceId:e})}`:"/operations"}function Ry(e){if(e.length===0)return"No operations";return fe(e.map((t)=>({id:t.metadata.name,workspace:t.spec.workspaceId,action:t.spec.action,state:t.status.state,created:t.metadata.creationTimestamp,finished:t.status.finishedAt})))}async function KA(e,t=C){let r=await t(GA(e));return Ry(r.items)}async function HA(e,t=C){let r=await t(`/operations/${encodeURIComponent(e)}`),o=[Ry([r])];if(r.status.error)o.push(`Error: ${r.status.error.code}: ${r.status.error.message}`);if(r.status.result!==void 0)o.push(`Result: ${JSON.stringify(r.status.result)}`);return o.join(`
|
|
112
|
+
`)}var JA,YA,XA;var Ty=_(()=>{q();G();ot();JA=S({meta:{name:"ls",description:"List operations"},args:{workspace:{type:"string",alias:"w",description:"Filter by workspace"}},async run({args:e}){console.log(await KA(e.workspace??e._[0]))}}),YA=S({meta:{name:"get",description:"Get an operation"},async run({args:e}){let t=String(e._[0]??"").trim();if(!t)throw Error("Operation ID is required");console.log(await HA(t))}}),XA=S({meta:{name:"operations",description:"Inspect server operations"},subCommands:{get:YA,ls:JA}})});function ek(e){return`${e.level==="good"?Pe.bgGreen:e.level==="bad"?Pe.bgRed:Pe.bgYellow}${Pe.fgBlack} ${e.label} ${Pe.reset}`}function tk(e){let t=e.split("/",1)[0],r=t==="Deployment"?Pe.fgBlue:t==="Service"?Pe.fgPurple:t==="Ingress"?Pe.fgYellow:t==="Pod"?Pe.fgGreen:void 0;return r?`${r}${e}${Pe.reset}`:e}function Oy(e){let t=[],r=(o,n,i)=>{t.push(`${n}${i?"\u2514\u2500 ":"\u251C\u2500 "}${tk(o.id)} ${ek(o.status)}`);let s=n+(i?" ":"\u2502 ");o.children.forEach((a,c)=>{r(a,s,c===o.children.length-1)})};for(let o of e)t.push(o.namespace),o.roots.forEach((n,i)=>{r(n,"",i===o.roots.length-1)}),t.push("");return t.join(`
|
|
113
|
+
`)}var Pe;var Iy=_(()=>{Pe={reset:"\x1B[0m",fgBlack:"\x1B[30m",fgBlue:"\x1B[34m",fgPurple:"\x1B[35m",fgYellow:"\x1B[33m",fgGreen:"\x1B[32m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgRed:"\x1B[41m"}});async function rk(e,t=!1,r=C){let o=t?"?includeIdle=true":"",n=await r(`/workspaces/${encodeURIComponent(e)}/status${o}`);return Oy(n)}var ok;var By=_(()=>{q();G();Iy();oe();ok=S({meta:{name:"ps",description:"List deployments"},args:{all:{type:"boolean",alias:"a",description:"Show all stopped deployments (including those created by the run command)"}},async run({args:{all:e}}){console.log(await rk(D().project,e))}})});function nk(e,t,r=C){return r(`/workspaces/${encodeURIComponent(e)}/lifecycle`,{method:"POST",json:{action:"restart",...t&&{services:[t]}}})}var ik;var zy=_(()=>{q();St();G();oe();ik=S({meta:{name:"restart",description:"Roll out a restart for managed deployments"},args:{deployment:{type:"positional",description:"Deployment name to restart (defaults to all managed)",required:!1}},async run({args:e}){await new he([{title:"Restart deployments",task:async(t,r)=>{let{deployments:o}=await nk(D().project,e.deployment);r.output=`${o.length} deployments queued`}}]).run()}})});function sk(e,t,r,o=C){return o(`/workspaces/${encodeURIComponent(e)}/rollback`,{method:"POST",json:{...t&&{services:[t]},timeoutMs:r}})}var ak;var Dy=_(()=>{q();St();G();oe();ak=S({meta:{name:"rollback",description:"Roll deployments back to the previous release",alias:"fuck"},args:{deployment:{type:"positional",description:"Deployment name to roll back (defaults to all managed)",required:!1}},async run({args:e}){let{project:t,config:r}=D(),o=[];if(await new he([{title:"Roll back deployments",task:async(n,i)=>{({deployments:o}=await sk(t,e.deployment,r.rolloutTimeoutMs)),i.output=`${o.length} deployment${o.length===1?"":"s"} queued`}}]).run(),o.length===0)if(e.deployment)console.log(`${e.deployment} has no previous release to roll back to`);else console.log("No deployments have a previous release to roll back to")}})});function uk(e,t,r=C){return r(`/workspaces/${encodeURIComponent(e)}/storage/credentials`,{method:"POST",json:{claim:t}})}function lk(e){return`${ck}/buckets/${encodeURIComponent(e)}/objects`}async function Ny(e){let t=at(await D().compose()).find((r)=>r.service===e);if(!t)throw Error(`Service ${e} does not declare a managed S3 volume.`);return t}var ck="http://garage-ui.garage-system.svc.cluster.local",pk,dk,fk,mk;var Ly=_(()=>{q();G();oe();ot();wr();pk=S({meta:{name:"ls",description:"List managed S3 claims"},async run(){let e=at(await D().compose());if(e.length===0){console.log("No managed S3 volumes declared");return}console.log(fe(e.map((t)=>({service:t.service,key:t.key,bucket:t.bucket}))))}}),dk=S({meta:{name:"creds",description:"Print S3 environment variables for a service"},async run({args:e}){let t=e._[0];if(!t)throw Error("Service name is required");let r=await uk(D().project,await Ny(t));for(let[o,n]of Object.entries(r))console.log(`${o}=${n}`)}}),fk=S({meta:{name:"ui",description:"Print the Garage UI URL for a service bucket"},async run({args:e}){let t=e._[0];if(!t)throw Error("Service name is required");console.log(lk((await Ny(t)).bucket))}}),mk=S({meta:{name:"s3",description:"Inspect managed S3 storage"},subCommands:{creds:dk,ls:pk,ui:fk}})});var hk;var Vy=_(()=>{q();vn();hk=S({meta:{name:"start",description:"Start deployments without rebuilding images"},async run(){await vr(!1)}})});function gk(e,t=C){return t(`/workspaces/${encodeURIComponent(e)}/lifecycle`,{method:"POST",json:{action:"stop"}})}var yk;var Uy=_(()=>{q();St();G();oe();yk=S({meta:{name:"stop",description:"Scale managed deployments to zero"},async run(){await new he([{title:"Scale deployments",task:async(e,t)=>{let{deployments:r}=await gk(D().project);t.output=`${r.length} deployments queued`}}]).run()}})});import{stdin as Ce,stdout as uc}from"process";import{createInterface as bk}from"readline/promises";function We(e){let t=String(e??"").trim();if(!t)throw Error("Username is required");return t}function Fy(e){let t=String(e??"").split(",").map((o)=>o.trim()).filter(Boolean);if(t.length===0)throw Error("At least one role is required (for example: --roles admin)");let r=t.find((o)=>!["viewer","operator","admin"].includes(o));if(r)throw Error(`Unknown role: ${r}`);return[...new Set(t)]}function _k(e){let t=String(e??"").split(",").map((o)=>o.trim()).filter(Boolean),r=new Set(["kubernetes:read","kubernetes:write","kubernetes:exec","users:read","users:write","sessions:revoke","platform:adopt"]);if(!t.length||t.some((o)=>!r.has(o)))throw Error("Provide valid capabilities (for example: --capabilities kubernetes:read,kubernetes:write; choices: kubernetes:read, kubernetes:write, kubernetes:exec, users:read, users:write, sessions:revoke, platform:adopt)");return[...new Set(t)]}function lc(e){if(e.length===0)return"No users";return fe(e.map((t)=>({username:t.username,roles:t.roles.join(","),disabled:t.disabled?"yes":"no",updated:t.updatedAt})))}async function jy(e="Password: "){if(!Ce.isTTY||!Ce.setRawMode)throw Error("Password input requires an interactive terminal");return uc.write(e),Ce.setRawMode(!0),Ce.resume(),new Promise((t,r)=>{let o="",n=()=>{Ce.off("data",s),Ce.setRawMode(!1),Ce.pause(),uc.write(`
|
|
113
114
|
`)},i=(a)=>{if(n(),a)r(a);else if(!o)r(Error("Password is required"));else t(o)},s=(a)=>{for(let c of a.toString()){if(c==="\x03"||c==="\x04"){i(Error("Password input cancelled"));return}if(c==="\r"||c===`
|
|
114
|
-
`){i();return}if(c==="\x7F"||c==="\b")o=o.slice(0,-1);else o+=c}};ke.on("data",s)})}async function My(e){if(!ke.isTTY)throw Error("Confirmation requires an interactive terminal; use --yes");let t=gk({input:ke,output:cc});try{return(await t.question(`Delete user '${e}'? [y/N] `)).trim().toLowerCase()==="y"}finally{t.close()}}async function bk(e=k){let t=await e("/users");return uc(t.items)}async function _k(e,t,r,o=k){let i=await o("/users",{method:"POST",json:{username:e,password:t,roles:r}});return uc([i])}async function jy(e,t,r=k){if(Object.keys(t).length===0)throw Error("No user updates specified");let o=await r(`/users/${encodeURIComponent(e)}`,{method:"PATCH",json:t});return uc([o])}function wk(e,t,r=k){return jy(e,{disabled:t},r)}async function vk(e,t,r=k){if(!t)return"Deletion cancelled";return await r(`/users/${encodeURIComponent(e)}`,{method:"DELETE"}),`Deleted user ${e}`}async function xk(e,t=k){let r=await t(`/users/${encodeURIComponent(e)}/sessions/revoke`,{method:"POST"});return`Revoked ${r.revoked} session${r.revoked===1?"":"s"} for ${r.username}`}function Zy(e){if(!e.length)return"No API keys";return le(e.map((t)=>({id:t.id,capabilities:t.capabilities.join(","),workspace:t.workspace??"",expires:t.expiresAt,disabled:t.disabled?"yes":"no"})))}async function Ek(e,t=k){let r=await t(`/users/${encodeURIComponent(e)}/keys`);return Zy(r.items)}async function Sk(e,t,r=k){return r(`/users/${encodeURIComponent(e)}/keys`,{method:"POST",json:t})}async function $k(e,t,r,o=k){if(!r)return"API key revocation cancelled";return await o(`/users/${encodeURIComponent(e)}/keys/${encodeURIComponent(t)}`,{method:"DELETE"}),`Revoked API key ${t} for ${e}`}function Vy(e,t){return E({meta:{name:e,description:`${t?"Disable":"Enable"} a user`},async run({args:r}){console.log(await wk(Be(r._[0]),t))}})}var Ak,kk,Pk,Ck,Rk,Tk,Ok;var qy=_(()=>{M();q();tt();Ak=E({meta:{name:"ls",description:"List users"},async run(){console.log(await bk())}}),kk=E({meta:{name:"add",description:"Add a user"},args:{roles:{type:"string",description:"Comma-separated roles"}},async run({args:e}){let t=Be(e._[0]);console.log(await _k(t,await Fy(),Uy(e.roles)))}}),Pk=E({meta:{name:"update",description:"Update a user's roles or password"},args:{roles:{type:"string",description:"Comma-separated roles"},password:{type:"boolean",description:"Prompt for a new password"}},async run({args:e}){let t=Be(e._[0]),r={};if(e.roles!==void 0)r.roles=Uy(e.roles);if(e.password)r.password=await Fy("New password: ");console.log(await jy(t,r))}});Ck=E({meta:{name:"delete",description:"Delete a user"},args:{yes:{type:"boolean",alias:"y",description:"Delete without confirmation"}},async run({args:e}){let t=Be(e._[0]),r=Boolean(e.yes)||await My(t);console.log(await vk(t,r))}}),Rk=E({meta:{name:"revoke",description:"Revoke all sessions for a user"},async run({args:e}){console.log(await xk(Be(e._[0])))}}),Tk=E({meta:{name:"keys",description:"Manage user API keys"},subCommands:{ls:E({meta:{name:"ls",description:"List a user's API keys"},async run({args:e}){console.log(await Ek(Be(e._[0])))}}),create:E({meta:{name:"create",description:"Create an API key"},args:{capabilities:{type:"string",required:!0,description:"Comma-separated capabilities"},workspace:{type:"string",description:"Restrict the key to a workspace"},expiresDays:{type:"string",default:"90",description:"Expiry in days (1-365)"}},async run({args:e}){let t=Number(e.expiresDays);if(!Number.isSafeInteger(t)||t<1||t>365)throw Error("--expires-days must be an integer from 1 to 365");let r=await Sk(Be(e._[0]),{capabilities:yk(e.capabilities),...e.workspace&&{workspace:e.workspace},expiresAt:new Date(Date.now()+t*24*60*60*1000).toISOString()});console.log("Store this API key securely now. It will not be shown again:"),console.log(r.token),console.log(Zy([r]))}}),revoke:E({meta:{name:"revoke",description:"Revoke an API key"},args:{yes:{type:"boolean",alias:"y",description:"Revoke without confirmation"}},async run({args:e}){let t=Be(e._[0]),r=Be(e._[1]),o=Boolean(e.yes)||await My(`API key '${r}' for ${t}`);console.log(await $k(t,r,o))}})}}),Ok=E({meta:{name:"users",description:"Administer users"},subCommands:{add:kk,delete:Ck,disable:Vy("disable",!0),enable:Vy("enable",!1),keys:Tk,ls:Ak,revoke:Rk,update:Pk}})});function pc(e){return`/workspaces/${encodeURIComponent(e)}/trust`}async function lc(){let{project:e,cwd:t}=I();return gt(e,t)}async function Ik(e,t=k){await t(pc(e.project),{method:"POST",json:{fingerprint:e.fingerprint}}),await Xs((r)=>[...r.filter((o)=>o.project!==e.project||o.fingerprint!==e.fingerprint),e]),console.log(`Trusted this directory for namespace ${e.project}`)}async function Bk(e,t=k){let r=(await Io()).some((i)=>i.project===e.project&&i.fingerprint===e.fingerprint),n=(await t(pc(e.project))).fingerprints.includes(e.fingerprint);console.log(`Namespace: ${e.project}`),console.log(`Local: ${r?"trusted":"untrusted"}`),console.log(`Server: ${n?"registered":"not registered"}`)}async function zk(e,t=k){let r;try{await t(`${pc(e.project)}?fingerprint=${encodeURIComponent(e.fingerprint)}`,{method:"DELETE"})}catch(o){if(!(o instanceof we&&o.status===404))r=o}if(await Xs((o)=>o.filter((n)=>n.project!==e.project||n.fingerprint!==e.fingerprint)),r){let o=r instanceof Error?r.message:String(r);throw Error(`Removed local trust for namespace ${e.project}, but failed to revoke the server registration: ${o}`,{cause:r})}console.log(`Revoked trust for namespace ${e.project}`)}var Dk;var Qy=_(()=>{M();q();ee();Bo();Dk=E({meta:{name:"trust",description:"Trust this directory for kuber up"},subCommands:{status:E({meta:{name:"status",description:"Show local and server trust"},async run(){await Bk(await lc())}}),revoke:E({meta:{name:"revoke",description:"Revoke this directory trust"},async run(){await zk(await lc())}})},async run(){await Ik(await lc())}})});import Nk from"assert";var D,Lk=class{name;variadic;command;handler;constructor(e,t,r,o=!1){this.command=e,this.name=t,this.handler=r,this.variadic=o}},Vk=class{value;description;command;handler;alias;isBoolean;constructor(e,t,r,o,n,i){this.command=e,this.value=t,this.description=r,this.handler=o,this.alias=n,this.isBoolean=i}},Wy=class{value;description;options=new Map;arguments=new Map;parent;constructor(e,t){this.value=e,this.description=t}option(e,t,r,o){let n,i,s;typeof r=="function"?(n=r,i=o,s=!1):typeof r=="string"?(n=void 0,i=r,s=!0):(n=void 0,i=void 0,s=!0);let a=new Vk(this,e,t,n,i,s);return this.options.set(e,a),this}argument(e,t,r=!1){let o=new Lk(this,e,t,r);return this.arguments.set(e,o),this}},Uk,Pe;var dc=_(()=>{fc();D={ShellCompDirectiveError:1,ShellCompDirectiveNoSpace:2,ShellCompDirectiveNoFileComp:4,ShellCompDirectiveFilterFileExt:8,ShellCompDirectiveFilterDirs:16,ShellCompDirectiveKeepOrder:32,shellCompDirectiveMaxValue:64,ShellCompDirectiveDefault:0},Uk=class extends Wy{commands=new Map;completions=[];directive=D.ShellCompDirectiveDefault;constructor(){super("","")}command(e,t){let r=new Wy(e,t);return this.commands.set(e,r),r}stripOptions(e){let t=[],r=0;for(;r<e.length;){let o=e[r];if(o.startsWith("-")){r++;let n=!1,i=this.findOption(this,o);if(i)n=i.isBoolean??!1;else for(let[,s]of this.commands){let a=this.findOption(s,o);if(a){n=a.isBoolean??!1;break}}!n&&r<e.length&&!e[r].startsWith("-")&&r++}else t.push(o),r++}return t}matchCommand(e){e=this.stripOptions(e);let t=[],r=[],o=null;for(let n=0;n<e.length;n++){let i=e[n];t.push(i);let s=this.commands.get(t.join(" "));if(s)o=s;else{r=e.slice(n,e.length);break}}return[o||this,r]}shouldCompleteFlags(e,t){if(t.startsWith("-"))return!0;if(e?.startsWith("-")){let r=this.findOption(this,e);if(!r){for(let[,o]of this.commands)if(r=this.findOption(o,e),r)break}return!(r&&r.isBoolean)}return!1}shouldCompleteCommands(e){return!e.startsWith("-")}handleFlagCompletion(e,t,r,o){let n;if(r.includes("=")){let[i]=r.split("=");n=i}else if(o?.startsWith("-")){let i=this.findOption(e,o);i&&!i.isBoolean&&(n=o)}if(n){let i=this.findOption(e,n);if(i?.handler){let s=[];i.handler.call(i,(a,c)=>s.push({value:a,description:c}),e.options),this.completions=s}return}if(r.startsWith("-")){let i=r.startsWith("-")&&!r.startsWith("--"),s=r.replace(/^-+/,"");for(let[a,c]of e.options)i&&c.alias&&`-${c.alias}`.startsWith(r)?this.completions.push({value:`-${c.alias}`,description:c.description}):!i&&a.startsWith(s)&&this.completions.push({value:`--${a}`,description:c.description})}}findOption(e,t){let r=e.options.get(t);if(r||(r=e.options.get(t.replace(/^-+/,"")),r))return r;for(let[o,n]of e.options)if(n.alias&&`-${n.alias}`===t)return n}handleCommandCompletion(e,t){let r=this.stripOptions(e);for(let[o,n]of this.commands){if(o==="")continue;let i=o.split(" ");i.slice(0,r.length).every((s,a)=>s===r[a])&&i[r.length]?.startsWith(t)&&this.completions.push({value:i[r.length],description:n.description})}}handlePositionalCompletion(e,t){let r=this.stripOptions(t),o=e.value.split(" ").length,n=Math.max(0,r.length-o),i=Array.from(e.arguments.entries());if(i.length>0){let s;if(n<i.length){let[a,c]=i[n];s=c}else{let a=i[i.length-1][1];a.variadic&&(s=a)}if(s&&s.handler&&typeof s.handler=="function"){let a=[];s.handler.call(s,(c,u)=>a.push({value:c,description:u}),e.options),this.completions.push(...a)}}}complete(e){this.directive=D.ShellCompDirectiveNoFileComp;let t=new Set;this.completions.filter((r)=>t.has(r.value)?!1:(t.add(r.value),!0)).filter((r)=>{if(e.includes("=")){let[,o]=e.split("=");return r.value.startsWith(o)}return r.value.startsWith(e)}).forEach((r)=>console.log(`${r.value} ${r.description??""}`)),console.log(`:${this.directive}`)}parse(e){this.completions=[];let t=e[e.length-1]==="";t&&e.pop();let r=e[e.length-1]||"",o=e.slice(0,-1);t&&(r!==""&&o.push(r),r="");let[n]=this.matchCommand(o),i=o[o.length-1];this.shouldCompleteFlags(i,r)?this.handleFlagCompletion(n,o,r,i):(this.shouldCompleteCommands(r)&&this.handleCommandCompletion(o,r),n&&n.arguments.size>0&&this.handlePositionalCompletion(n,o)),this.complete(r)}setup(e,t,r){switch(Nk(r==="zsh"||r==="bash"||r==="fish"||r==="powershell","Unsupported shell"),r){case"zsh":{let o=xn(e,t);console.log(o);break}case"bash":{let o=En(e,t);console.log(o);break}case"fish":{let o=Sn(e,t);console.log(o);break}case"powershell":{let o=$n(e,t);console.log(o);break}}}},Pe=new Uk});function xn(e,t){return`#compdef ${e}
|
|
115
|
+
`){i();return}if(c==="\x7F"||c==="\b")o=o.slice(0,-1);else o+=c}};Ce.on("data",s)})}async function Zy(e){if(!Ce.isTTY)throw Error("Confirmation requires an interactive terminal; use --yes");let t=bk({input:Ce,output:uc});try{return(await t.question(`Delete user '${e}'? [y/N] `)).trim().toLowerCase()==="y"}finally{t.close()}}async function wk(e=C){let t=await e("/users");return lc(t.items)}async function vk(e,t,r,o=C){let i=await o("/users",{method:"POST",json:{username:e,password:t,roles:r}});return lc([i])}async function qy(e,t,r=C){if(Object.keys(t).length===0)throw Error("No user updates specified");let o=await r(`/users/${encodeURIComponent(e)}`,{method:"PATCH",json:t});return lc([o])}function xk(e,t,r=C){return qy(e,{disabled:t},r)}async function Ek(e,t,r=C){if(!t)return"Deletion cancelled";return await r(`/users/${encodeURIComponent(e)}`,{method:"DELETE"}),`Deleted user ${e}`}async function Sk(e,t=C){let r=await t(`/users/${encodeURIComponent(e)}/sessions/revoke`,{method:"POST"});return`Revoked ${r.revoked} session${r.revoked===1?"":"s"} for ${r.username}`}function Qy(e){if(!e.length)return"No API keys";return fe(e.map((t)=>({id:t.id,username:t.username,capabilities:t.capabilities.join(","),workspace:t.workspace??"",expires:t.expiresAt??"never",disabled:t.disabled?"yes":"no"})))}async function $k(e,t=C){let r=e?[e]:(await t("/users")).items.map((n)=>n.username),o=await Promise.all(r.map((n)=>t(`/users/${encodeURIComponent(n)}/keys`)));return Qy(o.flatMap((n)=>n.items).sort((n,i)=>n.username.localeCompare(i.username)||n.id.localeCompare(i.id)))}async function Ak(e,t,r=C){if((await r(`/users/${encodeURIComponent(e)}`)).disabled)throw Error(`Cannot create API key: user '${e}' is inactive`);return r(`/users/${encodeURIComponent(e)}/keys`,{method:"POST",json:t})}async function kk(e,t,r,o=C){if(!r)return"API key revocation cancelled";return await o(`/users/${encodeURIComponent(e)}/keys/${encodeURIComponent(t)}`,{method:"DELETE"}),`Revoked API key ${t} for ${e}`}function My(e,t){return S({meta:{name:e,description:`${t?"Disable":"Enable"} a user`},async run({args:r}){console.log(await xk(We(r._[0]),t))}})}var Pk,Ck,Rk,Tk,Ok,Ik,Bk;var Wy=_(()=>{q();G();ot();Pk=S({meta:{name:"ls",description:"List users"},async run(){console.log(await wk())}}),Ck=S({meta:{name:"add",description:"Add a user"},args:{roles:{type:"string",description:"Comma-separated roles"}},async run({args:e}){let t=We(e._[0]);console.log(await vk(t,await jy(),Fy(e.roles)))}}),Rk=S({meta:{name:"update",description:"Update a user's roles or password"},args:{roles:{type:"string",description:"Comma-separated roles"},password:{type:"boolean",description:"Prompt for a new password"}},async run({args:e}){let t=We(e._[0]),r={};if(e.roles!==void 0)r.roles=Fy(e.roles);if(e.password)r.password=await jy("New password: ");console.log(await qy(t,r))}});Tk=S({meta:{name:"delete",description:"Delete a user"},args:{yes:{type:"boolean",alias:"y",description:"Delete without confirmation"}},async run({args:e}){let t=We(e._[0]),r=Boolean(e.yes)||await Zy(t);console.log(await Ek(t,r))}}),Ok=S({meta:{name:"revoke",description:"Revoke all sessions for a user"},async run({args:e}){console.log(await Sk(We(e._[0])))}}),Ik=S({meta:{name:"keys",description:"Manage user API keys"},subCommands:{ls:S({meta:{name:"ls",description:"List all API keys (optional positional username filters the results)"},async run({args:e}){console.log(await $k(e._[0]))}}),create:S({meta:{name:"create",description:"Create an API key for a user (e.g. kuber users keys create alice --capabilities kubernetes:read --expires-days none)"},args:{username:{type:"positional",required:!0,description:"Username to own the API key"},capabilities:{type:"string",required:!0,description:"Comma-separated capabilities, e.g. kubernetes:read,kubernetes:write (also kubernetes:exec, users:read, users:write, sessions:revoke, platform:adopt)"},workspace:{type:"string",description:"Restrict the key to a workspace"},"expires-days":{type:"string",default:"90",description:"Expiry in days (1-365), or none for a non-expiring key"}},async run({args:e}){let t=e["expires-days"]==="none"?void 0:Number(e["expires-days"]);if(t!==void 0&&(!Number.isSafeInteger(t)||t<1||t>365))throw Error("--expires-days must be an integer from 1 to 365, or none");let r=await Ak(We(e.username),{capabilities:_k(e.capabilities),...e.workspace&&{workspace:e.workspace},...t!==void 0&&{expiresAt:new Date(Date.now()+t*24*60*60*1000).toISOString()}});console.log("Store this API key securely now. It will not be shown again:"),console.log(r.token),console.log(Qy([r]))}}),revoke:S({meta:{name:"revoke",description:"Revoke an API key"},args:{yes:{type:"boolean",alias:"y",description:"Revoke without confirmation"}},async run({args:e}){let t=We(e._[0]),r=We(e._[1]),o=Boolean(e.yes)||await Zy(`API key '${r}' for ${t}`);console.log(await kk(t,r,o))}})}}),Bk=S({meta:{name:"users",description:"Administer users"},subCommands:{add:Ck,delete:Tk,disable:My("disable",!0),enable:My("enable",!1),keys:Ik,ls:Pk,revoke:Ok,update:Rk}})});function dc(e){return`/workspaces/${encodeURIComponent(e)}/trust`}async function pc(){let{project:e,cwd:t}=D();return bt(e,t)}async function zk(e,t=C){await t(dc(e.project),{method:"POST",json:{fingerprint:e.fingerprint}}),await ea((r)=>[...r.filter((o)=>o.project!==e.project||o.fingerprint!==e.fingerprint),e]),console.log(`Trusted this directory for namespace ${e.project}`)}async function Dk(e,t=C){let r=(await zo()).some((i)=>i.project===e.project&&i.fingerprint===e.fingerprint),n=(await t(dc(e.project))).fingerprints.includes(e.fingerprint);console.log(`Namespace: ${e.project}`),console.log(`Local: ${r?"trusted":"untrusted"}`),console.log(`Server: ${n?"registered":"not registered"}`)}async function Nk(e,t=C){let r;try{await t(`${dc(e.project)}?fingerprint=${encodeURIComponent(e.fingerprint)}`,{method:"DELETE"})}catch(o){if(!(o instanceof xe&&o.status===404))r=o}if(await ea((o)=>o.filter((n)=>n.project!==e.project||n.fingerprint!==e.fingerprint)),r){let o=r instanceof Error?r.message:String(r);throw Error(`Removed local trust for namespace ${e.project}, but failed to revoke the server registration: ${o}`,{cause:r})}console.log(`Revoked trust for namespace ${e.project}`)}var Lk;var Gy=_(()=>{q();G();oe();Do();Lk=S({meta:{name:"trust",description:"Trust this directory for kuber up"},subCommands:{status:S({meta:{name:"status",description:"Show local and server trust"},async run(){await Dk(await pc())}}),revoke:S({meta:{name:"revoke",description:"Revoke this directory trust"},async run(){await Nk(await pc())}})},async run(){await zk(await pc())}})});import Vk from"assert";var V,Uk=class{name;variadic;command;handler;constructor(e,t,r,o=!1){this.command=e,this.name=t,this.handler=r,this.variadic=o}},Mk=class{value;description;command;handler;alias;isBoolean;constructor(e,t,r,o,n,i){this.command=e,this.value=t,this.description=r,this.handler=o,this.alias=n,this.isBoolean=i}},Ky=class{value;description;options=new Map;arguments=new Map;parent;constructor(e,t){this.value=e,this.description=t}option(e,t,r,o){let n,i,s;typeof r=="function"?(n=r,i=o,s=!1):typeof r=="string"?(n=void 0,i=r,s=!0):(n=void 0,i=void 0,s=!0);let a=new Mk(this,e,t,n,i,s);return this.options.set(e,a),this}argument(e,t,r=!1){let o=new Uk(this,e,t,r);return this.arguments.set(e,o),this}},Fk,Re;var fc=_(()=>{mc();V={ShellCompDirectiveError:1,ShellCompDirectiveNoSpace:2,ShellCompDirectiveNoFileComp:4,ShellCompDirectiveFilterFileExt:8,ShellCompDirectiveFilterDirs:16,ShellCompDirectiveKeepOrder:32,shellCompDirectiveMaxValue:64,ShellCompDirectiveDefault:0},Fk=class extends Ky{commands=new Map;completions=[];directive=V.ShellCompDirectiveDefault;constructor(){super("","")}command(e,t){let r=new Ky(e,t);return this.commands.set(e,r),r}stripOptions(e){let t=[],r=0;for(;r<e.length;){let o=e[r];if(o.startsWith("-")){r++;let n=!1,i=this.findOption(this,o);if(i)n=i.isBoolean??!1;else for(let[,s]of this.commands){let a=this.findOption(s,o);if(a){n=a.isBoolean??!1;break}}!n&&r<e.length&&!e[r].startsWith("-")&&r++}else t.push(o),r++}return t}matchCommand(e){e=this.stripOptions(e);let t=[],r=[],o=null;for(let n=0;n<e.length;n++){let i=e[n];t.push(i);let s=this.commands.get(t.join(" "));if(s)o=s;else{r=e.slice(n,e.length);break}}return[o||this,r]}shouldCompleteFlags(e,t){if(t.startsWith("-"))return!0;if(e?.startsWith("-")){let r=this.findOption(this,e);if(!r){for(let[,o]of this.commands)if(r=this.findOption(o,e),r)break}return!(r&&r.isBoolean)}return!1}shouldCompleteCommands(e){return!e.startsWith("-")}handleFlagCompletion(e,t,r,o){let n;if(r.includes("=")){let[i]=r.split("=");n=i}else if(o?.startsWith("-")){let i=this.findOption(e,o);i&&!i.isBoolean&&(n=o)}if(n){let i=this.findOption(e,n);if(i?.handler){let s=[];i.handler.call(i,(a,c)=>s.push({value:a,description:c}),e.options),this.completions=s}return}if(r.startsWith("-")){let i=r.startsWith("-")&&!r.startsWith("--"),s=r.replace(/^-+/,"");for(let[a,c]of e.options)i&&c.alias&&`-${c.alias}`.startsWith(r)?this.completions.push({value:`-${c.alias}`,description:c.description}):!i&&a.startsWith(s)&&this.completions.push({value:`--${a}`,description:c.description})}}findOption(e,t){let r=e.options.get(t);if(r||(r=e.options.get(t.replace(/^-+/,"")),r))return r;for(let[o,n]of e.options)if(n.alias&&`-${n.alias}`===t)return n}handleCommandCompletion(e,t){let r=this.stripOptions(e);for(let[o,n]of this.commands){if(o==="")continue;let i=o.split(" ");i.slice(0,r.length).every((s,a)=>s===r[a])&&i[r.length]?.startsWith(t)&&this.completions.push({value:i[r.length],description:n.description})}}handlePositionalCompletion(e,t){let r=this.stripOptions(t),o=e.value.split(" ").length,n=Math.max(0,r.length-o),i=Array.from(e.arguments.entries());if(i.length>0){let s;if(n<i.length){let[a,c]=i[n];s=c}else{let a=i[i.length-1][1];a.variadic&&(s=a)}if(s&&s.handler&&typeof s.handler=="function"){let a=[];s.handler.call(s,(c,u)=>a.push({value:c,description:u}),e.options),this.completions.push(...a)}}}complete(e){this.directive=V.ShellCompDirectiveNoFileComp;let t=new Set;this.completions.filter((r)=>t.has(r.value)?!1:(t.add(r.value),!0)).filter((r)=>{if(e.includes("=")){let[,o]=e.split("=");return r.value.startsWith(o)}return r.value.startsWith(e)}).forEach((r)=>console.log(`${r.value} ${r.description??""}`)),console.log(`:${this.directive}`)}parse(e){this.completions=[];let t=e[e.length-1]==="";t&&e.pop();let r=e[e.length-1]||"",o=e.slice(0,-1);t&&(r!==""&&o.push(r),r="");let[n]=this.matchCommand(o),i=o[o.length-1];this.shouldCompleteFlags(i,r)?this.handleFlagCompletion(n,o,r,i):(this.shouldCompleteCommands(r)&&this.handleCommandCompletion(o,r),n&&n.arguments.size>0&&this.handlePositionalCompletion(n,o)),this.complete(r)}setup(e,t,r){switch(Vk(r==="zsh"||r==="bash"||r==="fish"||r==="powershell","Unsupported shell"),r){case"zsh":{let o=Sn(e,t);console.log(o);break}case"bash":{let o=$n(e,t);console.log(o);break}case"fish":{let o=An(e,t);console.log(o);break}case"powershell":{let o=kn(e,t);console.log(o);break}}}},Re=new Fk});function Sn(e,t){return`#compdef ${e}
|
|
115
116
|
compdef _${e} ${e}
|
|
116
117
|
|
|
117
118
|
# zsh completion for ${e} -*- shell-script -*-
|
|
@@ -124,12 +125,12 @@ __${e}_debug() {
|
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
_${e}() {
|
|
127
|
-
local shellCompDirectiveError=${
|
|
128
|
-
local shellCompDirectiveNoSpace=${
|
|
129
|
-
local shellCompDirectiveNoFileComp=${
|
|
130
|
-
local shellCompDirectiveFilterFileExt=${
|
|
131
|
-
local shellCompDirectiveFilterDirs=${
|
|
132
|
-
local shellCompDirectiveKeepOrder=${
|
|
128
|
+
local shellCompDirectiveError=${V.ShellCompDirectiveError}
|
|
129
|
+
local shellCompDirectiveNoSpace=${V.ShellCompDirectiveNoSpace}
|
|
130
|
+
local shellCompDirectiveNoFileComp=${V.ShellCompDirectiveNoFileComp}
|
|
131
|
+
local shellCompDirectiveFilterFileExt=${V.ShellCompDirectiveFilterFileExt}
|
|
132
|
+
local shellCompDirectiveFilterDirs=${V.ShellCompDirectiveFilterDirs}
|
|
133
|
+
local shellCompDirectiveKeepOrder=${V.ShellCompDirectiveKeepOrder}
|
|
133
134
|
|
|
134
135
|
local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
|
|
135
136
|
local -a completions
|
|
@@ -329,15 +330,15 @@ _${e}() {
|
|
|
329
330
|
if [ "\${funcstack[1]}" = "_${e}" ]; then
|
|
330
331
|
_${e}
|
|
331
332
|
fi
|
|
332
|
-
`}function
|
|
333
|
+
`}function $n(e,t){let r=e.replace(/[-:]/g,"_");return`# bash completion for ${e}
|
|
333
334
|
|
|
334
335
|
# Define shell completion directives
|
|
335
|
-
readonly ShellCompDirectiveError=${
|
|
336
|
-
readonly ShellCompDirectiveNoSpace=${
|
|
337
|
-
readonly ShellCompDirectiveNoFileComp=${
|
|
338
|
-
readonly ShellCompDirectiveFilterFileExt=${
|
|
339
|
-
readonly ShellCompDirectiveFilterDirs=${
|
|
340
|
-
readonly ShellCompDirectiveKeepOrder=${
|
|
336
|
+
readonly ShellCompDirectiveError=${V.ShellCompDirectiveError}
|
|
337
|
+
readonly ShellCompDirectiveNoSpace=${V.ShellCompDirectiveNoSpace}
|
|
338
|
+
readonly ShellCompDirectiveNoFileComp=${V.ShellCompDirectiveNoFileComp}
|
|
339
|
+
readonly ShellCompDirectiveFilterFileExt=${V.ShellCompDirectiveFilterFileExt}
|
|
340
|
+
readonly ShellCompDirectiveFilterDirs=${V.ShellCompDirectiveFilterDirs}
|
|
341
|
+
readonly ShellCompDirectiveKeepOrder=${V.ShellCompDirectiveKeepOrder}
|
|
341
342
|
|
|
342
343
|
# Function to debug completion
|
|
343
344
|
__${r}_debug() {
|
|
@@ -430,7 +431,7 @@ __${r}_complete() {
|
|
|
430
431
|
|
|
431
432
|
# Register completion function
|
|
432
433
|
complete -F __${r}_complete ${e}
|
|
433
|
-
`}function
|
|
434
|
+
`}function An(e,t){let r=e.replace(/[-:]/g,"_"),o=V.ShellCompDirectiveError,n=V.ShellCompDirectiveNoSpace,i=V.ShellCompDirectiveNoFileComp,s=V.ShellCompDirectiveFilterFileExt,a=V.ShellCompDirectiveFilterDirs;return`# fish completion for ${e} -*- shell-script -*-
|
|
434
435
|
|
|
435
436
|
function __${r}_debug
|
|
436
437
|
set -l file "$BASH_COMP_DEBUG_FILE"
|
|
@@ -525,7 +526,7 @@ function __${r}_requires_order_preservation
|
|
|
525
526
|
set -l directive (string sub --start 2 $__${r}_perform_completion_once_result[-1])
|
|
526
527
|
__${r}_debug "Directive is: $directive"
|
|
527
528
|
|
|
528
|
-
set -l shellCompDirectiveKeepOrder ${
|
|
529
|
+
set -l shellCompDirectiveKeepOrder ${V.ShellCompDirectiveKeepOrder}
|
|
529
530
|
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
|
|
530
531
|
__${r}_debug "Keeporder is: $keeporder"
|
|
531
532
|
|
|
@@ -662,7 +663,7 @@ complete -c ${e} -n '__${r}_clear_perform_completion_once_result'
|
|
|
662
663
|
complete -c ${e} -n 'not __${r}_requires_order_preservation && __${r}_prepare_completions' -f -a '$__${r}_comp_results'
|
|
663
664
|
# Otherwise we use the -k flag
|
|
664
665
|
complete -k -c ${e} -n '__${r}_requires_order_preservation && __${r}_prepare_completions' -f -a '$__${r}_comp_results'
|
|
665
|
-
`}function
|
|
666
|
+
`}function kn(e,t){let r=e.replace(/[-:]/g,"_");return`# powershell completion for ${e} -*- shell-script -*-
|
|
666
667
|
|
|
667
668
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
668
669
|
function __${e}_debug {
|
|
@@ -700,12 +701,12 @@ complete -k -c ${e} -n '__${r}_requires_order_preservation && __${r}_prepare_com
|
|
|
700
701
|
}
|
|
701
702
|
__${e}_debug "Truncated command: $Command"
|
|
702
703
|
|
|
703
|
-
$ShellCompDirectiveError=${
|
|
704
|
-
$ShellCompDirectiveNoSpace=${
|
|
705
|
-
$ShellCompDirectiveNoFileComp=${
|
|
706
|
-
$ShellCompDirectiveFilterFileExt=${
|
|
707
|
-
$ShellCompDirectiveFilterDirs=${
|
|
708
|
-
$ShellCompDirectiveKeepOrder=${
|
|
704
|
+
$ShellCompDirectiveError=${V.ShellCompDirectiveError}
|
|
705
|
+
$ShellCompDirectiveNoSpace=${V.ShellCompDirectiveNoSpace}
|
|
706
|
+
$ShellCompDirectiveNoFileComp=${V.ShellCompDirectiveNoFileComp}
|
|
707
|
+
$ShellCompDirectiveFilterFileExt=${V.ShellCompDirectiveFilterFileExt}
|
|
708
|
+
$ShellCompDirectiveFilterDirs=${V.ShellCompDirectiveFilterDirs}
|
|
709
|
+
$ShellCompDirectiveKeepOrder=${V.ShellCompDirectiveKeepOrder}
|
|
709
710
|
|
|
710
711
|
# Prepare the command to request completions for the program.
|
|
711
712
|
# Split the command at the first space to separate the program and arguments.
|
|
@@ -912,7 +913,7 @@ complete -k -c ${e} -n '__${r}_requires_order_preservation && __${r}_prepare_com
|
|
|
912
913
|
}
|
|
913
914
|
|
|
914
915
|
Register-ArgumentCompleter -CommandName '${e}' -ScriptBlock $__${r}CompleterBlock
|
|
915
|
-
`}var
|
|
916
|
-
Example: ${e} complete -- <args>`;console.error(t),process.exit(1)}}var
|
|
916
|
+
`}var mc=_(()=>{fc()});function Hy(e="cli"){if(process.argv.indexOf("--")===-1){let t=`Error: You need to use -- to separate completion arguments.
|
|
917
|
+
Example: ${e} complete -- <args>`;console.error(t),process.exit(1)}}var Jy=()=>{};async function jk(e){let t=[],r=[];for(let[o,n]of Object.entries(e))if(n.type==="positional"){let i=n;r.push({name:o,description:i.description,isOptional:!i.required,isVariadic:o.startsWith("[...")||o.startsWith("<...")})}else{let i={name:`--${o}`,description:n.description||"",isRequired:n.required};"alias"in n&&n.alias&&(Array.isArray(n.alias)?n.alias:[n.alias]).forEach((s)=>{t.push({...i,name:`-${s}`})}),t.push(i)}return{options:t,args:r}}async function Yy(e,t=""){let r=await Promise.resolve(e.meta),o=await Promise.resolve(e.subCommands);if(!r||!r.name)throw Error("Command meta or name is missing");let n={name:t?`${t} ${r.name}`:r.name,description:r.description||""};if(e.args){let{options:i,args:s}=await jk(await Promise.resolve(e.args));i.length>0&&(n.options=i),s.length>0&&(n.args=s)}return o&&(n.subcommands=await Promise.all(Object.entries(o).map(async([i,s])=>Yy(await Promise.resolve(s),n.name)))),n}async function Zk(e){let t=await Yy(e);return JSON.stringify(t,null,2)}function Xy(e){return e.args&&Object.values(e.args).some((t)=>t.type==="positional")}async function eb(e,t,r){for(let[o,n]of Object.entries(e)){let i=await xr(n),s=await xr(i.meta),a=await xr(i.subCommands),c=r?.[o];if(!s||typeof s?.description!="string")throw Error("Invalid meta or missing description.");let u=Xy(i),l=t?`${t} ${o}`:o,f=Re.command(l,s.description);if(u&&i.args)for(let[d,p]of Object.entries(i.args)){let m=p;if(m.type==="positional"){let h=m.required===!1,y=c?.args?.[d];y?f.argument(d,y,h):f.argument(d,void 0,h)}}if(a&&await eb(a,l,c?.subCommands),i.args)for(let[d,p]of Object.entries(i.args)){let m=p,h=typeof m=="object"&&"alias"in m?Array.isArray(m.alias)?m.alias[0]:m.alias:void 0,y=c?.options?.[d];y?h?f.option(d,m.description??"",y,h):f.option(d,m.description??"",y):h?f.option(d,m.description??"",h):f.option(d,m.description??"")}}}async function tb(e,t){let r=await xr(e.meta);if(!r)throw Error("Invalid meta.");let o=r.name;if(!o)throw Error("Invalid meta or missing name.");let n=await xr(e.subCommands);if(Xy(e)&&e.args)for(let[s,a]of Object.entries(e.args)){let c=a;if(c.type==="positional"){let u=c.required===!1,l=t?.args?.[s];l?Re.argument(s,l,u):Re.argument(s,void 0,u)}}if(n&&await eb(n,void 0,t?.subCommands),e.args)for(let[s,a]of Object.entries(e.args)){let c=a,u=typeof c=="object"&&"alias"in c?Array.isArray(c.alias)?c.alias[0]:c.alias:void 0,l=t?.options?.[s];l?u?Re.option(s,c.description??"",l,u):Re.option(s,c.description??"",l):u?Re.option(s,c.description??"",u):Re.option(s,c.description??"")}let i=S({meta:{name:"complete",description:"Generate shell completion scripts"},args:{shell:{type:"positional",description:"Shell type (zsh, bash, fish, powershell, fig)",required:!1}},async run(s){let a=s.rawArgs[0];a==="--"&&(a=void 0);let c=o;switch(a){case"zsh":{let u=Sn(o,c);console.log(u);break}case"bash":{let u=$n(o,c);console.log(u);break}case"fish":{let u=An(o,c);console.log(u);break}case"powershell":{let u=kn(o,c);console.log(u);break}case"fig":{let u=await Zk(e);console.log(u);break}default:{Hy(o);let u=s.rawArgs.slice(s.rawArgs.indexOf("--")+1);return Re.parse(u)}}}});return n?n.complete=i:e.subCommands={complete:i},Re}async function xr(e){return e instanceof Function?await e():await e}var rb=_(()=>{mc();fc();Jy();q()});q();q();Ms();var Uf=Symbol("wrappedCommand");function Fs(e){if(e instanceof Ad)return zc(e);if(e instanceof Error){let t=e.stack?.split(`
|
|
917
918
|
`).slice(0,3).join(`
|
|
918
|
-
`);return t&&t.trim().length>0?t:e.message}try{return JSON.stringify(e,null,2)}catch{return String(e)}}function
|
|
919
|
+
`);return t&&t.trim().length>0?t:e.message}try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Lw(e){console.error(Fs(e)),process.exitCode=1}function tr(e,t=Lw){let r=e;if(r[Uf])return;if(r[Uf]=!0,e.run){let o=e.run;e.run=async(...n)=>{try{return await o(...n)}catch(i){t(i)}}}if(!e.subCommands||typeof e.subCommands!=="object")return;for(let o of Object.values(e.subCommands))if(o&&typeof o==="object")tr(o,t)}function Q(e){let t;return()=>t??=e().then((r)=>{let o=nb(r);return tr(o),o}).catch((r)=>{throw t=void 0,r})}function nb(e){let t={...e},r=t.subCommands;if(r&&typeof r==="object")t.subCommands=Object.fromEntries(Object.entries(r).map(([o,n])=>[o,n&&typeof n==="object"?nb(n):n]));return t}var Rt=S({meta:{name:"kuber",version:"2.6.0",description:"Docker Compose -> K8s translation layer"},args:{config:{type:"string",description:"Path to a kuber configuration file"}},subCommands:{audit:Q(()=>Promise.resolve().then(() => (lm(),{})).then((e)=>rv)),ci:Q(()=>Promise.resolve().then(() => (fy(),{})).then((e)=>mA)),db:Q(()=>Promise.resolve().then(() => (my(),{})).then((e)=>bA)),down:Q(()=>Promise.resolve().then(() => (hy(),{})).then((e)=>wA)),export:Q(()=>Promise.resolve().then(() => (by(),{})).then((e)=>SA)),exec:Q(()=>Promise.resolve().then(() => (xy(),{})).then((e)=>CA)),logs:Q(()=>Promise.resolve().then(() => (ky(),{})).then((e)=>OA)),maintenance:Q(()=>Promise.resolve().then(() => (Cy(),{})).then((e)=>UA)),login:Q(()=>Promise.resolve().then(() => (En(),{})).then((e)=>qA)),logout:Q(()=>Promise.resolve().then(() => (En(),{})).then((e)=>QA)),operations:Q(()=>Promise.resolve().then(() => (Ty(),{})).then((e)=>XA)),ps:Q(()=>Promise.resolve().then(() => (By(),{})).then((e)=>ok)),restart:Q(()=>Promise.resolve().then(() => (zy(),{})).then((e)=>ik)),rollback:Q(()=>Promise.resolve().then(() => (Dy(),{})).then((e)=>ak)),s3:Q(()=>Promise.resolve().then(() => (Ly(),{})).then((e)=>mk)),start:Q(()=>Promise.resolve().then(() => (Vy(),{})).then((e)=>hk)),stop:Q(()=>Promise.resolve().then(() => (Uy(),{})).then((e)=>yk)),up:Q(()=>Promise.resolve().then(() => (vn(),{})).then((e)=>lA)),users:Q(()=>Promise.resolve().then(() => (Wy(),{})).then((e)=>Bk)),trust:Q(()=>Promise.resolve().then(() => (Gy(),{})).then((e)=>Lk)),whoami:Q(()=>Promise.resolve().then(() => (En(),{})).then((e)=>WA))}}),ob;function ib(){return ob??=(async()=>{let e=Rt.subCommands;if(e&&typeof e!=="function")Rt.subCommands=Object.fromEntries(await Promise.all(Object.entries(e).map(async([r,o])=>[r,typeof o==="function"?await o():await o])));await Promise.resolve().then(() => rb());return tb(Rt)})(),ob}oe();Oo();async function qk(){let{configPath:e,rawArgs:t}=dm(process.argv.slice(2));if(t[0]==="fuck")t[0]="rollback";if(t.length===0||t[0]==="complete"||t[0]==="--help"||t[0]==="-h")await ib();tr(Rt);let r=xc(Rt),o=new Set(["login","logout","whoami","maintenance"]);if(t[0]&&o.has(t[0])){await r({rawArgs:t});return}await vm(()=>r({rawArgs:t}),e)}qk().catch((e)=>{console.error(Fs(e)),process.exitCode=1});
|