@shadowclone/cli 0.0.25 → 0.0.27
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/PRIVACY.md +14 -13
- package/README.md +89 -64
- package/bin/shadowclone.mjs +0 -0
- package/dist/_.._/{web → _.._/web/src}/client/index.html +3 -3
- package/dist/shadowclone.js +858 -740
- package/dist/web/index-cmzs0t91.js +135 -0
- package/evals.md +72 -86
- package/package.json +12 -37
- package/plugins/shadowclone/.claude-plugin/plugin.json +1 -1
- package/plugins/shadowclone/.codex-plugin/plugin.json +1 -1
- package/plugins/shadowclone/README.md +9 -5
- package/plugins/shadowclone/SECURITY.md +2 -2
- package/plugins/shadowclone/plugin.json +1 -1
- package/plugins/shadowclone/skills/setup-shadowclone/SKILL.md +43 -31
- package/skills/shadowclone-review/SKILL.md +7 -4
- package/skills/write-plain-english/SKILL.md +15 -4
- package/dist/web/index-xsq72pnc.js +0 -134
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
function Ue(e){let t=Object.values(e).filter((n)=>typeof n==="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Qt(e,t="|"){return e.map((r)=>rr(r)).join(t)}function qe(e,t){if(typeof t==="bigint")return t.toString();return t}class bn{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 lt(e){return new bn(e)}function xn(e){return e===null||e===void 0}function dt(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function vn(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-n)<o)return 0;return r-n}function te(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 de(e){return pt(e._zod.def)??e._zod.def.shape}function wn(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return te(this,t,n),n},enumerable:!0,configurable:!0})}function _n(e,t,r){if(t in e)te(e,t,r);else e[t]=r}function ve(e,t,r,n){let o=de(t);for(let i of r){let s=Object.getOwnPropertyDescriptor(o,i);if(!s.enumerable)continue;if(s.get)wn(e,i,()=>{let a=t._zod.def.shape[i];return n?n(a,i):a});else _n(e,i,n?n(s.value,i):s.value)}}function Bc(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);if(!n.enumerable)continue;if(n.get)wn(e,r,()=>t[r]);else _n(e,r,n.value)}}function W(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function kn(e){return JSON.stringify(e)}function zn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var er="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Fe(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var $n=lt(()=>{if(G.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function we(e){if(Fe(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(Fe(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function tr(e){if(we(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 Sn=new Set(["string","number","symbol"]);function Ie(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ie(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}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 rr(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Pn(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var ft=(()=>({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]}))(),nr={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Fc(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i={};return ve(i,e,mt(e,t)),ie(e,W(r,{shape:i,checks:[]}))}function mt(e,t){let r=de(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw Error(`Unrecognized key: "${String(o)}"`);if(t[o])n.push(o)}return n}function Uc(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(mt(e,t)),s={};return ve(s,e,Reflect.ownKeys(de(e)).filter((a)=>!i.has(a))),ie(e,W(r,{shape:s,checks:[]}))}function qc(e,t){if(!we(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=de(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ie(e,W(e._zod.def,{shape:Zn(e,t)}))}function Zn(e,t){let r={};return ve(r,e,Reflect.ownKeys(de(e))),Bc(r,t),r}function Vc(e,t){if(!we(t))throw Error("Invalid input to safeExtend: expected a plain object");return ie(e,W(e._zod.def,{shape:Zn(e,t)}))}function Gc(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={};ve(r,e,Reflect.ownKeys(de(e))),ve(r,t,Reflect.ownKeys(de(t)));let n=W(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ie(e,n)}function In(e,t,r,n="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(mt(t,r)):void 0,c={};return ve(c,t,Reflect.ownKeys(de(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),ie(t,W(t._zod.def,{shape:c,checks:[]}))}function Jc(e,t,r){let n=r?new Set(mt(t,r)):void 0,o={};return ve(o,t,Reflect.ownKeys(de(t)),(i,s)=>n&&!n.has(s)?i:new e({type:"nonoptional",innerType:i})),ie(t,W(t._zod.def,{shape:o}))}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 En(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 ye(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Be(e){return typeof e==="string"?e:e?.message}function or(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function ae(e,t,r){var n;let o=e.inst?._zod?.traits;if(o?.has("$ZodType"))if(o.has("$ZodCheck"))(n=e).schema??(n.schema=e.inst);else e.schema=e.inst;let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:Be(e.inst?._zod.def?.error?.(e))??Be(i?.(e))??Be(t?.error?.(e))??Be(r.customError?.(e))??Be(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=s,t?.reportInput)a.input=e.input;return a}var Kc=/[\uD800-\uDBFF]/;function ht(e){let t=e.length;if(!Kc.test(e))return t;let r=t;for(let n=0;n<t-1;n++)if((e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320)r--,n++;return r}function gt(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function On(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,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}function Cn(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get)Object.defineProperty(e,r,{...n,enumerable:!1});else Wc(e,r,n.value)}}function pe(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function yt(e,t,r){return pe(e,t,r,!1)}function An(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return pe(this,r,n(this))},set(o){pe(this,r,o)}})}return t}function Wc(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:pe(this,t,r.bind(this))},set(n){pe(this,t,n)}})}function Hc(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var Xt,ge=!1,Yc={configurable:!0,get(){ge=!0;return}};function I(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&Xt!==e._zod){Xt=void 0;return}Xt=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Yc);let o=ge;ge=!1;try{let i=r(this);if(ge)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i});return ge=ge||o,i}catch(i){throw delete this[t],ge=ge||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Xc(e,t,r,n){let o=Hc(e,t);if(!o)return;Object.defineProperty(o,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,i),i.value=r(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:i})}})}var Qc="~constantCatch";function Nn(e){let t=()=>e;return t[Qc]=!0,t}var Tn;var ir={value:void 0,enumerable:!1},Rn="captureStackTrace"in Error?Error:null;function eu(e){let t=Rn;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return Rn=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function f(e,t,r,n){let o={};function i(p){this.def=p,this.constr=d,this.traits=new Set}i.prototype=o;let s=r,a=s&&new WeakSet;function c(p,m){if(!p._zod){ir.value=new i(m);try{Object.defineProperty(p,"_zod",ir)}finally{ir.value=void 0}}else if(p._zod.traits.has(e))return;if(p._zod.traits.add(e),t(p,m),a){let x=Object.getPrototypeOf(p),w=p._zod.constr.prototype,S=x;while(S&&S!==w)S=Object.getPrototypeOf(S);let P=S??x;if(!a.has(P))a.add(P),Cn(P,s)}let h=d.prototype;for(let x in h){if(!Object.prototype.hasOwnProperty.call(h,x))continue;if(!(x in p))p[x]=h[x].bind(p)}}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(p){let m=n?.Parent?eu(l):this;c(m,p);let h=m._zod.deferred;if(h){for(let w of h)w();m._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(m);return m}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:(p)=>{if(n?.Parent&&p instanceof n.Parent)return!0;return p?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class ce extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ve extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Tn=globalThis).__zod_globalConfig??(Tn.__zod_globalConfig={});var G=globalThis.__zod_globalConfig;function H(e){if(e)Object.assign(G,e);return G}function tu(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,qe,2)),e.message}function ru(e){this._zod.message=e}var nu={get:tu,set:ru,enumerable:!0,configurable:!0},ar={value:void 0,enumerable:!1},Mn=new WeakSet([Object.prototype,Error.prototype]),Ln=(e,t)=>{e.name="$ZodError",ar.value=t,Object.defineProperty(e,"issues",ar),ar.value=void 0,Object.defineProperty(e,"message",nu);let r=Object.getPrototypeOf(e);if(!Mn.has(r))Mn.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}})},Dn=f("$ZodError",Ln),Hd=f("$ZodError",Ln,void 0,{Parent:Error});function ou(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 jn(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)ou(r,o.path[0],()=>[]).push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function Bn(e,t=(r)=>r.message){let r={_errors:[]},n=(o,i=[])=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>n({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")n({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")n({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,u=0;while(u<a.length){let l=a[u],d=u===a.length-1;if(l==="_errors"){if(d)c._errors.push(t(s));u++;continue}if(!Object.prototype.hasOwnProperty.call(c,l))Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let p=c[l];if(d)p._errors.push(t(s));c=p,u++}}}};return n(e),r}function bt(e,t){return{callee:t?.callee??e,Err:t?.Err}}var xt=(e)=>{let t=(r,n,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new ce;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>ae(u,s,H())));throw er(c,i?.callee??t),c}return a.value};return t};var vt=(e)=>{let t=async(r,n,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},s);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>ae(u,s,H())));throw er(c,i?.callee??t),c}return a.value};return t};var wt=(e)=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new ce;return i.issues.length?Fn(e,i.issues,o):{success:!0,data:i.value}};function Fn(e,t,r){let n;return{success:!1,get error(){if(!n)n=new e(t.map((o)=>ae(o,r,H()))),t=void 0,r=void 0;return n},set error(o){n=o,t=void 0,r=void 0}}}var _t=(e)=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)i=await i;return i.issues.length?Fn(e,i.issues,o):{success:!0,data:i.value}};var iu=Symbol.for("zod.compile.invalid"),su=Symbol.for("zod.compile.fallback"),cr=(e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==iu)return!0;if(n.definite===!0&&r===void 0)return!1}return au(e,t,r)};function au(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,i;if(o)n[su]=!0,i=o({value:t,issues:[]},n);else i=e._zod.run({value:t,issues:[]},n);if(i instanceof Promise)throw new ce;return i.issues.length===0}var ur=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);if(o instanceof Promise)o=await o;return o.issues.length===0},Un=(e)=>{let t=xt(e),r=(n,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return t(n,o,a,bt(r,s))};return r};var qn=(e)=>{let t=xt(e),r=(n,o,i,s)=>t(n,o,i,bt(r,s));return r};var Vn=(e)=>{let t=vt(e),r=async(n,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(n,o,a,bt(r,s))};return r};var Gn=(e)=>{let t=vt(e),r=async(n,o,i,s)=>await t(n,o,i,bt(r,s));return r};var Jn=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return wt(e)(t,r,o)};var Kn=(e)=>(t,r,n)=>wt(e)(t,r,n);var Wn=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return _t(e)(t,r,o)};var Hn=(e)=>async(t,r,n)=>_t(e)(t,r,n);var Yn=/^[cC][0-9a-z]{6,}$/,Xn=/^[0-9a-z]+$/,Qn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,eo=/^[0-9a-vA-V]{20}$/,to=/^[A-Za-z0-9]{27}$/,ro=/^[a-zA-Z0-9_-]{21}$/;function no(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var oo=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var io=/^([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})$/,dr=(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 so=/^(?:[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 cu="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function ao(){return new RegExp(cu,"u")}var co=/^(?:(?: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])$/,uo=/^(([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 lo=/^((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])$/,po=/^(([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])$/,fo=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,mo=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var ho=/^https?$/,go=/^\+[1-9]\d{6,14}$/;var yo="(?:(?:\\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 uu(e){return new RegExp(`^${e}$`)}var bo=uu(yo);function lr(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 xo(e){return new RegExp(`^${lr(e)}$`)}function vo(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${lr({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${lr({precision:e.precision})}`:r;return new RegExp(`^${yo}T(?:${n})$`)}var wo=/^[\s\S]{0,}$/;var pr=/^-?\d+$/,Ge=/^-?\d+(?:\.\d+)?$/,_o=/^(?:true|false)$/i;var ko=/^[^A-Z]*$/,zo=/^[^a-z]*$/;var B=f("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var fr=(e)=>{let t=e.value;return!xn(t)&&t.length!==void 0},kt={number:"number",bigint:"bigint",object:"date"},mr=f("$ZodCheckLessThan",(e,t)=>{B.init(e,t);let r=kt[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:kt[typeof n.value]??r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hr=f("$ZodCheckGreaterThan",(e,t)=>{B.init(e,t);let r=kt[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:kt[typeof n.value]??r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$o=f("$ZodCheckMultipleOf",(e,t)=>{B.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):vn(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})}}),So=f("$ZodCheckNumberFormat",(e,t)=>{B.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,i]=ft[t.format];e._zod.check=(s)=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});else s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}if(a<o)s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort});if(a>i)s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var Po=f("$ZodCheckMaxLength",(e,t)=>{var r;B.init(e,t),(r=e._zod.def).when??(r.when=fr),e._zod.check=(n)=>{let o=n.value,i=o.length;if((typeof o==="string"&&i>t.maximum?ht(o):i)<=t.maximum)return;let a=gt(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Zo=f("$ZodCheckMinLength",(e,t)=>{var r;B.init(e,t),(r=e._zod.def).when??(r.when=fr),e._zod.check=(n)=>{let o=n.value,i=o.length;if((typeof o==="string"&&i>=t.minimum&&i<t.minimum*2?ht(o):i)>=t.minimum)return;let a=gt(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Io=f("$ZodCheckLengthEquals",(e,t)=>{var r;B.init(e,t),(r=e._zod.def).when??(r.when=fr),e._zod.check=(n)=>{let o=n.value,i=o.length,s=typeof o==="string"&&i>=t.length&&i<=t.length*2?ht(o):i;if(s===t.length)return;let a=gt(o),c=s>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ke=f("$ZodCheckStringFormat",(e,t)=>{var r,n;if(B.init(e,t),t.pattern)(r=e._zod).check??(r.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(n=e._zod).check??(n.check=()=>{})}),Eo=f("$ZodCheckRegex",(e,t)=>{Ke.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})}}),Oo=f("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ko),Ke.init(e,t)}),Co=f("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zo),Ke.init(e,t)}),Ao=f("$ZodCheckIncludes",(e,t)=>{B.init(e,t);let r=Ie(t.includes),n=new RegExp(typeof t.position==="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=(o)=>{if(o.value.includes(t.includes,t.position))return;o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),No=f("$ZodCheckStartsWith",(e,t)=>{B.init(e,t);let r=new RegExp(`^${Ie(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.startsWith(t.prefix))return;n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),To=f("$ZodCheckEndsWith",(e,t)=>{B.init(e,t);let r=new RegExp(`.*${Ie(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.endsWith(t.suffix))return;n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var Ro=f("$ZodCheckOverwrite",(e,t)=>{B.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class gr{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
|
-
`).filter((i)=>i),n=Math.min(...r.map((i)=>i.length-i.trimStart().length)),o=r.map((i)=>i.slice(n)).map((i)=>" ".repeat(this.indent*2)+i);for(let i of o)this.content.push(i)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
3
|
-
${t.join(`
|
|
4
|
-
`)}
|
|
5
|
-
};`)(...Object.values(this.closed))}}var Lo={major:4,minor:6,patch:5};var N=f("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Lo;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,c,u)=>{if(a.memo)return a;let l=se(a),d;for(let p of c){if(p._zod.def.when){if(En(a))continue;if(!p._zod.def.when(a))continue}else if(l)continue;let m=a.issues.length,h=p._zod.check(a);if(h instanceof Promise&&u?.async===!1)throw new ce;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await h,a.issues.length===m)return;if(or(a.issues,m,e),!l)l=se(a,m)});else{if(a.issues.length===m)continue;if(or(a.issues,m,e),!l)l=se(a,m)}}if(d)return d.then(()=>a);return a},s=(a,c,u)=>{if(se(a))return a.aborted=!0,a;let l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new ce;return l.then((d)=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(l instanceof Promise)return l.then((d)=>s(d,a,c));return s(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new ce;return u.then((l)=>i(l,o,c))}return i(u,o,c)}}},{get "~standard"(){return yt(this,"~standard",br(this))},set "~standard"(e){pe(this,"~standard",e)}}),Wo=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>ae(r,t,H()))}:{value:e.value};async function lu(e,t){let r={async:!0};return Wo(await e._zod.run({value:t,issues:[]},r),r)}function br(e){return{validate:(t)=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Wo(n,r)}catch(n){}return lu(e,t)},vendor:"zod",version:1}}var Pt=f("$ZodString",(e,t)=>{N.init(e,t),e._zod.pattern=t.pattern??wo,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(o){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),C=f("$ZodStringFormat",(e,t)=>{Ke.init(e,t),Pt.init(e,t)}),Ho=f("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=io),C.init(e,t)}),Yo=f("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=dr(n))}else t.pattern??(t.pattern=dr());C.init(e,t)}),Xo=f("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=so),C.init(e,t)}),Qo=1,$t=2;function ei(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function du(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return ei(e)||$t;return pu(e,t)}function pu(e,t){if(!t.normalize&&t.protocol?.source===ho.source&&!/^https?:\/\//i.test(e))return Qo;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??$t}return new URL(e)}catch{return $t}}var fu=/[\t\n\r]/g;function Do(e){return e.replace(fu,"")}function mu(e,t){return t.lastIndex=0,t.test(e.hostname)}function hu(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var ti=f("$ZodURL",(e,t)=>{C.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=du(n,t);if(o===Qo){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===$t){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Do(n);return}if(t.hostname&&!mu(o,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&&!hu(o,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?o.href:Do(n);return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ri=f("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ao()),C.init(e,t)}),ni=f("$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?ro:no(t.length)),C.init(e,t)}),oi=f("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Yn),C.init(e,t)}),ii=f("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Xn),C.init(e,t)}),si=f("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Qn),C.init(e,t)}),ai=f("$ZodXID",(e,t)=>{t.pattern??(t.pattern=eo),C.init(e,t)}),ci=f("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=to),C.init(e,t)}),ui=f("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=vo(t)),C.init(e,t)}),li=f("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=bo),C.init(e,t)}),di=f("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=xo(t)),C.init(e,t)}),pi=f("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=oo),C.init(e,t)}),fi=f("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=co),C.init(e,t)}),gu=/^[0-9a-fA-F:.]+$/;function mi(e){if(!gu.test(e))return!1;return ei(`http://[${e}]`)}var hi=f("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=uo),C.init(e,t),e._zod.check=(r)=>{if(!mi(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var gi=f("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=lo),C.init(e,t)});function yu(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);if(`${o}`!==n)return!1;if(o<0||o>128)return!1;return mi(r)}var yi=f("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=po),C.init(e,t),e._zod.check=(r)=>{if(!yu(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function bi(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 xr=/^[0-9a-zA-Z+/]*={0,2}$/,xi=f("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=xr),C.init(e,t),e._zod.check=(r)=>{if(bi(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),Zt=/^[A-Za-z0-9_-]*$/;function bu(e){if(!Zt.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return bi(r)}var vi=f("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Zt),C.init(e,t),e._zod.check=(r)=>{if(bu(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),wi=f("$ZodE164",(e,t)=>{t.pattern??(t.pattern=go),C.init(e,t)});function xu(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&(!("alg"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var _i=f("$ZodJWT",(e,t)=>{C.init(e,t),e._zod.check=(r)=>{if(xu(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var vr=f("$ZodNumber",(e,t)=>{N.init(e,t),e._zod.pattern=Ge,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(s){}let o=r.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?String(o):void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),ki=f("$ZodNumberFormat",(e,t)=>{So.init(e,t),vr.init(e,t)}),zi=f("$ZodBoolean",(e,t)=>{N.init(e,t),e._zod.pattern=_o,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(i){}let o=r.value;if(typeof o==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var $i=f("$ZodUnknown",(e,t)=>{N.init(e,t),e._zod.parse=(r)=>r}),Si=f("$ZodNever",(e,t)=>{N.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function jo(e,t,r){if(e.issues.length)t.issues.push(...ye(r,e.issues));t.value[r]=e.value}var Pi=f("$ZodArray",(e,t)=>{N.init(e,t);let r=G.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=r?r.alloc(e,n,Array(i.length),o):Array(i.length);let s=[],a=o?.abortEarly;for(let c=0;c<i.length;c++){let u=i[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)s.push(l.then((d)=>jo(d,n,c)));else if(jo(l,n,c),a&&l.issues.length!==0&&se(l))break}if(s.length)return Promise.all(s).then(()=>n);return n}});function St(e,t,r,n,o,i){let s=r in n,a=i==="optional";if(!s&&a&&o==="optional")return;if(e.issues.length){if(o!==void 0&&a&&!s)return;t.issues.push(...ye(r,e.issues))}if(!s&&o===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(s||o==="defaulted"&&!a)t.value[r]=void 0}else t.value[r]=e.value}var vu=[];function Zi(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:vu,o=n.length?[...t,...n]:t;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=Pn(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Ii(e,t,r,n,o,i,s){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,{optin:d,optout:p}=u,m=0;for(let h in t){if(s&&r.issues.length!==m){if(se(r,m))break;m=r.issues.length}if(c.has(h))continue;if(h==="__proto__"){if(l==="never")a.push(h);continue}if(l==="never"){a.push(h);continue}let x=u.run({value:t[h],issues:[]},n);if(x instanceof Promise)e.push(x.then((w)=>St(w,r,h,t,d,p)));else St(x,r,h,t,d,p)}if(a.length)r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var wu=f("$ZodObject",(e,t)=>{N.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=lt(()=>Zi(t));I(e,"propValues",(u)=>{let l=u.def.shape,d={};for(let p in l){let m=l[p]._zod;if(m.values){if(!Object.prototype.hasOwnProperty.call(d,p))te(d,p,new Set);for(let h of m.values)d[p].add(h);if(m.optin!==void 0)d[p].add(void 0)}}return d});let i=Fe,s=t.catchall,a,c=G.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!i(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let p=[],m=a.shape,h=l?.abortEarly,x=u.issues.length;for(let w of a.allKeys){if(h&&u.issues.length!==x){if(se(u,x))break;x=u.issues.length}if(w==="__proto__")continue;let S=m[w],P=S._zod.optin,L=S._zod.optout,V=S._zod.run({value:d[w],issues:[]},l);if(V instanceof Promise)p.push(V.then((z)=>St(z,u,w,d,P,L)));else St(V,u,w,d,P,L)}if(!s)return p.length?Promise.all(p).then(()=>u):u;return Ii(p,d,u,l,o.value,e,h===!0)}}),Ei=f("$ZodObjectJIT",(e,t)=>{wu.init(e,t);let r=e._zod.parse,n=lt(()=>Zi(t)),o=G.memoizer,i=(m)=>{let h=n.value,x=h.symbolKeys,w=new gr(["payload","ctx"],{shape:m,inst:e,memo:o,syms:x}),S=(z)=>`shape[${z}]._zod.run({ value: input[${z}], issues: [] }, ctx)`,P=(z,k)=>`
|
|
6
|
-
let ${z}_ab = false;
|
|
7
|
-
for (let i = 0; i < ${z}.issues.length; i++) {
|
|
8
|
-
const iss = ${z}.issues[i];
|
|
9
|
-
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
10
|
-
payload.issues.push(iss);
|
|
11
|
-
if (iss.continue !== true) ${z}_ab = true;
|
|
12
|
-
}
|
|
13
|
-
if (${z}_ab && ctx && ctx.abortEarly) {
|
|
14
|
-
payload.value = newResult;
|
|
15
|
-
return payload;
|
|
16
|
-
}`;w.write("const input = payload.value;");let L=Object.create(null),V=0;for(let z of h.allKeys)L[z]=`key_${V++}`;w.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let z of h.allKeys){if(z==="__proto__")continue;let k=L[z],Z=typeof z==="symbol"?`syms[${x.indexOf(z)}]`:kn(z),K=`${Z} in input`,F=m[z],X=F?._zod?.optin,le=X!==void 0,at=F?._zod?.optout==="optional";if(w.write(`const ${k} = ${S(Z)};`),le&&at){let ct=X==="optional"?`${k}_present`:`${k}.value !== undefined || ${k}_present`;w.write(`
|
|
17
|
-
const ${k}_present = ${K};
|
|
18
|
-
if (!${k}.issues.length || ${k}_present) {
|
|
19
|
-
if (${k}.issues.length) {${P(k,Z)}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (${ct}) {
|
|
23
|
-
newResult[${Z}] = ${k}.value;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
`)}else if(!le)w.write(`
|
|
28
|
-
const ${k}_present = ${K};
|
|
29
|
-
if (${k}.issues.length) {${P(k,Z)}
|
|
30
|
-
}
|
|
31
|
-
if (!${k}_present && !${k}.issues.length) {
|
|
32
|
-
payload.issues.push({
|
|
33
|
-
code: "invalid_type",
|
|
34
|
-
expected: "nonoptional",
|
|
35
|
-
input: undefined,
|
|
36
|
-
path: [${Z}]
|
|
37
|
-
});
|
|
38
|
-
if (ctx && ctx.abortEarly) {
|
|
39
|
-
payload.value = newResult;
|
|
40
|
-
return payload;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (${k}_present) {
|
|
45
|
-
newResult[${Z}] = ${k}.value;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
`);else if(w.write(`
|
|
49
|
-
if (${k}.issues.length) {${P(k,Z)}
|
|
50
|
-
}
|
|
51
|
-
`),X==="defaulted")w.write(`newResult[${Z}] = ${k}.value;`);else w.write(`
|
|
52
|
-
if (${k}.value !== undefined || ${K}) {
|
|
53
|
-
newResult[${Z}] = ${k}.value;
|
|
54
|
-
}
|
|
55
|
-
`)}return w.write("payload.value = newResult;"),w.write("return payload;"),w.compile()},s,a=Fe,c=!G.jitless,l=c&&$n.value,d=t.catchall,p;e._zod.parse=(m,h)=>{p??(p=n.value);let x=m.value;if(!a(x))return m.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),m;if(c&&l&&h?.async===!1&&h.jitless!==!0){if(!s)s=i(t.shape);if(m=s(m,h),!d)return m;return Ii([],x,m,h,p,e,h?.abortEarly===!0)}return r(m,h)}});function Bo(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter((i)=>!se(i));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>ae(s,n,H())))}),t}var Oi=f("$ZodUnion",(e,t)=>{N.init(e,t),I(e,"optin",(n)=>n.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),I(e,"optout",(n)=>n.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),I(e,"values",(n)=>{if(n.def.options.every((o)=>o._zod.values))return new Set(n.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),I(e,"pattern",(n)=>{if(n.def.options.every((o)=>o._zod.pattern)){let o=n.def.options.map((i)=>i._zod.pattern);return new RegExp(`^(${o.map((i)=>dt(i.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return Bo(s,n,e,o);return Promise.all(s).then((a)=>Bo(a,n,e,o))}});var Ci=f("$ZodIntersection",(e,t)=>{N.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,i=t.left._zod.run({value:o,issues:[]},n),s=t.right._zod.run({value:o,issues:[]},n);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>Fo(r,c,u));return Fo(r,i,s)}});function yr(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(we(e)&&we(t)){let r=Object.keys(t),n=Object.keys(e).filter((i)=>r.indexOf(i)!==-1),o={...e,...t};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let i of n){if(i==="__proto__")continue;let s=yr(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],i=t[n],s=yr(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Fo(e,t,r){let n=new Map,o,i=new Map,s=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let p=String(u.path[0]);if(!i.has(p))i.set(p,u);d=[p]}else return!1;for(let p of d){if(!n.has(p))n.set(p,{});n.get(p)[l]=!0}return!0};for(let u of t.issues)if(!s(u,"l"))e.issues.push(u);for(let u of r.issues)if(!s(u,"r"))e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter((l)=>o.keys.includes(l)):[];if(u.length)e.issues.push({...o,keys:u});for(let l of a)if(!u.includes(l)&&i.has(l))e.issues.push(i.get(l))}let c=yr(t.value,r.value);if(!c.valid){if(se(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Ai=f("$ZodRecord",(e,t)=>{N.init(e,t);let r=G.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!we(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;let s=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(c.add(typeof l==="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((h)=>ae(h,o,H())),input:l,path:[l],inst:e});continue}let p=d.value;if(p==="__proto__")continue;let m=t.valueType._zod.run({value:i[l],issues:[]},o);if(m instanceof Promise)s.push(m.then((h)=>{if(h.issues.length)n.issues.push(...ye(l,h.issues));n.value[p]=h.value}));else{if(m.issues.length)n.issues.push(...ye(l,m.issues));n.value[p]=m.value}}let u;for(let l in i)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=i[l]}else u=u??[],u.push(l);if(u&&u.length>0)n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(i)){if(u==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof u==="string"&&Ge.test(u)&&l.issues.length){let h=t.keyType._zod.run({value:Number(u),issues:[]},o);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length===0)l=h}if(l.issues.length){if(t.mode==="loose")n.value[u]=i[u];else if(a)c=c??[],c.push(u);else n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((h)=>ae(h,o,H())),input:u,path:[u],inst:e});continue}let p=l.value;if(p==="__proto__")continue;let m=t.valueType._zod.run({value:i[u],issues:[]},o);if(m instanceof Promise)s.push(m.then((h)=>{if(h.issues.length)n.issues.push(...ye(u,h.issues));n.value[p]=h.value}));else{if(m.issues.length)n.issues.push(...ye(u,m.issues));n.value[p]=m.value}}if(c&&c.length>0)n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}if(s.length)return Promise.all(s).then(()=>n);return n}});var Ni=f("$ZodEnum",(e,t)=>{N.init(e,t);let r=Ue(t.entries),n=new Set(r);e._zod.values=n,I(e,"pattern",(o)=>{let i=Ue(o.def.entries).filter((s)=>Sn.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>Ie(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let s=o.value;if(n.has(s))return o;return o.issues.push({code:"invalid_value",values:r,input:s,inst:e}),o}});var Ti=f("$ZodTransform",(e,t)=>{N.init(e,t),e._zod.optin="optional",G.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ve(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then((s)=>(r.value=s,r));if(o instanceof Promise)throw new ce;return r.value=o,r}});function Uo(e,t){return e.value=t.issues.length?void 0:t.value,e}var wr=f("$ZodOptional",(e,t)=>{N.init(e,t),I(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",I(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),I(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${dt(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((i)=>Uo(r,i));return Uo(r,o)}return t.innerType._zod.run(r,n)}}),Ri=f("$ZodExactOptional",(e,t)=>{wr.init(e,t),I(e,"values",(r)=>r.def.innerType._zod.values),I(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Mi=f("$ZodNullable",(e,t)=>{N.init(e,t),I(e,"optin",(r)=>r.def.innerType._zod.optin),I(e,"optout",(r)=>r.def.innerType._zod.optout),I(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${dt(n.source)}|null)$`):void 0}),I(e,"values",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),Li=f("$ZodDefault",(e,t)=>{N.init(e,t),e._zod.optin="defaulted",I(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>qo(i,t));return qo(o,t)}});function qo(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Di=f("$ZodPrefault",(e,t)=>{N.init(e,t),e._zod.optin="defaulted",I(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),ji=f("$ZodNonOptional",(e,t)=>{N.init(e,t),I(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>Vo(i,e));return Vo(o,e)}});function Vo(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 Go(e,t,r,n){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((o)=>ae(o,n,H()))},input:e.value}),e}var Bi=f("$ZodCatch",(e,t)=>{N.init(e,t),I(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),I(e,"optout",(r)=>r.def.innerType._zod.optout),I(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((i)=>Go(r,i,t,n));return Go(r,o,t,n)}});var Fi=f("$ZodPipe",(e,t)=>{N.init(e,t),I(e,"values",(r)=>r.def.in._zod.values),I(e,"optin",(r)=>r.def.in._zod.optin),I(e,"optout",(r)=>r.def.out._zod.optout),I(e,"propValues",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let i=t.out._zod.run(r,n);if(i instanceof Promise)return i.then((s)=>zt(s,t.in,n));return zt(i,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>zt(i,t.out,n));return zt(o,t.out,n)}});function zt(e,t,r){if(e.issues.some((n)=>n.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var Ui=f("$ZodReadonly",(e,t)=>{N.init(e,t),I(e,"propValues",(r)=>r.def.innerType._zod.propValues),I(e,"values",(r)=>r.def.innerType._zod.values),I(e,"optin",(r)=>r.def.innerType?._zod?.optin),I(e,"optout",(r)=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then(Jo);return Jo(o)}});function Jo(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var qi=f("$ZodCustom",(e,t)=>{B.init(e,t),N.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then((i)=>Ko(i,r,n,e));Ko(o,r,n,e);return}});function Ko(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)o.params=n._zod.def.params;t.issues.push(_e(o))}}class Gi extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var kr="~memo",Vi=[];function Ji(e){return e!==null&&typeof e==="object"}function _r(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Ki=new WeakMap,We=0,Ot=1,He=2;function Ct(e,t,r){let n=Ki.get(e);if(n!==void 0)return n?He:We;if(t.has(e))return He;t.add(e);let o=We,i=(l)=>{if(o!==He&&l?._zod){let d=Ct(l,t,r);if(d>o)o=d}},s=(l,d)=>{let p=We;for(let m of Reflect.ownKeys(l)){let h=Object.getOwnPropertyDescriptor(l,m);if(d&&!h.enumerable)continue;let x=h.get?Ot:h.value?._zod?Ct(h.value,t,r):We;if(x>p)p=x}return p},a=(l)=>{if(l>o)o=l},c=e._zod.def,u=c.type;switch(u){case"object":{let l=pt(c);a(l?s(l,!0):Ot),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(let l of c.items)i(l);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(let l of c.options)i(l);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?Ct(l,t,!1):Ot);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 l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let p=d.value;if(!p||typeof p!=="object")continue;if(p._zod)i(p);else if(Array.isArray(p))for(let m of p)i(m)}}return t.delete(e),_u(e,o)}function _u(e,t){if(t!==Ot)Ki.set(e,t===He);return t}function ku(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var It,Et=[],zu={alloc(e,t,r){let n=It;if(!n)return r;It=void 0;let o={value:r,issues:null};return n.set(t.value,o),Et.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,i)=>{if(i.direction!=="backward"&&$u(i,o.value))throw new Gi;return r(o,i)};if(e._zod.parse=n,e._zod.run===r)e._zod.run=n})},attach(e){var t;let r,n=!1,o,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,a=(c,u)=>{if(r===void 0){let S=Ct(e,new Set,!1);if(S===We){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(c,u)}if(S===He||n)r=!0;else n=!0}let l=c.value;if(!Ji(l))return s(c,u);let d=u[kr];if(!d)d={buckets:new WeakMap,backEdges:void 0},u[kr]=d;let p;if(o===u)p=i;else p=ku(d,e),o=u,i=p;let m=p.get(l);if(m){if(c.value=m.value,m.issues){if(m.issues.length)c.issues.push(..._r(m.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(m.value);return c}It=p;let h=Et.length,x=s(c,u);It=void 0;let w=Et.length>h?Et.pop():void 0;if(x instanceof Promise)return x.then((S)=>{if(w)w.issues=S.issues.length?_r(S.issues):Vi;return S});if(w)w.issues=x.issues.length?_r(x.issues):Vi;return x};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function Wi(){return zu}function $u(e,t){let r=e[kr]?.backEdges;return r!==void 0&&Ji(t)&&r.has(t)}var Su=()=>{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(i){return e[i]??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"},n={nan:"NaN"};function o(i,s){if(i==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return n[i]??i}return(i)=>{switch(i.code){case"invalid_type":{let s=o(i.expected),a=On(i.input),c=o(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${rr(i.values[0])}`;return`Invalid option: expected one of ${Qt(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=t(i.origin);if(a)return`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=t(i.origin);if(a)return`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`;return`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${r[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Qt(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":if(i.options&&Array.isArray(i.options)&&i.options.length>0)return`Invalid discriminator value. Expected ${i.options.map((a)=>`'${a}'`).join(" | ")}`;if(i.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function zr(){return{localeError:Su()}}var Hi;class Yi{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 n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Pu(){return new Yi}(Hi=globalThis).__zod_globalRegistry??(Hi.__zod_globalRegistry=Pu());var ke=globalThis.__zod_globalRegistry;function Xi(e){if(e.checks)e.checks=[...e.checks];return e}function Qi(e,t){return new e(Xi({type:"string",...v(t)}))}function es(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...v(t)})}function ts(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...v(t)})}function $r(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...v(t)})}function rs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...v(t)})}function ns(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...v(t)})}function os(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...v(t)})}function Sr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...v(t)})}function is(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...v(t)})}function ss(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...v(t)})}function as(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...v(t)})}function cs(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...v(t)})}function us(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...v(t)})}function ls(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...v(t)})}function ds(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...v(t)})}function ps(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...v(t)})}function fs(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...v(t)})}function ms(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...v(t)})}function hs(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...v(t)})}function gs(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...v(t)})}function ys(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...v(t)})}function bs(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...v(t)})}function xs(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...v(t)})}function vs(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...v(t)})}function ws(e,t){return new e({type:"string",format:"date",check:"string_format",...v(t)})}function _s(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...v(t)})}function ks(e,t){return new e({type:"string",format:"duration",check:"string_format",...v(t)})}function zs(e,t){return new e(Xi({type:"number",checks:[],...v(t)}))}function $s(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...v(t)})}function Ss(e,t){return new e({type:"boolean",...v(t)})}function Ps(e){return new e({type:"unknown"})}function Zs(e,t){return new e({type:"never",...v(t)})}function At(e,t){return new mr({check:"less_than",...v(t),value:e,inclusive:!1})}function Ye(e,t){return new mr({check:"less_than",...v(t),value:e,inclusive:!0})}function Nt(e,t){return new hr({check:"greater_than",...v(t),value:e,inclusive:!1})}function Xe(e,t){return new hr({check:"greater_than",...v(t),value:e,inclusive:!0})}function Tt(e,t){return new $o({check:"multiple_of",...v(t),value:e})}function Rt(e,t){return new Po({check:"max_length",...v(t),maximum:e})}function Ee(e,t){return new Zo({check:"min_length",...v(t),minimum:e})}function Mt(e,t){return new Io({check:"length_equals",...v(t),length:e})}function Pr(e,t){return new Eo({check:"string_format",format:"regex",...v(t),pattern:e})}function Zr(e){return new Oo({check:"string_format",format:"lowercase",...v(e)})}function Ir(e){return new Co({check:"string_format",format:"uppercase",...v(e)})}function Er(e,t){return new Ao({check:"string_format",format:"includes",...v(t),includes:e})}function Or(e,t){return new No({check:"string_format",format:"starts_with",...v(t),prefix:e})}function Cr(e,t){return new To({check:"string_format",format:"ends_with",...v(t),suffix:e})}function be(e){return new Ro({check:"overwrite",tx:e})}function Ar(e){return be((t)=>t.normalize(e))}function Nr(){return be((e)=>e.trim())}function Tr(){return be((e)=>e.toLowerCase())}function Rr(){return be((e)=>e.toUpperCase())}function Mr(){return be((e)=>zn(e))}function Is(e,t,r){return new e({type:"array",element:t,...v(r)})}function Es(e,t,r){return new e({type:"custom",check:"custom",fn:t,...v(r)})}function Os(e,t){let r=Zu((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(_e(o,n.value,r._zod.def));else{let i=o;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=n.value;i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),n.issues.push(_e(i))}},e(n.value,n)),t);return r}function Zu(e,t){let r=new B({check:"custom",...v(t)});return r._zod.check=e,r}function Qe(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))te(e,n,r[n]);return e}function Dr(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??ke,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 ze(e,t,r,n,o){let i=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw Error(o);return Object.assign(r,i),!0}function M(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,r.schemaPath.includes(e))i.cycle=r.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{let p=s.schema,m=t.processors[o.type];if(!m)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(e,t,p,l)}let d=e._zod.parent;if(d){if(!s.ref)s.ref=d;M(d,t,l),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Qe(s.schema,c);if(t.io==="input"&&U(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(n=s.schema).default??(n.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function Cs(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function jr(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 n=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=n.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,s[0])}}let o=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(s[0])?.id,p=e.external.uri??((h)=>h);if(d)return{ref:p(d)};let m=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=m,{defId:m,ref:`${p("__shared")}#/${a}/${Cs(m)}`}}let c="#",u=`${c}/${a}/`;if(s[1]===r&&!s[1].schema.id)return{ref:c};let l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Cs(l)}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=o(s);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
56
|
-
|
|
57
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref")i(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Ts(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!=="object")return;Ts(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let i=n.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!r.includes(s))r.push(s)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Rs=new Set(["type","properties","required","additionalProperties"]),As=["oneOf","anyOf"];function Ns(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 Lr(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!Rs.has(s))return null;t.push(i)}let r={},n=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(r,s))continue;let a=[];for(let u of t){let l=u.properties?.[s]??Ns(u);if(l===null||l===void 0)continue;if(!a.some((d)=>JSON.stringify(d)===JSON.stringify(l)))a.push(l)}let c=a.length===1?a[0]:Lr(a)??{allOf:a};te(r,s,c)}for(let s of i.required??[])n.add(s)}let o={type:"object",properties:r};if(n.size)o.required=[...n];if(t.every((i)=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of t){let a=Ns(s);if(a&&!i.some((c)=>JSON.stringify(c)===JSON.stringify(a)))i.push(a)}if(i.length===1)o.additionalProperties=i[0];else if(i.length>1)o.additionalProperties={allOf:i}}return o}function Iu(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Rs)if(o in e)return;let r=t.filter((o)=>As.some((i)=>Array.isArray(o[i]))),n=null;if(!r.length)n=Lr(t);else{let o=r[0],i=As.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let s=t.filter((c)=>c!==o),a=o[i].map((c)=>Lr([...s,c]));if(a.some((c)=>!c))return;n={[i]:a}}if(!n)return;delete e.allOf,Qe(e,n)}function Br(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let m=e.seen.get(d),h=m.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(h);else Qe(u,h);if(Qe(u,l),a._zod.parent===d)for(let w in u){if(w==="$ref"||w==="allOf")continue;if(!(w in l))delete u[w]}if(h.$ref&&m.def)for(let w in u){if(w==="$ref"||w==="allOf")continue;if(w in m.def&&JSON.stringify(u[w])===JSON.stringify(m.def[w]))delete u[w]}}let p=a._zod.parent;if(p&&p!==d){n(p);let m=e.seen.get(p);if(m?.schema.$ref){if(u.$ref=m.schema.$ref,m.def)for(let h in u){if(h==="$ref"||h==="allOf")continue;if(h in m.def&&JSON.stringify(u[h])===JSON.stringify(m.def[h]))delete u[h]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Ts(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);if(d)d.push(u);else a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])Iu(u)}}let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Qe(o,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&o.id===i)delete o.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;te(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")o.$defs=s;else o.definitions=s;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:et(t,"input",e.processors),output:et(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){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 n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return U(n.element,r);if(n.type==="set")return U(n.valueType,r);if(n.type==="lazy")return U(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return U(n.innerType,r);if(n.type==="intersection")return U(n.left,r)||U(n.right,r);if(n.type==="record"||n.type==="map")return U(n.keyType,r)||U(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return U(n.in,r)||U(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(U(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(U(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(U(o,r))return!0;if(n.rest&&U(n.rest,r))return!0;return!1}return!1}var Ms=(e,t={})=>(r)=>{let n=Dr({...r,processors:t});return M(e,n),jr(n,e),Br(n,e)},et=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:i}=n??{},s=Dr({...o??{},target:i,io:t,processors:r});return M(e,s),jr(s,e),Br(s,e)};var Oe=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},Ce=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},Ls=(e,t)=>{Oe(e,"minimum",t),Ce(e,"maximum",t)},Fs=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Us=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},qs=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},Vs=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Ds=(e,t)=>Oe(e,"minimum",t.minimum),js=(e,t)=>Ce(e,"maximum",t.maximum),Bs=(e)=>(t,r)=>{Vs(t,r.format);let[n,o]=e[r.format];Oe(t,"minimum",n),Ce(t,"maximum",o)},Eu={greater_than:(e,t)=>Oe(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Ce(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Fs(e,t.value),number_format:Bs(ft),bigint_format:Bs(nr),min_length:Ds,max_length:js,length_equals:(e,t)=>Ls(e,t.length),min_size:Ds,max_size:js,size_equals:(e,t)=>Ls(e,t.size),string_format:(e,t)=>{if(Vs(e,t.format),t.pattern)Us(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)=>qs(e,t.mime)};function Q(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of n)Eu[i._zod.def.check]?.(t,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)Oe(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)Oe(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)Ce(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)Ce(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)Fs(t,o.multipleOf);if(o.format!==void 0){if(t.format??(t.format=o.format),o.format.includes("int"))t.isInt=!0}if(o.mime)qs(t,o.mime);for(let i of o.patterns??[])Us(t,i);return t}var Ou={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Cu=new Map([[xr,fo],[Zt,mo]]),Gs=(e)=>Cu.get(e)??e,Js=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:l}=Q(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=Ou[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(u)o.contentEncoding=u;if(c&&c.size>0){let d=[...c].map(Gs);if(d.length===1)o.pattern=d[0].source;else if(d.length>1)o.allOf=[...d.map((p)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))]}},Ks=(e,t,r,n)=>{let o=r,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=Q(e);o.type=l?"integer":"number";let d=typeof u==="number"&&u>=(i??Number.NEGATIVE_INFINITY),p=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(m)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof i==="number")o.minimum=i;if(p)if(m)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof s==="number")o.maximum=s;if(a){let h=new Set;for(let S of a)if(Number.isFinite(S)&&S!==0)h.add(Math.abs(S));else ze(e,t,o,n,`A multipleOf divisor of ${S} cannot be represented in JSON Schema`);let[x,...w]=h;if(x!==void 0)o.multipleOf=x;if(w.length)o.allOf=[...o.allOf??[],...w.map((S)=>({multipleOf:S}))]}},Ws=(e,t,r,n)=>{r.type="boolean"};var Hs=(e,t,r,n)=>{r.not={}};var Ys=(e,t,r,n)=>{};var Xs=(e,t,r,n)=>{let o=e._zod.def,i=Ue(o.entries);if(i.length===0){r.not={};return}if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";r.enum=i};var Qs=(e,t,r,n)=>{ze(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var ea=(e,t,r,n)=>{ze(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var ta=(e,t,r,n)=>{let o=r,i=e._zod.def,{minimum:s,maximum:a}=Q(e);if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=M(i.element,t,{...n,path:[...n.path,"items"]})};function Lt(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Lt(t.out);if(t.type==="catch")return Lt(t.innerType);return e._zod.optin}var ra=(e,t,r,n)=>{let o=r,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&ze(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in s)te(o.properties,u,M(s[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(s)){let l=i.shape[u];if(t.io==="input"?Lt(l)===void 0:l._zod.optout===void 0)c.push(u)}if(c.length>0)o.required=c;if(i.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=M(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},na=(e,t,r,n)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>M(a,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));if(i)r.oneOf=s;else r.anyOf=s},oa=(e,t,r,n)=>{let o=e._zod.def,i=M(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=M(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=c,t.intersections.push(c)};function Fr(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let h=e.get(t)?.def;if(!h)return t;let x=Fr(e,h,r);return x===h?t:x}for(let h of["anyOf","oneOf"]){let x=t[h];if(!Array.isArray(x))continue;let w=x.map((S)=>Fr(e,S,r));if(w.some((S,P)=>S!==x[P]))t={...t,[h]:w}}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some((h)=>h==="number"||h==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!i?.some((h)=>typeof h==="number"))return t;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:p,...m}=t;if(m.enum)m.enum=m.enum.map((h)=>typeof h==="number"?String(h):h);else if(typeof m.const==="number")m.const=String(m.const);if(!o)return m;if(m.type="string",!i)m.pattern=(n.includes("number")?Ge:pr).source;return m}var Ur=new WeakMap;function Au(e){let t=new Map;for(let n of e.seen.values())if(n.def&&!t.has(n.schema))t.set(n.schema,n);let r=new Map;for(let n of Ur.get(e)??[]){let o=e.seen.get(n),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let s=Fr(t,i,new Set);if(s!==i)r.set(i,s)}if(!r.size)return;for(let n of e.seen.values())for(let o of[n.schema,n.def]){let i=o&&r.get(o.propertyNames);if(i)o.propertyNames=i}}var ia=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object";let s=i.keyType,a=Q(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let l=M(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)te(o.patternProperties,Gs(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=M(i.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=Ur.get(t);if(!l)l=[],Ur.set(t,l),t.deferred.push(()=>Au(t));l.push(e)}o.additionalProperties=M(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=s._zod.values,u=t.io==="input"&&Lt(i.valueType)!==void 0;if(c&&!i.partial&&!u){let l=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(l.length>0)o.required=l.map(String)}},sa=(e,t,r,n)=>{let o=e._zod.def,i=M(o.innerType,t,n),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=o.innerType,r.nullable=!0;else r.anyOf=[i,{type:"null"}]},aa=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},qr=Symbol();function ca(e,t,r,n,o){let i=!1,s=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return i=!0,null});if(!i)return JSON.parse(s);return ze(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),qr}var ua=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s=ca(o.defaultValue,e,t,r,n);if(s!==qr)r.default=s},la=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;let s=ca(o.defaultValue,e,t,r,n);if(s!==qr)r._prefault=s},da=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{ze(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},pa=(e,t,r,n)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;M(s,t,n);let a=t.seen.get(e);a.ref=s},fa=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0};var Vr=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType};var ma=new WeakSet([Object.prototype,Error.prototype]);function Dt(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var Bu=(e,t)=>{Dn.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(ma.has(r))return;ma.add(r),Dt(r,"format",(n)=>(o)=>Bn(n,o)),Dt(r,"flatten",(n)=>(o)=>jn(n,o)),Dt(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,qe,2)}),Dt(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,qe,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Y=f("ZodError",Bu,void 0,{Parent:Error});var ha=xt(Y),ga=vt(Y),ya=wt(Y),ba=_t(Y),xa=Un(Y),va=qn(Y),wa=Vn(Y),_a=Gn(Y),ka=Jn(Y),za=Kn(Y),$a=Wn(Y),Sa=Hn(Y);function Uu(){if(!G.localeError)H(zr())}function jt(){if(!G.memoizer)H({memoizer:Wi()})}var R=f("ZodType",(e,t)=>(Uu(),N.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(W(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 ie(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Rl(e,t))},superRefine(e,t){return this.check(Ml(e,t))},overwrite(e){return this.check(be(e))},optional(){return Ea(this)},exactOptional(){return kl(this)},nullable(){return Oa(this)},nullish(){return Ea(Oa(this))},nonoptional(e){return Il(this,e)},array(){return j(this)},or(e){return bl([this,e])},and(e){return vl(this,e)},transform(e){return Ca(this,_l(e))},default(e){return Sl(this,e)},prefault(e){return Zl(this,e)},catch(e){return Ol(this,e)},pipe(e){return Ca(this,e)},readonly(){return Nl(this)},describe(e){let t=this.clone();return ke.add(t,{description:e}),t},meta(...e){if(e.length===0)return ke.get(this);let t=this.clone();return ke.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 yt(this,"~standard",{...br(this),jsonSchema:{input:et(this,"input"),output:et(this,"output")}})},set "~standard"(e){pe(this,"~standard",e)},parse:function e(t,r){return ha(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await ga(this,t,r,{callee:e})},safeParse(e,t){return ya(this,e,t)},async safeParseAsync(e,t){return ba(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){pe(this,"spa",e)},validate(e,t){return cr(this,e,t)},validateAsync(e,t){return ur(this,e,t)},encode:function e(t,r){return xa(this,t,r,{callee:e})},decode:function e(t,r){return va(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await wa(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await _a(this,t,r,{callee:e})},safeEncode(e,t){return ka(this,e,t)},safeDecode(e,t){return za(this,e,t)},async safeEncodeAsync(e,t){return $a(this,e,t)},async safeDecodeAsync(e,t){return Sa(this,e,t)},toJSONSchema(e){return Ms(this,{})(e)},get description(){return ke.get(this)?.description},get _def(){return this._zod.def}}),Aa=f("_ZodString",(e,t)=>{Pt.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Js(e,r,n,o)},An({format:(e)=>Q(e).format??null,minLength:(e)=>Q(e).minimum??null,maxLength:(e)=>Q(e).maximum??null},{regex(...e){return this.check(Pr(...e))},includes(...e){return this.check(Er(...e))},startsWith(...e){return this.check(Or(...e))},endsWith(...e){return this.check(Cr(...e))},min(...e){return this.check(Ee(...e))},max(...e){return this.check(Rt(...e))},length(...e){return this.check(Mt(...e))},nonempty(...e){return this.check(Ee(1,...e))},lowercase(e){return this.check(Zr(e))},uppercase(e){return this.check(Ir(e))},trim(){return this.check(Nr())},normalize(...e){return this.check(Ar(...e))},toLowerCase(){return this.check(Tr())},toUpperCase(){return this.check(Rr())},slugify(){return this.check(Mr())}})),qu=f("ZodString",(e,t)=>{Pt.init(e,t),Aa.init(e,t)},{email(e){return this.check(es(Wu,e))},url(e){return this.check(Sr(Na,e))},jwt(e){return this.check(xs(dl,e))},emoji(e){return this.check(is(Yu,e))},guid(e){return this.check(ts(Hu,e))},uuid(e){return this.check($r(tt,e))},uuidv4(e){return this.check(rs(tt,e))},uuidv6(e){return this.check(ns(tt,e))},uuidv7(e){return this.check(os(tt,e))},nanoid(e){return this.check(ss(Xu,e))},cuid(e){return this.check(as(Qu,e))},cuid2(e){return this.check(cs(el,e))},ulid(e){return this.check(us(tl,e))},base64(e){return this.check(gs(cl,e))},base64url(e){return this.check(ys(ul,e))},xid(e){return this.check(ls(rl,e))},ksuid(e){return this.check(ds(nl,e))},ipv4(e){return this.check(ps(ol,e))},ipv6(e){return this.check(fs(il,e))},cidrv4(e){return this.check(ms(sl,e))},cidrv6(e){return this.check(hs(al,e))},e164(e){return this.check(bs(ll,e))},datetime(e){return this.check(vs(Vu,e))},date(e){return this.check(ws(Gu,e))},time(e){return this.check(_s(Ju,e))},duration(e){return this.check(ks(Ku,e))}});function y(e){return Qi(qu,e)}var T=f("ZodStringFormat",(e,t)=>{C.init(e,t),Aa.init(e,t)}),Vu=f("ZodISODateTime",(e,t)=>{ui.init(e,t),T.init(e,t)}),Gu=f("ZodISODate",(e,t)=>{li.init(e,t),T.init(e,t)}),Ju=f("ZodISOTime",(e,t)=>{di.init(e,t),T.init(e,t)}),Ku=f("ZodISODuration",(e,t)=>{pi.init(e,t),T.init(e,t)}),Wu=f("ZodEmail",(e,t)=>{Xo.init(e,t),T.init(e,t)});var Hu=f("ZodGUID",(e,t)=>{Ho.init(e,t),T.init(e,t)});var tt=f("ZodUUID",(e,t)=>{Yo.init(e,t),T.init(e,t)});function Bt(e){return $r(tt,e)}var Na=f("ZodURL",(e,t)=>{ti.init(e,t),T.init(e,t)});function Kr(e){return Sr(Na,e)}var Yu=f("ZodEmoji",(e,t)=>{ri.init(e,t),T.init(e,t)});var Xu=f("ZodNanoID",(e,t)=>{ni.init(e,t),T.init(e,t)});var Qu=f("ZodCUID",(e,t)=>{oi.init(e,t),T.init(e,t)});var el=f("ZodCUID2",(e,t)=>{ii.init(e,t),T.init(e,t)});var tl=f("ZodULID",(e,t)=>{si.init(e,t),T.init(e,t)});var rl=f("ZodXID",(e,t)=>{ai.init(e,t),T.init(e,t)});var nl=f("ZodKSUID",(e,t)=>{ci.init(e,t),T.init(e,t)});var ol=f("ZodIPv4",(e,t)=>{fi.init(e,t),T.init(e,t)});var il=f("ZodIPv6",(e,t)=>{hi.init(e,t),T.init(e,t)});var sl=f("ZodCIDRv4",(e,t)=>{gi.init(e,t),T.init(e,t)});var al=f("ZodCIDRv6",(e,t)=>{yi.init(e,t),T.init(e,t)});var cl=f("ZodBase64",(e,t)=>{xi.init(e,t),T.init(e,t)});var ul=f("ZodBase64URL",(e,t)=>{vi.init(e,t),T.init(e,t)});var ll=f("ZodE164",(e,t)=>{wi.init(e,t),T.init(e,t)});var dl=f("ZodJWT",(e,t)=>{_i.init(e,t),T.init(e,t)});var Ta=f("ZodNumber",(e,t)=>{vr.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ks(e,r,n,o),e.isFinite=!0},An({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=Q(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=Q(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=Q(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>Q(e).format??null},{gt(e,t){return this.check(Nt(e,t))},gte(e,t){return this.check(Xe(e,t))},min(e,t){return this.check(Xe(e,t))},lt(e,t){return this.check(At(e,t))},lte(e,t){return this.check(Ye(e,t))},max(e,t){return this.check(Ye(e,t))},int(e){return this.check(Pa(e))},safe(e){return this.check(Pa(e))},positive(e){return this.check(Nt(0,e))},nonnegative(e){return this.check(Xe(0,e))},negative(e){return this.check(At(0,e))},nonpositive(e){return this.check(Ye(0,e))},multipleOf(e,t){return this.check(Tt(e,t))},step(e,t){return this.check(Tt(e,t))},finite(){return this}}));function Wr(e){return zs(Ta,e)}var pl=f("ZodNumberFormat",(e,t)=>{ki.init(e,t),Ta.init(e,t)});function Pa(e){return $s(pl,e)}var fl=f("ZodBoolean",(e,t)=>{zi.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ws(e,r,n,o)});function fe(e){return Ss(fl,e)}var ml=f("ZodUnknown",(e,t)=>{$i.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ys(e,r,n,o)});function Za(){return Ps(ml)}var hl=f("ZodNever",(e,t)=>{Si.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hs(e,r,n,o)});function Ra(e){return Zs(hl,e)}var gl=f("ZodArray",(e,t)=>{jt(),Pi.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ta(e,r,n,o),e.element=t.element},{min(e,t){return this.check(Ee(e,t))},nonempty(e){return this.check(Ee(1,e))},max(e,t){return this.check(Rt(e,t))},length(e,t){return this.check(Mt(e,t))},unwrap(){return this.element}});function j(e,t){return Is(gl,e,t)}var Ma=f("ZodObject",(e,t)=>{jt(),Ei.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ra(e,r,n,o),Xc(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return Ae(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(W(this._zod.def,{catchall:e}))},passthrough(){return this.clone(W(this._zod.def,{catchall:Za()}))},loose(){return this.clone(W(this._zod.def,{catchall:Za()}))},strict(){return this.clone(W(this._zod.def,{catchall:Ra()}))},strip(){return this.clone(W(this._zod.def,{catchall:void 0}))},extend(e){return qc(this,e)},safeExtend(e){return Vc(this,e)},merge(e){return Gc(this,e)},pick(e){return Fc(this,e)},omit(e){return Uc(this,e)},partial(...e){return In(La,this,e[0])},exactPartial(...e){return In(Da,this,e[0],"exactPartial")},required(...e){return Jc(ja,this,e[0])}});function xe(e,t){let r={type:"object",shape:e??{},...v(t)};return new Ma(r)}function O(e,t){return new Ma({type:"object",shape:e,catchall:Ra(),...v(t)})}var yl=f("ZodUnion",(e,t)=>{Oi.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>na(e,r,n,o),e.options=t.options});function bl(e,t){return new yl({type:"union",options:e,...v(t)})}var xl=f("ZodIntersection",(e,t)=>{Ci.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>oa(e,r,n,o)});function vl(e,t){return new xl({type:"intersection",left:e,right:t})}var Ia=f("ZodRecord",(e,t)=>{jt(),Ai.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ia(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function Ft(e,t,r){if(!t||!t._zod)return new Ia({type:"record",keyType:y(),valueType:e,...v(t)});return new Ia({type:"record",keyType:e,valueType:t,...v(r)})}var Jr=f("ZodEnum",(e,t)=>{Ni.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Xs(e,n,o,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let i={};for(let s of n)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Jr({...t,checks:[],...v(o),entries:i})},e.exclude=(n,o)=>{let i={...t.entries};for(let s of n)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Jr({...t,checks:[],...v(o),entries:i})}});function Ae(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new Jr({type:"enum",entries:r,...v(t)})}var wl=f("ZodTransform",(e,t)=>{jt(),Ti.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ea(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ve(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(_e(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=r.value;s.inst??(s.inst=e),r.issues.push(_e(s))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((i)=>(r.value=i,r));return r.value=o,r}});function _l(e){return new wl({type:"transform",transform:e})}var La=f("ZodOptional",(e,t)=>{wr.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vr(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ea(e){return new La({type:"optional",innerType:e})}var Da=f("ZodExactOptional",(e,t)=>{Ri.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vr(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function kl(e){return new Da({type:"optional",innerType:e})}var zl=f("ZodNullable",(e,t)=>{Mi.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Oa(e){return new zl({type:"nullable",innerType:e})}var $l=f("ZodDefault",(e,t)=>{Li.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ua(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Sl(e,t){return new $l({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():tr(t)}})}var Pl=f("ZodPrefault",(e,t)=>{Di.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>la(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Zl(e,t){return new Pl({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():tr(t)}})}var ja=f("ZodNonOptional",(e,t)=>{ji.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>aa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Il(e,t){return new ja({type:"nonoptional",innerType:e,...v(t)})}var El=f("ZodCatch",(e,t)=>{Bi.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>da(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ol(e,t){return new El({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Nn(t)})}var Cl=f("ZodPipe",(e,t)=>{Fi.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pa(e,r,n,o),e.in=t.in,e.out=t.out});function Ca(e,t){return new Cl({type:"pipe",in:e,out:t})}var Al=f("ZodReadonly",(e,t)=>{Ui.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Nl(e){return new Al({type:"readonly",innerType:e})}var Tl=f("ZodCustom",(e,t)=>{qi.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qs(e,r,n,o)});function Rl(e,t={}){return Es(Tl,e,t)}function Ml(e,t){return Os(e,t)}var Ne=Ae(["global","private","shared"]),Ll=y().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(48),Te=O({name:Ll,description:y().trim().min(1).max(300),body:y().trim().min(1).max(24000)}),Hr=O({scope:Ne,choices:Ft(y().max(128),fe()),edits:Ft(y().max(128),y().min(1).max(48000)).default({}),custom:j(Te).max(40).default([])}),zm=Hr.extend({directory:y(),id:y()});var Dl=O({id:y(),title:y(),parentId:y().nullable()}),jl=O({id:y(),itemIds:j(y()).min(1),parentId:y(),relatedHubIds:j(y()).max(2)}),Yr=O({hubs:j(Dl),leaves:j(jl)});var Bl=O({id:y(),name:y(),title:y(),description:y(),text:y(),kind:Ae(["preference","skill"]),category:y().nullable(),section:y().nullable(),axis:y().nullable(),owner:Ae(["packaged","managed","user","provider"])}),Ba=O({scope:Ne,input:Hr,inherited:Ft(y(),fe()),locked:Ft(y(),fe()),items:j(Bl),constellation:Yr,requirements:j(y()),libraryEnabled:fe(),migrationRequired:fe(),revisionId:y().nullable()}),Fa=O({id:Bt(),changes:j(O({path:y(),before:y().nullable(),after:y().nullable(),internal:fe()})),warnings:j(y())}),Xr=O({revisionId:y().nullable()});var Qr=window.location.hash.slice(1),Fl=Qr||sessionStorage.getItem("shadowclone-session")||"";if(Qr)sessionStorage.setItem("shadowclone-session",Qr),history.replaceState(null,"",`${location.pathname}${location.search}`);async function E(e){let t=await fetch(e.path,{method:e.body===void 0?"GET":"POST",headers:{Authorization:`Bearer ${Fl}`,"Content-Type":"application/json"},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:e.signal}),r=await t.json();if(!t.ok){let n=xe({error:y()}).safeParse(r);throw Error(n.success?n.data.error:"The local editor could not complete this action.")}return e.schema.parse(r)}var Ul=[["testing",["test","tests","testing","regression","coverage","tdd","e2e","playwright"]],["review",["review","reviews","reviewer","feedback","findings","audit"]],["debugging",["debug","debugging","diagnose","bug","bugs","incident","triage","flaky"]],["version-control",["git","merge","rebase","branch","commit","commits","conflict","worktree"]],["pull-requests",["pr","prs","pull"]],["writing",["write","writing","docs","documentation","prose","readme","voice"]],["planning",["plan","planning","architecture","roadmap"]],["typescript",["typescript","types","type"]],["frontend",["ui","css","react","frontend","browser","web","page","design"]],["data",["sql","database","data","schema","migration"]],["delivery",["deploy","release","ci","pipeline"]],["security",["security","secret","secrets","auth","permissions"]],["research",["research","search","investigate","sources"]]];function ql(e){return e.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)}function Vl(e){return e.split("-").map((t)=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`).join(" ")}function Gl(e){if(e.category)return e.category;let t=new Set(ql(`${e.name} ${e.title} ${e.description}`)),[r]=Ul.map(([n,o],i)=>({category:n,index:i,hits:o.filter((s)=>t.has(s)).length})).filter((n)=>n.hits>0).sort((n,o)=>o.hits-n.hits||n.index-o.index);return r?.category??"more"}function Ua(e){let r=Gl(e.item),n=`category:custom:${r}`,o=[...e.constellation.hubs];if(!o.some((i)=>i.id==="source:custom"))o.push({id:"source:custom",title:"Your custom skills",parentId:null});if(!o.some((i)=>i.id===n))o.push({id:n,title:r==="more"?"More skills":Vl(r),parentId:"source:custom"});return{hubs:o,leaves:[...e.constellation.leaves,{id:`skill:${e.item.id}`,itemIds:[e.item.id],parentId:n,relatedHubIds:[]}]}}function _(e){let t=document.getElementById(e);if(t===null)throw Error("The editor is missing a required control");return t}function en(e){let t=document.querySelector(`#${e}`);if(!(t instanceof SVGSVGElement))throw Error("Expected an SVG canvas");return t}function J(e){let t=_(e);if(!(t instanceof HTMLInputElement))throw Error("Expected an input control");return t}function ue(e){let t=_(e);if(!(t instanceof HTMLSelectElement))throw Error("Expected a selection control");return t}function me(e){let t=_(e);if(!(t instanceof HTMLTextAreaElement))throw Error("Expected a text editor");return t}function Re(e){let t=_(e);if(!(t instanceof HTMLDialogElement))throw Error("Expected an editor dialog");return t}function g(e){let t=document.createElement(e.tag);if(e.className)t.className=e.className;if(e.text!==void 0)t.textContent=e.text;return t}function ee(e){let t=_("notice");t.textContent=e.message,t.classList.toggle("success",e.success===!0),t.hidden=e.message.length===0}function he(e){ee({message:e instanceof Error?e.message:"The action failed."})}var b={view:null,input:{scope:"global",choices:{},edits:{},custom:[]},activeId:"",search:"",dirty:!1};function D(e){let t=b.view?.locked[e.id];if(t!==void 0)return t;let r=b.input.choices[e.id];if(r!==void 0)return r;if(e.id.startsWith("custom:")&&b.input.custom.some((n)=>e.id===`custom:${n.name}`))return!0;return b.view?.inherited[e.id]===!0}function Me(e){if(b.view?.locked[e.id]!==void 0)return;let t=!D(e);if(b.input.choices[e.id]=t,t&&e.axis){for(let r of b.view?.items??[])if(r.axis===e.axis&&r.id!==e.id)b.input.choices[r.id]=!1,delete b.input.edits[r.id]}if(!t)delete b.input.edits[e.id];b.dirty=!0}function tn(e){return e.filter((t)=>t.owner!=="provider"&&b.view?.locked[t.id]===void 0)}function qa(e){let t=tn(e),r=!t.every(D),n=new Set;for(let o of t){if(D(o)===r){if(o.axis)n.add(o.axis);continue}if(r&&o.axis&&n.has(o.axis))continue;if(Me(o),o.axis)n.add(o.axis)}}function rn(e){_("custom-status").textContent="",J("custom-name").value=e?`my-${e.name}`.slice(0,48):"",J("custom-description").value=e?`Use alongside ${e.name} for my working preferences.`:"",me("custom-body").value=e?`# Personal guidance for ${e.title}
|
|
58
|
-
|
|
59
|
-
`:"",Re("custom-dialog").showModal()}function Va(){let e=Te.parse({name:J("custom-name").value,description:J("custom-description").value,body:me("custom-body").value}),t=`custom:${e.name}`;if(b.view?.items.some((r)=>r.name===e.name))throw Error("Choose a name that does not replace an existing skill.");if(b.input.custom.push(e),b.input.choices[t]=!0,b.dirty=!0,b.activeId=t,b.view?.items.push({id:t,name:e.name,title:e.name.replaceAll("-"," "),description:e.description,text:`---
|
|
60
|
-
name: ${e.name}
|
|
61
|
-
description: ${JSON.stringify(e.description)}
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
${e.body}
|
|
65
|
-
`,kind:"skill",category:null,section:null,axis:null,owner:"managed"}),b.view)b.view.constellation=Ua({constellation:b.view.constellation,item:{id:t,name:e.name,title:e.name.replaceAll("-"," "),description:e.description,category:null}});Re("custom-dialog").close(),J("custom-name").value="",me("custom-body").value=""}var nn={"design-deep-modules":{title:"Deep modules",summary:"Keep interfaces small and useful. Put complexity behind a clear boundary so callers have less to understand."},"typescript-type-safety":{title:"Explicit types",summary:"Represent valid states in the type system. Narrow uncertain values and keep unsafe assertions out of the implementation."},"verify-review-findings":{title:"Check review findings",summary:"Check each review comment against the code at the pull request head, and report a verdict before any change or reply."},"plan-with-review-page":{title:"Plan first",summary:"Read the code, ask one round of decisions with a recommendation, and share one plan with a review page before any edit."},"write-plain-english":{title:"Plain English",summary:"Write short sentences with one idea each and no dashes, in the user's voice. A checker reports long sentences and dashes."},"choose-by-consequence":{title:"Fail loudly",summary:"Compare each shortcut by what it does to the user's files and output. Pick the option that fails loudly and keeps counts true."},"scope-confirmed-changes":{title:"Reproduce, then fix",summary:"Reproduce the bug before any fix, then run the same reproduction after it. Keep the change to confirmed behavior."},"diagnose-before-editing":{title:"Find the cause",summary:"Reproduce the failure, make it smaller, and test one cause at a time until one cause predicts the symptom."},"tests-that-catch-bugs":{title:"Tests that catch bugs",summary:"Write a few tests that each name the bug they catch, check what the user sees, and fail when the fix is removed."},"verify-and-review":{title:"Verify the real outcome",summary:"Run what the user runs, read every count and exit code, and label each claim as measured, inferred, or not verified."},"research-primary-sources":{title:"Go to the source",summary:"Check authoritative documentation and original evidence when a technical decision depends on facts that need verification."},"planning-first":{title:"Plan the change",summary:"Establish the approach before implementation so the scope, decisions, and intended outcome are clear."},"planning-when-costly":{title:"Plan when it matters",summary:"Move directly on straightforward tasks. Pause for a plan when the cost, uncertainty, or consequences call for one."},"questions-autonomous":{title:"Keep moving",summary:"Use judgment to resolve routine choices. Ask when missing information changes the outcome or an action needs authorization."},"questions-early":{title:"Ask early",summary:"Resolve meaningful uncertainty with the user before investing in an implementation built on the wrong assumption."},"resolve-conflicts-by-intent":{title:"Preserve intent",summary:"Understand what both sides of a merge are trying to achieve. Resolve the conflict and verify the combined behavior."},"dependencies-existing":{title:"Know your tools",summary:"Look for a solution in the existing stack before adding another dependency."},"dependencies-mature":{title:"Choose proven tools",summary:"Use established, focused packages when they provide substantial reusable logic and justify the dependency."},"refactor-boundaries":{title:"Improve boundaries",summary:"Make a refactor when it improves responsibilities and simplifies the change. Keep its purpose connected to the task."},"refactor-preserve":{title:"Respect the structure",summary:"Work within the current structure and preserve unrelated code while making the requested change."}};function $e(e){return nn[e.id]?.title??e.title}function Ga(e){let t=nn[e.item.id];if(t&&e.editedText===void 0&&e.item.owner==="packaged")return t.summary;let r=(e.editedText??e.item.text).replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/,"").split(`
|
|
66
|
-
`).filter((n)=>n.trim()&&!n.startsWith("#")&&!n.startsWith("```")).slice(0,2).join(" ").replace(/\*\*/g,"");return r.length>320?`${r.slice(0,317).trimEnd()}…`:r}function Jl(e){let t=g({tag:"details",className:"editor"});t.append(g({tag:"summary",text:"Edit instructions"}));let r=g({tag:"textarea"});r.value=b.input.edits[e.item.id]??e.item.text,r.maxLength=48000,r.setAttribute("aria-label",`Instructions for ${e.item.title}`);let n=g({tag:"button",className:"quiet-button",text:"Save to draft"});return n.addEventListener("click",()=>{if(!D(e.item))Me(e.item);b.input.edits[e.item.id]=r.value,b.input.choices[e.item.id]=!0,b.dirty=!0,ee({message:"Instructions added to your draft. Review the changes before applying.",success:!0}),e.rerender()}),t.append(r,n),t}function Ja(e){let t=_("detail"),r=b.view?.items.find((a)=>a.id===b.activeId);if(t.replaceChildren(),!r){t.append(g({tag:"h2",text:"Choose a skill."})),t.append(g({tag:"p",className:"detail-description",text:"Inspect a star to see what it teaches your agent."}));return}t.append(g({tag:"p",className:"eyebrow",text:`${(r.category??"CUSTOM").replaceAll("-"," ").toUpperCase()} / ${r.kind.toUpperCase()}`}),g({tag:"h2",text:$e(r)}),g({tag:"p",className:"detail-description",text:r.description}));let n=g({tag:"div",className:"behavior"});n.append(g({tag:"p",className:"eyebrow",text:"YOUR AGENT WILL"}),g({tag:"p",text:Ga({item:r,editedText:b.input.edits[r.id]})})),t.append(n);let o=r.owner==="provider",i=b.view?.locked[r.id]!==void 0;if(t.append(g({tag:"p",className:"skill-status",text:i?"◇ Shared requirement":o?"◇ Managed by its provider":"◇ Workflow guidance"})),i){t.append(g({tag:"p",className:"owner-note",text:"This choice belongs to the shared repository build. Switch to shared scope to propose a reviewed change."}));return}let s=g({tag:"button",className:"primary-button",text:o?"Create a local companion":D(r)?"Unequip skill":"Equip skill"});if(s.addEventListener("click",()=>{if(o){e.companion(r);return}Me(r),e.rerender()}),t.append(s),o)t.append(g({tag:"p",className:"owner-note",text:"Enable or disable this package in its harness. A companion adds your own instructions without changing the package."}));else t.append(Jl({item:r,rerender:e.rerender}))}var Kl=O({title:y().min(1).max(48),profile:y().min(1).max(420),abilities:j(O({skill:y().min(1).max(120),text:y().min(1).max(200)})).min(1).max(3),tradeoff:y().min(1).max(240)}),Ka=O({name:Kl,destination:y()});function Wa(e){let t=new Map,r={status:"empty"},n=null,o=null,i=null,s=(u)=>{r=u,e.onChange(u)},a=()=>{if(o)e.cancel(o.handle);o=null,i?.abort(),i=null},c=()=>{let u=n;if(o=null,!u?.key)return;let l=u.key,d=new AbortController;i?.abort(),i=d,s({status:"loading"}),e.fetchName({input:structuredClone(u.input),signal:d.signal}).then((p)=>{if(t.set(l,p),!d.signal.aborted&&n?.key===l)s({status:"ready",result:p})}).catch((p)=>{if(!d.signal.aborted&&n?.key===l)s({status:"failed",error:p instanceof Error?p.message:"The build could not be named."})}).finally(()=>{if(i===d)i=null})};return{state:()=>r,update(u){let l=n;if(n=u,!u.enabled){if(a(),r.status!=="off")s({status:"off"});return}if(l?.key===u.key&&l.enabled&&r.status!=="off")return;if(a(),u.key===null){s({status:"empty"});return}let d=t.get(u.key);if(d){s({status:"ready",result:d});return}if(!u.changed){s({status:"unnamed"});return}s({status:"waiting"}),o={handle:e.schedule({run:c,delayMilliseconds:5000})}},retry(){a(),c()}}}var on="shadowclone-build-naming";function Ha(){try{return localStorage.getItem(on)!=="off"}catch{return!0}}function Wl(e){try{if(e)localStorage.removeItem(on);else localStorage.setItem(on,"off")}catch{return}}var Hl={empty:"Choose the instincts you want your agent to bring to work.",off:"Build naming is off. Turn it on to name your build with your fast model.",unnamed:"Name this build now, or change a skill and it gets a name 5 seconds later.",waiting:"Your build gets a name 5 seconds after your last change.",loading:"Naming your build…"};function Ya(e){let t=_("identity"),r=_("abilities"),n=_("tradeoff"),o=e.status==="ready"?e.result:null;t.dataset.naming=e.status,t.setAttribute("aria-busy",String(e.status==="loading")),_("identity-title").textContent=o?.name.title??"An open canvas",_("identity-description").textContent=e.status==="ready"?e.result.name.profile:e.status==="failed"?e.error:Hl[e.status],r.replaceChildren(...(o?.name.abilities??[]).map((a)=>{let c=g({tag:"li"});return c.append(g({tag:"strong",text:a.skill}),g({tag:"span",text:a.text})),c})),n.hidden=!o,n.textContent=o?`Tradeoff: ${o.name.tradeoff}`:"",_("naming-source").textContent=o?`Named by ${o.destination}`:"";let i=_("retry-name");i.hidden=e.status!=="failed"&&e.status!=="unnamed",i.textContent=e.status==="unnamed"?"Name my build":"Retry";let s=_("toggle-naming");s.textContent=e.status==="off"?"Turn naming on":"Turn naming off",s.setAttribute("aria-pressed",String(e.status!=="off"))}var sn=Wa({schedule:({run:e,delayMilliseconds:t})=>window.setTimeout(e,t),cancel:(e)=>window.clearTimeout(e),fetchName:({input:e,signal:t})=>E({path:"/api/build-name",schema:Ka,body:e,signal:t}),onChange:Ya});function Xa(){return b.view?.items.filter((e)=>e.owner!=="provider"&&D(e))??[]}function Qa(){let e=Xa();sn.update({key:e.length?JSON.stringify([b.input.scope,e.map((t)=>t.id).sort(),b.input.custom]):null,input:b.input,enabled:Ha(),changed:b.dirty})}function ec(){_("retry-name").addEventListener("click",()=>sn.retry()),_("toggle-naming").addEventListener("click",()=>{Wl(!Ha()),Qa()}),Ya(sn.state())}function tc(){let e=Xa();_("equipped-count").textContent=`${e.length} ${e.length===1?"skill":"skills"} equipped${b.dirty?" · unsaved changes":""}`,Qa();let t=_("requirements");if(t.replaceChildren(),t.hidden=!b.view?.requirements.length,b.view?.requirements.length){t.append(g({tag:"h3",text:"◇ Repository requirements"}));for(let r of b.view.requirements)t.append(g({tag:"p",text:r}))}}var Ut=null;async function rc(){if(b.view===null)throw Error("Wait for your skills to load before reviewing the build.");let e=await E({path:"/api/preview",schema:Fa,body:b.input});Ut=e;let t=_("review-content");t.replaceChildren(),t.append(g({tag:"p",className:"review-message",text:`${e.changes.length} local files will change. Review the instructions and destinations below.`}));for(let r of e.warnings)t.append(g({tag:"p",className:"review-warning",text:r}));for(let r of e.changes){let n=g({tag:"details",className:"file-change"});if(n.append(g({tag:"summary",text:r.path})),r.internal)n.append(g({tag:"p",text:"Local configuration or supporting resource. Its previous version is retained for undo."}));else n.append(g({tag:"h4",text:"Before"}),g({tag:"pre",text:r.before??"New file"}),g({tag:"h4",text:"After"}),g({tag:"pre",text:r.after??"Remove managed file"}));t.append(n)}Re("review-dialog").showModal()}async function nc(){if(Ut===null)throw Error("Review your build before applying it.");await E({path:"/api/apply",schema:Xr,body:{previewId:Ut.id}}),Ut=null,Re("review-dialog").close(),ee({message:"Build equipped. Start a fresh agent session to use your updated skills.",success:!0})}async function oc(){let e=b.view?.revisionId;if(!e||!window.confirm("Restore the files from before the last apply? Later edits will be preserved if they conflict."))return;await E({path:"/api/undo",schema:Xr,body:{revisionId:e}}),ee({message:"Restored the previous build.",success:!0})}function Yl(e){let t=e.map((r)=>b.view?.items.find((n)=>n.id===r)).filter((r)=>r!==void 0);return t.find(D)??t[0]}function Xl(e){return`${$e(e)} ${e.description}`.toLowerCase().includes(b.search.toLowerCase())}function ic(e){let t=_("constellation-list");t.replaceChildren();let r=new Map(e.constellation.hubs.map((n)=>[n.id,n.parentId]));for(let n of e.constellation.hubs.filter((o)=>o.parentId===null)){let o=g({tag:"section",className:"skill-list-group"});o.append(g({tag:"h3",text:n.title}));for(let i of e.constellation.leaves.filter((s)=>{let a=s.parentId;while(a){if(a===n.id)return!0;a=r.get(a)??null}return!1})){let s=Yl(i.itemIds);if(!s||!Xl(s))continue;let a=g({tag:"button",className:"skill-list-item",text:$e(s)});a.classList.toggle("equipped",D(s)),a.addEventListener("click",()=>e.inspect(s.id)),o.append(a)}if(o.childElementCount>1)t.append(o)}}var A={padding:32,rootX:56,sourceX:176,categoryX:296,cellWidth:120,cellHeight:96,groupGap:12,sourceGap:28,labelWidth:108,jitterX:4,jitterY:5};function sc(e){let t=2166136261;for(let r of e.key)t=Math.imul(t^(r.codePointAt(0)??0),16777619);return(t>>>0)/4294967295*e.range*2-e.range}function an(e){let t=e-A.categoryX-A.padding+A.cellWidth/2;return Math.max(2,Math.floor(t/A.cellWidth))}function qt(e){return{id:`${e.from.id}:${e.to.id}`,sourceX:e.from.x,sourceY:e.from.y,targetX:e.to.x,targetY:e.to.y,sibling:e.sibling??!1}}function Ql(e){let t=[],r=e.cells;for(let n of e.blocks){if(r+1+n.columns>e.cells)t.push([]),r=0;t.at(-1)?.push(n),r+=1+n.columns}return t}function ac(e){let t=an(e.width),{hubs:r,leaves:n}=e.constellation,o=[],i=[],s=[],a=e.collapsed??new Set,c=A.padding;for(let p of r.filter((m)=>m.parentId===null)){let m=[],h=[],x=r.filter((z)=>z.parentId===p.id),w=a.has(p.id),S=(w?[]:x).map((z)=>{let k=n.filter((K)=>K.parentId===z.id),Z=a.has(z.id)?[]:k;return{category:z,members:Z,hidden:k.length-Z.length,columns:Math.max(1,Math.min(Z.length,t-1))}});for(let z of Ql({blocks:S,cells:t})){let k=0,Z=1,K=null;for(let F of z){let X=A.categoryX+k*A.cellWidth,le={id:F.category.id,title:F.category.title,itemIds:[],kind:"category",parentId:p.id,x:X,y:c+A.cellHeight/2,hidden:F.hidden},at=le;if(m.push(le),K)i.push(qt({from:K,to:le,sibling:!0}));else h.push(le);for(let[ct,ut]of F.members.entries()){let yn=ct%F.columns,Yt={id:ut.id,title:"",itemIds:ut.itemIds,kind:"skill",parentId:F.category.id,hidden:0,x:X+(yn+1)*A.cellWidth+sc({key:ut.id,range:A.jitterX}),y:c+Math.floor(ct/F.columns)*A.cellHeight+A.cellHeight/2+sc({key:`${ut.id}:y`,range:A.jitterY})};i.push(qt({from:yn===0?le:at,to:Yt})),o.push(Yt),at=Yt}Z=Math.max(Z,Math.ceil(F.members.length/F.columns)),k+=1+F.columns,K=le}c+=Z*A.cellHeight+A.groupGap}let P=m[0],L=m.at(-1),V={id:p.id,title:p.title,itemIds:[],kind:"source",parentId:"constellation-root",x:A.sourceX,y:P&&L?(P.y+L.y)/2:c+A.cellHeight/2,hidden:w?n.filter((z)=>x.some((k)=>k.id===z.parentId)).length:0};if(w)c+=A.cellHeight;s.push(V),o.push(V,...m),i.push(...h.map((z)=>qt({from:V,to:z}))),c+=A.sourceGap}let u=s[0],l=s.at(-1),d={id:"constellation-root",title:"Shadowclone",itemIds:[],kind:"root",parentId:null,hidden:0,x:A.rootX,y:u&&l?(u.y+l.y)/2:A.padding+A.cellHeight/2};return i.push(...s.map((p)=>qt({from:d,to:p}))),{nodes:[d,...o],links:i,height:Math.max(c+A.padding,A.cellHeight*2)}}var ed={modules:"M4 4h6v6H4ZM14 4h6v6h-6ZM4 14h6v6H4ZM14 14h6v6h-6Z",code:"m8 5-6 7 6 7m8-14 6 7-6 7m-3-16-2 18",focus:"M8 3H4v4m12-4h4v4M4 17v4h4m12-4v4h-4M8 9h8v6H8Z",bug:"M9 5 7 2m8 3 2-3M8 9V7a4 4 0 0 1 8 0v2M6 9h12v6a6 6 0 0 1-12 0Zm6 0v12M2 10h4m12 0h4M2 15h4m12 0h4M4 21l3-3m10 0 3 3",flask:"M9 3h6m-5 0v7l-6 9q-1 2 2 2h12q3 0 2-2l-6-9V3M7 15h10",check:"m2 12 5 5L19 5M12 17l10-10",route:"M7 5h10a3 3 0 0 1 0 6H7a3 3 0 0 0 0 6h10M7 2a3 3 0 1 0 0 6 3 3 0 0 0 0-6m10 12a3 3 0 1 0 0 6 3 3 0 0 0 0-6",compass:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20m-3 7 8-2-2 8-8 2Z",flag:"M5 22V3q4-3 8 0t7 0v10q-3 3-7 0t-8 0",merge:"M6 2v8q0 5 6 5h6m-4-4 4 4-4 4M6 18v4M18 2v5",layers:"m12 2 10 6-10 6L2 8Zm-9 11 9 5 9-5M3 17l9 5 9-5",link:"m9 15 6-6m-7 4-2 2a4 4 0 0 0 6 6l3-3m1-5 2-2a4 4 0 0 0-6-6L9 8",shield:"m12 2 8 3v7q0 6-8 10-8-4-8-10V5Zm-4 9 3 3 5-6",question:"M8 7a4 4 0 1 1 6 4q-2 1-2 4m0 4v1M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20",spark:"m12 2 3 7 7 3-7 3-3 7-3-7-7-3 7-3Z",search:"M10 3a7 7 0 1 0 0 14 7 7 0 0 0 0-14m5 12 6 6"},td={"design-deep-modules":"modules","typescript-type-safety":"code","scope-confirmed-changes":"focus","choose-by-consequence":"compass","write-plain-english":"spark","plan-with-review-page":"route","verify-review-findings":"search","refactor-boundaries":"layers","refactor-preserve":"shield","dependencies-existing":"link","dependencies-mature":"layers","diagnose-before-editing":"bug","tests-that-catch-bugs":"flask","research-primary-sources":"search","verify-and-review":"check","planning-first":"route","planning-when-costly":"compass","questions-autonomous":"flag","questions-early":"question","resolve-conflicts-by-intent":"merge"};function cc(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg"),r=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.25"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true"),r.setAttribute("d",ed[e]),t.append(r),t}function uc(e){return cc(td[e.id]??"spark")}function lc(e){let t=e.toLowerCase(),n=Object.entries({engineering:"code",architecture:"modules",typescript:"code",workflow:"route",dependenc:"layers",testing:"flask",communication:"question",debugging:"bug",planning:"compass",research:"search",review:"check",setup:"spark"}).find(([o])=>t.includes(o))?.[1]??"compass";return cc(n)}var rd="http://www.w3.org/2000/svg",pc="shadowclone-collapsed-groups";function nd(){try{let e=JSON.parse(localStorage.getItem(pc)??"[]");return new Set(Array.isArray(e)?e.filter((t)=>typeof t==="string"):[])}catch{return new Set}}var Se=nd();function cn(){return Se}function fc(e){if(Se=new Set(Se),!Se.delete(e))Se.add(e);try{localStorage.setItem(pc,JSON.stringify([...Se]))}catch{return}}function rt(e){return document.createElementNS(rd,e)}function dc(e){e.target.addEventListener("click",(t)=>{t.stopPropagation(),e.action()}),e.target.addEventListener("keydown",(t)=>{if(t.key==="Enter"||t.key===" ")t.preventDefault(),t.stopPropagation(),e.action()})}function mc(e){let{container:t,node:r}=e,n=!Se.has(r.id),o=rt("g"),i=rt("circle"),s=rt("path");if(o.setAttribute("class","map-collapse"),o.setAttribute("transform","translate(36 0)"),o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.setAttribute("aria-expanded",String(n)),o.setAttribute("aria-label",`${n?"Collapse":"Expand"} ${r.title}`),i.setAttribute("r","12"),s.setAttribute("d",n?"M2 -4L-2 0L2 4":"M-2 -4L2 0L-2 4"),o.append(i,s),dc({target:o,action:()=>e.toggle(r.id)}),t.append(o),r.hidden>0){let c=rt("text");c.setAttribute("class","map-hidden-count"),c.setAttribute("x","54"),c.setAttribute("y","4"),c.textContent=`${r.hidden} hidden`,t.append(c)}if(r.kind!=="category")return;let a=rt("rect");for(let[c,u]of Object.entries({x:"-26",y:"-26",width:"52",height:"52",class:"map-node-hit"}))a.setAttribute(c,u);t.prepend(a),t.setAttribute("role","button"),t.setAttribute("tabindex","0"),dc({target:t,action:()=>e.equipAll(r.id)})}function hc(e){if(e.node.kind!=="category")return;let t=tn(e.items),r=t.length>0&&t.every(D);e.element.classList.toggle("equipped",r),e.element.classList.toggle("partial",!r&&t.some(D)),e.element.setAttribute("aria-pressed",String(r)),e.element.setAttribute("aria-disabled",String(t.length===0)),e.element.setAttribute("aria-label",t.length===0?`${e.node.title}, managed by plugins`:`${r?"Unequip":"Equip"} all ${t.length} skills in ${e.node.title}`)}var od="http://www.w3.org/2000/svg",nt=()=>{return},Gt=()=>{return},gc="",un=new Map,ln=new Map,dn=new Map;function oe(e){return document.createElementNS(od,e)}function ot(e){let t=e.itemIds.map((r)=>un.get(r)).filter((r)=>r!==void 0);return t.find(D)??t[0]}function yc(e){return(b.view?.constellation.leaves??[]).filter((t)=>t.parentId===e).flatMap((t)=>{let r=t.itemIds.map((o)=>un.get(o)).filter((o)=>o!==void 0),n=r.find(D)??r[0];return n?[n]:[]})}function Vt(e){let t=ot(e);return t?$e(t):e.title}function id(e){let t=ot(e);return!b.search||`${Vt(e)} ${t?.description??""}`.toLowerCase().includes(b.search.toLowerCase())}function sd(e){let t=[""];for(let r of e.split(/\s+/)){let n=t.at(-1)??"";if(n&&n.length+r.length>=16)t.push(r);else t[t.length-1]=`${n} ${r}`.trim()}return t.slice(0,2).map((r,n)=>`${r.slice(0,17)}${n===1&&t.length>2||r.length>17?"…":""}`)}function ad(e){let{node:t}=e,r=ot(t),n=oe("g"),o=t.kind==="skill"?26:t.kind==="root"?0:32,i=oe("text");if(n.setAttribute("class",`map-node map-node-${t.kind}`),n.setAttribute("transform",`translate(${t.x} ${t.y})`),n.dataset.nodeId=t.id,t.kind==="skill"){let a=oe("rect");for(let[c,u]of Object.entries({x:"-26",y:"-26",width:"52",height:"52",class:"map-node-hit"}))a.setAttribute(c,u);n.append(a),n.setAttribute("role","button"),n.setAttribute("tabindex","0")}if(t.kind==="root"){let a=oe("circle");a.setAttribute("r","26"),n.append(a)}else{let a=oe("rect");for(let[c,u]of Object.entries({x:String(-o/2),y:String(-o/2),width:String(o),height:String(o),rx:"6",transform:"rotate(45)",class:"map-node-gem"}))a.setAttribute(c,u);n.append(a)}i.setAttribute("text-anchor","middle");for(let[a,c]of sd(Vt(t)).entries()){let u=oe("tspan");u.setAttribute("x","0"),u.setAttribute("y",String((t.kind==="skill"?34:44)+a*16)),u.textContent=c,i.append(u)}let s=oe("title");if(s.textContent=Vt(t),n.append(s,i),t.kind==="root"){let a=document.querySelector(".brand-mark");if(a instanceof HTMLImageElement){let c=oe("image");for(let[u,l]of Object.entries({href:a.src,x:"-16",y:"-16",width:"32",height:"32"}))c.setAttribute(u,l);n.append(c)}}else{let a=oe("foreignObject"),c=g({tag:"span",className:"map-node-icon"});for(let[u,l]of Object.entries({x:"-9",y:"-9",width:"18",height:"18"}))a.setAttribute(u,l);c.append(r?uc(r):lc(t.title)),a.append(c),n.append(a)}if(t.kind==="category"||t.kind==="source")mc({container:n,node:t,toggle:(a)=>{fc(a),ld(),document.querySelector(`[data-node-id="${CSS.escape(a)}"] .map-collapse`)?.focus()},equipAll:(a)=>Gt(yc(a))}),dn.set(t.id,{node:t,element:n});if(t.kind==="skill"&&r){let a=()=>nt(ot(t)??r);n.addEventListener("click",a),n.addEventListener("keydown",(c)=>{if(c.key==="Enter"||c.key===" ")c.preventDefault(),a()}),ln.set(t.id,{node:t,element:n})}e.group.append(n)}function cd(e){if(!e.sibling)return`M${e.sourceX} ${e.sourceY}L${e.targetX} ${e.targetY}`;let t=(e.sourceX+e.targetX)/2;return`M${e.sourceX} ${e.sourceY-18}Q${t} ${e.sourceY-60} ${e.targetX} ${e.targetY-18}`}function ud(){for(let{node:e,element:t}of dn.values())hc({element:t,node:e,items:yc(e.id)});for(let{node:e,element:t}of ln.values()){let r=ot(e),n=r?D(r):!1;t.classList.toggle("equipped",n),t.classList.toggle("active",r?.id===b.activeId),t.classList.toggle("search-miss",!id(e)),t.setAttribute("aria-pressed",String(n)),t.setAttribute("aria-label",`${Vt(e)}${r?.owner==="provider"?", managed by its plugin":n?", equipped":""}`)}}function Jt(e){nt=e.choose,Gt=e.chooseGroup;let t=en("constellation-map"),r=b.view;if(!r)return;ic({constellation:r.constellation,inspect:(i)=>{let s=r.items.find((a)=>a.id===i);if(s)nt(s)}});let n=t.getBoundingClientRect().width;if(n<=0)return;un=new Map(r.items.map((i)=>[i.id,i]));let o=JSON.stringify([an(n),r.constellation,[...cn()]]);if(o!==gc){let i=ac({constellation:r.constellation,width:n,collapsed:cn()}),s=oe("g");gc=o,ln.clear(),dn.clear(),t.setAttribute("viewBox",`0 0 ${Math.round(n)} ${Math.round(i.height)}`),t.style.height=`${Math.round(i.height)}px`,t.replaceChildren(s);for(let a of i.links){let c=oe("path");c.setAttribute("class",a.sibling?"map-link sibling":"map-link"),c.setAttribute("d",cd(a)),s.append(c)}for(let a of i.nodes)ad({group:s,node:a})}ud()}function bc(){let e=en("constellation-map"),t=0;new ResizeObserver(()=>{let n=e.getBoundingClientRect().width;if(Math.round(n)!==Math.round(t))t=n,Jt({choose:nt,chooseGroup:Gt})}).observe(e);let r=_("toggle-constellation-view");r.addEventListener("click",()=>{let n=_("constellation").classList.toggle("list-view");r.setAttribute("aria-pressed",String(n))})}function ld(){Jt({choose:nt,chooseGroup:Gt})}var pn={squarePixelsPerStar:9000,maximumStars:600,attemptsPerStar:30};function xc(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let r=Math.imul(t^t>>>15,t|1);return r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}}function vc(e){return Math.min(pn.maximumStars,Math.round(Math.max(0,e.width)*Math.max(0,e.height)/pn.squarePixelsPerStar))}function dd(e){let t=Math.max(1,vc(e));return Math.sqrt(e.width*e.height/t)*0.55}function q(e){return e.low+e.random()*(e.high-e.low)}function pd(e){let{random:t}=e,r=t()<0.08,n=t()*Math.PI*2,o=q({random:t,low:4,high:14});return{id:e.id,x:e.x,y:e.y,radius:r?q({random:t,low:1.4,high:1.9}):q({random:t,low:0.5,high:1.2}),brightness:q({random:t,low:0.35,high:1}),twinkleSeconds:q({random:t,low:3.5,high:14}),delaySeconds:-q({random:t,low:0,high:14}),driftX:Math.cos(n)*o,driftY:Math.sin(n)*o,driftSeconds:q({random:t,low:18,high:60}),sparkle:r}}function wc(e){let t=vc(e),r=dd(e),n=e.existing.filter((l)=>l.x>=0&&l.x<=e.width&&l.y>=0&&l.y<=e.height).slice(0,t),o=[...n],i=r/Math.SQRT2,s=new Map,a=(l)=>`${Math.floor(l.x/i)}:${Math.floor(l.y/i)}`,c=(l)=>{let d=Math.floor(l.x/i),p=Math.floor(l.y/i);for(let m=-2;m<=2;m+=1)for(let h=-2;h<=2;h+=1){let x=s.get(`${d+m}:${p+h}`);if(x&&Math.hypot(x.x-l.x,x.y-l.y)<r)return!0}return!1},u=Math.max(0,...o.map((l)=>l.id+1));for(let l of n)s.set(a(l),l);for(let l=0;o.length<t&&l<t*pn.attemptsPerStar;l+=1){let d={x:e.random()*e.width,y:e.random()*e.height};if(c(d))continue;let p=pd({id:u,...d,random:e.random});u+=1,o.push(p),s.set(a(p),p)}return o}function _c(e){if(e.reducedMotion||e.width<=0||e.height<=0)return null;let{random:t}=e;return{waitMilliseconds:q({random:t,low:9000,high:28000}),star:{x:q({random:t,low:e.width*0.1,high:e.width*0.9}),y:q({random:t,low:0,high:Math.min(e.height*0.5,600)}),angle:t()<0.5?q({random:t,low:20,high:40}):q({random:t,low:140,high:160}),length:q({random:t,low:70,high:140}),travel:q({random:t,low:220,high:380}),seconds:q({random:t,low:0.7,high:1.3})}}}var Kt="http://www.w3.org/2000/svg";function kc(e){for(let[t,r]of Object.entries(e.properties))e.element.style.setProperty(t,r)}function fd(e){let t=document.createElementNS(Kt,"g"),r=document.createElementNS(Kt,"circle");if(t.setAttribute("class",e.sparkle?"star sparkle":"star"),t.setAttribute("transform",`translate(${e.x.toFixed(1)} ${e.y.toFixed(1)})`),r.setAttribute("r",e.radius.toFixed(2)),kc({element:t,properties:{"--brightness":e.brightness.toFixed(2),"--twinkle":`${e.twinkleSeconds.toFixed(2)}s`,"--delay":`${e.delaySeconds.toFixed(2)}s`,"--drift-x":`${e.driftX.toFixed(1)}px`,"--drift-y":`${e.driftY.toFixed(1)}px`,"--drift":`${e.driftSeconds.toFixed(1)}s`}}),t.append(r),e.sparkle){let n=document.createElementNS(Kt,"path");n.setAttribute("d","M-4 0h8M0 -4v8"),n.setAttribute("class","star-rays"),t.append(n)}return t}function zc(){let e=_("starfield"),t=xc(crypto.getRandomValues(new Uint32Array(1))[0]??Date.now()),r=window.matchMedia("(prefers-reduced-motion: reduce)"),n=new Map,o=[],i={width:0,height:0},s=!1,a=()=>{let l=e.getBoundingClientRect(),d=Math.max(1,Math.round(l.width)),p=Math.max(1,Math.round(l.height));if(d===i.width&&p===i.height)return;i={width:d,height:p},e.setAttribute("viewBox",`0 0 ${d} ${p}`),o=wc({width:d,height:p,existing:o,random:t});let m=new Set(o.map((h)=>h.id));for(let[h,x]of n)if(!m.has(h))x.remove(),n.delete(h);for(let h of o){if(n.has(h.id))continue;let x=fd(h);n.set(h.id,x),e.append(x)}},c=()=>{let l=s?null:_c({...i,random:t,reducedMotion:r.matches});if(!l)return;s=!0,window.setTimeout(()=>{if(s=!1,!document.hidden&&!r.matches){let d=document.createElementNS(Kt,"line");d.setAttribute("class","shooting-star"),d.setAttribute("x2",l.star.travel.toFixed(0)),d.setAttribute("transform",`translate(${l.star.x.toFixed(0)} ${l.star.y.toFixed(0)}) rotate(${l.star.angle.toFixed(0)})`),kc({element:d,properties:{"--shoot":`${l.star.seconds.toFixed(2)}s`,"--length":`${l.star.length.toFixed(0)}px`,"--travel":`${l.star.travel.toFixed(0)}px`}}),d.addEventListener("animationend",()=>d.remove()),e.append(d)}c()},l.waitMilliseconds)},u=()=>{e.classList.toggle("paused",document.hidden)};document.addEventListener("visibilitychange",u),r.addEventListener("change",c),new ResizeObserver(a).observe(e),a(),u(),c()}var Ch=O({name:y().trim().max(48),description:y().trim().max(300),body:y().trim().min(1).max(24000)}),$c=O({id:Bt(),destination:y(),payload:y(),limits:y(),cached:Te.nullable()}),Sc=O({skill:Te});function Wt(e){let t=!1,r=(n)=>{let o=e.getBoundingClientRect();return n.target===e&&(n.clientX<o.left||n.clientX>o.right||n.clientY<o.top||n.clientY>o.bottom)};e.addEventListener("pointerdown",(n)=>{t=r(n)}),e.addEventListener("click",(n)=>{if(t&&r(n))e.close();t=!1})}function Pc(e){let t=g({tag:"dialog"}),r=g({tag:"div",className:"dialog-heading"}),n=g({tag:"button",className:"quiet-button",text:"✕"}),o=g({tag:"details",className:"file-change"}),i=g({tag:"div",className:"dialog-actions"}),s=g({tag:"p",className:"review-message"}),a=g({tag:"button",className:"quiet-button",text:"Keep editing"}),c=g({tag:"button",className:"primary-button",text:e.confirm}),u=new AbortController;t.setAttribute("aria-label",e.title),n.setAttribute("aria-label","Close model request"),s.setAttribute("role","status"),n.addEventListener("click",()=>t.close()),Wt(t),r.append(g({tag:"h2",text:e.title}),n),o.append(g({tag:"summary",text:"Exact payload sent to the model"}),g({tag:"pre",text:e.review.payload})),a.addEventListener("click",()=>t.close()),t.addEventListener("close",()=>{u.abort(),t.remove()});async function l(){if(c.disabled)return;c.disabled=!0,c.textContent="Generating…",a.textContent="Cancel generation",s.textContent="Your model is working. You can cancel and keep your original draft.";try{let d=await E({path:e.path,schema:e.schema,body:{previewId:e.review.id},signal:u.signal});if(!u.signal.aborted)e.accept(d),t.close()}catch(d){if(u.signal.aborted)return;s.className="review-warning",s.textContent=d instanceof Error?d.message:"Generation failed. Your draft is unchanged.",c.textContent="Request ended",a.textContent="Back to editing"}}c.addEventListener("click",()=>{l().catch(()=>{s.textContent="Generation failed. Return to editing to try again."})}),i.append(a,c),t.append(r,g({tag:"p",className:"review-message",text:`Destination: ${e.review.destination}`}),g({tag:"p",className:"review-message",text:e.review.limits}),g({tag:"p",className:"review-message",text:e.explanation}),o,s,i),document.body.append(t),t.showModal()}function Pe(e){_("custom-status").textContent=e}async function md(){let e=me("custom-body").value;if(!e.trim()){Pe("Describe what your agent should do, then use AI to shape it into a skill."),me("custom-body").focus();return}let t=await E({path:"/api/skill/preview",schema:$c,body:{name:J("custom-name").value,description:J("custom-description").value,body:e}});Pc({review:t,title:"Draft your skill with AI.",explanation:"Only the form fields below are sent. The result fills this form for you to edit; adding and applying it remain your choice.",confirm:"Send and draft",path:"/api/skill/generate",schema:Sc,accept:({skill:r})=>{J("custom-name").value=r.name,J("custom-description").value=r.description,me("custom-body").value=r.body,Pe("AI draft ready. Edit the instructions before adding the skill to your build."),me("custom-body").focus()}})}function Zc(){let e=_("custom-ai");if(!(e instanceof HTMLButtonElement))return;e.addEventListener("click",()=>{if(e.disabled)return;e.disabled=!0,Pe("Preparing your model request…"),md().catch((t)=>{Pe(t instanceof Error?t.message:"Could not prepare an AI draft. Your text is unchanged.")}).finally(()=>{if(e.disabled=!1,_("custom-status").textContent==="Preparing your model request…")Pe("")})})}var fn=!1;async function Le(e){if(fn)return;fn=!0;let t=document.querySelectorAll("button, input, select, textarea"),r=Array.from(t,(n)=>({control:n,disabled:n.disabled}));for(let{control:n}of r)n.disabled=!0;try{await e()}finally{for(let{control:n,disabled:o}of r)n.disabled=o;fn=!1}}function Ze(e){_(e.id).addEventListener("click",()=>Le(e.action).catch(he))}function Ic(){let e=document.createElement("template");e.innerHTML=`
|
|
67
|
-
<dialog id="review-dialog" aria-labelledby="review-title">
|
|
68
|
-
<div class="dialog-heading">
|
|
69
|
-
<div>
|
|
70
|
-
<p class="eyebrow">READY TO EQUIP</p>
|
|
71
|
-
<h2 id="review-title">Review your changes.</h2>
|
|
72
|
-
</div>
|
|
73
|
-
<button class="close-dialog quiet-button" aria-label="Close review">
|
|
74
|
-
✕
|
|
75
|
-
</button>
|
|
76
|
-
</div>
|
|
77
|
-
<div id="review-content"></div>
|
|
78
|
-
<div class="dialog-actions">
|
|
79
|
-
<button class="close-dialog quiet-button">Keep editing</button>
|
|
80
|
-
<button id="apply" class="primary-button">Apply build</button>
|
|
81
|
-
</div>
|
|
82
|
-
</dialog>
|
|
83
|
-
|
|
84
|
-
<dialog id="custom-dialog" aria-labelledby="custom-title">
|
|
85
|
-
<div class="dialog-heading">
|
|
86
|
-
<h2 id="custom-title">Create a skill.</h2>
|
|
87
|
-
<button
|
|
88
|
-
class="close-dialog quiet-button"
|
|
89
|
-
aria-label="Close skill editor"
|
|
90
|
-
>
|
|
91
|
-
✕
|
|
92
|
-
</button>
|
|
93
|
-
</div>
|
|
94
|
-
<form id="custom-form">
|
|
95
|
-
<label>
|
|
96
|
-
Skill name
|
|
97
|
-
<input
|
|
98
|
-
id="custom-name"
|
|
99
|
-
pattern="[a-z0-9]+(-[a-z0-9]+)*"
|
|
100
|
-
maxlength="48"
|
|
101
|
-
placeholder="review-with-evidence"
|
|
102
|
-
required
|
|
103
|
-
>
|
|
104
|
-
</label>
|
|
105
|
-
<label>
|
|
106
|
-
When should your agent use it?
|
|
107
|
-
<input
|
|
108
|
-
id="custom-description"
|
|
109
|
-
maxlength="300"
|
|
110
|
-
placeholder="Use when reviewing an implementation."
|
|
111
|
-
required
|
|
112
|
-
>
|
|
113
|
-
</label>
|
|
114
|
-
<label>
|
|
115
|
-
What should your agent do?
|
|
116
|
-
<textarea
|
|
117
|
-
id="custom-body"
|
|
118
|
-
rows="9"
|
|
119
|
-
maxlength="24000"
|
|
120
|
-
placeholder="Describe the decisions, steps, and evidence you expect."
|
|
121
|
-
required
|
|
122
|
-
></textarea>
|
|
123
|
-
</label>
|
|
124
|
-
<p id="custom-status" class="review-message" role="status"></p>
|
|
125
|
-
<div class="dialog-actions">
|
|
126
|
-
<button id="custom-ai" type="button" class="quiet-button">✦ Use AI</button>
|
|
127
|
-
<button type="submit" class="primary-button">
|
|
128
|
-
Add to your build
|
|
129
|
-
</button>
|
|
130
|
-
</div>
|
|
131
|
-
</form>
|
|
132
|
-
</dialog>
|
|
133
|
-
`,document.body.append(e.content);for(let t of document.querySelectorAll("dialog"))Wt(t)}var hd=O({engine:Ae(["claude-code","codex","cursor-agent","pi"]),model:y().min(1).optional(),name:y()}),Ec=O({choices:j(hd),selected:xe({engine:y().optional(),model:y().optional()})});function Oc(){let e=null;Ze({id:"load-models",action:async()=>{e=await E({path:"/api/learning-models",schema:Ec});let t=ue("learning-model"),r=g({tag:"option",text:"Choose a configured model"});if(r.value="",r.disabled=!0,r.selected=!e.choices.some((n)=>n.engine===e?.selected.engine&&n.model===e?.selected.model),t.replaceChildren(r,...e.choices.map((n,o)=>{let i=g({tag:"option",text:n.name});return i.value=String(o),i.selected=n.engine===e?.selected.engine&&n.model===e?.selected.model,i})),e.choices.length===0)ee({message:"Configure a model in your coding harness, then refresh models."})}}),ue("learning-model").addEventListener("change",()=>{let t=ue("learning-model").value;if(t==="")return;let r=e?.choices[Number(t)];if(!r)return;Le(async()=>{await E({path:"/api/learning-model",schema:xe({saved:fe()}),body:{engine:r.engine,model:r.model}}),ee({message:"Saved your learning model. Session learning follows the session model unless overridden.",success:!0})}).catch(he)})}var ng=O({repository:y().regex(/^[\w.-]+\/[\w.-]+$/),name:y().trim().min(1).max(100),skills:j(y().regex(/^[a-z0-9-]+$/)).min(1).max(40)}),Cc=xe({id:Bt(),repository:y(),repositoryId:Wr(),owner:y(),appOwner:y(),fingerprint:y(),bytes:Wr(),files:j(xe({path:y(),content:y()}))}),mn=xe({repository:y().nullable(),skills:j(y()).default([]),app:xe({name:y(),installUrl:Kr()}).nullable(),pullUrl:Kr().nullable()}),Ac=xe({action:Kr(),manifest:y()}),gd=O({previewId:Bt()}),og=gd.extend({token:y().trim().regex(/^sk-ant-oat01-[A-Za-z0-9_-]{20,500}$/)});function it(e){let t=g({tag:"label",className:"field"}),r=g({tag:"input"});return r.value=e.value??"",r.type=e.type??"text",r.required=!0,t.append(g({tag:"span",text:e.label}),r),{label:t,input:r}}function De(e){let t=g({tag:"button",className:"quiet-button bot-actions",text:e.text});return t.type="button",t.addEventListener("click",()=>{t.disabled=!0,e.status.textContent="Working…",e.action().catch((r)=>{e.status.textContent=r instanceof Error?r.message:"Setup failed."}).finally(()=>{t.disabled=!1})}),t}function Nc(e){let{container:t,status:r,preview:n}=e;t.replaceChildren(),t.append(g({tag:"p",text:`Repository: ${n.repository} (ID ${n.repositoryId}). App owner: ${n.appOwner}. Requester: ${n.owner}. Guidance: ${n.bytes} encoded bytes.`})),t.append(g({tag:"p",text:"Review every file below. Approval uploads this exact bundle to a GitHub environment for Claude subscription runs. It also adds a ruleset so only people with write access can update the default branch. The default-branch workflow and code executed with credentials remain trusted."}));for(let s of n.files){let a=g({tag:"details"}),c=Uint8Array.from(atob(s.content),(l)=>l.charCodeAt(0)),u;try{u=new TextDecoder("utf-8",{fatal:!0}).decode(c)}catch{u=`Binary resource (${c.length} bytes), shown as base64:
|
|
134
|
-
${s.content}`}a.append(g({tag:"summary",text:s.path}),g({tag:"pre",text:u})),t.append(a)}let o=g({tag:"input"}),i=g({tag:"label",className:"bot-consent"});o.type="checkbox",i.append(o,document.createTextNode("I reviewed the exact guidance and authorize its cloud use.")),t.append(i),t.append(De({text:"Approve guidance and register my GitHub App",status:r,action:async()=>{if(!o.checked)throw Error("Review the files and select the approval checkbox.");let s=await E({path:"/api/bot/manifest",body:{previewId:n.id},schema:Ac}),a=g({tag:"form"}),c=g({tag:"input"});a.action=s.action,a.method="post",c.type="hidden",c.name="manifest",c.value=s.manifest,a.append(c),t.append(a),sessionStorage.setItem("shadowclone-bot-preview",n.id),a.submit()}})),r.textContent="Review the selected guidance before continuing."}function Tc(){let e=g({tag:"dialog"});e.className="bot-dialog";let t=g({tag:"h2",text:"Your personal GitHub clone"}),r=g({tag:"div"}),n=g({tag:"p"}),o=g({tag:"button",className:"quiet-button",text:"Close"});t.id="bot-title",e.setAttribute("aria-labelledby",t.id),n.setAttribute("role","status"),o.addEventListener("click",()=>e.close()),e.append(t,r,n,o),document.body.append(e);async function i(){let a=await E({path:"/api/bot/state",schema:mn});if(r.replaceChildren(),a.pullUrl){let d=g({tag:"a",text:"Review the setup PR"});d.href=a.pullUrl,d.target="_blank",d.rel="noreferrer",r.append(d),n.textContent="The clone starts after you merge its setup PR. Create one small issue to verify the installation.";return}if(a.app){let d=g({tag:"a",text:`Install ${a.app.name} on GitHub`}),p=it({label:"Claude subscription token",type:"password"}),m=g({tag:"input"}),h=g({tag:"label",className:"bot-consent"});d.href=a.app.installUrl,d.target="_blank",d.rel="noreferrer",p.input.autocomplete="off",m.type="checkbox",h.append(m,document.createTextNode("I authorize this repository to use my Claude subscription and the reviewed guidance.")),r.append(d,g({tag:"p",text:`Choose Only select repositories. Include ${a.repository}. Return to this tab after installation. All repositories is rejected.`}),g({tag:"p",text:"Run claude setup-token in your terminal. Use Safari for your personal Claude sign-in. Paste the resulting token below."}),p.label,h,De({text:"Verify installation and create the setup PR",status:n,action:async()=>{let x=sessionStorage.getItem("shadowclone-bot-preview");if(!x||!m.checked)throw Error("Approve subscription use after reviewing the guidance.");let w=p.input.value.trim();p.input.value="",await E({path:"/api/bot/activate",body:{previewId:x,token:w},schema:mn}),await i()}})),n.textContent="GitHub controls account and organization installation approval.";return}let c=it({label:"Repository (owner/repository)",value:new URLSearchParams(location.search).get("repository")??a.repository??""}),u=it({label:"Clone name",value:"my-shadowclone"}),l=it({label:"Selected skill names, separated by commas",value:a.skills.length?a.skills.join(", "):"shadowclone-work"});r.append(g({tag:"p",text:"Create a GitHub App that you own and name. Only selected repositories receive access. Owner issues start work; @shadowclone requests changes. You review and merge each PR."}),c.label,u.label,l.label,De({text:"Preview the exact guidance",status:n,action:async()=>{let d=await E({path:"/api/bot/preview",schema:Cc,body:{repository:c.input.value.trim(),name:u.input.value.trim(),skills:l.input.value.split(",").map((p)=>p.trim()).filter(Boolean)}});Nc({container:r,status:n,preview:d})}})),n.textContent="Start in this repository checkout with gh auth login and an active Shadowclone skills environment."}let s=De({text:"GitHub clone",status:n,action:async()=>{e.showModal(),await i()}});if(document.querySelector(".toolbar")?.append(s),new URLSearchParams(location.search).get("bot")==="github")s.click()}var hn=y().min(1).max(200),yd=O({traits:j(hn).min(3).max(8),do:j(hn).min(2).max(8),dont:j(hn).min(2).max(8)}),bd=O({pullRequest:y().min(1).max(1500),reviewComment:y().min(1).max(700),commitMessage:y().min(1).max(200)}),Rc=O({profile:yd,samples:bd});var Ht=O({consent:fe(),allowed:fe(),voiceFile:O({path:y(),state:Ae(["missing","file","link"]),target:y().nullable()})}),gn=O({draft:Rc,destination:y(),sourceCount:Wr().int().optional()}),Mc=O({path:y()});var xd={pullRequest:"Invented pull request",reviewComment:"Invented review comment",commitMessage:"Invented commit message"},Lc={traits:"Traits",do:"Do",dont:"Do not"};function Dc(){let e=g({tag:"dialog"}),t=g({tag:"h2",text:"Your writing voice"}),r=g({tag:"p",text:"Shadowclone can read your own pull requests, review comments, and commit messages through your gh login, and ask your model to describe how you write. You see only that description and invented examples, never your writing itself."}),n=g({tag:"p",className:"voice-file"}),o=g({tag:"label",className:"voice-consent"}),i=g({tag:"input"}),s=g({tag:"button",className:"primary-button",text:"Read my writing and describe my voice"}),a=g({tag:"div",className:"voice-result"}),c=g({tag:"p",className:"review-message"}),u=g({tag:"button",className:"quiet-button",text:"Close"}),l=null,d=null,p=!1;e.className="voice-dialog",t.id="voice-title",e.setAttribute("aria-labelledby",t.id),c.setAttribute("role","status"),i.type="checkbox",i.id="voice-consent",o.append(i," Let Shadowclone read my GitHub writing for this"),e.append(t,r,n,o,s,a,c,u),document.body.append(e);let m=async(P)=>{c.textContent=P.message,e.setAttribute("aria-busy","true");try{await P.action()}catch(L){c.textContent=L instanceof Error?L.message:"The voice request failed."}finally{e.setAttribute("aria-busy","false"),h()}},h=()=>{let P=l?.voiceFile.state!=="missing";i.checked=l?.consent??!1,i.disabled=!l?.allowed,s.disabled=!l?.consent,n.textContent=!l?"":!l.allowed?"Your managed policy does not allow Shadowclone to read GitHub writing.":P?`${l.voiceFile.path} already exists${l.voiceFile.target?` as a link to ${l.voiceFile.target}`:""}. Shadowclone will not change it.`:`Saving writes ${l.voiceFile.path}.`;for(let L of a.querySelectorAll("[data-action=save]"))L.disabled=P;for(let L of a.querySelectorAll("[data-action=rewrite]"))L.disabled=!p},x=()=>{let P=(L)=>[...a.querySelectorAll(`input[data-list=${L}]`)].map((V)=>V.value.trim()).filter(Boolean);return{traits:P("traits"),do:P("do"),dont:P("dont")}},w=(P)=>{if(a.replaceChildren(),p=!1,!d)return;a.append(g({tag:"p",className:"voice-source",text:`Described by ${P.destination}${P.sourceCount?` from ${P.sourceCount} pieces of your writing`:""}. Edit any line, then rewrite the samples.`}));for(let Z of["traits","do","dont"]){let K=g({tag:"fieldset"});K.append(g({tag:"legend",text:Lc[Z]}));for(let F of d.profile[Z]){let X=g({tag:"input"});X.value=F,X.dataset.list=Z,X.setAttribute("aria-label",`${Lc[Z]} line`),X.addEventListener("input",()=>{p=!0,h()}),K.append(X)}a.append(K)}for(let Z of["pullRequest","reviewComment","commitMessage"])a.append(g({tag:"h3",text:xd[Z]}),g({tag:"pre",text:d.samples[Z]}));let L=g({tag:"div",className:"dialog-actions"}),V=g({tag:"button",className:"quiet-button",text:"Discard"}),z=g({tag:"button",className:"quiet-button",text:"Rewrite the samples"}),k=g({tag:"button",className:"primary-button",text:"Save my voice"});z.dataset.action="rewrite",k.dataset.action="save",V.addEventListener("click",()=>{d=null,a.replaceChildren(),c.textContent="Discarded. Nothing was saved."}),z.addEventListener("click",()=>m({message:"Rewriting the samples with your fast model…",action:async()=>{let Z=await E({path:"/api/voice/rewrite",schema:gn,body:{profile:x()}});d=Z.draft,w({destination:Z.destination}),c.textContent="The samples now follow your edits."}})),k.addEventListener("click",()=>m({message:"Saving…",action:async()=>{if(!d)return;let Z=await E({path:"/api/voice/save",schema:Mc,body:{...d,profile:x()}});l=await E({path:"/api/voice/status",schema:Ht,body:{}}),c.textContent=`Saved ${Z.path}.`}})),L.append(V,z,k),a.append(L),h()};i.addEventListener("change",()=>m({message:i.checked?"Saving your consent…":"Turning reading off…",action:async()=>{l=await E({path:"/api/voice/consent",schema:Ht,body:{enabled:i.checked}}),c.textContent=l.consent?"Shadowclone may read your GitHub writing.":"Reading is off. Collected writing was discarded."}})),s.addEventListener("click",()=>m({message:"Reading your writing and asking your model. This can take a minute…",action:async()=>{let P=await E({path:"/api/voice/capture",schema:gn,body:{}});d=P.draft,w(P),c.textContent="Review the description and the invented examples."}})),u.addEventListener("click",()=>e.close());let S=g({tag:"button",className:"quiet-button",text:"My voice"});S.addEventListener("click",()=>{e.showModal(),m({message:"",action:async()=>{l=await E({path:"/api/voice/status",schema:Ht,body:{}})}}).catch(he)}),document.querySelector(".toolbar")?.append(S)}Ic();Oc();Tc();Dc();function je(){Jt({choose:(e)=>{if(b.activeId=e.id,e.owner!=="provider")Me(e);je()},chooseGroup:(e)=>{qa(e),je()}}),Ja({rerender:je,companion:rn}),tc(),_("undo").hidden=b.view?.revisionId===null}async function vd(e){let t=await E({path:`/api/build?scope=${e}`,schema:Ba});if(b.view=t,b.input=structuredClone(t.input),b.dirty=!1,!t.items.some((n)=>n.id===b.activeId))b.activeId=t.items.find(D)?.id??t.items[0]?.id??"";ue("scope").value=e;let r={global:"Your personal build follows you across coding agents.",private:"Only this repository. Stored privately on your machine; shared requirements stay in force.",shared:"A portable build for this repository. Review every file before sharing it with your team."};if(_("scope-note").textContent=r[e],_("library-note").hidden=t.libraryEnabled,t.migrationRequired)ee({message:"Your existing profile needs its reviewed skills migration before this build can be applied. You can explore the editor now."});je()}async function st(e){let t=_("constellation-status"),r=_("retry-build");if(!r.hidden)ee({message:""});t.hidden=!1,r.hidden=!0,_("constellation-status-text").textContent="Loading your skills…",_("constellation").setAttribute("aria-busy","true");try{await vd(e),t.hidden=!0}catch(n){throw _("constellation-status-text").textContent="Your skills couldn't be loaded. Retry to reconnect to the local editor.",r.hidden=!1,ue("scope").value=b.input.scope,n}finally{_("constellation").setAttribute("aria-busy","false")}}Ze({id:"retry-build",action:()=>st(b.input.scope)});Ze({id:"review",action:rc});Ze({id:"apply",action:async()=>{await nc(),await st(b.input.scope)}});Ze({id:"undo",action:async()=>{await oc(),await st(b.input.scope)}});_("new-skill").addEventListener("click",()=>rn());_("custom-form").addEventListener("submit",(e)=>{e.preventDefault();try{Va(),je()}catch(t){Pe(t instanceof Error?t.message:"The skill could not be added.")}});J("search").addEventListener("input",()=>{b.search=J("search").value,je()});ue("scope").addEventListener("change",()=>{if(b.dirty&&!window.confirm("Discard the draft and switch build scope?")){ue("scope").value=b.input.scope;return}let e=Ne.parse(ue("scope").value);Le(()=>st(e)).catch(he)});for(let e of document.querySelectorAll(".close-dialog"))e.addEventListener("click",()=>e.closest("dialog")?.close());window.addEventListener("beforeunload",(e)=>{if(b.dirty)e.preventDefault()});var jc=Ne.safeParse(new URLSearchParams(location.search).get("scope")??"global");zc();bc();ec();Zc();Le(()=>st(jc.success?jc.data:"global")).catch(he);
|