@apptoolkit/harness 1.0.4 → 1.0.5
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 +5 -3
- package/harness.js +64 -45
- package/package.json +2 -1
- package/payload/HARNESS.md +7 -0
- package/payload/author-style/README.md +3 -1
- package/payload/author-style/check.test.ts +26 -0
- package/payload/author-style/check.ts +41 -22
- package/payload/harness/LEARNING.md +18 -0
- package/payload/harness/POLICY.md +2 -0
- package/payload/harness/runtime/harness.mjs +64 -45
- package/payload/harness/workflows/W18.md +1 -1
- package/payload/harness/workflows/W19.md +2 -2
- package/payload/harness/workflows/W20.md +16 -2
- package/payload/harness/workflows/W21.md +4 -0
package/harness.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var cp=Object.defineProperty;var ap=(e)=>e;function up(e,t){this[e]=ap.bind(null,t)}var Go=(e,t)=>{for(var r in t)cp(e,r,{get:t[r],enumerable:!0,configurable:!0,set:up.bind(t,r)})};var pp=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(o){r=[o]}if(r)throw r[0];return t};var op={};Go(op,{selectChoice:()=>Qh,selectMany:()=>em});import{openSync as Bh}from"node:fs";import{WriteStream as Jh}from"node:tty";import{Box as Vh,Text as ir,render as Hh,useApp as Kh,useInput as Gh}from"ink";import{createElement as Ke,useRef as qh,useState as Xh}from"react";function Yh({question:e,choices:t,initiallySelected:r,select:o}){let n=r!==void 0,[s,i]=Xh(()=>({position:0,checked:new Set(r),selectionRequired:!1})),c=qh(s),{exit:a}=Kh();function u(l){c.current=l,i(l)}Gh((l,f)=>{let d=c.current;if(f.escape||l==="q")a();else if(f.upArrow)u({...d,position:Math.max(0,d.position-1)});else if(f.downArrow)u({...d,position:Math.min(t.length-1,d.position+1)});else if(n&&l===" "){let m=t[d.position];if(!m)return;let y=new Set(d.checked);if(y.has(m.value))y.delete(m.value);else y.add(m.value);u({...d,checked:y,selectionRequired:!1})}else if(f.return){let m=n?t.filter(({value:v})=>d.checked.has(v)):t.slice(d.position,d.position+1),[y,...g]=m;if(!y){u({...d,selectionRequired:!0});return}o([y.value,...g.map(({value:v})=>v)]),a()}});let p=n?"Use the arrow keys, Space to toggle, Enter to confirm, or Esc to cancel.":"Use the arrow keys, Enter to select, or Esc to cancel.";return Ke(Vh,{flexDirection:"column"},Ke(ir,{bold:!0},e),...t.map(({label:l,value:f},d)=>{let m=d===s.position,y=l;if(n)y=`[${s.checked.has(f)?"x":" "}] ${l}`;return Ke(ir,{key:f,color:m?"cyan":"white"},`${m?"›":" "} ${y}`)}),Ke(ir,{dimColor:!0},p),s.selectionRequired&&Ke(ir,{color:"yellow"},"Select at least one option to continue."))}async function rp(e,t,r){if(!t.length)throw Error("Provide at least one choice for the selection menu.");let o,n=process.stdout.isTTY?void 0:new Jh(Bh("/dev/tty","w"));try{await Hh(Ke(Yh,{question:e,choices:t,initiallySelected:r,select(i){o=i}}),n?{stdout:n}:{}).waitUntilExit()}finally{n?.destroy()}if(o===void 0)throw Error("The operation was cancelled.");return o}async function Qh(e,t){let[r]=await rp(e,t);return r}function em(e,t,r=[]){return rp(e,t,r)}var np=()=>{};import{resolve as cr}from"node:path";import{fileURLToPath as tm}from"node:url";function qe(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 lr(e,t="|"){return e.map((r)=>hr(r)).join(t)}function Xe(e,t){if(typeof t==="bigint")return t.toString();return t}class qo{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function Ye(e){return new qo(e)}function Xo(e){return e===null||e===void 0}function _t(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Yo(e,t){let r=e/t,o=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-o)<n)return 0;return r-o}function Y(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Qe(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ue(e){return Qe(e._zod.def)??e._zod.def.shape}function Qo(e,t,r){Object.defineProperty(e,t,{get(){let o=r();return Y(this,t,o),o},enumerable:!0,configurable:!0})}function en(e,t,r){if(t in e)Y(e,t,r);else e[t]=r}function ke(e,t,r,o){let n=ue(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(n,s);if(!i.enumerable)continue;if(i.get)Qo(e,s,()=>{let c=t._zod.def.shape[s];return o?o(c,s):c});else en(e,s,o?o(i.value,s):i.value)}}function lp(e,t){for(let r of Reflect.ownKeys(t)){let o=Object.getOwnPropertyDescriptor(t,r);if(!o.enumerable)continue;if(o.get)Qo(e,r,()=>t[r]);else en(e,r,o.value)}}function B(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function tn(e){return JSON.stringify(e)}function rn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var fr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ie(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var on=Ye(()=>{if(J.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Ae(e){if(Ie(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(Ie(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function dr(e){if(Ae(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}var nn=new Set(["string","number","symbol"]);function ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function oe(e,t,r){let o=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)o._zod.parent=e;return o}function x(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function hr(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function sn(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var bt=(()=>({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]}))(),mr={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function fp(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 s={};return ke(s,e,kt(e,t)),oe(e,B(r,{shape:s,checks:[]}))}function kt(e,t){let r=ue(e),o=[];for(let n of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw Error(`Unrecognized key: "${String(n)}"`);if(t[n])o.push(n)}return o}function dp(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 s=new Set(kt(e,t)),i={};return ke(i,e,Reflect.ownKeys(ue(e)).filter((c)=>!s.has(c))),oe(e,B(r,{shape:i,checks:[]}))}function hp(e,t){if(!Ae(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let n=ue(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return oe(e,B(e._zod.def,{shape:cn(e,t)}))}function cn(e,t){let r={};return ke(r,e,Reflect.ownKeys(ue(e))),lp(r,t),r}function mp(e,t){if(!Ae(t))throw Error("Invalid input to safeExtend: expected a plain object");return oe(e,B(e._zod.def,{shape:cn(e,t)}))}function gp(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};ke(r,e,Reflect.ownKeys(ue(e))),ke(r,t,Reflect.ownKeys(ue(t)));let o=B(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return oe(e,o)}function an(e,t,r,o="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${o}() cannot be used on object schemas containing refinements`);let c=r?new Set(kt(t,r)):void 0,a={};return ke(a,t,Reflect.ownKeys(ue(t)),e&&((u,p)=>c&&!c.has(p)?u:new e({type:"optional",innerType:u}))),oe(t,B(t._zod.def,{shape:a,checks:[]}))}function yp(e,t,r){let o=r?new Set(kt(t,r)):void 0,n={};return ke(n,t,Reflect.ownKeys(ue(t)),(s,i)=>o&&!o.has(i)?s:new e({type:"nonoptional",innerType:s})),oe(t,B(t._zod.def,{shape:n}))}function ne(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 un(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 $t(e,t){return t.map((r)=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function Ge(e){return typeof e==="string"?e:e?.message}function gr(e){let t=[];for(let r of e??[]){let o=r._zod.def;if(!/_(length|size)$|_equals$/.test(o.check))break;let n=o.maximum??o.length??o.size;if(n>=0)t.push([n,r])}return t}function St(e,t,r){var o;for(let n=t;n<e.length;n++)(o=e[n]).schema??(o.schema=r)}function xe(e,t,r){var o;let n=e.inst?._zod?.traits;if(n?.has("$ZodType"))if(n.has("$ZodCheck"))(o=e).schema??(o.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:Ge(e.inst?._zod.def?.error?.(e))??Ge(s?.(e))??Ge(t?.error?.(e))??Ge(r.customError?.(e))??Ge(r.localeError?.(e))??"Invalid input",c={};for(let a of Object.keys(e)){if(a==="inst"||a==="schema"||a==="continue"||a==="input"||a==="__proto__")continue;c[a]=e[a]}if(c.path??(c.path=[]),c.message=i,t?.reportInput)c.input=e.input;return c}var xp=/[\uD800-\uDBFF]/;function zt(e){let t=e.length;if(!xp.test(e))return t;let r=t;for(let o=0;o<t-1;o++)if((e.charCodeAt(o)&64512)===55296&&(e.charCodeAt(o+1)&64512)===56320)r--,o++;return r}function Pt(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function pn(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 $e(...e){let[t,r,o]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:o};return{...t}}function ln(e,t){for(let r in t){let o=Object.getOwnPropertyDescriptor(t,r);if(o.get)Object.defineProperty(e,r,{...o,enumerable:!1});else vp(e,r,o.value)}}function pe(e,t,r,o=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:o,value:r}),r}function Et(e,t,r){return pe(e,t,r,!1)}function Zt(e,t){for(let r in e){let o=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return pe(this,r,o(this))},set(n){pe(this,r,n)}})}return t}function vp(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:pe(this,t,r.bind(this))},set(o){pe(this,t,o)}})}function wp(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var pr,ge=!1,_p={configurable:!0,get(){ge=!0;return}};function S(e,t,r){let o=Object.getPrototypeOf(e._zod);if(t in o&&pr!==e._zod){pr=void 0;return}pr=e._zod,Object.defineProperty(o,t,{configurable:!0,get(){Object.defineProperty(this,t,_p);let n=ge;ge=!1;try{let s=r(this);if(ge)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return ge=ge||n,s}catch(s){throw delete this[t],ge=ge||n,s}},set(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})}function bp(e,t,r,o){let n=wp(e,t);if(!n)return;Object.defineProperty(n,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:o,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:o,value:s})}})}var kp="~constantCatch";function fn(e){let t=()=>e;return t[kp]=!0,t}var dn;var yr={value:void 0,enumerable:!1},hn="captureStackTrace"in Error?Error:null;function $p(e){let t=hn;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return hn=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function h(e,t,r,o){let n={};function s(f){this.def=f,this.constr=l,this.traits=new Set}s.prototype=n;let i=r,c=i&&new WeakSet;function a(f,d){if(!f._zod){yr.value=new s(d);try{Object.defineProperty(f,"_zod",yr)}finally{yr.value=void 0}}else if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,d),c){let y=Object.getPrototypeOf(f),g=f._zod.constr.prototype,v=y;while(v&&v!==g)v=Object.getPrototypeOf(v);let b=v??y;if(!c.has(b))c.add(b),ln(b,i)}let m=l.prototype;for(let y in m){if(!Object.prototype.hasOwnProperty.call(m,y))continue;if(!(y in f))f[y]=m[y].bind(f)}}let u=o?.Parent??Object;class p extends u{}Object.defineProperty(p,"name",{value:e});function l(f){let d=o?.Parent?$p(p):this;a(d,f);let m=d._zod.deferred;if(m){for(let g of m)g();d._zod.deferred=void 0}let y=globalThis.__zod_globalConfig?.postProcessor;if(y)y(d);return d}return Object.defineProperty(l,"init",{value:a}),Object.defineProperty(l,Symbol.hasInstance,{value:(f)=>{if(o?.Parent&&f instanceof o.Parent)return!0;return f?._zod?.traits?.has(e)}}),Object.defineProperty(l,"name",{value:e}),l}class se extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class et extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(dn=globalThis).__zod_globalConfig??(dn.__zod_globalConfig={});var J=globalThis.__zod_globalConfig;function ee(e){if(e)Object.assign(J,e);return J}function Sp(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Xe,2)),e.message}function zp(e){this._zod.message=e}var Pp={get:Sp,set:zp,enumerable:!0,configurable:!0},vr={value:void 0,enumerable:!1},mn=new WeakSet([Object.prototype,Error.prototype]),gn=(e,t)=>{e.name="$ZodError",vr.value=t,Object.defineProperty(e,"issues",vr),vr.value=void 0,Object.defineProperty(e,"message",Pp);let r=Object.getPrototypeOf(e);if(!mn.has(r))mn.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let o=()=>this.message;return Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0})}})},yn=h("$ZodError",gn),pm=h("$ZodError",gn,void 0,{Parent:Error});function Ep(e,t,r){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0});else e[t]=r();return e[t]}function xn(e,t=(r)=>r.message){let r={},o=[];for(let n of e.issues)if(n.path.length>0)Ep(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,s=[])=>{for(let i of n.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map((c)=>o({issues:c},[...s,...i.path]));else if(i.code==="invalid_key")o({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")o({issues:i.issues},[...s,...i.path]);else{let c=[...s,...i.path];if(c.length===0)r._errors.push(t(i));else{let a=r,u=0;while(u<c.length){let p=c[u],l=u===c.length-1;if(p==="_errors"){if(l)a._errors.push(t(i));u++;continue}if(!Object.prototype.hasOwnProperty.call(a,p))Object.defineProperty(a,p,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=a[p];if(l)f._errors.push(t(i));a=f,u++}}}};return o(e),r}function Ot(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Rt=(e)=>{let t=(r,o,n,s)=>{let i=n?{...n,async:!1}:{async:!1},c=r._zod.run({value:o,issues:[]},i);if(c instanceof Promise)throw new se;if(c.issues.length){let a=new(s?.Err??e)(c.issues.map((u)=>xe(u,i,ee())));throw fr(a,s?.callee??t),a}return c.value};return t};var Ct=(e)=>{let t=async(r,o,n,s)=>{let i=n?{...n,async:!0}:{async:!0},c=r._zod.run({value:o,issues:[]},i);if(c instanceof Promise)c=await c;if(c.issues.length){let a=new(s?.Err??e)(c.issues.map((u)=>xe(u,i,ee())));throw fr(a,s?.callee??t),a}return c.value};return t};var It=(e)=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw new se;return s.issues.length?wn(e,s.issues,n):{success:!0,data:s.value}};function wn(e,t,r){let o;return{success:!1,get error(){if(!o)o=new e(t.map((n)=>xe(n,r,ee()))),t=void 0,r=void 0;return o},set error(n){o=n,t=void 0,r=void 0}}}var At=(e)=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)s=await s;return s.issues.length?wn(e,s.issues,n):{success:!0,data:s.value}};var Zp=Symbol.for("zod.compile.invalid"),Op=Symbol.for("zod.compile.fallback"),wr=(e,t,r)=>{let o=e._zod.bag.validator;if(o!==void 0){if(o(t)!==Zp)return!0;if(o.definite===!0&&r===void 0)return!1}return Rp(e,t,r)};function Rp(e,t,r){let o=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},n=e._zod.bag.fallbackRun,s;if(n)o[Op]=!0,s=n({value:t,issues:[]},o);else s=e._zod.run({value:t,issues:[]},o);if(s instanceof Promise)throw new se;return s.issues.length===0}var _r=async(e,t,r)=>{let o=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},o);if(n instanceof Promise)n=await n;return n.issues.length===0},_n=(e)=>{let t=Rt(e),r=(o,n,s,i)=>{let c=s?{...s,direction:"backward"}:{direction:"backward"};return t(o,n,c,Ot(r,i))};return r};var bn=(e)=>{let t=Rt(e),r=(o,n,s,i)=>t(o,n,s,Ot(r,i));return r};var kn=(e)=>{let t=Ct(e),r=async(o,n,s,i)=>{let c=s?{...s,direction:"backward"}:{direction:"backward"};return await t(o,n,c,Ot(r,i))};return r};var $n=(e)=>{let t=Ct(e),r=async(o,n,s,i)=>await t(o,n,s,Ot(r,i));return r};var Sn=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return It(e)(t,r,n)};var zn=(e)=>(t,r,o)=>It(e)(t,r,o);var Pn=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return At(e)(t,r,n)};var En=(e)=>async(t,r,o)=>At(e)(t,r,o);var Zn=/^[cC][0-9a-z]{6,}$/,On=/^[0-9a-z]+$/,Rn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Cn=/^[0-9a-vA-V]{20}$/,In=/^[A-Za-z0-9]{27}$/,An=/^[a-zA-Z0-9_-]{21}$/;function Tn(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Nn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var 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})$/,kr=(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})$`)};var Dn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Cp="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Fn(){return new RegExp(Cp,"u")}var Ln=/^(?:(?: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])$/,Mn=/^(([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}|:))$/;var Wn=/^((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])$/,Un=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Bn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Jn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Vn=/^https?$/,Hn=/^\+[1-9]\d{6,14}$/;var Kn="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Ip(e){return new RegExp(`^${e}$`)}var Gn=Ip(Kn);function br(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}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function qn(e){return new RegExp(`^${br(e)}$`)}function Xn(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${br({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,o=e.local?`${r}|${br({precision:e.precision})}`:r;return new RegExp(`^${Kn}T(?:${o})$`)}var Yn=/^[\s\S]{0,}$/;var Qn=/^-?\d+n?$/;var $r=/^-?\d+(?:\.\d+)?$/,es=/^(?:true|false)$/i;var ts=/^[^A-Z]*$/,rs=/^[^a-z]*$/;var A=h("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Sr=(e)=>{let t=e.value;return!Xo(t)&&t.length!==void 0},Tt={number:"number",bigint:"bigint",object:"date"},zr=h("$ZodCheckLessThan",(e,t)=>{A.init(e,t);let r=Tt[typeof t.value];e._zod.check=(o)=>{if(t.inclusive?o.value<=t.value:o.value<t.value)return;o.issues.push({origin:Tt[typeof o.value]??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})}}),Pr=h("$ZodCheckGreaterThan",(e,t)=>{A.init(e,t);let r=Tt[typeof t.value];e._zod.check=(o)=>{if(t.inclusive?o.value>=t.value:o.value>t.value)return;o.issues.push({origin:Tt[typeof o.value]??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})}}),os=h("$ZodCheckMultipleOf",(e,t)=>{A.init(e,t),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"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):Yo(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})}}),ns=h("$ZodCheckNumberFormat",(e,t)=>{A.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,s]=bt[t.format];e._zod.check=(i)=>{let c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(c>0)i.issues.push({input:c,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 i.issues.push({input:c,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(c<n)i.issues.push({origin:"number",input:c,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(c>s)i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var ss=h("$ZodCheckMaxLength",(e,t)=>{var r;A.init(e,t),(r=e._zod.def).when??(r.when=Sr),e._zod.check=(o)=>{let n=o.value,s=n.length;if((typeof n==="string"&&s>t.maximum?zt(n):s)<=t.maximum)return;let c=Pt(n);o.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),is=h("$ZodCheckMinLength",(e,t)=>{var r;A.init(e,t),(r=e._zod.def).when??(r.when=Sr),e._zod.check=(o)=>{let n=o.value,s=n.length;if((typeof n==="string"&&s>=t.minimum&&s<t.minimum*2?zt(n):s)>=t.minimum)return;let c=Pt(n);o.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),cs=h("$ZodCheckLengthEquals",(e,t)=>{var r;A.init(e,t),(r=e._zod.def).when??(r.when=Sr),e._zod.check=(o)=>{let n=o.value,s=n.length,i=typeof n==="string"&&s>=t.length&&s<=t.length*2?zt(n):s;if(i===t.length)return;let c=Pt(n),a=i>t.length;o.issues.push({origin:c,...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})}}),rt=h("$ZodCheckStringFormat",(e,t)=>{var r,o;if(A.init(e,t),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=()=>{})}),as=h("$ZodCheckRegex",(e,t)=>{rt.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})}}),us=h("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ts),rt.init(e,t)}),ps=h("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=rs),rt.init(e,t)}),ls=h("$ZodCheckIncludes",(e,t)=>{A.init(e,t);let r=ye(t.includes),o=new RegExp(typeof t.position==="number"?`^.{${t.position},}${r}`:r);t.pattern=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})}}),fs=h("$ZodCheckStartsWith",(e,t)=>{A.init(e,t);let r=new RegExp(`^${ye(t.prefix)}.*`);t.pattern??(t.pattern=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})}}),ds=h("$ZodCheckEndsWith",(e,t)=>{A.init(e,t);let r=new RegExp(`.*${ye(t.suffix)}$`);t.pattern??(t.pattern=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})}});var hs=h("$ZodCheckOverwrite",(e,t)=>{A.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Er{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
|
|
2
|
+
var Ep=Object.defineProperty;var Op=(e)=>e;function Zp(e,t){this[e]=Op.bind(null,t)}var sn=(e,t)=>{for(var r in t)Ep(e,r,{get:t[r],enumerable:!0,configurable:!0,set:Zp.bind(t,r)})};var Rp=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(o){r=[o]}if(r)throw r[0];return t};var $p={};sn($p,{selectChoice:()=>Im,selectMany:()=>jm});import{openSync as Sm}from"node:fs";import{WriteStream as zm}from"node:tty";import{Box as Pm,Text as br,render as Em,useApp as Om,useInput as Zm}from"ink";import{createElement as st,useRef as Rm,useState as Cm}from"react";function Am({question:e,choices:t,initiallySelected:r,select:o}){let n=r!==void 0,[s,i]=Cm(()=>({position:0,checked:new Set(r),selectionRequired:!1})),c=Rm(s),{exit:a}=Om();function u(l){c.current=l,i(l)}Zm((l,f)=>{let h=c.current;if(f.escape||l==="q")a();else if(f.upArrow)u({...h,position:Math.max(0,h.position-1)});else if(f.downArrow)u({...h,position:Math.min(t.length-1,h.position+1)});else if(n&&l===" "){let d=t[h.position];if(!d)return;let m=new Set(h.checked);if(m.has(d.value))m.delete(d.value);else m.add(d.value);u({...h,checked:m,selectionRequired:!1})}else if(f.return){let d=n?t.filter(({value:x})=>h.checked.has(x)):t.slice(h.position,h.position+1),[m,...y]=d;if(!m){u({...h,selectionRequired:!0});return}o([m.value,...y.map(({value:x})=>x)]),a()}});let p=n?"Use the arrow keys, Space to toggle, Enter to confirm, or Esc to cancel.":"Use the arrow keys, Enter to select, or Esc to cancel.";return st(Pm,{flexDirection:"column"},st(br,{bold:!0},e),...t.map(({label:l,value:f},h)=>{let d=h===s.position,m=l;if(n)m=`[${s.checked.has(f)?"x":" "}] ${l}`;return st(br,{key:f,color:d?"cyan":"white"},`${d?"›":" "} ${m}`)}),st(br,{dimColor:!0},p),s.selectionRequired&&st(br,{color:"yellow"},"Select at least one option to continue."))}async function kp(e,t,r){if(!t.length)throw Error("Provide at least one choice for the selection menu.");let o,n=process.stdout.isTTY?void 0:new zm(Sm("/dev/tty","w"));try{await Em(st(Am,{question:e,choices:t,initiallySelected:r,select(i){o=i}}),n?{stdout:n}:{}).waitUntilExit()}finally{n?.destroy()}if(o===void 0)throw Error("The operation was cancelled.");return o}async function Im(e,t){let[r]=await kp(e,t);return r}function jm(e,t,r=[]){return kp(e,t,r)}var Sp=()=>{};import{resolve as _r}from"node:path";import{fileURLToPath as Nm}from"node:url";function ct(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 $r(e,t="|"){return e.map((r)=>Pr(r)).join(t)}function at(e,t){if(typeof t==="bigint")return t.toString();return t}class an{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function ut(e){return new an(e)}function un(e){return e===null||e===void 0}function Ct(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function pn(e,t){let r=e/t,o=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-o)<n)return 0;return r-o}var cn=Symbol("evaluating");function ln(e,t,r){let o=void 0;Object.defineProperty(e,t,{get(){if(o===cn)return;if(o===void 0)o=cn,o=r();return o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Q(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function pt(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function le(e){return pt(e._zod.def)??e._zod.def.shape}function fn(e,t,r){Object.defineProperty(e,t,{get(){let o=r();return Q(this,t,o),o},enumerable:!0,configurable:!0})}function dn(e,t,r){if(t in e)Q(e,t,r);else e[t]=r}function Oe(e,t,r,o){let n=le(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(n,s);if(!i.enumerable)continue;if(i.get)fn(e,s,()=>{let c=t._zod.def.shape[s];return o?o(c,s):c});else dn(e,s,o?o(i.value,s):i.value)}}function Cp(e,t){for(let r of Reflect.ownKeys(t)){let o=Object.getOwnPropertyDescriptor(t,r);if(!o.enumerable)continue;if(o.get)fn(e,r,()=>t[r]);else dn(e,r,o.value)}}function q(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function hn(e){return JSON.stringify(e)}function mn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Sr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ve(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var gn=ut(()=>{if(H.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Ze(e){if(Ve(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(Ve(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function zr(e){if(Ze(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}var yn=new Set(["string","number","symbol"]);function _e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ne(e,t,r){let o=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)o._zod.parent=e;return o}function v(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 Pr(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function xn(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var At=(()=>({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]}))(),Er={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Ap(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 s={};return Oe(s,e,It(e,t)),ne(e,q(r,{shape:s,checks:[]}))}function It(e,t){let r=le(e),o=[];for(let n of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw Error(`Unrecognized key: "${String(n)}"`);if(t[n])o.push(n)}return o}function Ip(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 s=new Set(It(e,t)),i={};return Oe(i,e,Reflect.ownKeys(le(e)).filter((c)=>!s.has(c))),ne(e,q(r,{shape:i,checks:[]}))}function jp(e,t){if(!Ze(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let n=le(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ne(e,q(e._zod.def,{shape:vn(e,t)}))}function vn(e,t){let r={};return Oe(r,e,Reflect.ownKeys(le(e))),Cp(r,t),r}function Np(e,t){if(!Ze(t))throw Error("Invalid input to safeExtend: expected a plain object");return ne(e,q(e._zod.def,{shape:vn(e,t)}))}function Tp(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Oe(r,e,Reflect.ownKeys(le(e))),Oe(r,t,Reflect.ownKeys(le(t)));let o=q(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ne(e,o)}function wn(e,t,r,o="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${o}() cannot be used on object schemas containing refinements`);let c=r?new Set(It(t,r)):void 0,a={};return Oe(a,t,Reflect.ownKeys(le(t)),e&&((u,p)=>c&&!c.has(p)?u:new e({type:"optional",innerType:u}))),ne(t,q(t._zod.def,{shape:a,checks:[]}))}function Dp(e,t,r){let o=r?new Set(It(t,r)):void 0,n={};return Oe(n,t,Reflect.ownKeys(le(t)),(s,i)=>o&&!o.has(i)?s:new e({type:"nonoptional",innerType:s})),ne(t,q(t._zod.def,{shape:n}))}function se(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 bn(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 ke(e,t){return t.map((r)=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function it(e){return typeof e==="string"?e:e?.message}function Or(e){let t=[];for(let r of e??[]){let o=r._zod.def;if(!/_(length|size)$|_equals$/.test(o.check))break;let n=o.maximum??o.length??o.size;if(n>=0)t.push([n,r])}return t}function jt(e,t,r){var o;for(let n=t;n<e.length;n++)(o=e[n]).schema??(o.schema=r)}function ie(e,t,r){var o;let n=e.inst?._zod?.traits;if(n?.has("$ZodType"))if(n.has("$ZodCheck"))(o=e).schema??(o.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:it(e.inst?._zod.def?.error?.(e))??it(s?.(e))??it(t?.error?.(e))??it(r.customError?.(e))??it(r.localeError?.(e))??"Invalid input",c={};for(let a of Object.keys(e)){if(a==="inst"||a==="schema"||a==="continue"||a==="input"||a==="__proto__")continue;c[a]=e[a]}if(c.path??(c.path=[]),c.message=i,t?.reportInput)c.input=e.input;return c}var Fp=/[\uD800-\uDBFF]/;function Nt(e){let t=e.length;if(!Fp.test(e))return t;let r=t;for(let o=0;o<t-1;o++)if((e.charCodeAt(o)&64512)===55296&&(e.charCodeAt(o+1)&64512)===56320)r--,o++;return r}function Tt(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function _n(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 Re(...e){let[t,r,o]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:o};return{...t}}function kn(e,t){for(let r in t){let o=Object.getOwnPropertyDescriptor(t,r);if(o.get)Object.defineProperty(e,r,{...o,enumerable:!1});else Lp(e,r,o.value)}}function fe(e,t,r,o=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:o,value:r}),r}function Dt(e,t,r){return fe(e,t,r,!1)}function Ft(e,t){for(let r in e){let o=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return fe(this,r,o(this))},set(n){fe(this,r,n)}})}return t}function Lp(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:fe(this,t,r.bind(this))},set(o){fe(this,t,o)}})}function Mp(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var kr,be=!1,Wp={configurable:!0,get(){be=!0;return}};function E(e,t,r){let o=Object.getPrototypeOf(e._zod);if(t in o&&kr!==e._zod){kr=void 0;return}kr=e._zod,Object.defineProperty(o,t,{configurable:!0,get(){Object.defineProperty(this,t,Wp);let n=be;be=!1;try{let s=r(this);if(be)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return be=be||n,s}catch(s){throw delete this[t],be=be||n,s}},set(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})}function Up(e,t,r,o){let n=Mp(e,t);if(!n)return;Object.defineProperty(n,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:o,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:o,value:s})}})}var Bp="~constantCatch";function $n(e){let t=()=>e;return t[Bp]=!0,t}var Sn;var Zr={value:void 0,enumerable:!1},zn="captureStackTrace"in Error?Error:null;function Vp(e){let t=zn;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return zn=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function g(e,t,r,o){let n={};function s(f){this.def=f,this.constr=l,this.traits=new Set}s.prototype=n;let i=r,c=i&&new WeakSet;function a(f,h){if(!f._zod){Zr.value=new s(h);try{Object.defineProperty(f,"_zod",Zr)}finally{Zr.value=void 0}}else if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,h),c){let m=Object.getPrototypeOf(f),y=f._zod.constr.prototype,x=m;while(x&&x!==y)x=Object.getPrototypeOf(x);let w=x??m;if(!c.has(w))c.add(w),kn(w,i)}let d=l.prototype;for(let m in d){if(!Object.prototype.hasOwnProperty.call(d,m))continue;if(!(m in f))f[m]=d[m].bind(f)}}let u=o?.Parent??Object;class p extends u{}Object.defineProperty(p,"name",{value:e});function l(f){let h=o?.Parent?Vp(p):this;a(h,f);let d=h._zod.deferred;if(d){for(let y of d)y();h._zod.deferred=void 0}let m=globalThis.__zod_globalConfig?.postProcessor;if(m)m(h);return h}return Object.defineProperty(l,"init",{value:a}),Object.defineProperty(l,Symbol.hasInstance,{value:(f)=>{if(o?.Parent&&f instanceof o.Parent)return!0;return f?._zod?.traits?.has(e)}}),Object.defineProperty(l,"name",{value:e}),l}class ce extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class lt extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Sn=globalThis).__zod_globalConfig??(Sn.__zod_globalConfig={});var H=globalThis.__zod_globalConfig;function X(e){if(e)Object.assign(H,e);return H}function Jp(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,at,2)),e.message}function Hp(e){this._zod.message=e}var Kp={get:Jp,set:Hp,enumerable:!0,configurable:!0},Cr={value:void 0,enumerable:!1},Pn=new WeakSet([Object.prototype,Error.prototype]),En=(e,t)=>{e.name="$ZodError",Cr.value=t,Object.defineProperty(e,"issues",Cr),Cr.value=void 0,Object.defineProperty(e,"message",Kp);let r=Object.getPrototypeOf(e);if(!Pn.has(r))Pn.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let o=()=>this.message;return Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0})}})},On=g("$ZodError",En),Vm=g("$ZodError",En,void 0,{Parent:Error});function Gp(e,t,r){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0});else e[t]=r();return e[t]}function Zn(e,t=(r)=>r.message){let r={},o=[];for(let n of e.issues)if(n.path.length>0)Gp(r,n.path[0],()=>[]).push(t(n));else o.push(t(n));return{formErrors:o,fieldErrors:r}}function Rn(e,t=(r)=>r.message){let r={_errors:[]},o=(n,s=[])=>{for(let i of n.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map((c)=>o({issues:c},[...s,...i.path]));else if(i.code==="invalid_key")o({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")o({issues:i.issues},[...s,...i.path]);else{let c=[...s,...i.path];if(c.length===0)r._errors.push(t(i));else{let a=r,u=0;while(u<c.length){let p=c[u],l=u===c.length-1;if(p==="_errors"){if(l)a._errors.push(t(i));u++;continue}if(!Object.prototype.hasOwnProperty.call(a,p))Object.defineProperty(a,p,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=a[p];if(l)f._errors.push(t(i));a=f,u++}}}};return o(e),r}function Lt(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Mt=(e)=>{let t=(r,o,n,s)=>{let i=n?{...n,async:!1}:{async:!1},c=r._zod.run({value:o,issues:[]},i);if(c instanceof Promise)throw new ce;if(c.issues.length){let a=new(s?.Err??e)(c.issues.map((u)=>ie(u,i,X())));throw Sr(a,s?.callee??t),a}return c.value};return t};var Wt=(e)=>{let t=async(r,o,n,s)=>{let i=n?{...n,async:!0}:{async:!0},c=r._zod.run({value:o,issues:[]},i);if(c instanceof Promise)c=await c;if(c.issues.length){let a=new(s?.Err??e)(c.issues.map((u)=>ie(u,i,X())));throw Sr(a,s?.callee??t),a}return c.value};return t};var Ut=(e)=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw new ce;return s.issues.length?Cn(e,s.issues,n):{success:!0,data:s.value}};function Cn(e,t,r){let o;return{success:!1,get error(){if(!o)o=new e(t.map((n)=>ie(n,r,X()))),t=void 0,r=void 0;return o},set error(n){o=n,t=void 0,r=void 0}}}var Bt=(e)=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)s=await s;return s.issues.length?Cn(e,s.issues,n):{success:!0,data:s.value}};var qp=Symbol.for("zod.compile.invalid"),Xp=Symbol.for("zod.compile.fallback"),Ar=(e,t,r)=>{let o=e._zod.bag.validator;if(o!==void 0){if(o(t)!==qp)return!0;if(o.definite===!0&&r===void 0)return!1}return Yp(e,t,r)};function Yp(e,t,r){let o=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},n=e._zod.bag.fallbackRun,s;if(n)o[Xp]=!0,s=n({value:t,issues:[]},o);else s=e._zod.run({value:t,issues:[]},o);if(s instanceof Promise)throw new ce;return s.issues.length===0}var Ir=async(e,t,r)=>{let o=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},o);if(n instanceof Promise)n=await n;return n.issues.length===0},An=(e)=>{let t=Mt(e),r=(o,n,s,i)=>{let c=s?{...s,direction:"backward"}:{direction:"backward"};return t(o,n,c,Lt(r,i))};return r};var In=(e)=>{let t=Mt(e),r=(o,n,s,i)=>t(o,n,s,Lt(r,i));return r};var jn=(e)=>{let t=Wt(e),r=async(o,n,s,i)=>{let c=s?{...s,direction:"backward"}:{direction:"backward"};return await t(o,n,c,Lt(r,i))};return r};var Nn=(e)=>{let t=Wt(e),r=async(o,n,s,i)=>await t(o,n,s,Lt(r,i));return r};var Tn=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Ut(e)(t,r,n)};var Dn=(e)=>(t,r,o)=>Ut(e)(t,r,o);var Fn=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Bt(e)(t,r,n)};var Ln=(e)=>async(t,r,o)=>Bt(e)(t,r,o);var Mn=/^[cC][0-9a-z]{6,}$/,Wn=/^[0-9a-z]+$/,Un=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Bn=/^[0-9a-vA-V]{20}$/,Vn=/^[A-Za-z0-9]{27}$/,Jn=/^[a-zA-Z0-9_-]{21}$/;function Hn(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Kn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Gn=/^([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})$/,Nr=(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})$`)};var qn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Qp="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Xn(){return new RegExp(Qp,"u")}var Yn=/^(?:(?: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])$/,Qn=/^(([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}|:))$/;var es=/^((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])$/,ts=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,rs=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,os=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var ns=/^https?$/,ss=/^\+[1-9]\d{6,14}$/;var is="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function el(e){return new RegExp(`^${e}$`)}var cs=el(is);function jr(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}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function as(e){return new RegExp(`^${jr(e)}$`)}function us(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${jr({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,o=e.local?`${r}|${jr({precision:e.precision})}`:r;return new RegExp(`^${is}T(?:${o})$`)}var ps=/^[\s\S]{0,}$/;var ls=/^-?\d+n?$/,Tr=/^-?\d+$/,ft=/^-?\d+(?:\.\d+)?$/,fs=/^(?:true|false)$/i,ds=/^null$/i;var hs=/^[^A-Z]*$/,ms=/^[^a-z]*$/;var F=g("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Dr=(e)=>{let t=e.value;return!un(t)&&t.length!==void 0},Vt={number:"number",bigint:"bigint",object:"date"},Fr=g("$ZodCheckLessThan",(e,t)=>{F.init(e,t);let r=Vt[typeof t.value];e._zod.check=(o)=>{if(t.inclusive?o.value<=t.value:o.value<t.value)return;o.issues.push({origin:Vt[typeof o.value]??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})}}),Lr=g("$ZodCheckGreaterThan",(e,t)=>{F.init(e,t);let r=Vt[typeof t.value];e._zod.check=(o)=>{if(t.inclusive?o.value>=t.value:o.value>t.value)return;o.issues.push({origin:Vt[typeof o.value]??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})}}),gs=g("$ZodCheckMultipleOf",(e,t)=>{F.init(e,t),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"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):pn(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})}}),ys=g("$ZodCheckNumberFormat",(e,t)=>{F.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,s]=At[t.format];e._zod.check=(i)=>{let c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(c>0)i.issues.push({input:c,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 i.issues.push({input:c,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(c<n)i.issues.push({origin:"number",input:c,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(c>s)i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var xs=g("$ZodCheckMaxLength",(e,t)=>{var r;F.init(e,t),(r=e._zod.def).when??(r.when=Dr),e._zod.check=(o)=>{let n=o.value,s=n.length;if((typeof n==="string"&&s>t.maximum?Nt(n):s)<=t.maximum)return;let c=Tt(n);o.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),vs=g("$ZodCheckMinLength",(e,t)=>{var r;F.init(e,t),(r=e._zod.def).when??(r.when=Dr),e._zod.check=(o)=>{let n=o.value,s=n.length;if((typeof n==="string"&&s>=t.minimum&&s<t.minimum*2?Nt(n):s)>=t.minimum)return;let c=Tt(n);o.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ws=g("$ZodCheckLengthEquals",(e,t)=>{var r;F.init(e,t),(r=e._zod.def).when??(r.when=Dr),e._zod.check=(o)=>{let n=o.value,s=n.length,i=typeof n==="string"&&s>=t.length&&s<=t.length*2?Nt(n):s;if(i===t.length)return;let c=Tt(n),a=i>t.length;o.issues.push({origin:c,...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})}}),ht=g("$ZodCheckStringFormat",(e,t)=>{var r,o;if(F.init(e,t),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=()=>{})}),bs=g("$ZodCheckRegex",(e,t)=>{ht.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})}}),_s=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=hs),ht.init(e,t)}),ks=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ms),ht.init(e,t)}),$s=g("$ZodCheckIncludes",(e,t)=>{F.init(e,t);let r=_e(t.includes),o=new RegExp(typeof t.position==="number"?`^.{${t.position},}${r}`:r);t.pattern=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})}}),Ss=g("$ZodCheckStartsWith",(e,t)=>{F.init(e,t);let r=new RegExp(`^${_e(t.prefix)}.*`);t.pattern??(t.pattern=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})}}),zs=g("$ZodCheckEndsWith",(e,t)=>{F.init(e,t);let r=new RegExp(`.*${_e(t.suffix)}$`);t.pattern??(t.pattern=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})}});var Ps=g("$ZodCheckOverwrite",(e,t)=>{F.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Mr{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
|
|
3
3
|
`).filter((s)=>s),o=Math.min(...r.map((s)=>s.length-s.trimStart().length)),n=r.map((s)=>s.slice(o)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of n)this.content.push(s)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
4
4
|
${t.join(`
|
|
5
5
|
`)}
|
|
6
|
-
};`)(...Object.values(this.closed))}}var gs={major:4,minor:6,patch:7};var P=h("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=gs;let o=e._zod.def.checks,n=e._zod.traits.has("$ZodCheck")?[e,...o??[]]:o?.length?[...o]:[];for(let s of n)for(let i of s._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(c,a,u)=>{if(c.memo)return c;let p=ne(c),l;for(let f of a){if(f._zod.def.when){if(un(c))continue;if(!f._zod.def.when(c))continue}else if(p)continue;let d=c.issues.length,m=f._zod.check(c);if(m instanceof Promise&&u?.async===!1)throw new se;if(l||m instanceof Promise)l=(l??Promise.resolve()).then(async()=>{if(await m,c.issues.length===d)return;if(St(c.issues,d,e),!p)p=ne(c,d)});else{if(c.issues.length===d)continue;if(St(c.issues,d,e),!p)p=ne(c,d)}}if(l)return l.then(()=>c);return c},i=(c,a,u)=>{if(ne(c))return c.aborted=!0,c;let p=s(a,n,u);if(p instanceof Promise){if(u.async===!1)throw new se;return p.then((l)=>e._zod.parse(l,u))}return e._zod.parse(p,u)};e._zod.run=(c,a)=>{if(a.skipChecks)return e._zod.parse(c,a);if(a.direction==="backward"){let p=e._zod.parse({value:c.value,issues:[]},{...a,skipChecks:!0});if(p instanceof Promise)return p.then((l)=>i(l,c,a));return i(p,c,a)}let u=e._zod.parse(c,a);if(u instanceof Promise){if(a.async===!1)throw new se;return u.then((p)=>s(p,n,a))}return s(u,n,a)}}},{get "~standard"(){return Et(this,"~standard",Or(this))},set "~standard"(e){pe(this,"~standard",e)}}),Ps=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>xe(r,t,ee()))}:{value:e.value};async function Tp(e,t){let r={async:!0};return Ps(await e._zod.run({value:t,issues:[]},r),r)}function Or(e){return{validate:(t)=>{let r={async:!1};try{let o=e._zod.run({value:t,issues:[]},r);if(!(o instanceof Promise))return Ps(o,r)}catch(o){}return Tp(e,t)},vendor:"zod",version:1}}var Ft=h("$ZodString",(e,t)=>{P.init(e,t),e._zod.pattern=t.pattern??Yn,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}}),E=h("$ZodStringFormat",(e,t)=>{rt.init(e,t),Ft.init(e,t)}),Es=h("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=jn),E.init(e,t)}),Zs=h("$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=kr(o))}else t.pattern??(t.pattern=kr());E.init(e,t)}),Os=h("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Dn),E.init(e,t)}),Rs=1,jt=2;function Cs(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Np(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return Cs(e)||jt;return jp(e,t)}function jp(e,t){if(!t.normalize&&t.protocol?.source===Vn.source&&!/^https?:\/\//i.test(e))return Rs;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??jt}return new URL(e)}catch{return jt}}var Dp=/[\t\n\r]/g;function ys(e){return e.replace(Dp,"")}function Fp(e,t){return t.lastIndex=0,t.test(e.hostname)}function Lp(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Is=h("$ZodURL",(e,t)=>{E.init(e,t),e._zod.check=(r)=>{try{let o=r.value.trim(),n=Np(o,t);if(n===Rs){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(n===jt){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(n===!0){r.value=ys(o);return}if(t.hostname&&!Fp(n,t.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&&!Lp(n,t.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort});r.value=t.normalize?n.href:ys(o);return}catch(o){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),As=h("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Fn()),E.init(e,t)}),Ts=h("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?An:Tn(t.length)),E.init(e,t)}),Ns=h("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Zn),E.init(e,t)}),js=h("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=On),E.init(e,t)}),Ds=h("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Rn),E.init(e,t)}),Fs=h("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Cn),E.init(e,t)}),Ls=h("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=In),E.init(e,t)}),Ms=h("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Xn(t)),E.init(e,t)}),Ws=h("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Gn),E.init(e,t)}),Us=h("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=qn(t)),E.init(e,t)}),Bs=h("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Nn),E.init(e,t)}),Js=h("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ln),E.init(e,t)}),Mp=/^[0-9a-fA-F:.]+$/;function Vs(e){if(!Mp.test(e))return!1;return Cs(`http://[${e}]`)}var Hs=h("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Mn),E.init(e,t),e._zod.check=(r)=>{if(!Vs(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var Ks=h("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Wn),E.init(e,t)});function Wp(e){let t=e.split("/");if(t.length!==2)return!1;let[r,o]=t;if(!o)return!1;let n=Number(o);if(`${n}`!==o)return!1;if(n<0||n>128)return!1;return Vs(r)}var Gs=h("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Un),E.init(e,t),e._zod.check=(r)=>{if(!Wp(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function qs(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}}var Rr=/^[0-9a-zA-Z+/]*={0,2}$/,Xs=h("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Rr),E.init(e,t),e._zod.check=(r)=>{if(qs(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),Lt=/^[A-Za-z0-9_-]*$/;function Up(e){if(!Lt.test(e))return!1;let t=e.replace(/[-_]/g,(o)=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return qs(r)}var Ys=h("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Lt),E.init(e,t),e._zod.check=(r)=>{if(Up(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Qs=h("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Hn),E.init(e,t)});function Bp(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}}var ei=h("$ZodJWT",(e,t)=>{E.init(e,t),e._zod.check=(r)=>{if(Bp(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Cr=h("$ZodNumber",(e,t)=>{P.init(e,t),e._zod.pattern=$r,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch(i){}let n=r.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let s=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?String(n):void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...s?{received:s}:{}}),r}}),ti=h("$ZodNumberFormat",(e,t)=>{ns.init(e,t),Cr.init(e,t)}),ri=h("$ZodBoolean",(e,t)=>{P.init(e,t),e._zod.pattern=es,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(s){}let n=r.value;if(typeof n==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),oi=h("$ZodBigInt",(e,t)=>{P.init(e,t),e._zod.pattern=Qn,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}});var ni=h("$ZodUnknown",(e,t)=>{P.init(e,t),e._zod.parse=(r)=>r}),si=h("$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)});var ii=h("$ZodDate",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(c){}let n=r.value,s=n instanceof Date;if(s&&!Number.isNaN(n.getTime()))return r;return r.issues.push({expected:"date",code:"invalid_type",input:n,...s?{received:"Invalid Date"}:{},inst:e}),r}});function Jp(e,t){let r=gr(e._zod.def.checks);if(!r.length)return;let o=Math.min(...r.map((s)=>s[0])),n=e._zod.parse;e._zod.parse=(s,i)=>{let c=t(s.value);if(c>o&&!i?.skipChecks&&i?.direction!=="backward"){for(let[a,u]of gr(e._zod.def.checks))if(c>a&&u._zod.def.when(s)){let p=s.issues.length;return u._zod.check(s),s.issues[p].continue=!1,St(s.issues,p,e),s}}return n(s,i)}}var Vp=(e)=>Array.isArray(e)?e.length:-1;function xs(e,t,r){if(e.issues.length)t.issues.push(...$t(r,e.issues));t.value[r]=e.value}var ci=h("$ZodArray",(e,t)=>{P.init(e,t);let r=J.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let s=o.value;if(!Array.isArray(s))return o.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),o;o.value=r?r.alloc(e,o,Array(s.length),n):Array(s.length);let i=[],c=n?.abortEarly;for(let a=0;a<s.length;a++){let u=s[a],p=t.element._zod.run({value:u,issues:[]},n);if(p instanceof Promise)i.push(p.then((l)=>xs(l,o,a)));else if(xs(p,o,a),c&&p.issues.length!==0&&ne(p))break}if(i.length)return Promise.all(i).then(()=>o);return o},Jp(e,Vp)});function Dt(e,t,r,o,n,s){let i=r in o,c=s==="optional";if(!i&&c&&n==="optional")return;if(e.issues.length){if(n!==void 0&&c&&!i)return;t.issues.push(...$t(r,e.issues))}if(!i&&n===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(i||n==="defaulted"&&!c)t.value[r]=void 0}else t.value[r]=e.value}var Hp=[];function ai(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),o=r.length?r:Hp,n=o.length?[...t,...o]:t;for(let i of n)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=sn(e.shape);return{...e,allKeys:n,symbolKeys:o,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function ui(e,t,r,o,n,s,i){let c=[],a=n.keySet,u=n.catchall._zod,p=u.def.type,{optin:l,optout:f}=u,d=0;for(let m in t){if(i&&r.issues.length!==d){if(ne(r,d))break;d=r.issues.length}if(a.has(m))continue;if(m==="__proto__"){if(p==="never")c.push(m);continue}if(p==="never"){c.push(m);continue}let y=u.run({value:t[m],issues:[]},o);if(y instanceof Promise)e.push(y.then((g)=>Dt(g,r,m,t,l,f)));else Dt(y,r,m,t,l,f)}if(c.length)r.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:s,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var Kp=h("$ZodObject",(e,t)=>{P.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),o=r?.get?r.get.raw:t.shape??{};if(o){let u=()=>{let p={...o};return Object.defineProperty(t,"shape",{value:p}),u.raw=p,p};u.raw=o,Object.defineProperty(t,"shape",{get:u})}let n=Ye(()=>ai(t));S(e,"propValues",(u)=>{let p=u.def.shape,l={};for(let f in p){let d=p[f]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(l,f))Y(l,f,new Set);for(let m of d.values)l[f].add(m);if(d.optin!==void 0)l[f].add(void 0)}}return l});let s=Ie,i=t.catchall,c,a=J.memoizer;a?.attach(e),e._zod.parse=(u,p)=>{c??(c=n.value);let l=u.value;if(!s(l))return u.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),u;u.value=a?a.alloc(e,u,{},p):{};let f=[],d=c.shape,m=p?.abortEarly,y=u.issues.length;for(let g of c.allKeys){if(m&&u.issues.length!==y){if(ne(u,y))break;y=u.issues.length}if(g==="__proto__")continue;let v=d[g],b=v._zod.optin,U=v._zod.optout,ae=v._zod.run({value:l[g],issues:[]},p);if(ae instanceof Promise)f.push(ae.then((Z)=>Dt(Z,u,g,l,b,U)));else Dt(ae,u,g,l,b,U)}if(!i)return f.length?Promise.all(f).then(()=>u):u;return ui(f,l,u,p,n.value,e,m===!0)}}),pi=h("$ZodObjectJIT",(e,t)=>{Kp.init(e,t);let r=e._zod.parse,o=Ye(()=>ai(t)),n=J.memoizer,s=(d)=>{let m=o.value,y=m.symbolKeys,g=new Er(["payload","ctx"],{shape:d,inst:e,memo:n,syms:y}),v=(Z)=>`shape[${Z}]._zod.run({ value: input[${Z}], issues: [] }, ctx)`,b=(Z,w)=>`
|
|
7
|
-
let ${
|
|
8
|
-
for (let i = 0; i < ${
|
|
9
|
-
const iss = ${
|
|
10
|
-
iss.path = iss.path ? [${
|
|
6
|
+
};`)(...Object.values(this.closed))}}var Os={major:4,minor:6,patch:7};var Z=g("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Os;let o=e._zod.def.checks,n=e._zod.traits.has("$ZodCheck")?[e,...o??[]]:o?.length?[...o]:[];for(let s of n)for(let i of s._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(c,a,u)=>{if(c.memo)return c;let p=se(c),l;for(let f of a){if(f._zod.def.when){if(bn(c))continue;if(!f._zod.def.when(c))continue}else if(p)continue;let h=c.issues.length,d=f._zod.check(c);if(d instanceof Promise&&u?.async===!1)throw new ce;if(l||d instanceof Promise)l=(l??Promise.resolve()).then(async()=>{if(await d,c.issues.length===h)return;if(jt(c.issues,h,e),!p)p=se(c,h)});else{if(c.issues.length===h)continue;if(jt(c.issues,h,e),!p)p=se(c,h)}}if(l)return l.then(()=>c);return c},i=(c,a,u)=>{if(se(c))return c.aborted=!0,c;let p=s(a,n,u);if(p instanceof Promise){if(u.async===!1)throw new ce;return p.then((l)=>e._zod.parse(l,u))}return e._zod.parse(p,u)};e._zod.run=(c,a)=>{if(a.skipChecks)return e._zod.parse(c,a);if(a.direction==="backward"){let p=e._zod.parse({value:c.value,issues:[]},{...a,skipChecks:!0});if(p instanceof Promise)return p.then((l)=>i(l,c,a));return i(p,c,a)}let u=e._zod.parse(c,a);if(u instanceof Promise){if(a.async===!1)throw new ce;return u.then((p)=>s(p,n,a))}return s(u,n,a)}}},{get "~standard"(){return Dt(this,"~standard",Ur(this))},set "~standard"(e){fe(this,"~standard",e)}}),Ls=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>ie(r,t,X()))}:{value:e.value};async function tl(e,t){let r={async:!0};return Ls(await e._zod.run({value:t,issues:[]},r),r)}function Ur(e){return{validate:(t)=>{let r={async:!1};try{let o=e._zod.run({value:t,issues:[]},r);if(!(o instanceof Promise))return Ls(o,r)}catch(o){}return tl(e,t)},vendor:"zod",version:1}}var Gt=g("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=t.pattern??ps,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}}),A=g("$ZodStringFormat",(e,t)=>{ht.init(e,t),Gt.init(e,t)}),Ms=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Gn),A.init(e,t)}),Ws=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=Nr(o))}else t.pattern??(t.pattern=Nr());A.init(e,t)}),Us=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=qn),A.init(e,t)}),Bs=1,Ht=2;function Vs(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function rl(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return Vs(e)||Ht;return ol(e,t)}function ol(e,t){if(!t.normalize&&t.protocol?.source===ns.source&&!/^https?:\/\//i.test(e))return Bs;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??Ht}return new URL(e)}catch{return Ht}}var nl=/[\t\n\r]/g;function Zs(e){return e.replace(nl,"")}function sl(e,t){return t.lastIndex=0,t.test(e.hostname)}function il(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Js=g("$ZodURL",(e,t)=>{A.init(e,t),e._zod.check=(r)=>{try{let o=r.value.trim(),n=rl(o,t);if(n===Bs){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(n===Ht){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(n===!0){r.value=Zs(o);return}if(t.hostname&&!sl(n,t.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&&!il(n,t.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort});r.value=t.normalize?n.href:Zs(o);return}catch(o){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Hs=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Xn()),A.init(e,t)}),Ks=g("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?Jn:Hn(t.length)),A.init(e,t)}),Gs=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Mn),A.init(e,t)}),qs=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Wn),A.init(e,t)}),Xs=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Un),A.init(e,t)}),Ys=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Bn),A.init(e,t)}),Qs=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Vn),A.init(e,t)}),ei=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=us(t)),A.init(e,t)}),ti=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=cs),A.init(e,t)}),ri=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=as(t)),A.init(e,t)}),oi=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Kn),A.init(e,t)}),ni=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Yn),A.init(e,t)}),cl=/^[0-9a-fA-F:.]+$/;function si(e){if(!cl.test(e))return!1;return Vs(`http://[${e}]`)}var ii=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Qn),A.init(e,t),e._zod.check=(r)=>{if(!si(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var ci=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=es),A.init(e,t)});function al(e){let t=e.split("/");if(t.length!==2)return!1;let[r,o]=t;if(!o)return!1;let n=Number(o);if(`${n}`!==o)return!1;if(n<0||n>128)return!1;return si(r)}var ai=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ts),A.init(e,t),e._zod.check=(r)=>{if(!al(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function ui(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}}var Br=/^[0-9a-zA-Z+/]*={0,2}$/,pi=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Br),A.init(e,t),e._zod.check=(r)=>{if(ui(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),qt=/^[A-Za-z0-9_-]*$/;function ul(e){if(!qt.test(e))return!1;let t=e.replace(/[-_]/g,(o)=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return ui(r)}var li=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=qt),A.init(e,t),e._zod.check=(r)=>{if(ul(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),fi=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ss),A.init(e,t)});function pl(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}}var di=g("$ZodJWT",(e,t)=>{A.init(e,t),e._zod.check=(r)=>{if(pl(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Vr=g("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=ft,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch(i){}let n=r.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let s=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?String(n):void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...s?{received:s}:{}}),r}}),hi=g("$ZodNumberFormat",(e,t)=>{ys.init(e,t),Vr.init(e,t)}),mi=g("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=fs,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(s){}let n=r.value;if(typeof n==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),gi=g("$ZodBigInt",(e,t)=>{Z.init(e,t),e._zod.pattern=ls,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}});var yi=g("$ZodNull",(e,t)=>{Z.init(e,t),e._zod.pattern=ds,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}});var xi=g("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=(r)=>r}),vi=g("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var wi=g("$ZodDate",(e,t)=>{Z.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(c){}let n=r.value,s=n instanceof Date;if(s&&!Number.isNaN(n.getTime()))return r;return r.issues.push({expected:"date",code:"invalid_type",input:n,...s?{received:"Invalid Date"}:{},inst:e}),r}});function ll(e,t){let r=Or(e._zod.def.checks);if(!r.length)return;let o=Math.min(...r.map((s)=>s[0])),n=e._zod.parse;e._zod.parse=(s,i)=>{let c=t(s.value);if(c>o&&!i?.skipChecks&&i?.direction!=="backward"){for(let[a,u]of Or(e._zod.def.checks))if(c>a&&u._zod.def.when(s)){let p=s.issues.length;return u._zod.check(s),s.issues[p].continue=!1,jt(s.issues,p,e),s}}return n(s,i)}}var fl=(e)=>Array.isArray(e)?e.length:-1;function Rs(e,t,r){if(e.issues.length)t.issues.push(...ke(r,e.issues));t.value[r]=e.value}var bi=g("$ZodArray",(e,t)=>{Z.init(e,t);let r=H.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let s=o.value;if(!Array.isArray(s))return o.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),o;o.value=r?r.alloc(e,o,Array(s.length),n):Array(s.length);let i=[],c=n?.abortEarly;for(let a=0;a<s.length;a++){let u=s[a],p=t.element._zod.run({value:u,issues:[]},n);if(p instanceof Promise)i.push(p.then((l)=>Rs(l,o,a)));else if(Rs(p,o,a),c&&p.issues.length!==0&&se(p))break}if(i.length)return Promise.all(i).then(()=>o);return o},ll(e,fl)});function Kt(e,t,r,o,n,s){let i=r in o,c=s==="optional";if(!i&&c&&n==="optional")return;if(e.issues.length){if(n!==void 0&&c&&!i)return;t.issues.push(...ke(r,e.issues))}if(!i&&n===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(i||n==="defaulted"&&!c)t.value[r]=void 0}else t.value[r]=e.value}var dl=[];function _i(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),o=r.length?r:dl,n=o.length?[...t,...o]:t;for(let i of n)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=xn(e.shape);return{...e,allKeys:n,symbolKeys:o,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function ki(e,t,r,o,n,s,i){let c=[],a=n.keySet,u=n.catchall._zod,p=u.def.type,{optin:l,optout:f}=u,h=0;for(let d in t){if(i&&r.issues.length!==h){if(se(r,h))break;h=r.issues.length}if(a.has(d))continue;if(d==="__proto__"){if(p==="never")c.push(d);continue}if(p==="never"){c.push(d);continue}let m=u.run({value:t[d],issues:[]},o);if(m instanceof Promise)e.push(m.then((y)=>Kt(y,r,d,t,l,f)));else Kt(m,r,d,t,l,f)}if(c.length)r.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:s,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var hl=g("$ZodObject",(e,t)=>{Z.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),o=r?.get?r.get.raw:t.shape??{};if(o){let u=()=>{let p={...o};return Object.defineProperty(t,"shape",{value:p}),u.raw=p,p};u.raw=o,Object.defineProperty(t,"shape",{get:u})}let n=ut(()=>_i(t));E(e,"propValues",(u)=>{let p=u.def.shape,l={};for(let f in p){let h=p[f]._zod;if(h.values){if(!Object.prototype.hasOwnProperty.call(l,f))Q(l,f,new Set);for(let d of h.values)l[f].add(d);if(h.optin!==void 0)l[f].add(void 0)}}return l});let s=Ve,i=t.catchall,c,a=H.memoizer;a?.attach(e),e._zod.parse=(u,p)=>{c??(c=n.value);let l=u.value;if(!s(l))return u.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),u;u.value=a?a.alloc(e,u,{},p):{};let f=[],h=c.shape,d=p?.abortEarly,m=u.issues.length;for(let y of c.allKeys){if(d&&u.issues.length!==m){if(se(u,m))break;m=u.issues.length}if(y==="__proto__")continue;let x=h[y],w=x._zod.optin,S=x._zod.optout,I=x._zod.run({value:l[y],issues:[]},p);if(I instanceof Promise)f.push(I.then((b)=>Kt(b,u,y,l,w,S)));else Kt(I,u,y,l,w,S)}if(!i)return f.length?Promise.all(f).then(()=>u):u;return ki(f,l,u,p,n.value,e,d===!0)}}),$i=g("$ZodObjectJIT",(e,t)=>{hl.init(e,t);let r=e._zod.parse,o=ut(()=>_i(t)),n=H.memoizer,s=(h)=>{let d=o.value,m=d.symbolKeys,y=new Mr(["payload","ctx"],{shape:h,inst:e,memo:n,syms:m}),x=(b)=>`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`,w=(b,z)=>`
|
|
7
|
+
let ${b}_ab = false;
|
|
8
|
+
for (let i = 0; i < ${b}.issues.length; i++) {
|
|
9
|
+
const iss = ${b}.issues[i];
|
|
10
|
+
iss.path = iss.path ? [${z}, ...iss.path] : [${z}];
|
|
11
11
|
payload.issues.push(iss);
|
|
12
|
-
if (iss.continue !== true) ${
|
|
12
|
+
if (iss.continue !== true) ${b}_ab = true;
|
|
13
13
|
}
|
|
14
|
-
if (${
|
|
14
|
+
if (${b}_ab && ctx && ctx.abortEarly) {
|
|
15
15
|
payload.value = newResult;
|
|
16
16
|
return payload;
|
|
17
|
-
}`;
|
|
18
|
-
const ${
|
|
19
|
-
if (!${
|
|
20
|
-
if (${
|
|
17
|
+
}`;y.write("const input = payload.value;");let S=Object.create(null),I=0;for(let b of d.allKeys)S[b]=`key_${I++}`;y.write(n?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let b of d.allKeys){if(b==="__proto__")continue;let z=S[b],_=typeof b==="symbol"?`syms[${m.indexOf(b)}]`:hn(b),Ue=`${_} in input`,pe=h[b],Be=pe?._zod?.optin,nn=Be!==void 0,zp=pe?._zod?.optout==="optional";if(y.write(`const ${z} = ${x(_)};`),nn&&zp){let Pp=Be==="optional"?`${z}_present`:`${z}.value !== undefined || ${z}_present`;y.write(`
|
|
18
|
+
const ${z}_present = ${Ue};
|
|
19
|
+
if (!${z}.issues.length || ${z}_present) {
|
|
20
|
+
if (${z}.issues.length) {${w(z,_)}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
if (${
|
|
24
|
-
newResult[${
|
|
23
|
+
if (${Pp}) {
|
|
24
|
+
newResult[${_}] = ${z}.value;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
`)}else if(!
|
|
29
|
-
const ${
|
|
30
|
-
if (${
|
|
28
|
+
`)}else if(!nn)y.write(`
|
|
29
|
+
const ${z}_present = ${Ue};
|
|
30
|
+
if (${z}.issues.length) {${w(z,_)}
|
|
31
31
|
}
|
|
32
|
-
if (!${
|
|
32
|
+
if (!${z}_present && !${z}.issues.length) {
|
|
33
33
|
payload.issues.push({
|
|
34
34
|
code: "invalid_type",
|
|
35
35
|
expected: "nonoptional",
|
|
36
36
|
input: undefined,
|
|
37
|
-
path: [${
|
|
37
|
+
path: [${_}]
|
|
38
38
|
});
|
|
39
39
|
if (ctx && ctx.abortEarly) {
|
|
40
40
|
payload.value = newResult;
|
|
@@ -42,49 +42,67 @@ ${t.join(`
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
if (${
|
|
46
|
-
newResult[${
|
|
45
|
+
if (${z}_present) {
|
|
46
|
+
newResult[${_}] = ${z}.value;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
`);else if(
|
|
50
|
-
if (${
|
|
49
|
+
`);else if(y.write(`
|
|
50
|
+
if (${z}.issues.length) {${w(z,_)}
|
|
51
51
|
}
|
|
52
|
-
`),
|
|
53
|
-
if (${
|
|
54
|
-
newResult[${
|
|
52
|
+
`),Be==="defaulted")y.write(`newResult[${_}] = ${z}.value;`);else y.write(`
|
|
53
|
+
if (${z}.value !== undefined || ${Ue}) {
|
|
54
|
+
newResult[${_}] = ${z}.value;
|
|
55
55
|
}
|
|
56
|
-
`)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},i,c=Ie,a=!J.jitless,p=a&&on.value,l=t.catchall,f;e._zod.parse=(d,m)=>{f??(f=o.value);let y=d.value;if(!c(y))return d.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),d;if(a&&p&&m?.async===!1&&m.jitless!==!0){if(!i)i=s(t.shape);if(d=i(d,m),!l)return d;return ui([],y,d,m,f,e,m?.abortEarly===!0)}return r(d,m)}});function vs(e,t,r,o){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let n=e.filter((s)=>!ne(s));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((s)=>s.issues.map((i)=>xe(i,o,ee())))}),t}var Ir=h("$ZodUnion",(e,t)=>{P.init(e,t),S(e,"optin",(o)=>o.def.options.some((n)=>n._zod.optin==="defaulted")?"defaulted":o.def.options.some((n)=>n._zod.optin!==void 0)?"optional":void 0),S(e,"optout",(o)=>o.def.options.some((n)=>n._zod.optout==="optional")?"optional":void 0),S(e,"values",(o)=>{if(o.def.options.every((n)=>n._zod.values))return new Set(o.def.options.flatMap((n)=>Array.from(n._zod.values)));return}),S(e,"pattern",(o)=>{if(o.def.options.every((n)=>n._zod.pattern)){let n=o.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${n.map((s)=>_t(s.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 s=!1,i=[];for(let c of t.options){let a=c._zod.run({value:o.value,issues:[]},n);if(a instanceof Promise)i.push(a),s=!0;else{if(a.issues.length===0)return a;i.push(a)}}if(!s)return vs(i,o,e,n);return Promise.all(i).then((c)=>vs(c,o,e,n))}});function Gp(e){let t=new Map;for(let r of e.options){let o=r._zod.propValues?.[e.discriminator];if(!o||o.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let n of o)if(t.has(n)){if(n!==void 0)throw Error(`Duplicate discriminator value "${String(n)}"`);t.set(n,null)}else t.set(n,r)}return t}var li=h("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ir.init(e,t);let r=e._zod.parse;S(e,"propValues",(n)=>{let s={},i=0;for(let c of n.def.options){let a=c._zod.propValues;if(!a||Object.keys(a).length===0)throw Error(`Invalid discriminated union option at index "${n.def.options.indexOf(c)}"`);if(a[n.def.discriminator]?.has(void 0))i++;for(let[u,p]of Object.entries(a)){if(!Object.prototype.hasOwnProperty.call(s,u))Y(s,u,new Set);for(let l of p)s[u].add(l)}}if(!n.def.unionFallback&&i>1)s[n.def.discriminator]?.delete(void 0);return s}),t.options.forEach((n,s)=>{let i=Qe(n._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let o=Ye(()=>Gp(t));e._zod.parse=(n,s)=>{let i=n.value;if(!Ie(i))return n.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),n;let c=i?.[t.discriminator],a=o.value.get(c);if(a&&(c!==void 0||s.direction!=="backward"))return a._zod.run(n,s);if(t.unionFallback||s.direction==="backward")return r(n,s);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()).filter((u)=>o.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),n}}),fi=h("$ZodIntersection",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,s=t.left._zod.run({value:n,issues:[]},o),i=t.right._zod.run({value:n,issues:[]},o);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([a,u])=>ws(r,a,u));return ws(r,s,i)}});function Zr(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(Ae(e)&&Ae(t)){let r=Object.keys(t),o=Object.keys(e).filter((s)=>r.indexOf(s)!==-1),n={...e,...t};if(Object.prototype.hasOwnProperty.call(n,"__proto__"))delete n.__proto__;for(let s of o){if(s==="__proto__")continue;let i=Zr(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};n[s]=i.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],s=t[o],i=Zr(n,s);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function ws(e,t,r){let o=new Map,n,s=new Map,i=(u,p)=>{let l;if(u.code==="unrecognized_keys"&&!u.path?.length)n??(n=u),l=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);if(!s.has(f))s.set(f,u);l=[f]}else return!1;for(let f of l){if(!o.has(f))o.set(f,{});o.get(f)[p]=!0}return!0};for(let u of t.issues)if(!i(u,"l"))e.issues.push(u);for(let u of r.issues)if(!i(u,"r"))e.issues.push(u);let c=[...o].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(c.length){let u=n?c.filter((p)=>n.keys.includes(p)):[];if(u.length)e.issues.push({...n,keys:u});for(let p of c)if(!u.includes(p)&&s.has(p))e.issues.push(s.get(p))}let a=Zr(t.value,r.value);if(!a.valid){if(ne(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`)}return e.value=a.data,e}var di=h("$ZodEnum",(e,t)=>{P.init(e,t);let r=qe(t.entries),o=new Set(r);e._zod.values=o,S(e,"pattern",(n)=>{let s=qe(n.def.entries).filter((i)=>nn.has(typeof i));return new RegExp(s.length?`^(${s.map((i)=>ye(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,s)=>{let i=n.value;if(o.has(i))return n;return n.issues.push({code:"invalid_value",values:r,input:i,inst:e}),n}}),hi=h("$ZodLiteral",(e,t)=>{P.init(e,t);let r=new Set(t.values);e._zod.values=r,S(e,"pattern",(o)=>{let n=o.def.values;return new RegExp(n.length?`^(${n.map((s)=>typeof s==="string"?ye(s):s?ye(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,n)=>{let s=o.value;if(r.has(s))return o;return o.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),o}});var mi=h("$ZodTransform",(e,t)=>{P.init(e,t),e._zod.optin="optional",J.memoizer?.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new et(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then((i)=>(r.value=i,r));if(n instanceof Promise)throw new se;return r.value=n,r}});function _s(e,t){return e.value=t.issues.length?void 0:t.value,e}var Ar=h("$ZodOptional",(e,t)=>{P.init(e,t),S(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",S(e,"values",(r)=>{let o=r.def.innerType._zod.values;return o?new Set([...o,void 0]):void 0}),S(e,"pattern",(r)=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${_t(o.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let n=t.innerType._zod.run({value:r.value,issues:[]},o);if(n instanceof Promise)return n.then((s)=>_s(r,s));return _s(r,n)}return t.innerType._zod.run(r,o)}}),gi=h("$ZodExactOptional",(e,t)=>{Ar.init(e,t),S(e,"values",(r)=>r.def.innerType._zod.values),S(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),yi=h("$ZodNullable",(e,t)=>{P.init(e,t),S(e,"optin",(r)=>r.def.innerType._zod.optin),S(e,"optout",(r)=>r.def.innerType._zod.optout),S(e,"pattern",(r)=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${_t(o.source)}|null)$`):void 0}),S(e,"values",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>{if(r.value===null)return r;return t.innerType._zod.run(r,o)}}),xi=h("$ZodDefault",(e,t)=>{P.init(e,t),e._zod.optin="defaulted",S(e,"values",(r)=>r.def.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((s)=>bs(s,t));return bs(n,t)}});function bs(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var vi=h("$ZodPrefault",(e,t)=>{P.init(e,t),e._zod.optin="defaulted",S(e,"values",(r)=>r.def.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)}}),wi=h("$ZodNonOptional",(e,t)=>{P.init(e,t),S(e,"values",(r)=>{let o=r.def.innerType._zod.values;return o?new Set([...o].filter((n)=>n!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((s)=>ks(s,e));return ks(n,e)}});function ks(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 $s(e,t,r,o){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map((n)=>xe(n,o,ee()))},input:e.value}),e}var _i=h("$ZodCatch",(e,t)=>{P.init(e,t),S(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),S(e,"optout",(r)=>r.def.innerType._zod.optout),S(e,"values",(r)=>r.def.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({value:r.value,issues:[]},o);if(n instanceof Promise)return n.then((s)=>$s(r,s,t,o));return $s(r,n,t,o)}});var bi=h("$ZodPipe",(e,t)=>{P.init(e,t),S(e,"values",(r)=>r.def.in._zod.values),S(e,"optin",(r)=>r.def.in._zod.optin),S(e,"optout",(r)=>r.def.out._zod.optout),S(e,"propValues",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let s=t.out._zod.run(r,o);if(s instanceof Promise)return s.then((i)=>Nt(i,t.in,o));return Nt(s,t.in,o)}let n=t.in._zod.run(r,o);if(n instanceof Promise)return n.then((s)=>Nt(s,t.out,o));return Nt(n,t.out,o)}});function Nt(e,t,r){if(e.issues.some((o)=>o.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var ki=h("$ZodReadonly",(e,t)=>{P.init(e,t),S(e,"propValues",(r)=>r.def.innerType._zod.propValues),S(e,"values",(r)=>r.def.innerType._zod.values),S(e,"optin",(r)=>r.def.innerType?._zod?.optin),S(e,"optout",(r)=>r.def.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(Ss);return Ss(n)}});function Ss(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var $i=h("$ZodCustom",(e,t)=>{A.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((s)=>zs(s,r,o,e));zs(n,r,o,e);return}});function zs(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($e(n))}}class zi extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Nr="~memo",Si=[];function Pi(e){return e!==null&&typeof e==="object"}function Tr(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Ei=new WeakMap,ot=0,Ut=1,nt=2;function Bt(e,t,r){let o=Ei.get(e);if(o!==void 0)return o?nt:ot;if(t.has(e))return nt;t.add(e);let n=ot,s=(p)=>{if(n!==nt&&p?._zod){let l=Bt(p,t,r);if(l>n)n=l}},i=(p,l)=>{let f=ot;for(let d of Reflect.ownKeys(p)){let m=Object.getOwnPropertyDescriptor(p,d);if(l&&!m.enumerable)continue;let y=m.get?Ut:m.value?._zod?Bt(m.value,t,r):ot;if(y>f)f=y}return f},c=(p)=>{if(p>n)n=p},a=e._zod.def,u=a.type;switch(u){case"object":{let p=Qe(a);c(p?i(p,!0):Ut),s(a.catchall);break}case"array":s(a.element);break;case"tuple":for(let p of a.items)s(p);s(a.rest);break;case"record":case"map":s(a.keyType),s(a.valueType);break;case"set":s(a.valueType);break;case"union":for(let p of a.options)s(p);break;case"intersection":s(a.left),s(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(a.innerType);break;case"pipe":s(a.in),s(a.out);break;case"function":s(a.input),s(a.output);break;case"lazy":{let p=a._cachedInner??(r?e._zod.innerType:void 0);c(p?Bt(p,t,!1):Ut);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let p in a){let l=Object.getOwnPropertyDescriptor(a,p);if(!l||l.get)continue;let f=l.value;if(!f||typeof f!=="object")continue;if(f._zod)s(f);else if(Array.isArray(f))for(let d of f)s(d)}}return t.delete(e),qp(e,n)}function qp(e,t){if(t!==Ut)Ei.set(e,t===nt);return t}function Xp(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Mt,Wt=[],Yp={alloc(e,t,r){let o=Mt;if(!o)return r;Mt=void 0;let n={value:r,issues:null};return o.set(t.value,n),Wt.push(n),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,o=(n,s)=>{if(s.direction!=="backward"&&Qp(s,n.value))throw new zi;return r(n,s)};if(e._zod.parse=o,e._zod.run===r)e._zod.run=o})},attach(e){var t;let r,o=!1,n,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,c=(a,u)=>{if(r===void 0){let v=Bt(e,new Set,!1);if(v===ot){if(e._zod.parse=i,e._zod.run===c)e._zod.run=i;return i(a,u)}if(v===nt||o)r=!0;else o=!0}let p=a.value;if(!Pi(p))return i(a,u);let l=u[Nr];if(!l)l={buckets:new WeakMap,backEdges:void 0},u[Nr]=l;let f;if(n===u)f=s;else f=Xp(l,e),n=u,s=f;let d=f.get(p);if(d){if(a.value=d.value,d.issues){if(d.issues.length)a.issues.push(...Tr(d.issues))}else a.memo=!0,l.backEdges??(l.backEdges=new WeakSet),l.backEdges.add(d.value);return a}Mt=f;let m=Wt.length,y=i(a,u);Mt=void 0;let g=Wt.length>m?Wt.pop():void 0;if(y instanceof Promise)return y.then((v)=>{if(g)g.issues=v.issues.length?Tr(v.issues):Si;return v});if(g)g.issues=y.issues.length?Tr(y.issues):Si;return y};if(e._zod.parse=c,e._zod.run===i)e._zod.run=c})}};function Zi(){return Yp}function Qp(e,t){let r=e[Nr]?.backEdges;return r!==void 0&&Pi(t)&&r.has(t)}var el=()=>{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(s){return e[s]??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",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};function n(s,i){if(s==="number"&&typeof i==="number"&&!Number.isFinite(i))return String(i);return o[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let i=n(s.expected),c=pn(s.input),a=n(c,s.input);return`Invalid input: expected ${i}, received ${a}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${hr(s.values[0])}`;return`Invalid option: expected one of ${lr(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",c=t(s.origin);if(c)return`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${c.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",c=t(s.origin);if(c)return`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${c.unit}`;return`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;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]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${lr(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((c)=>`'${c}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function jr(){return{localeError:el()}}var Oi;class Ri{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 tl(){return new Ri}(Oi=globalThis).__zod_globalRegistry??(Oi.__zod_globalRegistry=tl());var Se=globalThis.__zod_globalRegistry;function Jt(e){if(e.checks)e.checks=[...e.checks];return e}function Ci(e,t){return new e(Jt({type:"string",...x(t)}))}function Ii(e,t){return new e(Jt({type:"string",coerce:!0,...x(t)}))}function Ai(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...x(t)})}function Ti(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...x(t)})}function Dr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...x(t)})}function Ni(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...x(t)})}function ji(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...x(t)})}function Di(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...x(t)})}function Fr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...x(t)})}function Fi(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...x(t)})}function Li(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...x(t)})}function Mi(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...x(t)})}function Wi(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...x(t)})}function Ui(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...x(t)})}function Bi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...x(t)})}function Ji(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...x(t)})}function Vi(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...x(t)})}function Hi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...x(t)})}function Ki(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...x(t)})}function Gi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...x(t)})}function qi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...x(t)})}function Xi(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...x(t)})}function Yi(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...x(t)})}function Qi(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...x(t)})}function ec(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...x(t)})}function tc(e,t){return new e({type:"string",format:"date",check:"string_format",...x(t)})}function rc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...x(t)})}function oc(e,t){return new e({type:"string",format:"duration",check:"string_format",...x(t)})}function nc(e,t){return new e(Jt({type:"number",checks:[],...x(t)}))}function sc(e,t){return new e(Jt({type:"number",coerce:!0,checks:[],...x(t)}))}function ic(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...x(t)})}function cc(e,t){return new e({type:"boolean",...x(t)})}function ac(e,t){return new e({type:"boolean",coerce:!0,...x(t)})}function uc(e,t){return new e({type:"bigint",coerce:!0,...x(t)})}function pc(e){return new e({type:"unknown"})}function lc(e,t){return new e({type:"never",...x(t)})}function fc(e,t){return new e({type:"date",coerce:!0,...x(t)})}function Te(e,t){return new zr({check:"less_than",...x(t),value:e,inclusive:!1})}function le(e,t){return new zr({check:"less_than",...x(t),value:e,inclusive:!0})}function Ne(e,t){return new Pr({check:"greater_than",...x(t),value:e,inclusive:!1})}function fe(e,t){return new Pr({check:"greater_than",...x(t),value:e,inclusive:!0})}function st(e,t){return new os({check:"multiple_of",...x(t),value:e})}function Vt(e,t){return new ss({check:"max_length",...x(t),maximum:e})}function je(e,t){return new is({check:"min_length",...x(t),minimum:e})}function Ht(e,t){return new cs({check:"length_equals",...x(t),length:e})}function Lr(e,t){return new as({check:"string_format",format:"regex",...x(t),pattern:e})}function Mr(e){return new us({check:"string_format",format:"lowercase",...x(e)})}function Wr(e){return new ps({check:"string_format",format:"uppercase",...x(e)})}function Ur(e,t){return new ls({check:"string_format",format:"includes",...x(t),includes:e})}function Br(e,t){return new fs({check:"string_format",format:"starts_with",...x(t),prefix:e})}function Jr(e,t){return new ds({check:"string_format",format:"ends_with",...x(t),suffix:e})}function ve(e){return new hs({check:"overwrite",tx:e})}function Vr(e){return ve((t)=>t.normalize(e))}function Hr(){return ve((e)=>e.trim())}function Kr(){return ve((e)=>e.toLowerCase())}function Gr(){return ve((e)=>e.toUpperCase())}function qr(){return ve((e)=>rn(e))}function dc(e,t,r){return new e({type:"array",element:t,...x(r)})}function hc(e,t,r){return new e({type:"custom",check:"custom",fn:t,...x(r)})}function mc(e,t){let r=rl((o)=>(o.addIssue=(n)=>{if(typeof n==="string")o.issues.push($e(n,o.value,r._zod.def));else{let s=n;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=o.value;s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),o.issues.push($e(s))}},e(o.value,o)),t);return r}function rl(e,t){let r=new A({check:"custom",...x(t)});return r._zod.check=e,r}function it(e,...t){for(let r of t)for(let o of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,o))Y(e,o,r[o]);return e}function Yr(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??Se,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function te(e,t,r,o,n){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:o.path,message:n}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(n);return Object.assign(r,s),!0}function I(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,r.schemaPath.includes(e))s.cycle=r.path;return s.schema}let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{let p={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,p);else{let f=i.schema,d=t.processors[n.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);d(e,t,f,p)}let l=e._zod.parent;if(l){if(!i.ref)i.ref=l;I(l,t,p),t.seen.get(l).isParent=!0}}let a=t.metadataRegistry.get(e);if(a)it(i.schema,a);if(t.io==="input"&&F(e))delete i.schema.examples,delete i.schema.default;if(t.io==="input"&&"_prefault"in i.schema)(o=i.schema).default??(o.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function gc(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Qr(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let o=new Map;for(let i of e.seen.entries()){let c=e.metadataRegistry.get(i[0])?.id;if(c){let a=o.get(c);if(a&&a!==i[0])throw Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(c,i[0])}}let n=(i)=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let l=e.external.registry.get(i[0])?.id,f=e.external.uri??((m)=>m);if(l)return{ref:f(l)};let d=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=d,{defId:d,ref:`${f("__shared")}#/${c}/${gc(d)}`}}let a="#",u=`${a}/${c}/`;if(i[1]===r&&!i[1].schema.id)return{ref:a};let p=i[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:u+gc(p)}},s=(i)=>{if(i[1].schema.$ref)return;let c=i[1],{ref:a,defId:u}=n(i);if(c.def={...c.schema},u)c.defId=u;let p=c.schema;for(let l in p)delete p[l];p.$ref=a};if(e.cycles==="throw")for(let i of e.seen.entries()){let c=i[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
56
|
+
`)}return y.write("payload.value = newResult;"),y.write("return payload;"),y.compile()},i,c=Ve,a=!H.jitless,p=a&&gn.value,l=t.catchall,f;e._zod.parse=(h,d)=>{f??(f=o.value);let m=h.value;if(!c(m))return h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h;if(a&&p&&d?.async===!1&&d.jitless!==!0){if(!i)i=s(t.shape);if(h=i(h,d),!l)return h;return ki([],m,h,d,f,e,d?.abortEarly===!0)}return r(h,d)}});function Cs(e,t,r,o){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let n=e.filter((s)=>!se(s));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((s)=>s.issues.map((i)=>ie(i,o,X())))}),t}var Jr=g("$ZodUnion",(e,t)=>{Z.init(e,t),E(e,"optin",(o)=>o.def.options.some((n)=>n._zod.optin==="defaulted")?"defaulted":o.def.options.some((n)=>n._zod.optin!==void 0)?"optional":void 0),E(e,"optout",(o)=>o.def.options.some((n)=>n._zod.optout==="optional")?"optional":void 0),E(e,"values",(o)=>{if(o.def.options.every((n)=>n._zod.values))return new Set(o.def.options.flatMap((n)=>Array.from(n._zod.values)));return}),E(e,"pattern",(o)=>{if(o.def.options.every((n)=>n._zod.pattern)){let n=o.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${n.map((s)=>Ct(s.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 s=!1,i=[];for(let c of t.options){let a=c._zod.run({value:o.value,issues:[]},n);if(a instanceof Promise)i.push(a),s=!0;else{if(a.issues.length===0)return a;i.push(a)}}if(!s)return Cs(i,o,e,n);return Promise.all(i).then((c)=>Cs(c,o,e,n))}});function ml(e){let t=new Map;for(let r of e.options){let o=r._zod.propValues?.[e.discriminator];if(!o||o.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let n of o)if(t.has(n)){if(n!==void 0)throw Error(`Duplicate discriminator value "${String(n)}"`);t.set(n,null)}else t.set(n,r)}return t}var Si=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Jr.init(e,t);let r=e._zod.parse;E(e,"propValues",(n)=>{let s={},i=0;for(let c of n.def.options){let a=c._zod.propValues;if(!a||Object.keys(a).length===0)throw Error(`Invalid discriminated union option at index "${n.def.options.indexOf(c)}"`);if(a[n.def.discriminator]?.has(void 0))i++;for(let[u,p]of Object.entries(a)){if(!Object.prototype.hasOwnProperty.call(s,u))Q(s,u,new Set);for(let l of p)s[u].add(l)}}if(!n.def.unionFallback&&i>1)s[n.def.discriminator]?.delete(void 0);return s}),t.options.forEach((n,s)=>{let i=pt(n._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let o=ut(()=>ml(t));e._zod.parse=(n,s)=>{let i=n.value;if(!Ve(i))return n.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),n;let c=i?.[t.discriminator],a=o.value.get(c);if(a&&(c!==void 0||s.direction!=="backward"))return a._zod.run(n,s);if(t.unionFallback||s.direction==="backward")return r(n,s);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()).filter((u)=>o.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),n}}),zi=g("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,s=t.left._zod.run({value:n,issues:[]},o),i=t.right._zod.run({value:n,issues:[]},o);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([a,u])=>As(r,a,u));return As(r,s,i)}});function Wr(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(Ze(e)&&Ze(t)){let r=Object.keys(t),o=Object.keys(e).filter((s)=>r.indexOf(s)!==-1),n={...e,...t};if(Object.prototype.hasOwnProperty.call(n,"__proto__"))delete n.__proto__;for(let s of o){if(s==="__proto__")continue;let i=Wr(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};n[s]=i.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],s=t[o],i=Wr(n,s);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function As(e,t,r){let o=new Map,n,s=new Map,i=(u,p)=>{let l;if(u.code==="unrecognized_keys"&&!u.path?.length)n??(n=u),l=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);if(!s.has(f))s.set(f,u);l=[f]}else return!1;for(let f of l){if(!o.has(f))o.set(f,{});o.get(f)[p]=!0}return!0};for(let u of t.issues)if(!i(u,"l"))e.issues.push(u);for(let u of r.issues)if(!i(u,"r"))e.issues.push(u);let c=[...o].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(c.length){let u=n?c.filter((p)=>n.keys.includes(p)):[];if(u.length)e.issues.push({...n,keys:u});for(let p of c)if(!u.includes(p)&&s.has(p))e.issues.push(s.get(p))}let a=Wr(t.value,r.value);if(!a.valid){if(se(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`)}return e.value=a.data,e}var Pi=g("$ZodRecord",(e,t)=>{Z.init(e,t);let r=H.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let s=o.value;if(!Ze(s))return o.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),o;let i=[],c=t.keyType._zod.values;if(c&&!t.partial){o.value=r?r.alloc(e,o,{},n):{};let a=new Set;for(let p of c)if(typeof p==="string"||typeof p==="number"||typeof p==="symbol"){if(a.add(typeof p==="number"?p.toString():p),p==="__proto__")continue;let l=t.keyType._zod.run({value:p,issues:[]},n);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(l.issues.length){o.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((d)=>ie(d,n,X())),input:p,path:[p],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:s[p],issues:[]},n);if(h instanceof Promise)i.push(h.then((d)=>{if(d.issues.length)o.issues.push(...ke(p,d.issues));o.value[f]=d.value}));else{if(h.issues.length)o.issues.push(...ke(p,h.issues));o.value[f]=h.value}}let u;for(let p in s)if(!a.has(p))if(t.mode==="loose"){if(p==="__proto__")continue;o.value[p]=s[p]}else u=u??[],u.push(p);if(u&&u.length>0)o.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{o.value=r?r.alloc(e,o,{},n):{};let a;for(let u of Reflect.ownKeys(s)){if(u==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,u))continue;let p=t.keyType._zod.run({value:u,issues:[]},n);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof u==="string"&&ft.test(u)&&p.issues.length){let d=t.keyType._zod.run({value:Number(u),issues:[]},n);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length===0)p=d}if(p.issues.length){if(t.mode==="loose")o.value[u]=s[u];else if(c)a=a??[],a.push(u);else o.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((d)=>ie(d,n,X())),input:u,path:[u],inst:e});continue}let f=p.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:s[u],issues:[]},n);if(h instanceof Promise)i.push(h.then((d)=>{if(d.issues.length)o.issues.push(...ke(u,d.issues));o.value[f]=d.value}));else{if(h.issues.length)o.issues.push(...ke(u,h.issues));o.value[f]=h.value}}if(a&&a.length>0)o.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:a,continue:!0})}if(i.length)return Promise.all(i).then(()=>o);return o}});var Ei=g("$ZodEnum",(e,t)=>{Z.init(e,t);let r=ct(t.entries),o=new Set(r);e._zod.values=o,E(e,"pattern",(n)=>{let s=ct(n.def.entries).filter((i)=>yn.has(typeof i));return new RegExp(s.length?`^(${s.map((i)=>_e(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,s)=>{let i=n.value;if(o.has(i))return n;return n.issues.push({code:"invalid_value",values:r,input:i,inst:e}),n}}),Oi=g("$ZodLiteral",(e,t)=>{Z.init(e,t);let r=new Set(t.values);e._zod.values=r,E(e,"pattern",(o)=>{let n=o.def.values;return new RegExp(n.length?`^(${n.map((s)=>typeof s==="string"?_e(s):s?_e(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,n)=>{let s=o.value;if(r.has(s))return o;return o.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),o}});var Zi=g("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.optin="optional",H.memoizer?.guard(e),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((i)=>(r.value=i,r));if(n instanceof Promise)throw new ce;return r.value=n,r}});function Is(e,t){return e.value=t.issues.length?void 0:t.value,e}var Hr=g("$ZodOptional",(e,t)=>{Z.init(e,t),E(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",E(e,"values",(r)=>{let o=r.def.innerType._zod.values;return o?new Set([...o,void 0]):void 0}),E(e,"pattern",(r)=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${Ct(o.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let n=t.innerType._zod.run({value:r.value,issues:[]},o);if(n instanceof Promise)return n.then((s)=>Is(r,s));return Is(r,n)}return t.innerType._zod.run(r,o)}}),Ri=g("$ZodExactOptional",(e,t)=>{Hr.init(e,t),E(e,"values",(r)=>r.def.innerType._zod.values),E(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),Ci=g("$ZodNullable",(e,t)=>{Z.init(e,t),E(e,"optin",(r)=>r.def.innerType._zod.optin),E(e,"optout",(r)=>r.def.innerType._zod.optout),E(e,"pattern",(r)=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${Ct(o.source)}|null)$`):void 0}),E(e,"values",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>{if(r.value===null)return r;return t.innerType._zod.run(r,o)}}),Ai=g("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="defaulted",E(e,"values",(r)=>r.def.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((s)=>js(s,t));return js(n,t)}});function js(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Ii=g("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="defaulted",E(e,"values",(r)=>r.def.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)}}),ji=g("$ZodNonOptional",(e,t)=>{Z.init(e,t),E(e,"values",(r)=>{let o=r.def.innerType._zod.values;return o?new Set([...o].filter((n)=>n!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((s)=>Ns(s,e));return Ns(n,e)}});function Ns(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 Ts(e,t,r,o){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map((n)=>ie(n,o,X()))},input:e.value}),e}var Ni=g("$ZodCatch",(e,t)=>{Z.init(e,t),E(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),E(e,"optout",(r)=>r.def.innerType._zod.optout),E(e,"values",(r)=>r.def.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({value:r.value,issues:[]},o);if(n instanceof Promise)return n.then((s)=>Ts(r,s,t,o));return Ts(r,n,t,o)}});var Ti=g("$ZodPipe",(e,t)=>{Z.init(e,t),E(e,"values",(r)=>r.def.in._zod.values),E(e,"optin",(r)=>r.def.in._zod.optin),E(e,"optout",(r)=>r.def.out._zod.optout),E(e,"propValues",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let s=t.out._zod.run(r,o);if(s instanceof Promise)return s.then((i)=>Jt(i,t.in,o));return Jt(s,t.in,o)}let n=t.in._zod.run(r,o);if(n instanceof Promise)return n.then((s)=>Jt(s,t.out,o));return Jt(n,t.out,o)}});function Jt(e,t,r){if(e.issues.some((o)=>o.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var Di=g("$ZodReadonly",(e,t)=>{Z.init(e,t),E(e,"propValues",(r)=>r.def.innerType._zod.propValues),E(e,"values",(r)=>r.def.innerType._zod.values),E(e,"optin",(r)=>r.def.innerType?._zod?.optin),E(e,"optout",(r)=>r.def.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(Ds);return Ds(n)}});function Ds(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Fi=g("$ZodLazy",(e,t)=>{Z.init(e,t),ln(e._zod,"innerType",()=>{let r=t;if(!r._cachedInner)r._cachedInner=t.getter();return r._cachedInner}),E(e,"pattern",(r)=>r.innerType?._zod?.pattern),E(e,"propValues",(r)=>r.innerType?._zod?.propValues),E(e,"optin",(r)=>r.innerType?._zod?.optin??void 0),E(e,"optout",(r)=>r.innerType?._zod?.optout??void 0),e._zod.parse=(r,o)=>e._zod.innerType._zod.run(r,o)}),Li=g("$ZodCustom",(e,t)=>{F.init(e,t),Z.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((s)=>Fs(s,r,o,e));Fs(n,r,o,e);return}});function Fs(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(Re(n))}}class Wi extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Gr="~memo",Mi=[];function Ui(e){return e!==null&&typeof e==="object"}function Kr(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Bi=new WeakMap,mt=0,Qt=1,gt=2;function er(e,t,r){let o=Bi.get(e);if(o!==void 0)return o?gt:mt;if(t.has(e))return gt;t.add(e);let n=mt,s=(p)=>{if(n!==gt&&p?._zod){let l=er(p,t,r);if(l>n)n=l}},i=(p,l)=>{let f=mt;for(let h of Reflect.ownKeys(p)){let d=Object.getOwnPropertyDescriptor(p,h);if(l&&!d.enumerable)continue;let m=d.get?Qt:d.value?._zod?er(d.value,t,r):mt;if(m>f)f=m}return f},c=(p)=>{if(p>n)n=p},a=e._zod.def,u=a.type;switch(u){case"object":{let p=pt(a);c(p?i(p,!0):Qt),s(a.catchall);break}case"array":s(a.element);break;case"tuple":for(let p of a.items)s(p);s(a.rest);break;case"record":case"map":s(a.keyType),s(a.valueType);break;case"set":s(a.valueType);break;case"union":for(let p of a.options)s(p);break;case"intersection":s(a.left),s(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(a.innerType);break;case"pipe":s(a.in),s(a.out);break;case"function":s(a.input),s(a.output);break;case"lazy":{let p=a._cachedInner??(r?e._zod.innerType:void 0);c(p?er(p,t,!1):Qt);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let p in a){let l=Object.getOwnPropertyDescriptor(a,p);if(!l||l.get)continue;let f=l.value;if(!f||typeof f!=="object")continue;if(f._zod)s(f);else if(Array.isArray(f))for(let h of f)s(h)}}return t.delete(e),gl(e,n)}function gl(e,t){if(t!==Qt)Bi.set(e,t===gt);return t}function yl(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Xt,Yt=[],xl={alloc(e,t,r){let o=Xt;if(!o)return r;Xt=void 0;let n={value:r,issues:null};return o.set(t.value,n),Yt.push(n),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,o=(n,s)=>{if(s.direction!=="backward"&&vl(s,n.value))throw new Wi;return r(n,s)};if(e._zod.parse=o,e._zod.run===r)e._zod.run=o})},attach(e){var t;let r,o=!1,n,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,c=(a,u)=>{if(r===void 0){let x=er(e,new Set,!1);if(x===mt){if(e._zod.parse=i,e._zod.run===c)e._zod.run=i;return i(a,u)}if(x===gt||o)r=!0;else o=!0}let p=a.value;if(!Ui(p))return i(a,u);let l=u[Gr];if(!l)l={buckets:new WeakMap,backEdges:void 0},u[Gr]=l;let f;if(n===u)f=s;else f=yl(l,e),n=u,s=f;let h=f.get(p);if(h){if(a.value=h.value,h.issues){if(h.issues.length)a.issues.push(...Kr(h.issues))}else a.memo=!0,l.backEdges??(l.backEdges=new WeakSet),l.backEdges.add(h.value);return a}Xt=f;let d=Yt.length,m=i(a,u);Xt=void 0;let y=Yt.length>d?Yt.pop():void 0;if(m instanceof Promise)return m.then((x)=>{if(y)y.issues=x.issues.length?Kr(x.issues):Mi;return x});if(y)y.issues=m.issues.length?Kr(m.issues):Mi;return m};if(e._zod.parse=c,e._zod.run===i)e._zod.run=c})}};function Vi(){return xl}function vl(e,t){let r=e[Gr]?.backEdges;return r!==void 0&&Ui(t)&&r.has(t)}var wl=()=>{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(s){return e[s]??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",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};function n(s,i){if(s==="number"&&typeof i==="number"&&!Number.isFinite(i))return String(i);return o[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let i=n(s.expected),c=_n(s.input),a=n(c,s.input);return`Invalid input: expected ${i}, received ${a}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${Pr(s.values[0])}`;return`Invalid option: expected one of ${$r(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",c=t(s.origin);if(c)return`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${c.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",c=t(s.origin);if(c)return`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${c.unit}`;return`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;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]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${$r(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((c)=>`'${c}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function qr(){return{localeError:wl()}}var Ji;class Hi{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 bl(){return new Hi}(Ji=globalThis).__zod_globalRegistry??(Ji.__zod_globalRegistry=bl());var Ce=globalThis.__zod_globalRegistry;function tr(e){if(e.checks)e.checks=[...e.checks];return e}function Ki(e,t){return new e(tr({type:"string",...v(t)}))}function Gi(e,t){return new e(tr({type:"string",coerce:!0,...v(t)}))}function qi(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...v(t)})}function Xi(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...v(t)})}function Xr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...v(t)})}function Yi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...v(t)})}function Qi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...v(t)})}function ec(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...v(t)})}function Yr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...v(t)})}function tc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...v(t)})}function rc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...v(t)})}function oc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...v(t)})}function nc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...v(t)})}function sc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...v(t)})}function ic(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...v(t)})}function cc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...v(t)})}function ac(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...v(t)})}function uc(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...v(t)})}function pc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...v(t)})}function lc(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...v(t)})}function fc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...v(t)})}function dc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...v(t)})}function hc(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...v(t)})}function mc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...v(t)})}function gc(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...v(t)})}function yc(e,t){return new e({type:"string",format:"date",check:"string_format",...v(t)})}function xc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...v(t)})}function vc(e,t){return new e({type:"string",format:"duration",check:"string_format",...v(t)})}function wc(e,t){return new e(tr({type:"number",checks:[],...v(t)}))}function bc(e,t){return new e(tr({type:"number",coerce:!0,checks:[],...v(t)}))}function _c(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...v(t)})}function kc(e,t){return new e({type:"boolean",...v(t)})}function $c(e,t){return new e({type:"boolean",coerce:!0,...v(t)})}function Sc(e,t){return new e({type:"bigint",coerce:!0,...v(t)})}function zc(e,t){return new e({type:"null",...v(t)})}function Pc(e){return new e({type:"unknown"})}function Ec(e,t){return new e({type:"never",...v(t)})}function Oc(e,t){return new e({type:"date",coerce:!0,...v(t)})}function Je(e,t){return new Fr({check:"less_than",...v(t),value:e,inclusive:!1})}function de(e,t){return new Fr({check:"less_than",...v(t),value:e,inclusive:!0})}function He(e,t){return new Lr({check:"greater_than",...v(t),value:e,inclusive:!1})}function he(e,t){return new Lr({check:"greater_than",...v(t),value:e,inclusive:!0})}function yt(e,t){return new gs({check:"multiple_of",...v(t),value:e})}function rr(e,t){return new xs({check:"max_length",...v(t),maximum:e})}function Ke(e,t){return new vs({check:"min_length",...v(t),minimum:e})}function or(e,t){return new ws({check:"length_equals",...v(t),length:e})}function Qr(e,t){return new bs({check:"string_format",format:"regex",...v(t),pattern:e})}function eo(e){return new _s({check:"string_format",format:"lowercase",...v(e)})}function to(e){return new ks({check:"string_format",format:"uppercase",...v(e)})}function ro(e,t){return new $s({check:"string_format",format:"includes",...v(t),includes:e})}function oo(e,t){return new Ss({check:"string_format",format:"starts_with",...v(t),prefix:e})}function no(e,t){return new zs({check:"string_format",format:"ends_with",...v(t),suffix:e})}function $e(e){return new Ps({check:"overwrite",tx:e})}function so(e){return $e((t)=>t.normalize(e))}function io(){return $e((e)=>e.trim())}function co(){return $e((e)=>e.toLowerCase())}function ao(){return $e((e)=>e.toUpperCase())}function uo(){return $e((e)=>mn(e))}function Zc(e,t,r){return new e({type:"array",element:t,...v(r)})}function Rc(e,t,r){return new e({type:"custom",check:"custom",fn:t,...v(r)})}function Cc(e,t){let r=_l((o)=>(o.addIssue=(n)=>{if(typeof n==="string")o.issues.push(Re(n,o.value,r._zod.def));else{let s=n;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=o.value;s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),o.issues.push(Re(s))}},e(o.value,o)),t);return r}function _l(e,t){let r=new F({check:"custom",...v(t)});return r._zod.check=e,r}function xt(e,...t){for(let r of t)for(let o of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,o))Q(e,o,r[o]);return e}function lo(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??Ce,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function re(e,t,r,o,n){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:o.path,message:n}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(n);return Object.assign(r,s),!0}function N(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,r.schemaPath.includes(e))s.cycle=r.path;return s.schema}let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{let p={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,p);else{let f=i.schema,h=t.processors[n.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);h(e,t,f,p)}let l=e._zod.parent;if(l){if(!i.ref)i.ref=l;N(l,t,p),t.seen.get(l).isParent=!0}}let a=t.metadataRegistry.get(e);if(a)xt(i.schema,a);if(t.io==="input"&&U(e))delete i.schema.examples,delete i.schema.default;if(t.io==="input"&&"_prefault"in i.schema)(o=i.schema).default??(o.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function Ac(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function fo(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let o=new Map;for(let i of e.seen.entries()){let c=e.metadataRegistry.get(i[0])?.id;if(c){let a=o.get(c);if(a&&a!==i[0])throw Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(c,i[0])}}let n=(i)=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let l=e.external.registry.get(i[0])?.id,f=e.external.uri??((d)=>d);if(l)return{ref:f(l)};let h=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=h,{defId:h,ref:`${f("__shared")}#/${c}/${Ac(h)}`}}let a="#",u=`${a}/${c}/`;if(i[1]===r&&!i[1].schema.id)return{ref:a};let p=i[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:u+Ac(p)}},s=(i)=>{if(i[1].schema.$ref)return;let c=i[1],{ref:a,defId:u}=n(i);if(c.def={...c.schema},u)c.defId=u;let p=c.schema;for(let l in p)delete p[l];p.$ref=a};if(e.cycles==="throw")for(let i of e.seen.entries()){let c=i[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
57
57
|
|
|
58
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let c=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(c.cycle){s(i);continue}if(c.count>1){if(e.reused==="ref")s(i)}}if(e.external)e.sharedDefsExtractedFor=e.external}function vc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let o of t){if(!o||typeof o!=="object")return;vc(o);let n=Object.keys(o);if(n.length!==1||n[0]!=="type")return;let s=o.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!=="string")return;if(!r.includes(i))r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var wc=new Set(["type","properties","required","additionalProperties"]),yc=["oneOf","anyOf"];function xc(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Xr(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let i in s)if(!wc.has(i))return null;t.push(s)}let r={},o=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let c=[];for(let u of t){let p=u.properties?.[i]??xc(u);if(p===null||p===void 0)continue;if(!c.some((l)=>JSON.stringify(l)===JSON.stringify(p)))c.push(p)}let a=c.length===1?c[0]:Xr(c)??{allOf:c};Y(r,i,a)}for(let i of s.required??[])o.add(i)}let n={type:"object",properties:r};if(o.size)n.required=[...o];if(t.every((s)=>s.additionalProperties===!1))n.additionalProperties=!1;else{let s=[];for(let i of t){let c=xc(i);if(c&&!s.some((a)=>JSON.stringify(a)===JSON.stringify(c)))s.push(c)}if(s.length===1)n.additionalProperties=s[0];else if(s.length>1)n.additionalProperties={allOf:s}}return n}function ol(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of wc)if(n in e)return;let r=t.filter((n)=>yc.some((s)=>Array.isArray(n[s]))),o=null;if(!r.length)o=Xr(t);else{let n=r[0],s=yc.find((a)=>Array.isArray(n[a]));if(Object.keys(n).length!==1)return;let i=t.filter((a)=>a!==n),c=n[s].map((a)=>Xr([...i,a]));if(c.some((a)=>!a))return;o={[s]:c}}if(!o)return;delete e.allOf,it(e,o)}function eo(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(c)=>{let a=e.seen.get(c);if(a.ref===null)return;let u=a.def??a.schema,p={...u},l=a.ref;if(a.ref=null,l){o(l);let d=e.seen.get(l),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 it(u,m);if(it(u,p),c._zod.parent===l)for(let g in u){if(g==="$ref"||g==="allOf")continue;if(!(g in p))delete u[g]}if(m.$ref&&d.def)for(let g in u){if(g==="$ref"||g==="allOf")continue;if(g in d.def&&JSON.stringify(u[g])===JSON.stringify(d.def[g]))delete u[g]}}let f=c._zod.parent;if(f&&f!==l){o(f);let d=e.seen.get(f);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:c,jsonSchema:u,path:a.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())o(c[0]);if(e.target!=="openapi-3.0")for(let c of e.seen.entries())vc(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let a of e.seen.values())for(let u of[a.schema,a.def]){let p=u?.allOf;if(!Array.isArray(p))continue;let l=c.get(p);if(l)l.push(u);else c.set(p,[u])}for(let a of e.intersections)for(let u of c.get(a)??[])ol(u)}}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 c=e.external.registry.get(t)?.id;if(!c)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(c)}it(n,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&n.id===s)delete n.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let a=c[1];if(a.def&&a.defId){if(a.def.id===a.defId)delete a.def.id;Y(i,a.defId,a.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(i).length>0)if(e.target==="draft-2020-12")n.$defs=i;else n.definitions=i;try{let c=JSON.parse(JSON.stringify(n));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:ct(t,"input",e.processors),output:ct(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error("Error converting schema to JSON.")}}function F(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 F(o.element,r);if(o.type==="set")return F(o.valueType,r);if(o.type==="lazy")return F(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"||o.type==="catch")return F(o.innerType,r);if(o.type==="intersection")return F(o.left,r)||F(o.right,r);if(o.type==="record"||o.type==="map")return F(o.keyType,r)||F(o.valueType,r);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return F(o.in,r)||F(o.out,r)}if(o.type==="object"){for(let n in o.shape)if(F(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(F(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(F(n,r))return!0;if(o.rest&&F(o.rest,r))return!0;return!1}return!1}var _c=(e,t={})=>(r)=>{let o=Yr({...r,processors:t});return I(e,o),Qr(o,e),eo(o,e)},ct=(e,t,r={})=>(o)=>{let{libraryOptions:n,target:s}=o??{},i=Yr({...n??{},target:s,io:t,processors:r});return I(e,i),Qr(i,e),eo(i,e)};var De=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},Fe=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},bc=(e,t)=>{De(e,"minimum",t),Fe(e,"maximum",t)},zc=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Pc=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Ec=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},Zc=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},kc=(e,t)=>De(e,"minimum",t.minimum),$c=(e,t)=>Fe(e,"maximum",t.maximum),Sc=(e)=>(t,r)=>{Zc(t,r.format);let[o,n]=e[r.format];De(t,"minimum",o),Fe(t,"maximum",n)},nl={greater_than:(e,t)=>De(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Fe(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>zc(e,t.value),number_format:Sc(bt),bigint_format:Sc(mr),min_length:kc,max_length:$c,length_equals:(e,t)=>bc(e,t.length),min_size:kc,max_size:$c,size_equals:(e,t)=>bc(e,t.size),string_format:(e,t)=>{if(Zc(e,t.format),t.pattern)Pc(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>Ec(e,t.mime)};function N(e){let t={},r=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of o)nl[s._zod.def.check]?.(t,s._zod.def);let n=e._zod.bag;if(n.minimum!==void 0)De(t,"minimum",n.minimum);if(n.exclusiveMinimum!==void 0)De(t,"exclusiveMinimum",n.exclusiveMinimum);if(n.maximum!==void 0)Fe(t,"maximum",n.maximum);if(n.exclusiveMaximum!==void 0)Fe(t,"exclusiveMaximum",n.exclusiveMaximum);if(n.multipleOf!==void 0)zc(t,n.multipleOf);if(n.format!==void 0){if(t.format??(t.format=n.format),n.format.includes("int"))t.isInt=!0}if(n.mime)Ec(t,n.mime);for(let s of n.patterns??[])Pc(t,s);return t}var sl={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},il=new Map([[Rr,Bn],[Lt,Jn]]),cl=(e)=>il.get(e)??e,Oc=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:s,maximum:i,format:c,patterns:a,contentEncoding:u,laxFormat:p}=N(e);if(typeof s==="number")n.minLength=s;if(typeof i==="number")n.maxLength=i;if(c){if(n.format=sl[c]??c,n.format==="")delete n.format;if(c==="time"||p)delete n.format}if(u)n.contentEncoding=u;if(a&&a.size>0){let l=[...a].map(cl);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}))]}},Rc=(e,t,r,o)=>{let n=r,{minimum:s,maximum:i,multipleOf:c,exclusiveMaximum:a,exclusiveMinimum:u,isInt:p}=N(e);n.type=p?"integer":"number";let l=typeof u==="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof a==="number"&&a<=(i??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(l)if(d)n.minimum=u,n.exclusiveMinimum=!0;else n.exclusiveMinimum=u;else if(typeof s==="number")n.minimum=s;if(f)if(d)n.maximum=a,n.exclusiveMaximum=!0;else n.exclusiveMaximum=a;else if(typeof i==="number")n.maximum=i;if(c){let m=new Set;for(let v of c)if(Number.isFinite(v)&&v!==0)m.add(Math.abs(v));else te(e,t,n,o,`A multipleOf divisor of ${v} cannot be represented in JSON Schema`);let[y,...g]=m;if(y!==void 0)n.multipleOf=y;if(g.length)n.allOf=[...n.allOf??[],...g.map((v)=>({multipleOf:v}))]}},Cc=(e,t,r,o)=>{r.type="boolean"},Ic=(e,t,r,o)=>{te(e,t,r,o,"BigInt cannot be represented in JSON Schema")};var Ac=(e,t,r,o)=>{r.not={}};var Tc=(e,t,r,o)=>{},Nc=(e,t,r,o)=>{te(e,t,r,o,"Date cannot be represented in JSON Schema")},jc=(e,t,r,o)=>{let n=e._zod.def,s=qe(n.entries);if(s.length===0){r.not={};return}if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";r.enum=s},Dc=(e,t,r,o)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let s=[];for(let i of n.values)if(i===void 0){if(te(e,t,r,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i==="bigint"){if(te(e,t,r,o,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length===0);else if(s.length===1){let i=s[0];if(r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[i];else r.const=i}else{if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";if(s.every((i)=>typeof i==="boolean"))r.type="boolean";if(s.every((i)=>i===null))r.type="null";r.enum=s}};var Fc=(e,t,r,o)=>{te(e,t,r,o,"Custom types cannot be represented in JSON Schema")};var Lc=(e,t,r,o)=>{te(e,t,r,o,"Transforms cannot be represented in JSON Schema")};var Mc=(e,t,r,o)=>{let n=r,s=e._zod.def,{minimum:i,maximum:c}=N(e);if(typeof i==="number")n.minItems=i;if(typeof c==="number")n.maxItems=c;n.type="array",n.items=I(s.element,t,{...o,path:[...o.path,"items"]})};function to(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return to(t.out);if(t.type==="catch")return to(t.innerType);return e._zod.optin}var Wc=(e,t,r,o)=>{let n=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&te(e,t,n,o,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let u in i)Y(n.properties,u,I(i[u],t,{...o,path:[...o.path,"properties",u]}));let a=[];for(let u of Object.keys(i)){let p=s.shape[u];if(t.io==="input"?to(p)===void 0:p._zod.optout===void 0)a.push(u)}if(a.length>0)n.required=a;if(s.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")n.additionalProperties=!1}else if(s.catchall)n.additionalProperties=I(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},Uc=(e,t,r,o)=>{let n=e._zod.def,s=n.inclusive===!1,i=n.options.map((c,a)=>I(c,t,{...o,path:[...o.path,s?"oneOf":"anyOf",a]}));if(s)r.oneOf=i;else r.anyOf=i},Bc=(e,t,r,o)=>{let n=e._zod.def,s=I(n.left,t,{...o,path:[...o.path,"allOf",0]}),i=I(n.right,t,{...o,path:[...o.path,"allOf",1]}),c=(u)=>("allOf"in u)&&Object.keys(u).length===1,a=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];r.allOf=a,t.intersections.push(a)};var Jc=(e,t,r,o)=>{let n=e._zod.def,s=I(n.innerType,t,o),i=t.seen.get(e);if(t.target==="openapi-3.0")i.ref=n.innerType,r.nullable=!0;else r.anyOf=[s,{type:"null"}]},Vc=(e,t,r,o)=>{let n=e._zod.def;I(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType},ro=Symbol();function Hc(e,t,r,o,n){let s=!1,i=JSON.stringify(e,(c,a)=>{if(typeof a!=="bigint")return a;return s=!0,null});if(!s)return JSON.parse(i);return te(t,r,o,n,"BigInt defaults cannot be represented in JSON Schema"),ro}var Kc=(e,t,r,o)=>{let n=e._zod.def;I(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType;let i=Hc(n.defaultValue,e,t,r,o);if(i!==ro)r.default=i},Gc=(e,t,r,o)=>{let n=e._zod.def;I(n.innerType,t,o);let s=t.seen.get(e);if(s.ref=n.innerType,t.io!=="input")return;let i=Hc(n.defaultValue,e,t,r,o);if(i!==ro)r._prefault=i},qc=(e,t,r,o)=>{let n=e._zod.def;I(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType;let i;try{i=n.catchValue(void 0)}catch{te(e,t,r,o,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},Xc=(e,t,r,o)=>{let n=e._zod.def,s=n.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?n.out:n.in:n.out;I(i,t,o);let c=t.seen.get(e);c.ref=i},Yc=(e,t,r,o)=>{let n=e._zod.def;I(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType,r.readOnly=!0};var oo=(e,t,r,o)=>{let n=e._zod.def;I(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType};var Qc=new WeakSet([Object.prototype,Error.prototype]);function Kt(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let o=r(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}var gl=(e,t)=>{yn.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(Qc.has(r))return;Qc.add(r),Kt(r,"format",(o)=>(n)=>vn(o,n)),Kt(r,"flatten",(o)=>(n)=>xn(o,n)),Kt(r,"addIssue",(o)=>(n)=>{o.issues.push(n),o.message=JSON.stringify(o.issues,Xe,2)}),Kt(r,"addIssues",(o)=>(n)=>{o.issues.push(...n),o.message=JSON.stringify(o.issues,Xe,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var V=h("ZodError",gl,void 0,{Parent:Error});var ea=Rt(V),ta=Ct(V),ra=It(V),oa=At(V),na=_n(V),sa=bn(V),ia=kn(V),ca=$n(V),aa=Sn(V),ua=zn(V),pa=Pn(V),la=En(V);function xl(){if(!J.localeError)ee(jr())}function so(){if(!J.memoizer)ee({memoizer:Zi()})}var O=h("ZodType",(e,t)=>(xl(),P.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(B(t,{checks:[...t.checks??[],...e.map((r)=>typeof r==="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return oe(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(lf(e,t))},superRefine(e,t){return this.check(ff(e,t))},overwrite(e){return this.check(ve(e))},optional(){return ha(this)},exactOptional(){return Xl(this)},nullable(){return ma(this)},nullish(){return ha(ma(this))},nonoptional(e){return of(this,e)},array(){return k(this)},or(e){return uo([this,e])},and(e){return Hl(this,e)},transform(e){return ga(this,ql(e))},default(e){return ef(this,e)},prefault(e){return rf(this,e)},catch(e){return sf(this,e)},pipe(e){return ga(this,e)},readonly(){return uf(this)},describe(e){let t=this.clone();return Se.add(t,{description:e}),t},meta(...e){if(e.length===0)return Se.get(this);let t=this.clone();return Se.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Et(this,"~standard",{...Or(this),jsonSchema:{input:ct(this,"input"),output:ct(this,"output")}})},set "~standard"(e){pe(this,"~standard",e)},parse:function e(t,r){return ea(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await ta(this,t,r,{callee:e})},safeParse(e,t){return ra(this,e,t)},async safeParseAsync(e,t){return oa(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){pe(this,"spa",e)},validate(e,t){return wr(this,e,t)},validateAsync(e,t){return _r(this,e,t)},encode:function e(t,r){return na(this,t,r,{callee:e})},decode:function e(t,r){return sa(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await ia(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await ca(this,t,r,{callee:e})},safeEncode(e,t){return aa(this,e,t)},safeDecode(e,t){return ua(this,e,t)},async safeEncodeAsync(e,t){return pa(this,e,t)},async safeDecodeAsync(e,t){return la(this,e,t)},toJSONSchema(e){return _c(this,{})(e)},get description(){return Se.get(this)?.description},get _def(){return this._zod.def}}),ya=h("_ZodString",(e,t)=>{Ft.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Oc(e,r,o,n)},Zt({format:(e)=>N(e).format??null,minLength:(e)=>N(e).minimum??null,maxLength:(e)=>N(e).maximum??null},{regex(...e){return this.check(Lr(...e))},includes(...e){return this.check(Ur(...e))},startsWith(...e){return this.check(Br(...e))},endsWith(...e){return this.check(Jr(...e))},min(...e){return this.check(je(...e))},max(...e){return this.check(Vt(...e))},length(...e){return this.check(Ht(...e))},nonempty(...e){return this.check(je(1,...e))},lowercase(e){return this.check(Mr(e))},uppercase(e){return this.check(Wr(e))},trim(){return this.check(Hr())},normalize(...e){return this.check(Vr(...e))},toLowerCase(){return this.check(Kr())},toUpperCase(){return this.check(Gr())},slugify(){return this.check(qr())}})),io=h("ZodString",(e,t)=>{Ft.init(e,t),ya.init(e,t)},{email(e){return this.check(Ai(kl,e))},url(e){return this.check(Fr(xa,e))},jwt(e){return this.check(Qi(Ll,e))},emoji(e){return this.check(Fi(zl,e))},guid(e){return this.check(Ti($l,e))},uuid(e){return this.check(Dr(ut,e))},uuidv4(e){return this.check(Ni(ut,e))},uuidv6(e){return this.check(ji(ut,e))},uuidv7(e){return this.check(Di(ut,e))},nanoid(e){return this.check(Li(Pl,e))},cuid(e){return this.check(Mi(El,e))},cuid2(e){return this.check(Wi(Zl,e))},ulid(e){return this.check(Ui(Ol,e))},base64(e){return this.check(qi(jl,e))},base64url(e){return this.check(Xi(Dl,e))},xid(e){return this.check(Bi(Rl,e))},ksuid(e){return this.check(Ji(Cl,e))},ipv4(e){return this.check(Vi(Il,e))},ipv6(e){return this.check(Hi(Al,e))},cidrv4(e){return this.check(Ki(Tl,e))},cidrv6(e){return this.check(Gi(Nl,e))},e164(e){return this.check(Yi(Fl,e))},datetime(e){return this.check(ec(vl,e))},date(e){return this.check(tc(wl,e))},time(e){return this.check(rc(_l,e))},duration(e){return this.check(oc(bl,e))}});function _(e){return Ci(io,e)}var R=h("ZodStringFormat",(e,t)=>{E.init(e,t),ya.init(e,t)}),vl=h("ZodISODateTime",(e,t)=>{Ms.init(e,t),R.init(e,t)}),wl=h("ZodISODate",(e,t)=>{Ws.init(e,t),R.init(e,t)}),_l=h("ZodISOTime",(e,t)=>{Us.init(e,t),R.init(e,t)}),bl=h("ZodISODuration",(e,t)=>{Bs.init(e,t),R.init(e,t)}),kl=h("ZodEmail",(e,t)=>{Os.init(e,t),R.init(e,t)});var $l=h("ZodGUID",(e,t)=>{Es.init(e,t),R.init(e,t)});var ut=h("ZodUUID",(e,t)=>{Zs.init(e,t),R.init(e,t)});function co(e){return Dr(ut,e)}var xa=h("ZodURL",(e,t)=>{Is.init(e,t),R.init(e,t)});function Sl(e){return Fr(xa,e)}var zl=h("ZodEmoji",(e,t)=>{As.init(e,t),R.init(e,t)});var Pl=h("ZodNanoID",(e,t)=>{Ts.init(e,t),R.init(e,t)});var El=h("ZodCUID",(e,t)=>{Ns.init(e,t),R.init(e,t)});var Zl=h("ZodCUID2",(e,t)=>{js.init(e,t),R.init(e,t)});var Ol=h("ZodULID",(e,t)=>{Ds.init(e,t),R.init(e,t)});var Rl=h("ZodXID",(e,t)=>{Fs.init(e,t),R.init(e,t)});var Cl=h("ZodKSUID",(e,t)=>{Ls.init(e,t),R.init(e,t)});var Il=h("ZodIPv4",(e,t)=>{Js.init(e,t),R.init(e,t)});var Al=h("ZodIPv6",(e,t)=>{Hs.init(e,t),R.init(e,t)});var Tl=h("ZodCIDRv4",(e,t)=>{Ks.init(e,t),R.init(e,t)});var Nl=h("ZodCIDRv6",(e,t)=>{Gs.init(e,t),R.init(e,t)});var jl=h("ZodBase64",(e,t)=>{Xs.init(e,t),R.init(e,t)});var Dl=h("ZodBase64URL",(e,t)=>{Ys.init(e,t),R.init(e,t)});var Fl=h("ZodE164",(e,t)=>{Qs.init(e,t),R.init(e,t)});var Ll=h("ZodJWT",(e,t)=>{ei.init(e,t),R.init(e,t)});var Gt=h("ZodNumber",(e,t)=>{Cr.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Rc(e,r,o,n),e.isFinite=!0},Zt({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=N(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=N(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=N(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>N(e).format??null},{gt(e,t){return this.check(Ne(e,t))},gte(e,t){return this.check(fe(e,t))},min(e,t){return this.check(fe(e,t))},lt(e,t){return this.check(Te(e,t))},lte(e,t){return this.check(le(e,t))},max(e,t){return this.check(le(e,t))},int(e){return this.check(fa(e))},safe(e){return this.check(fa(e))},positive(e){return this.check(Ne(0,e))},nonnegative(e){return this.check(fe(0,e))},negative(e){return this.check(Te(0,e))},nonpositive(e){return this.check(le(0,e))},multipleOf(e,t){return this.check(st(e,t))},step(e,t){return this.check(st(e,t))},finite(){return this}}));function va(e){return nc(Gt,e)}var Ml=h("ZodNumberFormat",(e,t)=>{ti.init(e,t),Gt.init(e,t)});function fa(e){return ic(Ml,e)}var ao=h("ZodBoolean",(e,t)=>{ri.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Cc(e,r,o,n)});function Le(e){return cc(ao,e)}var wa=h("ZodBigInt",(e,t)=>{oi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ic(e,r,o,n)},Zt({minValue:(e)=>N(e).minimum??null,maxValue:(e)=>N(e).maximum??null,format:(e)=>N(e).format??null},{gte(e,t){return this.check(fe(e,t))},min(e,t){return this.check(fe(e,t))},gt(e,t){return this.check(Ne(e,t))},lt(e,t){return this.check(Te(e,t))},lte(e,t){return this.check(le(e,t))},max(e,t){return this.check(le(e,t))},positive(e){return this.check(Ne(BigInt(0),e))},negative(e){return this.check(Te(BigInt(0),e))},nonpositive(e){return this.check(le(BigInt(0),e))},nonnegative(e){return this.check(fe(BigInt(0),e))},multipleOf(e,t){return this.check(st(e,t))}}));var Wl=h("ZodUnknown",(e,t)=>{ni.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Tc(e,r,o,n)});function da(){return pc(Wl)}var Ul=h("ZodNever",(e,t)=>{si.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ac(e,r,o,n)});function _a(e){return lc(Ul,e)}var ba=h("ZodDate",(e,t)=>{ii.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Nc(e,r,o,n),e.min=(r,o)=>e.check(fe(r,o)),e.max=(r,o)=>e.check(le(r,o))},Zt({minDate:(e)=>{let{minimum:t}=N(e);return t?new Date(t):null},maxDate:(e)=>{let{maximum:t}=N(e);return t?new Date(t):null}},{}));var Bl=h("ZodArray",(e,t)=>{so(),ci.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Mc(e,r,o,n),e.element=t.element},{min(e,t){return this.check(je(e,t))},nonempty(e){return this.check(je(1,e))},max(e,t){return this.check(Vt(e,t))},length(e,t){return this.check(Ht(e,t))},unwrap(){return this.element}});function k(e,t){return dc(Bl,e,t)}var ka=h("ZodObject",(e,t)=>{so(),pi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Wc(e,r,o,n),bp(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return q(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(B(this._zod.def,{catchall:e}))},passthrough(){return this.clone(B(this._zod.def,{catchall:da()}))},loose(){return this.clone(B(this._zod.def,{catchall:da()}))},strict(){return this.clone(B(this._zod.def,{catchall:_a()}))},strip(){return this.clone(B(this._zod.def,{catchall:void 0}))},extend(e){return hp(this,e)},safeExtend(e){return mp(this,e)},merge(e){return gp(this,e)},pick(e){return fp(this,e)},omit(e){return dp(this,e)},partial(...e){return an(Sa,this,e[0])},exactPartial(...e){return an(za,this,e[0],"exactPartial")},required(...e){return yp(Pa,this,e[0])}});function pt(e,t){let r={type:"object",shape:e??{},...x(t)};return new ka(r)}function z(e,t){return new ka({type:"object",shape:e,catchall:_a(),...x(t)})}var $a=h("ZodUnion",(e,t)=>{Ir.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Uc(e,r,o,n),e.options=t.options});function uo(e,t){return new $a({type:"union",options:e,...x(t)})}var Jl=h("ZodDiscriminatedUnion",(e,t)=>{$a.init(e,t),li.init(e,t)});function po(e,t,r){return new Jl({type:"union",options:t,discriminator:e,...x(r)})}var Vl=h("ZodIntersection",(e,t)=>{fi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Bc(e,r,o,n)});function Hl(e,t){return new Vl({type:"intersection",left:e,right:t})}var no=h("ZodEnum",(e,t)=>{di.init(e,t),O.init(e,t),e._zod.processJSONSchema=(o,n,s)=>jc(e,o,n,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let s={};for(let i of o)if(r.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new no({...t,checks:[],...x(n),entries:s})},e.exclude=(o,n)=>{let s={...t.entries};for(let i of o)if(r.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new no({...t,checks:[],...x(n),entries:s})}});function q(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new no({type:"enum",entries:r,...x(t)})}var Kl=h("ZodLiteral",(e,t)=>{hi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Dc(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]}})});function H(e,t){return new Kl({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}var Gl=h("ZodTransform",(e,t)=>{so(),mi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Lc(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new et(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push($e(s,r.value,t));else{let i=s;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=r.value;i.inst??(i.inst=e),r.issues.push($e(i))}};let n=t.transform(r.value,r);if(n instanceof Promise)return n.then((s)=>(r.value=s,r));return r.value=n,r}});function ql(e){return new Gl({type:"transform",transform:e})}var Sa=h("ZodOptional",(e,t)=>{Ar.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>oo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function ha(e){return new Sa({type:"optional",innerType:e})}var za=h("ZodExactOptional",(e,t)=>{gi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>oo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Xl(e){return new za({type:"optional",innerType:e})}var Yl=h("ZodNullable",(e,t)=>{yi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function ma(e){return new Yl({type:"nullable",innerType:e})}var Ql=h("ZodDefault",(e,t)=>{xi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ef(e,t){return new Ql({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():dr(t)}})}var tf=h("ZodPrefault",(e,t)=>{vi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function rf(e,t){return new tf({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():dr(t)}})}var Pa=h("ZodNonOptional",(e,t)=>{wi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Vc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function of(e,t){return new Pa({type:"nonoptional",innerType:e,...x(t)})}var nf=h("ZodCatch",(e,t)=>{_i.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sf(e,t){return new nf({type:"catch",innerType:e,catchValue:typeof t==="function"?t:fn(t)})}var cf=h("ZodPipe",(e,t)=>{bi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xc(e,r,o,n),e.in=t.in,e.out=t.out});function ga(e,t){return new cf({type:"pipe",in:e,out:t})}var af=h("ZodReadonly",(e,t)=>{ki.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function uf(e){return new af({type:"readonly",innerType:e})}var pf=h("ZodCustom",(e,t)=>{$i.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Fc(e,r,o,n)});function lf(e,t={}){return hc(pf,e,t)}function ff(e,t){return mc(e,t)}var lo={};Go(lo,{bigint:()=>yf,boolean:()=>gf,date:()=>xf,number:()=>mf,string:()=>hf});function hf(e){return Ii(io,e)}function mf(e){return sc(Gt,e)}function gf(e){return ac(ao,e)}function yf(e){return uc(wa,e)}function xf(e){return fc(ba,e)}var fo=q(["codex","claude","opencode"]),vf=_().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/),wf="Initialize an AppToolkit workspace, register an existing checkout, or find the approved project workflow.",_f={codex:".agents/skills/apptoolkit/SKILL.md",claude:".claude/skills/apptoolkit/SKILL.md",opencode:".opencode/commands/apptoolkit.md"},Ea=["For requests involving this workspace, read `llm/HARNESS.md` and use its workflow index to open the relevant procedure. Follow the established rules for the project and target repository.","","For a request like “Dame mi lista de pendientes”, open W01. For a new feature, use W16 to establish requirements before W18 implementation."].join(`
|
|
59
|
-
`);
|
|
60
|
-
`)}function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
`}function ld(e,t){let r=cd(e),o=Ve(r,`.project.${td()}.json`);try{id(o,$o(t),{flag:"wx",mode:384}),nd(o,e)}catch(n){try{sd(o,{force:!0})}catch(s){throw AggregateError([n,s],`Write project settings and clean the draft at ${e}.`)}throw Error(`Write project settings at ${e}.`,{cause:n})}}async function Eo(e){let{root:t}=dt(e.root),r=tu(t,Qa(e.configPath));if(!r)throw Error("Provide the approved project settings JSON file.");return Ba(t,()=>{let{receipt:o}=dt(t),n=new Set([".",...o.repositories.map((u)=>u.path)]);for(let u of r.projects){if(!n.has(u.path))throw Error(`Register ${u.path} before initializing its settings.`);for(let p of u.services){if(!o.services.includes(p.provider))throw Error(`Select ${p.provider} during workspace installation before connecting it.`);if(p.snapshots==="versioned"&&!o.workspaceVersioned)throw Error("Versioned service snapshots require a versioned workspace harness.")}}let s=Ve(t,So);if(!o.workspaceVersioned){let u=L(t);if(u)Qt({git:u,path:ad(u.root,s)},!1)}let i=Ze(t),c=new Map(i?.projects.map((u)=>[u.path,u]));for(let u of r.projects)c.set(u.path,u);let a=Ee.parse({schema:1,projects:[...c.values()]});if(i&&$o(i)===$o(a))return{path:s,changed:!1,projects:a.projects.length};return ld(s,a),{path:s,changed:!0,projects:a.projects.length}})}var fd=z({root:_().min(1),project:Be,service:Je,verifyHealth:Le().optional(),verifyRead:Le()}),dd=pt({results:k(pt({id:co()})).max(1)}),hd=pt({name:_().min(1)}),md=131072;class _e extends Error{}function Oo(e){let{root:t,receipt:r}=dt(e.root);if(!r.services.includes(e.service))throw Error(`${e.service} is not selected in the installed workspace.`);if(e.project!=="."&&!r.repositories.some((s)=>s.path===e.project))throw Error(`Register ${e.project} before using its service connections.`);let n=Ze(t)?.projects.find((s)=>s.path===e.project)?.services.find((s)=>s.provider===e.service);if(!n)throw Error(`Initialize the ${e.service} connection for ${e.project} first.`);return{root:t,receipt:r,connection:n}}function Zo(e,t){let r=new URL(e);if(!r.pathname.endsWith("/"))r.pathname+="/";return new URL(t,r)}function gd(e){if(e.provider==="plane"){let r=`api/v1/workspaces/${e.workspace}/projects/${e.projectId}/work-items/`,o=Zo(e.baseUrl,r);return o.searchParams.set("per_page","1"),o.searchParams.set("fields","id"),o}let t=Zo(e.baseUrl,"api/rpc/command/get-file-summary");return t.searchParams.set("id",e.fileId),t}function yd(e,t){let r=new Headers({Accept:"application/json"});if(e.provider==="penpot")r.set("Authorization",`Token ${t}`);else if(e.auth==="oauth")r.set("Authorization",`Bearer ${t}`);else r.set("X-API-Key",t);return r}async function xd(e){if(!e.headers.get("content-type")?.toLowerCase().startsWith("application/json"))throw await e.body?.cancel(),new _e("Expected an application/json response from the service.");let r=e.body?.getReader();if(!r)throw new _e("The service response has no body.");let o=[],n=0;try{for(;;){let s=await r.read();if(s.done)return Buffer.concat(o,n).toString("utf8");if(n+=s.value.byteLength,n>md)throw await r.cancel(),new _e("The service response exceeded the 128 KiB verification limit.");o.push(s.value)}}finally{r.releaseLock()}}async function vd(e,t){let r=await t(Zo(e.baseUrl,"./"),{method:"HEAD",redirect:"manual",signal:AbortSignal.timeout(1e4)});return await r.body?.cancel(),r.status}async function wd(e,t,r){let o=await r(gd(e),{method:"GET",headers:yd(e,t),redirect:"error",signal:AbortSignal.timeout(1e4)});if(!o.ok)throw await o.body?.cancel(),new _e(`The selected resource returned HTTP ${o.status}. Confirm the target and its read permission.`);let n=await xd(o),s=e.provider==="plane"?dd:hd,i=!1;try{i=s.safeParse(JSON.parse(n)).success}catch(c){throw new _e("The service returned invalid JSON.",{cause:c})}if(!i)throw new _e("The response does not match the expected resource read.");return o.status}async function Ro(e,t={}){let r=fd.parse(e),{connection:o}=Oo(r),s=(t.environment??process.env)[o.tokenEnv],i=typeof s==="string"&&/^[\x21-\x7e]+$/.test(s),c={provider:o.provider,project:r.project,baseUrl:o.baseUrl,credentialEnv:o.tokenEnv,credentialAvailable:i,snapshots:o.snapshots,connectivity:"unchecked",read:"unchecked"},a=t.fetch??fetch;if(r.verifyRead){if(!i)throw Error(`Provide ${o.tokenEnv} in the process environment before verifying access.`);try{let u=await wd(o,s,a);return{...c,connectivity:"reachable",read:"verified",httpStatus:u}}catch(u){let p=u instanceof _e?u.message:"Check the configured host and retry.";throw Error(`Verify ${o.provider} read for ${r.project}. ${p}`,{cause:u})}}if(r.verifyHealth)try{let u=await vd(o,a);return{...c,connectivity:u>=500?"service-error":"reachable",httpStatus:u}}catch(u){throw Error(`Check ${o.provider} connectivity for ${r.project}.`,{cause:u})}return c}import{createHash as _d}from"node:crypto";import{constants as ru,createReadStream as bd,openSync as kd}from"node:fs";import{join as $d,relative as ou,resolve as Sd}from"node:path";var nu=Ue.refine((e)=>e.startsWith("harness-snapshots/"),{message:"Keep native service exports in the workspace harness-snapshots directory."}),zd=_().regex(/^[a-f0-9]{64}$/),Pd=z({path:nu,bytes:va().int().positive(),sha256:zd}),Ed=z({root:_().min(1),project:Be,service:Je}),su=z({schema:H(1),project:Be,service:Je,files:k(Pd).min(1).max(30)}).refine((e)=>new Set(e.files.map((t)=>t.path)).size===e.files.length,"Duplicate snapshot paths.");function iu(e,t){let r=Sd(e,t),o=nu.parse(ou(e,r)),n=e,s=o.split("/");for(let[i,c]of s.entries()){n=$d(n,c);let a=me(n);if(!(i===s.length-1?a?.isFile():a?.isDirectory()))throw Error(`Expected a regular nonsymlink snapshot path at ${n}.`)}return r}async function cu(e,t){let r=iu(e,t),o=me(r);if(!o?.isFile()||o.size===0)throw Error(`Expected a nonempty snapshot file at ${r}.`);let n=_d("sha256");try{let i=kd(r,ru.O_RDONLY|ru.O_NOFOLLOW),c=bd(r,{fd:i});for await(let a of c)n.update(a)}catch(i){throw Error(`Read snapshot bytes at ${r}.`,{cause:i})}let s=me(r);if(!s||o.dev!==s.dev||o.ino!==s.ino||o.mtimeMs!==s.mtimeMs||o.size!==s.size)throw Error(`Snapshot changed while reading ${r}. Retry with a stable export.`);return{path:ou(e,r),bytes:o.size,sha256:n.digest("hex")}}function au(e){let{root:t,receipt:r,connection:o}=Oo(Ed.parse(e));if(!r.workspaceVersioned||o.snapshots!=="versioned")throw Error("Enable versioned snapshots for this project and provider before working with a snapshot.");return t}async function Co(e){let t=au({root:e.root,project:e.project,service:e.service}),r=k(_().min(1)).min(1).max(30).parse(e.paths),o=[];for(let n of r)o.push(await cu(t,n));return su.parse({schema:1,project:e.project,service:e.service,files:o})}async function Io(e){let t=au({root:e.root,project:e.project,service:e.service}),r=iu(t,e.manifestPath),o=su.parse(zo(r));if(o.project!==e.project||o.service!==e.service)throw Error("The snapshot manifest belongs to a different project or service.");for(let n of o.files){let s=await cu(t,n.path);if(s.bytes!==n.bytes||s.sha256!==n.sha256)throw Error(`Snapshot integrity check failed for ${n.path}.`)}return{manifestPath:r,project:o.project,service:o.service,files:o.files.length}}import{closeSync as uu,constants as Ao,fstatSync as pu,lstatSync as lu,openSync as Zd,readSync as Od,realpathSync as Rd}from"node:fs";import{isAbsolute as du,join as Cd}from"node:path";var Id=262144,Ad=new Set([".aws",".git",".gnupg",".npm",".ssh","credentials","node_modules","passwords","private","processing","raw","secret","secrets"]);function hu(e){let t=e.toLowerCase(),r=t.replace(/(?:\.llm)?\.md$/,"");return t.startsWith(".env")||Ad.has(r)}function Td(e){if(du(e)||/[\\:\x00-\x1f\x7f]/.test(e))throw Error("Provide a relative path inside the project root.");let t=e.split("/");for(let r of t){if(r===""||r==="."||r==="..")throw Error("Paths must use explicit project-relative segments.");if(hu(r))throw Error(`The path crosses a protected location at "${r}".`)}return t}function fu(e,t){if(!du(e))throw Error("Provide an absolute project root.");if(!lu(e).isDirectory())throw Error("The project root must be a directory.");let r=Rd(e);if(r.split("/").filter(Boolean).some((s,i)=>(i!==0||s!=="private")&&hu(s)))throw Error("The project root crosses a protected location.");let n;for(let[s,i]of t.entries()){if(r=Cd(r,i),n=lu(r),n.isSymbolicLink())throw Error(`Symbolic links are not allowed in the project path at "${i}".`);if(s<t.length-1&&!n.isDirectory())throw Error(`Expected a directory at "${i}".`)}if(!n?.isFile())throw Error("The project path must resolve to a regular file.");return{path:r,info:n}}function Nd(e,t,r,o){let n=pu(e);if(!n.isFile()||n.ino!==t.ino||n.dev!==t.dev)throw Error("The file changed while opening. Retry after checking its path.");if(n.size>r)throw Error(`${o} source exceeds ${r} bytes. Use a narrower input.`);let s=Buffer.alloc(n.size+1),i=0;while(i<s.length){let a=Od(e,s,i,s.length-i,i);if(a===0)break;i+=a}if(i>r)throw Error(`${o} source exceeds ${r} bytes. Use a narrower input.`);let c=pu(e);if(c.size!==i||n.size!==c.size||n.mtimeMs!==c.mtimeMs||n.ctimeMs!==c.ctimeMs)throw Error("The source changed during the read. Retry with a stable file.");return s.subarray(0,i)}function jd(e,t,r,o){let n;try{n=Nd(e,t,r,o)}catch(s){try{uu(e)}catch(i){throw AggregateError([s,i],"Reading and closing the file both failed.")}throw s}return uu(e),n}function tr(e,t,r,o){try{let n=Td(t),{path:s,info:i}=fu(e,n),c=Zd(s,Ao.O_RDONLY|Ao.O_NOFOLLOW|Ao.O_NONBLOCK),a=jd(c,i,r,o),u=fu(e,n);if(u.path!==s||u.info.ino!==i.ino||u.info.dev!==i.dev)throw Error("The file path changed during the read. Retry after verifying the current path.");return new TextDecoder("utf-8",{fatal:!0}).decode(a)}catch(n){let s=n instanceof Error?n.message:String(n);throw Error(`Unable to read ${o} "${t}". ${s}`,{cause:n})}}function ht(e,t){if(!t.toLowerCase().endsWith(".md"))throw Error("Provide a relative Markdown path inside the project root.");return tr(e,t,Id,"Markdown context")}function mu(e){return e.match(/[^\n]*\n|[^\n]+$/g)??[]}function gu(e,t,r){let o=e.toLowerCase().replace(/[^\p{L}\p{M}\p{N}_\s-]/gu,"").trim().replace(/\s+/g,"-");return{title:e,level:t,line:r,locator:`line:${r}`,anchor:`#${o}`}}function Dd(e){let t=/^ {0,3}(`{3,}|~{3,})/.exec(e)?.[1];if(t)return{marker:t.charAt(0),length:t.length};return}function Fd(e,t){let r=/^ {0,3}(`{3,}|~{3,})[ \t]*$/.exec(e)?.[1];return r!==void 0&&r.startsWith(t.marker)&&r.length>=t.length}function Ld(e,t){let r=/^ {0,3}(#{1,6})[ \t]+(.*)$/.exec(e),o=r?.[1],n=r?.[2];if(o&&n){let s=n.replace(/(?:^|[ \t]+)#+[ \t]*$/,"").trim();if(s)return gu(s,o.length,t)}return}function Md(e){if(!e.trim()||/^(?: {4}|\t)/.test(e))return!1;return!/^ {0,3}(?:[>#<]|[-+*][ \t]|\d+[.)][ \t]|\[[^\]]+\]:|(?:[*_-][ \t]*){3,})/.test(e)}function yu(e){let t=[],r,o,n=!1,s=-1;if(e[0]?.trim()==="---")s=e.findIndex((i,c)=>c>0&&/^(---|\.\.\.)$/.test(i.trim()));for(let[i,c]of e.entries()){if(i<=s)continue;let a=c.replace(/\r?\n$/,""),u=i+1;if(r){if(Fd(a,r))r=void 0;continue}if(n||a.trimStart().startsWith("<!--")){n=!a.includes("-->"),o=void 0;continue}if(r=Dd(a),r){o=void 0;continue}let p=Ld(a,u);if(p){t.push(p),o=void 0;continue}let l=/^ {0,3}(=+|-+)[ \t]*$/.exec(a)?.[1];if(l&&o){let f=o.lines.join(" "),d=l.startsWith("=")?1:2;t.push(gu(f,d,o.line)),o=void 0;continue}if(!Md(a)){o=void 0;continue}if(!o)o={line:u,lines:[]};o.lines.push(a.trim())}return t}var To=_().min(1).refine((e)=>!/[\x00-\x1f\x7f]/.test(e),"Control characters are not allowed."),Wd=z({root:To.max(4096),file:To.max(4096),section:To.max(512).optional()}),xu=128,vu=16384;function Ud(e,t){let r=e.filter((n)=>{if(/^line:[1-9][0-9]*$/.test(t))return n.locator===t;if(t.startsWith("#"))return n.anchor===t;return n.title===t}),[o]=r;if(!o)throw Error(`No heading matches "${t}". List the heading index and use an exact locator.`);if(r.length>1){let n=r.slice(0,8).map((i)=>i.locator),s=r.length>n.length?", or another locator from the index":"";throw Error(`Heading "${t}" is ambiguous. Use one of ${n.join(", ")}${s}.`)}return o}function wu(e,t){if(Buffer.byteLength(e)>vu)throw Error(`Context output exceeds ${vu} bytes. ${t}`)}function _u(e){let t=Wd.parse(e),r=mu(ht(t.root,t.file)),o=yu(r);if(t.section===void 0){if(o.length>xu)throw Error(`Heading index exceeds ${xu} entries. Request a known section or use a narrower map.`);let u={kind:"index",file:t.file,headings:o};return wu(JSON.stringify(u),"Request a known section or use a narrower map."),u}let n=Ud(o,t.section),s=o.find((u)=>u.line>n.line&&u.level<=n.level),i=s?s.line-1:r.length,c=r.slice(n.line-1,i).join(""),a={kind:"section",file:t.file,heading:n,startLine:n.line,endLine:i,text:c};return wu(JSON.stringify(a),"Choose a smaller child section or a narrower map."),a}import{realpathSync as Xd}from"node:fs";import{isAbsolute as Do,normalize as Yd,relative as Qd,resolve as eh}from"node:path";var ku=q(["lines","functions","branches"]),Bd=q(["LF","LH","FNF","FNH","BRF","BRH"]),Jd={lines:{found:"LF",hit:"LH"},functions:{found:"FNF",hit:"FNH"},branches:{found:"BRF",hit:"BRH"}};function $u(e){return{source:e,summaries:new Map,lines:new Map,branches:new Map,functionNames:new Set,functionHits:new Map,groupIds:new Set,aliasHits:new Map,versionSeen:!1}}function T(e,t){let r=Number(e);if(!/^\d+$/.test(e)||!Number.isSafeInteger(r)||r<t)throw Error("Expected an integer within the supported range.");return r}function mt(e,t,r){if(e.has(t))throw Error("Duplicate coverage entry.");e.set(t,r)}function bu(e,t){if(e.has(t))throw Error("Duplicate coverage identity.");e.add(t)}function Vd(e,t){let[r,o,,n,s]=t.split(",");if(!r||!o||s!==void 0)throw Error("Expected a line number and execution count.");let i=T(r,1);if(n!==void 0)T(n,i);mt(e.lines,String(i),T(o,0)>0)}function Hd(e,t){let r=/^([^,]+),([ef]?u?\d+(?:\^\d+)?),(.+),([^,]+)$/.exec(t),o=r?.[1],n=r?.[2],s=r?.[3],i=r?.[4];if(!o||!n||!s||!i)throw Error("Expected a branch line, block, identity and hit count.");let[,c,a]=/^[ef]?u?(\d+)(?:\^(\d+))?$/.exec(n)??[];if(!c)throw Error("Expected a numeric branch block.");let u=JSON.stringify([T(o,1),T(c,0),a===void 0?null:T(a,0),/^\d+$/.test(s)?T(s,0):s]);mt(e.branches,u,i!=="-"&&T(i,0)>0)}function Kd(e,t,r){let o=t==="FN"?/^(\d+),(?:(\d+),)?(.+)$/:/^(\d+),(\d+)(?:,(\d+))?$/,[,n,s,i]=o.exec(r)??[];if(n===void 0)throw Error("Malformed function definition.");if(t==="FN"&&i){let c=T(n,1);if(s)T(s,c);bu(e.functionNames,i);return}if(t==="FNL"&&s){let c=T(s,1);if(i)T(i,c);bu(e.groupIds,String(T(n,0)));return}throw Error("Malformed function definition.")}function Gd(e,t,r){if(t==="FNDA"){let[,a,u]=/^(\d+),(.+)$/.exec(r)??[];if(!a||!u)throw Error("Expected a function hit count and name.");mt(e.functionHits,u,T(a,0)>0);return}let[,o,n,s]=/^(\d+),(\d+),(.+)$/.exec(r)??[];if(!o||!n||!s)throw Error("Expected an alias group, hit count and name.");let i=String(T(o,0)),c=e.aliasHits.get(i)??new Map;mt(c,s,T(n,0)>0),e.aliasHits.set(i,c)}function Su(e,t,r){let o=Bd.safeParse(t);if(o.success){mt(e.summaries,o.data,T(r,0));return}switch(t){case"VER":if(e.versionSeen||!r)throw Error("Expected one source version per record.");e.versionSeen=!0;return;case"DA":return Vd(e,r);case"BRDA":return Hd(e,r);case"FN":case"FNL":return Kd(e,t,r);case"FNDA":case"FNA":return Gd(e,t,r);default:throw Error("Unsupported LCOV field. Export a line, function and branch report.")}}function No(e){let t=0;for(let r of e.values())if(r)t+=1;return{found:e.size,hit:t}}function qd(e){let t=e.functionNames.size>0||e.functionHits.size>0,r=e.groupIds.size>0||e.aliasHits.size>0;if(t&&r)throw Error("Function records mix classic names and alias groups.");if(r){let o=0;if(e.groupIds.size!==e.aliasHits.size)throw Error("Missing function group or alias records.");for(let n of e.groupIds){let s=e.aliasHits.get(n);if(!s?.size)throw Error("Function group is missing execution records.");if(Array.from(s.values()).some(Boolean))o+=1}return{found:e.groupIds.size,hit:o}}if(e.functionNames.size!==e.functionHits.size)throw Error("Missing function names or execution records.");for(let o of e.functionNames)if(!e.functionHits.has(o))throw Error("A function definition has no matching execution record.");return No(e.functionHits)}function zu(e,t){let r=Jd[t],o=e.summaries.get(r.found),n=e.summaries.get(r.hit);if(o===void 0||n===void 0)throw Error(`Missing ${r.found} or ${r.hit} summary.`);let s;switch(t){case"lines":s=No(e.lines);break;case"functions":s=qd(e);break;case"branches":s=No(e.branches);break}if(s.found!==o||s.hit!==n)throw Error(`Summary ${n}/${o} differs from measured entries ${s.hit}/${s.found}.`);if(n!==o)throw Error(`Only ${n}/${o} were covered. The requirement is 100 percent.`);return s}var rr=_().min(1).max(4096).refine((e)=>!/[\x00-\x1f\x7f]/.test(e)),th=z({root:rr,file:rr,config:rr}),rh=z({files:k(rr).min(1).max(1e4),metrics:k(ku).min(1).max(3)});function jo(e){if(Do(e)||/[\\:\x00-\x1f\x7f]/.test(e)||e.split("/").some((t)=>!t||t==="."||t===".."))throw Error(`Use a project-relative source path in the coverage configuration. Received "${e}".`);return e}function Pu(e,t){let r=Qd(e,t);if(!r||r===".."||r.startsWith("../")||Do(r))return;return r}function oh(e,t,r){if(!e||/[\\:\x00-\x1f\x7f]/.test(e))throw Error("Expected a valid source path in the LCOV record.");if(Do(e)){let o=Pu(t,e)??Pu(r,e);if(o)return jo(o);throw Error("An LCOV source is outside the project root.")}return jo(Yd(e))}function nh(e,t){for(let[r,o]of t)try{let n=zu(e,r);o.found+=n.found,o.hit+=n.hit}catch(n){let s=n instanceof Error?n.message:String(n);throw Error(`${e.source} ${r}. ${s}`,{cause:n})}}function sh(e,t,r,o){let n=Xd(t),s=new Set,i=new Set,c,a=!1;for(let[p,l]of e.split(/\r?\n/).entries()){if(!l.trim()||l.startsWith("#"))continue;try{if(/[\x00-\x08\x0b-\x1f\x7f]/.test(l))throw Error("Control characters are not allowed in coverage records.");if(l.startsWith("TN:")&&!c&&!a)a=!0;else if((l.startsWith("SF:")||l.startsWith("KF:"))&&!c){let f=l.slice(3),[,d,m]=/^(\d+),(.*)$/.exec(f)??[],y=oh(m??f,t,n);if(d!==void 0){let g=Number(d);if(!Number.isSafeInteger(g)||i.has(g))throw Error("Expected a distinct safe integer source index.");i.add(g)}if(s.has(y))throw Error(`Duplicate LCOV source "${y}".`);if(!r.has(y))throw Error(`Unexpected LCOV source "${y}".`);c=$u(y),a=!1}else if(l==="end_of_record"&&c)nh(c,o),s.add(c.source),c=void 0;else if(c){let f=l.indexOf(":");if(f<1)throw Error("Malformed LCOV field.");Su(c,l.slice(0,f),l.slice(f+1))}else throw Error("Expected an LCOV source record.")}catch(f){let d=f instanceof Error?f.message:String(f);throw Error(`LCOV line ${p+1}. ${d}`,{cause:f})}}if(c||a)throw Error("The final LCOV record is incomplete.");let u=Array.from(r).filter((p)=>!s.has(p));if(u.length)throw Error(`LCOV is missing ${u.length} expected source files. First missing path is "${u[0]}".`)}function Eu(e){let t=th.parse(e),r=tr(t.root,t.config,262144,"coverage configuration"),o;try{o=rh.parse(JSON.parse(r))}catch(a){throw Error(`Invalid coverage configuration "${t.config}". Provide JSON arrays for files and metrics.`,{cause:a})}let n=new Set(o.files.map(jo)),s=new Map;for(let a of o.metrics)s.set(a,{found:0,hit:0});if(n.size!==o.files.length||s.size!==o.metrics.length)throw Error("Coverage configuration contains duplicate files or metrics.");let i=tr(t.root,t.file,16777216,"LCOV report");sh(i,eh(t.root),n,s);let c=Array.from(s,([a,u])=>{if(u.found===0)throw Error(`No measurable ${a} were found for the selected scope.`);return{metric:a,...u,percent:100}});return{file:t.file,config:t.config,sources:n.size,metrics:c}}import{lstatSync as Vu}from"node:fs";import{relative as Ju,resolve as be}from"node:path";import{lstatSync as ih,readdirSync as Ou}from"node:fs";import{basename as Zu,resolve as gt}from"node:path";var ch=pt({name:_().optional(),workspaces:uo([k(_()),pt({packages:k(_())})]).optional()}),ah=new Set(["package.json","pnpm-workspace.yaml","Cargo.toml","go.mod","pyproject.toml","Gemfile","pom.xml","composer.json"]),Ru=new Set([".git",".DS_Store",".agents",".claude",".opencode","llm","node_modules","dist","vendor"]);function uh(e){let t=C(e,"package.json");if(!t)return;try{return ch.parse(JSON.parse(t.bytes.toString("utf8")))}catch(r){throw Error(`Cannot read ${gt(e,"package.json")}. Correct the manifest and retry.`,{cause:r})}}function He(e,t){if(t===".")return e;re(t);let r=de(gt(e,t));if(!go(e,r)||r!==gt(e,t))throw Error(`Choose a real directory inside ${e}. The repository path resolves through a symbolic link: ${t}.`);if(L(r)?.root!==r)throw Error(`Choose the Git repository root at ${r} before registering it.`);return r}function ph(e){let t=Ou(e,{withFileTypes:!0});if(t.length>2048)throw Error(`Workspace discovery is limited to 2048 entries at ${e}. Choose a narrower directory.`);let r=[];for(let o of t.sort((n,s)=>n.name.localeCompare(s.name,"en"))){if(!o.isDirectory()||o.name.startsWith(".")||Ru.has(o.name))continue;let n=gt(e,o.name);if(!ih(gt(n,".git"),{throwIfNoEntry:!1}))continue;if(L(n)?.root!==n)throw Error(`The Git metadata in ${n} does not identify that checkout as a repository root.`);re(o.name),r.push({path:o.name,name:o.name,gitRoot:n})}return r}function Oe(e){let t=de(e),r=L(t),o=ph(t),n=new Set(Ou(t)),s=uh(t),i=Boolean(s?.workspaces||n.has("pnpm-workspace.yaml")||n.has("lerna.json")),c=[...ah].some((l)=>n.has(l)),a=r?{gitRoot:r.root}:{};if(o.length&&!i){let l=[...o];if(c)l.unshift({path:".",name:s?.name??Zu(t),...a});return{root:t,kind:"workspace",monorepo:i,repositories:l,...a}}let u=[...n].every((l)=>Ru.has(l)),p={path:".",name:s?.name??Zu(t),...a};return{root:t,kind:u?"blank":"existing",monorepo:i,repositories:[p],...a}}import{lstatSync as Au}from"node:fs";import{resolve as yt}from"node:path";function lh(e,t,r,o=!1){let n=`# appToolkit harness ${t} begin`,s=`# appToolkit harness ${t} end`,i=e.includes(`\r
|
|
58
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let c=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(c.cycle){s(i);continue}if(c.count>1){if(e.reused==="ref")s(i)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Nc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let o of t){if(!o||typeof o!=="object")return;Nc(o);let n=Object.keys(o);if(n.length!==1||n[0]!=="type")return;let s=o.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!=="string")return;if(!r.includes(i))r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Tc=new Set(["type","properties","required","additionalProperties"]),Ic=["oneOf","anyOf"];function jc(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function po(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let i in s)if(!Tc.has(i))return null;t.push(s)}let r={},o=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let c=[];for(let u of t){let p=u.properties?.[i]??jc(u);if(p===null||p===void 0)continue;if(!c.some((l)=>JSON.stringify(l)===JSON.stringify(p)))c.push(p)}let a=c.length===1?c[0]:po(c)??{allOf:c};Q(r,i,a)}for(let i of s.required??[])o.add(i)}let n={type:"object",properties:r};if(o.size)n.required=[...o];if(t.every((s)=>s.additionalProperties===!1))n.additionalProperties=!1;else{let s=[];for(let i of t){let c=jc(i);if(c&&!s.some((a)=>JSON.stringify(a)===JSON.stringify(c)))s.push(c)}if(s.length===1)n.additionalProperties=s[0];else if(s.length>1)n.additionalProperties={allOf:s}}return n}function kl(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of Tc)if(n in e)return;let r=t.filter((n)=>Ic.some((s)=>Array.isArray(n[s]))),o=null;if(!r.length)o=po(t);else{let n=r[0],s=Ic.find((a)=>Array.isArray(n[a]));if(Object.keys(n).length!==1)return;let i=t.filter((a)=>a!==n),c=n[s].map((a)=>po([...i,a]));if(c.some((a)=>!a))return;o={[s]:c}}if(!o)return;delete e.allOf,xt(e,o)}function ho(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(c)=>{let a=e.seen.get(c);if(a.ref===null)return;let u=a.def??a.schema,p={...u},l=a.ref;if(a.ref=null,l){o(l);let h=e.seen.get(l),d=h.schema;if(d.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(d);else xt(u,d);if(xt(u,p),c._zod.parent===l)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(!(y in p))delete u[y]}if(d.$ref&&h.def)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(y in h.def&&JSON.stringify(u[y])===JSON.stringify(h.def[y]))delete u[y]}}let f=c._zod.parent;if(f&&f!==l){o(f);let h=e.seen.get(f);if(h?.schema.$ref){if(u.$ref=h.schema.$ref,h.def)for(let d in u){if(d==="$ref"||d==="allOf")continue;if(d in h.def&&JSON.stringify(u[d])===JSON.stringify(h.def[d]))delete u[d]}}}e.override({zodSchema:c,jsonSchema:u,path:a.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())o(c[0]);if(e.target!=="openapi-3.0")for(let c of e.seen.entries())Nc(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let a of e.seen.values())for(let u of[a.schema,a.def]){let p=u?.allOf;if(!Array.isArray(p))continue;let l=c.get(p);if(l)l.push(u);else c.set(p,[u])}for(let a of e.intersections)for(let u of c.get(a)??[])kl(u)}}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 c=e.external.registry.get(t)?.id;if(!c)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(c)}xt(n,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&n.id===s)delete n.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let a=c[1];if(a.def&&a.defId){if(a.def.id===a.defId)delete a.def.id;Q(i,a.defId,a.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(i).length>0)if(e.target==="draft-2020-12")n.$defs=i;else n.definitions=i;try{let c=JSON.parse(JSON.stringify(n));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:vt(t,"input",e.processors),output:vt(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error("Error converting schema to JSON.")}}function U(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 U(o.element,r);if(o.type==="set")return U(o.valueType,r);if(o.type==="lazy")return U(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"||o.type==="catch")return U(o.innerType,r);if(o.type==="intersection")return U(o.left,r)||U(o.right,r);if(o.type==="record"||o.type==="map")return U(o.keyType,r)||U(o.valueType,r);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return U(o.in,r)||U(o.out,r)}if(o.type==="object"){for(let n in o.shape)if(U(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(U(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(U(n,r))return!0;if(o.rest&&U(o.rest,r))return!0;return!1}return!1}var Dc=(e,t={})=>(r)=>{let o=lo({...r,processors:t});return N(e,o),fo(o,e),ho(o,e)},vt=(e,t,r={})=>(o)=>{let{libraryOptions:n,target:s}=o??{},i=lo({...n??{},target:s,io:t,processors:r});return N(e,i),fo(i,e),ho(i,e)};var Ge=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},qe=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},Fc=(e,t)=>{Ge(e,"minimum",t),qe(e,"maximum",t)},Uc=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Bc=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Vc=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},Jc=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Lc=(e,t)=>Ge(e,"minimum",t.minimum),Mc=(e,t)=>qe(e,"maximum",t.maximum),Wc=(e)=>(t,r)=>{Jc(t,r.format);let[o,n]=e[r.format];Ge(t,"minimum",o),qe(t,"maximum",n)},$l={greater_than:(e,t)=>Ge(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>qe(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Uc(e,t.value),number_format:Wc(At),bigint_format:Wc(Er),min_length:Lc,max_length:Mc,length_equals:(e,t)=>Fc(e,t.length),min_size:Lc,max_size:Mc,size_equals:(e,t)=>Fc(e,t.size),string_format:(e,t)=>{if(Jc(e,t.format),t.pattern)Bc(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>Vc(e,t.mime)};function L(e){let t={},r=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of o)$l[s._zod.def.check]?.(t,s._zod.def);let n=e._zod.bag;if(n.minimum!==void 0)Ge(t,"minimum",n.minimum);if(n.exclusiveMinimum!==void 0)Ge(t,"exclusiveMinimum",n.exclusiveMinimum);if(n.maximum!==void 0)qe(t,"maximum",n.maximum);if(n.exclusiveMaximum!==void 0)qe(t,"exclusiveMaximum",n.exclusiveMaximum);if(n.multipleOf!==void 0)Uc(t,n.multipleOf);if(n.format!==void 0){if(t.format??(t.format=n.format),n.format.includes("int"))t.isInt=!0}if(n.mime)Vc(t,n.mime);for(let s of n.patterns??[])Bc(t,s);return t}var Sl={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},zl=new Map([[Br,rs],[qt,os]]),Hc=(e)=>zl.get(e)??e,Kc=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:s,maximum:i,format:c,patterns:a,contentEncoding:u,laxFormat:p}=L(e);if(typeof s==="number")n.minLength=s;if(typeof i==="number")n.maxLength=i;if(c){if(n.format=Sl[c]??c,n.format==="")delete n.format;if(c==="time"||p)delete n.format}if(u)n.contentEncoding=u;if(a&&a.size>0){let l=[...a].map(Hc);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}))]}},Gc=(e,t,r,o)=>{let n=r,{minimum:s,maximum:i,multipleOf:c,exclusiveMaximum:a,exclusiveMinimum:u,isInt:p}=L(e);n.type=p?"integer":"number";let l=typeof u==="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof a==="number"&&a<=(i??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(l)if(h)n.minimum=u,n.exclusiveMinimum=!0;else n.exclusiveMinimum=u;else if(typeof s==="number")n.minimum=s;if(f)if(h)n.maximum=a,n.exclusiveMaximum=!0;else n.exclusiveMaximum=a;else if(typeof i==="number")n.maximum=i;if(c){let d=new Set;for(let x of c)if(Number.isFinite(x)&&x!==0)d.add(Math.abs(x));else re(e,t,n,o,`A multipleOf divisor of ${x} cannot be represented in JSON Schema`);let[m,...y]=d;if(m!==void 0)n.multipleOf=m;if(y.length)n.allOf=[...n.allOf??[],...y.map((x)=>({multipleOf:x}))]}},qc=(e,t,r,o)=>{r.type="boolean"},Xc=(e,t,r,o)=>{re(e,t,r,o,"BigInt cannot be represented in JSON Schema")};var Yc=(e,t,r,o)=>{if(t.target==="openapi-3.0")r.type="string",r.nullable=!0,r.enum=[null];else r.type="null"};var Qc=(e,t,r,o)=>{r.not={}};var ea=(e,t,r,o)=>{},ta=(e,t,r,o)=>{re(e,t,r,o,"Date cannot be represented in JSON Schema")},ra=(e,t,r,o)=>{let n=e._zod.def,s=ct(n.entries);if(s.length===0){r.not={};return}if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";r.enum=s},oa=(e,t,r,o)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let s=[];for(let i of n.values)if(i===void 0){if(re(e,t,r,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i==="bigint"){if(re(e,t,r,o,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length===0);else if(s.length===1){let i=s[0];if(r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[i];else r.const=i}else{if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";if(s.every((i)=>typeof i==="boolean"))r.type="boolean";if(s.every((i)=>i===null))r.type="null";r.enum=s}};var na=(e,t,r,o)=>{re(e,t,r,o,"Custom types cannot be represented in JSON Schema")};var sa=(e,t,r,o)=>{re(e,t,r,o,"Transforms cannot be represented in JSON Schema")};var ia=(e,t,r,o)=>{let n=r,s=e._zod.def,{minimum:i,maximum:c}=L(e);if(typeof i==="number")n.minItems=i;if(typeof c==="number")n.maxItems=c;n.type="array",n.items=N(s.element,t,{...o,path:[...o.path,"items"]})};function nr(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return nr(t.out);if(t.type==="catch")return nr(t.innerType);return e._zod.optin}var ca=(e,t,r,o)=>{let n=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&re(e,t,n,o,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let u in i)Q(n.properties,u,N(i[u],t,{...o,path:[...o.path,"properties",u]}));let a=[];for(let u of Object.keys(i)){let p=s.shape[u];if(t.io==="input"?nr(p)===void 0:p._zod.optout===void 0)a.push(u)}if(a.length>0)n.required=a;if(s.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")n.additionalProperties=!1}else if(s.catchall)n.additionalProperties=N(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},aa=(e,t,r,o)=>{let n=e._zod.def,s=n.inclusive===!1,i=n.options.map((c,a)=>N(c,t,{...o,path:[...o.path,s?"oneOf":"anyOf",a]}));if(s)r.oneOf=i;else r.anyOf=i},ua=(e,t,r,o)=>{let n=e._zod.def,s=N(n.left,t,{...o,path:[...o.path,"allOf",0]}),i=N(n.right,t,{...o,path:[...o.path,"allOf",1]}),c=(u)=>("allOf"in u)&&Object.keys(u).length===1,a=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];r.allOf=a,t.intersections.push(a)};function mo(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let d=e.get(t)?.def;if(!d)return t;let m=mo(e,d,r);return m===d?t:m}for(let d of["anyOf","oneOf"]){let m=t[d];if(!Array.isArray(m))continue;let y=m.map((x)=>mo(e,x,r));if(y.some((x,w)=>x!==m[w]))t={...t,[d]:y}}let o=Array.isArray(t.type)?t.type:[t.type],n=!o.includes("string")&&o.some((d)=>d==="number"||d==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!n&&!s?.some((d)=>typeof d==="number"))return t;let{minimum:i,maximum:c,exclusiveMinimum:a,exclusiveMaximum:u,multipleOf:p,format:l,id:f,...h}=t;if(h.enum)h.enum=h.enum.map((d)=>typeof d==="number"?String(d):d);else if(typeof h.const==="number")h.const=String(h.const);if(!n)return h;if(h.type="string",!s)h.pattern=(o.includes("number")?ft:Tr).source;return h}var go=new WeakMap;function Pl(e){let t=new Map;for(let o of e.seen.values())if(o.def&&!t.has(o.schema))t.set(o.schema,o);let r=new Map;for(let o of go.get(e)??[]){let n=e.seen.get(o),s=(n?.def??n?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=mo(t,s,new Set);if(i!==s)r.set(s,i)}if(!r.size)return;for(let o of e.seen.values())for(let n of[o.schema,o.def]){let s=n&&r.get(n.propertyNames);if(s)n.propertyNames=s}}var pa=(e,t,r,o)=>{let n=r,s=e._zod.def;n.type="object";let i=s.keyType,c=L(i).patterns;if(s.mode==="loose"&&c&&c.size>0){let p=N(s.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let l of c)Q(n.patternProperties,Hc(l).source,p)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){n.propertyNames=N(s.keyType,t,{...o,path:[...o.path,"propertyNames"]});let p=go.get(t);if(!p)p=[],go.set(t,p),t.deferred.push(()=>Pl(t));p.push(e)}n.additionalProperties=N(s.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let a=i._zod.values,u=t.io==="input"&&nr(s.valueType)!==void 0;if(a&&!s.partial&&!u){let p=[...a].filter((l)=>typeof l==="string"||typeof l==="number");if(p.length>0)n.required=p.map(String)}},la=(e,t,r,o)=>{let n=e._zod.def,s=N(n.innerType,t,o),i=t.seen.get(e);if(t.target==="openapi-3.0")i.ref=n.innerType,r.nullable=!0;else r.anyOf=[s,{type:"null"}]},fa=(e,t,r,o)=>{let n=e._zod.def;N(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType},yo=Symbol();function da(e,t,r,o,n){let s=!1,i=JSON.stringify(e,(c,a)=>{if(typeof a!=="bigint")return a;return s=!0,null});if(!s)return JSON.parse(i);return re(t,r,o,n,"BigInt defaults cannot be represented in JSON Schema"),yo}var ha=(e,t,r,o)=>{let n=e._zod.def;N(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType;let i=da(n.defaultValue,e,t,r,o);if(i!==yo)r.default=i},ma=(e,t,r,o)=>{let n=e._zod.def;N(n.innerType,t,o);let s=t.seen.get(e);if(s.ref=n.innerType,t.io!=="input")return;let i=da(n.defaultValue,e,t,r,o);if(i!==yo)r._prefault=i},ga=(e,t,r,o)=>{let n=e._zod.def;N(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType;let i;try{i=n.catchValue(void 0)}catch{re(e,t,r,o,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},ya=(e,t,r,o)=>{let n=e._zod.def,s=n.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?n.out:n.in:n.out;N(i,t,o);let c=t.seen.get(e);c.ref=i},xa=(e,t,r,o)=>{let n=e._zod.def;N(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType,r.readOnly=!0};var xo=(e,t,r,o)=>{let n=e._zod.def;N(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType},va=(e,t,r,o)=>{let n=e._zod.innerType;N(n,t,o);let s=t.seen.get(e);s.ref=n};var wa=new WeakSet([Object.prototype,Error.prototype]);function sr(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let o=r(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}var Nl=(e,t)=>{On.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(wa.has(r))return;wa.add(r),sr(r,"format",(o)=>(n)=>Rn(o,n)),sr(r,"flatten",(o)=>(n)=>Zn(o,n)),sr(r,"addIssue",(o)=>(n)=>{o.issues.push(n),o.message=JSON.stringify(o.issues,at,2)}),sr(r,"addIssues",(o)=>(n)=>{o.issues.push(...n),o.message=JSON.stringify(o.issues,at,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Y=g("ZodError",Nl,void 0,{Parent:Error});var ba=Mt(Y),_a=Wt(Y),ka=Ut(Y),$a=Bt(Y),Sa=An(Y),za=In(Y),Pa=jn(Y),Ea=Nn(Y),Oa=Tn(Y),Za=Dn(Y),Ra=Fn(Y),Ca=Ln(Y);function Dl(){if(!H.localeError)X(qr())}function ir(){if(!H.memoizer)X({memoizer:Vi()})}var C=g("ZodType",(e,t)=>(Dl(),Z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(q(t,{checks:[...t.checks??[],...e.map((r)=>typeof r==="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ne(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(jf(e,t))},superRefine(e,t){return this.check(Nf(e,t))},overwrite(e){return this.check($e(e))},optional(){return Na(this)},exactOptional(){return wf(this)},nullable(){return Ta(this)},nullish(){return Na(Ta(this))},nonoptional(e){return zf(this,e)},array(){return P(this)},or(e){return ur([this,e])},and(e){return gf(this,e)},transform(e){return Da(this,vf(e))},default(e){return kf(this,e)},prefault(e){return Sf(this,e)},catch(e){return Ef(this,e)},pipe(e){return Da(this,e)},readonly(){return Rf(this)},describe(e){let t=this.clone();return Ce.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ce.get(this);let t=this.clone();return Ce.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Dt(this,"~standard",{...Ur(this),jsonSchema:{input:vt(this,"input"),output:vt(this,"output")}})},set "~standard"(e){fe(this,"~standard",e)},parse:function e(t,r){return ba(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await _a(this,t,r,{callee:e})},safeParse(e,t){return ka(this,e,t)},async safeParseAsync(e,t){return $a(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){fe(this,"spa",e)},validate(e,t){return Ar(this,e,t)},validateAsync(e,t){return Ir(this,e,t)},encode:function e(t,r){return Sa(this,t,r,{callee:e})},decode:function e(t,r){return za(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Pa(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Ea(this,t,r,{callee:e})},safeEncode(e,t){return Oa(this,e,t)},safeDecode(e,t){return Za(this,e,t)},async safeEncodeAsync(e,t){return Ra(this,e,t)},async safeDecodeAsync(e,t){return Ca(this,e,t)},toJSONSchema(e){return Dc(this,{})(e)},get description(){return Ce.get(this)?.description},get _def(){return this._zod.def}}),Fa=g("_ZodString",(e,t)=>{Gt.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kc(e,r,o,n)},Ft({format:(e)=>L(e).format??null,minLength:(e)=>L(e).minimum??null,maxLength:(e)=>L(e).maximum??null},{regex(...e){return this.check(Qr(...e))},includes(...e){return this.check(ro(...e))},startsWith(...e){return this.check(oo(...e))},endsWith(...e){return this.check(no(...e))},min(...e){return this.check(Ke(...e))},max(...e){return this.check(rr(...e))},length(...e){return this.check(or(...e))},nonempty(...e){return this.check(Ke(1,...e))},lowercase(e){return this.check(eo(e))},uppercase(e){return this.check(to(e))},trim(){return this.check(io())},normalize(...e){return this.check(so(...e))},toLowerCase(){return this.check(co())},toUpperCase(){return this.check(ao())},slugify(){return this.check(uo())}})),wo=g("ZodString",(e,t)=>{Gt.init(e,t),Fa.init(e,t)},{email(e){return this.check(qi(Ul,e))},url(e){return this.check(Yr(La,e))},jwt(e){return this.check(mc(cf,e))},emoji(e){return this.check(tc(Jl,e))},guid(e){return this.check(Xi(Bl,e))},uuid(e){return this.check(Xr(bt,e))},uuidv4(e){return this.check(Yi(bt,e))},uuidv6(e){return this.check(Qi(bt,e))},uuidv7(e){return this.check(ec(bt,e))},nanoid(e){return this.check(rc(Hl,e))},cuid(e){return this.check(oc(Kl,e))},cuid2(e){return this.check(nc(Gl,e))},ulid(e){return this.check(sc(ql,e))},base64(e){return this.check(fc(of,e))},base64url(e){return this.check(dc(nf,e))},xid(e){return this.check(ic(Xl,e))},ksuid(e){return this.check(cc(Yl,e))},ipv4(e){return this.check(ac(Ql,e))},ipv6(e){return this.check(uc(ef,e))},cidrv4(e){return this.check(pc(tf,e))},cidrv6(e){return this.check(lc(rf,e))},e164(e){return this.check(hc(sf,e))},datetime(e){return this.check(gc(Fl,e))},date(e){return this.check(yc(Ll,e))},time(e){return this.check(xc(Ml,e))},duration(e){return this.check(vc(Wl,e))}});function k(e){return Ki(wo,e)}var j=g("ZodStringFormat",(e,t)=>{A.init(e,t),Fa.init(e,t)}),Fl=g("ZodISODateTime",(e,t)=>{ei.init(e,t),j.init(e,t)}),Ll=g("ZodISODate",(e,t)=>{ti.init(e,t),j.init(e,t)}),Ml=g("ZodISOTime",(e,t)=>{ri.init(e,t),j.init(e,t)}),Wl=g("ZodISODuration",(e,t)=>{oi.init(e,t),j.init(e,t)}),Ul=g("ZodEmail",(e,t)=>{Us.init(e,t),j.init(e,t)});var Bl=g("ZodGUID",(e,t)=>{Ms.init(e,t),j.init(e,t)});var bt=g("ZodUUID",(e,t)=>{Ws.init(e,t),j.init(e,t)});function bo(e){return Xr(bt,e)}var La=g("ZodURL",(e,t)=>{Js.init(e,t),j.init(e,t)});function Vl(e){return Yr(La,e)}var Jl=g("ZodEmoji",(e,t)=>{Hs.init(e,t),j.init(e,t)});var Hl=g("ZodNanoID",(e,t)=>{Ks.init(e,t),j.init(e,t)});var Kl=g("ZodCUID",(e,t)=>{Gs.init(e,t),j.init(e,t)});var Gl=g("ZodCUID2",(e,t)=>{qs.init(e,t),j.init(e,t)});var ql=g("ZodULID",(e,t)=>{Xs.init(e,t),j.init(e,t)});var Xl=g("ZodXID",(e,t)=>{Ys.init(e,t),j.init(e,t)});var Yl=g("ZodKSUID",(e,t)=>{Qs.init(e,t),j.init(e,t)});var Ql=g("ZodIPv4",(e,t)=>{ni.init(e,t),j.init(e,t)});var ef=g("ZodIPv6",(e,t)=>{ii.init(e,t),j.init(e,t)});var tf=g("ZodCIDRv4",(e,t)=>{ci.init(e,t),j.init(e,t)});var rf=g("ZodCIDRv6",(e,t)=>{ai.init(e,t),j.init(e,t)});var of=g("ZodBase64",(e,t)=>{pi.init(e,t),j.init(e,t)});var nf=g("ZodBase64URL",(e,t)=>{li.init(e,t),j.init(e,t)});var sf=g("ZodE164",(e,t)=>{fi.init(e,t),j.init(e,t)});var cf=g("ZodJWT",(e,t)=>{di.init(e,t),j.init(e,t)});var cr=g("ZodNumber",(e,t)=>{Vr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gc(e,r,o,n),e.isFinite=!0},Ft({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=L(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=L(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=L(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>L(e).format??null},{gt(e,t){return this.check(He(e,t))},gte(e,t){return this.check(he(e,t))},min(e,t){return this.check(he(e,t))},lt(e,t){return this.check(Je(e,t))},lte(e,t){return this.check(de(e,t))},max(e,t){return this.check(de(e,t))},int(e){return this.check(Aa(e))},safe(e){return this.check(Aa(e))},positive(e){return this.check(He(0,e))},nonnegative(e){return this.check(he(0,e))},negative(e){return this.check(Je(0,e))},nonpositive(e){return this.check(de(0,e))},multipleOf(e,t){return this.check(yt(e,t))},step(e,t){return this.check(yt(e,t))},finite(){return this}}));function ar(e){return wc(cr,e)}var af=g("ZodNumberFormat",(e,t)=>{hi.init(e,t),cr.init(e,t)});function Aa(e){return _c(af,e)}var _o=g("ZodBoolean",(e,t)=>{mi.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qc(e,r,o,n)});function Ae(e){return kc(_o,e)}var Ma=g("ZodBigInt",(e,t)=>{gi.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xc(e,r,o,n)},Ft({minValue:(e)=>L(e).minimum??null,maxValue:(e)=>L(e).maximum??null,format:(e)=>L(e).format??null},{gte(e,t){return this.check(he(e,t))},min(e,t){return this.check(he(e,t))},gt(e,t){return this.check(He(e,t))},lt(e,t){return this.check(Je(e,t))},lte(e,t){return this.check(de(e,t))},max(e,t){return this.check(de(e,t))},positive(e){return this.check(He(BigInt(0),e))},negative(e){return this.check(Je(BigInt(0),e))},nonpositive(e){return this.check(de(BigInt(0),e))},nonnegative(e){return this.check(he(BigInt(0),e))},multipleOf(e,t){return this.check(yt(e,t))}}));var uf=g("ZodNull",(e,t)=>{yi.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yc(e,r,o,n)});function pf(e){return zc(uf,e)}var lf=g("ZodUnknown",(e,t)=>{xi.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ea(e,r,o,n)});function Ia(){return Pc(lf)}var ff=g("ZodNever",(e,t)=>{vi.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Qc(e,r,o,n)});function Wa(e){return Ec(ff,e)}var Ua=g("ZodDate",(e,t)=>{wi.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ta(e,r,o,n),e.min=(r,o)=>e.check(he(r,o)),e.max=(r,o)=>e.check(de(r,o))},Ft({minDate:(e)=>{let{minimum:t}=L(e);return t?new Date(t):null},maxDate:(e)=>{let{maximum:t}=L(e);return t?new Date(t):null}},{}));var df=g("ZodArray",(e,t)=>{ir(),bi.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ia(e,r,o,n),e.element=t.element},{min(e,t){return this.check(Ke(e,t))},nonempty(e){return this.check(Ke(1,e))},max(e,t){return this.check(rr(e,t))},length(e,t){return this.check(or(e,t))},unwrap(){return this.element}});function P(e,t){return Zc(df,e,t)}var Ba=g("ZodObject",(e,t)=>{ir(),$i.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ca(e,r,o,n),Up(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return B(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(q(this._zod.def,{catchall:e}))},passthrough(){return this.clone(q(this._zod.def,{catchall:Ia()}))},loose(){return this.clone(q(this._zod.def,{catchall:Ia()}))},strict(){return this.clone(q(this._zod.def,{catchall:Wa()}))},strip(){return this.clone(q(this._zod.def,{catchall:void 0}))},extend(e){return jp(this,e)},safeExtend(e){return Np(this,e)},merge(e){return Tp(this,e)},pick(e){return Ap(this,e)},omit(e){return Ip(this,e)},partial(...e){return wn(Ja,this,e[0])},exactPartial(...e){return wn(Ha,this,e[0],"exactPartial")},required(...e){return Dp(Ka,this,e[0])}});function me(e,t){let r={type:"object",shape:e??{},...v(t)};return new Ba(r)}function O(e,t){return new Ba({type:"object",shape:e,catchall:Wa(),...v(t)})}var Va=g("ZodUnion",(e,t)=>{Jr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>aa(e,r,o,n),e.options=t.options});function ur(e,t){return new Va({type:"union",options:e,...v(t)})}var hf=g("ZodDiscriminatedUnion",(e,t)=>{Va.init(e,t),Si.init(e,t)});function ko(e,t,r){return new hf({type:"union",options:t,discriminator:e,...v(r)})}var mf=g("ZodIntersection",(e,t)=>{zi.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ua(e,r,o,n)});function gf(e,t){return new mf({type:"intersection",left:e,right:t})}var ja=g("ZodRecord",(e,t)=>{ir(),Pi.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>pa(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function _t(e,t,r){if(!t||!t._zod)return new ja({type:"record",keyType:k(),valueType:e,...v(t)});return new ja({type:"record",keyType:e,valueType:t,...v(r)})}var vo=g("ZodEnum",(e,t)=>{Ei.init(e,t),C.init(e,t),e._zod.processJSONSchema=(o,n,s)=>ra(e,o,n,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let s={};for(let i of o)if(r.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new vo({...t,checks:[],...v(n),entries:s})},e.exclude=(o,n)=>{let s={...t.entries};for(let i of o)if(r.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new vo({...t,checks:[],...v(n),entries:s})}});function B(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new vo({type:"enum",entries:r,...v(t)})}var yf=g("ZodLiteral",(e,t)=>{Oi.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>oa(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]}})});function K(e,t){return new yf({type:"literal",values:Array.isArray(e)?e:[e],...v(t)})}var xf=g("ZodTransform",(e,t)=>{ir(),Zi.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>sa(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new lt(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push(Re(s,r.value,t));else{let i=s;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=r.value;i.inst??(i.inst=e),r.issues.push(Re(i))}};let n=t.transform(r.value,r);if(n instanceof Promise)return n.then((s)=>(r.value=s,r));return r.value=n,r}});function vf(e){return new xf({type:"transform",transform:e})}var Ja=g("ZodOptional",(e,t)=>{Hr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>xo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Na(e){return new Ja({type:"optional",innerType:e})}var Ha=g("ZodExactOptional",(e,t)=>{Ri.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>xo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function wf(e){return new Ha({type:"optional",innerType:e})}var bf=g("ZodNullable",(e,t)=>{Ci.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>la(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Ta(e){return new bf({type:"nullable",innerType:e})}var _f=g("ZodDefault",(e,t)=>{Ai.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ha(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function kf(e,t){return new _f({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():zr(t)}})}var $f=g("ZodPrefault",(e,t)=>{Ii.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ma(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Sf(e,t){return new $f({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():zr(t)}})}var Ka=g("ZodNonOptional",(e,t)=>{ji.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>fa(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function zf(e,t){return new Ka({type:"nonoptional",innerType:e,...v(t)})}var Pf=g("ZodCatch",(e,t)=>{Ni.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ga(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ef(e,t){return new Pf({type:"catch",innerType:e,catchValue:typeof t==="function"?t:$n(t)})}var Of=g("ZodPipe",(e,t)=>{Ti.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ya(e,r,o,n),e.in=t.in,e.out=t.out});function Da(e,t){return new Of({type:"pipe",in:e,out:t})}var Zf=g("ZodReadonly",(e,t)=>{Di.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>xa(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Rf(e){return new Zf({type:"readonly",innerType:e})}var Cf=g("ZodLazy",(e,t)=>{Fi.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>va(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});function Af(e){return new Cf({type:"lazy",getter:e})}var If=g("ZodCustom",(e,t)=>{Li.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>na(e,r,o,n)});function jf(e,t={}){return Rc(If,e,t)}function Nf(e,t){return Cc(e,t)}function pr(e){let t=Af(()=>ur([k(e),ar(),Ae(),pf(),P(t),_t(k(),t)]));return t}var $o={};sn($o,{bigint:()=>Mf,boolean:()=>Lf,date:()=>Wf,number:()=>Ff,string:()=>Df});function Df(e){return Gi(wo,e)}function Ff(e){return bc(cr,e)}function Lf(e){return $c(_o,e)}function Mf(e){return Sc(Ma,e)}function Wf(e){return Oc(Ua,e)}var So=B(["codex","claude","opencode"]),Uf=k().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/),Bf="Run AppToolkit Harness init or update when explicitly requested.",Vf={codex:".agents/skills/apptoolkit/SKILL.md",claude:".claude/skills/apptoolkit/SKILL.md",opencode:".opencode/commands/apptoolkit.md"};function zo(e,t="llm/HARNESS.md"){let r=new Set(P(So).parse(e)),o=[],n=[`At the start of work, resolve \`${t}\` from the project or workspace root that owns this bootstrap. Open it for scoped rules, tools, prior findings and the workflow index. Follow the established rules for the project. Use W01 for pending work and W16 then W18 for feature work.`,"Prefer reliable deterministic tools for mechanical work. Reuse the project runner and tool catalog. When work repeats or stdout is hard to use, improve or build the smallest tested utility and index it.","Capture durable decisions, human and PR feedback, and verified research in the project knowledge index as you work. Retrieve relevant prior findings first. Create and maintain applicable sibling .llm.md source maps. Apply and verify authorized local improvements to rules, checks and workflows before handoff."].join(`
|
|
59
|
+
`);if(r.has("codex")||r.has("opencode"))o.push({path:"AGENTS.md",content:n});if(r.has("claude"))o.push({path:"CLAUDE.md",content:n});return o}function Jf(e,t){let r=["---"];if(e!=="opencode")r.push("name: apptoolkit");if(r.push(`description: ${Bf}`),e==="claude")r.push('argument-hint: "[init | update]"',"disable-model-invocation: true");if(r.push("---","",`# AppToolkit Harness ${t}`,""),e!=="codex")r.push("Treat the following as user arguments, never as shell source.","","$ARGUMENTS","");return r.push("Find the installed workspace root using `llm/harness/workspace.json`. Open the session from that root when discovery is ambiguous.","Use this entry point for init and update. For ordinary work, follow the native project instructions and `llm/HARNESS.md` directly.","","Use `rtk proxy bun --no-env-file <workspace>/llm/harness/runtime/harness.mjs` for deterministic operations. If only Node.js is available, replace `bun --no-env-file` with `node`. Substitute absolute paths with individually quoted arguments.","","- For `init`, read W20 from the installed index. Use the installed runtime with `init --root <workspace> --json`. Ask the user about budgets, Biome scope and any blocked automatic bootstrap paths. Apply the authorized project choices and verify discovery with the steps in W20.","- For `update`, use `rtk proxy bunx --bun @apptoolkit/harness@latest update --root <workspace> --plan --json` (or `rtk proxy npx --yes @apptoolkit/harness@latest update --root <workspace> --plan --json`). Use the exact reported version for subsequent commands. Follow W20 to compare changed guidance with project rules. For any conflict, show the scoped alternatives and ask which prevails. Apply a clean plan with `--yes --json` and verify the result.",""),r.join(`
|
|
60
|
+
`)}function Po(e,t){let r=P(So).parse(e),o=Uf.parse(t),n=[...new Set(r)].map((s)=>({path:Vf[s],content:Jf(s,o)}));if(r.includes("codex"))n.push({path:".agents/skills/apptoolkit/agents/openai.yaml",content:`policy:
|
|
61
|
+
allow_implicit_invocation: false
|
|
62
|
+
`});return n}import{randomUUID as Sd}from"node:crypto";import{lstatSync as zd,readFileSync as Pd,realpathSync as xu,renameSync as Ed,rmSync as Od,writeFileSync as Zd}from"node:fs";import{dirname as Rd,join as rt,relative as Cd,resolve as vu}from"node:path";import{mkdirSync as ad,readFileSync as ud,rmSync as iu,writeFileSync as pd}from"node:fs";import{tmpdir as ld}from"node:os";import{resolve as Zo}from"node:path";import{createHash as Hf,randomUUID as Kf}from"node:crypto";import{chmodSync as Gf,linkSync as qf,lstatSync as lr,mkdirSync as Xf,readFileSync as Yf,realpathSync as Xa,renameSync as Qf,rmSync as ed,unlinkSync as td,writeFileSync as rd}from"node:fs";import{dirname as Ga,isAbsolute as Ya,relative as Qa,resolve as kt,sep as od}from"node:path";var qa=16777216;class fr extends Error{}function eu(e){return"code"in e&&e.code==="ENOENT"}function ge(e){let t=Xa(kt(e));if(!lr(t).isDirectory())throw Error(`Expected an existing directory at ${t}.`);return t}function Eo(e,t){let r=Qa(e,t);return r!==".."&&!r.startsWith(`..${od}`)&&!Ya(r)}function ye(e,t){if(!Eo(e,t))throw Error(`Path ${t} is outside ${e}.`);return Qa(e,t)||"."}function oe(e){let t=e.split("/");if(Ya(e)||/[\\\u0000-\u001f\u007f]/u.test(e)||t.some((r)=>!r||r==="."||r===".."||r===".git"))throw Error(`Expected a safe relative path. Received ${JSON.stringify(e)}.`)}function dr(e,t){if(oe(t),Xa(e)!==e||!lr(e).isDirectory())throw Error(`The installation base changed. Inspect ${e} before retrying.`);let r=t.split("/"),o=e;for(let[n,s]of r.entries()){o=kt(o,s);let i=lr(o,{throwIfNoEntry:!1});if(!i)break;let c=n===r.length-1;if(i.isSymbolicLink()||!c&&!i.isDirectory()||c&&!i.isFile())throw new fr(`Expected a regular file path. Inspect ${o} before retrying.`)}return kt(e,t)}function V(e){return Hf("sha256").update(e).digest("hex")}function T(e,t=420){let r=Buffer.isBuffer(e)?e:Buffer.from(e);return{bytes:r,hash:V(r),mode:t}}function R(e,t){let r=dr(e,t),o=lr(r,{throwIfNoEntry:!1});if(!o)return null;if(o.size>qa)throw Error(`The file at ${r} exceeds the ${qa}-byte installation limit.`);return T(Yf(r),o.mode&511)}function ae(e,t){return e?.hash===t?.hash&&e?.mode===t?.mode}function Ie(e){if(!ae(R(e.base,e.path),e.before))throw Error(`File changed after planning. Replan before applying ${kt(e.base,e.path)}.`)}function $t(e){Ie(e);let t=dr(e.base,e.path);if(!e.after){td(t);return}Xf(Ga(t),{recursive:!0}),Ie(e);let r=kt(Ga(t),`.apptoolkit-${Kf()}.tmp`),o=e.after;try{if(rd(r,o.bytes,{flag:"wx",mode:o.mode}),Gf(r,o.mode),e.before)Ie(e),Qf(r,t);else qf(r,t)}finally{ed(r,{force:!0})}}import{spawnSync as nd}from"node:child_process";import{lstatSync as sd,realpathSync as tu}from"node:fs";import{dirname as ru,resolve as Oo}from"node:path";function id(){let e={};for(let[t,r]of Object.entries(process.env))if(!t.startsWith("GIT_"))e[t]=r;return{...e,GIT_OPTIONAL_LOCKS:"0",LC_ALL:"C"}}function Xe(e,t,r=[0],o=!1){let s=nd("rtk",["proxy","git",...o?["--literal-pathspecs"]:[],"-C",e,...t],{encoding:"utf8",env:id(),maxBuffer:1048576,timeout:1e4});if(s.error)throw Error(`Cannot run Git ${t[0]} in ${e}. Verify RTK and Git are installed.`,{cause:s.error});if(s.status===null||!r.includes(s.status))throw Error(`Git ${t[0]} failed in ${e}: ${s.stderr.trim()||`exit ${s.status}`}`);return{output:s.stdout,status:s.status}}function ou(e){let t=e;while(!0){let r=sd(Oo(t,".git"),{throwIfNoEntry:!1});if(r?.isDirectory()||r?.isFile())return t;if(r)throw Error(`Unsupported Git metadata at ${Oo(t,".git")}. Inspect the repository before retrying.`);let o=ru(t);if(o===t)return;t=o}}function J(e){if(!ou(e))return;let t=tu(Xe(e,["rev-parse","--show-toplevel"]).output.trimEnd()),r=tu(Xe(e,["rev-parse","--path-format=absolute","--git-common-dir"]).output.trimEnd()),o=Xe(e,["rev-parse","--path-format=absolute","--git-path","info/exclude"]).output.trimEnd();if(Oo(r,"info/exclude")!==o)throw Error(`Git returned a local exclude path outside the expected metadata directory for ${e}.`);return{root:t,commonDirectory:r,exclude:"info/exclude"}}function je(e,t){if(ou(ru(e))!==t)throw Error(`The path ${e} belongs to a different Git checkout. Select that checkout explicitly before retrying.`)}function Ye(e,t){let r=ye(e.root,t);return Xe(e.root,["ls-files","--cached","-z","--",r],[0],!0).output.split("\x00").includes(r)}function hr(e,t){let r=Xe(e.git.root,["check-ignore","--quiet","--",`./${e.path}`],[0,1]);if(!t&&r.status!==0)throw Error(`Git did not ignore ${e.path} in ${e.git.root}. Check for an existing tracked file or a higher-priority rule before retrying.`);if(t&&r.status===0)throw Error(`Git ignores ${e.path} in ${e.git.root}. Choose local mode or resolve the existing exclusion before retrying.`)}function cd(e){if(e.includes("://")){try{let n=new URL(e);if(n.hostname&&n.pathname!=="/")return`${n.host.toLowerCase()}${n.pathname.replace(/\.git\/?$/,"").replace(/\/$/,"")}`}catch(n){throw Error("Git returned an invalid origin URL. Correct the local repository configuration before retrying.",{cause:n})}return}let t=/^(?:[^@/:\s]+@)?([^/:\s]+):([^\s]+)$/.exec(e),r=t?.[1],o=t?.[2];if(r&&o)return`${r.toLowerCase()}/${o.replace(/^\//,"").replace(/\.git\/?$/,"").replace(/\/$/,"")}`;return}function nu(e){let t=Xe(e,["config","--local","--get","remote.origin.url"],[0,1]);if(t.status===1)return;let r=cd(t.output.trimEnd());if(!r)return;return V(r)}function St(e){return`/${e.replace(/[\\[\]*? #!]/gu,"\\$&")}`}var fd=$o.number().int().positive(),cu=new WeakMap;function au(e,t){cu.set(e,t)}function dd(e){let t=Zo(ld(),`apptoolkit-${V(e).slice(0,24)}.lock`),r=Zo(t,"owner");try{ad(t,{mode:448})}catch(o){if(!(o instanceof Error)||!("code"in o)||o.code!=="EEXIST")throw Error(`Cannot acquire the installation lock ${t}.`,{cause:o});let n;try{n=fd.parse(ud(r,"utf8"))}catch(s){throw Error(`An installation lock already exists at ${t}. If no install is running, remove the stale lock directory and retry.`,{cause:s})}try{process.kill(n,0)}catch(s){if(s instanceof Error&&"code"in s&&s.code==="ESRCH")throw Error(`The previous installation stopped. Remove its stale lock at ${t} and rerun the same installation to resume.`,{cause:s});throw Error(`Cannot confirm whether the installation holding ${t} is still running.`,{cause:s})}throw Error(`Another installation is running for ${e} with process ID ${n}. Retry after it finishes.`)}try{pd(r,`${process.pid}
|
|
63
|
+
`,{mode:384,flag:"wx"})}catch(o){try{iu(t,{recursive:!0})}catch(n){throw AggregateError([o,n],`Cannot record or remove the installation lock at ${t}.`)}throw Error(`Cannot record the installation lock owner at ${r}.`,{cause:o})}return t}function hd(e){let t=new Map;for(let r of e){let n=t.get(r.git.root)??J(r.git.root)?.commonDirectory;if(n!==r.git.commonDirectory)throw Error(`Git metadata changed after planning in ${r.git.root}. Replan the installation.`);if(t.set(r.git.root,n),!r.versioned&&Ye(r.git,r.absolute))throw Error(`Git started tracking ${r.absolute} after planning. Replan before applying local mode.`)}}function md(e,t){let r=[t];for(let o of e.reverse())try{$t({...o,before:o.after,after:o.before})}catch(n){r.push(Error(`Cannot restore ${Zo(o.base,o.path)} after the installation failed.`,{cause:n}))}if(r.length>1)throw AggregateError(r,"Installation stopped and some files could not be restored. Inspect the reported paths and replan.");throw t}function gd(e){let{exclusions:t,files:r,checks:o,guards:n=[],receipt:s}=e,i=[];for(let c of[...n,...t,...r])Ie(c);for(let c of e.boundaries??[])je(c.absolute,c.gitRoot);hd(o);try{for(let c of t)$t(c),i.push(c);for(let c of o)hr(c,c.versioned);for(let c of r)$t(c),i.push(c);if(s){for(let c of n)Ie(c);for(let c of r)Ie({...c,before:c.after});$t(s),i.push(s)}}catch(c){md(i,Error("Could not apply the workspace installation. Inspect the cause and replan before retrying.",{cause:c}))}return i.length}function su(e){let t=[];for(let r of e.reverse())try{iu(r,{recursive:!0})}catch(o){if(!(o instanceof Error)||!eu(o))t.push(Error(`Cannot remove the installation lock at ${r}. Inspect it before retrying.`,{cause:o}))}return t}function uu(e,t){let r=[],o;try{for(let s of[...new Set(e)].sort())r.push(dd(s));o=t()}catch(s){let i=su(r);if(i.length)throw AggregateError([s,...i],"The installation failed and some locks could not be removed.");throw s}let n=su(r);if(n.length)throw AggregateError(n,"The installation completed and some locks could not be removed.");return o}function pu(e,t){return uu([e],t)}function Ro(e,t){let r=[e,...t.exclusions.map((o)=>o.base),...t.checks.map((o)=>o.git.commonDirectory)];return uu(r,()=>gd(t))}function Co(e){let t=cu.get(e);if(!t)throw Error("Apply requires a plan created by this process. Run the workspace planner again.");if(e.conflicts.length)throw Error(`Resolve the workspace conflicts before applying: ${e.conflicts.map((o)=>o.path).join(", ")}.`);return{changed:Ro(e.root,t),receipt:e.receipt}}import{resolve as yd}from"node:path";var lu=B(["codex","claude","opencode"]),fu=B(["plane","penpot"]),Qe=k().regex(/^[a-f0-9]{64}$/),du=O({path:k().min(1),versioned:Ae(),identity:Qe.optional()}),hu=O({schema:K(1),version:k().min(1),hosts:P(lu),workspaceVersioned:Ae(),repositories:P(du),services:P(fu),bootstrapNotices:P(k()).optional(),installation:k().regex(/^[a-f0-9]{16}$/).optional(),files:P(O({path:k().min(1),hash:Qe,versioned:Ae(),fragment:Qe.optional(),retainedAgainst:Qe.nullable().optional()}))}),mr=O({root:k().min(1),action:B(["install","update","add-repo"]),version:k().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/),contentDirectory:k(),hosts:P(lu).min(1),workspaceVersioned:Ae(),repositories:P(du),services:P(fu),repository:k().min(1).optional(),resolutions:P(O({path:k().min(1),local:Qe.nullable(),incoming:Qe.nullable(),choice:B(["local","release"])})).optional()}),W="llm/harness/workspace.json";var mu=new Set([".agents/skills/apptoolkit/SKILL.md",".agents/skills/apptoolkit/agents/openai.yaml",".claude/skills/apptoolkit/SKILL.md",".opencode/commands/apptoolkit.md",".opencode/opencode.json",".opencode/opencode.jsonc","AGENTS.md","AGENTS.override.md","CLAUDE.md",".claude/rules/apptoolkit.md","opencode.json","opencode.jsonc","llm/harness-local/opencode-instructions.md"]);function Ao(e,t){if(e.startsWith("llm/harness/")||e.startsWith("llm/author-style/")||mu.has(e))return e!==W&&e!=="llm/harness/project.json";if(e==="llm/HARNESS.md"||e==="llm/README.md")return!0;return t.some((r)=>e===et(r.path)||r.path!=="."&&[...mu].some((o)=>e===`${r.path}/${o}`))}function et(e){if(e===".")return"llm/harness-context.llm.md";return`${e}/llm/harness-context.llm.md`}function ee(e){let t=ge(e),r=R(t,W);if(!r)return;try{let o=hu.parse(JSON.parse(r.bytes.toString("utf8"))),n=new Set,s=new Set;for(let i of o.repositories){if(i.path!==".")oe(i.path);if(n.has(i.path))throw Error(`Repeated repository path ${i.path}.`);n.add(i.path)}for(let i of o.files){if(oe(i.path),!Ao(i.path,o.repositories)||s.has(i.path))throw Error(`Unexpected managed file ${i.path}.`);s.add(i.path)}return o}catch(o){throw Error(`Cannot read the installation receipt at ${yd(t,W)}. Restore a valid receipt before retrying.`,{cause:o})}}var ue=k().trim().min(1).max(120).regex(/^[\p{L}\p{N}][\p{L}\p{N} ./_:+-]*$/u),yu=k().regex(/^[A-Z_][A-Z0-9_]*$/).max(120),xe=k().min(1).max(512).refine((e)=>{if(/^[A-Za-z]:|[\\\u0000-\u001f\u007f]/u.test(e))return!1;return e.split("/").every((t)=>t!==""&&t!=="."&&t!==".."&&t!==".git")},"Use a workspace-relative path without traversal."),Se=ur([K("."),xe]),tt=B(["plane","penpot"]),xd=new Set(["localhost","127.0.0.1","[::1]"]),Io=Vl().max(512).pipe(k().refine((e)=>{let t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:"&&xd.has(t.hostname))&&!t.username&&!t.password&&!t.search&&!t.hash},"Use HTTPS or loopback HTTP without credentials, query, or fragment.")),gu={baseUrl:Io,tokenEnv:yu,snapshots:B(["off","versioned"])},vd=ko("provider",[O({...gu,provider:K("plane"),workspace:k().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,119}$/),projectId:bo(),auth:B(["api-key","oauth"]).default("api-key")}),O({...gu,provider:K("penpot"),fileId:bo()})]),wd=B(["project","agent-only"]),bd=ko("mode",[O({mode:K("unlimited")}),O({mode:K("limited"),limits:P(O({category:ue,maximum:ar().positive(),unit:ue})).min(1).max(12)})]),_d=O({category:ue,scope:ue,authority:ue,provider:ue,access:ko("method",[O({method:K("local"),path:xe}),O({method:K("cli"),command:ue}),O({method:K("mcp"),server:ue}),O({method:K("api"),baseUrl:Io,tokenEnv:yu.optional()}),O({method:K("web"),baseUrl:Io})])}),kd=O({kind:ue,template:xe.optional(),requiredSections:P(ue).max(30),checklist:P(k().trim().min(1).max(200)).max(30),prohibitedText:P(k().trim().min(1).max(120)).max(30)}),$d=O({path:Se,budget:bd,biome:wd.optional(),rules:P(xe).max(50),routes:P(_d).max(50),documentation:P(kd).max(50),services:P(vd).max(2)}).superRefine((e,t)=>{let r=new Set;for(let[n,s]of e.routes.entries()){let i=`${s.category.toLowerCase()}
|
|
64
|
+
${s.scope.toLowerCase()}`;if(r.has(i))t.addIssue({code:"custom",path:["routes",n],message:"Choose one authority for this category and scope."});r.add(i)}let o=new Set;for(let[n,s]of e.services.entries()){if(o.has(s.provider))t.addIssue({code:"custom",path:["services",n],message:"Configure each built-in service once per project."});o.add(s.provider)}}),Ne=O({schema:K(1),projects:P($d).min(1).max(100)}).superRefine((e,t)=>{let r=new Set;for(let[o,n]of e.projects.entries()){if(r.has(n.path))t.addIssue({code:"custom",path:["projects",o,"path"],message:"Each project must appear once."});r.add(n.path)}});var No="llm/harness/project.json",Ad=1048576;function ve(e){try{return zd(e)}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return;throw Error(`Inspect ${e}.`,{cause:t})}}function we(e){let t=ve(e);if(!t?.isFile()||t.size>Ad)throw Error(`Expected a regular JSON file of at most 1 MiB at ${e}.`);try{return JSON.parse(Pd(e,"utf8"))}catch(r){throw Error(`Read JSON configuration at ${e}.`,{cause:r})}}function wu(e){let t=e;for(let r of["llm","harness"])if(t=rt(t,r),!ve(t)?.isDirectory())throw Error(`Expected an installed, nonsymlink workspace directory at ${t}.`);return t}function Te(e){let t=xu(vu(e));wu(t);let r=ee(t);if(!r)throw Error("Install the harness in the selected workspace before configuring it.");return{root:t,receipt:r}}function bu(e,t){if(wu(e),!ve(t))return;let r=Ne.safeParse(we(t));if(!r.success){let o=r.error.issues.map((n)=>`${n.path.join(".")||"settings"} ${n.message}`);throw Error(`Invalid project settings in ${t}. ${o.join(" ")}`)}return r.data}function De(e){return bu(e,rt(e,No))}function Id(e,t,r){if(r)return{...r,biome:r.biome??null};let o=rt(e,t),n=[];if(ve(o)?.isDirectory()&&xu(o)===o){for(let s of["AGENTS.md","CLAUDE.md","CONTRIBUTING.md"])if(ve(rt(o,s))?.isFile())n.push(s)}return{path:t,budget:null,biome:null,rules:n,routes:[],documentation:[],services:[]}}function To(e){let{root:t,receipt:r}=Te(e),o=De(t),n=new Set([".",...r.repositories.map((s)=>s.path)]);return{schema:1,...r.bootstrapNotices?.length?{bootstrapNotices:r.bootstrapNotices}:{},projects:[...n].map((s)=>{let i=o?.projects.find((c)=>c.path===s);return Id(t,s,i)})}}function jo(e){return`${JSON.stringify(e,null,2)}
|
|
65
|
+
`}function jd(e,t){let r=Rd(e),o=rt(r,`.project.${Sd()}.json`);try{Zd(o,jo(t),{flag:"wx",mode:384}),Ed(o,e)}catch(n){try{Od(o,{force:!0})}catch(s){throw AggregateError([n,s],`Write project settings and clean the draft at ${e}.`)}throw Error(`Write project settings at ${e}.`,{cause:n})}}async function Do(e){let{root:t}=Te(e.root),r=bu(t,vu(e.configPath));if(!r)throw Error("Provide the approved project settings JSON file.");return pu(t,()=>{let{receipt:o}=Te(t),n=new Set([".",...o.repositories.map((u)=>u.path)]);for(let u of r.projects){if(!n.has(u.path))throw Error(`Register ${u.path} before initializing its settings.`);if(!u.biome)throw Error(`Choose project or agent-only Biome scope for project "${u.path}".`);for(let p of u.services){if(!o.services.includes(p.provider))throw Error(`Select ${p.provider} during workspace installation before connecting it.`);if(p.snapshots==="versioned"&&!o.workspaceVersioned)throw Error("Versioned service snapshots require a versioned workspace harness.")}}let s=rt(t,No);if(!o.workspaceVersioned){let u=J(t);if(u)hr({git:u,path:Cd(u.root,s)},!1)}let i=De(t),c=new Map(i?.projects.map((u)=>[u.path,u]));for(let u of r.projects)c.set(u.path,u);let a=Ne.parse({schema:1,projects:[...c.values()]});if(i&&jo(i)===jo(a))return{path:s,changed:!1,projects:a.projects.length};return jd(s,a),{path:s,changed:!0,projects:a.projects.length}})}var Nd=O({root:k().min(1),project:Se,service:tt,verifyHealth:Ae().optional(),verifyRead:Ae()}),Td=me({results:P(me({id:bo()})).max(1)}),Dd=me({name:k().min(1)}),Fd=131072;class ze extends Error{}function Lo(e){let{root:t,receipt:r}=Te(e.root);if(!r.services.includes(e.service))throw Error(`${e.service} is not selected in the installed workspace.`);if(e.project!=="."&&!r.repositories.some((s)=>s.path===e.project))throw Error(`Register ${e.project} before using its service connections.`);let n=De(t)?.projects.find((s)=>s.path===e.project)?.services.find((s)=>s.provider===e.service);if(!n)throw Error(`Initialize the ${e.service} connection for ${e.project} first.`);return{root:t,receipt:r,connection:n}}function Fo(e,t){let r=new URL(e);if(!r.pathname.endsWith("/"))r.pathname+="/";return new URL(t,r)}function Ld(e){if(e.provider==="plane"){let r=`api/v1/workspaces/${e.workspace}/projects/${e.projectId}/work-items/`,o=Fo(e.baseUrl,r);return o.searchParams.set("per_page","1"),o.searchParams.set("fields","id"),o}let t=Fo(e.baseUrl,"api/rpc/command/get-file-summary");return t.searchParams.set("id",e.fileId),t}function Md(e,t){let r=new Headers({Accept:"application/json"});if(e.provider==="penpot")r.set("Authorization",`Token ${t}`);else if(e.auth==="oauth")r.set("Authorization",`Bearer ${t}`);else r.set("X-API-Key",t);return r}async function Wd(e){if(!e.headers.get("content-type")?.toLowerCase().startsWith("application/json"))throw await e.body?.cancel(),new ze("Expected an application/json response from the service.");let r=e.body?.getReader();if(!r)throw new ze("The service response has no body.");let o=[],n=0;try{for(;;){let s=await r.read();if(s.done)return Buffer.concat(o,n).toString("utf8");if(n+=s.value.byteLength,n>Fd)throw await r.cancel(),new ze("The service response exceeded the 128 KiB verification limit.");o.push(s.value)}}finally{r.releaseLock()}}async function Ud(e,t){let r=await t(Fo(e.baseUrl,"./"),{method:"HEAD",redirect:"manual",signal:AbortSignal.timeout(1e4)});return await r.body?.cancel(),r.status}async function Bd(e,t,r){let o=await r(Ld(e),{method:"GET",headers:Md(e,t),redirect:"error",signal:AbortSignal.timeout(1e4)});if(!o.ok)throw await o.body?.cancel(),new ze(`The selected resource returned HTTP ${o.status}. Confirm the target and its read permission.`);let n=await Wd(o),s=e.provider==="plane"?Td:Dd,i=!1;try{i=s.safeParse(JSON.parse(n)).success}catch(c){throw new ze("The service returned invalid JSON.",{cause:c})}if(!i)throw new ze("The response does not match the expected resource read.");return o.status}async function Mo(e,t={}){let r=Nd.parse(e),{connection:o}=Lo(r),s=(t.environment??process.env)[o.tokenEnv],i=typeof s==="string"&&/^[\x21-\x7e]+$/.test(s),c={provider:o.provider,project:r.project,baseUrl:o.baseUrl,credentialEnv:o.tokenEnv,credentialAvailable:i,snapshots:o.snapshots,connectivity:"unchecked",read:"unchecked"},a=t.fetch??fetch;if(r.verifyRead){if(!i)throw Error(`Provide ${o.tokenEnv} in the process environment before verifying access.`);try{let u=await Bd(o,s,a);return{...c,connectivity:"reachable",read:"verified",httpStatus:u}}catch(u){let p=u instanceof ze?u.message:"Check the configured host and retry.";throw Error(`Verify ${o.provider} read for ${r.project}. ${p}`,{cause:u})}}if(r.verifyHealth)try{let u=await Ud(o,a);return{...c,connectivity:u>=500?"service-error":"reachable",httpStatus:u}}catch(u){throw Error(`Check ${o.provider} connectivity for ${r.project}.`,{cause:u})}return c}import{createHash as Vd}from"node:crypto";import{constants as _u,createReadStream as Jd,openSync as Hd}from"node:fs";import{join as Kd,relative as ku,resolve as Gd}from"node:path";var $u=xe.refine((e)=>e.startsWith("harness-snapshots/"),{message:"Keep native service exports in the workspace harness-snapshots directory."}),qd=k().regex(/^[a-f0-9]{64}$/),Xd=O({path:$u,bytes:ar().int().positive(),sha256:qd}),Yd=O({root:k().min(1),project:Se,service:tt}),Su=O({schema:K(1),project:Se,service:tt,files:P(Xd).min(1).max(30)}).refine((e)=>new Set(e.files.map((t)=>t.path)).size===e.files.length,"Duplicate snapshot paths.");function zu(e,t){let r=Gd(e,t),o=$u.parse(ku(e,r)),n=e,s=o.split("/");for(let[i,c]of s.entries()){n=Kd(n,c);let a=ve(n);if(!(i===s.length-1?a?.isFile():a?.isDirectory()))throw Error(`Expected a regular nonsymlink snapshot path at ${n}.`)}return r}async function Pu(e,t){let r=zu(e,t),o=ve(r);if(!o?.isFile()||o.size===0)throw Error(`Expected a nonempty snapshot file at ${r}.`);let n=Vd("sha256");try{let i=Hd(r,_u.O_RDONLY|_u.O_NOFOLLOW),c=Jd(r,{fd:i});for await(let a of c)n.update(a)}catch(i){throw Error(`Read snapshot bytes at ${r}.`,{cause:i})}let s=ve(r);if(!s||o.dev!==s.dev||o.ino!==s.ino||o.mtimeMs!==s.mtimeMs||o.size!==s.size)throw Error(`Snapshot changed while reading ${r}. Retry with a stable export.`);return{path:ku(e,r),bytes:o.size,sha256:n.digest("hex")}}function Eu(e){let{root:t,receipt:r,connection:o}=Lo(Yd.parse(e));if(!r.workspaceVersioned||o.snapshots!=="versioned")throw Error("Enable versioned snapshots for this project and provider before working with a snapshot.");return t}async function Wo(e){let t=Eu({root:e.root,project:e.project,service:e.service}),r=P(k().min(1)).min(1).max(30).parse(e.paths),o=[];for(let n of r)o.push(await Pu(t,n));return Su.parse({schema:1,project:e.project,service:e.service,files:o})}async function Uo(e){let t=Eu({root:e.root,project:e.project,service:e.service}),r=zu(t,e.manifestPath),o=Su.parse(we(r));if(o.project!==e.project||o.service!==e.service)throw Error("The snapshot manifest belongs to a different project or service.");for(let n of o.files){let s=await Pu(t,n.path);if(s.bytes!==n.bytes||s.sha256!==n.sha256)throw Error(`Snapshot integrity check failed for ${n.path}.`)}return{manifestPath:r,project:o.project,service:o.service,files:o.files.length}}import{resolve as Bo}from"node:path";import{lstatSync as Qd,readdirSync as Zu}from"node:fs";import{basename as Ou,resolve as zt}from"node:path";var eh=me({name:k().optional(),workspaces:ur([P(k()),me({packages:P(k())})]).optional()}),th=new Set(["package.json","pnpm-workspace.yaml","Cargo.toml","go.mod","pyproject.toml","Gemfile","pom.xml","composer.json"]),Ru=new Set([".git",".DS_Store",".agents",".claude",".opencode","llm","node_modules","dist","vendor"]);function rh(e){let t=R(e,"package.json");if(!t)return;try{return eh.parse(JSON.parse(t.bytes.toString("utf8")))}catch(r){throw Error(`Cannot read ${zt(e,"package.json")}. Correct the manifest and retry.`,{cause:r})}}function Pe(e,t){if(t===".")return e;oe(t);let r=ge(zt(e,t));if(!Eo(e,r)||r!==zt(e,t))throw Error(`Choose a real directory inside ${e}. The repository path resolves through a symbolic link: ${t}.`);if(J(r)?.root!==r)throw Error(`Choose the Git repository root at ${r} before registering it.`);return r}function oh(e){let t=Zu(e,{withFileTypes:!0});if(t.length>2048)throw Error(`Workspace discovery is limited to 2048 entries at ${e}. Choose a narrower directory.`);let r=[];for(let o of t.sort((n,s)=>n.name.localeCompare(s.name,"en"))){if(!o.isDirectory()||o.name.startsWith(".")||Ru.has(o.name))continue;let n=zt(e,o.name);if(!Qd(zt(n,".git"),{throwIfNoEntry:!1}))continue;if(J(n)?.root!==n)throw Error(`The Git metadata in ${n} does not identify that checkout as a repository root.`);oe(o.name),r.push({path:o.name,name:o.name,gitRoot:n})}return r}function Fe(e){let t=ge(e),r=J(t),o=oh(t),n=new Set(Zu(t)),s=rh(t),i=Boolean(s?.workspaces||n.has("pnpm-workspace.yaml")||n.has("lerna.json")),c=[...th].some((l)=>n.has(l)),a=r?{gitRoot:r.root}:{};if(o.length&&!i){let l=[...o];if(c)l.unshift({path:".",name:s?.name??Ou(t),...a});return{root:t,kind:"workspace",monorepo:i,repositories:l,...a}}let u=[...n].every((l)=>Ru.has(l)),p={path:".",name:s?.name??Ou(t),...a};return{root:t,kind:u?"blank":"existing",monorepo:i,repositories:[p],...a}}var nh=B(["bun","npm","pnpm","yarn"]),sh=/^(bun|npm|pnpm|yarn)@[^\s]+$/u,ih=me({packageManager:k().regex(sh).optional()}),ch=me({devDependencies:me({"@biomejs/biome":k().regex(/^\d+\.\d+\.\d+$/u)})}),ah=me({root:K(!0),formatter:_t(k(),pr()),javascript:_t(k(),pr()),assist:_t(k(),pr()),linter:_t(k(),pr())}),uh=[{manager:"bun",names:["bun.lock","bun.lockb"]},{manager:"npm",names:["package-lock.json","npm-shrinkwrap.json"]},{manager:"pnpm",names:["pnpm-lock.yaml"]},{manager:"yarn",names:["yarn.lock"]}];function Cu(e,t){let r=Se.parse(t),{root:o,receipt:n}=Te(e);if(r!=="."&&!n.repositories.some(({path:x})=>x===r))throw Error(`Register ${r} before planning its Biome setup.`);let s=Pe(o,r),i=["biome.json","biome.jsonc"].filter((x)=>Boolean(R(s,x))),c=i[0];if(i.length>1)throw Error(`Choose the authoritative Biome configuration in ${s} before adopting changes.`);if(c)return{directory:s,existing:c};if(!R(s,"package.json"))throw Error(`Expected package.json in ${s}. Select the applicable code project or its isolated check.`);let{packageManager:a}=ih.parse(we(Bo(s,"package.json"))),u=uh.filter(({names:x})=>x.some((w)=>Boolean(R(s,w)))),p=a?.split("@")[0],l=p??u[0]?.manager??"bun";if(u.length>1||p&&u.length&&u[0]?.manager!==p)throw Error(`Confirm the project's package manager in ${s}. Declare it in package.json or use its existing lockfile.`);let f=nh.parse(l),h=ch.parse(we(Bo(o,"llm/author-style/package.json"))).devDependencies["@biomejs/biome"],d=ah.parse(we(Bo(o,"llm/author-style/biome-core.json"))),m=`@biomejs/biome@${h}`;return{directory:s,install:f==="npm"?["npm","install","--save-dev","--save-exact",m]:[f,"add","--dev","--exact",m],path:"biome.json",config:d}}import{closeSync as Au,constants as Vo,fstatSync as Iu,lstatSync as ju,openSync as ph,readSync as lh,realpathSync as fh}from"node:fs";import{isAbsolute as Tu,join as dh}from"node:path";var hh=262144,mh=new Set([".aws",".git",".gnupg",".npm",".ssh","credentials","node_modules","passwords","private","processing","raw","secret","secrets"]);function Du(e){let t=e.toLowerCase(),r=t.replace(/(?:\.llm)?\.md$/,"");return t.startsWith(".env")||mh.has(r)}function gh(e){if(Tu(e)||/[\\:\x00-\x1f\x7f]/.test(e))throw Error("Provide a relative path inside the project root.");let t=e.split("/");for(let r of t){if(r===""||r==="."||r==="..")throw Error("Paths must use explicit project-relative segments.");if(Du(r))throw Error(`The path crosses a protected location at "${r}".`)}return t}function Nu(e,t){if(!Tu(e))throw Error("Provide an absolute project root.");if(!ju(e).isDirectory())throw Error("The project root must be a directory.");let r=fh(e);if(r.split("/").filter(Boolean).some((s,i)=>(i!==0||s!=="private")&&Du(s)))throw Error("The project root crosses a protected location.");let n;for(let[s,i]of t.entries()){if(r=dh(r,i),n=ju(r),n.isSymbolicLink())throw Error(`Symbolic links are not allowed in the project path at "${i}".`);if(s<t.length-1&&!n.isDirectory())throw Error(`Expected a directory at "${i}".`)}if(!n?.isFile())throw Error("The project path must resolve to a regular file.");return{path:r,info:n}}function yh(e,t,r,o){let n=Iu(e);if(!n.isFile()||n.ino!==t.ino||n.dev!==t.dev)throw Error("The file changed while opening. Retry after checking its path.");if(n.size>r)throw Error(`${o} source exceeds ${r} bytes. Use a narrower input.`);let s=Buffer.alloc(n.size+1),i=0;while(i<s.length){let a=lh(e,s,i,s.length-i,i);if(a===0)break;i+=a}if(i>r)throw Error(`${o} source exceeds ${r} bytes. Use a narrower input.`);let c=Iu(e);if(c.size!==i||n.size!==c.size||n.mtimeMs!==c.mtimeMs||n.ctimeMs!==c.ctimeMs)throw Error("The source changed during the read. Retry with a stable file.");return s.subarray(0,i)}function xh(e,t,r,o){let n;try{n=yh(e,t,r,o)}catch(s){try{Au(e)}catch(i){throw AggregateError([s,i],"Reading and closing the file both failed.")}throw s}return Au(e),n}function ot(e,t,r,o){try{let n=gh(t),{path:s,info:i}=Nu(e,n),c=ph(s,Vo.O_RDONLY|Vo.O_NOFOLLOW|Vo.O_NONBLOCK),a=xh(c,i,r,o),u=Nu(e,n);if(u.path!==s||u.info.ino!==i.ino||u.info.dev!==i.dev)throw Error("The file path changed during the read. Retry after verifying the current path.");return new TextDecoder("utf-8",{fatal:!0}).decode(a)}catch(n){let s=n instanceof Error?n.message:String(n);throw Error(`Unable to read ${o} "${t}". ${s}`,{cause:n})}}function Le(e,t){if(!t.toLowerCase().endsWith(".md"))throw Error("Provide a relative Markdown path inside the project root.");return ot(e,t,hh,"Markdown context")}function Fu(e){return e.match(/[^\n]*\n|[^\n]+$/g)??[]}function Lu(e,t,r){let o=e.toLowerCase().replace(/[^\p{L}\p{M}\p{N}_\s-]/gu,"").trim().replace(/\s+/g,"-");return{title:e,level:t,line:r,locator:`line:${r}`,anchor:`#${o}`}}function vh(e){let t=/^ {0,3}(`{3,}|~{3,})/.exec(e)?.[1];if(t)return{marker:t.charAt(0),length:t.length};return}function wh(e,t){let r=/^ {0,3}(`{3,}|~{3,})[ \t]*$/.exec(e)?.[1];return r!==void 0&&r.startsWith(t.marker)&&r.length>=t.length}function bh(e,t){let r=/^ {0,3}(#{1,6})[ \t]+(.*)$/.exec(e),o=r?.[1],n=r?.[2];if(o&&n){let s=n.replace(/(?:^|[ \t]+)#+[ \t]*$/,"").trim();if(s)return Lu(s,o.length,t)}return}function _h(e){if(!e.trim()||/^(?: {4}|\t)/.test(e))return!1;return!/^ {0,3}(?:[>#<]|[-+*][ \t]|\d+[.)][ \t]|\[[^\]]+\]:|(?:[*_-][ \t]*){3,})/.test(e)}function Mu(e){let t=[],r,o,n=!1,s=-1;if(e[0]?.trim()==="---")s=e.findIndex((i,c)=>c>0&&/^(---|\.\.\.)$/.test(i.trim()));for(let[i,c]of e.entries()){if(i<=s)continue;let a=c.replace(/\r?\n$/,""),u=i+1;if(r){if(wh(a,r))r=void 0;continue}if(n||a.trimStart().startsWith("<!--")){n=!a.includes("-->"),o=void 0;continue}if(r=vh(a),r){o=void 0;continue}let p=bh(a,u);if(p){t.push(p),o=void 0;continue}let l=/^ {0,3}(=+|-+)[ \t]*$/.exec(a)?.[1];if(l&&o){let f=o.lines.join(" "),h=l.startsWith("=")?1:2;t.push(Lu(f,h,o.line)),o=void 0;continue}if(!_h(a)){o=void 0;continue}if(!o)o={line:u,lines:[]};o.lines.push(a.trim())}return t}var Jo=k().min(1).refine((e)=>!/[\x00-\x1f\x7f]/.test(e),"Control characters are not allowed."),kh=O({root:Jo.max(4096),file:Jo.max(4096),section:Jo.max(512).optional()}),Wu=128,Uu=16384;function $h(e,t){let r=e.filter((n)=>{if(/^line:[1-9][0-9]*$/.test(t))return n.locator===t;if(t.startsWith("#"))return n.anchor===t;return n.title===t}),[o]=r;if(!o)throw Error(`No heading matches "${t}". List the heading index and use an exact locator.`);if(r.length>1){let n=r.slice(0,8).map((i)=>i.locator),s=r.length>n.length?", or another locator from the index":"";throw Error(`Heading "${t}" is ambiguous. Use one of ${n.join(", ")}${s}.`)}return o}function Bu(e,t){if(Buffer.byteLength(e)>Uu)throw Error(`Context output exceeds ${Uu} bytes. ${t}`)}function Vu(e){let t=kh.parse(e),r=Fu(Le(t.root,t.file)),o=Mu(r);if(t.section===void 0){if(o.length>Wu)throw Error(`Heading index exceeds ${Wu} entries. Request a known section or use a narrower map.`);let u={kind:"index",file:t.file,headings:o};return Bu(JSON.stringify(u),"Request a known section or use a narrower map."),u}let n=$h(o,t.section),s=o.find((u)=>u.line>n.line&&u.level<=n.level),i=s?s.line-1:r.length,c=r.slice(n.line-1,i).join(""),a={kind:"section",file:t.file,heading:n,startLine:n.line,endLine:i,text:c};return Bu(JSON.stringify(a),"Choose a smaller child section or a narrower map."),a}import{realpathSync as Ch}from"node:fs";import{isAbsolute as Go,normalize as Ah,relative as Ih,resolve as jh}from"node:path";var Hu=B(["lines","functions","branches"]),Sh=B(["LF","LH","FNF","FNH","BRF","BRH"]),zh={lines:{found:"LF",hit:"LH"},functions:{found:"FNF",hit:"FNH"},branches:{found:"BRF",hit:"BRH"}};function Ku(e){return{source:e,summaries:new Map,lines:new Map,branches:new Map,functionNames:new Set,functionHits:new Map,groupIds:new Set,aliasHits:new Map,versionSeen:!1}}function M(e,t){let r=Number(e);if(!/^\d+$/.test(e)||!Number.isSafeInteger(r)||r<t)throw Error("Expected an integer within the supported range.");return r}function Pt(e,t,r){if(e.has(t))throw Error("Duplicate coverage entry.");e.set(t,r)}function Ju(e,t){if(e.has(t))throw Error("Duplicate coverage identity.");e.add(t)}function Ph(e,t){let[r,o,,n,s]=t.split(",");if(!r||!o||s!==void 0)throw Error("Expected a line number and execution count.");let i=M(r,1);if(n!==void 0)M(n,i);Pt(e.lines,String(i),M(o,0)>0)}function Eh(e,t){let r=/^([^,]+),([ef]?u?\d+(?:\^\d+)?),(.+),([^,]+)$/.exec(t),o=r?.[1],n=r?.[2],s=r?.[3],i=r?.[4];if(!o||!n||!s||!i)throw Error("Expected a branch line, block, identity and hit count.");let[,c,a]=/^[ef]?u?(\d+)(?:\^(\d+))?$/.exec(n)??[];if(!c)throw Error("Expected a numeric branch block.");let u=JSON.stringify([M(o,1),M(c,0),a===void 0?null:M(a,0),/^\d+$/.test(s)?M(s,0):s]);Pt(e.branches,u,i!=="-"&&M(i,0)>0)}function Oh(e,t,r){let o=t==="FN"?/^(\d+),(?:(\d+),)?(.+)$/:/^(\d+),(\d+)(?:,(\d+))?$/,[,n,s,i]=o.exec(r)??[];if(n===void 0)throw Error("Malformed function definition.");if(t==="FN"&&i){let c=M(n,1);if(s)M(s,c);Ju(e.functionNames,i);return}if(t==="FNL"&&s){let c=M(s,1);if(i)M(i,c);Ju(e.groupIds,String(M(n,0)));return}throw Error("Malformed function definition.")}function Zh(e,t,r){if(t==="FNDA"){let[,a,u]=/^(\d+),(.+)$/.exec(r)??[];if(!a||!u)throw Error("Expected a function hit count and name.");Pt(e.functionHits,u,M(a,0)>0);return}let[,o,n,s]=/^(\d+),(\d+),(.+)$/.exec(r)??[];if(!o||!n||!s)throw Error("Expected an alias group, hit count and name.");let i=String(M(o,0)),c=e.aliasHits.get(i)??new Map;Pt(c,s,M(n,0)>0),e.aliasHits.set(i,c)}function Gu(e,t,r){let o=Sh.safeParse(t);if(o.success){Pt(e.summaries,o.data,M(r,0));return}switch(t){case"VER":if(e.versionSeen||!r)throw Error("Expected one source version per record.");e.versionSeen=!0;return;case"DA":return Ph(e,r);case"BRDA":return Eh(e,r);case"FN":case"FNL":return Oh(e,t,r);case"FNDA":case"FNA":return Zh(e,t,r);default:throw Error("Unsupported LCOV field. Export a line, function and branch report.")}}function Ho(e){let t=0;for(let r of e.values())if(r)t+=1;return{found:e.size,hit:t}}function Rh(e){let t=e.functionNames.size>0||e.functionHits.size>0,r=e.groupIds.size>0||e.aliasHits.size>0;if(t&&r)throw Error("Function records mix classic names and alias groups.");if(r){let o=0;if(e.groupIds.size!==e.aliasHits.size)throw Error("Missing function group or alias records.");for(let n of e.groupIds){let s=e.aliasHits.get(n);if(!s?.size)throw Error("Function group is missing execution records.");if(Array.from(s.values()).some(Boolean))o+=1}return{found:e.groupIds.size,hit:o}}if(e.functionNames.size!==e.functionHits.size)throw Error("Missing function names or execution records.");for(let o of e.functionNames)if(!e.functionHits.has(o))throw Error("A function definition has no matching execution record.");return Ho(e.functionHits)}function qu(e,t){let r=zh[t],o=e.summaries.get(r.found),n=e.summaries.get(r.hit);if(o===void 0||n===void 0)throw Error(`Missing ${r.found} or ${r.hit} summary.`);let s;switch(t){case"lines":s=Ho(e.lines);break;case"functions":s=Rh(e);break;case"branches":s=Ho(e.branches);break}if(s.found!==o||s.hit!==n)throw Error(`Summary ${n}/${o} differs from measured entries ${s.hit}/${s.found}.`);if(n!==o)throw Error(`Only ${n}/${o} were covered. The requirement is 100 percent.`);return s}var gr=k().min(1).max(4096).refine((e)=>!/[\x00-\x1f\x7f]/.test(e)),Nh=O({root:gr,file:gr,config:gr}),Th=O({files:P(gr).min(1).max(1e4),metrics:P(Hu).min(1).max(3)});function Ko(e){if(Go(e)||/[\\:\x00-\x1f\x7f]/.test(e)||e.split("/").some((t)=>!t||t==="."||t===".."))throw Error(`Use a project-relative source path in the coverage configuration. Received "${e}".`);return e}function Xu(e,t){let r=Ih(e,t);if(!r||r===".."||r.startsWith("../")||Go(r))return;return r}function Dh(e,t,r){if(!e||/[\\:\x00-\x1f\x7f]/.test(e))throw Error("Expected a valid source path in the LCOV record.");if(Go(e)){let o=Xu(t,e)??Xu(r,e);if(o)return Ko(o);throw Error("An LCOV source is outside the project root.")}return Ko(Ah(e))}function Fh(e,t){for(let[r,o]of t)try{let n=qu(e,r);o.found+=n.found,o.hit+=n.hit}catch(n){let s=n instanceof Error?n.message:String(n);throw Error(`${e.source} ${r}. ${s}`,{cause:n})}}function Lh(e,t,r,o){let n=Ch(t),s=new Set,i=new Set,c,a=!1;for(let[p,l]of e.split(/\r?\n/).entries()){if(!l.trim()||l.startsWith("#"))continue;try{if(/[\x00-\x08\x0b-\x1f\x7f]/.test(l))throw Error("Control characters are not allowed in coverage records.");if(l.startsWith("TN:")&&!c&&!a)a=!0;else if((l.startsWith("SF:")||l.startsWith("KF:"))&&!c){let f=l.slice(3),[,h,d]=/^(\d+),(.*)$/.exec(f)??[],m=Dh(d??f,t,n);if(h!==void 0){let y=Number(h);if(!Number.isSafeInteger(y)||i.has(y))throw Error("Expected a distinct safe integer source index.");i.add(y)}if(s.has(m))throw Error(`Duplicate LCOV source "${m}".`);if(!r.has(m))throw Error(`Unexpected LCOV source "${m}".`);c=Ku(m),a=!1}else if(l==="end_of_record"&&c)Fh(c,o),s.add(c.source),c=void 0;else if(c){let f=l.indexOf(":");if(f<1)throw Error("Malformed LCOV field.");Gu(c,l.slice(0,f),l.slice(f+1))}else throw Error("Expected an LCOV source record.")}catch(f){let h=f instanceof Error?f.message:String(f);throw Error(`LCOV line ${p+1}. ${h}`,{cause:f})}}if(c||a)throw Error("The final LCOV record is incomplete.");let u=Array.from(r).filter((p)=>!s.has(p));if(u.length)throw Error(`LCOV is missing ${u.length} expected source files. First missing path is "${u[0]}".`)}function Yu(e){let t=Nh.parse(e),r=ot(t.root,t.config,262144,"coverage configuration"),o;try{o=Th.parse(JSON.parse(r))}catch(a){throw Error(`Invalid coverage configuration "${t.config}". Provide JSON arrays for files and metrics.`,{cause:a})}let n=new Set(o.files.map(Ko)),s=new Map;for(let a of o.metrics)s.set(a,{found:0,hit:0});if(n.size!==o.files.length||s.size!==o.metrics.length)throw Error("Coverage configuration contains duplicate files or metrics.");let i=ot(t.root,t.file,16777216,"LCOV report");Lh(i,jh(t.root),n,s);let c=Array.from(s,([a,u])=>{if(u.found===0)throw Error(`No measurable ${a} were found for the selected scope.`);return{metric:a,...u,percent:100}});return{file:t.file,config:t.config,sources:n.size,metrics:c}}import{lstatSync as Mh}from"node:fs";import{resolve as Wh}from"node:path";var Uh=O({root:k().min(1),threshold:ar().int().nonnegative(),files:P(xe).max(200),important:P(xe).max(200)});function Qu(e){let{root:t,threshold:r,files:o,important:n}=Uh.parse(e),s=new Set(n),i=[...new Set([...o,...n])].sort();if(!i.length)throw Error("Supply a changed implementation with --file or --important.");return i.map((c)=>{let a=ot(t,c,1048576,"authored implementation"),u=a.length?a.replace(/(?:\r\n|\r|\n)$/u,"").split(/\r\n|\r|\n/u).length:0,p=`${c}.llm.md`,l=Mh(Wh(t,p),{throwIfNoEntry:!1});if(l)Le(t,p);return{file:c,lines:u,map:p,exists:Boolean(l),required:s.has(c)||u>r}})}import{lstatSync as dp}from"node:fs";import{relative as fp,resolve as Ee}from"node:path";import{lstatSync as rp}from"node:fs";import{resolve as nt}from"node:path";function Bh(e,t,r,o=!1){let n=`# appToolkit harness ${t} begin`,s=`# appToolkit harness ${t} end`,i=e.includes(`\r
|
|
64
66
|
`)?`\r
|
|
65
67
|
`:`
|
|
66
|
-
`,c=e.split(i),a=c.indexOf(n),u=c.indexOf(s);if(a===-1!==(u===-1)||a!==-1&&u<=a||c.lastIndexOf(n)!==a||c.lastIndexOf(s)!==u)throw Error(`The existing appToolkit local exclusion block ${t} is malformed. Repair it before retrying.`);let p=new Set(r);if(o&&a!==-1)for(let
|
|
67
|
-
`,i.mode);return{base:e,path:
|
|
68
|
+
`,c=e.split(i),a=c.indexOf(n),u=c.indexOf(s);if(a===-1!==(u===-1)||a!==-1&&u<=a||c.lastIndexOf(n)!==a||c.lastIndexOf(s)!==u)throw Error(`The existing appToolkit local exclusion block ${t} is malformed. Repair it before retrying.`);let p=new Set(r);if(o&&a!==-1)for(let h of c.slice(a+1,u)){if(!h.startsWith("/"))throw Error(`The existing appToolkit local exclusion block ${t} contains an unsupported pattern.`);p.add(h)}let l=p.size?[n,...[...p].sort(),s]:[];if(a!==-1)return c.splice(a,u-a+1,...l),c.join(i);if(!l.length)return e;return`${e&&!e.endsWith(i)?`${e}${i}`:e}${l.join(i)}${i}`}function qo(e,t,r,o=!1){let n=R(e.commonDirectory,e.exclude),s=n?.bytes.toString("utf8")??"";if(n&&!Buffer.from(s).equals(n.bytes))throw Error(`Cannot update the non-UTF-8 local exclusions at ${nt(e.commonDirectory,e.exclude)}.`);let i=Bh(s,t,r,o),c=i||n?T(i,n?.mode):null;if(ae(n,c))return;return{base:e.commonDirectory,path:e.exclude,before:n,after:c}}function ep(e,t){let r=new Map,o=J(e);if(o)r.set(".",o);for(let n of t){if(n.path===".")continue;let s=nt(e,n.path);if(!rp(s,{throwIfNoEntry:!1})?.isDirectory())continue;let c=J(s);if(c?.root===s)r.set(n.path,c)}return r}function tp(e,t){let r=[...t.keys()].filter((n)=>n!=="."&&e.startsWith(`${n}/`));r.sort((n,s)=>s.length-n.length);let o=r[0]??".";return t.get(o)}function op(e,t,r,o,n,s){let i=ep(e,t.repositories),c=new Map,a=[],u=[];if(r){let m=ep(e,r.repositories);for(let y of m.values())c.set(y.commonDirectory,{scope:y,patterns:new Set});for(let y of n){let x=nt(e,y),w=tp(y,m);je(x,w?.root),u.push(w?{absolute:x,gitRoot:w.root}:{absolute:x})}}let p=[...t.files,...s.map((m)=>({path:m,versioned:!1})),{path:"llm/harness/workspace.json",versioned:t.workspaceVersioned},{path:"llm/harness/project.json",versioned:t.workspaceVersioned}];if(!t.workspaceVersioned)for(let m of["KNOWLEDGE.md","TOOLS.md","IMPROVEMENTS.md"])p.push({path:`llm/harness-local/${m}`,versioned:!1});let l=t.repositories.filter(({path:m})=>!rp(nt(e,m),{throwIfNoEntry:!1}));for(let m of p){if(l.some(({path:I})=>m.path.startsWith(`${I}/`)))continue;let y=tp(m.path,i),x=nt(e,m.path);if(je(x,y?.root),u.push(y?{absolute:x,gitRoot:y.root}:{absolute:x}),!y)continue;let w=ye(y.root,x);if(a.push({git:y,path:w,absolute:x,versioned:m.versioned}),m.versioned)continue;if(Ye(y,x)){o.push({path:m.path,reason:"Git already tracks this file. Choose versioned mode or separately remove it from the index before retrying."});continue}let S=c.get(y.commonDirectory)??{scope:y,patterns:new Set};S.patterns.add(St(w)),c.set(y.commonDirectory,S)}let f=i.get(".");if(f){let m=t.workspaceVersioned?"llm/harness-local/update-history":"llm/harness-local",y=ye(f.root,nt(e,m)),x=c.get(f.commonDirectory)??{scope:f,patterns:new Set};x.patterns.add(`${St(y)}/`),c.set(f.commonDirectory,x)}let h=[],d=t.installation??V(e).slice(0,16);for(let{scope:m,patterns:y}of c.values()){let x=qo(m,d,y);if(x)h.push(x)}return{operations:h,checks:a,boundaries:u}}import{lstatSync as Vh,readdirSync as Jh}from"node:fs";import{resolve as np}from"node:path";var sp=4096,Hh=67108864,Kh=new Set([".git","node_modules","raw","processing",".npmrc"]);function ip(e){if(!e)throw Error("The release content directory is required for install and update.");let t=ge(e),r=new Map,o=["."],n=0;while(o.length){let s=o.pop();if(!s)break;let i=Jh(np(t,s),{withFileTypes:!0});for(let c of i.sort((a,u)=>a.name.localeCompare(u.name,"en"))){let a=s==="."?c.name:`${s}/${c.name}`;if(oe(a),Kh.has(c.name)||/^\.env(?:$|\.(?!example$))/u.test(c.name))throw Error(`The release payload includes an unsupported private path: ${a}.`);if(c.isDirectory()&&!Vh(np(t,a)).isSymbolicLink()){if(o.length+r.size>=sp||a.split("/").length>12)throw Error(`Release content exceeds the directory limits at ${a}.`);o.push(a);continue}let u=`llm/${a}`;if(!c.isFile()||u.startsWith("llm/harness-local/")||!Ao(u,[]))throw Error(`The release payload includes an unsupported file: ${a}.`);let p=R(t,a);if(!p)throw Error(`The release payload changed while reading ${a}.`);if(n+=p.bytes.length,r.size>=sp||n>Hh)throw Error(`The release payload exceeds the installation limits at ${a}.`);r.set(u,p)}}if(!r.has("llm/HARNESS.md"))throw Error("The release payload is missing the harness index HARNESS.md.");return r}var yr="llm/harness/project.json";function cp(e,t,r,o){let n=t.repositories.find((c)=>!r.repositories.some((a)=>a.path===c.path));if(!n)return;let s=r.repositories.find((c)=>c.identity&&c.identity===n.identity);if(!s)return;let i=R(e,yr);if(!i)return;try{let c=Ne.parse(JSON.parse(i.bytes.toString("utf8")));if(!c.projects.some((p)=>p.path===n.path))return;if(c.projects.some((p)=>p.path===s.path)){o.push({path:yr,reason:"Both the old and new checkout paths already have project settings. Reconcile them before registering the move."});return}let a=c.projects.map((p)=>{if(p.path===n.path)return{...p,path:s.path};return p}),u=T(`${JSON.stringify(Ne.parse({...c,projects:a}),null,2)}
|
|
69
|
+
`,i.mode);return{base:e,path:yr,before:i,after:u}}catch(c){throw Error(`Cannot reassign the project settings in ${yr}. Restore a valid settings file before retrying.`,{cause:c})}}import{lstatSync as Xo}from"node:fs";import{basename as Gh,relative as qh,resolve as Et}from"node:path";var Yo="<!-- apptoolkit-harness:begin -->",xr="<!-- apptoolkit-harness:end -->";function vr(e){return["AGENTS.md","AGENTS.override.md","CLAUDE.md","opencode.json","opencode.jsonc","opencode-instructions.md"].includes(Gh(e))||e===".claude/rules/apptoolkit.md"||e.endsWith("/.claude/rules/apptoolkit.md")}function Xh(e,t){let r=e.indexOf(Yo),o=e.indexOf(xr);if(r===-1&&o===-1)return;if(r<0||o<=r||e.lastIndexOf(Yo)!==r||e.lastIndexOf(xr)!==o)throw Error(`The AppToolkit router block in ${t} is malformed. Review its markers before retrying.`);let n=o+xr.length;return{prefix:e.slice(0,r),old:e.slice(r,n),suffix:e.slice(n)}}function Yh(e,t,r,o,n,s,i,c){let a;try{a=R(e,t)}catch(S){if(!(S instanceof fr))throw S;i.push(`Automatic discovery needs a regular native instructions file at ${t}. Preserved the existing path.`);return}let u=a?.bytes.toString("utf8")??"",p=n?.files.find((S)=>S.path===t)?.fragment,l=u.includes(`\r
|
|
68
70
|
`)?`\r
|
|
69
71
|
`:`
|
|
70
|
-
`,
|
|
71
|
-
`,
|
|
72
|
-
|
|
72
|
+
`,f=[Yo,r.trimEnd().replaceAll(`
|
|
73
|
+
`,l),xr].join(l),h=V(f);if(a&&!Buffer.from(u).equals(a.bytes)){s.push({path:t,reason:"The native project instructions are not UTF-8. Open the harness explicitly from the agent instead."});return}let d=Xh(u,t),m=d?V(d.old):null,y=c?.find((S)=>S.path===t&&S.local===m&&S.incoming===h),x=n?.files.find((S)=>S.path===t)?.retainedAgainst;if(!d&&a&&(x===h||y?.choice==="local"))return{content:a,versioned:o,observed:a,retainedAgainst:h};if((p||x)&&!d&&y?.choice!=="release"){s.push({path:t,reason:"The previously installed router block was removed. Restore or reconcile it before updating.",local:m,incoming:h});return}if(d){let S=m!==h&&(m!==p||x!==void 0&&x!==h);if(y?.choice==="local"&&m)return{content:T(u,a?.mode),versioned:o,fragment:m,observed:a,retainedAgainst:h};if(m&&m===p&&x===h)return{content:T(u,a?.mode),versioned:o,fragment:m,observed:a,retainedAgainst:h};if(S&&y?.choice!=="release"){s.push({path:t,reason:"The existing router block has local edits. Reconcile it before applying the release.",local:m,incoming:h});return}if(!p&&!o&&!y&&(d.prefix||d.suffix!==l)){i.push(`Preserved the existing ${t}. Review its local bootstrap before relying on automatic discovery.`);return}return{content:T(`${d.prefix}${f}${d.suffix}`,a?.mode),versioned:o,fragment:h,observed:a,replaced:S}}if(a&&!o&&y?.choice!=="release"){i.push(`Preserved the existing ${t} in local mode.`);return}let w=u;if(u&&!u.endsWith(`${l}${l}`))w=u.endsWith(l)?`${u}${l}`:`${u}${l}${l}`;return{content:T(`${w}${f}${l}`,a?.mode),versioned:o,fragment:h,observed:a,replaced:y?.choice==="release"}}function ap(e,t,r,o,n,s){let i=new Map,c=new Map([[".",t.workspaceVersioned]]);for(let a of t.repositories)if(a.path!=="."&&Xo(Et(e,a.path),{throwIfNoEntry:!1}))c.set(a.path,t.workspaceVersioned&&a.versioned);for(let[a,u]of c){let p=(h)=>a==="."?h:`${a}/${h}`,l=qh(Et(e,a),Et(e,"llm/HARNESS.md")),f=(h,d,m=u,y=n)=>{let x=Yh(e,h,d,m,r,o,y,s);if(x)i.set(h,x);return Boolean(x)};for(let{path:h,content:d}of zo(t.hosts,l)){let m=p(h);if(h==="CLAUDE.md"){let S=p(".claude/rules/apptoolkit.md"),I=r?.files.some((z)=>z.path===S),b=[];if(I||!u&&!f(m,d,u,b))if(f(S,d,!1))n.push(`Claude loads ${S} alongside the preserved project guidance.`);else n.push(...b);else if(u)f(m,d);continue}let y=f(m,d),x=p("AGENTS.override.md"),w=Xo(Et(e,x),{throwIfNoEntry:!1});if(t.hosts.includes("codex")&&(w||!y&&!u)){let S=`Before acting, read the sibling AGENTS.md if present. It contains the project's existing instructions.
|
|
74
|
+
|
|
75
|
+
${d}`;if(!f(x,S,!1)&&w)n.push(`Codex prioritizes ${x}. Confirm a bootstrap there before relying on automatic discovery.`)}if(!y&&!u&&t.hosts.includes("opencode")){let S=[".opencode/opencode.json",".opencode/opencode.jsonc","opencode.json","opencode.jsonc"].map(p),b=S.find((z)=>r?.files.some((_)=>_.path===z))??S.find((z)=>!Xo(Et(e,z),{throwIfNoEntry:!1}));if(b){let _=`${JSON.stringify({instructions:["llm/harness-local/opencode-instructions.md"]},null,2)}
|
|
76
|
+
`;i.set(b,{content:T(_),versioned:!1}),i.set(p("llm/harness-local/opencode-instructions.md"),{content:T(`${d}
|
|
77
|
+
`),versioned:!1})}else n.push(`All native OpenCode configuration paths are occupied for ${a}. Keep tracked configuration intact and confirm a local route during init.`)}}}return i}import{lstatSync as Qh}from"node:fs";import{basename as em,resolve as up}from"node:path";function Ot(e,t){return!Qh(up(e,t),{throwIfNoEntry:!1})}function Qo(e,t){let r=ye(e,up(e,t));if(r!==".")oe(r);return r}function pp(e,t,r){let o=Pe(e,t),n=J(o);if(r&&!n)throw Error(`Cannot version files in ${o} because Git does not manage this directory.`);let s=n&&nu(n.root);return s?{path:t,versioned:r,identity:s}:{path:t,versioned:r}}function tm(e,t,r){let o=t.repository;if(!o)throw Error("Specify the directory of the Git repository to register.");let n=Qo(e,o);if(r.repositories.find((p)=>p.path===n)&&!Ot(e,n))return Pe(e,n),r.repositories;if(Ot(e,n)){let p=r.repositories.filter((f)=>em(f.path)===o),l=p[0];if(l&&p.length===1&&!Ot(e,l.path))return Pe(e,l.path),r.repositories}if(n===".")throw Error("Select the directory of a Git checkout inside the workspace.");let i=t.repositories.find((p)=>Qo(e,p.path)===n)?.versioned;if(i===void 0)throw Error(`Choose whether generated files inside ${n} should be versioned before registering it.`);let c=pp(e,n,i),a=r.repositories.filter((p)=>c.identity&&p.identity===c.identity&&Ot(e,p.path)),u=a[0];if(a.length>1)throw Error(`More than one missing registration matches ${n}. Resolve the ambiguous repository paths before retrying.`);return[...r.repositories.filter((p)=>p.path!==u?.path),c]}function lp(e,t,r){let{root:o}=e;if(t.action==="add-repo"){if(!r)throw Error("Install the workspace harness before registering an additional repository.");return tm(o,t,r).sort((c,a)=>c.path.localeCompare(a.path,"en"))}let n=t.workspaceVersioned&&Boolean(e.gitRoot),s=t.repositories;if(!s.length&&r)s=r.repositories;if(!s.length&&e.kind==="workspace")throw Error("Select the repositories to register in this workspace.");if(!s.length)s=[{path:".",versioned:n}];let i=new Map;for(let c of s){let a=Qo(o,c.path);if(i.has(a))throw Error(`Repository ${a} was selected more than once.`);let u=r?.repositories.find((p)=>p.path===a);if(u&&Ot(o,a))i.set(a,{...u,versioned:c.versioned});else i.set(a,pp(o,a,c.versioned))}if(r?.repositories.some((c)=>!i.has(c.path)))throw Error("The new selection omits a registered repository. Keep the existing selection when reinstalling or updating.");return[...i.values()].sort((c,a)=>c.path.localeCompare(a.path,"en"))}import{resolve as rm}from"node:path";var om=O({root:k().min(1),repository:k().min(1),file:k().endsWith(".llm.md")}),en=new WeakMap;function tn(e){let t=om.parse(e),r=ge(t.root),o=R(r,W),n=ee(r),s=n?.repositories.find((y)=>y.path===t.repository);if(!n||!s)throw Error(`Register repository ${t.repository} in the workspace before excluding generated files.`);if(s.versioned)throw Error(`Repository ${t.repository} is configured to version its generated files.`);let i=Pe(r,s.path),c=dr(i,t.file),a=J(i);je(c,a?.root);let u={root:r,writes:[],conflicts:[]},p=[{base:r,path:W,before:o,after:o}],l=[a?{absolute:c,gitRoot:a.root}:{absolute:c}];if(!ae(o,R(r,W)))throw Error("The installation receipt changed while planning. Retry the artifact command.");if(!a)return en.set(u,{exclusions:[],files:[],checks:[],guards:p,boundaries:l}),u;if(Ye(a,c))u.conflicts.push({path:t.file,reason:"Git already tracks this file. Resolve its index status before choosing local mode."});let f=ye(a.root,c),h=n.installation??V(r).slice(0,16),d=qo(a,`${h} artifacts`,new Set([St(f)]),!0),m=d?[d]:[];if(d)u.writes.push({path:rm(d.base,d.path),before:d.before?.hash??null,after:d.after?.hash??null});return en.set(u,{exclusions:m,files:[],checks:[{git:a,path:f,absolute:c,versioned:!1}],guards:p,boundaries:l}),u}function rn(e){let t=en.get(e);if(!t||e.conflicts.length)throw Error("Resolve the artifact conflicts and create a new plan in this process before applying.");return{changed:Ro(e.root,t)}}function nm(e,t){let r=Ee(e,t,"llm"),o=fp(r,Ee(e,"llm/HARNESS.md"));return["# Harness context","",`Start from the workspace folder at \`${fp(Ee(e,t),e)||"."}\` and open the [harness index](${encodeURI(o)}).`,"Read the workspace profile and this repository’s own instructions before changing code.","Use the repository-specific settings for services, documentation conventions and validation.","Prefer deterministic tools and improve repeatable work and noisy command output.","Retrieve and maintain indexed project knowledge and sibling .llm.md source maps as you work.",""].join(`
|
|
78
|
+
`)}function sm(e){let t=[["llm/harness-local/KNOWLEDGE.md",`# Project knowledge
|
|
79
|
+
|
|
80
|
+
Index durable findings by topic and repository. Link to the smallest useful record and include search terms, status and revalidation triggers.
|
|
81
|
+
`],["llm/harness-local/TOOLS.md",`# Project tools
|
|
82
|
+
|
|
83
|
+
Index project runners, deterministic utilities and output filters. Record invocation, inputs, outputs, effects, tests and recovery.
|
|
84
|
+
`],["llm/harness-local/IMPROVEMENTS.md",`# Project improvements
|
|
85
|
+
|
|
86
|
+
Index verified harness changes and pending decisions. Record the trigger, evidence, scope, outcome, checks and rollback route.
|
|
87
|
+
`]],r=[];for(let[o,n]of t)if(o&&n&&!R(e,o))r.push({base:e,path:o,before:null,after:T(n)});return r}function im(e,t,r,o,n,s){let i=new Map;if(t.action!=="add-repo"){for(let[l,f]of ip(t.contentDirectory))i.set(l,{content:f,versioned:r.workspaceVersioned});for(let l of Po(r.hosts,r.version))i.set(l.path,{content:T(l.content),versioned:r.workspaceVersioned});let c="llm/README.md",a=R(e,c),u=o?.files.some((l)=>l.path===c),p=T(`# LLM workspace
|
|
73
88
|
|
|
74
89
|
Open the [harness index](HARNESS.md) for workspace rules, project routing, workflows and tools.
|
|
75
|
-
`);if(!a||u||a.hash===p.hash)i.set(c,{content:p,versioned:r.workspaceVersioned})}for(let c of r.repositories){if(!
|
|
76
|
-
`,
|
|
77
|
-
|
|
90
|
+
`);if(!a||u||a.hash===p.hash)i.set(c,{content:p,versioned:r.workspaceVersioned})}for(let[c,a]of ap(e,r,o,n,s,t.resolutions))i.set(c,a);for(let c of r.repositories){if(!dp(Ee(e,c.path),{throwIfNoEntry:!1}))continue;let a=et(c.path),p=o?.files.find((l)=>l.path===a)?.versioned??(r.workspaceVersioned&&c.versioned);if(p&&!r.workspaceVersioned)s.push(`The existing versioned context map ${a} points to a local harness. Review its Git scope during init if it should become private.`);i.set(a,{content:T(nm(e,c.path)),versioned:p})}return i}function cm(e,t,r,o,n,s){let i=[],c=[],a=new Map(n.resolutions?.map((d)=>[d.path,d])),u=new Map,p=new Map(o?.files.map((d)=>[d.path,d])),l=new Set(o?.repositories.map((d)=>et(d.path))),f=[...new Set([...r.repositories,...o?.repositories??[]].map(({path:d})=>d))].filter((d)=>!dp(Ee(e,d),{throwIfNoEntry:!1}));function h(d,m){let y=`llm/harness-local/update-history/${V(d)}/${m.hash}`,x=`${JSON.stringify({path:d,sha256:m.hash},null,2)}
|
|
91
|
+
`,w=new Map([[`${y}.bak`,T(m.bytes,384)],[`${y}.json`,T(x,384)]]);for(let[S,I]of w){let b=R(e,S);if(b&&b.hash!==I.hash)throw Error(`Update history differs from its expected hash at ${S}. Restore it before retrying.`);let z={base:e,path:S,before:b,after:I};if(b)c.push({...z,after:b});else u.set(S,z)}}for(let[d,{content:m,versioned:y,fragment:x,observed:w,replaced:S,retainedAgainst:I}]of t){let b=R(e,d),z=p.get(d),_=T(m.bytes,b?.mode??m.mode);if(w!==void 0&&!ae(b,w))throw Error(`The native router ${d} changed while planning. Retry the workspace command.`);let Ue=!x&&I===void 0&&b&&b.hash!==_.hash&&(b.hash!==z?.hash||z.retainedAgainst!==void 0&&z.retainedAgainst!==_.hash),pe=a.get(d);if(!x&&I===void 0&&b&&(Ue||z?.retainedAgainst===_.hash)&&(pe?.choice==="local"&&pe.local===b.hash&&pe.incoming===_.hash||b.hash===z?.hash&&z.retainedAgainst===_.hash)){r.files.push({path:d,hash:b.hash,versioned:y,retainedAgainst:_.hash}),c.push({base:e,path:d,before:b,after:b});continue}let Be=b&&pe?.choice==="release"&&pe.local===b.hash&&pe.incoming===_.hash;if(Ue&&!Be)s.push({path:d,reason:"Local changes differ from this release. Compare the files and select the applicable version.",local:b.hash,incoming:_.hash});else if(!ae(b,_)){if(b&&(Be||S))h(d,b);i.push({base:e,path:d,before:b,after:_})}else c.push({base:e,path:d,before:b,after:b});r.files.push({path:d,hash:_.hash,versioned:y,...x?{fragment:x}:{},...I?{retainedAgainst:I}:{}})}for(let d of p.values()){if(t.has(d.path))continue;if(f.some((w)=>d.path.startsWith(`${w}/`))){if(r.repositories.some(({path:w})=>d.path.startsWith(`${w}/`)))r.files.push(d);continue}if(vr(d.path)||n.action==="add-repo"&&!l.has(d.path)){r.files.push(d);continue}let m=R(e,d.path);if(!m)continue;let y=a.get(d.path),x=y?.local===m.hash&&y.incoming===null;if(x&&y.choice==="local"||m.hash===d.hash&&d.retainedAgainst===null){r.files.push({...d,hash:m.hash,retainedAgainst:null}),c.push({base:e,path:d.path,before:m,after:m});continue}if((m.hash!==d.hash||d.retainedAgainst!==void 0)&&!x){s.push({path:d.path,reason:"The release retires this file, but it has local edits. Preserve the changes before updating.",local:m.hash,incoming:null});continue}if(x)h(d.path,m);i.push({base:e,path:d.path,before:m,after:null})}return r.files.sort((d,m)=>d.path.localeCompare(m.path,"en")),{files:[...u.values(),...i],guards:c}}function hp(e){let t=mr.parse(e);if(t.resolutions?.length&&t.action!=="update")throw Error("Conflict decisions apply only to an update.");let r=Fe(t.root),{root:o}=r,n=R(o,W),s=ee(o);if(t.action==="update"&&!s)throw Error("Install the workspace harness before updating it.");if(t.action==="install"&&s&&s.version!==t.version)throw Error(`This workspace already has harness ${s.version}. Use update to select ${t.version}.`);let i=t.action==="add-repo"&&s,c=lp(r,t,s),a=i?s.workspaceVersioned:t.workspaceVersioned;if(a&&!r.gitRoot)throw Error(`The workspace at ${o} does not have Git. Choose local workspace mode before retrying.`);let u={schema:1,version:i?s.version:t.version,hosts:i?s.hosts:[...new Set(t.hosts)].sort(),workspaceVersioned:a,repositories:c,services:i?s.services:[...new Set(t.services)].sort(),installation:s?.installation??V(o).slice(0,16),files:[]},p=[],l=[],f=im(o,t,u,s,p,l);if(l.length)u.bootstrapNotices=[...l];let{files:h,guards:d}=cm(o,f,u,s,t,p);if(h.push(...sm(o)),i){let _=cp(o,s,u,p);if(_)h.push(_)}let m=h.filter((_)=>_.after===null).map((_)=>_.path),y=[...h,...d].filter(({path:_})=>_.startsWith("llm/harness-local/update-history/")).map(({path:_})=>_),x=op(o,u,s,p,m,y),w=new Set(x.checks.filter((_)=>!_.versioned&&_.git.commonDirectory!==Ee(_.git.root,".git")).map((_)=>_.git.commonDirectory));for(let _ of w)l.push(`Local Git exclusions use ${Ee(_,"info/exclude")}. Linked worktrees that share this Git directory use the same exclusions.`);let S=T(`${JSON.stringify(u,null,2)}
|
|
92
|
+
`,n?.mode);if(!ae(n,R(o,W)))throw Error("The installation receipt changed while planning. Retry the workspace command.");let I=ae(n,S)?[]:[{base:o,path:W,before:n,after:S}],b=[...x.operations,...h,...I].map((_)=>({path:_.base===o?_.path:Ee(_.base,_.path),before:_.before?.hash??null,after:_.after?.hash??null})),z={root:o,...r.gitRoot?{gitRoot:r.gitRoot}:{},action:t.action,writes:b,conflicts:p,notices:l,receipt:u};return au(z,{exclusions:x.operations,files:h,checks:x.checks,guards:[{base:o,path:W,before:n,after:n},...d],...I[0]?{receipt:I[0]}:{},boundaries:x.boundaries}),z}import{parseArgs as am}from"node:util";var Me=B(["codex","claude","opencode"]),Zt={codex:"Codex",claude:"Claude Code",opencode:"OpenCode"},We=B(["plane","penpot"]);function mp(e){let t=am({args:e,allowPositionals:!0,options:{help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"},root:{type:"string"},json:{type:"boolean"},yes:{type:"boolean",short:"y"},plan:{type:"boolean"},hosts:{type:"string"},versioned:{type:"boolean"},local:{type:"boolean"},repo:{type:"string",multiple:!0},"repo-mode":{type:"string",multiple:!0},"repo-versioned":{type:"boolean"},"repo-local":{type:"boolean"},"enable-service":{type:"string",multiple:!0},config:{type:"string"},project:{type:"string"},"verify-read":{type:"boolean"},"verify-health":{type:"boolean"},manifest:{type:"string"},file:{type:"string",multiple:!0},section:{type:"string"},resolutions:{type:"string"},threshold:{type:"string"},important:{type:"string",multiple:!0},"verify-maps":{type:"boolean"}}}),{values:r}=t;if(r.versioned&&r.local||r["repo-versioned"]&&r["repo-local"])throw Error("Choose exactly one Git storage mode for each scope.");if(r.plan&&r.yes)throw Error("Choose --plan to preview or --yes to apply.");return t}function G(e,t){return k().min(1,`Supply ${t}.`).parse(e??"")}function gp(e){let t=new Map;for(let r of e){let o=r.lastIndexOf("="),n=r.slice(0,o),s=r.slice(o+1);if(o<1||s!=="local"&&s!=="versioned"||t.has(n))throw Error(`Invalid or duplicate --repo-mode ${r}. Use <path>=local or <path>=versioned.`);t.set(n,s==="versioned")}return t}import{readFileSync as yp}from"node:fs";var um=O({kind:k().min(1),title:k().min(1).optional(),headings:P(k().min(1)).default([]),checkedItems:P(k().min(1)).default([]),requiredText:P(k().min(1)).default([]),forbiddenText:P(k().min(1)).default([])});function pm(e){let t,r=[];for(let o of e.split(/\r?\n/)){let n=/^ {0,3}(`{3,}|~{3,})(.*)$/.exec(o),s=n?.[1];if(t){if(s?.startsWith(t)&&!n?.[2]?.trim())t=void 0}else if(s)t=s;else r.push(o)}return r}function xp(e,t){let r=um.parse(JSON.parse(yp(e,"utf8"))),o=yp(t,"utf8"),n=pm(o),s=n.join(`
|
|
93
|
+
`),i=o.toLowerCase(),c=n.flatMap((l)=>{let f=/^ {0,3}#{1,6}[ \t]+(.+?)\s*$/.exec(l);return f?.[1]?[f[1].replace(/[ \t]+#+[ \t]*$/,"")]:[]}),a=new Set(n.flatMap((l)=>{let f=/^\s*[-+*]\s+\[[xX]\]\s+(.+?)\s*$/.exec(l);return f?.[1]?[f[1]]:[]})),u=[],p=-1;if(r.title&&c[0]!==r.title)u.push(`Expected the first heading to be ${r.title}.`);for(let l of r.headings){let f=c.indexOf(l,p+1);if(f<0)u.push(`Missing or out-of-order heading: ${l}.`);else p=f}for(let l of r.checkedItems)if(!a.has(l))u.push(`Checklist item must be checked: ${l}.`);for(let l of r.requiredText)if(!s.includes(l))u.push(`Required text is absent: ${l}.`);for(let[l,f]of r.forbiddenText.entries())if(i.includes(f.toLowerCase()))u.push(`Forbidden text rule ${l+1} matched.`);return{kind:r.kind,valid:u.length===0,issues:u}}import{resolve as wr}from"node:path";import{basename as lm,isAbsolute as fm,relative as dm,resolve as hm}from"node:path";var Rt=new Intl.ListFormat("en"),vp={plane:"Plane for work items",penpot:"Penpot for design"};function mm(e,t,r){let o=e.receipt.version;if(e.action==="add-repo"){if(!e.writes.length&&!e.conflicts.length)return`Review the AppToolkit Harness registration for ${r} in ${e.root}.`;return`Register ${r} with the shared AppToolkit Harness in ${e.root}.`}if(e.action==="update"){if(t&&t.version!==o)return`Update AppToolkit Harness from ${t.version} to ${o} in ${e.root}.`;return`Update the AppToolkit Harness ${o} setup in ${e.root}.`}return`Install AppToolkit Harness ${o} in ${e.root}.`}function gm(e,t){let{workspaceVersioned:r,repositories:o}=e.receipt,n=Boolean(e.gitRoot),i=(o.length===1&&o[0]?.path==="."?o[0]:void 0)?.versioned===r,c=i?"the harness, its settings and generated project guidance":"the shared harness and its settings",a=e.action==="add-repo"?o.filter(({path:p})=>p===t):o,u=[];if(r)u.push(`Make ${c} available to commit in the workspace Git repository.`);else if(n)u.push(`Keep ${c} on this machine using local Git ignore rules.`);else u.push(`Keep ${c} in this folder outside Git.`);for(let p of a){if(i&&p.path===".")continue;let l=p.path==="."?"this project":p.path;if(p.versioned)u.push(`Make the harness files generated for ${l} available to commit.`);else if(p.path!=="."||n)u.push(`Keep the harness files generated for ${l} local using Git ignore rules.`);else u.push(`Keep the harness files generated for ${l} in the project folder outside Git.`)}if(r||a.some(({versioned:p})=>p))u.push("You decide what to stage and commit in Git.");return u}function ym(e,t){let{services:r}=e.receipt,o=r.filter((i)=>!t?.services.includes(i)),n=r.filter((i)=>t?.services.includes(i)),s=[];if(o.length){let i=Rt.format(o.map((c)=>vp[c]));s.push(`Offer ${i} during agent setup. Each connection is configured separately.`)}if(n.length){let i=Rt.format(n.map((c)=>vp[c]));s.push(`Optional services selected for this workspace are ${i}.`)}if(!r.length)s.push("Skip the optional Plane and Penpot setup.");return s}function xm(e){let{writes:t}=e,r=t.filter(({after:f})=>f!==null),o=r.filter(({path:f})=>vr(f)),n=o.filter(({before:f})=>f===null).map(({path:f})=>f),s=o.filter(({before:f})=>f!==null).map(({path:f})=>f),i=new Set(e.receipt.repositories.map(({path:f})=>et(f))),c=new Set(["llm/HARNESS.md","llm/README.md"]),a="llm/harness/project.json",u=[],p=r.filter(({path:f})=>{let h=f.startsWith("llm/harness/")&&f!==W&&f!=="llm/harness/project.json";return c.has(f)||f.startsWith("llm/author-style/")||h});if(p.length){let f=p.every(({before:h})=>h===null)?"Add":"Refresh";u.push(`${f} shared workflows, project guidance, and tools for verification and code style in llm/.`)}if(r.some(({path:f})=>f.startsWith(".agents/")||f.startsWith(".claude/skills/")||f.startsWith(".opencode/commands/")))u.push("Set up the shortcuts your selected agents use to open the harness.");if(n.length)u.push(`Create agent guidance in ${Rt.format(n)} so your agents can find the harness.`);if(s.length)u.push(`Update the harness section in ${Rt.format(s)} and preserve the project guidance.`);if(r.some(({path:f})=>i.has(f)))u.push("Write project context that points agents to the shared harness and the relevant project rules.");if(r.some(({path:f})=>f==="llm/harness/project.json"))u.push("Update the saved project settings for the checkout path.");if(r.some(({path:f})=>fm(f)))u.push("Update the local Git ignore rules for the generated harness files.");if(r.some(({path:f})=>f===W))u.push("Save the harness version and workspace choices.");if(t.some(({after:f})=>f===null))u.push("Remove harness files retired by this plan.");return u}function vm(e,t,r){let o=e.receipt.repositories.map(({path:i})=>i),n=o.find((i)=>!t?.repositories.some((c)=>c.path===i));if(n)return n;if(!r)return"the checkout";let s=dm(e.root,hm(e.root,r))||".";if(o.includes(s))return s;return o.find((i)=>lm(i)===r)??s}function wp(e,t,r){let o=e.action==="add-repo"?vm(e,t,r):"",n=Me.options.filter((a)=>e.receipt.hosts.includes(a)),s=Rt.format(n.map((a)=>Zt[a])),i=e.action==="add-repo"?[]:ym(e,t),c=[mm(e,t,o),`The harness will be available in ${s}.`,...gm(e,o),...i,...xm(e)];for(let a of e.notices)c.push(a);if(e.conflicts.length){c.push("Resolve these conflicts before applying the plan.");for(let{path:a,reason:u}of e.conflicts)c.push(` ${a}. ${u}`)}else if(!e.writes.length)c.push("The current setup already matches this plan.");return c}var wm=[{label:"Keep harness files local",value:"local"},{label:"Make harness files available to commit",value:"versioned"}],bp=[{label:"No",value:"no"},{label:"Yes",value:"yes"}];async function on(e,t,r){if(!e)throw Error(`Supply ${r} for a noninteractive run.`);return await e(t,wm)==="versioned"}async function bm(e){let{options:t,selectMany:r}=e;if(t.hosts)return[...new Set(P(Me).min(1).parse(t.hosts.split(",")))];if(!r)throw Error("Supply --hosts codex,claude,opencode or a subset for a noninteractive install.");let o=Me.options.map((s)=>({label:Zt[s],value:s})),n=await r("Which agent hosts should this workspace support?",o,Me.options);return P(Me).min(1).parse(n)}async function _m(e,t){let{options:r,select:o}=e,n=gp(r["repo-mode"]??[]),s=new Set(t.repositories.map(({path:a})=>a)),i=new Set(r.repo??[]),c=[];for(let a of[...i,...n.keys()])if(!s.has(a))throw Error(`No repository was detected at ${a}. Inspect the workspace for accepted relative paths.`);for(let a of t.repositories){if(i.size&&!i.has(a.path))continue;if(t.kind==="workspace"&&o&&!i.size&&!n.has(a.path)){if(await o(`Register ${a.path}?`,[{label:"Register",value:"yes"},{label:"Skip",value:"no"}])==="no")continue}let u=`--repo-mode ${a.path}=local or ${a.path}=versioned`,p=a.gitRoot?n.get(a.path)??await on(o,`Version files generated inside ${a.path}?`,u):!1;c.push({path:a.path,versioned:p})}if(t.kind==="workspace"&&c.length===0)throw Error("Select at least one repository for the shared workspace.");return c}async function km(e){let{root:t,options:r,select:o,emit:n}=e,s=Fe(t);if(!r.json){let p={blank:"an empty project",existing:"an existing project",workspace:"a parent workspace"};n(`Detected ${s.monorepo?"a monorepo":p[s.kind]} at ${s.root}.`)}let i=await bm(e),c=s.gitRoot?r.versioned||!r.local&&await on(o,"Version the central harness with this Git repository?","--local or --versioned"):!1;if(r.versioned&&!s.gitRoot)throw Error("The workspace root has no Git repository. Use --local.");let a=await _m(e,s),u=P(We).parse(r["enable-service"]??[]);if(o&&!r["enable-service"]){for(let p of We.options)if(await o(`Offer ${p==="plane"?"Plane for agent work items":"Penpot for design"} during setup?`,bp)==="yes")u.push(p)}return{hosts:i,workspaceVersioned:c,repositories:a,services:[...new Set(u)]}}function $m(e){let t=ee(e);if(!t)throw Error(`No harness is registered at ${e}. Run install first.`);return{hosts:t.hosts,workspaceVersioned:t.workspaceVersioned,repositories:t.repositories,services:t.services}}async function _p(e,t,r){let{root:o,version:n,options:s,emit:i,select:c,contentDirectory:a}=e;if(!a&&t!=="add-repo")throw Error("Run this command from a release package. Use bunx @apptoolkit/harness@latest update for an installed workspace.");let u=ee(o),p=t==="install"&&!u?await km(e):$m(o),l;if(t==="update"&&s["enable-service"]){let m=P(We).parse(s["enable-service"]);p.services=[...new Set([...p.services,...m])]}if(t==="add-repo"){l=G(r,"the checkout path");let m=wr(o,l),y=p.repositories.find(({path:w})=>wr(o,w)===m),x=s["repo-versioned"]||(s["repo-local"]?!1:y?.versioned??await on(c,`Version files generated inside ${l}?`,"--repo-local or --repo-versioned"));p.repositories=[...p.repositories.filter(({path:w})=>wr(o,w)!==m),{path:l,versioned:x}]}let f=hp({root:o,action:t,version:n,contentDirectory:a??"",...p,...s.resolutions?{resolutions:mr.shape.resolutions.unwrap().parse(we(wr(s.resolutions)))}:{},...l?{repository:l}:{}}),h={action:t,root:f.root,version:f.receipt.version,writes:f.writes.map(({path:m,before:y,after:x})=>({path:m,effect:x===null?"remove":y===null?"create":"update",before:y,after:x})),conflicts:f.conflicts,notices:f.notices};if(!s.json)for(let m of wp(f,u,l))i(m);if(s.plan||!s.yes&&!c){if(s.json)i(h);return f.conflicts.length?1:0}if(f.conflicts.length){if(s.json)i(h);throw Error("Resolve the reported installation conflicts before applying the plan.")}if(!s.yes&&f.writes.length&&c&&await c("Apply this plan?",bp)!=="yes")return 0;let d=Co(f);if(s.json)i({...h,changed:d.changed,version:d.receipt.version,hosts:d.receipt.hosts});else if(i(`Applied ${d.changed} change(s) for @apptoolkit/harness ${d.receipt.version}.`),t==="install"){i(`Open ${f.root} in your selected agent host.`);for(let m of d.receipt.hosts)i(` ${Zt[m]}: ${m==="codex"?"$":"/"}apptoolkit init`)}return 0}var Tm=`@apptoolkit/harness 1.0.5
|
|
78
94
|
|
|
79
95
|
install Inspect and prepare a project or workspace
|
|
80
96
|
inspect Report workspace topology and installation state
|
|
81
97
|
init --json Print the project setup template for the agent
|
|
82
98
|
init --config <file> Apply validated project choices
|
|
99
|
+
biome-plan Inspect project-wide setup for --project <repo>
|
|
83
100
|
add repo <path> Register a related checkout
|
|
84
101
|
protect <file> Preview or apply a local exclusion for a source map
|
|
85
102
|
update Reconcile this package version with the workspace
|
|
86
103
|
workflow <W01-W37|list> Read a single workflow or the index
|
|
87
104
|
context <file> List headings or read an exact --section
|
|
105
|
+
source-maps Inspect explicit --file and --important paths, use --verify-maps to enforce
|
|
88
106
|
verify document <file> Check a document against a local --config policy
|
|
89
107
|
verify coverage <lcov> Require 100% measured coverage for the configured source scope
|
|
90
108
|
service status <name> Inspect opt-in Plane or Penpot access
|
|
@@ -97,8 +115,9 @@ Install options: --hosts codex,claude,opencode --local | --versioned
|
|
|
97
115
|
Add options: --repo-local | --repo-versioned
|
|
98
116
|
Service options: --project <repo> --verify-health --verify-read --manifest <file> | --file <export>
|
|
99
117
|
Use --plan to preview. Noninteractive workspace changes require --yes and explicit choices.
|
|
100
|
-
`;function
|
|
101
|
-
`),0;if(e.help||!r)return process.stdout.write(
|
|
102
|
-
`);else process.stdout.write(`${JSON.stringify(
|
|
103
|
-
`)};if(r==="inspect"&&!o){let
|
|
118
|
+
`;function Dm(){return Nm(new URL("./payload/",import.meta.url))}function Fm(e,t){if(t==="list")return Le(e,"llm/harness/WORKFLOWS.md");let r=k().regex(/^W(?:0[1-9]|[12][0-9]|3[0-7])$/,"Choose W01 through W37 or list.").parse(t??""),o=Le(e,`llm/harness/workflows/${r}.md`);if(Buffer.byteLength(o)>32768)throw Error(`Workflow ${r} is larger than 32 KiB. Use context to read a section.`);return o}async function Lm(){let{values:e,positionals:t}=mp(process.argv.slice(2)),[r,o,n,s]=t;if(e.version)return process.stdout.write(`1.0.5
|
|
119
|
+
`),0;if(e.help||!r)return process.stdout.write(Tm),0;let i=_r(e.root??process.cwd()),c=(y)=>{if(typeof y==="string")process.stdout.write(`${y.trimEnd()}
|
|
120
|
+
`);else process.stdout.write(`${JSON.stringify(y,null,2)}
|
|
121
|
+
`)};if(r==="inspect"&&!o){let y=Fe(i),x=ee(y.root),S=(x?De(y.root):void 0)?.projects.map(({path:I,budget:b,services:z})=>({path:I,budget:b.mode,services:z.map(({provider:_})=>_)}))??[];return c({...y,installation:x??null,configuredProjects:S}),0}if(r==="init"&&!o){if(!e.config)return c(await To(i)),0;if(e.plan)throw Error("Use init without --config to read the setup template. Applying a configuration requires a separate invocation.");return c(await Do({root:i,configPath:_r(e.config)})),0}if(r==="biome-plan"&&!o)return c(Cu(i,G(e.project,"--project <repo>"))),0;if(r==="workflow"&&!n){let y=Fm(i,o);return c(e.json?{id:o,document:y}:y),0}if(r==="context"&&!n){let y=G(o,"the workspace-relative Markdown path");return c(Vu({root:i,file:y,...e.section?{section:e.section}:{}})),0}if(r==="source-maps"&&!o){let y=k().regex(/^\d+$/u).transform(Number).parse(e.threshold??"200"),x=Qu({root:i,threshold:y,files:e.file??[],important:e.important??[]});if(c(x),e["verify-maps"]&&x.some(({required:w,exists:S})=>w&&!S))return process.stderr.write(`Required sibling source maps are missing. Create the reported maps and verify again.
|
|
122
|
+
`),1;return 0}if(r==="verify"&&o==="document"&&!s){let y=_r(G(e.config,"--config <policy.json>")),x=_r(G(n,"the document path")),w=xp(y,x);return c(w),w.valid?0:1}if(r==="verify"&&o==="coverage"&&!s){let y=G(n,"the workspace-relative LCOV report"),x=G(e.config,"--config <coverage-policy.json>");return c(Yu({root:i,file:y,config:x})),0}if(r==="protect"&&!n){let y=G(e.project,"--project <repo>"),x=G(o,"the repository-relative source map path"),w=tn({root:i,repository:y,file:x});if(e.yes&&!w.conflicts.length)c({...w,...rn(w)});else c(w);return w.conflicts.length?1:0}if(r==="service"&&o==="status"&&!s){let y=We.parse(n),x=G(e.project,"--project <repo>");return c(await Mo({root:i,service:y,project:x,verifyRead:e["verify-read"]??!1,verifyHealth:e["verify-health"]??!1})),0}if(r==="service"&&o==="snapshot"&&!s){let y=We.parse(n),x=G(e.project,"--project <repo>"),w=e.file??[];if(w.length&&e.manifest)throw Error("Choose --file to prepare a manifest or --manifest to verify it.");if(w.length)c(await Wo({root:i,service:y,project:x,paths:w}));else{let S=G(e.manifest,"--manifest <snapshot.json>");c(await Uo({root:i,service:y,project:x,manifestPath:S}))}return 0}let a=r==="add"&&o==="repo"&&!s,u=r==="install"&&!o;if(!a&&!u&&!(r==="update"&&!o))throw Error("Unknown command or arguments. Run with --help for usage.");let f=process.stdin.isTTY&&!e.json&&!e.plan&&!e.yes?await Promise.resolve().then(() => (Sp(),$p)):void 0,h={root:i,version:"1.0.5",options:e,emit:c},d={contentDirectory:Dm()},m=f?{select:f.selectChoice,selectMany:f.selectMany}:{};return _p({...h,...d,...m},a?"add-repo":u?"install":"update",n)}try{process.exitCode=await Lm()}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`apptoolkit: ${t}
|
|
104
123
|
`),process.exitCode=1}
|